Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button/Link/CTA - Updates for the interactive elements #217

Merged
merged 126 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
370777f
added generic β€œinteractive” component
didoo Apr 14, 2022
23d61b0
updated the `dropdown/list-item/interactive` to use the new `interact…
didoo Apr 14, 2022
891adea
added documentation page for `interactive` component
didoo Apr 14, 2022
647008f
small update
didoo Apr 14, 2022
f098f5c
small commit to open the main PR
didoo Apr 14, 2022
686f5ce
added integration tests for the β€œinteractive” element
didoo Apr 14, 2022
9c269f4
removed leftover import
didoo Apr 14, 2022
fababb7
small updates to the documentation page for β€œinteractive”
didoo Apr 19, 2022
295bfd5
removed empty backing class for β€œinteractive”
didoo Apr 20, 2022
4199bdb
small update to the documentation
didoo Apr 20, 2022
5464c8d
small updates to the integration tests
didoo Apr 20, 2022
db12345
added one more integration test to the β€œinteractive” component
didoo Apr 20, 2022
e2cbe81
updated the button to use the new interactive generic component
didoo Apr 20, 2022
393f330
fixed underline of text on links
didoo Apr 20, 2022
6b8441a
improved assertion guards in `button` to work differently between but…
didoo Apr 20, 2022
0c87f75
added special visual treatment to alert the developer if a `href` HTM…
didoo Apr 20, 2022
011de8d
updated documentation page for β€œbutton”
didoo Apr 20, 2022
abd2aac
updated integration tests for β€œbutton”
didoo Apr 20, 2022
9627d5d
skipped failing test in "ember-lts-3.24"
didoo Apr 20, 2022
cf58529
Merge branch 'spike-interactive-generic-component' into spike-button-…
didoo Apr 20, 2022
9e68782
skipped failing test in "ember-lts-3.24"
didoo Apr 20, 2022
81d5878
entirely removed `Link/LinkTo::CTA` from the HDS components
didoo Apr 20, 2022
25223ec
skipped another failing test in "ember-lts-3.24"
didoo Apr 20, 2022
821a86b
Merge branch 'spike-button-with-link-support' into spike-remove-link-CTA
didoo Apr 20, 2022
1cdd811
linting
didoo Apr 20, 2022
e12dd44
added handling of `@isHrefExternal` to the `Interactive` generic comp…
didoo Apr 27, 2022
3544a8d
updated documentation following introduction of `@isHrefExternal`
didoo Apr 27, 2022
cf71762
Merge branch 'spike-interactive-generic-component' into spike-button-…
didoo Apr 27, 2022
b0bc06f
updated documentation following the introduction of the `@isHrefExter…
didoo Apr 27, 2022
934a3d5
forgot default
didoo Apr 27, 2022
4bf4572
small changes
didoo May 5, 2022
4446bd9
Merge branch 'main' into spike-interactive-generic-component
didoo May 5, 2022
fda0103
updated `dropdown/list-item/interactive` after merge of `main` branch
didoo May 5, 2022
9fd6809
aligned documentation with most recent format for accessibility
didoo May 5, 2022
524dce0
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 5, 2022
d42043b
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-interactive-gene…
didoo May 5, 2022
61f54d9
updated integration tests for `interactive` component
didoo May 5, 2022
29f79fe
Merge branch 'spike-interactive-generic-component' into spike-button-…
didoo May 5, 2022
e104fbf
added missing `isHrefExternal` to Button component
didoo May 5, 2022
c812e39
Merge branch 'spike-button-with-link-support' into spike-remove-link-CTA
didoo May 5, 2022
987aee3
removed `LinkTo::Standalone` component
didoo May 5, 2022
2062833
updated the `Link:Standalone` to use the new interactive generic comp…
didoo May 5, 2022
b4dac77
unified documentation page for `Link::Standalone`
didoo May 5, 2022
8c8e2ce
updated integration tests for `Link:Standalone`
didoo May 5, 2022
7926217
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 9, 2022
d0aa0d6
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-interactive-gene…
didoo May 9, 2022
c8106a9
Merge branch 'spike-interactive-generic-component' into spike-button-…
didoo May 9, 2022
9c1289f
Merge branch 'spike-interactive-generic-component' into spike-unify-l…
didoo May 9, 2022
65aadbb
added `Link::Inline` component
didoo May 9, 2022
c2a7e1d
added documentation page for `Link::Inline`
didoo May 9, 2022
5035d6a
added tests (integration + percy) for `Link::Inline`
didoo May 9, 2022
c4a1e4a
small updates to integration tests for `Link::Standalone` for consist…
didoo May 9, 2022
f580744
added icon support to β€œlink-inline”
didoo May 9, 2022
96ea039
improved icon alignment
didoo May 9, 2022
37f2c96
updated CSS for `Link::Inline` according to new designs
didoo May 10, 2022
952e25c
Merge branch 'spike-link-inline' into spike-add-icon-to-link-inline
didoo May 10, 2022
8faea6c
added missing test for `Button` component
didoo May 10, 2022
f43fae3
Merge pull request #216 from hashicorp/spike-interactive-generic-comp…
didoo May 11, 2022
59d8e60
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-unify-link-stand…
didoo May 11, 2022
dba115f
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-button-with-link…
didoo May 11, 2022
3d8afbe
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-link-inline
didoo May 11, 2022
3a86700
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-remove-link-CTA
didoo May 11, 2022
229c5b1
Merge branch 'spike-link-inline' into spike-add-icon-to-link-inline
didoo May 11, 2022
0d54c25
Merge pull request #227 from hashicorp/spike-unify-link-standalone
didoo May 11, 2022
a4151bb
updated the `interactive` base component, to reduce issues with white…
didoo May 11, 2022
45930b6
updated the `Link::Inline` template to reduce issues with whitespaces
didoo May 11, 2022
aee3d7e
small tweaks to the styling of the `Link::Inline`
didoo May 11, 2022
18eef3c
Merge branch 'spike-link-inline' into spike-add-icon-to-link-inline +…
didoo May 11, 2022
9983a13
changed default icon position for `Link::Inline` to `trailing` (likel…
didoo May 11, 2022
7d86c6d
updated documentation for `Link::Inline`
didoo May 11, 2022
6e2da93
updated tests for `Link::Inline`
didoo May 11, 2022
d3af5ef
Merge pull request #255 from hashicorp/spike-add-icon-to-link-inline
didoo May 11, 2022
384a88b
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 11, 2022
c73fdec
removed `LinkTo::Standalone` from `Alert` and `Toast` contextual comp…
didoo May 11, 2022
568de83
updated `Alert` and `Toast` documentation pages to fix errors for `Li…
didoo May 11, 2022
0a963a4
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-button-with-link…
didoo May 11, 2022
18d5662
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-remove-link-CTA
didoo May 11, 2022
6957ff5
Merge remote-tracking branch 'origin/spike-BUTTON-LINK-CTA-main' into…
didoo May 11, 2022
4e13bcf
added a comment
didoo May 11, 2022
4d1897e
linting
didoo May 11, 2022
ff0ba40
fixed integration test
didoo May 11, 2022
84388c5
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-remove-link-CTA
didoo May 11, 2022
f65348b
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-button-with-link…
didoo May 11, 2022
a8e5a2c
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-link-inline
didoo May 11, 2022
5571f30
Merge branch 'spike-button-with-link-support' into spike-remove-link-CTA
didoo May 11, 2022
ea4602e
added missing anchors to the page
didoo May 12, 2022
64d9a5e
updated color according to design specs
didoo May 12, 2022
5e82573
removed underline on focus as per design specs
didoo May 12, 2022
1e08d27
linting
didoo May 18, 2022
cc4dcd7
Enable interactive links to be actioned using space
alex-ju May 18, 2022
07dd76e
Test the dispatch of a click event when pressing space key on an inte…
alex-ju May 18, 2022
e59543b
Merge pull request #291 from hashicorp/alex-ju/action-interactive-lin…
alex-ju May 18, 2022
532e00f
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 18, 2022
1969434
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-button-with-link…
didoo May 18, 2022
6df24f1
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-link-inline
didoo May 18, 2022
de89138
Merge branch 'spike-button-with-link-support' into spike-remove-link-CTA
didoo May 18, 2022
2535a1d
re-added the underline to the text when `Hds::Button` is a link
didoo May 18, 2022
228e891
removed the `@type` argument in favour of the native `type` attribute…
didoo May 18, 2022
2836b6f
updated documentation after removing `@type` argument
didoo May 18, 2022
e782b79
updated tests after removing `@type` argument
didoo May 18, 2022
00573b5
removed extra test
didoo May 18, 2022
6926071
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 18, 2022
54ef3b7
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-button-with-link…
didoo May 18, 2022
6f0a49c
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-link-inline
didoo May 18, 2022
ccf9988
Merge branch 'spike-button-with-link-support' into spike-remove-link-CTA
didoo May 18, 2022
1680f17
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 19, 2022
885e398
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-button-with-link…
didoo May 19, 2022
237e1cb
Merge branch 'spike-button-with-link-support' into spike-remove-link-CTA
didoo May 19, 2022
dff380e
Merge pull request #221 from hashicorp/spike-remove-link-CTA
didoo May 19, 2022
fa79875
Merge pull request #220 from hashicorp/spike-button-with-link-support
didoo May 19, 2022
f362d7e
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-link-inline
didoo May 19, 2022
b658213
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 19, 2022
650b9aa
Merge branch 'spike-BUTTON-LINK-CTA-main' into spike-link-inline
didoo May 19, 2022
210edd1
changeset
didoo May 19, 2022
61d3a0b
Merge pull request #231 from hashicorp/spike-link-inline
didoo May 19, 2022
0a47087
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 19, 2022
264c497
hiding the β€œLinkCTA” banner until we decide if we want to keep it or …
didoo May 19, 2022
5829e9b
Apply suggestions from code review
didoo May 20, 2022
c9a8df5
updated documentation following heather’s feedback
didoo May 20, 2022
48159a6
linting
didoo May 20, 2022
8cdc3b6
small update to the β€œnotice” message on top of the `Disclosure` and `…
didoo May 24, 2022
eeb4564
adds a11y info to button documentation
MelSumner May 25, 2022
59b8ac1
Merge pull request #315 from hashicorp/melsumner/button-a11y
MelSumner May 25, 2022
eb74108
Merge branch 'main' into spike-BUTTON-LINK-CTA-main
didoo May 26, 2022
32c837c
fixed missed standalone link attribute
didoo May 26, 2022
0ca2179
updated link pages to use new mock status
didoo May 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .changeset/warm-buckets-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
"@hashicorp/design-system-components": minor
---

# Interactive
- Introduced `<Hds::Interactive>` (a generic, "utility" component used internally by all the interactive elements like buttons and links)

# Button
- updated the button API to handle also links as `<a>`/`<LinkTo/LinkToExternal>`
- it can be used in place of the `<Hds::Link/LinkTo::CTA>` component (see below)
- 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
- removed the `@type` argument from the API in favour of the `type` native attribute - 🚨 **Breaking change!**

# Link/LinkTo::CTA
- removed the `<Hds::Link/LinkTo::CTA>` component, in favour of `<Hds::Button>` component (see above) - 🚨 **Breaking change!**

# Link::Inline
- added the `<Hds::Link::Inline>` component (with API very similar to the `<Hds::Link::Standalone>`)

# Dropdown
- Updated the `Dropdown::ListItem::Interactive` to use the new `<Hds::Interactive>` component

# Alert/Toast components
- Removed the `<LinkTo::Standalone>` action (now you can use directly `<Link::Standalone>`)


4 changes: 1 addition & 3 deletions packages/components/addon/components/hds/alert/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
<div class="hds-alert__actions">
{{yield
(hash
Button=(component "hds/button" size="small")
Link::Standalone=(component "hds/link/standalone" size="small")
LinkTo::Standalone=(component "hds/link-to/standalone" size="small")
Button=(component "hds/button" size="small") Link::Standalone=(component "hds/link/standalone" size="small")
)
}}
</div>
Expand Down
16 changes: 14 additions & 2 deletions packages/components/addon/components/hds/button/index.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
<button class={{this.classNames}} ...attributes aria-label={{if this.isIconOnly this.text null}} type={{this.type}}>
<Hds::Interactive
class={{this.classNames}}
@current-when={{@current-when}}
@models={{hds-link-to-models @model @models}}
@query={{hds-link-to-query @query}}
@replace={{@replace}}
@route={{@route}}
@isRouteExternal={{@isRouteExternal}}
@href={{@href}}
@isHrefExternal={{@isHrefExternal}}
...attributes
aria-label={{if this.isIconOnly this.text null}}
>
{{#if this.isIconOnly}}
<div class="hds-button__icon">
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
Expand Down Expand Up @@ -26,4 +38,4 @@
</div>
{{/if}}
{{/if}}
</button>
</Hds::Interactive>
21 changes: 0 additions & 21 deletions packages/components/addon/components/hds/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { assert } from '@ember/debug';

export const DEFAULT_SIZE = 'medium';
export const DEFAULT_COLOR = 'primary';
export const DEFAULT_TYPE = 'button';
export const DEFAULT_ICONPOSITION = 'leading';
export const SIZES = ['small', 'medium', 'large'];
export const COLORS = ['primary', 'secondary', 'tertiary', 'critical'];
export const TYPES = ['button', 'submit', 'reset'];
export const ICONPOSITIONS = ['leading', 'trailing'];

export default class HdsButtonIndexComponent extends Component {
Expand Down Expand Up @@ -126,25 +124,6 @@ export default class HdsButtonIndexComponent extends Component {
}
}

/**
* @param type
* @type {string}
* @default button
* @description The value for the button's `type` attribute. Acceptable values are `button`, `submit`, and `reset`
*/
get type() {
let { type = DEFAULT_TYPE } = this.args;

assert(
`@type for "Hds::Button" must be one of the following: ${TYPES.join(
', '
)}; received: ${type}`,
TYPES.includes(type)
);

return type;
}

/**
* @param isFullWidth
* @type {boolean}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,22 @@
<li class={{this.classNames}}>
{{#if @route}}
<LinkTo
@current-when={{@current-when}}
@models={{hds-link-to-models @model @models}}
@query={{hds-link-to-query @query}}
@replace={{@replace}}
@route={{@route}}
...attributes
>
{{#if @icon}}
<div class="hds-dropdown-list-item__interactive-icon">
<FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
</div>
{{/if}}
<div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
{{this.text}}
<Hds::Interactive
@current-when={{@current-when}}
@models={{hds-link-to-models @model @models}}
@query={{hds-link-to-query @query}}
@replace={{@replace}}
@route={{@route}}
@isRouteExternal={{@isRouteExternal}}
@href={{@href}}
@isHrefExternal={{@isHrefExternal}}
...attributes
>
{{#if @icon}}
<div class="hds-dropdown-list-item__interactive-icon">
<FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
</div>
</LinkTo>
{{else if @href}}
<a target="_blank" rel="noopener noreferrer" href={{@href}}>
{{#if @icon}}
<div class="hds-dropdown-list-item__interactive-icon">
<FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
</div>
{{/if}}
<div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
{{this.text}}
</div>
</a>
{{else}}
<button type="button" ...attributes>
{{#if @icon}}
<div class="hds-dropdown-list-item__interactive-icon">
<FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
</div>
{{/if}}
<div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
{{this.text}}
</div>
</button>
{{/if}}
{{/if}}
<div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
{{this.text}}
</div>
</Hds::Interactive>
</li>
33 changes: 33 additions & 0 deletions packages/components/addon/components/hds/interactive/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{! 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) }}
{{! 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 }}
{{#if @route}}
{{#if this.isRouteExternal}}
<LinkToExternal
@current-when={{@current-when}}
@models={{hds-link-to-models @model @models}}
@query={{hds-link-to-query @query}}
@replace={{@replace}}
@route={{@route}}
...attributes
>{{yield}}</LinkToExternal>
{{else}}
<LinkTo
@current-when={{@current-when}}
@models={{hds-link-to-models @model @models}}
@query={{hds-link-to-query @query}}
@replace={{@replace}}
@route={{@route}}
...attributes
>{{yield}}</LinkTo>
{{/if}}
{{else if @href}}
{{#if this.isHrefExternal}}
<a target="_blank" rel="noopener noreferrer" ...attributes href={{@href}} {{on "keyup" this.onKeyUp}}>{{yield}}</a>
{{else}}
<a ...attributes href={{@href}} {{on "keyup" this.onKeyUp}}>{{yield}}</a>
{{/if}}
{{else}}
<button type="button" ...attributes>
{{yield}}
</button>
{{/if}}
33 changes: 33 additions & 0 deletions packages/components/addon/components/hds/interactive/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';

export default class HdsInteractiveComponent extends Component {
/**
* Determines if a @href value is "external" (it adds target="_blank" rel="noopener noreferrer")
*
* @param isHrefExternal
* @type boolean
* @default true
*/
get isHrefExternal() {
return this.args.isHrefExternal ?? true;
}

/**
* Determines if a @route value is "external" (uses the LinkToExternal component instead of LinkTo)
*
* @param isRouteExternal
* @type boolean
* @default false
*/
get isRouteExternal() {
return this.args.isRouteExternal ?? false;
}

@action
onKeyUp(event) {
if (event.key === ' ' || event.code === 'Space') {
event.target.click();
}
}
}
51 changes: 0 additions & 51 deletions packages/components/addon/components/hds/link-to/cta.hbs

This file was deleted.

Loading