Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Lightweight dark mode #167

Closed

Conversation

anthonyringoet
Copy link

Added a lightweight dark mode. Can certainly be improved, only used some CSS overrides.

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

@anthonyringoet
Copy link
Author

Linking to #79

@anthonyringoet
Copy link
Author

Screenshot_2020-05-04 Fastify, Fast and low overhead web framework, for Node js

@@ -269,3 +275,89 @@ a > code {
.media.v-center {
align-items: center;
}

// lightweight dark mode using some overrides
@media (prefers-color-scheme: dark) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a solution with css variables

@media (prefers-color-scheme: dark) {
	:root {
	  --main-bg-color: dark;
	}

}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is possible for the custom CSS like overriding body background. To override the third-party CSS (eg. Bulma panel and card) you'll still have to overwrite the imported rules afaik. Bulma supports customization but only at compile time with SASS variables afaik.

Is that what you're aiming for here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but did you try this

// create css variables
$black_value:        hsl(0, 0%, 4%) !default;
// assign css property to bulma variables
$black:         var(--color-black);


// Framework code will work with css property notation
div {
  background-color: #{$black};
}
// Framework code end

// Create css variables
:root {
  --color-black: #{$black_value};
}

produces

div {
  background-color: var(--color-black);
}

:root {
  --color-black: #0a0a0a;
}

this should work as long as no other transform functions are applied on $black

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zekth
Copy link
Member

zekth commented Sep 25, 2021

@anthonyringoet could you rebase it and land this? Also we might want a switch for light/dark theme in the future

@anthonyringoet
Copy link
Author

@zekth rebased the changes from upstream, feel free to check again

@zekth
Copy link
Member

zekth commented Sep 28, 2021

@StarpTech can you recheck it?

@anthonyringoet
Copy link
Author

@StarpTech @zekth No need to waste your time rechecking it. FYI, only had time to rebase and check these incoming changes. Did not have the time to add the requested changes.

@Eomm
Copy link
Member

Eomm commented Jun 27, 2023

Closing for https://github.com/fastify/website-next

@Eomm Eomm closed this Jun 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants