@hashicorp/design-system-components 0.0.3 → 0.0.8

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.
@@ -90,7 +90,9 @@ jobs:
90
90
  steps.cache-dependencies.outputs.cache-hit != 'true'
91
91
 
92
92
  - name: Test
93
- run: yarn test:ember --launch ${{ matrix.browser }}
93
+ run: yarn test:ember:percy --launch ${{ matrix.browser }}
94
+ env:
95
+ PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
94
96
 
95
97
  floating-dependencies:
96
98
  name: Floating Dependencies
@@ -132,7 +134,9 @@ jobs:
132
134
  run: yarn install --no-lockfile --non-interactive
133
135
 
134
136
  - name: Test
135
- run: yarn test:ember --launch ${{ matrix.browser }}
137
+ run: yarn test:ember:percy --launch ${{ matrix.browser }}
138
+ env:
139
+ PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
136
140
 
137
141
  try-scenarios:
138
142
  name: Tests - ${{ matrix.ember-try-scenario }}
@@ -0,0 +1,43 @@
1
+ {
2
+ "bitwise": true,
3
+ "camelcase": true,
4
+ "curly": false,
5
+ "eqeqeq": true,
6
+ "es3": true,
7
+ "forin": true,
8
+ "immed": false,
9
+ "indent": false,
10
+ "latedef": "nofunc",
11
+ "newcap": false,
12
+ "noarg": true,
13
+ "noempty": true,
14
+ "nonew": false,
15
+ "plusplus": false,
16
+ "quotmark": false,
17
+ "undef": true,
18
+ "unused": "vars",
19
+ "strict": false,
20
+ "trailing": true,
21
+ "maxparams": 5,
22
+ "maxdepth": false,
23
+ "maxstatements": false,
24
+ "maxcomplexity": false,
25
+ "maxlen": 100,
26
+
27
+ "asi": true,
28
+ "expr": true,
29
+ "globalstrict": true,
30
+ "smarttabs": true,
31
+ "sub": true,
32
+
33
+ "node": true,
34
+ "globals": {
35
+ "describe": false,
36
+ "it": false,
37
+ "before": false,
38
+ "beforeEach": false,
39
+ "after": false,
40
+ "afterEach": false,
41
+ "define": false
42
+ }
43
+ }
@@ -1,4 +1,4 @@
1
- <div class="hds-badge {{this.colorClass}} {{this.typeClass}} {{this.sizeClass}}" ...attributes >
1
+ <div class="hds-badge {{this.sizeClass}} {{this.typeClass}} {{this.colorClass}}" ...attributes>
2
2
  {{#if @icon}}
3
3
  <div class="hds-badge__icon">
4
4
  <FlightIcon @name={{this.icon}} @size="16" @stretched="true" />
@@ -1,12 +1,12 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { assert } from '@ember/debug';
3
3
 
4
- const DEFAULT_SIZE = 'medium';
5
- const DEFAULT_COLOR = 'neutral';
6
- const DEFAULT_TYPE = 'filled';
7
- const SIZES = ['small', 'medium', 'large'];
8
- const TYPES = ['filled', 'inverted', 'outlined'];
9
- const COLORS = [
4
+ export const DEFAULT_SIZE = 'medium';
5
+ export const DEFAULT_TYPE = 'filled';
6
+ export const DEFAULT_COLOR = 'neutral';
7
+ export const SIZES = ['small', 'medium', 'large'];
8
+ export const TYPES = ['filled', 'inverted', 'outlined'];
9
+ export const COLORS = [
10
10
  'neutral',
11
11
  'neutral-dark-mode',
12
12
  'highlight',
@@ -17,8 +17,8 @@ const COLORS = [
17
17
 
18
18
  export default class HdsBadgeIndexComponent extends Component {
19
19
  /**
20
- * Sets the size for the badge
21
- * Accepted sizes: small, medium, large
20
+ * Sets the size for the component
21
+ * Accepted values: small, medium, large
22
22
  *
23
23
  * @param size
24
24
  * @type {string}
@@ -27,29 +27,27 @@ export default class HdsBadgeIndexComponent extends Component {
27
27
  get size() {
28
28
  let { size = DEFAULT_SIZE } = this.args;
29
29
 
30
- if (size) {
31
- assert(
32
- `@size for ${this.toString()} must be one of the following: ${SIZES.join(
33
- ', '
34
- )}, received: ${size}`,
35
- SIZES.includes(size)
36
- );
37
- }
30
+ assert(
31
+ `@size for "Hds::Badge" must be one of the following: ${SIZES.join(
32
+ ', '
33
+ )}, received: ${size}`,
34
+ SIZES.includes(size)
35
+ );
38
36
 
39
37
  return size;
40
38
  }
41
39
 
42
40
  /**
43
- * Get a class to apply to the badge based on the size argument.
41
+ * Get a class to apply to the component based on the size argument.
44
42
  * @method Badge#sizeClass
45
- * @return {string} The css class to apply to the Badge.
43
+ * @return {string} The css class to apply to the component.
46
44
  */
47
45
  get sizeClass() {
48
46
  return `hds-badge--size-${this.size}`;
49
47
  }
50
48
 
51
49
  /**
52
- * Sets the type of badge
50
+ * Sets the type of the component
53
51
  * Accepted values: filled, inverted, outlined
54
52
  *
55
53
  * @param type
@@ -59,30 +57,28 @@ export default class HdsBadgeIndexComponent extends Component {
59
57
  get type() {
60
58
  let { type = DEFAULT_TYPE } = this.args;
61
59
 
62
- if (type) {
63
- assert(
64
- `@type for ${this.toString()} must be one of the following: ${TYPES.join(
65
- ', '
66
- )}, received: ${type}`,
67
- TYPES.includes(type)
68
- );
69
- }
60
+ assert(
61
+ `@type for "Hds::Badge" must be one of the following: ${TYPES.join(
62
+ ', '
63
+ )}, received: ${type}`,
64
+ TYPES.includes(type)
65
+ );
70
66
 
71
67
  return type;
72
68
  }
73
69
 
74
70
  /**
75
- * Get a class to apply to the badge based on the type argument.
71
+ * Get a class to apply to the component based on the type argument.
76
72
  * @method Badge#typeClass
77
- * @return {string} The css class to apply to the Badge.
73
+ * @return {string} The css class to apply to the component.
78
74
  */
79
75
  get typeClass() {
80
76
  return `hds-badge--type-${this.type}`;
81
77
  }
82
78
 
83
79
  /**
84
- * Sets the color scheme for the badge
85
- * Accepted colors: neutral, neutral-dark-mode, highlight, success, warning, critical
80
+ * Sets the color scheme for the component
81
+ * Accepted values: neutral, neutral-dark-mode, highlight, success, warning, critical
86
82
  *
87
83
  * @param color
88
84
  * @type {string}
@@ -91,22 +87,20 @@ export default class HdsBadgeIndexComponent extends Component {
91
87
  get color() {
92
88
  let { color = DEFAULT_COLOR } = this.args;
93
89
 
94
- if (color) {
95
- assert(
96
- `@color for ${this.toString()} must be one of the following: ${COLORS.join(
97
- ', '
98
- )}, received: ${color}`,
99
- COLORS.includes(color)
100
- );
101
- }
90
+ assert(
91
+ `@color for "Hds::Badge" must be one of the following: ${COLORS.join(
92
+ ', '
93
+ )}, received: ${color}`,
94
+ COLORS.includes(color)
95
+ );
102
96
 
103
97
  return color;
104
98
  }
105
99
 
106
100
  /**
107
- * Get a class to apply to the badge based on the color argument.
101
+ * Get a class to apply to the component based on the color argument.
108
102
  * @method Badge#colorClass
109
- * @return {string} The css class to apply to the Badge.
103
+ * @return {string} The css class to apply to the component.
110
104
  */
111
105
  get colorClass() {
112
106
  return `hds-badge--color-${this.color}`;
@@ -0,0 +1,3 @@
1
+ <div class="hds-badge-count {{this.sizeClass}} {{this.typeClass}} {{this.colorClass}}" ...attributes >
2
+ {{@text}}
3
+ </div>
@@ -0,0 +1,101 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ export const DEFAULT_SIZE = 'medium';
5
+ export const DEFAULT_TYPE = 'filled';
6
+ export const DEFAULT_COLOR = 'neutral';
7
+ export const SIZES = ['small', 'medium', 'large'];
8
+ export const TYPES = ['filled', 'inverted', 'outlined'];
9
+ export const COLORS = ['neutral', 'neutral-dark-mode'];
10
+
11
+ export default class HdsBadgeCountIndexComponent extends Component {
12
+ /**
13
+ * Sets the size for the component
14
+ * Accepted sizes: small, medium, large
15
+ *
16
+ * @param size
17
+ * @type {string}
18
+ * @default 'medium'
19
+ */
20
+ get size() {
21
+ let { size = DEFAULT_SIZE } = this.args;
22
+
23
+ assert(
24
+ `@size for "Hds::BadgeCount" must be one of the following: ${SIZES.join(
25
+ ', '
26
+ )}, received: ${size}`,
27
+ SIZES.includes(size)
28
+ );
29
+
30
+ return size;
31
+ }
32
+
33
+ /**
34
+ * Get a class to apply to the component based on the size argument.
35
+ * @method BadgeCount#sizeClass
36
+ * @return {string} The css class to apply to the component.
37
+ */
38
+ get sizeClass() {
39
+ return `hds-badge-count--size-${this.size}`;
40
+ }
41
+
42
+ /**
43
+ * Sets the type of the component
44
+ * Accepted values: filled, inverted, outlined
45
+ *
46
+ * @param type
47
+ * @type {string}
48
+ * @default 'filled'
49
+ */
50
+ get type() {
51
+ let { type = DEFAULT_TYPE } = this.args;
52
+
53
+ assert(
54
+ `@type for "Hds::BadgeCount" must be one of the following: ${TYPES.join(
55
+ ', '
56
+ )}, received: ${type}`,
57
+ TYPES.includes(type)
58
+ );
59
+
60
+ return type;
61
+ }
62
+
63
+ /**
64
+ * Get a class to apply to the component based on the type argument.
65
+ * @method BadgeCount#typeClass
66
+ * @return {string} The css class to apply to the component.
67
+ */
68
+ get typeClass() {
69
+ return `hds-badge-count--type-${this.type}`;
70
+ }
71
+
72
+ /**
73
+ * Sets the color scheme for the component
74
+ * Accepted colors: neutral, neutral-dark-mode
75
+ *
76
+ * @param color
77
+ * @type {string}
78
+ * @default 'neutral'
79
+ */
80
+ get color() {
81
+ let { color = DEFAULT_COLOR } = this.args;
82
+
83
+ assert(
84
+ `@color for "Hds::BadgeCount" must be one of the following: ${COLORS.join(
85
+ ', '
86
+ )}, received: ${color}`,
87
+ COLORS.includes(color)
88
+ );
89
+
90
+ return color;
91
+ }
92
+
93
+ /**
94
+ * Get a class to apply to the component based on the color argument.
95
+ * @method BadgeCount#colorClass
96
+ * @return {string} The css class to apply to the component.
97
+ */
98
+ get colorClass() {
99
+ return `hds-badge-count--color-${this.color}`;
100
+ }
101
+ }
@@ -0,0 +1,35 @@
1
+ <button
2
+ class="hds-button {{this.sizeClass}} {{this.colorClass}} {{this.widthClass}}"
3
+ ...attributes
4
+ aria-label={{if this.isIconOnly this.text null}}
5
+ type={{this.type}}
6
+ disabled={{if this.isDisabled "disabled" null}}
7
+ >
8
+ {{#if this.isIconOnly}}
9
+ <div class="hds-button__icon">
10
+ <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
11
+ </div>
12
+ {{else}}
13
+ {{#if this.icon}}
14
+ {{#if (eq this.iconPos "leading")}}
15
+ <div class="hds-button__icon">
16
+ <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
17
+ </div>
18
+ <div class="hds-button__text">
19
+ {{this.text}}
20
+ </div>
21
+ {{else}}
22
+ <div class="hds-button__text">
23
+ {{this.text}}
24
+ </div>
25
+ <div class="hds-button__icon">
26
+ <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
27
+ </div>
28
+ {{/if}}
29
+ {{else}}
30
+ <div class="hds-button__text">
31
+ {{this.text}}
32
+ </div>
33
+ {{/if}}
34
+ {{/if}}
35
+ </button>
@@ -0,0 +1,185 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ export const DEFAULT_SIZE = 'medium';
5
+ export const DEFAULT_COLOR = 'primary';
6
+ export const DEFAULT_TYPE = 'button';
7
+ export const SIZES = ['small', 'medium', 'large'];
8
+ export const COLORS = ['primary', 'secondary', 'destructive'];
9
+ export const TYPES = ['button', 'submit', 'reset'];
10
+
11
+ export default class HdsButtonIndexComponent extends Component {
12
+ /**
13
+ * @param text
14
+ * @type {string}
15
+ * @description The text of the button or value of `aria-label` if `isIconOnly` is set to `true`. 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::Button" must have a valid value',
22
+ text !== undefined
23
+ );
24
+
25
+ return text;
26
+ }
27
+
28
+ /**
29
+ * @param size
30
+ * @type {string}
31
+ * @default medium
32
+ * @description The size of the button; acceptable values are `small`, `medium`, and `large`
33
+ */
34
+ get size() {
35
+ let { size = DEFAULT_SIZE } = this.args;
36
+
37
+ assert(
38
+ `@size for "Hds::Button" must be one of the following: ${SIZES.join(
39
+ ', '
40
+ )}; received: ${size}`,
41
+ SIZES.includes(size)
42
+ );
43
+
44
+ return size;
45
+ }
46
+
47
+ /**
48
+ * @param sizeClass
49
+ * @type {string}
50
+ * @default hds-button--size-medium
51
+ * @description Determines the CSS class that the button should have, based on the size value; automatically set.
52
+ */
53
+ get sizeClass() {
54
+ return `hds-button--size-${this.size}`;
55
+ }
56
+
57
+ /**
58
+ * @param color
59
+ * @type {string}
60
+ * @default primary
61
+ * @description Determines the color of button to be used; acceptable values are `primary`, `secondary`, and `destructive`
62
+ */
63
+ get color() {
64
+ let { color = DEFAULT_COLOR } = this.args;
65
+
66
+ assert(
67
+ `@color for "Hds::Button" must be one of the following: ${COLORS.join(
68
+ ', '
69
+ )}; received: ${color}`,
70
+ COLORS.includes(color)
71
+ );
72
+
73
+ return color;
74
+ }
75
+
76
+ /**
77
+ * @param colorClass
78
+ * @type {string}
79
+ * @default hds-button--color-primary
80
+ * @description Determines the CSS class that the button should have, based on the color value; automatically set
81
+ */
82
+ get colorClass() {
83
+ return `hds-button--color-${this.color}`;
84
+ }
85
+
86
+ /**
87
+ * @param icon
88
+ * @type {string}
89
+ * @default null
90
+ * @description The name of the icon to be used.
91
+ */
92
+ get icon() {
93
+ return this.args.icon ?? null;
94
+ }
95
+
96
+ /**
97
+ * @param isIconOnly
98
+ * @type {boolean}
99
+ * @default false
100
+ * @description Indicates if the button will only contain an icon; component will also ensure that accessible text is still applied to the component.
101
+ */
102
+ get isIconOnly() {
103
+ if (this.icon) {
104
+ return this.args.isIconOnly ?? false;
105
+ }
106
+ return false;
107
+ }
108
+
109
+ /**
110
+ * @param iconPos
111
+ * @type {string}
112
+ * @default leading
113
+ * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
114
+ */
115
+ get iconPos() {
116
+ return this.args.iconPos ?? 'leading';
117
+ }
118
+
119
+ /**
120
+ * @param iconSize
121
+ * @type {string}
122
+ * @default 16
123
+ * @description ensures that the correct icon size is used. Automatically calculated.
124
+ */
125
+ get iconSize() {
126
+ if (this.args.size === 'large') {
127
+ return '24';
128
+ } else {
129
+ return '16';
130
+ }
131
+ }
132
+
133
+ /**
134
+ * @param type
135
+ * @type {string}
136
+ * @default button
137
+ * @description The value for the button's `type` attribute. Acceptable values are `button`, `submit`, and `reset`
138
+ */
139
+ get type() {
140
+ let { type = DEFAULT_TYPE } = this.args;
141
+
142
+ assert(
143
+ `@type for "Hds::Button" must be one of the following: ${TYPES.join(
144
+ ', '
145
+ )}; received: ${type}`,
146
+ TYPES.includes(type)
147
+ );
148
+
149
+ return type;
150
+ }
151
+
152
+ /**
153
+ * @param isFullWidth
154
+ * @type {boolean}
155
+ * @default false
156
+ * @description Indicates that a button should take up the full width of the parent container. The default is false.
157
+ */
158
+ get isFullWidth() {
159
+ return this.args.isFullWidth ?? false;
160
+ }
161
+
162
+ /**
163
+ * @param widthClass
164
+ * @type {string|null}
165
+ * @default null
166
+ * @description Determines if the full-width class should be applied to the component. This is set automatically based on the value of `isFullWidth`.
167
+ */
168
+ get widthClass() {
169
+ if (this.isFullWidth === true) {
170
+ return 'hds-button--width-full';
171
+ } else {
172
+ return null;
173
+ }
174
+ }
175
+
176
+ /**
177
+ * @param isDisabled
178
+ * @type {boolean}
179
+ * @default null
180
+ * @description Sets the native HTML attribute `disabled` on the button element. Default is null (doesn't render the attribute).
181
+ */
182
+ get isDisabled() {
183
+ return this.args.isDisabled ?? null;
184
+ }
185
+ }
@@ -0,0 +1,3 @@
1
+ <div class="hds-card__container {{this.levelClass}} {{this.borderClass}} {{this.backgroundClass}} {{this.overflowClass}}" ...attributes>
2
+ {{yield}}
3
+ </div>
@@ -0,0 +1,110 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ export const DEFAULT_LEVEL = 'base';
5
+ export const DEFAULT_BACKGROUND = 'neutral-primary';
6
+ export const DEFAULT_OVERFLOW = 'hidden';
7
+ export const LEVELS = ['base', 'mid', 'high'];
8
+ export const BACKGROUNDS = ['neutral-primary', 'neutral-secondary'];
9
+ export const OVERFLOWS = ['hidden', 'visible'];
10
+
11
+ export default class HdsCardContainerComponent extends Component {
12
+ /**
13
+ * Sets the "elevation" level for the component
14
+ * Accepted values: base, mid, high
15
+ *
16
+ * @param level
17
+ * @type {string}
18
+ * @default 'base'
19
+ */
20
+ get level() {
21
+ let { level = DEFAULT_LEVEL } = this.args;
22
+
23
+ assert(
24
+ `@level for "Hds::CardContainer" must be one of the following: ${LEVELS.join(
25
+ ', '
26
+ )}, received: ${level}`,
27
+ LEVELS.includes(level)
28
+ );
29
+
30
+ return level;
31
+ }
32
+
33
+ /**
34
+ * Get a class to apply to the component based on the level argument.
35
+ * @method Card#levelClass
36
+ * @return {string} The css class to apply to the component.
37
+ */
38
+ get levelClass() {
39
+ return `hds-card__container--level-${this.level}`;
40
+ }
41
+
42
+ /**
43
+ * Sets the background for the component
44
+ * Accepted values: neutral-primary, neutral-secondary
45
+ *
46
+ * @param background
47
+ * @type {string}
48
+ * @default 'base'
49
+ */
50
+ get background() {
51
+ let { background = DEFAULT_BACKGROUND } = this.args;
52
+
53
+ assert(
54
+ `@background for "Hds::CardContainer" must be one of the following: ${BACKGROUNDS.join(
55
+ ', '
56
+ )}, received: ${background}`,
57
+ BACKGROUNDS.includes(background)
58
+ );
59
+
60
+ return background;
61
+ }
62
+
63
+ /**
64
+ * Get a class to apply to the component based on the background argument.
65
+ * @method Card#backgroundClass
66
+ * @return {string} The css class to apply to the component.
67
+ */
68
+ get backgroundClass() {
69
+ return `hds-card__container--background-${this.background}`;
70
+ }
71
+
72
+ /**
73
+ * Get a class to apply to the component based on the hasBorder argument.
74
+ * @method Card#hasBorderClass
75
+ * @return {string} The css class to apply to the component.
76
+ */
77
+ get borderClass() {
78
+ return this.args.hasBorder ? `hds-card__container--has-border` : undefined;
79
+ }
80
+
81
+ /**
82
+ * Sets the level for the card
83
+ * Accepted values: visible, hidden
84
+ *
85
+ * @param overflow
86
+ * @type {string}
87
+ * @default 'hidden'
88
+ */
89
+ get overflow() {
90
+ let { overflow = DEFAULT_OVERFLOW } = this.args;
91
+
92
+ assert(
93
+ `@overflow for "Hds::CardContainer" must be one of the following: ${OVERFLOWS.join(
94
+ ', '
95
+ )}, received: ${overflow}`,
96
+ OVERFLOWS.includes(overflow)
97
+ );
98
+
99
+ return overflow;
100
+ }
101
+
102
+ /**
103
+ * Get a class to apply to the component based on the overflow argument.
104
+ * @method Card#overflowClass
105
+ * @return {string} The css class to apply to the component.
106
+ */
107
+ get overflowClass() {
108
+ return `hds-card__container--overflow-${this.overflow}`;
109
+ }
110
+ }