@hashicorp/design-system-components 1.4.0 → 1.5.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @hashicorp/design-system-components
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#827](https://github.com/hashicorp/design-system/pull/827) [`c775030b0`](https://github.com/hashicorp/design-system/commit/c775030b0337d630159ce3a108b61f336efca7bb) Thanks [@MelSumner](https://github.com/MelSumner)! - [PR 760](https://github.com/hashicorp/design-system/pull/760) Finalized Hds::Table component; resolved text alignment and column width invocation options. Added support for `th` elements with the scope of `row`.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#816](https://github.com/hashicorp/design-system/pull/816) [`325cdaa2a`](https://github.com/hashicorp/design-system/commit/325cdaa2aa3859058de9f79758e1f1d1c5e4246e) Thanks [@jorytindall](https://github.com/jorytindall)! - Updated the modal border radius based on revised design guidelines.
12
+
13
+ ## 1.4.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [#740](https://github.com/hashicorp/design-system/pull/740) [`cd1a09307`](https://github.com/hashicorp/design-system/commit/cd1a09307aef9617e7a31a5d9e722417f4c9045e) Thanks [@alex-ju](https://github.com/alex-ju)! - Add `indeterminate` style to `Checkbox` component
18
+
19
+ - Updated dependencies [[`92c83961f`](https://github.com/hashicorp/design-system/commit/92c83961f0e8b01e52e3c596c85871ec5cf8c94d)]:
20
+ - @hashicorp/design-system-tokens@1.3.0
21
+
3
22
  ## 1.4.0
4
23
 
5
24
  ### Minor Changes
@@ -8,26 +8,18 @@
8
8
  {{#if @columns}}
9
9
  <Hds::Table::Tr>
10
10
  {{#each @columns as |column|}}
11
- {{#if @sortingKeys}}
12
- {{#if (includes column.key @sortingKeys)}}
13
- <Hds::Table::ThSort
14
- @isSorted={{eq column.key this.sortBy}}
15
- @sortOrder={{this.sortOrder}}
16
- @onClick={{(fn this.setSortBy column.key)}}
17
- >
18
- {{column.label}}
19
- </Hds::Table::ThSort>
20
- {{else}}
21
- <Hds::Table::Th>{{column.label}}</Hds::Table::Th>
22
- {{/if}}
23
- {{else}}
11
+ {{#if column.isSortable}}
24
12
  <Hds::Table::ThSort
25
13
  @isSorted={{eq column.key this.sortBy}}
26
14
  @sortOrder={{this.sortOrder}}
27
15
  @onClick={{(fn this.setSortBy column.key)}}
16
+ @align={{column.align}}
17
+ @width={{column.width}}
28
18
  >
29
19
  {{column.label}}
30
20
  </Hds::Table::ThSort>
21
+ {{else}}
22
+ <Hds::Table::Th @align={{column.align}} @width={{column.width}}>{{column.label}}</Hds::Table::Th>
31
23
  {{/if}}
32
24
  {{/each}}
33
25
  </Hds::Table::Tr>
@@ -41,14 +33,25 @@
41
33
  <tbody class="hds-table__tbody">
42
34
  {{#if @columns}}
43
35
  {{#each (sort-by this.getSortCriteria @model) as |data|}}
44
- {{yield (hash Tr=(component "hds/table/tr") Td=(component "hds/table/td") data=data) to="body"}}
45
- {{/each}}
46
- {{else if @model}}
47
- {{#each @model as |data|}}
48
- {{yield (hash Tr=(component "hds/table/tr") Td=(component "hds/table/td") data=data) to="body"}}
36
+ {{yield
37
+ (hash
38
+ Tr=(component "hds/table/tr")
39
+ Th=(component "hds/table/th" scope="row")
40
+ Td=(component "hds/table/td" align=@align)
41
+ data=data
42
+ )
43
+ to="body"
44
+ }}
49
45
  {{/each}}
50
46
  {{else}}
51
- {{yield (hash Tr=(component "hds/table/tr") Td=(component "hds/table/td")) to="body"}}
47
+ {{yield
48
+ (hash
49
+ Tr=(component "hds/table/tr")
50
+ Th=(component "hds/table/th" scope="row")
51
+ Td=(component "hds/table/td" align=@align)
52
+ )
53
+ to="body"
54
+ }}
52
55
  {{/if}}
53
56
  </tbody>
54
57
  </table>
@@ -5,7 +5,7 @@ import { assert } from '@ember/debug';
5
5
 
6
6
  const DENSITIES = ['short', 'medium', 'tall'];
7
7
  const DEFAULT_DENSITY = 'medium';
8
- const VALIGNMENTS = ['top', 'middle', 'bottom', 'baseline', 'sub', 'text-top'];
8
+ const VALIGNMENTS = ['top', 'middle'];
9
9
  const DEFAULT_VALIGN = 'top';
10
10
 
11
11
  export default class HdsTableIndexComponent extends Component {
@@ -20,11 +20,21 @@ export default class HdsTableIndexComponent extends Component {
20
20
  /**
21
21
  * @param isStriped
22
22
  * @type {boolean}
23
- * @default true
24
- * @description Determines whether the table rows should have alternating background colors; defaults to true.
23
+ * @default false
24
+ * @description Determines whether the table rows should have alternating background colors; defaults to false.
25
25
  */
26
26
  get isStriped() {
27
- return this.args.isStriped ?? true;
27
+ return this.args.isStriped ?? false;
28
+ }
29
+
30
+ /**
31
+ * @param isFixedLayout
32
+ * @type {boolean}
33
+ * @default false
34
+ * @description Determines whether the table-display should be set to fixed; meaning, the table columns are of equal width no matter the content; defaults to false.
35
+ */
36
+ get isFixedLayout() {
37
+ return this.args.isFixedLayout ?? false;
28
38
  }
29
39
 
30
40
  /**
@@ -50,7 +60,7 @@ export default class HdsTableIndexComponent extends Component {
50
60
  * @param valign
51
61
  * @type {string}
52
62
  * @default 'top'
53
- * @description Determines the vertical alignment of the table cells; options are all of the values accepted by the CSS "vertical-align" property: "top", "middle", "bottom", "baseline", "sub", and "text-top". If no valign is defined, "top" is used.
63
+ * @description Determines the vertical alignment of the table cells; options are: "top", "middle". If no valign is defined, "top" is used.
54
64
  */
55
65
  get valign() {
56
66
  let { valign = DEFAULT_VALIGN } = this.args;
@@ -78,6 +88,11 @@ export default class HdsTableIndexComponent extends Component {
78
88
  classes.push('hds-table--striped');
79
89
  }
80
90
 
91
+ // add a class based on the @isFixedLayout argument
92
+ if (this.isFixedLayout) {
93
+ classes.push('hds-table--layout-fixed');
94
+ }
95
+
81
96
  // add a class based on the @density argument
82
97
  if (this.density) {
83
98
  classes.push(`hds-table--density-${this.density}`);
@@ -1,3 +1,3 @@
1
- <td class="hds-table__td hds-typography-body-200 hds-font-weight-regular" ...attributes>
1
+ <td class={{this.classNames}} ...attributes>
2
2
  {{yield}}
3
3
  </td>
@@ -0,0 +1,45 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ const ALIGNMENTS = ['left', 'center', 'right'];
5
+ const DEFAULT_ALIGN = 'left';
6
+
7
+ export default class HdsTableTdComponent extends Component {
8
+ /**
9
+ * @param align
10
+ * @type {string}
11
+ * @default left
12
+ * @description Determines the text alignment of the header or cell content. Options are: "left", "center", "right". If no align is defined, "left" is used.
13
+ */
14
+ get align() {
15
+ let { align = DEFAULT_ALIGN } = this.args;
16
+
17
+ assert(
18
+ `@align for "Hds::Table::Td" must be one of the following: ${ALIGNMENTS.join(
19
+ ', '
20
+ )}; received: ${align}`,
21
+ ALIGNMENTS.includes(align)
22
+ );
23
+ return align;
24
+ }
25
+
26
+ /**
27
+ * Get the class names to apply to the component.
28
+ * @method classNames
29
+ * @return {string} The "class" attribute to apply to the component.
30
+ */
31
+ get classNames() {
32
+ let classes = [
33
+ 'hds-table__td',
34
+ 'hds-typography-body-200',
35
+ 'hds-font-weight-regular',
36
+ ];
37
+
38
+ // add a class based on the @align argument
39
+ if (this.align) {
40
+ classes.push(`.hds-table__td--text-${this.align}`);
41
+ }
42
+
43
+ return classes.join(' ');
44
+ }
45
+ }
@@ -1,4 +1,4 @@
1
- <th scope="col" class="hds-table__th-sort" aria-sort={{this.ariaSort}} ...attributes>
1
+ <th class={{this.classNames}} aria-sort={{this.ariaSort}} {{style width=@width}} ...attributes scope="col">
2
2
  <button type="button" {{on "click" this.onClick}}>
3
3
  <div class="hds-table__th-sort--button-content">
4
4
  <span class="hds-typography-body-200 hds-font-weight-semibold">{{yield}}</span>
@@ -1,6 +1,9 @@
1
1
  import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
2
3
 
3
4
  const NOOP = () => {};
5
+ const ALIGNMENTS = ['left', 'center', 'right'];
6
+ const DEFAULT_ALIGN = 'left';
4
7
 
5
8
  export default class HdsTableThSortComponent extends Component {
6
9
  /**
@@ -32,6 +35,24 @@ export default class HdsTableThSortComponent extends Component {
32
35
  }
33
36
  }
34
37
 
38
+ /**
39
+ * @param align
40
+ * @type {string}
41
+ * @default left
42
+ * @description Determines the text alignment of the header or cell content. Options are: "left", "center", "right". If no align is defined, "left" is used.
43
+ */
44
+ get align() {
45
+ let { align = DEFAULT_ALIGN } = this.args;
46
+
47
+ assert(
48
+ `@align for "Hds::Table" must be one of the following: ${ALIGNMENTS.join(
49
+ ', '
50
+ )}; received: ${align}`,
51
+ ALIGNMENTS.includes(align)
52
+ );
53
+ return align;
54
+ }
55
+
35
56
  /**
36
57
  * @param onClick
37
58
  * @type {function}
@@ -41,4 +62,20 @@ export default class HdsTableThSortComponent extends Component {
41
62
  let { onClick } = this.args;
42
63
  return onClick || NOOP;
43
64
  }
65
+
66
+ /**
67
+ * Get the class names to apply to the component.
68
+ * @method classNames
69
+ * @return {string} The "class" attribute to apply to the component.
70
+ */
71
+ get classNames() {
72
+ let classes = ['hds-table__th-sort'];
73
+
74
+ // add a class based on the @align argument
75
+ if (this.align) {
76
+ classes.push(`.hds-table__th-sort--text-${this.align}`);
77
+ }
78
+
79
+ return classes.join(' ');
80
+ }
44
81
  }
@@ -1,3 +1,3 @@
1
- <th class="hds-table__th hds-typography-body-200 hds-font-weight-semibold" ...attributes scope="col">
1
+ <th class={{this.classNames}} {{style width=@width}} ...attributes scope={{(or @scope "col")}}>
2
2
  {{yield}}
3
3
  </th>
@@ -0,0 +1,45 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ const ALIGNMENTS = ['left', 'center', 'right'];
5
+ const DEFAULT_ALIGN = 'left';
6
+
7
+ export default class HdsTableThComponent extends Component {
8
+ /**
9
+ * @param align
10
+ * @type {string}
11
+ * @default left
12
+ * @description Determines the text alignment of the header or cell content. Options are: "left", "center", "right". If no align is defined, "left" is used.
13
+ */
14
+ get align() {
15
+ let { align = DEFAULT_ALIGN } = this.args;
16
+
17
+ assert(
18
+ `@align for "Hds::Table::Th" must be one of the following: ${ALIGNMENTS.join(
19
+ ', '
20
+ )}; received: ${align}`,
21
+ ALIGNMENTS.includes(align)
22
+ );
23
+ return align;
24
+ }
25
+
26
+ /**
27
+ * Get the class names to apply to the component.
28
+ * @method classNames
29
+ * @return {string} The "class" attribute to apply to the component.
30
+ */
31
+ get classNames() {
32
+ let classes = [
33
+ 'hds-table__th',
34
+ 'hds-typography-body-200',
35
+ 'hds-font-weight-semibold',
36
+ ];
37
+
38
+ // add a class based on the @align argument
39
+ if (this.align) {
40
+ classes.push(`.hds-table__th--text-${this.align}`);
41
+ }
42
+
43
+ return classes.join(' ');
44
+ }
45
+ }
@@ -22,7 +22,7 @@
22
22
 
23
23
  // base (default)
24
24
 
25
- &:not(:checked) {
25
+ &:not(:checked, :indeterminate) {
26
26
  background-color: var(--token-form-control-base-surface-color-default);
27
27
  border-color: var(--token-form-control-base-border-color-default);
28
28
  box-shadow: var(--hds-elevation-inset-box-shadow);
@@ -34,16 +34,24 @@
34
34
  border-color: var(--token-form-control-checked-border-color-default);
35
35
  }
36
36
 
37
+ &:indeterminate {
38
+ background-color: var(--token-form-control-checked-surface-color-default);
39
+ background-image: var(--token-form-checkbox-background-image-data-url-indeterminate);
40
+ border-color: var(--token-form-control-checked-border-color-default);
41
+ }
42
+
37
43
  // hover
38
44
 
39
- &:hover:not(:checked),
40
- &.mock-hover:not(:checked) {
45
+ &:hover:not(:checked, :indeterminate),
46
+ &.mock-hover:not(:checked, :indeterminate) {
41
47
  background-color: var(--token-form-control-base-surface-color-hover);
42
48
  border-color: var(--token-form-control-base-border-color-hover);
43
49
  }
44
50
 
45
51
  &:hover:checked,
46
- &.mock-hover:checked {
52
+ &.mock-hover:checked,
53
+ &:hover:indeterminate,
54
+ &.mock-hover:indeterminate {
47
55
  background-color: var(--token-form-control-checked-border-color-default);
48
56
  border-color: var(--token-form-control-checked-border-color-hover);
49
57
  }
@@ -58,7 +66,7 @@
58
66
 
59
67
  // DISABLED
60
68
 
61
- &:disabled:not(:checked) {
69
+ &:disabled:not(:checked, :indeterminate) {
62
70
  background-color: var(--token-form-control-disabled-surface-color);
63
71
  border-color: var(--token-form-control-disabled-border-color);
64
72
  box-shadow: none;
@@ -72,4 +80,13 @@
72
80
  box-shadow: none;
73
81
  cursor: not-allowed;
74
82
  }
83
+
84
+ &:disabled:indeterminate {
85
+ background-color: var(--token-form-control-disabled-surface-color);
86
+ background-image: var(--token-form-checkbox-background-image-data-url-indeterminate-disabled);
87
+ background-repeat: no-repeat;
88
+ border-color: var(--token-form-control-disabled-border-color);
89
+ box-shadow: none;
90
+ cursor: not-allowed;
91
+ }
75
92
  }
@@ -8,7 +8,7 @@
8
8
  padding: 0;
9
9
  background: var(--token-color-surface-primary);
10
10
  border: none;
11
- border-radius: 10px;
11
+ border-radius: 8px;
12
12
  box-shadow: var(--token-surface-overlay-box-shadow);
13
13
 
14
14
  &[open] {
@@ -16,74 +16,21 @@ $hds-table-cell-padding-tall: 20px 16px;
16
16
 
17
17
  .hds-table {
18
18
  width: 100%;
19
- table-layout: fixed;
20
19
  border: $hds-table-border-width solid $hds-table-border-color;
21
20
  border-radius: $hds-table-border-radius;
22
21
  border-spacing: 0;
23
22
  }
24
23
 
24
+ // TABLE DISPLAY
25
+ .hds-table--layout-fixed {
26
+ table-layout: fixed;
27
+ }
28
+
25
29
  // TABLE HEADER
26
30
  .hds-table__thead {
27
31
  .hds-table__tr {
28
32
  color: var(--token-color-foreground-strong);
29
33
  background-color: var(--token-color-surface-strong);
30
-
31
- .hds-table__th,
32
- .hds-table__th-sort {
33
- height: $hds-table-header-height;
34
- text-align: left;
35
- border-top: none;
36
- border-right: none;
37
- border-bottom: $hds-table-border-width solid $hds-table-border-color;
38
- border-left: none;
39
- }
40
-
41
- .hds-table__th {
42
- padding: $hds-table-cell-padding-medium;
43
- }
44
-
45
- .hds-table__th-sort {
46
- padding: 0;
47
-
48
- button {
49
- width: 100%;
50
- height: 100%;
51
- min-height: $hds-table-header-height;
52
- margin: 0;
53
- padding: $hds-table-cell-padding-medium;
54
- text-align: inherit;
55
- background-color: transparent;
56
- border: 1px solid transparent;
57
- border-radius: inherit;
58
-
59
- .hds-table__th-sort--button-content {
60
- display: flex; // we can't put flex on the button itself so we drop the content into its own container
61
- align-items: center;
62
-
63
- .flight-icon {
64
- flex: none;
65
- margin-left: 8px;
66
- color: var(--token-color-foreground-action);
67
- }
68
- }
69
-
70
- &:hover,
71
- &.mock-hover {
72
- color: var(--token-color-foreground-strong);
73
- background-color: var(--token-color-palette-neutral-200);
74
- cursor: pointer;
75
- }
76
-
77
- @include hds-focus-ring-with-pseudo-element($radius: inherit);
78
-
79
- &:active,
80
- &.mock-active {
81
- color: var(--token-color-foreground-strong);
82
- background-color: var(--token-color-palette-neutral-300);
83
- }
84
- }
85
- }
86
-
87
34
  // BORDER RADIUS: TARGET FIRST AND LAST TH ELEMENTS IN THE ROW
88
35
  &:first-of-type {
89
36
  th:first-child {
@@ -98,6 +45,63 @@ $hds-table-cell-padding-tall: 20px 16px;
98
45
  }
99
46
  }
100
47
 
48
+ .hds-table__th,
49
+ .hds-table__th-sort {
50
+ height: $hds-table-header-height;
51
+ text-align: left;
52
+ border-top: none;
53
+ border-right: none;
54
+ border-bottom: $hds-table-border-width solid $hds-table-border-color;
55
+ border-left: none;
56
+ }
57
+
58
+ .hds-table__th {
59
+ padding: $hds-table-cell-padding-medium;
60
+ }
61
+
62
+ .hds-table__th-sort {
63
+ padding: 0;
64
+
65
+ button {
66
+ width: 100%;
67
+ height: 100%;
68
+ min-height: $hds-table-header-height;
69
+ margin: 0;
70
+ padding: $hds-table-cell-padding-medium;
71
+ text-align: inherit;
72
+ background-color: transparent;
73
+ border: 1px solid transparent;
74
+ border-radius: inherit;
75
+
76
+ .hds-table__th-sort--button-content {
77
+ display: flex; // we can't put flex on the button itself so we drop the content into its own container
78
+ align-items: center;
79
+
80
+ .flight-icon {
81
+ flex: none;
82
+ margin-left: 8px;
83
+ color: var(--token-color-foreground-action);
84
+ }
85
+ }
86
+
87
+ &:hover,
88
+ &.mock-hover {
89
+ color: var(--token-color-foreground-strong);
90
+ background-color: var(--token-color-palette-neutral-200);
91
+ cursor: pointer;
92
+ }
93
+
94
+ @include hds-focus-ring-with-pseudo-element($radius: inherit);
95
+
96
+ &:active,
97
+ &.mock-active {
98
+ color: var(--token-color-foreground-strong);
99
+ background-color: var(--token-color-palette-neutral-300);
100
+ }
101
+ }
102
+ }
103
+
104
+
101
105
  // TABLE BODY
102
106
 
103
107
  // TABLE STRIPING ROWS
@@ -131,21 +135,19 @@ $hds-table-cell-padding-tall: 20px 16px;
131
135
  vertical-align: middle;
132
136
  }
133
137
 
134
- .hds-table--valign-bottom .hds-table__tbody td {
135
- vertical-align: bottom;
136
- }
137
-
138
- .hds-table--valign-baseline .hds-table__tbody td {
139
- vertical-align: baseline;
138
+ // TABLE CELL TEXT ALIGNMENT (LEFT IS DEFAULT)
139
+ .hds-table__th-sort--text-right,
140
+ .hds-table__th--text-right,
141
+ .hds-table__td--text-right {
142
+ text-align: right;
140
143
  }
141
144
 
142
- .hds-table--valign-sub .hds-table__tbody td {
143
- vertical-align: sub;
145
+ .hds-table__th-sort--text-center,
146
+ .hds-table__th--text-center,
147
+ .hds-table__td--text-center {
148
+ text-align: center;
144
149
  }
145
150
 
146
- .hds-table--valign-text-top .hds-table__tbody td {
147
- vertical-align: text-top;
148
- }
149
151
 
150
152
  .hds-table__tbody {
151
153
  .hds-table__tr {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashicorp/design-system-components",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "HashiCorp Design System Components",
5
5
  "keywords": [
6
6
  "hashicorp",
@@ -36,7 +36,7 @@
36
36
  "test:ember:percy": "percy exec ember test"
37
37
  },
38
38
  "dependencies": {
39
- "@hashicorp/design-system-tokens": "^1.2.0",
39
+ "@hashicorp/design-system-tokens": "^1.3.0",
40
40
  "@hashicorp/ember-flight-icons": "^3.0.2",
41
41
  "dialog-polyfill": "^0.5.6",
42
42
  "ember-auto-import": "^2.4.2",
@@ -58,14 +58,14 @@
58
58
  "@embroider/test-setup": "^1.8.3",
59
59
  "@glimmer/component": "^1.1.2",
60
60
  "@glimmer/tracking": "^1.1.2",
61
- "@percy/cli": "^1.13.0",
61
+ "@percy/cli": "^1.16.0",
62
62
  "@percy/ember": "^4.0.0",
63
63
  "babel-eslint": "^10.1.0",
64
64
  "broccoli-asset-rev": "^3.0.0",
65
65
  "ember-a11y-refocus": "^2.1.0",
66
66
  "ember-a11y-testing": "^5.0.0",
67
67
  "ember-cli": "~4.7.0",
68
- "ember-cli-clipboard": "^0.16.0",
68
+ "ember-cli-clipboard": "^1.0.0",
69
69
  "ember-cli-dependency-checker": "^3.3.1",
70
70
  "ember-cli-deprecation-workflow": "^2.1.0",
71
71
  "ember-cli-inject-live-reload": "^2.1.0",