@hashicorp/design-system-components 0.6.0 → 0.8.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 +18 -0
- package/{COMPONENT-CHECKLIST.md → NEW-COMPONENT-CHECKLIST.md} +0 -0
- package/README.md +2 -0
- package/addon/components/hds/button/index.js +0 -1
- package/addon/components/hds/disclosure/index.hbs +1 -1
- package/addon/components/hds/disclosure/index.js +3 -1
- package/addon/components/hds/link/cta.hbs +50 -0
- package/addon/components/hds/link/cta.js +150 -0
- package/addon/components/hds/link-to/cta.hbs +51 -0
- package/addon/components/hds/link-to/cta.js +165 -0
- package/app/components/hds/link/cta.js +1 -0
- package/app/components/hds/link-to/cta.js +1 -0
- package/app/styles/@hashicorp/design-system-components.scss +1 -0
- package/app/styles/components/badge-count.scss +0 -1
- package/app/styles/components/badge.scss +0 -1
- package/app/styles/components/button.scss +0 -2
- package/app/styles/components/icon-tile.scss +0 -1
- package/app/styles/components/link/cta.scss +28 -0
- package/app/styles/mixins/_focus-ring.scss +0 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @hashicorp/design-system-components
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#115](https://github.com/hashicorp/design-system/pull/115) [`caff569b`](https://github.com/hashicorp/design-system/commit/caff569b46a9a46940eab94d263816dd7d046c56) Thanks [@didoo](https://github.com/didoo)! - added “Link::CTA“ and “LinkTo::CTA” components
|
|
8
|
+
|
|
9
|
+
## 0.7.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#184](https://github.com/hashicorp/design-system/pull/184) [`12056051`](https://github.com/hashicorp/design-system/commit/12056051f2c3ffebc09a85fcd802732e5d5dce7d) Thanks [@didoo](https://github.com/didoo)! - Fixed issue with "click outside" in Safari for "Disclosure/Breadcrumb/Dropdown"
|
|
14
|
+
|
|
15
|
+
## 0.7.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#150](https://github.com/hashicorp/design-system/pull/150) [`c236c159`](https://github.com/hashicorp/design-system/commit/c236c159f7d7ec6edc661710963f5733eb961edf) Thanks [@didoo](https://github.com/didoo)! - removed “box-sizing“ declarations from the components (we assume the consumers codebase already have set it to “border-box“ by default
|
|
20
|
+
|
|
3
21
|
## 0.6.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
File without changes
|
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ Finally, add this line to the top of your app's style file (`app.scss` or simila
|
|
|
47
47
|
@import '@hashicorp/design-system-components';
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
⚠️ **Notice**: our component library assumes that a `*, *::before, *::after { box-sizing: border-box; }` reset is applied globally in the CSS of the application. If in your use case this is not true, please speak with the design system team (we can try to find a workaround).
|
|
51
|
+
|
|
50
52
|
Usage
|
|
51
53
|
------------------------------------------------------------------------------
|
|
52
54
|
|
|
@@ -160,7 +160,6 @@ export default class HdsButtonIndexComponent extends Component {
|
|
|
160
160
|
* @method Button#classNames
|
|
161
161
|
* @return {string} The "class" attribute to apply to the component.
|
|
162
162
|
*/
|
|
163
|
-
// "hds-button {{this.sizeClass}} {{this.colorClass}} {{this.widthClass}}"
|
|
164
163
|
get classNames() {
|
|
165
164
|
let classes = ['hds-button'];
|
|
166
165
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div class="hds-disclosure" ...attributes>
|
|
2
2
|
<div class="hds-disclosure__toggle">
|
|
3
|
-
{{yield (hash onClickToggle=this.onClickToggle) to="toggle"}}
|
|
3
|
+
{{yield (hash onClickToggle=this.onClickToggle isActive=this.isActive) to="toggle"}}
|
|
4
4
|
</div>
|
|
5
5
|
{{#if this.isActive}}
|
|
6
6
|
<div
|
|
@@ -20,7 +20,9 @@ export default class HdsDisclosureComponent extends Component {
|
|
|
20
20
|
clickOutsideDeactivates(event) {
|
|
21
21
|
// we check if the toggle reference belongs to the tree of parent DOM nodes
|
|
22
22
|
// of the element that was clicked and triggered the "click outside" event handling
|
|
23
|
-
|
|
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);
|
|
24
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).
|
|
25
27
|
// see: https://github.com/focus-trap/focus-trap#createoptions
|
|
26
28
|
return true;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
// ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
|
|
3
|
+
// ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
|
|
4
|
+
// ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
|
|
5
|
+
// ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
6
|
+
// ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
|
|
7
|
+
//
|
|
8
|
+
// Notice: in this component we're using directly the styles from the `Hds::Button` component
|
|
9
|
+
// using the `hds-button` class names (and adding a specialized class for the "cta", see below)
|
|
10
|
+
// If you need to change the styling of the `Button` component, remember that this will impact also
|
|
11
|
+
// this component too.
|
|
12
|
+
// If instead you need to change only the styling of the `CTA` component, you can do it
|
|
13
|
+
// in the CSS file using the specialized class declared there.
|
|
14
|
+
// This is NOT a standard approach that we use in the HDS design system implementation, but it's been
|
|
15
|
+
// the least worst option we could find to solve the problem of sharing the exact same style of the
|
|
16
|
+
// `Button (primary)` with other components.
|
|
17
|
+
}}
|
|
18
|
+
|
|
19
|
+
{{! template-lint-disable link-href-attributes }}
|
|
20
|
+
{{! we can disable this linting rule because the developer will add the html attribute themselves }}
|
|
21
|
+
<a
|
|
22
|
+
class={{this.classNames}}
|
|
23
|
+
target="_blank"
|
|
24
|
+
rel="noopener noreferrer"
|
|
25
|
+
...attributes
|
|
26
|
+
{{did-insert this.didInsert}}
|
|
27
|
+
{{on-key "Space" this.onKeySpace}}
|
|
28
|
+
>
|
|
29
|
+
{{#if this.icon}}
|
|
30
|
+
{{#if (eq this.iconPosition "leading")}}
|
|
31
|
+
<div class="hds-button__icon">
|
|
32
|
+
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
|
|
33
|
+
</div>
|
|
34
|
+
<div class="hds-button__text">
|
|
35
|
+
{{this.text}}
|
|
36
|
+
</div>
|
|
37
|
+
{{else}}
|
|
38
|
+
<div class="hds-button__text">
|
|
39
|
+
{{this.text}}
|
|
40
|
+
</div>
|
|
41
|
+
<div class="hds-button__icon">
|
|
42
|
+
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
|
|
43
|
+
</div>
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{else}}
|
|
46
|
+
<div class="hds-button__text">
|
|
47
|
+
{{this.text}}
|
|
48
|
+
</div>
|
|
49
|
+
{{/if}}
|
|
50
|
+
</a>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
|
|
2
|
+
// ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
|
|
3
|
+
// ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
|
|
4
|
+
// ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
5
|
+
// ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
|
|
6
|
+
//
|
|
7
|
+
// Notice: in this component we're using directly the styles from the `Hds::Button` component
|
|
8
|
+
// using the `hds-button` class names (and adding a specialized class for the "cta", see below)
|
|
9
|
+
// If you need to change the styling of the `Button` component, remember that this will impact also
|
|
10
|
+
// this component too.
|
|
11
|
+
// If instead you need to change only the styling of the `CTA` component, you can do it
|
|
12
|
+
// in the CSS file using the specialized class declared there.
|
|
13
|
+
// This is NOT a standard approach that we use in the HDS design system implementation, but it's been
|
|
14
|
+
// the least worst option we could find to solve the problem of sharing the exact same style of the
|
|
15
|
+
// `Button (primary)` with other components.
|
|
16
|
+
|
|
17
|
+
import Component from '@glimmer/component';
|
|
18
|
+
import { assert } from '@ember/debug';
|
|
19
|
+
import { action } from '@ember/object';
|
|
20
|
+
|
|
21
|
+
export const DEFAULT_SIZE = 'medium';
|
|
22
|
+
export const DEFAULT_ICONPOSITION = 'leading';
|
|
23
|
+
export const SIZES = ['small', 'medium', 'large'];
|
|
24
|
+
export const ICONPOSITIONS = ['leading', 'trailing'];
|
|
25
|
+
|
|
26
|
+
export default class HdsLinkCtaComponent extends Component {
|
|
27
|
+
/**
|
|
28
|
+
* @param text
|
|
29
|
+
* @type {string}
|
|
30
|
+
* @description The text of the component. If no text value is defined an error will be thrown.
|
|
31
|
+
*/
|
|
32
|
+
get text() {
|
|
33
|
+
let { text } = this.args;
|
|
34
|
+
|
|
35
|
+
assert(
|
|
36
|
+
'@text for "Hds::Link::Cta" must have a valid value',
|
|
37
|
+
text !== undefined
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return text;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param size
|
|
45
|
+
* @type {string}
|
|
46
|
+
* @default medium
|
|
47
|
+
* @description The size of the component; acceptable values are `small`, `medium`, and `large`
|
|
48
|
+
*/
|
|
49
|
+
get size() {
|
|
50
|
+
let { size = DEFAULT_SIZE } = this.args;
|
|
51
|
+
|
|
52
|
+
assert(
|
|
53
|
+
`@size for "Hds::Link::Cta" must be one of the following: ${SIZES.join(
|
|
54
|
+
', '
|
|
55
|
+
)}; received: ${size}`,
|
|
56
|
+
SIZES.includes(size)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return size;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param icon
|
|
64
|
+
* @type {string}
|
|
65
|
+
* @default null
|
|
66
|
+
* @description The name of the icon to be used.
|
|
67
|
+
*/
|
|
68
|
+
get icon() {
|
|
69
|
+
return this.args.icon ?? null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param iconPosition
|
|
74
|
+
* @type {string}
|
|
75
|
+
* @default leading
|
|
76
|
+
* @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
|
|
77
|
+
*/
|
|
78
|
+
get iconPosition() {
|
|
79
|
+
let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
|
|
80
|
+
|
|
81
|
+
assert(
|
|
82
|
+
`@iconPosition for "Hds::Link::Cta" must be one of the following: ${ICONPOSITIONS.join(
|
|
83
|
+
', '
|
|
84
|
+
)}; received: ${iconPosition}`,
|
|
85
|
+
ICONPOSITIONS.includes(iconPosition)
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return iconPosition;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param iconSize
|
|
93
|
+
* @type {string}
|
|
94
|
+
* @default 16
|
|
95
|
+
* @description ensures that the correct icon size is used. Automatically calculated.
|
|
96
|
+
*/
|
|
97
|
+
get iconSize() {
|
|
98
|
+
if (this.args.size === 'large') {
|
|
99
|
+
return '24';
|
|
100
|
+
} else {
|
|
101
|
+
return '16';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param isFullWidth
|
|
107
|
+
* @type {boolean}
|
|
108
|
+
* @default false
|
|
109
|
+
* @description Indicates that the component should take up the full width of the parent container. The default is false.
|
|
110
|
+
*/
|
|
111
|
+
get isFullWidth() {
|
|
112
|
+
return this.args.isFullWidth ?? false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@action
|
|
116
|
+
didInsert(el) {
|
|
117
|
+
// we need to register the element to compare it with the one that triggered the "key/space" event
|
|
118
|
+
this.el = el;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@action
|
|
122
|
+
onKeySpace(event) {
|
|
123
|
+
if (event.target === this.el) {
|
|
124
|
+
event.target.click();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get the class names to apply to the component.
|
|
130
|
+
* @method classNames
|
|
131
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
132
|
+
*/
|
|
133
|
+
get classNames() {
|
|
134
|
+
let classes = [
|
|
135
|
+
'hds-button',
|
|
136
|
+
'hds-button--color-primary',
|
|
137
|
+
'hds-link-cta--inherit-button-styles',
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
// add a class based on the @size argument
|
|
141
|
+
classes.push(`hds-button--size-${this.size}`);
|
|
142
|
+
|
|
143
|
+
// add a class based on the @isFullWidth argument
|
|
144
|
+
if (this.isFullWidth) {
|
|
145
|
+
classes.push('hds-button--width-full');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return classes.join(' ');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
// ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
|
|
3
|
+
// ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
|
|
4
|
+
// ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
|
|
5
|
+
// ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
6
|
+
// ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
|
|
7
|
+
//
|
|
8
|
+
// Notice: in this component we're using directly the styles from the `Hds::Button` component
|
|
9
|
+
// using the `hds-button` class names (and adding a specialized class for the "cta", see below)
|
|
10
|
+
// If you need to change the styling of the `Button` component, remember that this will impact also
|
|
11
|
+
// this component too.
|
|
12
|
+
// If instead you need to change only the styling of the `CTA` component, you can do it
|
|
13
|
+
// in the CSS file using the specialized class declared there.
|
|
14
|
+
// This is NOT a standard approach that we use in the HDS design system implementation, but it's been
|
|
15
|
+
// the least worst option we could find to solve the problem of sharing the exact same style of the
|
|
16
|
+
// `Button (primary)` with other components.
|
|
17
|
+
}}
|
|
18
|
+
|
|
19
|
+
<LinkTo
|
|
20
|
+
class={{this.classNames}}
|
|
21
|
+
@current-when={{@current-when}}
|
|
22
|
+
@models={{hds-link-to-models @model @models}}
|
|
23
|
+
@query={{hds-link-to-query @query}}
|
|
24
|
+
@replace={{@replace}}
|
|
25
|
+
@route={{this.route}}
|
|
26
|
+
...attributes
|
|
27
|
+
{{did-insert this.didInsert}}
|
|
28
|
+
{{on-key "Space" this.onKeySpace}}
|
|
29
|
+
>
|
|
30
|
+
{{#if this.icon}}
|
|
31
|
+
{{#if (eq this.iconPosition "leading")}}
|
|
32
|
+
<div class="hds-button__icon">
|
|
33
|
+
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
|
|
34
|
+
</div>
|
|
35
|
+
<div class="hds-button__text">
|
|
36
|
+
{{this.text}}
|
|
37
|
+
</div>
|
|
38
|
+
{{else}}
|
|
39
|
+
<div class="hds-button__text">
|
|
40
|
+
{{this.text}}
|
|
41
|
+
</div>
|
|
42
|
+
<div class="hds-button__icon">
|
|
43
|
+
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
|
|
44
|
+
</div>
|
|
45
|
+
{{/if}}
|
|
46
|
+
{{else}}
|
|
47
|
+
<div class="hds-button__text">
|
|
48
|
+
{{this.text}}
|
|
49
|
+
</div>
|
|
50
|
+
{{/if}}
|
|
51
|
+
</LinkTo>
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
|
|
2
|
+
// ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
|
|
3
|
+
// ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
|
|
4
|
+
// ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
5
|
+
// ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
|
|
6
|
+
//
|
|
7
|
+
// Notice: in this component we're using directly the styles from the `Hds::Button` component
|
|
8
|
+
// using the `hds-button` class names (and adding a specialized class for the "cta", see below)
|
|
9
|
+
// If you need to change the styling of the `Button` component, remember that this will impact also
|
|
10
|
+
// this component too.
|
|
11
|
+
// If instead you need to change only the styling of the `CTA` component, you can do it
|
|
12
|
+
// in the CSS file using the specialized class declared there.
|
|
13
|
+
// This is NOT a standard approach that we use in the HDS design system implementation, but it's been
|
|
14
|
+
// the least worst option we could find to solve the problem of sharing the exact same style of the
|
|
15
|
+
// `Button (primary)` with other components.
|
|
16
|
+
|
|
17
|
+
import Component from '@glimmer/component';
|
|
18
|
+
import { assert } from '@ember/debug';
|
|
19
|
+
import { action } from '@ember/object';
|
|
20
|
+
|
|
21
|
+
export const DEFAULT_SIZE = 'medium';
|
|
22
|
+
export const DEFAULT_ICONPOSITION = 'leading';
|
|
23
|
+
export const SIZES = ['small', 'medium', 'large'];
|
|
24
|
+
export const ICONPOSITIONS = ['leading', 'trailing'];
|
|
25
|
+
|
|
26
|
+
export default class HdsLinkToCtaComponent extends Component {
|
|
27
|
+
/**
|
|
28
|
+
* @param text
|
|
29
|
+
* @type {string}
|
|
30
|
+
* @description The text of the component. If no text value is defined an error will be thrown.
|
|
31
|
+
*/
|
|
32
|
+
get text() {
|
|
33
|
+
let { text } = this.args;
|
|
34
|
+
|
|
35
|
+
assert(
|
|
36
|
+
'@text for "Hds::LinkTo::Cta" must have a valid value',
|
|
37
|
+
text !== undefined
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return text;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param size
|
|
45
|
+
* @type {string}
|
|
46
|
+
* @default medium
|
|
47
|
+
* @description The size of the component; acceptable values are `small`, `medium`, and `large`
|
|
48
|
+
*/
|
|
49
|
+
get size() {
|
|
50
|
+
let { size = DEFAULT_SIZE } = this.args;
|
|
51
|
+
|
|
52
|
+
assert(
|
|
53
|
+
`@size for "Hds::LinkTo::Cta" must be one of the following: ${SIZES.join(
|
|
54
|
+
', '
|
|
55
|
+
)}; received: ${size}`,
|
|
56
|
+
SIZES.includes(size)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return size;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param icon
|
|
64
|
+
* @type {string}
|
|
65
|
+
* @default null
|
|
66
|
+
* @description The name of the icon to be used.
|
|
67
|
+
*/
|
|
68
|
+
get icon() {
|
|
69
|
+
return this.args.icon ?? null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param iconPosition
|
|
74
|
+
* @type {string}
|
|
75
|
+
* @default leading
|
|
76
|
+
* @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
|
|
77
|
+
*/
|
|
78
|
+
get iconPosition() {
|
|
79
|
+
let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
|
|
80
|
+
|
|
81
|
+
assert(
|
|
82
|
+
`@iconPosition for "Hds::LinkTo::Cta" must be one of the following: ${ICONPOSITIONS.join(
|
|
83
|
+
', '
|
|
84
|
+
)}; received: ${iconPosition}`,
|
|
85
|
+
ICONPOSITIONS.includes(iconPosition)
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return iconPosition;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param iconSize
|
|
93
|
+
* @type {string}
|
|
94
|
+
* @default 16
|
|
95
|
+
* @description ensures that the correct icon size is used. Automatically calculated.
|
|
96
|
+
*/
|
|
97
|
+
get iconSize() {
|
|
98
|
+
if (this.args.size === 'large') {
|
|
99
|
+
return '24';
|
|
100
|
+
} else {
|
|
101
|
+
return '16';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param isFullWidth
|
|
107
|
+
* @type {boolean}
|
|
108
|
+
* @default false
|
|
109
|
+
* @description Indicates that the component should take up the full width of the parent container. The default is false.
|
|
110
|
+
*/
|
|
111
|
+
get isFullWidth() {
|
|
112
|
+
return this.args.isFullWidth ?? false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @param route
|
|
117
|
+
* @type {string|null}
|
|
118
|
+
* @description Checks to make sure route is defined.
|
|
119
|
+
*/
|
|
120
|
+
get route() {
|
|
121
|
+
let { route } = this.args;
|
|
122
|
+
assert(
|
|
123
|
+
'@route must be defined for "Hds::LinkTo::Cta"',
|
|
124
|
+
route !== undefined
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
return route;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@action
|
|
131
|
+
didInsert(el) {
|
|
132
|
+
// we need to register the element to compare it with the one that triggered the "key/space" event
|
|
133
|
+
this.el = el;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@action
|
|
137
|
+
onKeySpace(event) {
|
|
138
|
+
if (event.target === this.el) {
|
|
139
|
+
event.target.click();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get the class names to apply to the component.
|
|
145
|
+
* @method classNames
|
|
146
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
147
|
+
*/
|
|
148
|
+
get classNames() {
|
|
149
|
+
let classes = [
|
|
150
|
+
'hds-button',
|
|
151
|
+
'hds-button--color-primary',
|
|
152
|
+
'hds-link-cta--inherit-button-styles',
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
// add a class based on the @size argument
|
|
156
|
+
classes.push(`hds-button--size-${this.size}`);
|
|
157
|
+
|
|
158
|
+
// add a class based on the @isFullWidth argument
|
|
159
|
+
if (this.isFullWidth) {
|
|
160
|
+
classes.push('hds-button--width-full');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return classes.join(' ');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/link/cta';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/link-to/cta';
|
|
@@ -15,7 +15,6 @@ $hds-badge-count-border-width: 1px;
|
|
|
15
15
|
.hds-badge-count {
|
|
16
16
|
align-items: center;
|
|
17
17
|
border: $hds-badge-count-border-width solid transparent;
|
|
18
|
-
box-sizing: border-box;
|
|
19
18
|
display: inline-flex;
|
|
20
19
|
font-family: var(--token-typography-font-stack-text);
|
|
21
20
|
max-width: 100%;
|
|
@@ -18,7 +18,6 @@ $hds-button-focus-border-width: 3px;
|
|
|
18
18
|
align-items: center;
|
|
19
19
|
border: $hds-button-border-width solid transparent; // We need this to be transparent for a11y
|
|
20
20
|
border-radius: $hds-button-border-radius;
|
|
21
|
-
box-sizing: border-box; // TODO https://github.com/hashicorp/design-system-components/issues/46
|
|
22
21
|
display: flex;
|
|
23
22
|
font-family: var(--token-typography-font-stack-text);
|
|
24
23
|
isolation: isolate;
|
|
@@ -69,7 +68,6 @@ $hds-button-focus-border-width: 3px;
|
|
|
69
68
|
border-radius: $hds-button-border-radius + $hds-button-focus-border-width;
|
|
70
69
|
border: $hds-button-focus-border-width solid transparent;
|
|
71
70
|
bottom: -$shift;
|
|
72
|
-
box-sizing: border-box;
|
|
73
71
|
content: '';
|
|
74
72
|
left: -$shift;
|
|
75
73
|
position: absolute;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
|
|
2
|
+
// ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
|
|
3
|
+
// ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
|
|
4
|
+
// ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
5
|
+
// ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
|
|
6
|
+
//
|
|
7
|
+
// Notice: in this component we're using directly the styles from the `Hds::Button` component
|
|
8
|
+
// using the `hds-button` class names (and adding a specialized class for the "cta", see below)
|
|
9
|
+
// If you need to change the styling of the `Button` component, remember that this will impact also
|
|
10
|
+
// this component too.
|
|
11
|
+
// If instead you need to change only the styling of the `CTA` component, you can do it here using
|
|
12
|
+
// the specialized class declared below.
|
|
13
|
+
// This is NOT a standard approach that we use in the HDS design system implementation, but it's been
|
|
14
|
+
// the least worst option we could find to solve the problem of sharing the exact same style of the
|
|
15
|
+
// `Button (primary)` with other components.
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// LINK > CTA COMPONENT
|
|
19
|
+
//
|
|
20
|
+
// properties within each class are sorted alphabetically
|
|
21
|
+
//
|
|
22
|
+
//
|
|
23
|
+
|
|
24
|
+
.hds-link-cta--inherit-button-styles {
|
|
25
|
+
isolation: isolate;
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
width: fit-content;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashicorp/design-system-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "HashiCorp Design System Components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hashicorp",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"ember-cli-htmlbars": "^5.7.1",
|
|
42
42
|
"ember-cli-sass": "^10.0.1",
|
|
43
43
|
"ember-focus-trap": "^1.0.1",
|
|
44
|
+
"ember-keyboard": "^8.0.0",
|
|
44
45
|
"ember-named-blocks-polyfill": "^0.2.5",
|
|
45
46
|
"sass": "^1.43.4"
|
|
46
47
|
},
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"@embroider/test-setup": "^0.43.5",
|
|
51
52
|
"@glimmer/component": "^1.0.4",
|
|
52
53
|
"@glimmer/tracking": "^1.0.4",
|
|
53
|
-
"@percy/cli": "^1.0.
|
|
54
|
+
"@percy/cli": "^1.0.1",
|
|
54
55
|
"@percy/ember": "^3.0.0",
|
|
55
56
|
"babel-eslint": "^10.1.0",
|
|
56
57
|
"broccoli-asset-rev": "^3.0.0",
|