Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New landing page, prefers-color-scheme, prefers-reduced-motion #343

Merged
merged 8 commits into from
Jul 22, 2020

Conversation

0xdade
Copy link
Member

@0xdade 0xdade commented Jul 6, 2020

This will close #340.

I think it's ready for consideration.

  • New landing page that also has support for login/reg if required.
  • prefers-color-scheme is now honored and a dark theme is offered when requested
  • prefers-reduced-motion is now honored and animation is reduced to a minimum when set
  • Restructure a bunch of css into subpages
  • Update stylelint rules to work with scss
  • Update codeclimate to use stylelint
  • stylelint in pre-commit hooks

@0xdade 0xdade added enhancement New feature or request server affecting natlas-server javascript Pull requests that update Javascript code labels Jul 6, 2020
@codeclimate
Copy link

codeclimate bot commented Jul 6, 2020

Code Climate has analyzed commit 5ad528f and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

View more on Code Climate.

Copy link
Member

@ajacques ajacques left a comment

Choose a reason for hiding this comment

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

First Pass

natlas-server/app/static/natlas.js Outdated Show resolved Hide resolved
natlas-server/app/static/natlas.scss Outdated Show resolved Hide resolved
natlas-server/app/templates/user/profile.html Show resolved Hide resolved
natlas-server/app/static/conf/particles-active.json Outdated Show resolved Hide resolved
natlas-server/app/static/natlas.js Outdated Show resolved Hide resolved
natlas-server/app/static/natlas.scss Outdated Show resolved Hide resolved
@0xdade 0xdade force-pushed the new_homepage branch 6 times, most recently from b4c3cb3 to e4817f7 Compare July 6, 2020 07:41
@0xdade 0xdade linked an issue Jul 6, 2020 that may be closed by this pull request
@0xdade
Copy link
Member Author

0xdade commented Jul 8, 2020

Accidentally upset codeclimate again because stylelint has some issues with @mixin and @include despite claiming it has support for scss. But now that I've done all this again, I think it actually makes the most sense to do color-theme switches with native css variables instead of scss variables. This codepen has a pretty good example, showing that we can set variables based on a selector matching or not. This should reasonably be able to extend to media queries, too, and also allows us to make other themes more easily in the future if we want.

@0xdade 0xdade marked this pull request as ready for review July 14, 2020 03:00
@0xdade 0xdade requested a review from ajacques July 14, 2020 03:00
@0xdade 0xdade force-pushed the new_homepage branch 3 times, most recently from 5c744c3 to 94e0c09 Compare July 15, 2020 07:57
natlas-server/app/static/conf/particles-active.ts Outdated Show resolved Hide resolved
natlas-server/app/static/css/components/host-row.scss Outdated Show resolved Hide resolved
natlas-server/app/static/css/globals.scss Outdated Show resolved Hide resolved
natlas-server/app/static/css/pages/landing.scss Outdated Show resolved Hide resolved
Comment on lines +1 to +11
export function getReducedMotion(): MediaQueryList {
return window.matchMedia('(prefers-reduced-motion: reduce)');
}

export function getDarkMode(): MediaQueryList {
return window.matchMedia('(prefers-color-scheme: dark)');
}

export function getLightMode(): MediaQueryList {
return window.matchMedia('(prefers-color-scheme: light)');
}
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about these names that are a bit more intuitive?

doesUserPreferReducedMotion()
isDarkMode
isLightMode

Copy link
Member Author

Choose a reason for hiding this comment

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

I originally used a isDarkMode and isLightMode but that, to me, implies a boolean response, which right now is inaccurate. I could return .matches which then gives us a boolean, but makes it so you can't register event handlers on it if you so choose.

@@ -0,0 +1,47 @@
import 'particles.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest tsParticles https://github.com/matteobruni/tsparticles instead of this obsolete library. You'll have less CPU usage client-side and tsParticles it's written in TypeScript. You can have also more configurations

@0xdade 0xdade merged commit 376cfd5 into natlas:main Jul 22, 2020
@0xdade 0xdade deleted the new_homepage branch July 22, 2020 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code server affecting natlas-server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for prefers-color-scheme
3 participants