Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
232 commits
Select commit Hold shift + click to select a range
2437dbc
TODO - added temporary file to main feature branch for phase 1
didoo Sep 25, 2025
9379907
added temporary changeset to feature branch for `$modes` support
didoo Sep 15, 2025
855350c
TEMP - added `$modes` entry to `color.palette.neutral-0`
didoo Sep 15, 2025
f2efecd
refactored logic used to provide SD configuration per target
didoo Sep 15, 2025
41ac1b4
progress on logic for handling `$modes` - 1
didoo Sep 16, 2025
8abb950
TEMP - added `modes-testing` tokens
didoo Sep 16, 2025
48229f4
TEMP - added `expected-CSS-output` files
didoo Sep 16, 2025
13b5335
progress on logic for handling `$modes` - 2
didoo Sep 16, 2025
08160c6
added `attributes/themeable` transformation
didoo Sep 16, 2025
b350e26
progress on logic for handling `$modes` - 3
didoo Sep 16, 2025
f98d74e
TEMP - used local version of Style Dictionary for debugging
didoo Sep 17, 2025
0c2ee28
progress on logic for handling `$modes` - 4
didoo Sep 17, 2025
ff6ab43
TEMP generated temporary dist files for testing
didoo Sep 16, 2025
3ebac47
TEMP - added examples of generated themed tokens
didoo Sep 19, 2025
d5ee7ad
added logic to generate theming CSS files
didoo Sep 19, 2025
84e4c74
REVERT - Removed `modes-testing` tokens
didoo Sep 30, 2025
d97c7f7
removed `modes-testing` folder from compilation
didoo Sep 30, 2025
57dedbd
added `carbon-extracted` reference in the `source` definitions
didoo Sep 30, 2025
47f28ab
TEMP - added `$modes` entries for some color and typography tokens, w…
didoo Sep 30, 2025
acd4015
changed `outputReferences` to `false` (temporary) to bypass issue wit…
didoo Sep 30, 2025
2268dc9
added commented code to `build` to use for debugging issue with missi…
didoo Sep 30, 2025
6213739
added two new themed tokens generated files, for Scss mixins and for …
didoo Oct 2, 2025
716d14e
fixed issue with `cds` naming missing the `g`
didoo Oct 7, 2025
1fce318
fixed some issues with how the β€œextra” themed CSS files were generated
didoo Oct 7, 2025
557b0eb
TEMP - Re-generated tokens
didoo Sep 30, 2025
699acb9
REVERT - used local version of Style Dictionary for debugging
didoo Oct 9, 2025
09dd74d
REVERT - added examples of generated themed tokens
didoo Oct 9, 2025
d7bf8df
REVERT - added `expected-CSS-output` files
didoo Oct 9, 2025
cb8b409
fixed wrong check for existence of key in object (`0` values would tr…
didoo Oct 27, 2025
afbe333
added `.hds-theme-light/dark` and `[data-hds-theme=β€œlight/dark”]` to …
didoo Oct 27, 2025
eb8bb1e
re-generated themed tokens
didoo Oct 27, 2025
d082f01
updated generation of tokens’ CSS helpers to use CSS variables for `f…
didoo Oct 27, 2025
b00bcd4
re-generated CSS helper files
didoo Oct 27, 2025
5b7a1d8
updated generation of extra CSS files to include `.hds-theme-hds/[dat…
didoo Oct 28, 2025
272cb3f
updated design tokens pipeline to generate a `themed-tokens.json` fil…
didoo Oct 28, 2025
5a28a4e
re-generated themed tokens
didoo Oct 27, 2025
2a1183e
updated β€œsrc” files to replace `hds` key with `default` in `$modes` d…
didoo Nov 6, 2025
8e698cc
updated logic to replace `hds` key with `default` in `$modes` definit…
didoo Nov 6, 2025
595c3cb
re-generated tokens in `dist` folder
didoo Nov 6, 2025
f331e76
tweaked logic for CSS selectors for `@media (prefers-color-scheme)` t…
didoo Nov 7, 2025
24ce7e5
re-generated tokens in `dist` folder
didoo Nov 7, 2025
7fafde9
updated generation of extra theming CSS files to avoid CSS variables …
didoo Nov 12, 2025
a0acd85
updated generation of extra theming CSS files to differentiate betwee…
didoo Nov 14, 2025
b7ff42f
re-generated tokens in `dist` folder
didoo Nov 14, 2025
9915431
removed `[data-hds-theme]` CSS selectors for simplicity
didoo Nov 17, 2025
2233feb
re-generated tokens in `dist` folder
didoo Nov 17, 2025
140d7b6
updated logic for generation of extra β€œthemed” CSS files (removed `pr…
didoo Nov 18, 2025
453011c
re-generated tokens in `dist` folder
didoo Nov 18, 2025
eead131
small tweakings before code review
didoo Nov 20, 2025
77b3147
renamed `generateExtra***` to `generate***`
didoo Nov 20, 2025
876db98
updated comment
didoo Nov 21, 2025
f97ce91
Draft a custom plugin to compile the themed SCSS
alex-ju Sep 24, 2025
cba2971
updated SCSS files organization for components (split common part) + …
didoo Sep 26, 2025
eb55e46
added support for source maps for generated themed CSS files
didoo Sep 29, 2025
5af5a0a
TEMP - Added generation of β€œalt” CSS for HDS components to compare wi…
didoo Sep 30, 2025
27bdbd6
abstracted logic for custom Rollup plugin to compile multiple Sass fi…
didoo Sep 30, 2025
8875e25
updated `includePaths` for design tokens in Showcase and Website `emb…
didoo Sep 30, 2025
3bae73f
moved compilation of existing Scss files for components and overrides…
didoo Sep 30, 2025
268e587
removed `rollup-plugin-scss` dev dependency (we use our own custom pl…
didoo Sep 30, 2025
b9c59d3
added CSS compilation for `combined-strategies` tokens
didoo Oct 2, 2025
269e0a4
updated the `prePublish` script in `package.json` of `components` to …
didoo Oct 15, 2025
a89f813
simplified architecture of CSS compilation for HDS components (as agr…
didoo Oct 24, 2025
5f273d7
fixed `prepublisOnly` script that was causing error in build (looking…
didoo Oct 24, 2025
764b41c
updated `cssFilePath` in blueprints to reflect new Scss file organiza…
didoo Oct 29, 2025
ab12e38
Apply suggestions from code review
didoo Nov 20, 2025
9f55897
Update packages/components/src/styles/@hashicorp/design-system-compon…
didoo Nov 21, 2025
c12c9a6
added `Hds::ThemeSwitcher` component
didoo Sep 30, 2025
21007a8
added `Hds::Theming` service
didoo Sep 30, 2025
8bc5fe4
added theming to the Showcase itself (and replaced hardcoded values w…
didoo Sep 30, 2025
2ea2b33
added `Shw::ThemeSwitcher` component for showcase
didoo Sep 30, 2025
bc2b868
updated `Mock::App` and added new yielded sub-components
didoo Sep 30, 2025
80411c0
added `Shw:: ThemeSwitcher` to the Showcase page header
didoo Sep 30, 2025
28fcdc8
added `foundations/theming` showcase page (and a frameless demo)
didoo Sep 30, 2025
87f42e5
refactored `hds-theming` service to align with the new themes/modes a…
didoo Oct 1, 2025
52eb07d
added `hdsTheming` initialization to main showcase app
didoo Oct 1, 2025
9451129
removed compilation of components Scss and replaced it with static in…
didoo Oct 3, 2025
f063a8c
added theming options via popover - part 1
didoo Oct 3, 2025
3022e34
added theming options via popover - part 2
didoo Oct 3, 2025
7232e05
added theming options via popover - part 3
didoo Oct 3, 2025
2214da0
added theming options via popover - part 4
didoo Oct 4, 2025
cabf840
added theming options via popover - part 5
didoo Oct 6, 2025
610c79d
big code refactoring for the theme selector, to streamline user selec…
didoo Oct 6, 2025
3e2870f
updated logic that sets the theming for the showcase itself (without …
didoo Oct 7, 2025
3c19815
small fixes here and there for cleanup and linting
didoo Oct 10, 2025
d827507
fixed issue with `pnpm lint:format` (missing newline at the end of `p…
didoo Oct 10, 2025
4fd49e8
fixed accessibility issue in `advanced-table` page, due to changes to…
didoo Oct 10, 2025
a1a197d
fixed typescript error due to new mock page being added
didoo Oct 10, 2025
9fa1477
added fix for tests failing
didoo Oct 13, 2025
b1ea4b5
started large refactoring/rewrite of the theming switcher and page in…
didoo Oct 14, 2025
a8e0af1
updated logic by creating a `shwTheming` service that extends `hdsThe…
didoo Oct 15, 2025
b676ca1
moved theming logic from `ShwThemeSwitcher` component/subcomponents t…
didoo Oct 15, 2025
a288b54
updated reference CSS files to follow new theming approach/logic
didoo Oct 16, 2025
045c9f4
further refactoring/rewriting of theming logic
didoo Oct 16, 2025
b26b167
updated approach to `light/dark` styles in showcase by using the HDS …
didoo Oct 17, 2025
5ec03f5
migrated back the `Contextual` demo content to the index page
didoo Oct 17, 2025
7a0c44d
added a `DebuggingPanel` to the `ShwThemeSwitcher` controls
didoo Oct 17, 2025
563de6b
refactored/improved `DebuggingPanel` and added new preferences to adv…
didoo Oct 17, 2025
9b6e22a
small cleanups and refactorings
didoo Oct 17, 2025
6f82ba5
fixed small issue with `ShwThemeSwitcher` selector
didoo Oct 20, 2025
94c4e94
removed some outdated comments
didoo Oct 20, 2025
d71c910
small refactorings
didoo Oct 20, 2025
df63428
added local storage support for theming options
didoo Oct 20, 2025
53e8849
big refactoring of the `hdsTheming` service to simplify logic and red…
didoo Oct 20, 2025
6a4d1d7
cleanup of debugging comments and other stuff
didoo Oct 20, 2025
be9ea6a
refactor and cleanup in preparation for PR review
didoo Oct 21, 2025
205ba8e
refactored code to fix logic flow for theming initialization
didoo Oct 21, 2025
6615dc2
fixed how the theming options were saved in local storage
didoo Oct 21, 2025
ce4a126
Apply suggestions from Copilot's code review
didoo Oct 21, 2025
a1ad917
fixed issue with `setTheme` not being passed `options` by the `ShwThe…
didoo Oct 22, 2025
187d37d
fix issue with the popover of the ShwThemeSwitcher component, where t…
didoo Oct 22, 2025
3b38076
Update showcase/app/services/shw-theming.ts
didoo Oct 23, 2025
ec80c12
small tweak to the typing of `HdsModes` per code review suggestion
didoo Oct 23, 2025
4686fa3
updated how the CSS files (tokens and components, with/without themin…
didoo Oct 24, 2025
b6a7812
updated logic for styleshet switching using the `disabled` attribute
didoo Oct 24, 2025
4df5e6b
removed unused import
didoo Oct 24, 2025
f89ceca
removed `isInitialized` logic from the `hdeTheming` service to avoid bug
didoo Oct 24, 2025
ea77ff8
TEMP - added temporary `hds-theme-light/dark` selectors
didoo Oct 24, 2025
cf4150d
TEMP - Added back custom token values for testing purpose
didoo Oct 24, 2025
7c4be3f
fixed small issue with the `HdsThemeSwitcher` components used in the …
didoo Oct 29, 2025
00030e9
added small comment
didoo Oct 29, 2025
71b6880
updated `hdsTheming` service to support `default` theme / mode
didoo Nov 7, 2025
72a156d
added support for `default` option to HDS ThemeSwitcher component
didoo Nov 7, 2025
bdd9b8f
Updated β€œfoundations/theming” showcase page to include variants of HD…
didoo Nov 7, 2025
729f043
updated Showcase ThemeSwitcher to use ``default` as theme option
didoo Nov 7, 2025
bd71fb2
updated logic for how CSS selectors are applied to the `html:root` el…
didoo Nov 7, 2025
862d28d
updated CSS selectors for local `public/assets` themed tokens CSS fil…
didoo Nov 7, 2025
2c23e8f
added fake theming for display/text typography to `public/assets` the…
didoo Nov 7, 2025
2d0d3e8
updated β€œfoundations/theming” showcase page to include `default` and …
didoo Nov 7, 2025
5a00c72
implemented `ThemeContex` component
didoo Nov 13, 2025
f2a6974
added demos of `ThemeContext` component to showcase β€œfoundations/them…
didoo Nov 13, 2025
c68a900
improved type definitions for ThemeContext and showcase β€œfoundations/…
didoo Nov 13, 2025
e5807de
refactored how CSS selectors are applied to enable mode-specific over…
didoo Nov 14, 2025
9dbcc14
updated CSS selectors for local `public/assets` themed tokens CSS fil…
didoo Nov 14, 2025
6a5e199
updated `ThemeContext` to use a more generic `context` argument
didoo Nov 14, 2025
643b703
updated showcase β€œtheming” page to use the new `@context` argument fo…
didoo Nov 14, 2025
5d15e8d
finally defined proper typing for `ThemeContext` component
didoo Nov 14, 2025
8f82c7f
refactored showcase code to remove handling of `[data-hds-theme]` CSS…
didoo Nov 17, 2025
49d9da7
updated CSS selectors for local `public/assets` themed tokens CSS fil…
didoo Nov 18, 2025
7fe2cb2
refactored theme switching in showcase to use new CSS files
didoo Nov 18, 2025
187872f
updated theme switcher in showcase to allow toggling of the β€œadvanced…
didoo Nov 18, 2025
73e10ca
introduced a β€œcarbonization” mixin for applying styles only for certa…
didoo Nov 19, 2025
d26548b
added subtle shadow to `ThemingBasicContainer`
didoo Nov 19, 2025
ab9d395
fixed small bug that would cause the showcase pages to crash if the v…
didoo Nov 19, 2025
657f913
small fix to the control logic for the `HdsThemeSwitcher` demo in sho…
didoo Nov 18, 2025
db2b49b
fixed TypeScript issue
didoo Nov 20, 2025
14d91f9
fix small bug in the logic when the β€œapply” with β€œshow advanced optio…
didoo Nov 20, 2025
8f0c147
added `ShwBodyLinkToRoute` component
didoo Nov 20, 2025
5dc663c
replaced custom link in AdvancedTable showcase page with newly create…
didoo Nov 20, 2025
7f58e0b
reworked the demo frameless for application with theme switcher to av…
didoo Nov 20, 2025
9e1be4c
replaced custom theme switcher with proper `HdsThemeSwitcher` in `App…
didoo Nov 21, 2025
26d892c
some cleanup before code review
didoo Nov 21, 2025
3a388ee
changed how theming is applied to the showcase itself, to limit `pref…
didoo Nov 25, 2025
e0b4a13
fixed wrong CSS selector, per code review suggestion
didoo Nov 25, 2025
f8d253d
prefixed `OnSetThemeCallback` with `Hds` per review suggestion
didoo Nov 25, 2025
6d6a6ef
Update packages/components/src/template-registry.ts
didoo Nov 25, 2025
19e497f
converted `updatePageStylesheets` function to a private method
didoo Nov 26, 2025
acb85e9
small cleanup per code reviews suggestions
didoo Nov 26, 2025
bb3810e
small fixes per code review
didoo Nov 28, 2025
1def0b3
updated logic that reads the stored theming data for the `HdsThemingS…
didoo Nov 28, 2025
313bc50
removed comment
didoo Dec 2, 2025
755b55c
updated CSS selectors for local `public/assets` themed tokens CSS fil…
didoo Nov 18, 2025
8aba763
basic implementation of `<ShwCarbonizationComparisonGrid>`
didoo Sep 23, 2025
7028ae2
refactored implementation of `<ShwCarbonizationComparisonGrid>`
didoo Sep 23, 2025
1d8b864
implemented β€œCarbonization” section for `Badge` page
didoo Sep 23, 2025
11237dd
implemented β€œCarbonization” section for `BadgeCount` page
didoo Sep 23, 2025
c284040
implemented β€œCarbonization” section for `Button` page
didoo Sep 23, 2025
6b70151
implemented β€œCarbonization” section for `Focus Ring` page
didoo Sep 24, 2025
ee87029
implemented β€œCarbonization” section for `Typography` page
didoo Sep 24, 2025
c090df2
implemented β€œCarbonization” section for (new) `Color` page
didoo Sep 24, 2025
77150b0
added `@carbon/web-components` as devDependency to Showcase app
didoo Sep 24, 2025
f03e46d
added `@carbon/[themes|layout|grid|type]` + `@ibm/plex` as devDepende…
didoo Sep 25, 2025
4cc3cb8
refactored `ComparisonGrid` component to add themed background color …
didoo Sep 25, 2025
3a35512
added temporary support for IBM Plex font-family
didoo Sep 25, 2025
823e41c
refactored code to support theming for reference web components, base…
didoo Sep 25, 2025
20585c8
small refactoring
didoo Sep 25, 2025
9c97d22
small refactorings
didoo Sep 25, 2025
b0c66c4
refactored content organization to have the carbonization pages as st…
didoo Sep 25, 2025
d1e7f2a
added carbon web components for comparison on `BadgeCount` page
didoo Oct 7, 2025
a000828
added carbon web components for comparison on `Button` page
didoo Oct 7, 2025
aab0746
more small fixes for cleanup and linting
didoo Oct 10, 2025
0c8cd69
implemented β€œCarbonization” section for `Form::TextInput` page
didoo Oct 21, 2025
c6bba18
implemented β€œCarbonization” section for `SegmentedGroup` page
didoo Oct 14, 2025
b93fb9f
removed link to β€œFoundations > Color” page
didoo Oct 21, 2025
d3f1f0b
Small update to an `rgba` color
didoo Oct 21, 2025
9e131ec
moved theming class in ComparisonGrid from item to item content per c…
didoo Oct 23, 2025
9bfa7b5
improved how to apply themed foreground/background colors to content …
didoo Oct 23, 2025
7cbce09
installed `@carbon/styles` as devDependency to import CSS variables f…
didoo Oct 23, 2025
1730d35
fixed issue with text color in typography page
didoo Nov 21, 2025
05fb2ad
reorganized carbonized pages so they all live under the `carbonized` …
didoo Oct 23, 2025
9d7e273
prepared the ground for controlling the ShwThemeSwitcher on carbonize…
didoo Oct 23, 2025
96cb68b
fixed CSS for carbonization pages
didoo Oct 23, 2025
da499eb
updated carbonized typography page to show equivalent/mapped Carbon t…
didoo Oct 24, 2025
ce4ba50
updated `ShwComparisonGrid` to expose an alternative side-by-side layout
didoo Oct 24, 2025
f21ded9
updated some components to take into account the new `hideCarbonLabel…
didoo Oct 24, 2025
66e9a5d
fixed typescript/glint issue
didoo Oct 24, 2025
6a44266
updated a couple of typographic mappings
didoo Oct 24, 2025
de2fe50
added yielding of `theme` value in the named blocks of the `Compariso…
didoo Oct 28, 2025
59f7eab
introduced `ShwCarbonizationStylePreviewTypography` to facilitate com…
didoo Oct 27, 2025
5fde5cc
refactored `carbonization/foundations/color` page and `ShwCarbonizati…
didoo Oct 28, 2025
30ba016
updated comparison grid to use `default` for original HDS theming ins…
didoo Nov 7, 2025
7dde76f
small tweak to the `badge` carbonization page
didoo Nov 12, 2025
2a7e827
added logic to the application to lock theme switching when loading a…
didoo Nov 18, 2025
1bbfb47
replaced `theme` with `mode` in `ComparisonGrid`
didoo Nov 14, 2025
b5c049c
fixed issue with the β€œdefault” block of the carbonization grid was no…
didoo Nov 20, 2025
1a4d9ce
fixed issue in the carbonization page for colors
didoo Nov 20, 2025
01c6dcd
some cleanup before code review
didoo Nov 20, 2025
d3b262d
Update showcase/app/components/shw/carbonization/token-preview/color.gts
didoo Nov 21, 2025
27ccce6
updated showcase page for Button carbonization
didoo Nov 18, 2025
06ff1b4
implemented β€œCarbonization” page for `Modal` component
didoo Nov 25, 2025
fe636c2
added examples of components with focus state to the carbonization pa…
didoo Nov 27, 2025
a15cac1
tweaks per code review suggestions
didoo Nov 28, 2025
ce96e02
implemented β€œCarbonization” page for `Form/RadioCard` component
didoo Nov 28, 2025
f2a332f
better visual grouping of carbonization pages links in homepage
didoo Dec 1, 2025
a3dfa9b
renamed the `page-carbonization` components files and declarations to…
didoo Dec 3, 2025
902d4ee
added `disabled` state to `cds-radio-tile`
didoo Dec 3, 2025
3434085
avoid duplicate `name` attributes for different radio groups
didoo Dec 3, 2025
619542f
add missing `{{on "change" this.onChange}}` handled to the `RadioCard…
didoo Dec 3, 2025
32f2d99
updated logic that converts the Carbon duration value to the DTCG for…
didoo Dec 2, 2025
fbe07a5
updated logic that converts the Carbon `cubic-bezier` value to the ex…
didoo Dec 2, 2025
36ffb3a
re-extracted carbon tokens
didoo Dec 2, 2025
1e9be3a
turned on option to convert `font-size` from `rem` to `px` for extrac…
didoo Dec 3, 2025
c83857f
re-extracted carbon tokens
didoo Dec 3, 2025
b4e711c
[06] [Project Solar / Phase 1 / Dry-run] Migration dry-run for founda…
didoo Dec 5, 2025
1f08b2e
[Project Solar / Phase 1 / Engineering Follow-ups] Add `localStorage`…
didoo Dec 8, 2025
93cf191
added `chalk` as devDependency
didoo Dec 2, 2025
8fcbc26
updated `build.ts` script for design tokens, to have validation of ex…
didoo Dec 2, 2025
815ba83
improved logging messages for validation warnings/errors of `$modes`
didoo Dec 3, 2025
fd69b4d
[Project Solar / Phase 1 / Engineering Follow-ups] Add tests for HDS…
didoo Dec 11, 2025
fa5468f
re-generated CSS files in output after rebasing on `main` (new styles…
didoo Dec 16, 2025
55dc292
[HDS-5702] - Remove postbuild in favor of rollup copy (#3441)
RobbieTheWagner Dec 16, 2025
653c364
fixed TS issue
didoo Dec 18, 2025
9beac95
fixed some linting warnings for `package.json` files post rebase (and…
didoo Dec 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/tough-cows-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@hashicorp/design-system-tokens": major
---

MODES - TODOs

- Decide if this is a `major` or a `minor`
- Add a proper changeset entry here
1 change: 1 addition & 0 deletions DELETE-ME.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE ME!
8 changes: 7 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"lint:js:fix": "eslint . --fix",
"lint:types": "glint",
"start": "rollup --config --watch --environment development",
"prepublishOnly": "pnpm build && test -f 'dist/styles/@hashicorp/design-system-components.css' || (echo \"\n\\033[31m⚠️ Error: the pre-compiled CSS file \\`dist/styles/@hashicorp/design-system-components.css\\` was not found\\033[0m\\n\" && exit 1)"
"test-f:design-system-components": "test -f 'dist/styles/@hashicorp/design-system-components.css' || (echo \"\n\\033[31m⚠️ Error: the pre-compiled CSS file \\`dist/styles/@hashicorp/design-system-components.css\\` was not found\\033[0m\\n\" && exit 1)",
"test-f:design-system-components-common": "test -f 'dist/styles/@hashicorp/design-system-components-common.css' || (echo \"\n\\033[31m⚠️ Error: the pre-compiled CSS file \\`dist/styles/@hashicorp/design-system-components-common.css\\` was not found\\033[0m\\n\" && exit 1)",
"test-f:design-system-power-select-overrides": "test -f 'dist/styles/@hashicorp/design-system-power-select-overrides.css' || (echo \"\n\\033[31m⚠️ Error: the pre-compiled CSS file \\`dist/styles/@hashicorp/design-system-power-select-overrides.css\\` was not found\\033[0m\\n\" && exit 1)",
"prepublishOnly": "pnpm build && pnpm test-f:design-system-components && pnpm test-f:design-system-components-common && pnpm test-f:design-system-power-select-overrides"
},
"dependencies": {
"@codemirror/commands": "^6.8.0",
Expand Down Expand Up @@ -357,6 +360,8 @@
"./components/hds/text/code.js": "./dist/_app_/components/hds/text/code.js",
"./components/hds/text/display.js": "./dist/_app_/components/hds/text/display.js",
"./components/hds/text.js": "./dist/_app_/components/hds/text.js",
"./components/hds/theme-context.js": "./dist/_app_/components/hds/theme-context.js",
"./components/hds/theme-switcher.js": "./dist/_app_/components/hds/theme-switcher.js",
"./components/hds/time.js": "./dist/_app_/components/hds/time.js",
"./components/hds/time/range.js": "./dist/_app_/components/hds/time/range.js",
"./components/hds/time/single.js": "./dist/_app_/components/hds/time/single.js",
Expand Down Expand Up @@ -385,6 +390,7 @@
"./modifiers/hds-register-event.js": "./dist/_app_/modifiers/hds-register-event.js",
"./modifiers/hds-tooltip.js": "./dist/_app_/modifiers/hds-tooltip.js",
"./services/hds-intl.js": "./dist/_app_/services/hds-intl.js",
"./services/hds-theming.js": "./dist/_app_/services/hds-theming.js",
"./services/hds-time.js": "./dist/_app_/services/hds-time.js"
}
},
Expand Down
84 changes: 67 additions & 17 deletions packages/components/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,57 @@
import { Addon } from '@embroider/addon-dev/rollup';
import { babel } from '@rollup/plugin-babel';
import copy from 'rollup-plugin-copy';
import scss from 'rollup-plugin-scss';
import process from 'process';
import path from 'node:path';
import * as sass from 'sass';

const addon = new Addon({
srcDir: 'src',
destDir: 'dist',
});

// Custom SCSS compilation plugin for Rollup
function addScssCompilationPlugins(options) {
return options.map(({ inputFile, outputFile }) => ({
name: `rollup custom plugin to generate ${outputFile}`,
generateBundle() {
try {
const inputFileFullPath = `src/styles/@hashicorp/${inputFile}`;
const outputFileFullPath = `styles/@hashicorp/${outputFile}`;

const result = sass.compile(inputFileFullPath, {
sourceMap: true,
loadPaths: ['node_modules/@hashicorp/design-system-tokens/dist'],
});

// Emit the compiled CSS
this.emitFile({
type: 'asset',
fileName: outputFileFullPath,
source: result.css,
});

// Emit the source map
if (result.sourceMap) {
this.emitFile({
type: 'asset',
fileName: `${outputFileFullPath}.map`,
source: JSON.stringify(result.sourceMap),
});
}
} catch (error) {
this.error(
`Failed to compile SCSS file "${inputFile}": ${error.message}`
);
}
},
}));
}

const plugins = [
// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints([
'**/*.{js,ts}',
'index.js',
'template-registry.js',
'styles/@hashicorp/design-system-components.scss',
]),
addon.publicEntrypoints(['**/*.{js,ts}', 'index.js', 'template-registry.js']),

// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
Expand All @@ -50,16 +83,22 @@ const plugins = [
// package names.
addon.dependencies(),

scss({
fileName: 'styles/@hashicorp/design-system-components.css',
includePaths: [
'node_modules/@hashicorp/design-system-tokens/dist/products/css',
],
}),

scss({
fileName: 'styles/@hashicorp/design-system-power-select-overrides.css',
}),
// We use a custom plugin for the Sass/SCSS compilation
// so we can have multiple input and multiple outputs
...addScssCompilationPlugins([
{
inputFile: 'design-system-components.scss',
outputFile: 'design-system-components.css',
},
{
inputFile: 'design-system-components-common.scss',
outputFile: 'design-system-components-common.css',
},
{
inputFile: 'design-system-power-select-overrides.scss',
outputFile: 'design-system-power-select-overrides.css',
},
]),

// Ensure that standalone .hbs files are properly integrated as Javascript.
addon.hbs(),
Expand Down Expand Up @@ -92,6 +131,17 @@ const plugins = [
{ src: 'LICENSE.md', dest: 'dist' },
],
}),

// After bundle is written, copy built CSS to Showcase app
copy({
hook: 'writeBundle',
targets: [
{
src: 'dist/styles/@hashicorp/*.css',
dest: '../../showcase/public/assets/styles/@hashicorp',
},
],
}),
];

if (!process.env.development) {
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ export { default as HdsTextCode } from './components/hds/text/code.ts';
export { default as HdsTextDisplay } from './components/hds/text/display.ts';
export * from './components/hds/text/types.ts';

// Theme Context
export { default as HdsThemeContext } from './components/hds/theme-context/index.ts';

// Theme Switcher
export { default as HdsThemeSwitcher } from './components/hds/theme-switcher/index.ts';

// Time
export { default as HdsTime } from './components/hds/time/index.ts';
export { default as HdsTimeSingle } from './components/hds/time/single.ts';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
<div class={{this.classNames}} ...attributes>{{yield}}</div>
69 changes: 69 additions & 0 deletions packages/components/src/components/hds/theme-context/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import { assert } from '@ember/debug';
import type Owner from '@ember/owner';

import {
HdsThemeContextThemesValues,
HdsThemeContextModesValues,
} from './types.ts';
import type { HdsThemeContexts } from './types.ts';

import type { HdsThemes, HdsModes } from '../../../services/hds-theming.ts';

export interface HdsThemeContextSignature {
Args: {
// can be either an `HdsTheme` or an `HdsMode`
context: HdsThemeContexts;
};
Blocks: {
default: [];
};
Element: HTMLElement;
}

export const CONTEXTUAL_THEMES: HdsThemes[] = Object.values(
HdsThemeContextThemesValues
);
export const CONTEXTUAL_MODES: HdsModes[] = Object.values(
HdsThemeContextModesValues
);
export const CONTEXTUAL_VALUES: HdsThemeContexts[] = [
...CONTEXTUAL_THEMES,
...CONTEXTUAL_MODES,
];

export default class HdsThemeContext extends Component<HdsThemeContextSignature> {
constructor(owner: Owner, args: HdsThemeContextSignature['Args']) {
super(owner, args);

const { context } = args;

assert(
`@context for "Hds::ThemeContext" must be one of the following: ${CONTEXTUAL_VALUES.join(
', '
)}; received: ${context}`,
CONTEXTUAL_VALUES.includes(context)
);
}

// Get the class names to apply to the component.
get classNames(): string {
const classes = ['hds-theme-context'];

const { context } = this.args;

// add "theme" or "mode" classes based on the @context arguments
if (CONTEXTUAL_THEMES.includes(context as HdsThemes)) {
classes.push(`hds-theme-${context}`);
} else if (CONTEXTUAL_MODES.includes(context as HdsModes)) {
classes.push(`hds-mode-${context}`);
}

return classes.join(' ');
}
}
32 changes: 32 additions & 0 deletions packages/components/src/components/hds/theme-context/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import {
HdsThemeValues,
HdsModesLightValues,
HdsModesDarkValues,
} from '../../../services/hds-theming.ts';

import type { HdsThemes, HdsModes } from '../../../services/hds-theming.ts';

// re-export the enum values for the `HdsThemes` to use in the component
// note: using `as const` ensures Object.values() returns only the values (not keys _and_ values)
export const HdsThemeContextThemesValues = {
Default: HdsThemeValues.Default,
System: HdsThemeValues.System,
Light: HdsThemeValues.Light,
Dark: HdsThemeValues.Dark,
} as const;

// re-export the enum values for the `HdsModes` to use in the component
// note: using `as const` ensures Object.values() returns only the values (not keys _and_ values)
export const HdsThemeContextModesValues = {
CdsG0: HdsModesLightValues.CdsG0,
CdsG10: HdsModesLightValues.CdsG10,
CdsG90: HdsModesDarkValues.CdsG90,
CdsG100: HdsModesDarkValues.CdsG100,
} as const;

export type HdsThemeContexts = HdsThemes | Exclude<HdsModes, 'default'>;
29 changes: 29 additions & 0 deletions packages/components/src/components/hds/theme-switcher/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}

{{!
------------------------------------------------------------------------------------------
IMPORTANT: this is a temporary implementation, while we wait for the design specifications
------------------------------------------------------------------------------------------
}}

<Hds::Dropdown
@enableCollisionDetection={{true}}
@matchToggleWidth={{@toggleIsFullWidth}}
class="hds-theme-switcher-control"
...attributes
as |D|
>
<D.ToggleButton
@color="secondary"
@size={{this.toggleSize}}
@isFullWidth={{this.toggleIsFullWidth}}
@text={{this.toggleContent.label}}
@icon={{this.toggleContent.icon}}
/>
{{#each-in this._options as |key data|}}
<D.Interactive @icon={{data.icon}} {{on "click" (fn this.onSelectTheme data.theme)}}>{{data.label}}</D.Interactive>
{{/each-in}}
</Hds::Dropdown>
Loading
Loading