@hashicorp/design-system-components 1.4.1 → 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,15 @@
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
+
3
13
  ## 1.4.1
4
14
 
5
15
  ### Patch 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>
@@ -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
+ }
@@ -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] {
@@ -31,63 +31,6 @@ $hds-table-cell-padding-tall: 20px 16px;
31
31
  .hds-table__tr {
32
32
  color: var(--token-color-foreground-strong);
33
33
  background-color: var(--token-color-surface-strong);
34
-
35
- .hds-table__th,
36
- .hds-table__th-sort {
37
- height: $hds-table-header-height;
38
- text-align: left;
39
- border-top: none;
40
- border-right: none;
41
- border-bottom: $hds-table-border-width solid $hds-table-border-color;
42
- border-left: none;
43
- }
44
-
45
- .hds-table__th {
46
- padding: $hds-table-cell-padding-medium;
47
- }
48
-
49
- .hds-table__th-sort {
50
- padding: 0;
51
-
52
- button {
53
- width: 100%;
54
- height: 100%;
55
- min-height: $hds-table-header-height;
56
- margin: 0;
57
- padding: $hds-table-cell-padding-medium;
58
- text-align: inherit;
59
- background-color: transparent;
60
- border: 1px solid transparent;
61
- border-radius: inherit;
62
-
63
- .hds-table__th-sort--button-content {
64
- display: flex; // we can't put flex on the button itself so we drop the content into its own container
65
- align-items: center;
66
-
67
- .flight-icon {
68
- flex: none;
69
- margin-left: 8px;
70
- color: var(--token-color-foreground-action);
71
- }
72
- }
73
-
74
- &:hover,
75
- &.mock-hover {
76
- color: var(--token-color-foreground-strong);
77
- background-color: var(--token-color-palette-neutral-200);
78
- cursor: pointer;
79
- }
80
-
81
- @include hds-focus-ring-with-pseudo-element($radius: inherit);
82
-
83
- &:active,
84
- &.mock-active {
85
- color: var(--token-color-foreground-strong);
86
- background-color: var(--token-color-palette-neutral-300);
87
- }
88
- }
89
- }
90
-
91
34
  // BORDER RADIUS: TARGET FIRST AND LAST TH ELEMENTS IN THE ROW
92
35
  &:first-of-type {
93
36
  th:first-child {
@@ -102,6 +45,63 @@ $hds-table-cell-padding-tall: 20px 16px;
102
45
  }
103
46
  }
104
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
+
105
105
  // TABLE BODY
106
106
 
107
107
  // TABLE STRIPING ROWS
@@ -135,6 +135,19 @@ $hds-table-cell-padding-tall: 20px 16px;
135
135
  vertical-align: middle;
136
136
  }
137
137
 
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;
143
+ }
144
+
145
+ .hds-table__th-sort--text-center,
146
+ .hds-table__th--text-center,
147
+ .hds-table__td--text-center {
148
+ text-align: center;
149
+ }
150
+
138
151
 
139
152
  .hds-table__tbody {
140
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.1",
3
+ "version": "1.5.0",
4
4
  "description": "HashiCorp Design System Components",
5
5
  "keywords": [
6
6
  "hashicorp",
@@ -65,7 +65,7 @@
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",