@hashicorp/design-system-components 2.1.0 → 2.3.0
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/CHANGELOG.md +48 -0
- package/HOW-TO-TEST-A-COMPONENT-IN-CLOUD-UI.md +28 -3
- package/addon/components/hds/app-frame/index.hbs +24 -0
- package/addon/components/hds/app-frame/index.js +52 -0
- package/addon/components/hds/app-frame/parts/footer.hbs +7 -0
- package/addon/components/hds/app-frame/parts/header.hbs +7 -0
- package/addon/components/hds/app-frame/parts/main.hbs +7 -0
- package/addon/components/hds/app-frame/parts/modals.hbs +6 -0
- package/addon/components/hds/app-frame/parts/sidebar.hbs +7 -0
- package/addon/components/hds/application-state/footer.js +5 -0
- package/addon/components/hds/dropdown/index.hbs +2 -2
- package/addon/components/hds/dropdown/index.js +18 -2
- package/addon/components/hds/flyout/footer.hbs +7 -0
- package/addon/components/hds/flyout/index.hbs +1 -0
- package/addon/components/hds/form/checkbox/field.hbs +0 -1
- package/addon/components/hds/form/field/index.hbs +3 -1
- package/addon/components/hds/form/radio/field.hbs +0 -1
- package/addon/components/hds/form/select/field.hbs +0 -1
- package/addon/components/hds/form/text-input/field.hbs +0 -1
- package/addon/components/hds/form/textarea/field.hbs +0 -1
- package/addon/components/hds/form/toggle/base.hbs +1 -1
- package/addon/components/hds/form/toggle/field.hbs +0 -2
- package/addon/components/hds/segmented-group/index.hbs +15 -0
- package/addon/components/hds/side-nav/base.hbs +14 -0
- package/addon/components/hds/side-nav/{home-link.js → header/home-link.js} +2 -2
- package/addon/components/hds/side-nav/{icon-button.js → header/icon-button.js} +2 -2
- package/addon/components/hds/side-nav/{header.hbs → header/index.hbs} +2 -2
- package/addon/components/hds/side-nav/index.hbs +40 -0
- package/addon/components/hds/side-nav/index.js +107 -0
- package/addon/components/hds/side-nav/list/index.hbs +2 -0
- package/addon/components/hds/side-nav/portal/index.hbs +12 -0
- package/addon/components/hds/side-nav/portal/target.hbs +14 -0
- package/addon/components/hds/side-nav/portal/target.js +153 -0
- package/addon/components/hds/tooltip-button/index.hbs +11 -0
- package/addon/components/hds/tooltip-button/index.js +86 -0
- package/addon/modifiers/hds-tooltip.js +164 -0
- package/app/components/hds/{side-nav/wrapper.js → app-frame/index.js} +1 -1
- package/app/components/hds/app-frame/parts/footer.js +6 -0
- package/app/components/hds/app-frame/parts/header.js +6 -0
- package/app/components/hds/{side-nav/icon-button.js → app-frame/parts/main.js} +1 -1
- package/app/components/hds/app-frame/parts/modals.js +6 -0
- package/app/components/hds/app-frame/parts/sidebar.js +6 -0
- package/app/components/hds/{side-nav/home-link.js → flyout/footer.js} +1 -1
- package/app/components/hds/segmented-group/index.js +6 -0
- package/app/components/hds/side-nav/base.js +6 -0
- package/app/components/hds/side-nav/header/home-link.js +6 -0
- package/app/components/hds/side-nav/header/icon-button.js +6 -0
- package/app/components/hds/side-nav/index.js +6 -0
- package/app/components/hds/side-nav/portal/index.js +6 -0
- package/app/components/hds/side-nav/portal/target.js +6 -0
- package/app/components/hds/tooltip-button/index.js +6 -0
- package/app/modifiers/hds-tooltip.js +6 -0
- package/app/styles/@hashicorp/design-system-components.scss +3 -0
- package/app/styles/@hashicorp/design-system-power-select-overrides.scss +32 -2
- package/app/styles/components/app-frame.scss +60 -0
- package/app/styles/components/dropdown.scss +11 -0
- package/app/styles/components/flyout.scss +15 -1
- package/app/styles/components/form/field.scss +4 -1
- package/app/styles/components/form/textarea.scss +1 -0
- package/app/styles/components/segmented-group.scss +59 -0
- package/app/styles/components/side-nav/a11y-refocus.scss +30 -0
- package/app/styles/components/side-nav/content.scss +159 -0
- package/app/styles/components/side-nav/header.scss +103 -0
- package/app/styles/components/side-nav/index.scss +10 -0
- package/app/styles/components/side-nav/main.scss +202 -0
- package/app/styles/components/side-nav/vars.scss +36 -0
- package/app/styles/components/tooltip.scss +84 -0
- package/package.json +7 -4
- package/addon/components/hds/form/toggle/base.js +0 -27
- package/addon/components/hds/side-nav/wrapper.hbs +0 -18
- package/app/styles/components/side-nav.scss +0 -275
- /package/addon/components/hds/side-nav/{home-link.hbs → header/home-link.hbs} +0 -0
- /package/addon/components/hds/side-nav/{icon-button.hbs → header/icon-button.hbs} +0 -0
- /package/app/components/hds/side-nav/{header.js → header/index.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @hashicorp/design-system-components
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1283](https://github.com/hashicorp/design-system/pull/1283) [`d0ae66503`](https://github.com/hashicorp/design-system/commit/d0ae665033e6b83a65c2dcde8630985f76872901) Thanks [@KristinLBradley](https://github.com/KristinLBradley)! - - Add new `TooltipButton` component and `hds-tooltip` modifier
|
|
8
|
+
|
|
9
|
+
- Add design tokens for `Tooltip`
|
|
10
|
+
|
|
11
|
+
- [#1316](https://github.com/hashicorp/design-system/pull/1316) [`5763ffbca`](https://github.com/hashicorp/design-system/commit/5763ffbca564d3a23b8a497393acc43729d92de8) Thanks [@alex-ju](https://github.com/alex-ju)! - Add `SegmentedGroup` component
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#1329](https://github.com/hashicorp/design-system/pull/1329) [`216ce51a8`](https://github.com/hashicorp/design-system/commit/216ce51a81383f2e8a5d1f989c5148edf74268f6) Thanks [@didoo](https://github.com/didoo)! - `SideNav::Portal::Target` - Removed extra call to `commitStyles`
|
|
16
|
+
|
|
17
|
+
- [#1328](https://github.com/hashicorp/design-system/pull/1328) [`095caf4d4`](https://github.com/hashicorp/design-system/commit/095caf4d430d459d848647ed3c1dba3155c358cf) Thanks [@didoo](https://github.com/didoo)! - `SideNav::Portal::Target` - Made the `:hover:focus` state (the one the links finds itself once clicked) identical to the `:active/.active` state
|
|
18
|
+
|
|
19
|
+
- [#1334](https://github.com/hashicorp/design-system/pull/1334) [`f6fa1e15e`](https://github.com/hashicorp/design-system/commit/f6fa1e15ee52bc8962fc244a73640dd57d62769a) Thanks [@didoo](https://github.com/didoo)! - `SideNav` - added missing override of `Dropdown::ToggleButton`
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`d0ae66503`](https://github.com/hashicorp/design-system/commit/d0ae665033e6b83a65c2dcde8630985f76872901)]:
|
|
22
|
+
- @hashicorp/design-system-tokens@1.5.0
|
|
23
|
+
|
|
24
|
+
## 2.2.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- [#1284](https://github.com/hashicorp/design-system/pull/1284) [`050a2afa5`](https://github.com/hashicorp/design-system/commit/050a2afa5bd539e15ff21728bb6ac27ac2b90dc6) Thanks [@didoo](https://github.com/didoo)! - Added `AppFrame` component
|
|
29
|
+
|
|
30
|
+
- [#1321](https://github.com/hashicorp/design-system/pull/1321) [`6cb5f55b1`](https://github.com/hashicorp/design-system/commit/6cb5f55b1a47d9718960e17c68c7ad3b8bcad04c) Thanks [@didoo](https://github.com/didoo)! - Extracted `Hds::SideNav::Base` from the `Hds::SideNav` component
|
|
31
|
+
|
|
32
|
+
- [#1304](https://github.com/hashicorp/design-system/pull/1304) [`038d8306a`](https://github.com/hashicorp/design-system/commit/038d8306aee38711ba846e4d7272d237b93733e5) Thanks [@didoo](https://github.com/didoo)! - Extended the `Hds::SideNav` component to support responsiveness (animation/transition) and content portaling by adapting existing implementation for Cloud UI
|
|
33
|
+
|
|
34
|
+
- [#1315](https://github.com/hashicorp/design-system/pull/1315) [`e900dbcca`](https://github.com/hashicorp/design-system/commit/e900dbcca7df1592559245e2b2031d0b2a9ec617) Thanks [@didoo](https://github.com/didoo)! - Added a `@isInline` argument to the `Hds::Dropdown` component
|
|
35
|
+
|
|
36
|
+
- [#1309](https://github.com/hashicorp/design-system/pull/1309) [`ef7eeff66`](https://github.com/hashicorp/design-system/commit/ef7eeff66d1d9b81b53cf082085eb1fa636263ef) Thanks [@jorytindall](https://github.com/jorytindall)! - Add `Hds::Flyout::Footer` as generic block to `Hds::Flyout`
|
|
37
|
+
|
|
38
|
+
- [#1317](https://github.com/hashicorp/design-system/pull/1317) [`fa3a328a1`](https://github.com/hashicorp/design-system/commit/fa3a328a1806af8482bcedee002c8bc3232f3968) Thanks [@didoo](https://github.com/didoo)! - Changed order of "modal" container element in the DOM for the `AppFrame` component
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- [#1312](https://github.com/hashicorp/design-system/pull/1312) [`cd1527ef5`](https://github.com/hashicorp/design-system/commit/cd1527ef5de743e1fdf9b982bff7aa1bbc18ac54) Thanks [@alex-ju](https://github.com/alex-ju)! - Add `min-height` to `Hds::Textarea`
|
|
43
|
+
|
|
44
|
+
- [#1313](https://github.com/hashicorp/design-system/pull/1313) [`5a2f5778d`](https://github.com/hashicorp/design-system/commit/5a2f5778d5e1d57a7d0d080f01319492e1a5a8b7) Thanks [@didoo](https://github.com/didoo)! - Added design tokens for `SideNav` component
|
|
45
|
+
|
|
46
|
+
- [#1306](https://github.com/hashicorp/design-system/pull/1306) [`e993f6c42`](https://github.com/hashicorp/design-system/commit/e993f6c42a502f4d43cce2e1e7b1a7a8cfd90cdd) Thanks [@alex-ju](https://github.com/alex-ju)! - Fix `PowerSelectMultiple` style overrides when search is enabled
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [[`5a2f5778d`](https://github.com/hashicorp/design-system/commit/5a2f5778d5e1d57a7d0d080f01319492e1a5a8b7)]:
|
|
49
|
+
- @hashicorp/design-system-tokens@1.4.2
|
|
50
|
+
|
|
3
51
|
## 2.1.0
|
|
4
52
|
|
|
5
53
|
### Minor Changes
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
# How to test a component in Cloud UI
|
|
2
2
|
|
|
3
|
-
To test a
|
|
3
|
+
To test a component that is under development (or because it’s new or has been modified) you have a few options:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- you can use your local environment as source for the `@hashicorp/design-system-components` package
|
|
6
|
+
- you can install the `@hashicorp/design-system-components` package using a branch available on GitHub
|
|
7
|
+
|
|
8
|
+
This is the case when the component has not yet been released as an npm package, of course.
|
|
9
|
+
|
|
10
|
+
## Using your local environment (via symlink)
|
|
11
|
+
|
|
12
|
+
This approach is the preferable one, if there is an ongoing development of the component and you want to see the changes reflected immediately in the application (automatically rebuilt/refreshed whenever you save the HDS files).
|
|
13
|
+
|
|
14
|
+
### Prepare the Cloud UI project
|
|
6
15
|
|
|
7
16
|
For simplicity, you will need three CLI/terminal windows/tabs opened.
|
|
8
17
|
|
|
@@ -13,7 +22,7 @@ In in the first terminal window go the folder containing your local version of t
|
|
|
13
22
|
- run `rm -fr node_modules/` to start from a blank slate
|
|
14
23
|
- run `yarn` to make sure all the packages are installed
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
### Replace the installed `@hashicorp/design-system-components` package in Cloud UI with the local one
|
|
17
26
|
|
|
18
27
|
In the second terminal window:
|
|
19
28
|
|
|
@@ -52,3 +61,19 @@ Everything should work and you should be able to do whatever you need to do in t
|
|
|
52
61
|
- run `rm design-system-components` (no need for the `-fr` option, it's a symlink file not a folder)
|
|
53
62
|
- go to the root of the Cloud UI project
|
|
54
63
|
- run `yarn` to reinstall all the missing packages (including `@hashicorp/design-system-components` from NPM)
|
|
64
|
+
|
|
65
|
+
## Using a remote branch (via GitHub)
|
|
66
|
+
|
|
67
|
+
This approach is more suitable for one-off testing before releasing a package, less so for ongoing development.
|
|
68
|
+
|
|
69
|
+
### Override the package resolution in the `package.json` file in the root
|
|
70
|
+
|
|
71
|
+
You can override every dependency declared in the engines' `package.json` files with a single entry in the `package.json` file in the root of the project folder, by adding this line to the `"resolutions"` block:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
"@hashicorp/design-system-components": "https://github.com/hashicorp/design-system#head=BRANCH-NAME&workspace=@hashicorp/design-system-components"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Once done run `yarn install` to use the "remote" version of the package, update the `node_modules` and the `yarn.lock` file.
|
|
78
|
+
|
|
79
|
+
**IMPORTANT**: the way in which yarn works in this case is that it resolves in a hash referencing a commit in `yarn.lock`; so if you make changes to the branch, they’re not reflected in the local `node_modules` unless you change the hash manually in the `yarn.lock` to point to another commit, and re-run the `yarn install` command.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
5
|
+
<div class="hds-app-frame" ...attributes>
|
|
6
|
+
{{#if this.hasHeader}}
|
|
7
|
+
{{yield (hash Header=(component "hds/app-frame/parts/header"))}}
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if this.hasSidebar}}
|
|
10
|
+
{{yield (hash Sidebar=(component "hds/app-frame/parts/sidebar"))}}
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{!
|
|
13
|
+
IMPORTANT: since the modals may be injected via portal or `in-element` with code that lives in the "main" container,
|
|
14
|
+
the "modal" container needs to be present in the DOM _before_ the "main" block, otherwise it may cause errors
|
|
15
|
+
where the target DOM element is not found (for example in tests where the modal may be immediately opened on first render).
|
|
16
|
+
}}
|
|
17
|
+
{{#if this.hasModals}}
|
|
18
|
+
{{yield (hash Modals=(component "hds/app-frame/parts/modals"))}}
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{yield (hash Main=(component "hds/app-frame/parts/main"))}}
|
|
21
|
+
{{#if this.hasFooter}}
|
|
22
|
+
{{yield (hash Footer=(component "hds/app-frame/parts/footer"))}}
|
|
23
|
+
{{/if}}
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Component from '@glimmer/component';
|
|
7
|
+
|
|
8
|
+
export default class HdsAppFrameIndexComponent extends Component {
|
|
9
|
+
/**
|
|
10
|
+
* Indicates if the "header" container should be displayed
|
|
11
|
+
*
|
|
12
|
+
* @param hasHeader
|
|
13
|
+
* @type {boolean}
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
get hasHeader() {
|
|
17
|
+
return this.args.hasHeader ?? true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Indicates if the "sidebar" container should be displayed
|
|
22
|
+
*
|
|
23
|
+
* @param hasSidebar
|
|
24
|
+
* @type {boolean}
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
get hasSidebar() {
|
|
28
|
+
return this.args.hasSidebar ?? true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Indicates if the "footer" container should be displayed
|
|
33
|
+
*
|
|
34
|
+
* @param hasFooter
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
get hasFooter() {
|
|
39
|
+
return this.args.hasFooter ?? true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Indicates if the "modals" container should be displayed
|
|
44
|
+
*
|
|
45
|
+
* @param hasModals
|
|
46
|
+
* @type {boolean}
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
get hasModals() {
|
|
50
|
+
return this.args.hasModals ?? true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Copyright (c) HashiCorp, Inc.
|
|
3
3
|
SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
}}
|
|
5
|
-
<Hds::Disclosure class=
|
|
5
|
+
<Hds::Disclosure class={{this.classNames}} @onClose={{@onClose}} ...attributes>
|
|
6
6
|
<:toggle as |t|>
|
|
7
7
|
{{yield
|
|
8
8
|
(hash
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}}
|
|
13
13
|
</:toggle>
|
|
14
14
|
<:content as |c|>
|
|
15
|
-
<div class={{this.
|
|
15
|
+
<div class={{this.classNamesContent}} {{style width=@width height=@height}}>
|
|
16
16
|
{{yield (hash Header=(component "hds/dropdown/header"))}}
|
|
17
17
|
<ul class="hds-dropdown__list" {{did-insert this.didInsertList}}>
|
|
18
18
|
{{yield
|
|
@@ -39,11 +39,27 @@ export default class HdsDropdownIndexComponent extends Component {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Get the class names to apply to the
|
|
42
|
+
* Get the class names to apply to the element
|
|
43
43
|
* @method classNames
|
|
44
|
-
* @return {string} The "class" attribute to apply to the
|
|
44
|
+
* @return {string} The "class" attribute to apply to the root element
|
|
45
45
|
*/
|
|
46
46
|
get classNames() {
|
|
47
|
+
let classes = ['hds-dropdown'];
|
|
48
|
+
|
|
49
|
+
// add a class based on the @isInline argument
|
|
50
|
+
if (this.args.isInline) {
|
|
51
|
+
classes.push('hds-dropdown--is-inline');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return classes.join(' ');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the class names to apply to the content
|
|
59
|
+
* @method classNamesContent
|
|
60
|
+
* @return {string} The "class" attribute to apply to the disclosed content
|
|
61
|
+
*/
|
|
62
|
+
get classNamesContent() {
|
|
47
63
|
let classes = ['hds-dropdown__content'];
|
|
48
64
|
|
|
49
65
|
// add a class based on the @listPosition argument
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
{{yield (hash Header=(component "hds/flyout/header" id=this.id onDismiss=this.onDismiss))}}
|
|
13
13
|
{{yield (hash Description=(component "hds/flyout/description"))}}
|
|
14
14
|
{{yield (hash Body=(component "hds/flyout/body"))}}
|
|
15
|
+
{{yield (hash Footer=(component "hds/flyout/footer" onDismiss=this.onDismiss))}}
|
|
15
16
|
</dialog>
|
|
16
17
|
{{#if this.isOpen}}
|
|
17
18
|
<div class="hds-flyout__overlay"></div>
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
)
|
|
25
25
|
)
|
|
26
26
|
}}
|
|
27
|
-
|
|
27
|
+
<div class="hds-form-field__control">
|
|
28
|
+
{{yield (hash Control=(component "hds/yield") id=this.id ariaDescribedBy=this.ariaDescribedBy)}}
|
|
29
|
+
</div>
|
|
28
30
|
{{yield
|
|
29
31
|
(hash
|
|
30
32
|
Error=(component
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Copyright (c) HashiCorp, Inc.
|
|
3
3
|
SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
}}
|
|
5
|
-
<div class=
|
|
5
|
+
<div class="hds-form-toggle">
|
|
6
6
|
<input class="hds-form-toggle__control" type="checkbox" ...attributes value={{@value}} role="switch" />
|
|
7
7
|
<div class="hds-form-toggle__facade"></div>
|
|
8
8
|
</div>
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
{{yield (hash Label=F.Label HelperText=F.HelperText Error=F.Error)}}
|
|
14
14
|
<F.Control>
|
|
15
15
|
<Hds::Form::Toggle::Base
|
|
16
|
-
{{! template-lint-disable no-capital-arguments }}
|
|
17
|
-
@_wrapperClass="hds-form-field__control"
|
|
18
16
|
@value={{@value}}
|
|
19
17
|
required={{@isRequired}}
|
|
20
18
|
...attributes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
5
|
+
<div class="hds-segmented-group" ...attributes>
|
|
6
|
+
{{yield
|
|
7
|
+
(hash
|
|
8
|
+
Button=(component "hds/button")
|
|
9
|
+
Dropdown=(component "hds/dropdown")
|
|
10
|
+
Select=(component "hds/form/select/base")
|
|
11
|
+
TextInput=(component "hds/form/text-input/base")
|
|
12
|
+
Generic=(component "hds/yield")
|
|
13
|
+
)
|
|
14
|
+
}}
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<div class="hds-side-nav" ...attributes>
|
|
2
|
+
<div class="hds-side-nav__wrapper">
|
|
3
|
+
{{yield to="root"}}
|
|
4
|
+
<div class="hds-side-nav__wrapper-header">
|
|
5
|
+
{{yield to="header"}}
|
|
6
|
+
</div>
|
|
7
|
+
<div class="hds-side-nav__wrapper-body">
|
|
8
|
+
{{yield to="body"}}
|
|
9
|
+
</div>
|
|
10
|
+
<div class="hds-side-nav__wrapper-footer">
|
|
11
|
+
{{yield to="footer"}}
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import Component from '@glimmer/component';
|
|
7
7
|
import { assert } from '@ember/debug';
|
|
8
8
|
|
|
9
|
-
export default class
|
|
9
|
+
export default class HdsSideNavHeaderHomeLinkComponent extends Component {
|
|
10
10
|
/**
|
|
11
11
|
* @param ariaLabel
|
|
12
12
|
* @type {string}
|
|
@@ -16,7 +16,7 @@ export default class HdsSideNavHomeLinkComponent extends Component {
|
|
|
16
16
|
let { ariaLabel } = this.args;
|
|
17
17
|
|
|
18
18
|
assert(
|
|
19
|
-
'@ariaLabel for "Hds::SideNav::HomeLink" must have a valid value',
|
|
19
|
+
'@ariaLabel for "Hds::SideNav::Header::HomeLink" ("Logo") must have a valid value',
|
|
20
20
|
ariaLabel !== undefined
|
|
21
21
|
);
|
|
22
22
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import Component from '@glimmer/component';
|
|
7
7
|
import { assert } from '@ember/debug';
|
|
8
8
|
|
|
9
|
-
export default class
|
|
9
|
+
export default class HdsSideNavHeaderIconButtonComponent extends Component {
|
|
10
10
|
/**
|
|
11
11
|
* @param ariaLabel
|
|
12
12
|
* @type {string}
|
|
@@ -16,7 +16,7 @@ export default class HdsSideNavIconButtonComponent extends Component {
|
|
|
16
16
|
let { ariaLabel } = this.args;
|
|
17
17
|
|
|
18
18
|
assert(
|
|
19
|
-
'@ariaLabel for "Hds::SideNav::IconButton" must have a valid value',
|
|
19
|
+
'@ariaLabel for "Hds::SideNav::Header::IconButton" must have a valid value',
|
|
20
20
|
ariaLabel !== undefined
|
|
21
21
|
);
|
|
22
22
|
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
}}
|
|
5
5
|
|
|
6
6
|
<div class="hds-side-nav-header" ...attributes>
|
|
7
|
-
<div class="hds-side-nav-header__logo">
|
|
7
|
+
<div class="hds-side-nav-header__logo-container">
|
|
8
8
|
{{yield to="logo"}}
|
|
9
9
|
</div>
|
|
10
|
-
<div class="hds-side-nav-header__actions">
|
|
10
|
+
<div class="hds-side-nav-header__actions-container hds-side-nav-hide-when-minimized">
|
|
11
11
|
{{yield to="actions"}}
|
|
12
12
|
</div>
|
|
13
13
|
</div>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
5
|
+
|
|
6
|
+
<Hds::SideNav::Base class={{this.classNames}} ...attributes {{focus-trap isActive=this.shouldTrapFocus}}>
|
|
7
|
+
<:root>
|
|
8
|
+
{{#if this.hasA11yRefocus}}
|
|
9
|
+
<NavigationNarrator
|
|
10
|
+
@routeChangeValidator={{@a11yRefocusRouteChangeValidator}}
|
|
11
|
+
@skipTo="#{{@a11yRefocusSkipTo}}"
|
|
12
|
+
@skipText={{@a11yRefocusSkipText}}
|
|
13
|
+
@navigationText={{@a11yRefocusNavigationText}}
|
|
14
|
+
/>
|
|
15
|
+
{{/if}}
|
|
16
|
+
{{#if this.isResponsive}}
|
|
17
|
+
{{! template-lint-disable no-invalid-interactive}}
|
|
18
|
+
<div class="hds-side-nav__overlay" {{on "click" this.toggleMinimizedStatus}} />
|
|
19
|
+
{{! template-lint-enable no-invalid-interactive}}
|
|
20
|
+
<button
|
|
21
|
+
class="hds-side-nav__menu-toggle-button"
|
|
22
|
+
type="button"
|
|
23
|
+
{{on "click" this.toggleMinimizedStatus}}
|
|
24
|
+
{{! To be localized - see: https://hashicorp.atlassian.net/browse/HDS-567 }}
|
|
25
|
+
aria-label={{if this.isMinimized "Open menu" "Close menu"}}
|
|
26
|
+
>
|
|
27
|
+
<FlightIcon @name={{if this.isMinimized "menu" "x"}} @size="24" @stretched={{true}} />
|
|
28
|
+
</button>
|
|
29
|
+
{{/if}}
|
|
30
|
+
</:root>
|
|
31
|
+
<:header as |Header|>
|
|
32
|
+
{{yield (hash Header=Header isMinimized=this.isMinimized) to="header"}}
|
|
33
|
+
</:header>
|
|
34
|
+
<:body as |Body|>
|
|
35
|
+
{{yield (hash Body=Body isMinimized=this.isMinimized) to="body"}}
|
|
36
|
+
</:body>
|
|
37
|
+
<:footer as |Footer|>
|
|
38
|
+
{{yield (hash Footer=Footer isMinimized=this.isMinimized) to="footer"}}
|
|
39
|
+
</:footer>
|
|
40
|
+
</Hds::SideNav::Base>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Component from '@glimmer/component';
|
|
7
|
+
import { action } from '@ember/object';
|
|
8
|
+
import { tracked } from '@glimmer/tracking';
|
|
9
|
+
import { assert } from '@ember/debug';
|
|
10
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
11
|
+
|
|
12
|
+
export default class HdsSideNavComponent extends Component {
|
|
13
|
+
@tracked isResponsive = this.args.isResponsive ?? true;
|
|
14
|
+
@tracked isMinimized = this.isResponsive; // we set it minimized by default so that if we switch viewport from desktop to mobile its already minimized
|
|
15
|
+
@tracked isDesktop = true;
|
|
16
|
+
hasA11yRefocus = this.args.hasA11yRefocus ?? true;
|
|
17
|
+
|
|
18
|
+
desktopMQVal = getComputedStyle(document.documentElement).getPropertyValue(
|
|
19
|
+
'--hds-app-desktop-breakpoint'
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.desktopMQ = window.matchMedia(`(min-width:${this.desktopMQVal})`);
|
|
25
|
+
this.addEventListeners();
|
|
26
|
+
registerDestructor(this, () => {
|
|
27
|
+
this.removeEventListeners();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (this.args.hasA11yRefocus) {
|
|
31
|
+
assert(
|
|
32
|
+
'@a11yRefocusSkipTo for NavigatorNarrator (a11y-refocus) in "Hds::SideNav" must have a valid value',
|
|
33
|
+
this.args.a11yRefocusSkipTo !== undefined
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
addEventListeners() {
|
|
39
|
+
document.addEventListener('keydown', this.escapePress, true);
|
|
40
|
+
this.desktopMQ.addEventListener('change', this.updateDesktopVariable, true);
|
|
41
|
+
// set initial state based on viewport
|
|
42
|
+
this.updateDesktopVariable({ matches: this.desktopMQ.matches });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
removeEventListeners() {
|
|
46
|
+
document.removeEventListener('keydown', this.escapePress, true);
|
|
47
|
+
this.desktopMQ.removeEventListener(
|
|
48
|
+
'change',
|
|
49
|
+
this.updateDesktopVariable,
|
|
50
|
+
true
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get shouldTrapFocus() {
|
|
55
|
+
return this.isResponsive && !this.isDesktop && !this.isMinimized;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get classNames() {
|
|
59
|
+
let classes = []; // `hds-side-nav` is already set by the "Hds::SideNav::Base" component
|
|
60
|
+
|
|
61
|
+
// add specific class names for the different possible states
|
|
62
|
+
if (this.isDesktop) {
|
|
63
|
+
classes.push('hds-side-nav--is-desktop');
|
|
64
|
+
} else {
|
|
65
|
+
classes.push('hds-side-nav--is-mobile');
|
|
66
|
+
}
|
|
67
|
+
if (this.isResponsive) {
|
|
68
|
+
classes.push('hds-side-nav--is-responsive');
|
|
69
|
+
}
|
|
70
|
+
if (this.isMinimized) {
|
|
71
|
+
classes.push('hds-side-nav--is-minimized');
|
|
72
|
+
} else {
|
|
73
|
+
classes.push('hds-side-nav--is-not-minimized');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return classes.join(' ');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@action
|
|
80
|
+
escapePress(event) {
|
|
81
|
+
if (event.key === 'Escape' && !this.isMinimized) {
|
|
82
|
+
this.isMinimized = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@action
|
|
87
|
+
toggleMinimizedStatus() {
|
|
88
|
+
this.isMinimized = !this.isMinimized;
|
|
89
|
+
|
|
90
|
+
let { onToggleMinimizedStatus } = this.args;
|
|
91
|
+
|
|
92
|
+
if (typeof onToggleMinimizedStatus === 'function') {
|
|
93
|
+
onToggleMinimizedStatus(this.isMinimized);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@action
|
|
98
|
+
updateDesktopVariable(event) {
|
|
99
|
+
this.isDesktop = event.matches;
|
|
100
|
+
|
|
101
|
+
let { onDesktopViewportChange } = this.args;
|
|
102
|
+
|
|
103
|
+
if (typeof onDesktopViewportChange === 'function') {
|
|
104
|
+
onDesktopViewportChange(this.isDesktop);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
}}
|
|
5
5
|
|
|
6
6
|
<nav class="hds-side-nav__list-wrapper" ...attributes>
|
|
7
|
+
{{yield (hash extraBefore=(component "hds/yield"))}}
|
|
7
8
|
<ul class="hds-side-nav__list" role="list">
|
|
8
9
|
{{yield
|
|
9
10
|
(hash
|
|
@@ -14,4 +15,5 @@
|
|
|
14
15
|
)
|
|
15
16
|
}}
|
|
16
17
|
</ul>
|
|
18
|
+
{{yield (hash extraAfter=(component "hds/yield"))}}
|
|
17
19
|
</nav>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
5
|
+
|
|
6
|
+
<Portal @target={{if @targetName @targetName "hds-side-nav-portal-target"}}>
|
|
7
|
+
<div class="hds-side-nav__content-panel" ...attributes>
|
|
8
|
+
<Hds::SideNav::List aria-label={{@ariaLabel}} as |ListElements|>
|
|
9
|
+
{{yield ListElements}}
|
|
10
|
+
</Hds::SideNav::List>
|
|
11
|
+
</div>
|
|
12
|
+
</Portal>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
5
|
+
|
|
6
|
+
<div class="hds-side-nav__content" ...attributes>
|
|
7
|
+
<PortalTarget
|
|
8
|
+
@multiple={{true}}
|
|
9
|
+
@onChange={{this.panelsChanged}}
|
|
10
|
+
@name={{if @targetName @targetName "hds-side-nav-portal-target"}}
|
|
11
|
+
class="hds-side-nav__content-panels hds-side-nav-hide-when-minimized"
|
|
12
|
+
{{did-update this.didUpdateSubnav this.numSubnavs}}
|
|
13
|
+
/>
|
|
14
|
+
</div>
|