@hashicorp/design-system-components 4.24.1-rc-20251103142516 → 4.24.1-rc-20251104114028
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/components/hds/flyout/index.d.ts +2 -1
- package/declarations/components/hds/icon/index.d.ts +1 -1
- package/declarations/components/hds/modal/index.d.ts +1 -0
- package/declarations/components/hds/stepper/task/indicator.d.ts +1 -1
- package/declarations/components.d.ts +0 -1
- package/declarations/services.d.ts +0 -1
- package/declarations/template-registry.d.ts +0 -3
- package/dist/components/hds/flyout/index.js +11 -8
- package/dist/components/hds/flyout/index.js.map +1 -1
- package/dist/components/hds/form/super-select/multiple/base.js +1 -1
- package/dist/components/hds/modal/index.js +25 -22
- package/dist/components/hds/modal/index.js.map +1 -1
- package/dist/components.js +0 -1
- package/dist/components.js.map +1 -1
- package/dist/services.js +1 -1
- package/dist/styles/@hashicorp/design-system-components.css +1563 -383
- package/dist/styles/@hashicorp/design-system-components.scss +59 -4
- package/dist/styles/@hashicorp/design-system-components.scss.map +1 -0
- package/dist/styles/components/app-header.scss +6 -1
- package/dist/styles/components/form/super-select.scss +4 -0
- package/dist/styles/components/side-nav/header.scss +6 -1
- package/package.json +5 -10
- package/declarations/components/hds/theme-switcher/index.d.ts +0 -41
- package/declarations/services/hds-theming.d.ts +0 -68
- package/dist/_app_/components/hds/theme-switcher.js +0 -1
- package/dist/_app_/services/hds-theming.js +0 -1
- package/dist/components/hds/theme-switcher/index.js +0 -86
- package/dist/components/hds/theme-switcher/index.js.map +0 -1
- package/dist/services/hds-theming.js +0 -204
- package/dist/services/hds-theming.js.map +0 -1
- package/dist/styles/@hashicorp/design-system-components-common.css +0 -9823
- package/dist/styles/@hashicorp/design-system-components-common.css.map +0 -1
- package/dist/styles/@hashicorp/design-system-components-common.scss +0 -20
- package/dist/styles/@hashicorp/design-system-components.css.map +0 -1
- package/dist/styles/@hashicorp/design-system-power-select-overrides.css +0 -229
- package/dist/styles/@hashicorp/design-system-power-select-overrides.css.map +0 -1
- package/dist/styles/components/index.scss +0 -52
|
@@ -3,8 +3,63 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// these
|
|
7
|
-
@use "
|
|
6
|
+
// these files come from the 'design-system-tokens' package
|
|
7
|
+
@use "tokens";
|
|
8
|
+
@use "helpers/color";
|
|
9
|
+
@use "helpers/elevation";
|
|
10
|
+
@use "helpers/focus-ring";
|
|
11
|
+
@use "helpers/typography";
|
|
8
12
|
|
|
9
|
-
//
|
|
10
|
-
|
|
13
|
+
// Notice: this list can be automatically edited by the Ember blueprint, please don't remove the start/end comments
|
|
14
|
+
// START COMPONENTS CSS FILES IMPORTS
|
|
15
|
+
@use "../components/accordion";
|
|
16
|
+
@use "../components/advanced-table";
|
|
17
|
+
@use "../components/alert";
|
|
18
|
+
@use "../components/app-footer";
|
|
19
|
+
@use "../components/app-frame";
|
|
20
|
+
@use "../components/app-header";
|
|
21
|
+
@use "../components/app-side-nav";
|
|
22
|
+
@use "../components/application-state";
|
|
23
|
+
@use "../components/badge";
|
|
24
|
+
@use "../components/badge-count";
|
|
25
|
+
@use "../components/breadcrumb";
|
|
26
|
+
@use "../components/button";
|
|
27
|
+
@use "../components/button-set";
|
|
28
|
+
@use "../components/card";
|
|
29
|
+
@use "../components/code-block";
|
|
30
|
+
@use "../components/code-editor";
|
|
31
|
+
@use "../components/copy";
|
|
32
|
+
@use "../components/dialog-primitive";
|
|
33
|
+
@use "../components/disclosure-primitive";
|
|
34
|
+
@use "../components/dismiss-button";
|
|
35
|
+
@use "../components/dropdown";
|
|
36
|
+
@use "../components/flyout";
|
|
37
|
+
@use "../components/form"; // multiple components
|
|
38
|
+
@use "../components/icon";
|
|
39
|
+
@use "../components/icon-tile";
|
|
40
|
+
@use "../components/layout"; // multiple components
|
|
41
|
+
@use "../components/link"; // multiple components
|
|
42
|
+
@use "../components/menu-primitive";
|
|
43
|
+
@use "../components/modal";
|
|
44
|
+
@use "../components/page-header";
|
|
45
|
+
@use "../components/pagination";
|
|
46
|
+
@use "../components/reveal";
|
|
47
|
+
@use "../components/rich-tooltip";
|
|
48
|
+
@use "../components/segmented-group";
|
|
49
|
+
@use "../components/separator";
|
|
50
|
+
@use "../components/side-nav";
|
|
51
|
+
@use "../components/stepper";
|
|
52
|
+
@use "../components/table";
|
|
53
|
+
@use "../components/tabs";
|
|
54
|
+
@use "../components/tag";
|
|
55
|
+
@use "../components/text";
|
|
56
|
+
@use "../components/time";
|
|
57
|
+
@use "../components/toast";
|
|
58
|
+
@use "../components/tooltip";
|
|
59
|
+
// END COMPONENT CSS FILES IMPORTS
|
|
60
|
+
|
|
61
|
+
@use "../mixins/screen-reader-only" as *;
|
|
62
|
+
// stylelint-disable-next-line selector-class-pattern
|
|
63
|
+
.sr-only {
|
|
64
|
+
@include screen-reader-only();
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-system-components.scss","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -110,7 +110,12 @@
|
|
|
110
110
|
.hds-dropdown-toggle-button,
|
|
111
111
|
.hds-dropdown-toggle-icon {
|
|
112
112
|
// Apply dark theme to child interactive components not within a nested dropdown
|
|
113
|
-
&:not(
|
|
113
|
+
&:not(
|
|
114
|
+
.hds-dropdown * *,
|
|
115
|
+
.ember-basic-dropdown-trigger * *,
|
|
116
|
+
.ember-basic-dropdown-content * *,
|
|
117
|
+
.hds-dialog-primitive__wrapper *
|
|
118
|
+
) {
|
|
114
119
|
@include hds-interactive-dark-theme();
|
|
115
120
|
|
|
116
121
|
// disabled state:
|
|
@@ -198,6 +198,10 @@ $hds-super-select-item-height: 36px;
|
|
|
198
198
|
background-color: var(--token-color-foreground-action-active);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
+
|
|
202
|
+
&[aria-disabled="true"] {
|
|
203
|
+
color: var(--token-form-control-disabled-foreground-color);
|
|
204
|
+
}
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
// Option Groups (similar to HTML optgroup)
|
|
@@ -76,7 +76,12 @@
|
|
|
76
76
|
.hds-dropdown-toggle-button,
|
|
77
77
|
.hds-dropdown-toggle-icon {
|
|
78
78
|
// Apply dark theme to child interactive components not within a nested dropdown
|
|
79
|
-
&:not(
|
|
79
|
+
&:not(
|
|
80
|
+
.hds-dropdown * *,
|
|
81
|
+
.ember-basic-dropdown-trigger * *,
|
|
82
|
+
.ember-basic-dropdown-content * *,
|
|
83
|
+
.hds-dialog-primitive__wrapper *
|
|
84
|
+
) {
|
|
80
85
|
@include hds-interactive-dark-theme();
|
|
81
86
|
|
|
82
87
|
// disabled state:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashicorp/design-system-components",
|
|
3
|
-
"version": "4.24.1-rc-
|
|
3
|
+
"version": "4.24.1-rc-20251104114028",
|
|
4
4
|
"description": "Helios Design System Components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hashicorp",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@embroider/macros": "^1.18.1",
|
|
36
36
|
"@embroider/util": "^1.13.4",
|
|
37
37
|
"@floating-ui/dom": "^1.6.12",
|
|
38
|
-
"@hashicorp/design-system-tokens": "
|
|
39
|
-
"@hashicorp/flight-icons": "
|
|
38
|
+
"@hashicorp/design-system-tokens": "^3.0.0",
|
|
39
|
+
"@hashicorp/flight-icons": "3.14.0-rc-20251104114028",
|
|
40
40
|
"@lezer/highlight": "^1.2.1",
|
|
41
41
|
"@nullvoxpopuli/ember-composable-helpers": "^5.2.11",
|
|
42
42
|
"clipboard-polyfill": "^4.1.1",
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"prettier-plugin-ember-template-tag": "^2.0.5",
|
|
97
97
|
"rollup": "^4.39.0",
|
|
98
98
|
"rollup-plugin-copy": "^3.5.0",
|
|
99
|
+
"rollup-plugin-scss": "^4.0.1",
|
|
99
100
|
"stylelint": "^16.17.0",
|
|
100
101
|
"stylelint-config-rational-order": "^0.1.2",
|
|
101
102
|
"stylelint-config-standard-scss": "^14.0.0",
|
|
@@ -350,7 +351,6 @@
|
|
|
350
351
|
"./components/hds/text/code.js": "./dist/_app_/components/hds/text/code.js",
|
|
351
352
|
"./components/hds/text/display.js": "./dist/_app_/components/hds/text/display.js",
|
|
352
353
|
"./components/hds/text.js": "./dist/_app_/components/hds/text.js",
|
|
353
|
-
"./components/hds/theme-switcher.js": "./dist/_app_/components/hds/theme-switcher.js",
|
|
354
354
|
"./components/hds/time.js": "./dist/_app_/components/hds/time.js",
|
|
355
355
|
"./components/hds/time/range.js": "./dist/_app_/components/hds/time/range.js",
|
|
356
356
|
"./components/hds/time/single.js": "./dist/_app_/components/hds/time/single.js",
|
|
@@ -379,7 +379,6 @@
|
|
|
379
379
|
"./modifiers/hds-register-event.js": "./dist/_app_/modifiers/hds-register-event.js",
|
|
380
380
|
"./modifiers/hds-tooltip.js": "./dist/_app_/modifiers/hds-tooltip.js",
|
|
381
381
|
"./services/hds-intl.js": "./dist/_app_/services/hds-intl.js",
|
|
382
|
-
"./services/hds-theming.js": "./dist/_app_/services/hds-theming.js",
|
|
383
382
|
"./services/hds-time.js": "./dist/_app_/services/hds-time.js"
|
|
384
383
|
}
|
|
385
384
|
},
|
|
@@ -412,7 +411,6 @@
|
|
|
412
411
|
},
|
|
413
412
|
"scripts": {
|
|
414
413
|
"build": "rollup --config",
|
|
415
|
-
"postbuild": "cp -R dist/styles/@hashicorp/design-system-components.css ../../showcase/public/assets/styles/@hashicorp/ && cp -R dist/styles/@hashicorp/design-system-components-common.css ../../showcase/public/assets/styles/@hashicorp/ && cp -R dist/styles/@hashicorp/design-system-power-select-overrides.css ../../showcase/public/assets/styles/@hashicorp/",
|
|
416
414
|
"format": "prettier . --cache --write",
|
|
417
415
|
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
|
|
418
416
|
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm run format",
|
|
@@ -424,9 +422,6 @@
|
|
|
424
422
|
"lint:js": "eslint . --cache",
|
|
425
423
|
"lint:js:fix": "eslint . --fix",
|
|
426
424
|
"lint:types": "glint",
|
|
427
|
-
"start": "rollup --config --watch --environment development"
|
|
428
|
-
"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)",
|
|
429
|
-
"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)",
|
|
430
|
-
"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)"
|
|
425
|
+
"start": "rollup --config --watch --environment development"
|
|
431
426
|
}
|
|
432
427
|
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) HashiCorp, Inc.
|
|
3
|
-
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
*/
|
|
5
|
-
import Component from '@glimmer/component';
|
|
6
|
-
import type { HdsDropdownSignature } from '../dropdown/index.ts';
|
|
7
|
-
import type { HdsDropdownToggleButtonSignature } from '../dropdown/toggle/button.ts';
|
|
8
|
-
import type { HdsIconSignature } from '../icon/index.ts';
|
|
9
|
-
import type HdsThemingService from '../../../services/hds-theming.ts';
|
|
10
|
-
import type { HdsThemes, OnSetThemeCallback } from '../../../services/hds-theming.ts';
|
|
11
|
-
interface ThemeOption {
|
|
12
|
-
theme: HdsThemes | undefined;
|
|
13
|
-
icon: HdsIconSignature['Args']['name'];
|
|
14
|
-
label: string;
|
|
15
|
-
}
|
|
16
|
-
interface HdsThemeSwitcherSignature {
|
|
17
|
-
Args: {
|
|
18
|
-
toggleSize?: HdsDropdownToggleButtonSignature['Args']['size'];
|
|
19
|
-
toggleIsFullWidth?: HdsDropdownToggleButtonSignature['Args']['isFullWidth'];
|
|
20
|
-
hasSystemOption?: boolean;
|
|
21
|
-
onSetTheme?: OnSetThemeCallback;
|
|
22
|
-
};
|
|
23
|
-
Element: HdsDropdownSignature['Element'];
|
|
24
|
-
}
|
|
25
|
-
export default class HdsThemeSwitcher extends Component<HdsThemeSwitcherSignature> {
|
|
26
|
-
readonly hdsTheming: HdsThemingService;
|
|
27
|
-
get toggleSize(): "small" | "medium";
|
|
28
|
-
get toggleIsFullWidth(): boolean;
|
|
29
|
-
get toggleContent(): {
|
|
30
|
-
label: string;
|
|
31
|
-
icon: "type" | "map" | "filter" | "code" | "link" | "menu" | "search" | "video" | "circle" | "image" | "path" | "tag" | "repeat" | "hash" | "queue" | "shuffle" | "chevron-up" | "chevron-down" | "unfold-open" | "unfold-close" | "arrow-down" | "arrow-up" | "swap-vertical" | "top" | "key" | "move" | "change" | "pause" | "play" | "move-horizontal" | "loading" | "loading-static" | "running" | "running-static" | "apple" | "apple-color" | "alibaba" | "alibaba-color" | "amazon-ecs" | "amazon-ecs-color" | "amazon-eks" | "amazon-eks-color" | "auth0" | "auth0-color" | "aws" | "aws-color" | "aws-cdk" | "aws-cdk-color" | "aws-cloudwatch" | "aws-cloudwatch-color" | "aws-ec2" | "aws-ec2-color" | "aws-lambda" | "aws-lambda-color" | "aws-s3" | "aws-s3-color" | "azure" | "azure-color" | "azure-aks" | "azure-aks-color" | "azure-blob-storage" | "azure-blob-storage-color" | "azure-devops" | "azure-devops-color" | "azure-vms" | "azure-vms-color" | "bitbucket" | "bitbucket-color" | "bridgecrew" | "bridgecrew-color" | "cisco" | "cisco-color" | "codepen" | "codepen-color" | "confluence" | "confluence-color" | "confluent" | "confluent-color" | "datadog" | "datadog-color" | "digital-ocean" | "digital-ocean-color" | "docker" | "docker-color" | "duo" | "duo-color" | "elastic-observability" | "elastic-observability-color" | "f5" | "f5-color" | "facebook" | "facebook-color" | "figma" | "figma-color" | "gcp" | "gcp-color" | "git" | "git-color" | "gitlab" | "gitlab-color" | "github" | "github-color" | "google" | "google-color" | "google-docs" | "google-docs-color" | "google-drive" | "google-drive-color" | "google-forms" | "google-forms-color" | "google-sheets" | "google-sheets-color" | "google-slides" | "google-slides-color" | "grafana" | "grafana-color" | "helm" | "helm-color" | "infracost" | "infracost-color" | "jfrog" | "jfrog-color" | "jira" | "jira-color" | "jwt" | "jwt-color" | "kubernetes" | "kubernetes-color" | "lightlytics" | "lightlytics-color" | "linkedin" | "linkedin-color" | "linode" | "linode-color" | "linux" | "linux-color" | "loom" | "loom-color" | "meetup" | "meetup-color" | "microsoft" | "microsoft-color" | "microsoft-teams" | "microsoft-teams-color" | "minio" | "minio-color" | "mongodb" | "mongodb-color" | "new-relic" | "new-relic-color" | "okta" | "okta-color" | "oracle" | "oracle-color" | "opa" | "opa-color" | "openid" | "openid-color" | "pack" | "pack-color" | "pager-duty" | "pager-duty-color" | "ping-identity " | "ping-identity-color" | "postgres" | "postgres-color" | "rabbitmq" | "rabbitmq-color" | "saml" | "saml-color" | "service-now" | "service-now-color" | "slack" | "slack-color" | "snyk" | "snyk-color" | "splunk" | "splunk-color" | "twilio" | "twilio-color" | "twitch" | "twitch-color" | "twitter" | "twitter-color" | "twitter-x" | "twitter-x-color" | "vantage" | "vantage-color" | "venafi" | "venafi-color" | "vercel" | "vercel-color" | "vmware" | "vmware-color" | "youtube" | "youtube-color" | "boundary" | "boundary-color" | "boundary-fill" | "boundary-fill-color" | "boundary-square" | "boundary-square-color" | "consul" | "consul-color" | "consul-fill" | "consul-fill-color" | "consul-square" | "consul-square-color" | "nomad" | "nomad-color" | "nomad-fill" | "nomad-fill-color" | "nomad-square" | "nomad-square-color" | "packer" | "packer-color" | "packer-fill" | "packer-fill-color" | "packer-square" | "packer-square-color" | "terraform" | "terraform-color" | "terraform-fill" | "terraform-fill-color" | "terraform-square" | "terraform-square-color" | "vagrant" | "vagrant-color" | "vagrant-fill" | "vagrant-fill-color" | "vagrant-square" | "vagrant-square-color" | "vault" | "vault-color" | "vault-fill" | "vault-fill-color" | "vault-square" | "vault-square-color" | "vault-radar" | "vault-radar-color" | "vault-radar-fill" | "vault-radar-fill-color" | "vault-radar-square" | "vault-radar-square-color" | "vault-secrets" | "vault-secrets-color" | "vault-secrets-fill" | "vault-secrets-fill-color" | "vault-secrets-square" | "vault-secrets-square-color" | "waypoint" | "waypoint-color" | "waypoint-fill" | "waypoint-fill-color" | "waypoint-square" | "waypoint-square-color" | "hashicorp" | "hashicorp-color" | "hashicorp-fill" | "hashicorp-fill-color" | "hashicorp-square" | "hashicorp-square-color" | "hcp" | "hcp-color" | "hcp-fill" | "hcp-fill-color" | "hcp-square" | "hcp-square-color" | "accessibility" | "folder-users" | "frown" | "identity-service" | "identity-user" | "meh" | "robot" | "smile" | "user" | "user-check" | "user-circle" | "user-circle-fill" | "user-minus" | "user-plus" | "user-x" | "users" | "ampersand" | "beaker" | "bucket" | "bulb" | "circle-dot" | "circle-fill" | "circle-half" | "diamond" | "diamond-fill" | "disc" | "dot" | "dot-half" | "droplet" | "flag" | "gift" | "government" | "handshake" | "hexagon" | "hexagon-fill" | "labyrinth" | "layers" | "moon" | "octagon" | "outline" | "random" | "rocket" | "sparkle" | "square" | "square-fill" | "sun" | "triangle" | "triangle-fill" | "truck" | "wand" | "zap" | "zap-off" | "docs" | "docs-download" | "docs-link" | "guide" | "guide-link" | "help" | "info" | "info-fill" | "learn" | "learn-link" | "support" | "alert-circle" | "alert-circle-fill" | "alert-diamond" | "alert-diamond-fill" | "alert-octagon" | "alert-octagon-fill" | "alert-triangle" | "alert-triangle-fill" | "check" | "check-circle" | "check-circle-fill" | "check-diamond" | "check-diamond-fill" | "check-hexagon" | "check-hexagon-fill" | "check-square" | "check-square-fill" | "skip" | "x" | "x-circle" | "x-circle-fill" | "x-diamond" | "x-diamond-fill" | "x-hexagon" | "x-hexagon-fill" | "x-square" | "x-square-fill" | "bug" | "certificate" | "eye" | "eye-off" | "fingerprint" | "keychain" | "lock" | "lock-fill" | "lock-off" | "shield" | "shield-alert" | "shield-check" | "shield-off" | "shield-x" | "token" | "unlock" | "verified" | "wall" | "minus" | "minus-circle" | "minus-circle-fill" | "minus-plus" | "minus-plus-circle" | "minus-plus-square" | "minus-square" | "minus-square-fill" | "plus" | "plus-circle" | "plus-circle-fill" | "plus-square" | "camera" | "camera-off" | "cast" | "closed-caption" | "fast-forward" | "film" | "headphones" | "music" | "pause-circle" | "play-circle" | "radio" | "rewind" | "rss" | "skip-back" | "skip-forward" | "speaker" | "stop-circle" | "volume" | "volume-down" | "volume-2" | "volume-x" | "wifi" | "wifi-off" | "compass" | "crosshair" | "map-pin" | "navigation" | "navigation-alt" | "redirect" | "target" | "align-center" | "align-justify" | "align-left" | "align-right" | "battery" | "battery-charging" | "bookmark" | "bookmark-add" | "bookmark-add-fill" | "bookmark-fill" | "bookmark-remove" | "bookmark-remove-fill" | "bottom" | "start" | "end" | "command" | "crop" | "dashboard" | "delete" | "download" | "edit" | "entry-point" | "exit-point" | "external-link" | "filter-circle" | "filter-fill" | "grid" | "grid-alt" | "home" | "jump-link" | "layout" | "list" | "maximize" | "maximize-alt" | "minimize" | "minimize-alt" | "more-horizontal" | "more-vertical" | "mouse-pointer" | "paperclip" | "pen-tool" | "pencil-tool" | "pin" | "pin-off" | "power" | "printer" | "reload" | "resize-column" | "rotate-cw" | "rotate-ccw" | "share" | "sidebar" | "sidebar-hide" | "sidebar-show" | "sign-in" | "sign-out" | "slash" | "slash-square" | "sort-asc" | "sort-desc" | "switcher" | "sync" | "sync-alert" | "sync-reverse" | "toggle-left" | "toggle-right" | "trash" | "text-wrap" | "upload" | "zoom-in" | "zoom-out" | "archive" | "clipboard" | "clipboard-checked" | "clipboard-copy" | "clipboard-x" | "file" | "file-change" | "file-check" | "file-diff" | "file-minus" | "file-plus" | "file-source" | "file-text" | "file-x" | "files" | "folder" | "folder-fill" | "folder-minus" | "folder-minus-fill" | "folder-plus" | "folder-plus-fill" | "folder-star" | "inbox" | "api" | "auto-apply" | "build" | "change-circle" | "change-square" | "channel" | "cloud" | "cloud-check" | "cloud-download" | "cloud-lightning" | "cloud-lock" | "cloud-off" | "cloud-upload" | "cloud-x" | "connection" | "connection-gateway" | "cpu" | "duplicate" | "gateway" | "git-branch" | "git-commit" | "git-merge" | "git-pull-request" | "git-repo" | "hammer" | "key-values" | "mainframe" | "mesh" | "module" | "monitor" | "network" | "network-alt" | "node" | "pipeline" | "plug" | "replication-direct" | "replication-perf" | "scissors" | "server" | "server-cluster" | "serverless" | "service" | "settings" | "sliders" | "smartphone" | "socket" | "step" | "tablet" | "terminal" | "terminal-screen" | "test" | "tools" | "transform-data" | "tv" | "webhook" | "wrench" | "calendar" | "clock" | "clock-filled" | "delay" | "event" | "history" | "hourglass" | "watch" | "bar-chart" | "bar-chart-alt" | "box" | "collections" | "database" | "hard-drive" | "line-chart" | "line-chart-up" | "logs" | "package" | "pie-chart" | "save" | "trend-down" | "trend-up" | "activity" | "at-sign" | "award" | "bell" | "bell-active" | "bell-active-fill" | "bell-off" | "discussion-circle" | "discussion-square" | "heart" | "heart-fill" | "heart-off" | "mail" | "mail-open" | "message-circle" | "message-circle-fill" | "message-square" | "message-square-fill" | "mic" | "mic-off" | "newspaper" | "phone" | "phone-call" | "phone-off" | "send" | "star" | "star-circle" | "star-fill" | "star-off" | "thumbs-down" | "thumbs-up" | "video-off" | "bank-vault" | "briefcase" | "credit-card" | "dollar-sign" | "enterprise" | "globe" | "globe-private" | "org" | "provider" | "shopping-bag" | "shopping-cart" | "arrow-down-circle" | "arrow-down-left" | "arrow-down-right" | "arrow-left" | "arrow-left-circle" | "arrow-right" | "arrow-right-circle" | "arrow-up-circle" | "arrow-up-left" | "arrow-up-right" | "caret" | "chevron-left" | "chevron-right" | "chevrons-down" | "chevrons-left" | "chevrons-right" | "chevrons-up" | "corner-down-left" | "corner-down-right" | "corner-left-down" | "corner-left-up" | "corner-right-down" | "corner-right-up" | "corner-up-left" | "corner-up-right" | "load-balancer" | "migrate" | "swap-horizontal";
|
|
32
|
-
} | {
|
|
33
|
-
label: string;
|
|
34
|
-
icon: undefined;
|
|
35
|
-
};
|
|
36
|
-
get hasSystemOption(): boolean;
|
|
37
|
-
get _options(): Partial<Record<"light" | "dark" | "system", ThemeOption>>;
|
|
38
|
-
get currentTheme(): "light" | "dark" | "system" | undefined;
|
|
39
|
-
onSelectTheme(theme: HdsThemes | undefined): void;
|
|
40
|
-
}
|
|
41
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import Service from '@ember/service';
|
|
2
|
-
export declare enum HdsThemeValues {
|
|
3
|
-
System = "system",
|
|
4
|
-
Light = "light",
|
|
5
|
-
Dark = "dark"
|
|
6
|
-
}
|
|
7
|
-
declare enum HdsModesBaseValues {
|
|
8
|
-
Hds = "hds"
|
|
9
|
-
}
|
|
10
|
-
declare enum HdsModesLightValues {
|
|
11
|
-
CdsG0 = "cds-g0",
|
|
12
|
-
CdsG10 = "cds-g10"
|
|
13
|
-
}
|
|
14
|
-
declare enum HdsModesDarkValues {
|
|
15
|
-
CdsG90 = "cds-g90",
|
|
16
|
-
CdsG100 = "cds-g100"
|
|
17
|
-
}
|
|
18
|
-
export declare enum HdsCssSelectorsValues {
|
|
19
|
-
Data = "data",
|
|
20
|
-
Class = "class"
|
|
21
|
-
}
|
|
22
|
-
export type HdsThemes = `${HdsThemeValues}`;
|
|
23
|
-
export type HdsModes = `${HdsModesBaseValues}` | `${HdsModesLightValues}` | `${HdsModesDarkValues}`;
|
|
24
|
-
export type HdsModesLight = `${HdsModesLightValues}`;
|
|
25
|
-
export type HdsModesDark = `${HdsModesDarkValues}`;
|
|
26
|
-
export type HdsCssSelectors = `${HdsCssSelectorsValues}`;
|
|
27
|
-
type HdsThemingOptions = {
|
|
28
|
-
lightTheme: HdsModesLight;
|
|
29
|
-
darkTheme: HdsModesDark;
|
|
30
|
-
cssSelector: HdsCssSelectors;
|
|
31
|
-
};
|
|
32
|
-
type SetThemeArgs = {
|
|
33
|
-
theme: HdsThemes | undefined;
|
|
34
|
-
options?: HdsThemingOptions;
|
|
35
|
-
onSetTheme?: OnSetThemeCallback;
|
|
36
|
-
};
|
|
37
|
-
export type OnSetThemeCallbackArgs = {
|
|
38
|
-
currentTheme: HdsThemes | undefined;
|
|
39
|
-
currentMode: HdsModes | undefined;
|
|
40
|
-
};
|
|
41
|
-
export type OnSetThemeCallback = (args: OnSetThemeCallbackArgs) => void;
|
|
42
|
-
export declare const THEMES: HdsThemes[];
|
|
43
|
-
export declare const MODES_LIGHT: HdsModesLight[];
|
|
44
|
-
export declare const MODES_DARK: HdsModesDark[];
|
|
45
|
-
export declare const MODES: HdsModes[];
|
|
46
|
-
export declare const HDS_THEMING_DATA_SELECTOR = "data-hds-theme";
|
|
47
|
-
export declare const HDS_THEMING_CLASS_SELECTOR_PREFIX = "hds-theme";
|
|
48
|
-
export declare const HDS_THEMING_CLASS_SELECTORS_LIST: string[];
|
|
49
|
-
export declare const HDS_THEMING_LOCALSTORAGE_DATA = "hds-theming-data";
|
|
50
|
-
export declare const DEFAULT_THEMING_OPTION_LIGHT_THEME = HdsModesLightValues.CdsG0;
|
|
51
|
-
export declare const DEFAULT_THEMING_OPTION_DARK_THEME = HdsModesDarkValues.CdsG100;
|
|
52
|
-
export declare const DEFAULT_THEMING_OPTION_CSS_SELECTOR = "data";
|
|
53
|
-
export default class HdsThemingService extends Service {
|
|
54
|
-
_currentTheme: HdsThemes | undefined;
|
|
55
|
-
_currentMode: HdsModes | undefined;
|
|
56
|
-
_currentLightTheme: HdsModesLight;
|
|
57
|
-
_currentDarkTheme: HdsModesDark;
|
|
58
|
-
_currentCssSelector: HdsCssSelectors;
|
|
59
|
-
globalOnSetTheme: OnSetThemeCallback | undefined;
|
|
60
|
-
initializeTheme(): void;
|
|
61
|
-
setTheme({ theme, options, onSetTheme }: SetThemeArgs): void;
|
|
62
|
-
get currentTheme(): HdsThemes | undefined;
|
|
63
|
-
get currentMode(): HdsModes | undefined;
|
|
64
|
-
get currentLightTheme(): HdsModesLight;
|
|
65
|
-
get currentDarkTheme(): HdsModesDark;
|
|
66
|
-
get currentCssSelector(): HdsCssSelectors;
|
|
67
|
-
}
|
|
68
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "@hashicorp/design-system-components/components/hds/theme-switcher/index";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "@hashicorp/design-system-components/services/hds-theming";
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { inject } from '@ember/service';
|
|
3
|
-
import { action } from '@ember/object';
|
|
4
|
-
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
|
-
import { g, i, n } from 'decorator-transforms/runtime';
|
|
6
|
-
import { setComponentTemplate } from '@ember/component';
|
|
7
|
-
|
|
8
|
-
var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n{{!\n ------------------------------------------------------------------------------------------\n IMPORTANT: this is a temporary implementation, while we wait for the design specifications\n ------------------------------------------------------------------------------------------\n}}\n\n<Hds::Dropdown\n @enableCollisionDetection={{true}}\n @matchToggleWidth={{@toggleIsFullWidth}}\n class=\"hds-theme-switcher-control\"\n ...attributes\n as |D|\n>\n <D.ToggleButton\n @color=\"secondary\"\n @size={{this.toggleSize}}\n @isFullWidth={{this.toggleIsFullWidth}}\n @text={{this.toggleContent.label}}\n @icon={{this.toggleContent.icon}}\n />\n {{#each-in this._options as |key data|}}\n <D.Interactive @icon={{data.icon}} {{on \"click\" (fn this.onSelectTheme data.theme)}}>{{data.label}}</D.Interactive>\n {{/each-in}}\n</Hds::Dropdown>");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Copyright (c) HashiCorp, Inc.
|
|
12
|
-
* SPDX-License-Identifier: MPL-2.0
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const OPTIONS = {
|
|
16
|
-
system: {
|
|
17
|
-
theme: 'system',
|
|
18
|
-
icon: 'monitor',
|
|
19
|
-
label: 'System'
|
|
20
|
-
},
|
|
21
|
-
light: {
|
|
22
|
-
theme: 'light',
|
|
23
|
-
icon: 'sun',
|
|
24
|
-
label: 'Light'
|
|
25
|
-
},
|
|
26
|
-
dark: {
|
|
27
|
-
theme: 'dark',
|
|
28
|
-
icon: 'moon',
|
|
29
|
-
label: 'Dark'
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
class HdsThemeSwitcher extends Component {
|
|
33
|
-
static {
|
|
34
|
-
g(this.prototype, "hdsTheming", [inject]);
|
|
35
|
-
}
|
|
36
|
-
#hdsTheming = (i(this, "hdsTheming"), void 0);
|
|
37
|
-
get toggleSize() {
|
|
38
|
-
return this.args.toggleSize ?? 'small';
|
|
39
|
-
}
|
|
40
|
-
get toggleIsFullWidth() {
|
|
41
|
-
return this.args.toggleIsFullWidth ?? false;
|
|
42
|
-
}
|
|
43
|
-
get toggleContent() {
|
|
44
|
-
if (this.currentTheme === 'system' && this.hasSystemOption || this.currentTheme === 'light' || this.currentTheme === 'dark') {
|
|
45
|
-
return {
|
|
46
|
-
label: OPTIONS[this.currentTheme].label,
|
|
47
|
-
icon: OPTIONS[this.currentTheme].icon
|
|
48
|
-
};
|
|
49
|
-
} else {
|
|
50
|
-
return {
|
|
51
|
-
label: 'Theme',
|
|
52
|
-
icon: undefined
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
get hasSystemOption() {
|
|
57
|
-
return this.args.hasSystemOption ?? true;
|
|
58
|
-
}
|
|
59
|
-
get _options() {
|
|
60
|
-
const options = {
|
|
61
|
-
...OPTIONS
|
|
62
|
-
};
|
|
63
|
-
if (!this.hasSystemOption) {
|
|
64
|
-
delete options.system;
|
|
65
|
-
}
|
|
66
|
-
return options;
|
|
67
|
-
}
|
|
68
|
-
get currentTheme() {
|
|
69
|
-
// we get the theme from the global service
|
|
70
|
-
return this.hdsTheming.currentTheme;
|
|
71
|
-
}
|
|
72
|
-
onSelectTheme(theme) {
|
|
73
|
-
// we set the theme in the global service (and provide an optional user-defined callback)
|
|
74
|
-
this.hdsTheming.setTheme({
|
|
75
|
-
theme,
|
|
76
|
-
onSetTheme: this.args.onSetTheme
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
static {
|
|
80
|
-
n(this.prototype, "onSelectTheme", [action]);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
setComponentTemplate(TEMPLATE, HdsThemeSwitcher);
|
|
84
|
-
|
|
85
|
-
export { HdsThemeSwitcher as default };
|
|
86
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/theme-switcher/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\n// ------------------------------------------------------------------------------------------\n// IMPORTANT: this is a temporary implementation, while we wait for the design specifications\n// ------------------------------------------------------------------------------------------\n\nimport Component from '@glimmer/component';\nimport { inject as service } from '@ember/service';\nimport { action } from '@ember/object';\n\nimport type { HdsDropdownSignature } from '../dropdown/index.ts';\nimport type { HdsDropdownToggleButtonSignature } from '../dropdown/toggle/button.ts';\nimport type { HdsIconSignature } from '../icon/index.ts';\nimport type HdsThemingService from '../../../services/hds-theming.ts';\nimport type {\n HdsThemes,\n OnSetThemeCallback,\n} from '../../../services/hds-theming.ts';\n\ninterface ThemeOption {\n theme: HdsThemes | undefined;\n icon: HdsIconSignature['Args']['name'];\n label: string;\n}\n\nconst OPTIONS: Record<HdsThemes, ThemeOption> = {\n system: { theme: 'system', icon: 'monitor', label: 'System' },\n light: { theme: 'light', icon: 'sun', label: 'Light' },\n dark: { theme: 'dark', icon: 'moon', label: 'Dark' },\n};\n\ninterface HdsThemeSwitcherSignature {\n Args: {\n toggleSize?: HdsDropdownToggleButtonSignature['Args']['size'];\n toggleIsFullWidth?: HdsDropdownToggleButtonSignature['Args']['isFullWidth'];\n hasSystemOption?: boolean;\n onSetTheme?: OnSetThemeCallback;\n };\n Element: HdsDropdownSignature['Element'];\n}\n\nexport default class HdsThemeSwitcher extends Component<HdsThemeSwitcherSignature> {\n @service declare readonly hdsTheming: HdsThemingService;\n\n get toggleSize() {\n return this.args.toggleSize ?? 'small';\n }\n\n get toggleIsFullWidth() {\n return this.args.toggleIsFullWidth ?? false;\n }\n\n get toggleContent() {\n if (\n (this.currentTheme === 'system' && this.hasSystemOption) ||\n this.currentTheme === 'light' ||\n this.currentTheme === 'dark'\n ) {\n return {\n label: OPTIONS[this.currentTheme].label,\n icon: OPTIONS[this.currentTheme].icon,\n };\n } else {\n return { label: 'Theme', icon: undefined };\n }\n }\n\n get hasSystemOption() {\n return this.args.hasSystemOption ?? true;\n }\n\n get _options() {\n const options: Partial<typeof OPTIONS> = { ...OPTIONS };\n\n if (!this.hasSystemOption) {\n delete options.system;\n }\n\n return options;\n }\n\n get currentTheme() {\n // we get the theme from the global service\n return this.hdsTheming.currentTheme;\n }\n\n @action\n onSelectTheme(theme: HdsThemes | undefined): void {\n // we set the theme in the global service (and provide an optional user-defined callback)\n this.hdsTheming.setTheme({ theme, onSetTheme: this.args.onSetTheme });\n }\n}\n"],"names":["OPTIONS","system","theme","icon","label","light","dark","HdsThemeSwitcher","Component","g","prototype","service","i","void 0","toggleSize","args","toggleIsFullWidth","toggleContent","currentTheme","hasSystemOption","undefined","_options","options","hdsTheming","onSelectTheme","setTheme","onSetTheme","n","action","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;;AAyBA,MAAMA,OAAuC,GAAG;AAC9CC,EAAAA,MAAM,EAAE;AAAEC,IAAAA,KAAK,EAAE,QAAQ;AAAEC,IAAAA,IAAI,EAAE,SAAS;AAAEC,IAAAA,KAAK,EAAE;GAAU;AAC7DC,EAAAA,KAAK,EAAE;AAAEH,IAAAA,KAAK,EAAE,OAAO;AAAEC,IAAAA,IAAI,EAAE,KAAK;AAAEC,IAAAA,KAAK,EAAE;GAAS;AACtDE,EAAAA,IAAI,EAAE;AAAEJ,IAAAA,KAAK,EAAE,MAAM;AAAEC,IAAAA,IAAI,EAAE,MAAM;AAAEC,IAAAA,KAAK,EAAE;AAAO;AACrD,CAAC;AAYc,MAAMG,gBAAgB,SAASC,SAAS,CAA4B;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CAChFC,MAAO,CAAA,CAAA;AAAA;AAAA,EAAA,WAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,YAAA,CAAA,EAAAC,MAAA;EAER,IAAIC,UAAUA,GAAG;AACf,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,UAAU,IAAI,OAAO;AACxC,EAAA;EAEA,IAAIE,iBAAiBA,GAAG;AACtB,IAAA,OAAO,IAAI,CAACD,IAAI,CAACC,iBAAiB,IAAI,KAAK;AAC7C,EAAA;EAEA,IAAIC,aAAaA,GAAG;IAClB,IACG,IAAI,CAACC,YAAY,KAAK,QAAQ,IAAI,IAAI,CAACC,eAAe,IACvD,IAAI,CAACD,YAAY,KAAK,OAAO,IAC7B,IAAI,CAACA,YAAY,KAAK,MAAM,EAC5B;MACA,OAAO;QACLd,KAAK,EAAEJ,OAAO,CAAC,IAAI,CAACkB,YAAY,CAAC,CAACd,KAAK;AACvCD,QAAAA,IAAI,EAAEH,OAAO,CAAC,IAAI,CAACkB,YAAY,CAAC,CAACf;OAClC;AACH,IAAA,CAAC,MAAM;MACL,OAAO;AAAEC,QAAAA,KAAK,EAAE,OAAO;AAAED,QAAAA,IAAI,EAAEiB;OAAW;AAC5C,IAAA;AACF,EAAA;EAEA,IAAID,eAAeA,GAAG;AACpB,IAAA,OAAO,IAAI,CAACJ,IAAI,CAACI,eAAe,IAAI,IAAI;AAC1C,EAAA;EAEA,IAAIE,QAAQA,GAAG;AACb,IAAA,MAAMC,OAAgC,GAAG;MAAE,GAAGtB;KAAS;AAEvD,IAAA,IAAI,CAAC,IAAI,CAACmB,eAAe,EAAE;MACzB,OAAOG,OAAO,CAACrB,MAAM;AACvB,IAAA;AAEA,IAAA,OAAOqB,OAAO;AAChB,EAAA;EAEA,IAAIJ,YAAYA,GAAG;AACjB;AACA,IAAA,OAAO,IAAI,CAACK,UAAU,CAACL,YAAY;AACrC,EAAA;EAGAM,aAAaA,CAACtB,KAA4B,EAAQ;AAChD;AACA,IAAA,IAAI,CAACqB,UAAU,CAACE,QAAQ,CAAC;MAAEvB,KAAK;AAAEwB,MAAAA,UAAU,EAAE,IAAI,CAACX,IAAI,CAACW;AAAW,KAAC,CAAC;AACvE,EAAA;AAAC,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAjB,SAAA,EAAA,eAAA,EAAA,CAJAkB,MAAM,CAAA,CAAA;AAAA;AAKT;AAACC,oBAAA,CAAAC,QAAA,EAlDoBvB,gBAAgB,CAAA;;;;"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import Service from '@ember/service';
|
|
2
|
-
import { tracked } from '@glimmer/tracking';
|
|
3
|
-
import { g, i } from 'decorator-transforms/runtime';
|
|
4
|
-
|
|
5
|
-
let HdsThemeValues = /*#__PURE__*/function (HdsThemeValues) {
|
|
6
|
-
// system settings (prefers-color-scheme)
|
|
7
|
-
HdsThemeValues["System"] = "system";
|
|
8
|
-
// user settings for dark/light
|
|
9
|
-
HdsThemeValues["Light"] = "light";
|
|
10
|
-
HdsThemeValues["Dark"] = "dark";
|
|
11
|
-
return HdsThemeValues;
|
|
12
|
-
}({});
|
|
13
|
-
var HdsModesBaseValues = /*#__PURE__*/function (HdsModesBaseValues) {
|
|
14
|
-
HdsModesBaseValues["Hds"] = "hds"; // TODO understand if it should be `default`
|
|
15
|
-
return HdsModesBaseValues;
|
|
16
|
-
}(HdsModesBaseValues || {});
|
|
17
|
-
var HdsModesLightValues = /*#__PURE__*/function (HdsModesLightValues) {
|
|
18
|
-
HdsModesLightValues["CdsG0"] = "cds-g0";
|
|
19
|
-
HdsModesLightValues["CdsG10"] = "cds-g10";
|
|
20
|
-
return HdsModesLightValues;
|
|
21
|
-
}(HdsModesLightValues || {});
|
|
22
|
-
var HdsModesDarkValues = /*#__PURE__*/function (HdsModesDarkValues) {
|
|
23
|
-
HdsModesDarkValues["CdsG90"] = "cds-g90";
|
|
24
|
-
HdsModesDarkValues["CdsG100"] = "cds-g100";
|
|
25
|
-
return HdsModesDarkValues;
|
|
26
|
-
}(HdsModesDarkValues || {});
|
|
27
|
-
let HdsCssSelectorsValues = /*#__PURE__*/function (HdsCssSelectorsValues) {
|
|
28
|
-
HdsCssSelectorsValues["Data"] = "data";
|
|
29
|
-
HdsCssSelectorsValues["Class"] = "class";
|
|
30
|
-
return HdsCssSelectorsValues;
|
|
31
|
-
}({});
|
|
32
|
-
const THEMES = Object.values(HdsThemeValues);
|
|
33
|
-
const MODES_LIGHT = Object.values(HdsModesLightValues);
|
|
34
|
-
const MODES_DARK = Object.values(HdsModesDarkValues);
|
|
35
|
-
const MODES = [...Object.values(HdsModesBaseValues), ...MODES_LIGHT, ...MODES_DARK];
|
|
36
|
-
const HDS_THEMING_DATA_SELECTOR = 'data-hds-theme';
|
|
37
|
-
const HDS_THEMING_CLASS_SELECTOR_PREFIX = 'hds-theme';
|
|
38
|
-
const HDS_THEMING_CLASS_SELECTORS_LIST = [...MODES_LIGHT, ...MODES_DARK].map(mode => `${HDS_THEMING_CLASS_SELECTOR_PREFIX}-${mode}`);
|
|
39
|
-
const HDS_THEMING_LOCALSTORAGE_DATA = 'hds-theming-data';
|
|
40
|
-
const DEFAULT_THEMING_OPTION_LIGHT_THEME = HdsModesLightValues.CdsG0;
|
|
41
|
-
const DEFAULT_THEMING_OPTION_DARK_THEME = HdsModesDarkValues.CdsG100;
|
|
42
|
-
const DEFAULT_THEMING_OPTION_CSS_SELECTOR = 'data';
|
|
43
|
-
class HdsThemingService extends Service {
|
|
44
|
-
static {
|
|
45
|
-
g(this.prototype, "_currentTheme", [tracked], function () {
|
|
46
|
-
return undefined;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
#_currentTheme = (i(this, "_currentTheme"), void 0);
|
|
50
|
-
static {
|
|
51
|
-
g(this.prototype, "_currentMode", [tracked], function () {
|
|
52
|
-
return undefined;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
#_currentMode = (i(this, "_currentMode"), void 0);
|
|
56
|
-
static {
|
|
57
|
-
g(this.prototype, "_currentLightTheme", [tracked], function () {
|
|
58
|
-
return DEFAULT_THEMING_OPTION_LIGHT_THEME;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
#_currentLightTheme = (i(this, "_currentLightTheme"), void 0);
|
|
62
|
-
static {
|
|
63
|
-
g(this.prototype, "_currentDarkTheme", [tracked], function () {
|
|
64
|
-
return DEFAULT_THEMING_OPTION_DARK_THEME;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
#_currentDarkTheme = (i(this, "_currentDarkTheme"), void 0);
|
|
68
|
-
static {
|
|
69
|
-
g(this.prototype, "_currentCssSelector", [tracked], function () {
|
|
70
|
-
return DEFAULT_THEMING_OPTION_CSS_SELECTOR;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
#_currentCssSelector = (i(this, "_currentCssSelector"), void 0);
|
|
74
|
-
static {
|
|
75
|
-
g(this.prototype, "globalOnSetTheme", [tracked]);
|
|
76
|
-
}
|
|
77
|
-
#globalOnSetTheme = (i(this, "globalOnSetTheme"), void 0);
|
|
78
|
-
initializeTheme() {
|
|
79
|
-
const rawStoredThemingData = localStorage.getItem(HDS_THEMING_LOCALSTORAGE_DATA);
|
|
80
|
-
if (rawStoredThemingData !== null) {
|
|
81
|
-
const storedThemingData = JSON.parse(rawStoredThemingData);
|
|
82
|
-
if (storedThemingData) {
|
|
83
|
-
const {
|
|
84
|
-
theme,
|
|
85
|
-
options
|
|
86
|
-
} = storedThemingData;
|
|
87
|
-
this.setTheme({
|
|
88
|
-
theme,
|
|
89
|
-
options
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
setTheme({
|
|
95
|
-
theme,
|
|
96
|
-
options,
|
|
97
|
-
onSetTheme
|
|
98
|
-
}) {
|
|
99
|
-
if (options !== undefined) {
|
|
100
|
-
// if we have new options, we override the current ones (`lightTheme` / `darkTheme` / `cssSelector`)
|
|
101
|
-
// these options can be used by consumers that want to customize how they apply theming
|
|
102
|
-
// (and used by the showcase for the custom theming / theme switching logic)
|
|
103
|
-
if (Object.hasOwn(options, 'lightTheme') && Object.hasOwn(options, 'darkTheme') && Object.hasOwn(options, 'cssSelector')) {
|
|
104
|
-
const {
|
|
105
|
-
lightTheme,
|
|
106
|
-
darkTheme,
|
|
107
|
-
cssSelector
|
|
108
|
-
} = options;
|
|
109
|
-
this._currentLightTheme = lightTheme;
|
|
110
|
-
this._currentDarkTheme = darkTheme;
|
|
111
|
-
this._currentCssSelector = cssSelector;
|
|
112
|
-
} else {
|
|
113
|
-
// fallback if something goes wrong
|
|
114
|
-
this._currentLightTheme = DEFAULT_THEMING_OPTION_LIGHT_THEME;
|
|
115
|
-
this._currentDarkTheme = DEFAULT_THEMING_OPTION_DARK_THEME;
|
|
116
|
-
this._currentCssSelector = DEFAULT_THEMING_OPTION_CSS_SELECTOR;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// set the current theme/mode (`currentTheme` / `currentMode`)
|
|
121
|
-
if (theme === undefined ||
|
|
122
|
-
// standard (no theming)
|
|
123
|
-
!THEMES.includes(theme) // handle possible errors
|
|
124
|
-
) {
|
|
125
|
-
this._currentTheme = undefined;
|
|
126
|
-
this._currentMode = undefined;
|
|
127
|
-
} else if (theme === HdsThemeValues.System // system (prefers-color-scheme)
|
|
128
|
-
) {
|
|
129
|
-
this._currentTheme = HdsThemeValues.System;
|
|
130
|
-
this._currentMode = undefined;
|
|
131
|
-
} else {
|
|
132
|
-
this._currentTheme = theme;
|
|
133
|
-
if (this._currentTheme === HdsThemeValues.Light) {
|
|
134
|
-
this._currentMode = this._currentLightTheme;
|
|
135
|
-
}
|
|
136
|
-
if (this._currentTheme === HdsThemeValues.Dark) {
|
|
137
|
-
this._currentMode = this._currentDarkTheme;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// IMPORTANT: for this to work, it needs to be the HTML tag (it's the `:root` in CSS)
|
|
142
|
-
const rootElement = document.querySelector('html');
|
|
143
|
-
if (!rootElement) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
// remove or update the CSS selectors applied to the root element (depending on the `theme` argument)
|
|
147
|
-
rootElement.removeAttribute(HDS_THEMING_DATA_SELECTOR);
|
|
148
|
-
rootElement.classList.remove(...HDS_THEMING_CLASS_SELECTORS_LIST);
|
|
149
|
-
if (this._currentMode !== undefined) {
|
|
150
|
-
if (this._currentCssSelector === 'data') {
|
|
151
|
-
rootElement.setAttribute(HDS_THEMING_DATA_SELECTOR, this._currentMode);
|
|
152
|
-
} else if (this._currentCssSelector === 'class') {
|
|
153
|
-
rootElement.classList.add(`${HDS_THEMING_CLASS_SELECTOR_PREFIX}-${this._currentMode}`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// store the current theme and theming options in local storage (unless undefined)
|
|
158
|
-
localStorage.setItem(HDS_THEMING_LOCALSTORAGE_DATA, JSON.stringify({
|
|
159
|
-
theme: this._currentTheme,
|
|
160
|
-
options: {
|
|
161
|
-
lightTheme: this._currentLightTheme,
|
|
162
|
-
darkTheme: this._currentDarkTheme,
|
|
163
|
-
cssSelector: this._currentCssSelector
|
|
164
|
-
}
|
|
165
|
-
}));
|
|
166
|
-
|
|
167
|
-
// this is a general callback that can be defined globally (by extending the service)
|
|
168
|
-
if (this.globalOnSetTheme) {
|
|
169
|
-
this.globalOnSetTheme({
|
|
170
|
-
currentTheme: this._currentTheme,
|
|
171
|
-
currentMode: this._currentMode
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// this is a "local" callback that can be defined "locally" (eg. in a theme switcher)
|
|
176
|
-
if (onSetTheme) {
|
|
177
|
-
onSetTheme({
|
|
178
|
-
currentTheme: this._currentTheme,
|
|
179
|
-
currentMode: this._currentMode
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// getters used for reactivity in the components/services using this service
|
|
185
|
-
|
|
186
|
-
get currentTheme() {
|
|
187
|
-
return this._currentTheme;
|
|
188
|
-
}
|
|
189
|
-
get currentMode() {
|
|
190
|
-
return this._currentMode;
|
|
191
|
-
}
|
|
192
|
-
get currentLightTheme() {
|
|
193
|
-
return this._currentLightTheme ?? DEFAULT_THEMING_OPTION_LIGHT_THEME;
|
|
194
|
-
}
|
|
195
|
-
get currentDarkTheme() {
|
|
196
|
-
return this._currentDarkTheme ?? DEFAULT_THEMING_OPTION_DARK_THEME;
|
|
197
|
-
}
|
|
198
|
-
get currentCssSelector() {
|
|
199
|
-
return this._currentCssSelector ?? DEFAULT_THEMING_OPTION_CSS_SELECTOR;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export { DEFAULT_THEMING_OPTION_CSS_SELECTOR, DEFAULT_THEMING_OPTION_DARK_THEME, DEFAULT_THEMING_OPTION_LIGHT_THEME, HDS_THEMING_CLASS_SELECTORS_LIST, HDS_THEMING_CLASS_SELECTOR_PREFIX, HDS_THEMING_DATA_SELECTOR, HDS_THEMING_LOCALSTORAGE_DATA, HdsCssSelectorsValues, HdsThemeValues, MODES, MODES_DARK, MODES_LIGHT, THEMES, HdsThemingService as default };
|
|
204
|
-
//# sourceMappingURL=hds-theming.js.map
|