Skip to content

Commit 86a2800

Browse files
committed
SQUASHED COMMITS CRIS EXPLORATIONS
1 parent b24145a commit 86a2800

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+7006
-798
lines changed

packages/components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
"./modifiers/hds-clipboard.js": "./dist/_app_/modifiers/hds-clipboard.js",
304304
"./modifiers/hds-register-event.js": "./dist/_app_/modifiers/hds-register-event.js",
305305
"./modifiers/hds-tooltip.js": "./dist/_app_/modifiers/hds-tooltip.js",
306+
"./services/hds-theming.js": "./dist/_app_/services/hds-theming.js",
306307
"./services/hds-time.js": "./dist/_app_/services/hds-time.js"
307308
}
308309
},

packages/components/src/services.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
*/
55

66
// This file is used to expose public services
7+
8+
export * from './services/hds-theming.ts';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Service from '@ember/service';
2+
import { tracked } from '@glimmer/tracking';
3+
4+
export enum HdsThemeValues {
5+
// `auto` means to use the default in the browser (which depends on what the consumer imports as CSS)
6+
Auto = 'auto',
7+
Light = 'light',
8+
Dark = 'dark',
9+
}
10+
11+
export type HdsThemes = `${HdsThemeValues}` | undefined;
12+
13+
export const THEMES: string[] = Object.values(HdsThemeValues);
14+
15+
export default class HdsThemingService extends Service {
16+
@tracked _currentTheme: HdsThemes = undefined;
17+
18+
getTheme(): HdsThemes {
19+
// return localStorage.getItem('hdsCurrentTheme');
20+
return this._currentTheme;
21+
}
22+
23+
setTheme(theme: HdsThemes) {
24+
console.log('setting HDS theme', theme);
25+
26+
// IMPORTANT: for this to work, it needs to be the HTML tag (it's the `:root` in CSS)
27+
const rootElement = document.querySelector('html');
28+
29+
if (rootElement) {
30+
if (theme === undefined) {
31+
rootElement.removeAttribute('data-hds-theme');
32+
} else {
33+
rootElement.setAttribute('data-hds-theme', theme);
34+
}
35+
36+
// localStorage.setItem('hdsCurrentTheme', theme);
37+
this._currentTheme = theme;
38+
}
39+
}
40+
}

packages/components/src/styles/@hashicorp/design-system-components.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
* SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
// these files come from the 'design-system-tokens' package
7-
@use "tokens";
6+
// this CSS tokens file comes from the 'design-system-tokens' package
7+
// @use "tokens" as *;
8+
// TEMP used to include themed tokens in the standard generated CSS file
9+
@use "themed-tokens/unified.css" as *;
10+
11+
// these helper files come from the 'design-system-tokens' package (they don't depend on theming)
812
@use "helpers/color";
913
@use "helpers/elevation";
1014
@use "helpers/focus-ring";

0 commit comments

Comments
 (0)