@hashicorp/design-system-components 0.11.0 → 0.12.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/addon/components/hds/alert/description.hbs +1 -0
  3. package/addon/components/hds/alert/index.hbs +3 -9
  4. package/addon/components/hds/alert/title.hbs +1 -0
  5. package/addon/components/hds/breadcrumb/truncation.hbs +1 -0
  6. package/addon/components/hds/button/index.hbs +14 -2
  7. package/addon/components/hds/button/index.js +0 -21
  8. package/addon/components/hds/disclosure/index.hbs +12 -12
  9. package/addon/components/hds/disclosure/index.js +31 -24
  10. package/addon/components/hds/dropdown/index.hbs +2 -2
  11. package/addon/components/hds/dropdown/list-item/copy-item.hbs +1 -5
  12. package/addon/components/hds/dropdown/list-item/interactive.hbs +19 -41
  13. package/addon/components/hds/dropdown/toggle/button.hbs +1 -0
  14. package/addon/components/hds/dropdown/toggle/icon.hbs +8 -1
  15. package/addon/components/hds/interactive/index.hbs +33 -0
  16. package/addon/components/hds/interactive/index.js +33 -0
  17. package/addon/components/hds/link/inline.hbs +23 -0
  18. package/addon/components/hds/link/inline.js +71 -0
  19. package/addon/components/hds/link/standalone.hbs +15 -5
  20. package/addon/components/hds/link/standalone.js +7 -0
  21. package/addon/components/hds/toast/index.hbs +1 -3
  22. package/app/components/hds/{link-to/standalone.js → alert/description.js} +1 -1
  23. package/app/components/hds/{link-to/cta.js → alert/title.js} +1 -1
  24. package/app/components/hds/interactive/index.js +1 -0
  25. package/app/components/hds/link/{cta.js → inline.js} +1 -1
  26. package/app/styles/@hashicorp/design-system-components.scss +4 -1
  27. package/app/styles/components/alert.scss +17 -4
  28. package/app/styles/components/button.scss +44 -19
  29. package/app/styles/components/dropdown.scss +10 -10
  30. package/app/styles/components/link/inline.scss +66 -0
  31. package/app/styles/components/link/standalone.scss +4 -4
  32. package/app/styles/mixins/_focus-ring.scss +8 -4
  33. package/blueprints/hds-component/files/addon/components/hds/__name__/index.hbs +4 -0
  34. package/blueprints/hds-component/files/addon/components/hds/__name__/index.js +23 -0
  35. package/blueprints/hds-component/files/app/components/hds/__name__/index.js +1 -0
  36. package/blueprints/hds-component/files/app/styles/components/__name__.scss +6 -0
  37. package/blueprints/hds-component/index.js +60 -0
  38. package/blueprints/hds-component-test/files/tests/dummy/app/routes/components/__name__.js +3 -0
  39. package/blueprints/hds-component-test/files/tests/dummy/app/styles/pages/__dummyCSSFileName__.scss +1 -0
  40. package/blueprints/hds-component-test/files/tests/dummy/app/templates/components/__name__.hbs +65 -0
  41. package/blueprints/hds-component-test/files/tests/integration/components/hds/__name__/index-test.js +17 -0
  42. package/blueprints/hds-component-test/index.js +126 -0
  43. package/package.json +4 -4
  44. package/addon/components/hds/link/cta.hbs +0 -50
  45. package/addon/components/hds/link/cta.js +0 -150
  46. package/addon/components/hds/link-to/cta.hbs +0 -51
  47. package/addon/components/hds/link-to/cta.js +0 -165
  48. package/addon/components/hds/link-to/standalone.hbs +0 -25
  49. package/addon/components/hds/link-to/standalone.js +0 -151
  50. package/app/styles/components/link/cta.scss +0 -28
package/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @hashicorp/design-system-components
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#217](https://github.com/hashicorp/design-system/pull/217) [`210edd17`](https://github.com/hashicorp/design-system/commit/210edd17431e6e3097260aed0df5a8902f93b7f7) Thanks [@didoo](https://github.com/didoo)! - # Interactive
8
+
9
+ - Introduced `<Hds::Interactive>` (a generic, "utility" component used internally by all the interactive elements like buttons and links)
10
+
11
+ # Button
12
+
13
+ - updated the button API to handle also links as `<a>`/`<LinkTo/LinkToExternal>`
14
+ - it can be used in place of the `<Hds::Link/LinkTo::CTA>` component (see below)
15
+ - when the button is a link - the text is underlined for differentiation with a normal button - ⚠️ **Visual change!** - the button responds to `space` key event
16
+ - removed the `@type` argument from the API in favour of the `type` native attribute - 🚨 **Breaking change!**
17
+
18
+ # Link/LinkTo::CTA
19
+
20
+ - removed the `<Hds::Link/LinkTo::CTA>` component, in favour of `<Hds::Button>` component (see above) - 🚨 **Breaking change!**
21
+
22
+ # Link::Inline
23
+
24
+ - added the `<Hds::Link::Inline>` component (with API very similar to the `<Hds::Link::Standalone>`)
25
+
26
+ # Dropdown
27
+
28
+ - Updated the `Dropdown::ListItem::Interactive` to use the new `<Hds::Interactive>` component
29
+
30
+ # Alert/Toast components
31
+
32
+ - Removed the `<LinkTo::Standalone>` action (now you can use directly `<Link::Standalone>`)
33
+
34
+ ## 0.11.2
35
+
36
+ ### Patch Changes
37
+
38
+ - [#301](https://github.com/hashicorp/design-system/pull/301) [`4976379e`](https://github.com/hashicorp/design-system/commit/4976379e1b080c7753ceee2affe8cadc053296e5) Thanks [@alex-ju](https://github.com/alex-ju)! - Convey the disclosure state to assistive tech for dropdown and truncated breadcrumbs
39
+
40
+ ## 0.11.1
41
+
42
+ ### Patch Changes
43
+
44
+ - [#284](https://github.com/hashicorp/design-system/pull/284) [`ba409885`](https://github.com/hashicorp/design-system/commit/ba409885468f91d659d10971fa1f34f64f57ddbc) Thanks [@alex-ju](https://github.com/alex-ju)! - Change focus management in disclosure utility component
45
+
46
+ * [#289](https://github.com/hashicorp/design-system/pull/289) [`bf3a00e5`](https://github.com/hashicorp/design-system/commit/bf3a00e56989bbef92bfa355a42e5775785847a3) Thanks [@didoo](https://github.com/didoo)! - "Alert" and "Toast" components - converted "title" and "description" arguments to be contextual components
47
+
3
48
  ## 0.11.0
4
49
 
5
50
  ### Minor Changes
@@ -0,0 +1 @@
1
+ <div class="hds-alert__description" ...attributes>{{yield}}</div>
@@ -7,20 +7,14 @@
7
7
 
8
8
  <div class="hds-alert__content">
9
9
  <div class="hds-alert__text">
10
- {{#if @title}}
11
- <div class="hds-alert__title">{{@title}}</div>
12
- {{/if}}
13
- {{#if @description}}
14
- <div class="hds-alert__description">{{html-safe @description}}</div>
15
- {{/if}}
10
+ {{yield (hash Title=(component "hds/alert/title"))}}
11
+ {{yield (hash Description=(component "hds/alert/description"))}}
16
12
  </div>
17
13
 
18
14
  <div class="hds-alert__actions">
19
15
  {{yield
20
16
  (hash
21
- Button=(component "hds/button" size="small")
22
- Link::Standalone=(component "hds/link/standalone" size="small")
23
- LinkTo::Standalone=(component "hds/link-to/standalone" size="small")
17
+ Button=(component "hds/button" size="small") Link::Standalone=(component "hds/link/standalone" size="small")
24
18
  )
25
19
  }}
26
20
  </div>
@@ -0,0 +1 @@
1
+ <div class="hds-alert__title" ...attributes>{{yield}}</div>
@@ -7,6 +7,7 @@
7
7
  {{if @hover 'is-hover'}}
8
8
  {{if @active 'is-active'}}
9
9
  {{if @focus 'is-focus'}}"
10
+ aria-expanded={{if t.isOpen "true" "false"}}
10
11
  {{on "click" t.onClickToggle}}
11
12
  >
12
13
  <FlightIcon @name="more-horizontal" @size="16" @isInlineBlock={{false}} />
@@ -1,4 +1,16 @@
1
- <button class={{this.classNames}} ...attributes aria-label={{if this.isIconOnly this.text null}} type={{this.type}}>
1
+ <Hds::Interactive
2
+ class={{this.classNames}}
3
+ @current-when={{@current-when}}
4
+ @models={{hds-link-to-models @model @models}}
5
+ @query={{hds-link-to-query @query}}
6
+ @replace={{@replace}}
7
+ @route={{@route}}
8
+ @isRouteExternal={{@isRouteExternal}}
9
+ @href={{@href}}
10
+ @isHrefExternal={{@isHrefExternal}}
11
+ ...attributes
12
+ aria-label={{if this.isIconOnly this.text null}}
13
+ >
2
14
  {{#if this.isIconOnly}}
3
15
  <div class="hds-button__icon">
4
16
  <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
@@ -26,4 +38,4 @@
26
38
  </div>
27
39
  {{/if}}
28
40
  {{/if}}
29
- </button>
41
+ </Hds::Interactive>
@@ -3,11 +3,9 @@ import { assert } from '@ember/debug';
3
3
 
4
4
  export const DEFAULT_SIZE = 'medium';
5
5
  export const DEFAULT_COLOR = 'primary';
6
- export const DEFAULT_TYPE = 'button';
7
6
  export const DEFAULT_ICONPOSITION = 'leading';
8
7
  export const SIZES = ['small', 'medium', 'large'];
9
8
  export const COLORS = ['primary', 'secondary', 'tertiary', 'critical'];
10
- export const TYPES = ['button', 'submit', 'reset'];
11
9
  export const ICONPOSITIONS = ['leading', 'trailing'];
12
10
 
13
11
  export default class HdsButtonIndexComponent extends Component {
@@ -126,25 +124,6 @@ export default class HdsButtonIndexComponent extends Component {
126
124
  }
127
125
  }
128
126
 
129
- /**
130
- * @param type
131
- * @type {string}
132
- * @default button
133
- * @description The value for the button's `type` attribute. Acceptable values are `button`, `submit`, and `reset`
134
- */
135
- get type() {
136
- let { type = DEFAULT_TYPE } = this.args;
137
-
138
- assert(
139
- `@type for "Hds::Button" must be one of the following: ${TYPES.join(
140
- ', '
141
- )}; received: ${type}`,
142
- TYPES.includes(type)
143
- );
144
-
145
- return type;
146
- }
147
-
148
127
  /**
149
128
  * @param isFullWidth
150
129
  * @type {boolean}
@@ -1,16 +1,16 @@
1
- <div class="hds-disclosure" ...attributes>
2
- <div class="hds-disclosure__toggle">
3
- {{yield (hash onClickToggle=this.onClickToggle isActive=this.isActive) to="toggle"}}
1
+ {{! template-lint-disable no-invalid-interactive }}
2
+ <div
3
+ class="hds-disclosure"
4
+ ...attributes
5
+ {{did-insert this.didInsert}}
6
+ {{on "focusout" this.onFocusOut}}
7
+ {{on "keyup" this.onKeyUp}}
8
+ >
9
+ <div class="hds-disclosure__toggle" tabindex="-1">
10
+ {{yield (hash onClickToggle=this.onClickToggle isOpen=this.isOpen) to="toggle"}}
4
11
  </div>
5
- {{#if this.isActive}}
6
- <div
7
- class="hds-disclosure__content"
8
- {{focus-trap
9
- isActive=this.isActive
10
- shouldSelfFocus=true
11
- focusTrapOptions=(hash clickOutsideDeactivates=this.clickOutsideDeactivates onDeactivate=this.onDeactivate)
12
- }}
13
- >
12
+ {{#if this.isOpen}}
13
+ <div class="hds-disclosure__content" tabindex="-1">
14
14
  {{yield to="content"}}
15
15
  </div>
16
16
  {{/if}}
@@ -3,45 +3,52 @@ import { tracked } from '@glimmer/tracking';
3
3
  import { action } from '@ember/object';
4
4
 
5
5
  export default class HdsDisclosureComponent extends Component {
6
- @tracked isActive; // notice: if in the future we need to add a "@isActive" prop to control the status from outside (eg to have the Disclosure opened on render) just add "this.args.isActive" here to initalize the variable
6
+ @tracked isOpen; // notice: if in the future we need to add a "@isOpen" prop to control the status from outside (eg to have the Disclosure opened on render) just add "this.args.isOpen" here to initalize the variable
7
7
  @tracked toggleRef;
8
8
  @tracked isToggleClicked;
9
9
 
10
+ @action
11
+ didInsert(element) {
12
+ this.element = element;
13
+ }
14
+
10
15
  @action
11
16
  onClickToggle(event) {
12
17
  // we store a reference to the DOM node that has the "onClickToggle" event associated with it
13
18
  if (!this.toggleRef) {
14
19
  this.toggleRef = event.currentTarget;
15
20
  }
16
- this.isActive = !this.isActive;
21
+ this.isOpen = !this.isOpen;
22
+ // we explicitly apply a focus state to the toggle element to overcome a bug in WebKit (see b8abfcf)
23
+ this.toggleRef.focus();
17
24
  }
18
25
 
19
26
  @action
20
- clickOutsideDeactivates(event) {
21
- // we check if the toggle reference belongs to the tree of parent DOM nodes
22
- // of the element that was clicked and triggered the "click outside" event handling
23
- // notice: we use "event.composedPath" here because is now fully supported (see https://caniuse.com/?search=event%20path)
24
- const path = event.composedPath();
25
- this.isToggleClicked = path.includes(this.toggleRef);
26
- // here we need to return `true` to make sure that the focus trap will be deactivated (and allow the click event to do its thing (i.e. to pass-through to the element that was clicked).
27
- // see: https://github.com/focus-trap/focus-trap#createoptions
28
- return true;
27
+ onFocusOut(event) {
28
+ if (
29
+ !event.relatedTarget || // click or tap a non-related target (e.g. outside the element)
30
+ !this.element.contains(event.relatedTarget) // move focus to a target outside the element
31
+ ) {
32
+ this.deactivate();
33
+ }
29
34
  }
30
35
 
31
36
  @action
32
- onDeactivate() {
33
- // on deactivate we hide the content, except for the case when the button has been clicked
34
- // the reason is that the "onClickToggle" is called in any case (there's no way to block the event)
35
- // so when the user clicks the toggle to close the panel, we let the "onClickToggle" handle the closure
36
- // otherwise we would have two changes of status, this and the toggle, and the panel would remain open
37
- if (!this.isToggleClicked) {
38
- this.isActive = false;
39
- // we need to reset this check
40
- this.isToggleClicked = false;
41
- // we call the "onClose" callback if it exists (and is a function)
42
- if (this.args.onClose && typeof this.args.onClose === 'function') {
43
- this.args.onClose();
44
- }
37
+ onKeyUp(event) {
38
+ if (event.key === 'Escape') {
39
+ this.deactivate();
40
+ this.toggleRef.focus();
41
+ }
42
+ }
43
+
44
+ @action
45
+ deactivate() {
46
+ if (this.isOpen) {
47
+ this.isOpen = false;
48
+ }
49
+ // we call the "onClose" callback if it exists (and is a function)
50
+ if (this.args.onClose && typeof this.args.onClose === 'function') {
51
+ this.args.onClose();
45
52
  }
46
53
  }
47
54
  }
@@ -2,8 +2,8 @@
2
2
  <:toggle as |t|>
3
3
  {{yield
4
4
  (hash
5
- ToggleButton=(component "hds/dropdown/toggle/button" isOpen=t.isActive onClick=t.onClickToggle)
6
- ToggleIcon=(component "hds/dropdown/toggle/icon" isOpen=t.isActive onClick=t.onClickToggle)
5
+ ToggleButton=(component "hds/dropdown/toggle/button" isOpen=t.isOpen onClick=t.onClickToggle)
6
+ ToggleIcon=(component "hds/dropdown/toggle/icon" isOpen=t.isOpen onClick=t.onClickToggle)
7
7
  )
8
8
  }}
9
9
  </:toggle>
@@ -4,11 +4,7 @@
4
4
  class="hds-dropdown-list-item__copy-item-title hds-typography-body-100 hds-font-weight-semibold"
5
5
  >{{@copyItemTitle}}</div>
6
6
  {{/if}}
7
- <button
8
- type="button"
9
- class="{{if @state (concat 'is-' @state)}} {{if this.isSuccess 'is-success'}}"
10
- {{on "click" this.copyCode}}
11
- >
7
+ <button type="button" class="{{if this.isSuccess 'is-success'}}" {{on "click" this.copyCode}}>
12
8
  <div class="hds-dropdown-list-item__copy-item-text hds-typography-code-100">
13
9
  {{this.text}}
14
10
  </div>
@@ -1,44 +1,22 @@
1
1
  <li class={{this.classNames}}>
2
- {{#if @route}}
3
- <LinkTo
4
- class="{{if @state (concat 'is-' @state)}}"
5
- @current-when={{@current-when}}
6
- @models={{hds-link-to-models @model @models}}
7
- @query={{hds-link-to-query @query}}
8
- @replace={{@replace}}
9
- @route={{@route}}
10
- ...attributes
11
- >
12
- {{#if @icon}}
13
- <div class="hds-dropdown-list-item__interactive-icon">
14
- <FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
15
- </div>
16
- {{/if}}
17
- <div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
18
- {{this.text}}
2
+ <Hds::Interactive
3
+ @current-when={{@current-when}}
4
+ @models={{hds-link-to-models @model @models}}
5
+ @query={{hds-link-to-query @query}}
6
+ @replace={{@replace}}
7
+ @route={{@route}}
8
+ @isRouteExternal={{@isRouteExternal}}
9
+ @href={{@href}}
10
+ @isHrefExternal={{@isHrefExternal}}
11
+ ...attributes
12
+ >
13
+ {{#if @icon}}
14
+ <div class="hds-dropdown-list-item__interactive-icon">
15
+ <FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
19
16
  </div>
20
- </LinkTo>
21
- {{else if @href}}
22
- <a target="_blank" rel="noopener noreferrer" href={{@href}} class="{{if @state (concat 'is-' @state)}}">
23
- {{#if @icon}}
24
- <div class="hds-dropdown-list-item__interactive-icon">
25
- <FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
26
- </div>
27
- {{/if}}
28
- <div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
29
- {{this.text}}
30
- </div>
31
- </a>
32
- {{else}}
33
- <button class="{{if @state (concat 'is-' @state)}}" type="button" ...attributes>
34
- {{#if @icon}}
35
- <div class="hds-dropdown-list-item__interactive-icon">
36
- <FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
37
- </div>
38
- {{/if}}
39
- <div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
40
- {{this.text}}
41
- </div>
42
- </button>
43
- {{/if}}
17
+ {{/if}}
18
+ <div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
19
+ {{this.text}}
20
+ </div>
21
+ </Hds::Interactive>
44
22
  </li>
@@ -19,5 +19,6 @@
19
19
  @iconPosition="trailing"
20
20
  @color={{this.color}}
21
21
  ...attributes
22
+ aria-expanded={{if @isOpen "true" "false"}}
22
23
  {{on "click" this.onClick}}
23
24
  />
@@ -1,4 +1,11 @@
1
- <button class={{this.classNames}} aria-label={{this.text}} ...attributes {{on "click" this.onClick}} type="button">
1
+ <button
2
+ class={{this.classNames}}
3
+ aria-label={{this.text}}
4
+ ...attributes
5
+ aria-expanded={{if @isOpen "true" "false"}}
6
+ {{on "click" this.onClick}}
7
+ type="button"
8
+ >
2
9
  <div class="hds-dropdown-toggle-icon__wrapper">
3
10
  {{#if @imageSrc}}
4
11
  <img src={{@imageSrc}} alt="" role="presentation" height="32" width="32" />
@@ -0,0 +1,33 @@
1
+ {{! IMPORTANT: we removed the newlines before/after the yield to reduce the issues with unexpected whitespaces (see https://github.com/hashicorp/design-system/pull/231#issuecomment-1123502499) }}
2
+ {{! NOTICE: we can't support the direct use of the "href" HTML attribute via ...attributes in the <a> elements, because we need to rely on the "@href" Ember argument to differentiate between different types of generated output }}
3
+ {{#if @route}}
4
+ {{#if this.isRouteExternal}}
5
+ <LinkToExternal
6
+ @current-when={{@current-when}}
7
+ @models={{hds-link-to-models @model @models}}
8
+ @query={{hds-link-to-query @query}}
9
+ @replace={{@replace}}
10
+ @route={{@route}}
11
+ ...attributes
12
+ >{{yield}}</LinkToExternal>
13
+ {{else}}
14
+ <LinkTo
15
+ @current-when={{@current-when}}
16
+ @models={{hds-link-to-models @model @models}}
17
+ @query={{hds-link-to-query @query}}
18
+ @replace={{@replace}}
19
+ @route={{@route}}
20
+ ...attributes
21
+ >{{yield}}</LinkTo>
22
+ {{/if}}
23
+ {{else if @href}}
24
+ {{#if this.isHrefExternal}}
25
+ <a target="_blank" rel="noopener noreferrer" ...attributes href={{@href}} {{on "keyup" this.onKeyUp}}>{{yield}}</a>
26
+ {{else}}
27
+ <a ...attributes href={{@href}} {{on "keyup" this.onKeyUp}}>{{yield}}</a>
28
+ {{/if}}
29
+ {{else}}
30
+ <button type="button" ...attributes>
31
+ {{yield}}
32
+ </button>
33
+ {{/if}}
@@ -0,0 +1,33 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+
4
+ export default class HdsInteractiveComponent extends Component {
5
+ /**
6
+ * Determines if a @href value is "external" (it adds target="_blank" rel="noopener noreferrer")
7
+ *
8
+ * @param isHrefExternal
9
+ * @type boolean
10
+ * @default true
11
+ */
12
+ get isHrefExternal() {
13
+ return this.args.isHrefExternal ?? true;
14
+ }
15
+
16
+ /**
17
+ * Determines if a @route value is "external" (uses the LinkToExternal component instead of LinkTo)
18
+ *
19
+ * @param isRouteExternal
20
+ * @type boolean
21
+ * @default false
22
+ */
23
+ get isRouteExternal() {
24
+ return this.args.isRouteExternal ?? false;
25
+ }
26
+
27
+ @action
28
+ onKeyUp(event) {
29
+ if (event.key === ' ' || event.code === 'Space') {
30
+ event.target.click();
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,23 @@
1
+ {{! IMPORTANT: we removed the newlines before/after the yield to reduce the issues with unexpected whitespaces (see https://github.com/hashicorp/design-system/pull/231#issuecomment-1123502499) }}
2
+ {{! IMPORTANT: we need to add "squishies" here (~) because otherwise the whitespace added by Ember becomes visible in the link (being an inline element) - See https://handlebarsjs.com/guide/expressions.html#whitespace-control }}
3
+ <Hds::Interactive
4
+ class={{this.classNames}}
5
+ @current-when={{@current-when}}
6
+ @models={{hds-link-to-models @model @models}}
7
+ @query={{hds-link-to-query @query}}
8
+ @replace={{@replace}}
9
+ @route={{@route}}
10
+ @isRouteExternal={{@isRouteExternal}}
11
+ @href={{@href}}
12
+ target="_blank"
13
+ rel="noopener noreferrer"
14
+ ...attributes
15
+ >{{#if (and @icon (eq this.iconPosition "leading"))~}}
16
+ <span class="hds-link-inline__icon hds-link-inline__icon--leading">
17
+ <FlightIcon @name={{@icon}} @size="16" @stretched={{true}} />
18
+ </span>
19
+ {{~/if~}}{{yield}}{{~#if (and @icon (eq this.iconPosition "trailing"))~}}
20
+ <span class="hds-link-inline__icon hds-link-inline__icon--trailing">
21
+ <FlightIcon @name={{@icon}} @size="16" @stretched={{true}} />
22
+ </span>
23
+ {{~/if}}</Hds::Interactive>
@@ -0,0 +1,71 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ export const DEFAULT_ICONPOSITION = 'trailing';
5
+ export const DEFAULT_COLOR = 'primary';
6
+ export const ICONPOSITIONS = ['leading', 'trailing'];
7
+ export const COLORS = ['primary', 'secondary'];
8
+
9
+ export default class HdsLinkInlineComponent extends Component {
10
+ constructor() {
11
+ super(...arguments);
12
+ if (!(this.args.href || this.args.route)) {
13
+ assert('@href or @route must be defined for <Hds::Link::Inline>');
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @param color
19
+ * @type {string}
20
+ * @default primary
21
+ * @description Determines the color of link to be used; acceptable values are `primary` and `secondary`
22
+ */
23
+ get color() {
24
+ let { color = DEFAULT_COLOR } = this.args;
25
+
26
+ assert(
27
+ `@color for "Hds::Link::Inline" must be one of the following: ${COLORS.join(
28
+ ', '
29
+ )}; received: ${color}`,
30
+ COLORS.includes(color)
31
+ );
32
+
33
+ return color;
34
+ }
35
+
36
+ /**
37
+ * @param iconPosition
38
+ * @type {string}
39
+ * @default leading
40
+ * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
41
+ */
42
+ get iconPosition() {
43
+ let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
44
+
45
+ assert(
46
+ `@iconPosition for "Hds::Link::Inline" must be one of the following: ${ICONPOSITIONS.join(
47
+ ', '
48
+ )}; received: ${iconPosition}`,
49
+ ICONPOSITIONS.includes(iconPosition)
50
+ );
51
+
52
+ return iconPosition;
53
+ }
54
+
55
+ /**
56
+ * Get the class names to apply to the component.
57
+ * @method LinkInline#classNames
58
+ * @return {string} The "class" attribute to apply to the component.
59
+ */
60
+ get classNames() {
61
+ let classes = ['hds-link-inline'];
62
+
63
+ // add a class based on the @color argument
64
+ classes.push(`hds-link-inline--color-${this.color}`);
65
+
66
+ // add a class based on the @iconPosition argument
67
+ classes.push(`hds-link-inline--icon-${this.iconPosition}`);
68
+
69
+ return classes.join(' ');
70
+ }
71
+ }
@@ -1,6 +1,17 @@
1
- {{! template-lint-disable link-href-attributes }}
2
- {{! we can disable this linting rule because the developer will add the html attribute themselves }}
3
- <a class={{this.classNames}} target="_blank" rel="noopener noreferrer" ...attributes>
1
+ <Hds::Interactive
2
+ class={{this.classNames}}
3
+ @current-when={{@current-when}}
4
+ @models={{hds-link-to-models @model @models}}
5
+ @query={{hds-link-to-query @query}}
6
+ @replace={{@replace}}
7
+ @route={{@route}}
8
+ @isRouteExternal={{@isRouteExternal}}
9
+ @href={{@href}}
10
+ @isHrefExternal={{@isHrefExternal}}
11
+ target="_blank"
12
+ rel="noopener noreferrer"
13
+ ...attributes
14
+ >
4
15
  {{#if (eq this.iconPosition "leading")}}
5
16
  <div class="hds-link-standalone__icon">
6
17
  <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
@@ -16,5 +27,4 @@
16
27
  <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
17
28
  </div>
18
29
  {{/if}}
19
- </a>
20
- {{! template-lint-enable link-href-attributes }}
30
+ </Hds::Interactive>
@@ -9,6 +9,13 @@ export const COLORS = ['primary', 'secondary'];
9
9
  export const SIZES = ['small', 'medium', 'large'];
10
10
 
11
11
  export default class HdsLinkStandaloneComponent extends Component {
12
+ constructor() {
13
+ super(...arguments);
14
+ if (!(this.args.href || this.args.route)) {
15
+ assert('@href or @route must be defined for <Hds::Link::Standalone>');
16
+ }
17
+ }
18
+
12
19
  /**
13
20
  * @param text
14
21
  * @type {string}
@@ -3,13 +3,11 @@
3
3
  @type="inline"
4
4
  @color={{@color}}
5
5
  @icon={{@icon}}
6
- @title={{@title}}
7
- @description={{@description}}
8
6
  @onDismiss={{@onDismiss}}
9
7
  ...attributes
10
8
  as |A|
11
9
  >
12
10
  {{yield
13
- (hash Button=A.Button Link::Standalone=A.Link::Standalone LinkTo::Standalone=A.LinkTo::Standalone Generic=A.Generic)
11
+ (hash Title=A.Title Description=A.Description Button=A.Button Link::Standalone=A.Link::Standalone Generic=A.Generic)
14
12
  }}
15
13
  </Hds::Alert>
@@ -1 +1 @@
1
- export { default } from '@hashicorp/design-system-components/components/hds/link-to/standalone';
1
+ export { default } from '@hashicorp/design-system-components/components/hds/alert/description';
@@ -1 +1 @@
1
- export { default } from '@hashicorp/design-system-components/components/hds/link-to/cta';
1
+ export { default } from '@hashicorp/design-system-components/components/hds/alert/title';
@@ -0,0 +1 @@
1
+ export { default } from '@hashicorp/design-system-components/components/hds/interactive/index';
@@ -1 +1 @@
1
- export { default } from '@hashicorp/design-system-components/components/hds/link/cta';
1
+ export { default } from '@hashicorp/design-system-components/components/hds/link/inline';
@@ -5,6 +5,8 @@
5
5
  @use "helpers/focus-ring";
6
6
  @use "helpers/typography";
7
7
 
8
+ // Notice: this list can be automatically edited by the Ember blueprint, please don't remove the start/end comments
9
+ // START COMPONENTS CSS FILES IMPORTS
8
10
  @use "../components/alert";
9
11
  @use "../components/badge";
10
12
  @use "../components/badge-count";
@@ -14,9 +16,10 @@
14
16
  @use "../components/disclosure";
15
17
  @use "../components/dropdown";
16
18
  @use "../components/icon-tile";
17
- @use "../components/link/cta";
19
+ @use "../components/link/inline";
18
20
  @use "../components/link/standalone";
19
21
  @use "../components/toast";
22
+ // END COMPONENT CSS FILES IMPORTS
20
23
 
21
24
  .sr-only {
22
25
  border: 0 !important;