@hashicorp/design-system-components 0.0.10 → 0.0.14
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/.github/ISSUE_TEMPLATE/new-component-quest-issue-engineering-checklist.md +78 -0
- package/.husky/pre-commit +14 -0
- package/README.md +1 -1
- package/addon/components/hds/badge/index.hbs +2 -4
- package/addon/components/hds/badge/index.js +20 -27
- package/addon/components/hds/badge-count/index.hbs +1 -1
- package/addon/components/hds/badge-count/index.js +16 -23
- package/addon/components/hds/button/index.hbs +6 -6
- package/addon/components/hds/button/index.js +26 -34
- package/addon/components/hds/card/container.hbs +1 -1
- package/addon/components/hds/card/container.js +18 -32
- package/addon/components/hds/icon-tile/index.hbs +4 -47
- package/addon/components/hds/icon-tile/index.js +30 -28
- package/addon/components/hds/link/standalone.hbs +20 -0
- package/addon/components/hds/link/standalone.js +132 -0
- package/addon/components/hds/link-to/standalone.hbs +25 -0
- package/addon/components/hds/link-to/standalone.js +158 -0
- package/addon/helpers/hds-link-to-models.js +30 -0
- package/app/components/hds/link/standalone.js +1 -0
- package/app/components/hds/link-to/standalone.js +1 -0
- package/app/helpers/hds-link-to-models.js +1 -0
- package/app/styles/@hashicorp/design-system-components.scss +5 -0
- package/app/styles/components/button.scss +37 -49
- package/app/styles/components/card/container.scss +0 -62
- package/app/styles/components/icon-tile.scss +25 -25
- package/app/styles/components/link/standalone.scss +126 -0
- package/app/styles/mixins/_generic-focus-state.scss +4 -0
- package/package.json +27 -18
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { assert } from '@ember/debug';
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_ICONPOSITION = 'leading';
|
|
5
|
+
export const DEFAULT_COLOR = 'primary';
|
|
6
|
+
export const DEFAULT_SIZE = 'medium';
|
|
7
|
+
export const ICONPOSITIONS = ['leading', 'trailing'];
|
|
8
|
+
export const COLORS = ['primary', 'secondary'];
|
|
9
|
+
export const SIZES = ['small', 'medium', 'large'];
|
|
10
|
+
|
|
11
|
+
export default class HdsLinkStandaloneComponent extends Component {
|
|
12
|
+
/**
|
|
13
|
+
* @param text
|
|
14
|
+
* @type {string}
|
|
15
|
+
* @description The text of the link. If no text value is defined an error will be thrown.
|
|
16
|
+
*/
|
|
17
|
+
get text() {
|
|
18
|
+
let { text } = this.args;
|
|
19
|
+
|
|
20
|
+
assert(
|
|
21
|
+
'@text for "Hds::Link::Standalone" must have a valid value',
|
|
22
|
+
text !== undefined
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return text;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param color
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @default primary
|
|
32
|
+
* @description Determines the color of link to be used; acceptable values are `primary` and `secondary`
|
|
33
|
+
*/
|
|
34
|
+
get color() {
|
|
35
|
+
let { color = DEFAULT_COLOR } = this.args;
|
|
36
|
+
|
|
37
|
+
assert(
|
|
38
|
+
`@color for "Hds::Link::Standalone" must be one of the following: ${COLORS.join(
|
|
39
|
+
', '
|
|
40
|
+
)}; received: ${color}`,
|
|
41
|
+
COLORS.includes(color)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return color;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param icon
|
|
49
|
+
* @type {string|null}
|
|
50
|
+
* @default null
|
|
51
|
+
* @description The name of the icon to be used. An icon name must be defined.
|
|
52
|
+
*/
|
|
53
|
+
get icon() {
|
|
54
|
+
let { icon } = this.args;
|
|
55
|
+
|
|
56
|
+
assert(
|
|
57
|
+
'@icon for "Hds::Link::Standalone" must have a valid value',
|
|
58
|
+
icon !== undefined
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return icon;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param iconPosition
|
|
66
|
+
* @type {string}
|
|
67
|
+
* @default leading
|
|
68
|
+
* @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
|
|
69
|
+
*/
|
|
70
|
+
get iconPosition() {
|
|
71
|
+
let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
|
|
72
|
+
|
|
73
|
+
assert(
|
|
74
|
+
`@iconPosition for "Hds::Link::Standalone" must be one of the following: ${ICONPOSITIONS.join(
|
|
75
|
+
', '
|
|
76
|
+
)}; received: ${iconPosition}`,
|
|
77
|
+
ICONPOSITIONS.includes(iconPosition)
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return iconPosition;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param size
|
|
85
|
+
* @type {string}
|
|
86
|
+
* @default medium
|
|
87
|
+
* @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`
|
|
88
|
+
*/
|
|
89
|
+
get size() {
|
|
90
|
+
let { size = DEFAULT_SIZE } = this.args;
|
|
91
|
+
|
|
92
|
+
assert(
|
|
93
|
+
`@size for "Hds::Link::Standalone" must be one of the following: ${SIZES.join(
|
|
94
|
+
', '
|
|
95
|
+
)}; received: ${size}`,
|
|
96
|
+
SIZES.includes(size)
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return size;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param iconSize
|
|
104
|
+
* @type {string}
|
|
105
|
+
* @default 16
|
|
106
|
+
* @description ensures that the correct icon size is used. Automatically calculated.
|
|
107
|
+
*/
|
|
108
|
+
get iconSize() {
|
|
109
|
+
if (this.args.size === 'large') {
|
|
110
|
+
return '24';
|
|
111
|
+
} else {
|
|
112
|
+
return '16';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Get the class names to apply to the component.
|
|
118
|
+
* @method LinkStandalone#classNames
|
|
119
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
120
|
+
*/
|
|
121
|
+
get classNames() {
|
|
122
|
+
let classes = ['hds-link-standalone'];
|
|
123
|
+
|
|
124
|
+
// add a class based on the @size argument
|
|
125
|
+
classes.push(`hds-link-standalone--size-${this.size}`);
|
|
126
|
+
|
|
127
|
+
// add a class based on the @color argument
|
|
128
|
+
classes.push(`hds-link-standalone--color-${this.color}`);
|
|
129
|
+
|
|
130
|
+
return classes.join(' ');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<LinkTo
|
|
2
|
+
class={{this.classNames}}
|
|
3
|
+
@current-when={{@current-when}}
|
|
4
|
+
@models={{hds-link-to-models @model @models}}
|
|
5
|
+
@query={{this.queryParams}}
|
|
6
|
+
@replace={{@replace}}
|
|
7
|
+
@route={{this.route}}
|
|
8
|
+
...attributes
|
|
9
|
+
>
|
|
10
|
+
{{#if (eq this.iconPosition "leading")}}
|
|
11
|
+
<div class="hds-link-standalone__icon">
|
|
12
|
+
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
|
|
13
|
+
</div>
|
|
14
|
+
<div class="hds-link-standalone__text">
|
|
15
|
+
{{this.text}}
|
|
16
|
+
</div>
|
|
17
|
+
{{else}}
|
|
18
|
+
<div class="hds-link-standalone__text">
|
|
19
|
+
{{this.text}}
|
|
20
|
+
</div>
|
|
21
|
+
<div class="hds-link-standalone__icon">
|
|
22
|
+
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
|
|
23
|
+
</div>
|
|
24
|
+
{{/if}}
|
|
25
|
+
</LinkTo>
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { assert } from '@ember/debug';
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_ICONPOSITION = 'leading';
|
|
5
|
+
export const DEFAULT_COLOR = 'primary';
|
|
6
|
+
export const DEFAULT_SIZE = 'medium';
|
|
7
|
+
export const ICONPOSITIONS = ['leading', 'trailing'];
|
|
8
|
+
export const COLORS = ['primary', 'secondary'];
|
|
9
|
+
export const SIZES = ['small', 'medium', 'large'];
|
|
10
|
+
|
|
11
|
+
export default class HdsLinkToStandaloneComponent extends Component {
|
|
12
|
+
/**
|
|
13
|
+
* @param text
|
|
14
|
+
* @type {string}
|
|
15
|
+
* @description The text of the link. If no text value is defined an error will be thrown.
|
|
16
|
+
*/
|
|
17
|
+
get text() {
|
|
18
|
+
let { text } = this.args;
|
|
19
|
+
|
|
20
|
+
assert(
|
|
21
|
+
'@text for "Hds::LinkTo::Standalone" must have a valid value',
|
|
22
|
+
text !== undefined
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return text;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param route
|
|
30
|
+
* @type {string|null}
|
|
31
|
+
* @description Checks to make sure route is defined.
|
|
32
|
+
*/
|
|
33
|
+
get route() {
|
|
34
|
+
let { route } = this.args;
|
|
35
|
+
assert(
|
|
36
|
+
'@route must be defined for "Hds::LinkTo::Standalone"',
|
|
37
|
+
route !== undefined
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return route;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param color
|
|
45
|
+
* @type {string}
|
|
46
|
+
* @default primary
|
|
47
|
+
* @description Determines the color of link to be used; acceptable values are `primary` and `secondary`
|
|
48
|
+
*/
|
|
49
|
+
get color() {
|
|
50
|
+
let { color = DEFAULT_COLOR } = this.args;
|
|
51
|
+
|
|
52
|
+
assert(
|
|
53
|
+
`@color for "Hds::LinkTo::Standalone" must be one of the following: ${COLORS.join(
|
|
54
|
+
', '
|
|
55
|
+
)}; received: ${color}`,
|
|
56
|
+
COLORS.includes(color)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return color;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param icon
|
|
64
|
+
* @type {string|null}
|
|
65
|
+
* @default null
|
|
66
|
+
* @description The name of the icon to be used. An icon name must be defined.
|
|
67
|
+
*/
|
|
68
|
+
get icon() {
|
|
69
|
+
let { icon } = this.args;
|
|
70
|
+
|
|
71
|
+
assert(
|
|
72
|
+
'@icon for "Hds::LinkTo::Standalone" must have a valid value',
|
|
73
|
+
icon !== undefined
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return icon;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param iconPosition
|
|
81
|
+
* @type {string}
|
|
82
|
+
* @default leading
|
|
83
|
+
* @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
|
|
84
|
+
*/
|
|
85
|
+
get iconPosition() {
|
|
86
|
+
let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
|
|
87
|
+
|
|
88
|
+
assert(
|
|
89
|
+
`@iconPosition for "Hds::LinkTo::Standalone" must be one of the following: ${ICONPOSITIONS.join(
|
|
90
|
+
', '
|
|
91
|
+
)}; received: ${iconPosition}`,
|
|
92
|
+
ICONPOSITIONS.includes(iconPosition)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return iconPosition;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param size
|
|
100
|
+
* @type {string}
|
|
101
|
+
* @default medium
|
|
102
|
+
* @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`
|
|
103
|
+
*/
|
|
104
|
+
get size() {
|
|
105
|
+
let { size = DEFAULT_SIZE } = this.args;
|
|
106
|
+
|
|
107
|
+
assert(
|
|
108
|
+
`@size for "Hds::LinkTo::Standalone" must be one of the following: ${SIZES.join(
|
|
109
|
+
', '
|
|
110
|
+
)}; received: ${size}`,
|
|
111
|
+
SIZES.includes(size)
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return size;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @param iconSize
|
|
119
|
+
* @type {string}
|
|
120
|
+
* @default 16
|
|
121
|
+
* @description ensures that the correct icon size is used. Automatically calculated.
|
|
122
|
+
*/
|
|
123
|
+
get iconSize() {
|
|
124
|
+
if (this.args.size === 'large') {
|
|
125
|
+
return '24';
|
|
126
|
+
} else {
|
|
127
|
+
return '16';
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// this is a workaround for https://github.com/emberjs/ember.js/issues/19693
|
|
132
|
+
// don't remove until we drop support for ember 3.27 and 3.28
|
|
133
|
+
get queryParams() {
|
|
134
|
+
if (this.args.query) {
|
|
135
|
+
return this.args.query;
|
|
136
|
+
} else {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Get the class names to apply to the component.
|
|
143
|
+
* @method LinkToStandalone#classNames
|
|
144
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
145
|
+
*/
|
|
146
|
+
get classNames() {
|
|
147
|
+
// Notice: we've left this class name the same as the hds::link::standalone (we didn't add the "-to") so we didn't have to replicate the CSS
|
|
148
|
+
let classes = ['hds-link-standalone'];
|
|
149
|
+
|
|
150
|
+
// add a class based on the @size argument
|
|
151
|
+
classes.push(`hds-link-standalone--size-${this.size}`);
|
|
152
|
+
|
|
153
|
+
// add a class based on the @color argument
|
|
154
|
+
classes.push(`hds-link-standalone--color-${this.color}`);
|
|
155
|
+
|
|
156
|
+
return classes.join(' ');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { helper } from '@ember/component/helper';
|
|
2
|
+
import { assert } from '@ember/debug';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* This helper can be used to support both @model and @models arguments when wrapping
|
|
6
|
+
* the `<LinkTo>` component without it triggering assertions or having to use the component helper.
|
|
7
|
+
*
|
|
8
|
+
* The result of this helper should be passed into the `@models` argument of the `<LinkTo>` component:
|
|
9
|
+
*
|
|
10
|
+
* ```hbs
|
|
11
|
+
* <LinkTo @models={{hds-link-to-models @model @models}} />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export function hdsLinkToModels([model, models]) {
|
|
16
|
+
assert(
|
|
17
|
+
'You cannot provide both the `@model` and `@models` arguments to the component.',
|
|
18
|
+
!model || !models
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if (model) {
|
|
22
|
+
return [model];
|
|
23
|
+
} else if (models) {
|
|
24
|
+
return models;
|
|
25
|
+
} else {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default helper(hdsLinkToModels);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/link/standalone';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/link-to/standalone';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/helpers/hds-link-to-models';
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
// these are files coming from the 'design-system-tokens' package
|
|
1
2
|
@use "tokens";
|
|
3
|
+
@use "helpers/elevation";
|
|
4
|
+
|
|
5
|
+
@use "../mixins/generic-focus-state";
|
|
2
6
|
|
|
3
7
|
@use "../components/badge";
|
|
4
8
|
@use "../components/badge-count";
|
|
5
9
|
@use "../components/button";
|
|
6
10
|
@use "../components/card";
|
|
7
11
|
@use "../components/icon-tile";
|
|
12
|
+
@use "../components/link/standalone";
|
|
8
13
|
|
|
9
14
|
.sr-only {
|
|
10
15
|
border: 0 !important;
|
|
@@ -4,25 +4,9 @@ $hds-button-border-radius: 5px;
|
|
|
4
4
|
$hds-button-border-width: 1px;
|
|
5
5
|
$hds-button-focus-border-width: 3px;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
@mixin tempElevation() {
|
|
9
|
-
box-shadow:
|
|
10
|
-
var(--token-elevation-low-shadow-01-x)
|
|
11
|
-
var(--token-elevation-low-shadow-01-y)
|
|
12
|
-
var(--token-elevation-low-shadow-01-blur)
|
|
13
|
-
var(--token-elevation-low-shadow-01-spread)
|
|
14
|
-
var(--token-elevation-low-shadow-01-color),
|
|
15
|
-
var(--token-elevation-low-shadow-02-x)
|
|
16
|
-
var(--token-elevation-low-shadow-02-y)
|
|
17
|
-
var(--token-elevation-low-shadow-02-blur)
|
|
18
|
-
var(--token-elevation-low-shadow-02-spread)
|
|
19
|
-
var(--token-elevation-low-shadow-02-color)
|
|
20
|
-
;
|
|
21
|
-
}
|
|
7
|
+
$hds-button-sizes: ( 'small', 'medium', 'large' );
|
|
22
8
|
|
|
23
9
|
.hds-button {
|
|
24
|
-
@include tempElevation();
|
|
25
|
-
|
|
26
10
|
align-items: center;
|
|
27
11
|
border: $hds-button-border-width solid transparent; // We need this to be transparent for a11y
|
|
28
12
|
border-radius: $hds-button-border-radius;
|
|
@@ -101,41 +85,45 @@ $hds-button-focus-border-width: 3px;
|
|
|
101
85
|
|
|
102
86
|
// SIZE
|
|
103
87
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
88
|
+
// these values later may come from the design tokens
|
|
89
|
+
$size-props: (
|
|
90
|
+
"small": (
|
|
91
|
+
"font-size": 0.8125rem, // 13px;
|
|
92
|
+
"line-height": 1,
|
|
93
|
+
"min-height": 1.75rem, // 28px
|
|
94
|
+
"padding": 0 1rem, // 0 16px
|
|
95
|
+
"icon-size": 0.75rem, // 12px
|
|
96
|
+
),
|
|
97
|
+
"medium": (
|
|
98
|
+
"font-size": 0.875rem, // 14px
|
|
99
|
+
"line-height": 1rem,// 16px
|
|
100
|
+
"min-height": 2.25rem, // 36px
|
|
101
|
+
"padding": 0.625rem 1rem, // 10px 16px
|
|
102
|
+
"icon-size": 1rem, // 16px
|
|
103
|
+
),
|
|
104
|
+
"large": (
|
|
105
|
+
"font-size": 1rem, //16px
|
|
106
|
+
"line-height": 1.5rem, // 24px
|
|
107
|
+
"min-height": 3rem, // 48px
|
|
108
|
+
"padding": 0.75rem 1.25rem, // 12px 20px
|
|
109
|
+
"icon-size": 1.5rem, // 24px
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
@each $size in $hds-button-sizes {
|
|
114
|
+
.hds-button--size-#{$size} {
|
|
115
|
+
font-size: map-get($size-props, $size, "font-size");
|
|
116
|
+
min-height: map-get($size-props, $size, "min-height");
|
|
117
|
+
line-height: map-get($size-props, $size, "line-height");
|
|
118
|
+
padding: map-get($size-props, $size, "padding");
|
|
119
|
+
|
|
120
|
+
.hds-button__icon {
|
|
121
|
+
height: map-get($size-props, $size, "icon-size");
|
|
122
|
+
width: map-get($size-props, $size, "icon-size");
|
|
123
|
+
}
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
.hds-button--size-large {
|
|
129
|
-
font-size: 1rem; //16px
|
|
130
|
-
line-height: 1.5rem; // 24px
|
|
131
|
-
min-height: 3rem; //48px
|
|
132
|
-
padding: 0.75rem 1.25rem; // 12px 20px
|
|
133
|
-
|
|
134
|
-
.hds-button__icon {
|
|
135
|
-
height: 1.5rem;
|
|
136
|
-
width: 1.5rem;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
127
|
|
|
140
128
|
// COLORS & STATES
|
|
141
129
|
// Note: the order of the pseuo-selectors need to stay the way they are; it doesn't match the Figma file but it's the correct order for browsers to render the styles correctly.
|
|
@@ -5,56 +5,6 @@
|
|
|
5
5
|
//
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
// this mixin is used to apply the "elevation" styles to the card container
|
|
9
|
-
// depending on the "elevation level" and if it has a border applied to it.
|
|
10
|
-
// we are mimicking the way this effect is defined in Figma, through a set of
|
|
11
|
-
// multiple drop shadows (also the border is a 1px shadow); we tried using an
|
|
12
|
-
// outline but Safari still doesn't support rounded edges for outlines.
|
|
13
|
-
// for details see: https://www.figma.com/file/oQsMzMMnynfPWpMEt91OpH/?node-id=1988%3A2
|
|
14
|
-
|
|
15
|
-
@mixin getElevationStyle($level, $has-border: false) {
|
|
16
|
-
$drop-shadow: false;
|
|
17
|
-
$border-shadow: false;
|
|
18
|
-
|
|
19
|
-
// here we define the "drop-shadow" values (there are two shadows applied)
|
|
20
|
-
// notice: the "base" level doesn't have a "drop shadow" effect applied (no elevation)
|
|
21
|
-
@if ($level != 'base') {
|
|
22
|
-
$drop-shadow:
|
|
23
|
-
var(--token-elevation-#{$level}-shadow-01-x)
|
|
24
|
-
var(--token-elevation-#{$level}-shadow-01-y)
|
|
25
|
-
var(--token-elevation-#{$level}-shadow-01-blur)
|
|
26
|
-
var(--token-elevation-#{$level}-shadow-01-spread)
|
|
27
|
-
var(--token-elevation-#{$level}-shadow-01-color),
|
|
28
|
-
var(--token-elevation-#{$level}-shadow-02-x)
|
|
29
|
-
var(--token-elevation-#{$level}-shadow-02-y)
|
|
30
|
-
var(--token-elevation-#{$level}-shadow-02-blur)
|
|
31
|
-
var(--token-elevation-#{$level}-shadow-02-spread)
|
|
32
|
-
var(--token-elevation-#{$level}-shadow-02-color)
|
|
33
|
-
;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// here we define the "border-shadow" values
|
|
37
|
-
// notice: we create a border via a shadow, so we have zero values for x/y/blur
|
|
38
|
-
@if ($has-border) {
|
|
39
|
-
$border-shadow:
|
|
40
|
-
0
|
|
41
|
-
0
|
|
42
|
-
0
|
|
43
|
-
var(--token-elevation-#{$level}-border-width)
|
|
44
|
-
var(--token-elevation-#{$level}-border-color);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// here we join the two effects in a single box-shadow (depending on the different cases)
|
|
48
|
-
@if ($drop-shadow and not $border-shadow) {
|
|
49
|
-
box-shadow: $drop-shadow;
|
|
50
|
-
} @else if($border-shadow and not $drop-shadow) {
|
|
51
|
-
box-shadow: $border-shadow;
|
|
52
|
-
} @else {
|
|
53
|
-
// notice: we put the "border-shadow" first because the final rendering in the browser looks better
|
|
54
|
-
// see: https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow - "The z-ordering of multiple box shadows is the same as multiple text shadows (the first specified shadow is on top)."
|
|
55
|
-
box-shadow: $border-shadow, $drop-shadow;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
8
|
|
|
59
9
|
$hds-card-container-levels: ( 'base', 'mid', 'high' );
|
|
60
10
|
|
|
@@ -66,18 +16,6 @@ $hds-card-container-border-radius: 6px;
|
|
|
66
16
|
position: relative;
|
|
67
17
|
}
|
|
68
18
|
|
|
69
|
-
// LEVEL (elevation style as "drop" + "border" shadow effects)
|
|
70
|
-
|
|
71
|
-
@each $level in $hds-card-container-levels {
|
|
72
|
-
.hds-card__container--level-#{$level} {
|
|
73
|
-
@include getElevationStyle($level);
|
|
74
|
-
|
|
75
|
-
&.hds-card__container--has-border {
|
|
76
|
-
@include getElevationStyle($level, true);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
19
|
|
|
82
20
|
// BACKGROUND
|
|
83
21
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
$hds-icon-tile-sizes: ( 'small', 'medium', 'large' );
|
|
9
9
|
$hds-icon-tile-types: ( 'object','resource','logo' );
|
|
10
|
-
$hds-icon-tile-colors-products: ( 'boundary', 'consul', 'nomad', 'packer', 'terraform', 'vagrant', 'vault', 'waypoint' );
|
|
10
|
+
$hds-icon-tile-colors-products: ( 'boundary', 'consul', 'hcp', 'nomad', 'packer', 'terraform', 'vagrant', 'vault', 'waypoint' );
|
|
11
11
|
|
|
12
12
|
$hds-icon-tile-border-width: 1px;
|
|
13
13
|
$hds-icon-tile-box-shadow: 0px 1px 1px rgba(#656A76, 0.05);
|
|
@@ -52,27 +52,27 @@ $size-props: (
|
|
|
52
52
|
"small": (
|
|
53
53
|
"size": 1.75rem, // 28px
|
|
54
54
|
"border-radius": 5px,
|
|
55
|
-
"icon-size": 1rem,
|
|
56
|
-
"logo-size": 1.
|
|
57
|
-
'extra-size': 1.125rem,
|
|
55
|
+
"icon-size": 1rem, // 16px
|
|
56
|
+
"logo-size": 1.125rem, // 18px
|
|
57
|
+
'extra-size': 1.125rem, // 18px
|
|
58
58
|
'extra-border-radius': 4px,
|
|
59
59
|
'extra-icon-size': 0.75rem,
|
|
60
60
|
),
|
|
61
61
|
"medium": (
|
|
62
62
|
"size": 2.5rem, // 40px
|
|
63
63
|
"border-radius": 6px,
|
|
64
|
-
"icon-size": 1.5rem,
|
|
65
|
-
"logo-size":
|
|
66
|
-
'extra-size': 1.5rem,
|
|
64
|
+
"icon-size": 1.5rem, // 24px
|
|
65
|
+
"logo-size": 1.75rem, // 28px
|
|
66
|
+
'extra-size': 1.5rem, // 24px
|
|
67
67
|
'extra-border-radius': 5px,
|
|
68
68
|
'extra-icon-size': 1rem,
|
|
69
69
|
),
|
|
70
70
|
"large": (
|
|
71
71
|
"size": 3rem, // 48px
|
|
72
72
|
"border-radius": 6px,
|
|
73
|
-
"icon-size": 1.5rem,
|
|
74
|
-
"logo-size":
|
|
75
|
-
'extra-size': 1.5rem,
|
|
73
|
+
"icon-size": 1.5rem, // 24px
|
|
74
|
+
"logo-size": 2rem, // 32px
|
|
75
|
+
'extra-size': 1.5rem, // 24px
|
|
76
76
|
'extra-border-radius': 5px,
|
|
77
77
|
'extra-icon-size': 1rem,
|
|
78
78
|
)
|
|
@@ -111,19 +111,9 @@ $size-props: (
|
|
|
111
111
|
// LOGO - COLOR
|
|
112
112
|
|
|
113
113
|
.hds-icon-tile--logo {
|
|
114
|
+
// notice: we are using colored icons so we don't need to set the "color" property here
|
|
114
115
|
background-color: var(--token-color-neutral-background-primary);
|
|
115
116
|
border-color: var(--token-color-neutral-border-primary);
|
|
116
|
-
|
|
117
|
-
@each $product in $hds-icon-tile-colors-products {
|
|
118
|
-
&.hds-icon-tile--color-#{$product} {
|
|
119
|
-
color: var(--token-color-#{$product}-brand);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// exception for Vault, where the color of the logo needs to be the "alt" one
|
|
124
|
-
&.hds-icon-tile--color-vault {
|
|
125
|
-
color: var(--token-color-vault-brand-alt);
|
|
126
|
-
}
|
|
127
117
|
}
|
|
128
118
|
|
|
129
119
|
// ICON - COLOR
|
|
@@ -137,10 +127,20 @@ $size-props: (
|
|
|
137
127
|
}
|
|
138
128
|
|
|
139
129
|
@each $product in $hds-icon-tile-colors-products {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
color
|
|
130
|
+
@if ($product == 'hcp') {
|
|
131
|
+
// exception for HCP (we use neutral colors, we don't have specific product colors for foreground/background)
|
|
132
|
+
// notice: at the moment we don't have a token for that, that's why we're using an hex value
|
|
133
|
+
&.hds-icon-tile--color-hcp {
|
|
134
|
+
background-color: var(--token-color-neutral-background-secondary);
|
|
135
|
+
border-color: var(--token-color-neutral-border-primary);
|
|
136
|
+
color: var(--token-color-palette-#{$product}-brand);
|
|
137
|
+
}
|
|
138
|
+
} @else {
|
|
139
|
+
&.hds-icon-tile--color-#{$product} {
|
|
140
|
+
background: linear-gradient(135deg, var(--token-color-#{$product}-gradient-faint-start) 0%, var(--token-color-#{$product}-gradient-faint-stop) 100%);
|
|
141
|
+
border-color: var(--token-color-#{$product}-border);
|
|
142
|
+
color: var(--token-color-#{$product}-foreground);
|
|
143
|
+
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|