Skip to content

docs-infra: theming and dark mode#41129

Closed
AleksanderBodurri wants to merge 7 commits into
angular:masterfrom
AleksanderBodurri:aio-theming
Closed

docs-infra: theming and dark mode#41129
AleksanderBodurri wants to merge 7 commits into
angular:masterfrom
AleksanderBodurri:aio-theming

Conversation

@AleksanderBodurri

@AleksanderBodurri AleksanderBodurri commented Mar 9, 2021

Copy link
Copy Markdown
Member

Meant to continue the conversation from #40257.

This draft PR is a major refactor of the styles in https://angular.io/ in an effort to make aio themeable (primarily for a long awaited dark mode) and move towards using the sass module system.

The implementation is heavily inspired by the awesome folks who've worked on material.angular.io.

Previously styles were organized like this:

  • styles
    • 1-layout
      • _global_layout.scss
      • ...
    • 2-modules
      • _alert.scss
      • ...

This PR changes this structure to:

  • styles
    • 1-layout
      • global_layout
        • _global_layout.scss
        • _global_layout-theme.scss
      • ...
    • 2-modules
      • alert
        • _alert.scss
        • _alert-theme.scss
      • ...

Essentially splitting styling related to theming into separate files. Within each theme file is a scss mixin that takes in a material theme configuration and generates the appropriate styling for that theme and component.

Theme configurations are defined in: src/styles/custom-themes

Tooling that has been ported over from material.angular.io allows theme chunks to be lazy loaded.

The advantage of this approach:

  • Theming is contained to one file per component. Developers need only be aware of the existence of a single file when making theming related changes to a component
  • Moves away from using sass @imports that are no longer recommended by the sass team
  • Themes can be lazy loaded at runtime, preventing growth of the default styles chunk every time a new theme is implemented

disadvantages:

  • Splitting styles into theming files means duplication of some selectors, resulting in an increase of the default styles chunk size (in my testing this increase was about 2.6 KB on a prod build)

I'm opening this as a draft to request further technical review, and to start a conversation around what we want a potential dark mode to look like. This draft provides the tooling to make aio themeable, but does not provide an actual dark mode implementation. I didn't want to attempt an implementation without first getting direction from the design team.

EDIT: pushed a prototype dark mode implementation to iterate from.

EDIT: PR is ready to review 🔍

PR Type

What kind of change does this PR introduce?

  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)

Does this PR introduce a breaking change?

  • Yes
  • No

@mary-poppins

Copy link
Copy Markdown

You can preview dd399cf at https://pr41129-dd399cf.ngbuilds.io/.
You can preview e42dbd6 at https://pr41129-e42dbd6.ngbuilds.io/.
You can preview 8cd2a5c at https://pr41129-8cd2a5c.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 77ab271 at https://pr41129-77ab271.ngbuilds.io/.

@AleksanderBodurri

AleksanderBodurri commented Mar 12, 2021

Copy link
Copy Markdown
Member Author

Implemented a prototype dark mode to iterate from.

Unrelated but is the ";;" at the bottom of the page on https://angular.io/ supposed to be there? Noticed it while working on this.

Screen Shot 2021-03-12 at 3 08 49 PM

@gkalpak

gkalpak commented Mar 12, 2021

Copy link
Copy Markdown
Member

The ;; at the end are definitely not supposed to be there 😁
I accidentally introduced them in #41162 😇 They will be fixed by #41183.

@mary-poppins

Copy link
Copy Markdown

You can preview cee8e1f at https://pr41129-cee8e1f.ngbuilds.io/.

@AleksanderBodurri AleksanderBodurri force-pushed the aio-theming branch 2 times, most recently from b8a3a7d to 4931453 Compare March 13, 2021 03:00
@mary-poppins

Copy link
Copy Markdown

You can preview 4931453 at https://pr41129-4931453.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview f35ca19 at https://pr41129-f35ca19.ngbuilds.io/.

@AleksanderBodurri AleksanderBodurri changed the title [RFC] aio Theming aio Theming Mar 13, 2021
@mary-poppins

Copy link
Copy Markdown

You can preview 85b7010 at https://pr41129-85b7010.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 93c32fc at https://pr41129-93c32fc.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 083086a at https://pr41129-083086a.ngbuilds.io/.

@AleksanderBodurri

AleksanderBodurri commented Mar 13, 2021

Copy link
Copy Markdown
Member Author

Encountered a weird bug while working on this. When I install aio with the install prompt in the url bar, the installed aio opens as expected but when I click the toggle for dark mode all the content on the screen becomes invisible. On mac os chrome 89.0.4389.90. Confirmed that this does not happen on windows.

  1. Open https://pr41129-93c32fc.ngbuilds.io/
  2. Install with the "install app" prompt in the url bar
  3. Click the dark mode toggle.

Can anyone confirm being able to reproduce this on their end?

@mary-poppins

Copy link
Copy Markdown

You can preview 7927057 at https://pr41129-7927057.ngbuilds.io/.

@AleksanderBodurri AleksanderBodurri force-pushed the aio-theming branch 3 times, most recently from 66195fa to 9d79153 Compare May 25, 2021 02:24
@mary-poppins

Copy link
Copy Markdown

You can preview 9d79153 at https://pr41129-9d79153.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 93bf826 at https://pr41129-93bf826.ngbuilds.io/.

@AleksanderBodurri

AleksanderBodurri commented May 25, 2021

Copy link
Copy Markdown
Member Author

@gkalpak I think I've addressed most of your comments. There was one I was uncertain of so I left it open for clarification.

Appreciate the review 🙏 Let me know if theres anything else I can do for this PR.

@mary-poppins

Copy link
Copy Markdown

You can preview 9a73356 at https://pr41129-9a73356.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview c800bca at https://pr41129-c800bca.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview c918995 at https://pr41129-c918995.ngbuilds.io/.

brings in theming tools from material io into angular io in preparation of implementing darkmode
scss files were forwarded from files that were named without convention, changes these file names to follow conventions
…ad of the global imports

move away from using global constants in scss files because @import will be deprecated soon
…f global imports

move away from global mixins because @import is going to be deprecated
creates theming files for the aio typography styles; done as part of the effort to make aio themeable
creates theming files for the module styles in aio; done as part of the effor to make aio themeable
defines styles for a first iteration of an aio darkmode
@mary-poppins

Copy link
Copy Markdown

You can preview 7ca90ae at https://pr41129-7ca90ae.ngbuilds.io/.

@gkalpak gkalpak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for addressing all the comments, @AleksanderBodurri ❤️
I don't see anything that should block this PR. Incredible work 💯

I can't tell you how excited I am for this feature 🤤 🚀 🕙

:shipit:

@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels May 27, 2021
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants