@hashicorp/design-system-components 2.2.0 → 2.3.1

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/addon/components/hds/form/checkbox/field.hbs +0 -1
  3. package/addon/components/hds/form/field/index.hbs +3 -1
  4. package/addon/components/hds/form/radio/field.hbs +0 -1
  5. package/addon/components/hds/form/select/field.hbs +0 -1
  6. package/addon/components/hds/form/text-input/field.hbs +0 -1
  7. package/addon/components/hds/form/textarea/field.hbs +0 -1
  8. package/addon/components/hds/form/toggle/base.hbs +1 -1
  9. package/addon/components/hds/form/toggle/field.hbs +0 -2
  10. package/addon/components/hds/segmented-group/index.hbs +15 -0
  11. package/addon/components/hds/side-nav/portal/index.hbs +1 -1
  12. package/addon/components/hds/side-nav/portal/target.hbs +1 -1
  13. package/addon/components/hds/side-nav/portal/target.js +1 -4
  14. package/addon/components/hds/tooltip-button/index.hbs +11 -0
  15. package/addon/components/hds/tooltip-button/index.js +86 -0
  16. package/addon/modifiers/hds-tooltip.js +164 -0
  17. package/app/components/hds/segmented-group/index.js +6 -0
  18. package/app/components/hds/tooltip-button/index.js +6 -0
  19. package/app/modifiers/hds-tooltip.js +6 -0
  20. package/app/styles/@hashicorp/design-system-components.scss +2 -0
  21. package/app/styles/components/form/field.scss +4 -1
  22. package/app/styles/components/segmented-group.scss +59 -0
  23. package/app/styles/components/side-nav/content.scss +3 -0
  24. package/app/styles/components/side-nav/header.scss +2 -1
  25. package/app/styles/components/side-nav/main.scss +4 -0
  26. package/app/styles/components/tooltip.scss +84 -0
  27. package/package.json +4 -3
  28. package/addon/components/hds/form/toggle/base.js +0 -27
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @hashicorp/design-system-components
2
2
 
3
+ ## 2.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1338](https://github.com/hashicorp/design-system/pull/1338) [`2bc23fd20`](https://github.com/hashicorp/design-system/commit/2bc23fd20bafdedda65126f606c345ea5eb6fa1e) Thanks [@didoo](https://github.com/didoo)! - `SideNav` - Fix issue with links being clickable even if not visible
8
+
9
+ - [#1339](https://github.com/hashicorp/design-system/pull/1339) [`ea8edb9bf`](https://github.com/hashicorp/design-system/commit/ea8edb9bf0567b5dc97ded9efbfeb5c6f27f52d5) Thanks [@didoo](https://github.com/didoo)! - `SideNav` - Updated CSS declaration that was causing an horizontal scrollbar to appear in some conditions
10
+
11
+ ## 2.3.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#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
16
+
17
+ - Add design tokens for `Tooltip`
18
+
19
+ - [#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
20
+
21
+ ### Patch Changes
22
+
23
+ - [#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`
24
+
25
+ - [#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
26
+
27
+ - [#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`
28
+
29
+ - Updated dependencies [[`d0ae66503`](https://github.com/hashicorp/design-system/commit/d0ae665033e6b83a65c2dcde8630985f76872901)]:
30
+ - @hashicorp/design-system-tokens@1.5.0
31
+
3
32
  ## 2.2.0
4
33
 
5
34
  ### Minor Changes
@@ -13,7 +13,6 @@
13
13
  {{yield (hash Label=F.Label HelperText=F.HelperText Error=F.Error)}}
14
14
  <F.Control>
15
15
  <Hds::Form::Checkbox::Base
16
- class="hds-form-field__control"
17
16
  @value={{@value}}
18
17
  name={{@name}}
19
18
  required={{@isRequired}}
@@ -24,7 +24,9 @@
24
24
  )
25
25
  )
26
26
  }}
27
- {{yield (hash Control=(component "hds/yield") id=this.id ariaDescribedBy=this.ariaDescribedBy)}}
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
@@ -13,7 +13,6 @@
13
13
  {{yield (hash Label=F.Label HelperText=F.HelperText Error=F.Error)}}
14
14
  <F.Control>
15
15
  <Hds::Form::Radio::Base
16
- class="hds-form-field__control"
17
16
  @value={{@value}}
18
17
  name={{@name}}
19
18
  required={{@isRequired}}
@@ -15,7 +15,6 @@
15
15
  {{yield (hash HelperText=F.HelperText Error=F.Error)}}
16
16
  <F.Control>
17
17
  <Hds::Form::Select::Base
18
- class="hds-form-field__control"
19
18
  @value={{@value}}
20
19
  @isInvalid={{@isInvalid}}
21
20
  @width={{@width}}
@@ -15,7 +15,6 @@
15
15
  {{yield (hash HelperText=F.HelperText Error=F.Error)}}
16
16
  <F.Control>
17
17
  <Hds::Form::TextInput::Base
18
- class="hds-form-field__control"
19
18
  @type={{@type}}
20
19
  @value={{@value}}
21
20
  @isInvalid={{@isInvalid}}
@@ -15,7 +15,6 @@
15
15
  {{yield (hash HelperText=F.HelperText Error=F.Error)}}
16
16
  <F.Control>
17
17
  <Hds::Form::Textarea::Base
18
- class="hds-form-field__control"
19
18
  @value={{@value}}
20
19
  @isInvalid={{@isInvalid}}
21
20
  @width={{@width}}
@@ -2,7 +2,7 @@
2
2
  Copyright (c) HashiCorp, Inc.
3
3
  SPDX-License-Identifier: MPL-2.0
4
4
  }}
5
- <div class={{this.classNames}}>
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>
@@ -4,7 +4,7 @@
4
4
  }}
5
5
 
6
6
  <Portal @target={{if @targetName @targetName "hds-side-nav-portal-target"}}>
7
- <div class="hds-side-nav__content-panel" ...attributes>
7
+ <div class="hds-side-nav__content-panel hds-side-nav-hide-when-minimized" ...attributes>
8
8
  <Hds::SideNav::List aria-label={{@ariaLabel}} as |ListElements|>
9
9
  {{yield ListElements}}
10
10
  </Hds::SideNav::List>
@@ -8,7 +8,7 @@
8
8
  @multiple={{true}}
9
9
  @onChange={{this.panelsChanged}}
10
10
  @name={{if @targetName @targetName "hds-side-nav-portal-target"}}
11
- class="hds-side-nav__content-panels hds-side-nav-hide-when-minimized"
11
+ class="hds-side-nav__content-panels"
12
12
  {{did-update this.didUpdateSubnav this.numSubnavs}}
13
13
  />
14
14
  </div>
@@ -112,10 +112,7 @@ export default class SidenavPortalTarget extends Component {
112
112
  fill: 'forwards',
113
113
  }
114
114
  );
115
- // Notice: we don't add the styles by default because it writes a `style` attribute to the element and it causes an additional re-render
116
- if (DEBUG) {
117
- anim.commitStyles();
118
- }
115
+
119
116
  anim.finished.then(() => {
120
117
  // uncomment this if we need/want to scroll the element to the top
121
118
  // targetElement.scrollIntoView(true);
@@ -0,0 +1,11 @@
1
+ {{!
2
+ Copyright (c) HashiCorp, Inc.
3
+ SPDX-License-Identifier: MPL-2.0
4
+ }}
5
+
6
+ <button
7
+ type="button"
8
+ class={{this.classNames}}
9
+ {{hds-tooltip this.text options=this.options}}
10
+ ...attributes
11
+ >{{~yield~}}</button>
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import Component from '@glimmer/component';
7
+ import { assert } from '@ember/debug';
8
+
9
+ export const PLACEMENTS = [
10
+ 'top',
11
+ 'top-start',
12
+ 'top-end',
13
+ 'right',
14
+ 'right-start',
15
+ 'right-end',
16
+ 'bottom',
17
+ 'bottom-start',
18
+ 'bottom-end',
19
+ 'left',
20
+ 'left-start',
21
+ 'left-end',
22
+ ];
23
+
24
+ export default class HdsTooltipIndexComponent extends Component {
25
+ /**
26
+ * @param text
27
+ * @type {string}
28
+ * @description text content for tooltip
29
+ */
30
+ get text() {
31
+ let { text } = this.args;
32
+
33
+ assert(
34
+ '@text for "Hds::TooltipButton" must have a valid value',
35
+ text !== undefined
36
+ );
37
+
38
+ return text;
39
+ }
40
+
41
+ get options() {
42
+ let { placement } = this.args;
43
+
44
+ assert(
45
+ '@placement for "Hds::TooltipButton" must have a valid value',
46
+ placement == undefined || PLACEMENTS.includes(placement)
47
+ );
48
+
49
+ return {
50
+ ...this.args.extraTippyOptions,
51
+ // takes string
52
+ placement: placement,
53
+ // takes array of 2 numbers (skidding, distance): array(0, 0)
54
+ offset: this.args.offset,
55
+ };
56
+ }
57
+
58
+ /**
59
+ * @param isInline
60
+ * @type {boolean}
61
+ * @default true
62
+ * @description sets display for the button
63
+ */
64
+ get isInline() {
65
+ let { isInline = true } = this.args;
66
+ return isInline;
67
+ }
68
+
69
+ /**
70
+ * Get the class names to apply to the component.
71
+ * @method classNames
72
+ * @return {string} The "class" attribute to apply to the component.
73
+ */
74
+ get classNames() {
75
+ let classes = ['hds-tooltip-button'];
76
+
77
+ // add a class based on the @isInline argument
78
+ if (this.isInline) {
79
+ classes.push('hds-tooltip-button--is-inline');
80
+ } else {
81
+ classes.push('hds-tooltip-button--is-block');
82
+ }
83
+
84
+ return classes.join(' ');
85
+ }
86
+ }
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ // Note: the majority of this code is a porting of the existing tooltip implementation in Cloud UI
7
+ // (which was initially implemented in Structure)
8
+
9
+ import Modifier from 'ember-modifier';
10
+ import { assert } from '@ember/debug';
11
+ import { registerDestructor } from '@ember/destroyable';
12
+
13
+ import tippy, { followCursor } from 'tippy.js';
14
+ // used by custom SVG arrow:
15
+ import 'tippy.js/dist/svg-arrow.css';
16
+
17
+ function cleanup(instance) {
18
+ const { interval, needsTabIndex, tooltip } = instance;
19
+ if (needsTabIndex) {
20
+ tooltip?.reference?.removeAttribute('tabindex');
21
+ }
22
+ clearInterval(interval);
23
+ tooltip?.destroy();
24
+ }
25
+
26
+ /**
27
+ *
28
+ * `Tooltip` implements a modifier that uses Tippy.js to display a tooltip.
29
+ *
30
+ * Sample usage:
31
+ * ```
32
+ * <div {{hds-tooltip 'Text' options=(hash )}}>Hover me!</div>
33
+ * ```
34
+ *
35
+ * @see https://atomiks.github.io/tippyjs
36
+ * @class TooltipModifier
37
+ *
38
+ */
39
+ export default class HdsTooltipModifier extends Modifier {
40
+ didSetup = false;
41
+
42
+ interval = null;
43
+ needsTabIndex = false;
44
+ tooltip = null;
45
+
46
+ constructor(owner, args) {
47
+ super(owner, args);
48
+ registerDestructor(this, cleanup);
49
+ }
50
+
51
+ hideOnEsc = {
52
+ name: 'hideOnEsc',
53
+ defaultValue: true,
54
+ fn({ hide }) {
55
+ function onKeyDown(event) {
56
+ if (event.keyCode === 27) {
57
+ hide();
58
+ }
59
+ }
60
+
61
+ return {
62
+ onShow() {
63
+ document.addEventListener('keydown', onKeyDown);
64
+ },
65
+ onHide() {
66
+ document.removeEventListener('keydown', onKeyDown);
67
+ },
68
+ };
69
+ },
70
+ };
71
+
72
+ modify(element, positional, named) {
73
+ assert('Tooltip must have an element', element);
74
+
75
+ if (!this.didSetup) {
76
+ this.#setup(element, positional, named);
77
+ this.didSetup = true;
78
+ }
79
+
80
+ this.#update(element, positional, named);
81
+ }
82
+
83
+ #setup(element, positional, named) {
84
+ const tooltipProps = this.#getTooltipProps(element, positional, named);
85
+ this.tooltip = tippy(element, tooltipProps);
86
+ }
87
+
88
+ #update(element, positional, named) {
89
+ const tooltipProps = this.#getTooltipProps(element, positional, named);
90
+ this.tooltip.setProps(tooltipProps);
91
+ }
92
+
93
+ #getTooltipProps(element, positional, named) {
94
+ const { options = {} } = named;
95
+ let [content] = positional;
96
+
97
+ let $anchor = element;
98
+
99
+ // Make it easy to specify the modified element as the actual tooltip.
100
+ if (typeof options.triggerTarget === 'string') {
101
+ const $el = $anchor;
102
+ switch (options.triggerTarget) {
103
+ case 'parentNode':
104
+ $anchor = $anchor.parentNode;
105
+ break;
106
+ default:
107
+ $anchor = $anchor.querySelectorAll(options.triggerTarget);
108
+ }
109
+ content = $anchor.cloneNode(true);
110
+ $el.remove();
111
+ options.triggerTarget = undefined;
112
+ }
113
+
114
+ // The {{hds-tooltip}} will just use the HTML content.
115
+ if (typeof content === 'undefined') {
116
+ content = $anchor.innerHTML;
117
+ $anchor.innerHTML = '';
118
+ }
119
+
120
+ if (options.trigger === 'manual') {
121
+ // If we are manually triggering, a out delay means only show for the
122
+ // amount of time specified by the delay.
123
+ const delay = options.delay || [];
124
+
125
+ if (typeof delay[1] !== 'undefined') {
126
+ options.onShown = (tooltip) => {
127
+ clearInterval(this.interval);
128
+ this.interval = setTimeout(() => {
129
+ tooltip.hide();
130
+ }, delay[1]);
131
+ };
132
+ }
133
+ }
134
+
135
+ const $trigger = $anchor;
136
+
137
+ if (!$trigger.hasAttribute('tabindex')) {
138
+ this.needsTabIndex = true;
139
+ $trigger.setAttribute('tabindex', '0');
140
+ }
141
+
142
+ return {
143
+ theme: 'hds',
144
+ triggerTarget: $trigger,
145
+ arrow: `
146
+ <svg class="hds-tooltip-pointer" width="16" height="7" viewBox="0 0 16 7" xmlns="http://www.w3.org/2000/svg">
147
+ <path d="M0 7H16L9.11989 0.444571C8.49776 -0.148191 7.50224 -0.148191 6.88011 0.444572L0 7Z" />
148
+ </svg>`,
149
+ // keeps tooltip itself open on hover:
150
+ interactive: true,
151
+ // fix accessibility features that get messed up with setting interactive: true
152
+ aria: {
153
+ content: 'describedby',
154
+ expanded: null,
155
+ },
156
+ content: () => content,
157
+ plugins: [
158
+ typeof options.followCursor !== 'undefined' ? followCursor : undefined,
159
+ this.hideOnEsc,
160
+ ].filter((item) => Boolean(item)),
161
+ ...options,
162
+ };
163
+ }
164
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ export { default } from '@hashicorp/design-system-components/components/hds/segmented-group/index';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ export { default } from '@hashicorp/design-system-components/components/hds/tooltip-button/index';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ export { default } from '@hashicorp/design-system-components/modifiers/hds-tooltip';
@@ -31,12 +31,14 @@
31
31
  @use "../components/link"; // multiple components
32
32
  @use "../components/modal";
33
33
  @use "../components/pagination";
34
+ @use "../components/segmented-group";
34
35
  @use "../components/side-nav";
35
36
  @use "../components/stepper";
36
37
  @use "../components/table";
37
38
  @use "../components/tabs";
38
39
  @use "../components/tag";
39
40
  @use "../components/toast";
41
+ @use "../components/tooltip";
40
42
  // END COMPONENT CSS FILES IMPORTS
41
43
 
42
44
  // stylelint-disable-next-line selector-class-pattern
@@ -32,6 +32,9 @@
32
32
  }
33
33
 
34
34
  .hds-form-field__control {
35
+ display: flex; // to avoid extra whitespace when the content is an <input>, <select>, or <textarea> (inline elements)
36
+ justify-self: stretch; // allows <input> and <textarea> to go full-width
37
+
35
38
  &:not(:first-child) {
36
39
  margin-top: 8px;
37
40
  }
@@ -50,7 +53,6 @@
50
53
  .hds-form-field--layout-flag {
51
54
  display: grid;
52
55
  grid-auto-flow: row;
53
- // stylelint-disable-next-line declaration-colon-space-after
54
56
  grid-template-areas:
55
57
  "control label"
56
58
  "control helper-text"
@@ -70,6 +72,7 @@
70
72
  }
71
73
 
72
74
  .hds-form-field__control {
75
+ display: flex; // to avoid extra whitespace when the content is an <input>, <select>, or <textarea> (inline elements)
73
76
  grid-area: control;
74
77
 
75
78
  &:not(:only-child) {
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ //
7
+ // SEGMENTED-GROUP
8
+ //
9
+
10
+ .hds-segmented-group {
11
+ display: inline-flex;
12
+
13
+ .hds-button,
14
+ .hds-dropdown,
15
+ .hds-form-select,
16
+ .hds-form-text-input {
17
+ &:first-child {
18
+ border-top-right-radius: 0;
19
+ border-bottom-right-radius: 0;
20
+
21
+ &::before,
22
+ .hds-dropdown-toggle-button,
23
+ .hds-dropdown-toggle-button::before {
24
+ border-top-right-radius: inherit;
25
+ border-bottom-right-radius: inherit;
26
+ }
27
+ }
28
+
29
+ &:last-child {
30
+ margin-left: -1px;
31
+ border-top-left-radius: 0;
32
+ border-bottom-left-radius: 0;
33
+
34
+ &::before,
35
+ .hds-dropdown-toggle-button,
36
+ .hds-dropdown-toggle-button::before {
37
+ border-top-left-radius: inherit;
38
+ border-bottom-left-radius: inherit;
39
+ }
40
+ }
41
+
42
+ &:not(:first-child, :last-child) {
43
+ margin-left: -1px;
44
+ border-radius: 0;
45
+
46
+ &::before,
47
+ .hds-dropdown-toggle-button,
48
+ .hds-dropdown-toggle-button::before {
49
+ border-radius: inherit;
50
+ }
51
+ }
52
+
53
+ &:focus,
54
+ &.mock-focus,
55
+ .hds-dropdown-toggle-button:focus {
56
+ z-index: 1;
57
+ }
58
+ }
59
+ }
@@ -95,6 +95,9 @@
95
95
  }
96
96
  }
97
97
 
98
+ // NOTICE: this is necessary to mitigate the flickering of the link when clicked (expecially noticeable with a badge)
99
+ // For details see: https://github.com/hashicorp/design-system/pull/1328
100
+ &:hover:focus,
98
101
  // notice: this ".active" extra class is used to match the corresponding `active` class assigned automatically
99
102
  // by the `<LinkTo>` Ember component (when the link is "current), so that consumers get it for free if they want
100
103
  // otherwise they can use the `@isActive` argument to set this visual state directly
@@ -84,7 +84,8 @@
84
84
  // dropdown overrides
85
85
 
86
86
  .hds-side-nav__dropdown { // ⬅︎ add this class name to the `Hds::Dropdown` component to apply the style overrides
87
- .hds-dropdown-toggle-icon {
87
+ .hds-dropdown-toggle-icon,
88
+ .hds-dropdown-toggle-button {
88
89
  @include hds-side-nav-icon-button($add-visible-border: true);
89
90
  }
90
91
  }
@@ -167,6 +167,10 @@
167
167
  padding:
168
168
  var(--token-side-nav-wrapper-padding-vertical)
169
169
  var(--token-side-nav-wrapper-padding-horizontal);
170
+ // this is necessary, otherwise when the sidenav is minimized an horizontal scrollbar may appear
171
+ // (if there are words longer than the width of the available space for the list "item" content)
172
+ overflow-x: hidden;
173
+ // we want the content to vertically scroll if needed
170
174
  overflow-y: auto;
171
175
  }
172
176
 
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ //
7
+ // TOOLTIP & TOOLTIP-BUTTON
8
+ //
9
+
10
+ @use "../mixins/focus-ring" as *;
11
+
12
+ .hds-tooltip-button {
13
+ @include hds-focus-ring-with-pseudo-element(
14
+ $top: var(--token-tooltip-focus-offset),
15
+ $right: var(--token-tooltip-focus-offset),
16
+ $bottom: var(--token-tooltip-focus-offset),
17
+ $left: var(--token-tooltip-focus-offset),
18
+ );
19
+ }
20
+
21
+ // The special declarations below are used to allow the button to inherit styles from the parent element
22
+ // without preventing the consumers from applying these styles via HDS or custom classes if they want
23
+ //
24
+ // Since the `:where()` selector has a specificity of `0` (see https://developer.mozilla.org/en-US/docs/Web/CSS/:where)
25
+ // the styles declared below are applied to the `<button>` element, but are overwritten by any other style applied via classname
26
+ //
27
+ // If you want to see the effect of this selector, try to comment it and look at the "Inheritance" demo in the showcase:
28
+ // https://hds-showcase.vercel.app/components/tooltip
29
+
30
+ :where(.hds-tooltip-button) {
31
+ margin: 0;
32
+ padding: 0;
33
+ color: inherit;
34
+ font: inherit;
35
+ background-color: inherit;
36
+ border: none;
37
+ }
38
+
39
+ :where(.hds-tooltip-button--is-inline) {
40
+ display: inline-flex;
41
+ }
42
+
43
+ :where(.hds-tooltip-button--is-block) {
44
+ display: flex;
45
+ }
46
+
47
+
48
+ // Tippy.js styling
49
+ // https://atomiks.github.io/tippyjs/
50
+
51
+ .tippy-box[data-theme~="hds"] {
52
+ padding: var(--token-tooltip-padding-vertical) var(--token-tooltip-padding-horizontal);
53
+ color: var(--token-tooltip-color-foreground-primary);
54
+ font-weight: var(--token-typography-font-weight-regular);
55
+ font-size: var(--token-typography-body-200-font-size);
56
+ font-family: var(--token-typography-body-200-font-family);
57
+ line-height: var(--token-typography-body-200-line-height);
58
+ overflow-wrap: break-word;
59
+ background-color: var(--token-tooltip-color-surface-primary);
60
+ border-radius: var(--token-tooltip-border-radius);
61
+ box-shadow: var(--token-elevation-higher-box-shadow);
62
+ transition-property: transform, visibility, opacity;
63
+
64
+ &[data-animation="fade"][data-state="hidden"] {
65
+ opacity: 0;
66
+ }
67
+
68
+ &[data-inertia][data-state="visible"] {
69
+ transition-timing-function: var(--token-tooltip-transition-function);
70
+ }
71
+
72
+ .tippy-content {
73
+ position: relative;
74
+ z-index: 1;
75
+ // This needs to go here because Tippy generates a javascript
76
+ // max-width on .tippy-box.
77
+ max-width: var(--token-tooltip-max-width);
78
+ }
79
+
80
+ // works with Tippy's custom SVG arrow variation:
81
+ .tippy-svg-arrow {
82
+ fill: var(--token-tooltip-color-surface-primary);
83
+ }
84
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashicorp/design-system-components",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "Helios Design System Components",
5
5
  "keywords": [
6
6
  "hashicorp",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@ember/render-modifiers": "^2.0.5",
41
- "@hashicorp/design-system-tokens": "^1.4.2",
41
+ "@hashicorp/design-system-tokens": "^1.5.0",
42
42
  "@hashicorp/ember-flight-icons": "^3.0.2",
43
43
  "dialog-polyfill": "^0.5.6",
44
44
  "ember-a11y-refocus": "^3.0.2",
@@ -54,7 +54,8 @@
54
54
  "ember-stargate": "^0.4.3",
55
55
  "ember-style-modifier": "^0.8.0",
56
56
  "ember-truth-helpers": "^3.0.0",
57
- "sass": "^1.58.3"
57
+ "sass": "^1.58.3",
58
+ "tippy.js": "^6.3.7"
58
59
  },
59
60
  "devDependencies": {
60
61
  "@ember/optional-features": "^2.0.0",
@@ -1,27 +0,0 @@
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 HdsFormToggleBaseComponent extends Component {
9
- /**
10
- * Get the class names to apply to the component.
11
- * @method classNames
12
- * @return {string} The "class" attribute to apply to the component.
13
- */
14
- get classNames() {
15
- let classes = ['hds-form-toggle'];
16
-
17
- // add a class based on the @_wrapperClass argument
18
- // we need to use this special argument to pass a class to the wrapping element, because the ...attributes is applied to the control
19
- // notice: this will *not* be documented for public use
20
- // the reason for this is that the spread (...) of attributes is applied to the <input> element, but the component has a wrapping container and we need to pass a class to it
21
- if (this.args._wrapperClass) {
22
- classes.push(this.args._wrapperClass);
23
- }
24
-
25
- return classes.join(' ');
26
- }
27
- }