-
Notifications
You must be signed in to change notification settings - Fork 50
[04-Part2] [Project Solar / Phase 1 / Showcase] Add support for theming and theme-switching to the showcase #3390
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
base: project-solar/phase-1-main-feature-branch
Are you sure you want to change the base?
Conversation
…ith `—shw` CSS variables)
…nd be open to configurations
…clusion of pre-compiled (standard and themed) CSS The pre-compiled CSS files have been manually copied in the `public/assets` folder, while waiting to understand what is the best way to proceed to have them added at build time from the `@hashicorp/design-system-components` package
…tion and expand use cases we can cover
…relying on HDS selectors)
…ackage.json` solution: run `pnpm prettier . --cache --write` locally and then commit
… “themed” `—shw` colors
…o `hdsTheming` service
…d `ShwBodyLinkToRoute` component
…oid collisions between the main page and the frame
…ers-color-scheme` application only to the explict `system` theme selection
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
per Copilot suggestion: #3240 (comment)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements comprehensive theming support for the Helios Design System, including theme switching capabilities in both the HDS components library and the showcase application. The changes enable light/dark theme support with multiple implementation options (CSS selectors, system preferences) and provide developer tools for testing and demonstrating theming functionality.
Key Changes
- Added
hdsThemingservice for managing theme state and options - Implemented
HdsThemeSwitcherandHdsThemeContextcomponents for theme control - Created showcase-specific theming infrastructure with
shwThemingservice and controls - Added a dedicated "Foundations > Theming" showcase page with demos and examples
Reviewed changes
Copilot reviewed 68 out of 70 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/services/hds-theming.ts | Core theming service managing theme state and localStorage persistence |
| packages/components/src/components/hds/theme-switcher/index.ts | Theme switcher dropdown component implementation |
| packages/components/src/components/hds/theme-context/index.ts | Headless component for applying contextual themes |
| showcase/app/services/shw-theming.ts | Showcase theming service extending HDS theming |
| showcase/app/components/shw/theme-switcher/index.gts | Showcase theme switcher with advanced options |
| showcase/app/index.html | HTML head updates for multiple stylesheet support |
| showcase/app/styles/showcase-theming/index.scss | Showcase-specific themed color variables |
| showcase/public/assets/styles/@hashicorp/themed-tokens/ | Temporary CSS files for testing different theming approaches |
showcase/public/assets/styles/@hashicorp/themed-tokens/with-css-selectors/tokens.css
Show resolved
Hide resolved
showcase/public/assets/styles/@hashicorp/themed-tokens/with-css-selectors--migration/tokens.css
Show resolved
Hide resolved
showcase/public/assets/styles/@hashicorp/themed-tokens/with-css-selectors--migration/tokens.css
Show resolved
Hide resolved
showcase/public/assets/styles/@hashicorp/themed-tokens/with-css-selectors--advanced/tokens.css
Show resolved
Hide resolved
showcase/public/assets/styles/@hashicorp/themed-tokens/with-css-selectors--advanced/tokens.css
Show resolved
Hide resolved
showcase/app/components/page-foundations/theming/sub-sections/theme-switcher.gts
Show resolved
Hide resolved
…ervice` to make it more robust
Important
This PR is the same as #3240 but because it was accidentally closed, we need to continue the review process in this second PR.
📌 Summary
This PR contains multiple pieces of the "theming" puzzle:
HDS Components:
hdsThemingserviceHdsThemeSwitchercomponentHdsThemeContextcomponentShowcase
shwThemingservice and set of showcase controls to switch theming (and theming options) plus the CSS file linked in the applicationThis is based on top of #3259
🛠️ Detailed description
The first commits are a direct porting of previous showcase theming explorations (squashed):
After the initial cherry picking of code, there's been a lot of back and forth / refactorings, with different attempts in reaching an implementation that could (hopefully) withstand how different teams may want to adopt theming in their codebases. For this reason, the bulk of the work has been around finding the right "location" for the different pieces of logic, the different concerns: what goes into the HDS theming service vs the SHW theming service; how theming preferences are expressed in the UI and controlled by the user; how consumers decisions are reflected and stored and passed over between HDS/SHW services and components; how a user would use the theming controls (including a showcase user/developer/designer) and how a consumer would allow that user to interact with the application.
It's impossible to describe in detail all the code changes and implementations introduced in this PR, you have to look at diff in code, the showcase application, the "how to review" and "how to test" sections below, and try to get a general picture of what went into this PR.
👉 👉 👉 Preview: theming page
🔎 How to review
This is a quite large PR (we may consider splitting it). I would suggest to look at a piece of code/logic (eg. HDS theming service), see how this interacts with the rest of the code (in HDS and/or in the showcase), and in parallel I would try to see in the showcase application how this logic is reflected in the UI, and try to interact with it to see what happens.
The "logical" order in which I would look at things is this:
hdsThemingservice and theHdsThemeSwitcherandHdsThemeContextcomponents underpackages/componentsshwThemingservice undershowCaseand see how it's an extension of thehdsThemingShwThemeSwitchercontrols (component and sub-components) and see how they're using internally both thehdsThemingandshwThemingservices, how the "current" theming options are reflected in the services and in the controls values/states, what happens when a control value is updated/applied, etcfoundations/themingshowcase page, and its sectionsHdsThemSwitchercomponentpublic/assets/styles/@hashicorp/folder, in particular the CSS selectors, and see if they make sense🛠️ How to test
Launch the showcase application locally, then visit the "Foundations > Theming" page. Here play with the controls in the top right of the page, and see how changing them impacts the page:
If you want to double check how the tokens and their values are applied depending on the chosen theme/options, you can update the colors in the temporary/testing CSS files under the
public/assets/styles/@hashicorp/folder (see the CSS variables under theadded these to test theming in the showcasecomment)🔗 External links
Jira tickets:
👀 Component checklist
mainyet to avoid having issues in testing with the (breaking) version5.0+in the consumers' codebasesA changelog entry was added via Changesets if needed (see templates here)💬 Please consider using conventional comments when reviewing this PR.
📋 PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.