metacpan / metacpan-web

Web interface for MetaCPAN
http://metacpan.org
Other
417 stars 237 forks source link

feature request: Dark mode #2182

Open Altreus opened 5 years ago

Altreus commented 5 years ago

Many developers have their environments set to a dark background. Having metacpan be the only brilliant white window in one's entire desktop environment is ouchy.

An alternative CSS using a darker colour scheme (and the option to save the preference) would be supreme.

clipland commented 5 years ago

In case this materializes, please implement theme-ability in a way that doesn't require one to be logged in.

Also a "classic" theme would be nice (shameless plug: just released add-on). Related issues: #1432, #278, #1360

oalders commented 5 years ago

I think this completely acceptable, but I don't see any of the core devs working on this since it's pretty low on our list of stuff that seems broken. I mean, I can't read their minds, but that's kind of my impression.

So, if someone else wants to do the heavy lifting, please do. Maybe hit us up with a plan before you sink a lot of time into it. https://github.com/metacpan/metacpan-docker

clipland commented 5 years ago

@Altreus If you're really impatient, you may use the same approach our yesterday-released Firefox Add-On uses, client-side overrides.

Just go there, fork and clone on github or just clone locally, and replace/copy into the core .js file what I've quickly hacked up for you during break:

var styles = "body, .autocomplete-suggestion { background-color: #727272 !important; color: #0a0a0a !important; }";
styles    += "a, a:hover, a:visited { color: #fa4; }";
styles    += ".navbar-default .navbar-nav > li > a { color: #da2037; }";
styles    += "li.active a { background-color:#727272 !important; border-top-color: #fa4 !important; box-shadow: inset -1px 0px 0 #000, inset 1px 0px 0 #000 !important; }";
styles    += "input { background: #b0b0b0 !important; background-image: linear-gradient(#999, #b0b0b0) !important; border-color: #393939 !important; color: #020202 !important; } ";
styles    += ".btn { background-image: linear-gradient(#a6a6a6, #8a8a8a) !important; border: 1px solid #393939; border-radius: 4px; color: #020202; text-shadow: none; }";
styles    += ".alert { background-color: #a6a6a6 !important; border-color: #b0b0b0 !important;  }";
styles    += ".navbar { background-color: #393939 !important; color: #fff !important; border-color: #000 !important; border-top-color: #000 !important; }";
styles    += ".content { border-left-color: #000 !important; }";
styles    += ".description { color: #161616 !important; }";
styles    += "pre { background-color: #b0b0b0 !important; }";

var styleSheet = document.createElement("style");
styleSheet.type = "text/css";
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);

Then load it as temporary add-on or generate a self-signed .xpi and you'll have this here: (Color-scheme is based on fabulous Blender.) screenshot If you're not using FF, but another browser (oh no, ...), it should be easily adaptable.

These overrides are admittedly hackish/heavy-handed and you might see flashes of the old white layout. The overall approach to override the original stylesheets isn't so smart in general! Yet still, a client-side setting via a browser-extension/web-storage/localstorage might be a good the best way to implement a theme-switcher for MetaCPAN without requiring a login/cookies and being light on resources.

CaseOf commented 5 years ago

@clipland Do you think it can be set with a simple css theme for Stylus?

To something like that:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("metacpan.org") {
  body, .autocomplete-suggestion {
    background-color: #727272 !important; color: #0a0a0a !important;
  }
  a, a:hover, a:visited {
    color: #fa4;
  }
  .navbar-default .navbar-nav > li > a {
    color: #da2037;
  }
  li.active a {
    background-color:#727272 !important; border-top-color: #fa4 !important; box-shadow: inset -1px 0px 0 #000, inset 1px 0px 0 #000 !important;
  }
  input {
    background: #b0b0b0 !important; background-image: linear-gradient(#999, #b0b0b0) !important; border-color: #393939 !important; color: #020202 !important;
  }
  .btn {
    background-image: linear-gradient(#a6a6a6, #8a8a8a) !important; border: 1px solid #393939; border-radius: 4px; color: #020202; text-shadow: none;
  }
  .alert {
    background-color: #a6a6a6 !important; border-color: #b0b0b0 !important;
  }
  .navbar {
    background-color: #393939 !important; color: #fff !important; border-color: #000 !important; border-top-color: #000 !important;
  }
  .content {
    border-left-color: #000 !important;
  }
  .description {
    color: #161616 !important;
  }
  pre {
    background-color: #b0b0b0 !important;
  }
}
clipland commented 5 years ago

Stylus, the FF Add-On? Well, I guess that's essentially the same. ;) Both solutions inject override CSS rules.

ThisUsedToBeAnEmail commented 4 years ago

volunteering and I've made a start over the past couple of days.

Screenshot 2020-10-01 at 09 11 44 Screenshot 2020-10-01 at 09 15 13
clipland commented 4 years ago

Congrats! Nice color scheme. Even nicer: it seems configurable. Am I right in assuming (from first screencap) you came up with some sort of client-side config, relying on web-storage/localstorage/(browser-extension) - not requiring a login? Would be great.

ThisUsedToBeAnEmail commented 4 years ago

Yes, the plan is to make everything configurable, I also want to add functionality to change font size and family.

Currently I am using local storage to cache the account profile so that I don't need to make an API request per page refresh.

As I mentioned I am using an api and storing this against the author document. The reason I'm doing this is because I would like persistency between my devices, however I'll welcome more opinions on this.

haarg commented 4 years ago

I really don't think we should have this be configurable on a per color basis. If someone wants to tweak individual colors, they can already do that with user stylesheets.

Having a dark mode seems reasonable.

ThisUsedToBeAnEmail commented 4 years ago

I'm not finished going through every page yet but currently you can configure the following colours:

Screenshot 2020-10-01 at 13 48 29

I'm open to removing this and only having the dark mode switch, I would like some more opinions though.

Here are some more screenshots:

Screenshot 2020-10-01 at 13 50 00 Screenshot 2020-10-01 at 13 51 36 Screenshot 2020-10-01 at 13 54 08
oalders commented 4 years ago

That looks really good!

konstantinos-giannakakis commented 3 years ago

Hello! Any progress with this feature? Still could be pretty useful.

oalders commented 3 years ago

Thanks for the nudge. I've asked internally about what we need to do to get this merged.

ThisUsedToBeAnEmail commented 3 years ago

If you want something you can use now I wrote an extension:

https://chrome.google.com/webstore/detail/metacpantheme/dmdmhdilgmmdnklgdnokgfcfnbegfkil?hl=en https://addons.mozilla.org/en-US/firefox/addon/meta-cpan-theme/

clipland commented 3 years ago

Note to anyone following/reading this: please make it standards conformant and not reliant on logins/auth of some sort.

Altreus commented 3 years ago

+1 for the prefers-color-scheme feature. I think browsers can read the system preferences on OSes that support it, and feed that through, so if you've got your OS set to dark mode the browser will ask the site to prefer dark mode.

akarelas commented 1 month ago

One of the few big sites that still don't support dark mode. And it's so easy to implement (if you already know the colors to use).

oalders commented 1 month ago

I would love to see dark mode as well, but someone needs to step up and volunteer the time.

Grinnz commented 1 month ago

I can recommend this snippet from the bootstrap docs as a nice way to auto detect as well as save the color preference in local storage. Styling of course would all have to be figured out specific to MetaCPAN. https://getbootstrap.com/docs/5.3/customize/color-modes/#javascript

akarelas commented 1 month ago

Even a simple "follow system's color mode" would be great - can be done with plain CSS. See https://karelcom.net

oalders commented 1 month ago

If there's a PR, we are happy to review it.

akarelas commented 2 weeks ago

I really think this should be set as first-priority. I think it's one of those things that separates neanderthal websites from active ones (according to the average modern web-user). I mean, people will see it.