Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c0c1d7c
TODO - added temporary file to main feature branch for phase 1
didoo Sep 25, 2025
fa4bad2
added temporary changeset to feature branch for `$modes` support
didoo Sep 15, 2025
9729199
added `$modes` entry to `color.palette.neutral-0`
didoo Sep 15, 2025
560b40b
refactored logic used to provide SD configuration per target
didoo Sep 15, 2025
807dbc1
progress on logic for handling `$modes` - 1
didoo Sep 16, 2025
e91963c
TEMP - added `modes-testing` tokens
didoo Sep 16, 2025
7462def
TEMP - added `expected-CSS-output` files
didoo Sep 16, 2025
7971ae5
progress on logic for handling `$modes` - 2
didoo Sep 16, 2025
7ceebbf
added `attributes/themeable` transformation
didoo Sep 16, 2025
cc7aece
progress on logic for handling `$modes` - 3
didoo Sep 16, 2025
c9f47de
TEMP - used local version of Style Dictionary for debugging
didoo Sep 17, 2025
8aff3a2
progress on logic for handling `$modes` - 4
didoo Sep 17, 2025
a21bf77
TEMP generated temporary dist files for testing
didoo Sep 16, 2025
fef192f
added examples of generated themed tokens
didoo Sep 19, 2025
94cdd2c
added logic to generate theming CSS files
didoo Sep 19, 2025
3230ae2
REVERT - Removed `modes-testing` tokens
didoo Sep 30, 2025
9ba0f20
removed `modes-testing` folder from compilation
didoo Sep 30, 2025
139fc97
added `carbon-extracted` reference in the `source` definitions
didoo Sep 30, 2025
3ff97d2
TEMP - added `$modes` entries for some color and typography tokens, w…
didoo Sep 30, 2025
604b35e
changed `outputReferences` to `false` (temporary) to bypass issue wit…
didoo Sep 30, 2025
c490d5f
added commented code to `build` to use for debugging issue with missi…
didoo Sep 30, 2025
9bcc21c
added two new themed tokens generated files, for Scss mixins and for …
didoo Oct 2, 2025
1a855c1
TEMP - Re-generated tokens
didoo Sep 30, 2025
40e85a2
Draft a custom plugin to compile the themed SCSS
alex-ju Sep 24, 2025
95f52ff
updated SCSS files organization for components (split common part) + …
didoo Sep 26, 2025
3a40e13
added support for source maps for generated themed CSS files
didoo Sep 29, 2025
fcbe7c9
TEMP - Added generation of β€œalt” CSS for HDS components to compare wi…
didoo Sep 30, 2025
77cf091
abstracted logic for custom Rollup plugin to compile multiple Sass fi…
didoo Sep 30, 2025
ccb2660
updated `includePaths` for design tokens in Showcase and Website `emb…
didoo Sep 30, 2025
2d15ee6
moved compilation of existing Scss files for components and overrides…
didoo Sep 30, 2025
4d022d0
removed `rollup-plugin-scss` dev dependency (we use our own custom pl…
didoo Sep 30, 2025
bb949c9
added CSS compilation for `combined-strategies` tokens
didoo Oct 2, 2025
a9880a6
added `Hds::ThemeSwitcher` component
didoo Sep 30, 2025
ad4081b
added `Hds::Theming` service
didoo Sep 30, 2025
03cc2d0
added theming to the Showcase itself (and replaced hardcoded values w…
didoo Sep 30, 2025
7adcb8b
added `Shw::ThemeSwitcher` component for showcase
didoo Sep 30, 2025
97c5559
updated `Mock::App` and added new yielded sub-components
didoo Sep 30, 2025
07095c1
added `Shw:: ThemeSwitcher` to the Showcase page header
didoo Sep 30, 2025
0d10871
added `foundations/theming` showcase page (and a frameless demo)
didoo Sep 30, 2025
95608fd
refactored `hds-theming` service to align with the new themes/modes a…
didoo Oct 1, 2025
40581cc
sq
didoo Oct 1, 2025
ce65667
WIP
didoo Oct 1, 2025
d2a87ca
basic implementation of `<ShwCarbonizationComparisonGrid>`
didoo Sep 23, 2025
504d11a
refactored implementation of `<ShwCarbonizationComparisonGrid>`
didoo Sep 23, 2025
e6e05a0
implemented β€œCarbonization” section for `Badge` page
didoo Sep 23, 2025
f2e47f4
implemented β€œCarbonization” section for `BadgeCount` page
didoo Sep 23, 2025
07e5a87
implemented β€œCarbonization” section for `Button` page
didoo Sep 23, 2025
3e1f545
implemented β€œCarbonization” section for `Focus Ring` page
didoo Sep 24, 2025
64c80c6
implemented β€œCarbonization” section for `Typography` page
didoo Sep 24, 2025
692ac77
implemented β€œCarbonization” section for (new) `Color` page
didoo Sep 24, 2025
279ce8c
added `@carbon/web-components` as devDependency to Showcase app
didoo Sep 24, 2025
af64fda
added `@carbon/[themes|layout|grid|type]` + `@ibm/plex` as devDepende…
didoo Sep 25, 2025
11e0ed6
refactored `ComparisonGrid` component to add themed background color …
didoo Sep 25, 2025
e0f1475
added temporary support for IBM Plex font-family
didoo Sep 25, 2025
71855e9
refactored code to support theming for reference web components, base…
didoo Sep 25, 2025
ef2d208
small refactoring
didoo Sep 25, 2025
67d5f31
small refactorings
didoo Sep 25, 2025
f8e77f1
refactored content organization to have the carbonization pages as st…
didoo Sep 25, 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!
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"pnpm": {
"overrides": {
"ember-composable-helpers": "npm:@nullvoxpopuli/ember-composable-helpers@^5.2.11"
"ember-composable-helpers": "npm:@nullvoxpopuli/ember-composable-helpers@^5.2.11",
"style-dictionary": "file:/Users/cristianorastelli/src/github/style-dictionary-didoo"
},
"patchedDependencies": {
"broccoli-asset-rewrite": "patches/broccoli-asset-rewrite.patch"
Expand Down
5 changes: 3 additions & 2 deletions 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 Expand Up @@ -425,4 +426,4 @@
"engines": {
"node": ">= 18"
}
}
}
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