@hashicorp/design-system-components 2.5.0 → 2.6.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,16 @@
1
1
  # @hashicorp/design-system-components
2
2
 
3
+ ## 2.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1381](https://github.com/hashicorp/design-system/pull/1381) [`02cdeacd5`](https://github.com/hashicorp/design-system/commit/02cdeacd51d29ed3d19e66cc09b95589becd770b) Thanks [@KristinLBradley](https://github.com/KristinLBradley)! - Add new `Reveal` component
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies []:
12
+ - @hashicorp/ember-flight-icons@3.0.4
13
+
3
14
  ## 2.5.0
4
15
 
5
16
  ### Minor Changes
@@ -9,7 +9,7 @@ import { action } from '@ember/object';
9
9
  import { schedule } from '@ember/runloop';
10
10
 
11
11
  export default class HdsDisclosurePrimitiveComponent extends Component {
12
- @tracked isOpen; // notice: if in the future we need to add a "@isOpen" prop to control the status from outside (eg to have the DisclosurePrimitive opened on render) just add "this.args.isOpen" here to initalize the variable
12
+ @tracked isOpen = this.args.isOpen ?? false;
13
13
 
14
14
  @action
15
15
  onClickToggle() {
@@ -0,0 +1,21 @@
1
+ {{!
2
+ Copyright (c) HashiCorp, Inc.
3
+ SPDX-License-Identifier: MPL-2.0
4
+ }}
5
+
6
+ <Hds::DisclosurePrimitive class="hds-reveal" @isOpen={{@isOpen}} ...attributes>
7
+ <:toggle as |t|>
8
+ <Hds::Reveal::Toggle::Button
9
+ aria-controls={{this.contentId}}
10
+ @text={{if (and t.isOpen @textWhenOpen) @textWhenOpen this.text}}
11
+ @isOpen={{t.isOpen}}
12
+ {{on "click" t.onClickToggle}}
13
+ />
14
+ </:toggle>
15
+
16
+ <:content>
17
+ <div class="hds-reveal__content hds-typography-body-200 hds-foreground-primary" id={{this.contentId}}>
18
+ {{yield}}
19
+ </div>
20
+ </:content>
21
+ </Hds::DisclosurePrimitive>
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import Component from '@glimmer/component';
7
+ import { guidFor } from '@ember/object/internals';
8
+ import { assert } from '@ember/debug';
9
+
10
+ export default class HdsRevealIndexComponent extends Component {
11
+ /**
12
+ * Generates a unique ID for the Content
13
+ *
14
+ * @param contentId
15
+ */
16
+ contentId = 'content-' + guidFor(this);
17
+
18
+ /**
19
+ * @param text
20
+ * @type {string}
21
+ * @description The text of the button.
22
+ */
23
+ get text() {
24
+ let { text } = this.args;
25
+
26
+ assert(
27
+ '@text for "Hds::Reveal" must have a valid value',
28
+ text !== undefined
29
+ );
30
+
31
+ return text;
32
+ }
33
+ }
@@ -0,0 +1,13 @@
1
+ {{!
2
+ Copyright (c) HashiCorp, Inc.
3
+ SPDX-License-Identifier: MPL-2.0
4
+ }}
5
+
6
+ <Hds::Button
7
+ @text={{@text}}
8
+ @color="tertiary"
9
+ @icon="chevron-down"
10
+ aria-expanded={{if @isOpen "true" "false"}}
11
+ class={{this.classNames}}
12
+ ...attributes
13
+ />
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import Component from '@glimmer/component';
7
+
8
+ export default class HdsDropdownToggleButtonComponent extends Component {
9
+ /**
10
+ * Get the class names to apply to the component.
11
+ * @method ToggleButton#classNames
12
+ * @return {string} The "class" attribute to apply to the component.
13
+ */
14
+ get classNames() {
15
+ let classes = ['hds-reveal__toggle-button'];
16
+
17
+ // add a class based on the @isOpen argument
18
+ if (this.args.isOpen) {
19
+ classes.push('hds-reveal__toggle-button--is-open');
20
+ }
21
+
22
+ return classes.join(' ');
23
+ }
24
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ export { default } from '@hashicorp/design-system-components/components/hds/reveal/index';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ export { default } from '@hashicorp/design-system-components/components/hds/reveal/toggle/button';
@@ -32,6 +32,7 @@
32
32
  @use "../components/menu-primitive";
33
33
  @use "../components/modal";
34
34
  @use "../components/pagination";
35
+ @use "../components/reveal";
35
36
  @use "../components/segmented-group";
36
37
  @use "../components/side-nav";
37
38
  @use "../components/stepper";
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ //
7
+ // REVEAL COMPONENT
8
+ //
9
+
10
+ .hds-reveal__toggle-button {
11
+ // overriding some styles of the tertiary button, per design specs
12
+ min-height: 1.75rem; // 28px, Override default so padding difference will be visible
13
+ padding: 0.313rem 0.313rem 0.313rem 0.188rem; // 6px 6px 6px 4px, taking into account the 1px border & icon spacing
14
+
15
+ .flight-icon-chevron-down {
16
+ @media (prefers-reduced-motion: no-preference) {
17
+ transition: transform 0.3s;
18
+ }
19
+ }
20
+ }
21
+
22
+ .hds-reveal__toggle-button--is-open {
23
+ .flight-icon-chevron-down {
24
+ transform: rotate(-180deg);
25
+ }
26
+ }
27
+
28
+ .hds-reveal__content {
29
+ margin-top: 4px;
30
+ }
@@ -35,6 +35,7 @@ module.exports = {
35
35
  updateDummyAppRouter.call(this, options);
36
36
  updateDummyAppCSS.call(this, options);
37
37
  updateDummyAppIndexHBS.call(this, options);
38
+ updatePercyTest.call(this, options);
38
39
  },
39
40
  };
40
41
 
@@ -94,6 +95,23 @@ const updateDummyAppIndexHBS = (options) => {
94
95
  fs.appendFileSync(hbsFilePath, `\n\n${newListItemHTML}\n`);
95
96
  };
96
97
 
98
+ const updatePercyTest = (options) => {
99
+ const name = options.entity.name;
100
+ const percyTestFilePath = `${options.project.root}/tests/acceptance/percy-test.js`;
101
+
102
+ let newSnapshot = ` await visit('/components/${getKebabizedModuleName(
103
+ name
104
+ )}');\n`;
105
+ newSnapshot += ` await percySnapshot('${stringUtil.classify(name)}');\n`;
106
+
107
+ let source = fs.readFileSync(percyTestFilePath, 'utf-8');
108
+ source = source.replace(
109
+ ' // DO NOT REMOVE – PERCY SNAPSHOTS END',
110
+ ` // MOVE THIS BLOCK IN THE RIGHT POSITION\n${newSnapshot}\n // DO NOT REMOVE – PERCY SNAPSHOTS END`
111
+ );
112
+ fs.writeFileSync(percyTestFilePath, source);
113
+ };
114
+
97
115
  const getColumnizedModuleName = (name) => {
98
116
  const columnizedModuleName = name
99
117
  .split('/')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashicorp/design-system-components",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Helios Design System Components",
5
5
  "keywords": [
6
6
  "hashicorp",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@ember/render-modifiers": "^2.0.5",
41
41
  "@hashicorp/design-system-tokens": "^1.5.0",
42
- "@hashicorp/ember-flight-icons": "^3.0.3",
42
+ "@hashicorp/ember-flight-icons": "^3.0.4",
43
43
  "dialog-polyfill": "^0.5.6",
44
44
  "ember-a11y-refocus": "^3.0.2",
45
45
  "ember-auto-import": "^2.6.0",