Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4f7a80b
TEMP - added `$modes` entries for some color and typography tokens, w…
didoo Sep 30, 2025
253bef2
changed `outputReferences` to `false` (temporary) to bypass issue wit…
didoo Sep 30, 2025
8ead1bd
added commented code to `build` to use for debugging issue with missi…
didoo Sep 30, 2025
95d83a9
added two new themed tokens generated files, for Scss mixins and for …
didoo Oct 2, 2025
d67cc0d
fixed issue with `cds` naming missing the `g`
didoo Oct 7, 2025
aee3548
fixed some issues with how the β€œextra” themed CSS files were generated
didoo Oct 7, 2025
e206be7
TEMP - Re-generated tokens
didoo Sep 30, 2025
d1dc3fc
REVERT - used local version of Style Dictionary for debugging
didoo Oct 9, 2025
5be5c3b
REVERT - added examples of generated themed tokens
didoo Oct 9, 2025
b81cb39
REVERT - added `expected-CSS-output` files
didoo Oct 9, 2025
28fa9d6
Draft a custom plugin to compile the themed SCSS
alex-ju Sep 24, 2025
68deebe
updated SCSS files organization for components (split common part) + …
didoo Sep 26, 2025
8c888e4
added support for source maps for generated themed CSS files
didoo Sep 29, 2025
58ee21d
TEMP - Added generation of β€œalt” CSS for HDS components to compare wi…
didoo Sep 30, 2025
6c613d0
abstracted logic for custom Rollup plugin to compile multiple Sass fi…
didoo Sep 30, 2025
414e7b2
updated `includePaths` for design tokens in Showcase and Website `emb…
didoo Sep 30, 2025
8a4461a
moved compilation of existing Scss files for components and overrides…
didoo Sep 30, 2025
b6c7f1d
removed `rollup-plugin-scss` dev dependency (we use our own custom pl…
didoo Sep 30, 2025
b078d30
added CSS compilation for `combined-strategies` tokens
didoo Oct 2, 2025
869539e
added `Hds::ThemeSwitcher` component
didoo Sep 30, 2025
182eada
added `Hds::Theming` service
didoo Sep 30, 2025
d5ae427
added theming to the Showcase itself (and replaced hardcoded values w…
didoo Sep 30, 2025
fc9c4f1
added `Shw::ThemeSwitcher` component for showcase
didoo Sep 30, 2025
73a9df2
updated `Mock::App` and added new yielded sub-components
didoo Sep 30, 2025
6433a29
added `Shw:: ThemeSwitcher` to the Showcase page header
didoo Sep 30, 2025
0169455
added `foundations/theming` showcase page (and a frameless demo)
didoo Sep 30, 2025
3513fe6
refactored `hds-theming` service to align with the new themes/modes a…
didoo Oct 1, 2025
274d755
added `hdsTheming` initialization to main showcase app
didoo Oct 1, 2025
af827b4
removed compilation of components Scss and replaced it with static in…
didoo Oct 3, 2025
7adb4e3
added theming options via popover - part 1
didoo Oct 3, 2025
496aa6a
added theming options via popover - part 2
didoo Oct 3, 2025
62cd1d3
added theming options via popover - part 3
didoo Oct 3, 2025
c63bac5
added theming options via popover - part 4
didoo Oct 4, 2025
1b43974
added theming options via popover - part 5
didoo Oct 6, 2025
eb55281
big code refactoring for the theme selector, to streamline user selec…
didoo Oct 6, 2025
b88e665
updated logic that sets the theming for the showcase itself (without …
didoo Oct 7, 2025
33e2842
small fixes here and there for cleanup and linting
didoo Oct 10, 2025
de6b173
fixed issue with `pnpm lint:format` (missing newline at the end of `p…
didoo Oct 10, 2025
84de83f
fixed accessibility issue in `advanced-table` page, due to changes to…
didoo Oct 10, 2025
df9cec8
fixed typescript error due to new mock page being added
didoo Oct 10, 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
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
},
"pnpm": {
"overrides": {
"ember-composable-helpers": "npm:@nullvoxpopuli/ember-composable-helpers@^5.2.11",
"style-dictionary": "file:/Users/cristianorastelli/src/github/style-dictionary-didoo"
"ember-composable-helpers": "npm:@nullvoxpopuli/ember-composable-helpers@^5.2.11"
},
"patchedDependencies": {
"broccoli-asset-rewrite": "patches/broccoli-asset-rewrite.patch"
Expand Down
3 changes: 2 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
"prettier-plugin-ember-template-tag": "^2.0.5",
"rollup": "^4.39.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-scss": "^4.0.1",
"stylelint": "^16.17.0",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-config-standard-scss": "^14.0.0",
Expand Down Expand Up @@ -367,6 +366,7 @@
"./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-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 @@ -395,6 +395,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
85 changes: 68 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 plugins 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,34 @@ 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-theming-with-css-selectors.scss',
outputFile: 'design-system-components-theming-with-css-selectors.css',
},
{
inputFile:
'design-system-components-theming-with-prefers-color-scheme.scss',
outputFile:
'design-system-components-theming-with-prefers-color-scheme.css',
},
{
inputFile:
'design-system-components-theming-with-combined-strategies.scss',
outputFile:
'design-system-components-theming-with-combined-strategies.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
3 changes: 3 additions & 0 deletions packages/components/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ 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 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
23 changes: 23 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,23 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}

<Hds::Dropdown
@enableCollisionDetection={{true}}
@matchToggleWidth={{@toggleIsFullWidth}}
class="hds-theme-switcher-control"
...attributes
as |D|
>
<D.ToggleButton
@color="secondary"
@size={{this.toggleSize}}
@isFullWidth={{@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.setTheme data.theme)}}>{{data.label}}</D.Interactive>
{{/each-in}}
</Hds::Dropdown>
89 changes: 89 additions & 0 deletions packages/components/src/components/hds/theme-switcher/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';

import type { HdsDropdownSignature } from '../dropdown/index.ts';
import type { HdsDropdownToggleButtonSignature } from '../dropdown/toggle/button.ts';
import type { HdsIconSignature } from '../icon/index.ts';
import type HdsThemingService from '../../../services/hds-theming.ts';
import { type HdsThemes } from '../../../services/hds-theming.ts';

type ThemeOptionKey = 'system' | 'light' | 'dark'; // | 'none';

interface ThemeOption {
theme: HdsThemes;
icon: HdsIconSignature['Args']['name'];
label: string;
}

export const OPTIONS: Record<ThemeOptionKey, ThemeOption> = {
system: { theme: 'system', icon: 'monitor', label: 'System' },
light: { theme: 'light', icon: 'sun', label: 'Light' },
dark: { theme: 'dark', icon: 'moon', label: 'Dark' },
// none: { theme: undefined, icon: 'minus', label: 'None' },
};

export interface HdsThemeSwitcherSignature {
Args: {
toggleSize?: HdsDropdownToggleButtonSignature['Args']['size'];
toggleIsFullWidth?: boolean;
hasSystemOption?: boolean;
// hasNoThemeOption?: boolean;
};
Element: HdsDropdownSignature['Element'];
}

export default class HdsThemeSwitcher extends Component<HdsThemeSwitcherSignature> {
@service declare readonly hdsTheming: HdsThemingService;

get _options() {
const options: Partial<typeof OPTIONS> = { ...OPTIONS };
const hasSystemOption = this.args.hasSystemOption ?? true;
// const hasNoThemeOption = this.args.hasNoThemeOption ?? false;

if (!hasSystemOption) {
delete options.system;
}

// if (!hasNoThemeOption) {
// delete options.none;
// }

return options;
}

get toggleSize() {
return this.args.toggleSize ?? 'small';
}

get toggleContent() {
switch (this.currentTheme) {
case 'system':
case 'light':
case 'dark':
return {
label: OPTIONS[this.currentTheme].label,
icon: OPTIONS[this.currentTheme].icon,
};
case undefined:
default:
return { label: 'Theme', icon: undefined };
}
}

get currentTheme() {
// we get the theme from the global service
return this.hdsTheming.currentTheme;
}

@action
setTheme(theme: HdsThemes): void {
// we set the theme in the global service
this.hdsTheming.setTheme(theme);
}
}
2 changes: 2 additions & 0 deletions packages/components/src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
*/

// This file is used to expose public services

export * from './services/hds-theming.ts';
Loading
Loading