@hashicorp/design-system-components 0.11.0 → 0.12.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/addon/components/hds/alert/description.hbs +1 -0
  3. package/addon/components/hds/alert/index.hbs +3 -9
  4. package/addon/components/hds/alert/title.hbs +1 -0
  5. package/addon/components/hds/breadcrumb/truncation.hbs +1 -0
  6. package/addon/components/hds/button/index.hbs +14 -2
  7. package/addon/components/hds/button/index.js +0 -21
  8. package/addon/components/hds/disclosure/index.hbs +12 -12
  9. package/addon/components/hds/disclosure/index.js +31 -24
  10. package/addon/components/hds/dropdown/index.hbs +2 -2
  11. package/addon/components/hds/dropdown/list-item/copy-item.hbs +1 -5
  12. package/addon/components/hds/dropdown/list-item/interactive.hbs +19 -41
  13. package/addon/components/hds/dropdown/toggle/button.hbs +1 -0
  14. package/addon/components/hds/dropdown/toggle/icon.hbs +8 -1
  15. package/addon/components/hds/interactive/index.hbs +33 -0
  16. package/addon/components/hds/interactive/index.js +33 -0
  17. package/addon/components/hds/link/inline.hbs +23 -0
  18. package/addon/components/hds/link/inline.js +71 -0
  19. package/addon/components/hds/link/standalone.hbs +15 -5
  20. package/addon/components/hds/link/standalone.js +7 -0
  21. package/addon/components/hds/toast/index.hbs +1 -3
  22. package/app/components/hds/{link-to/standalone.js → alert/description.js} +1 -1
  23. package/app/components/hds/{link-to/cta.js → alert/title.js} +1 -1
  24. package/app/components/hds/interactive/index.js +1 -0
  25. package/app/components/hds/link/{cta.js → inline.js} +1 -1
  26. package/app/styles/@hashicorp/design-system-components.scss +4 -1
  27. package/app/styles/components/alert.scss +17 -4
  28. package/app/styles/components/button.scss +44 -19
  29. package/app/styles/components/dropdown.scss +10 -10
  30. package/app/styles/components/link/inline.scss +66 -0
  31. package/app/styles/components/link/standalone.scss +4 -4
  32. package/app/styles/mixins/_focus-ring.scss +8 -4
  33. package/blueprints/hds-component/files/addon/components/hds/__name__/index.hbs +4 -0
  34. package/blueprints/hds-component/files/addon/components/hds/__name__/index.js +23 -0
  35. package/blueprints/hds-component/files/app/components/hds/__name__/index.js +1 -0
  36. package/blueprints/hds-component/files/app/styles/components/__name__.scss +6 -0
  37. package/blueprints/hds-component/index.js +60 -0
  38. package/blueprints/hds-component-test/files/tests/dummy/app/routes/components/__name__.js +3 -0
  39. package/blueprints/hds-component-test/files/tests/dummy/app/styles/pages/__dummyCSSFileName__.scss +1 -0
  40. package/blueprints/hds-component-test/files/tests/dummy/app/templates/components/__name__.hbs +65 -0
  41. package/blueprints/hds-component-test/files/tests/integration/components/hds/__name__/index-test.js +17 -0
  42. package/blueprints/hds-component-test/index.js +126 -0
  43. package/package.json +4 -4
  44. package/addon/components/hds/link/cta.hbs +0 -50
  45. package/addon/components/hds/link/cta.js +0 -150
  46. package/addon/components/hds/link-to/cta.hbs +0 -51
  47. package/addon/components/hds/link-to/cta.js +0 -165
  48. package/addon/components/hds/link-to/standalone.hbs +0 -25
  49. package/addon/components/hds/link-to/standalone.js +0 -151
  50. package/app/styles/components/link/cta.scss +0 -28
@@ -0,0 +1,126 @@
1
+ /* eslint-disable ember/no-string-prototype-extensions */
2
+ /* eslint-disable node/no-extraneous-require */
3
+ 'use strict';
4
+
5
+ const stringUtil = require('ember-cli-string-utils');
6
+ const EmberRouterGenerator = require('ember-router-generator');
7
+ const fs = require('fs');
8
+
9
+ module.exports = {
10
+ description: 'Generates tests for an HDS component',
11
+
12
+ locals(options) {
13
+ return {
14
+ columnizedModuleName: getColumnizedModuleName(options.entity.name),
15
+ kebabizedModuleName: getKebabizedModuleName(options.entity.name),
16
+ folderizedModuleName: getFolderizedModuleName(options.entity.name),
17
+ };
18
+ },
19
+
20
+ fileMapTokens() {
21
+ return {
22
+ // prepend `db-` to the file name
23
+ __dummyCSSFileName__(options) {
24
+ return getDummyCSSFileName(options.dasherizedModuleName);
25
+ },
26
+ };
27
+ },
28
+
29
+ afterInstall(options) {
30
+ updateDummyAppRouter.call(this, options);
31
+ updateDummyAppCSS.call(this, options);
32
+ updateDummyAppIndexHBS.call(this, options);
33
+ },
34
+ };
35
+
36
+ const updateDummyAppRouter = (options) => {
37
+ const newRouteToAdd = `components/${options.entity.name}`; // we prefix all the component routes with "components"
38
+ const routerFilePath = `${options.project.root}/tests/dummy/app/router.js`;
39
+ const source = fs.readFileSync(routerFilePath, 'utf-8');
40
+ let oldRoutes = new EmberRouterGenerator(source);
41
+ let newRoutes = oldRoutes['add'](newRouteToAdd, options);
42
+ fs.writeFileSync(routerFilePath, newRoutes.code());
43
+ };
44
+
45
+ const updateDummyAppCSS = (options) => {
46
+ const name = options.entity.name;
47
+ const cssFilePath = `${options.project.root}/tests/dummy/app/styles/app.scss`;
48
+ const source = fs.readFileSync(cssFilePath, 'utf-8');
49
+ const oldLinesArray = source.split(/\r?\n/);
50
+ const firstComponentImportIndex =
51
+ oldLinesArray.findIndex((line) =>
52
+ line.match(/^\/\/ START COMPONENT PAGES IMPORTS/)
53
+ ) + 1;
54
+ const lastComponentImportIndex =
55
+ oldLinesArray.findIndex((line) =>
56
+ line.match(/^\/\/ END COMPONENT PAGES IMPORTS/)
57
+ ) - 1;
58
+ const importLinesArray = oldLinesArray.slice(
59
+ firstComponentImportIndex,
60
+ lastComponentImportIndex + 1
61
+ );
62
+ importLinesArray.push(`@import "./pages/${getDummyCSSFileName(name)}";`);
63
+ const newImportLinesArray = importLinesArray
64
+ .filter((line, index, self) => self.indexOf(line) === index)
65
+ .sort();
66
+ const newLinesArray = [].concat(
67
+ oldLinesArray.slice(0, firstComponentImportIndex),
68
+ newImportLinesArray,
69
+ oldLinesArray.slice(lastComponentImportIndex + 1)
70
+ );
71
+ fs.writeFileSync(cssFilePath, newLinesArray.join('\n'));
72
+ };
73
+
74
+ const updateDummyAppIndexHBS = (options) => {
75
+ const name = options.entity.name;
76
+ const hbsFilePath = `${options.project.root}/tests/dummy/app/templates/index.hbs`;
77
+ let newListItemHTML = '';
78
+ newListItemHTML += '<!-- MOVE THIS HTML BLOCK IN THE RIGHT POSITION -->\n';
79
+ newListItemHTML += '<!-- (adjust component name & route if necessary) -->\n';
80
+ newListItemHTML += '<li class="dummy-paragraph">\n';
81
+ newListItemHTML += ` <LinkTo @route="components.${getRoutedModuleName(
82
+ name
83
+ )}">\n`;
84
+ newListItemHTML += ` ${getColumnizedModuleName(name)}\n`;
85
+ newListItemHTML += ' </LinkTo>\n';
86
+ newListItemHTML += '</li>\n';
87
+ fs.appendFileSync(hbsFilePath, `\n\n${newListItemHTML}\n`);
88
+ };
89
+
90
+ const getColumnizedModuleName = (name) => {
91
+ const columnizedModuleName = name
92
+ .split('/')
93
+ .map((part) => stringUtil.classify(part))
94
+ .join('::');
95
+ return columnizedModuleName;
96
+ };
97
+
98
+ const getKebabizedModuleName = (name) => {
99
+ const kebabizedModuleName = name
100
+ .split('/')
101
+ .map((part) => stringUtil.dasherize(part))
102
+ .join('-');
103
+ return kebabizedModuleName;
104
+ };
105
+
106
+ const getFolderizedModuleName = (name) => {
107
+ const folderizedModuleName = name
108
+ .split('/')
109
+ .map((part) => stringUtil.dasherize(part).toUpperCase())
110
+ .join(' > ');
111
+ return folderizedModuleName;
112
+ };
113
+
114
+ const getRoutedModuleName = (name) => {
115
+ const routedModuleName = name
116
+ .split('/')
117
+ .map((part) => stringUtil.dasherize(part))
118
+ .join('.');
119
+ return routedModuleName;
120
+ };
121
+
122
+ const getDummyCSSFileName = (name) => {
123
+ const parts = name.split('/');
124
+ const fileName = `db-${parts.pop()}`;
125
+ return `${parts.concat([fileName]).join('/')}`;
126
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashicorp/design-system-components",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "HashiCorp Design System Components",
5
5
  "keywords": [
6
6
  "hashicorp",
@@ -40,10 +40,10 @@
40
40
  "ember-cli-babel": "^7.26.11",
41
41
  "ember-cli-htmlbars": "^6.0.1",
42
42
  "ember-cli-sass": "^10.0.1",
43
- "ember-focus-trap": "^1.0.1",
44
43
  "ember-keyboard": "^8.1.0",
45
44
  "ember-named-blocks-polyfill": "^0.2.5",
46
- "sass": "^1.43.4"
45
+ "sass": "^1.43.4",
46
+ "sinon": "^14.0.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@ember/optional-features": "^2.0.0",
@@ -51,7 +51,7 @@
51
51
  "@embroider/test-setup": "^1.5.0",
52
52
  "@glimmer/component": "^1.0.4",
53
53
  "@glimmer/tracking": "^1.0.4",
54
- "@percy/cli": "^1.0.1",
54
+ "@percy/cli": "^1.2.1",
55
55
  "@percy/ember": "^3.0.0",
56
56
  "babel-eslint": "^10.1.0",
57
57
  "broccoli-asset-rev": "^3.0.0",
@@ -1,50 +0,0 @@
1
- {{!
2
- // ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
3
- // ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
4
- // ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
5
- // ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
6
- // ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
7
- //
8
- // Notice: in this component we're using directly the styles from the `Hds::Button` component
9
- // using the `hds-button` class names (and adding a specialized class for the "cta", see below)
10
- // If you need to change the styling of the `Button` component, remember that this will impact also
11
- // this component too.
12
- // If instead you need to change only the styling of the `CTA` component, you can do it
13
- // in the CSS file using the specialized class declared there.
14
- // This is NOT a standard approach that we use in the HDS design system implementation, but it's been
15
- // the least worst option we could find to solve the problem of sharing the exact same style of the
16
- // `Button (primary)` with other components.
17
- }}
18
-
19
- {{! template-lint-disable link-href-attributes }}
20
- {{! we can disable this linting rule because the developer will add the html attribute themselves }}
21
- <a
22
- class={{this.classNames}}
23
- target="_blank"
24
- rel="noopener noreferrer"
25
- ...attributes
26
- {{did-insert this.didInsert}}
27
- {{on-key "Space" this.onKeySpace}}
28
- >
29
- {{#if this.icon}}
30
- {{#if (eq this.iconPosition "leading")}}
31
- <div class="hds-button__icon">
32
- <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
33
- </div>
34
- <div class="hds-button__text">
35
- {{this.text}}
36
- </div>
37
- {{else}}
38
- <div class="hds-button__text">
39
- {{this.text}}
40
- </div>
41
- <div class="hds-button__icon">
42
- <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
43
- </div>
44
- {{/if}}
45
- {{else}}
46
- <div class="hds-button__text">
47
- {{this.text}}
48
- </div>
49
- {{/if}}
50
- </a>
@@ -1,150 +0,0 @@
1
- // ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
2
- // ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
3
- // ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
4
- // ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
5
- // ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
6
- //
7
- // Notice: in this component we're using directly the styles from the `Hds::Button` component
8
- // using the `hds-button` class names (and adding a specialized class for the "cta", see below)
9
- // If you need to change the styling of the `Button` component, remember that this will impact also
10
- // this component too.
11
- // If instead you need to change only the styling of the `CTA` component, you can do it
12
- // in the CSS file using the specialized class declared there.
13
- // This is NOT a standard approach that we use in the HDS design system implementation, but it's been
14
- // the least worst option we could find to solve the problem of sharing the exact same style of the
15
- // `Button (primary)` with other components.
16
-
17
- import Component from '@glimmer/component';
18
- import { assert } from '@ember/debug';
19
- import { action } from '@ember/object';
20
-
21
- export const DEFAULT_SIZE = 'medium';
22
- export const DEFAULT_ICONPOSITION = 'leading';
23
- export const SIZES = ['small', 'medium', 'large'];
24
- export const ICONPOSITIONS = ['leading', 'trailing'];
25
-
26
- export default class HdsLinkCtaComponent extends Component {
27
- /**
28
- * @param text
29
- * @type {string}
30
- * @description The text of the component. If no text value is defined an error will be thrown.
31
- */
32
- get text() {
33
- let { text } = this.args;
34
-
35
- assert(
36
- '@text for "Hds::Link::Cta" must have a valid value',
37
- text !== undefined
38
- );
39
-
40
- return text;
41
- }
42
-
43
- /**
44
- * @param size
45
- * @type {string}
46
- * @default medium
47
- * @description The size of the component; acceptable values are `small`, `medium`, and `large`
48
- */
49
- get size() {
50
- let { size = DEFAULT_SIZE } = this.args;
51
-
52
- assert(
53
- `@size for "Hds::Link::Cta" must be one of the following: ${SIZES.join(
54
- ', '
55
- )}; received: ${size}`,
56
- SIZES.includes(size)
57
- );
58
-
59
- return size;
60
- }
61
-
62
- /**
63
- * @param icon
64
- * @type {string}
65
- * @default null
66
- * @description The name of the icon to be used.
67
- */
68
- get icon() {
69
- return this.args.icon ?? null;
70
- }
71
-
72
- /**
73
- * @param iconPosition
74
- * @type {string}
75
- * @default leading
76
- * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
77
- */
78
- get iconPosition() {
79
- let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
80
-
81
- assert(
82
- `@iconPosition for "Hds::Link::Cta" must be one of the following: ${ICONPOSITIONS.join(
83
- ', '
84
- )}; received: ${iconPosition}`,
85
- ICONPOSITIONS.includes(iconPosition)
86
- );
87
-
88
- return iconPosition;
89
- }
90
-
91
- /**
92
- * @param iconSize
93
- * @type {string}
94
- * @default 16
95
- * @description ensures that the correct icon size is used. Automatically calculated.
96
- */
97
- get iconSize() {
98
- if (this.args.size === 'large') {
99
- return '24';
100
- } else {
101
- return '16';
102
- }
103
- }
104
-
105
- /**
106
- * @param isFullWidth
107
- * @type {boolean}
108
- * @default false
109
- * @description Indicates that the component should take up the full width of the parent container. The default is false.
110
- */
111
- get isFullWidth() {
112
- return this.args.isFullWidth ?? false;
113
- }
114
-
115
- /**
116
- * Get the class names to apply to the component.
117
- * @method classNames
118
- * @return {string} The "class" attribute to apply to the component.
119
- */
120
- get classNames() {
121
- let classes = [
122
- 'hds-button',
123
- 'hds-button--color-primary',
124
- 'hds-link-cta--inherit-button-styles',
125
- ];
126
-
127
- // add a class based on the @size argument
128
- classes.push(`hds-button--size-${this.size}`);
129
-
130
- // add a class based on the @isFullWidth argument
131
- if (this.isFullWidth) {
132
- classes.push('hds-button--width-full');
133
- }
134
-
135
- return classes.join(' ');
136
- }
137
-
138
- @action
139
- didInsert(el) {
140
- // we need to register the element to compare it with the one that triggered the "key/space" event
141
- this.el = el;
142
- }
143
-
144
- @action
145
- onKeySpace(event) {
146
- if (event.target === this.el) {
147
- event.target.click();
148
- }
149
- }
150
- }
@@ -1,51 +0,0 @@
1
- {{!
2
- // ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
3
- // ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
4
- // ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
5
- // ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
6
- // ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
7
- //
8
- // Notice: in this component we're using directly the styles from the `Hds::Button` component
9
- // using the `hds-button` class names (and adding a specialized class for the "cta", see below)
10
- // If you need to change the styling of the `Button` component, remember that this will impact also
11
- // this component too.
12
- // If instead you need to change only the styling of the `CTA` component, you can do it
13
- // in the CSS file using the specialized class declared there.
14
- // This is NOT a standard approach that we use in the HDS design system implementation, but it's been
15
- // the least worst option we could find to solve the problem of sharing the exact same style of the
16
- // `Button (primary)` with other components.
17
- }}
18
-
19
- <LinkTo
20
- class={{this.classNames}}
21
- @current-when={{@current-when}}
22
- @models={{hds-link-to-models @model @models}}
23
- @query={{hds-link-to-query @query}}
24
- @replace={{@replace}}
25
- @route={{this.route}}
26
- ...attributes
27
- {{did-insert this.didInsert}}
28
- {{on-key "Space" this.onKeySpace}}
29
- >
30
- {{#if this.icon}}
31
- {{#if (eq this.iconPosition "leading")}}
32
- <div class="hds-button__icon">
33
- <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
34
- </div>
35
- <div class="hds-button__text">
36
- {{this.text}}
37
- </div>
38
- {{else}}
39
- <div class="hds-button__text">
40
- {{this.text}}
41
- </div>
42
- <div class="hds-button__icon">
43
- <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
44
- </div>
45
- {{/if}}
46
- {{else}}
47
- <div class="hds-button__text">
48
- {{this.text}}
49
- </div>
50
- {{/if}}
51
- </LinkTo>
@@ -1,165 +0,0 @@
1
- // ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
2
- // ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
3
- // ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
4
- // ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
5
- // ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
6
- //
7
- // Notice: in this component we're using directly the styles from the `Hds::Button` component
8
- // using the `hds-button` class names (and adding a specialized class for the "cta", see below)
9
- // If you need to change the styling of the `Button` component, remember that this will impact also
10
- // this component too.
11
- // If instead you need to change only the styling of the `CTA` component, you can do it
12
- // in the CSS file using the specialized class declared there.
13
- // This is NOT a standard approach that we use in the HDS design system implementation, but it's been
14
- // the least worst option we could find to solve the problem of sharing the exact same style of the
15
- // `Button (primary)` with other components.
16
-
17
- import Component from '@glimmer/component';
18
- import { assert } from '@ember/debug';
19
- import { action } from '@ember/object';
20
-
21
- export const DEFAULT_SIZE = 'medium';
22
- export const DEFAULT_ICONPOSITION = 'leading';
23
- export const SIZES = ['small', 'medium', 'large'];
24
- export const ICONPOSITIONS = ['leading', 'trailing'];
25
-
26
- export default class HdsLinkToCtaComponent extends Component {
27
- /**
28
- * @param text
29
- * @type {string}
30
- * @description The text of the component. If no text value is defined an error will be thrown.
31
- */
32
- get text() {
33
- let { text } = this.args;
34
-
35
- assert(
36
- '@text for "Hds::LinkTo::Cta" must have a valid value',
37
- text !== undefined
38
- );
39
-
40
- return text;
41
- }
42
-
43
- /**
44
- * @param size
45
- * @type {string}
46
- * @default medium
47
- * @description The size of the component; acceptable values are `small`, `medium`, and `large`
48
- */
49
- get size() {
50
- let { size = DEFAULT_SIZE } = this.args;
51
-
52
- assert(
53
- `@size for "Hds::LinkTo::Cta" must be one of the following: ${SIZES.join(
54
- ', '
55
- )}; received: ${size}`,
56
- SIZES.includes(size)
57
- );
58
-
59
- return size;
60
- }
61
-
62
- /**
63
- * @param icon
64
- * @type {string}
65
- * @default null
66
- * @description The name of the icon to be used.
67
- */
68
- get icon() {
69
- return this.args.icon ?? null;
70
- }
71
-
72
- /**
73
- * @param iconPosition
74
- * @type {string}
75
- * @default leading
76
- * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
77
- */
78
- get iconPosition() {
79
- let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
80
-
81
- assert(
82
- `@iconPosition for "Hds::LinkTo::Cta" must be one of the following: ${ICONPOSITIONS.join(
83
- ', '
84
- )}; received: ${iconPosition}`,
85
- ICONPOSITIONS.includes(iconPosition)
86
- );
87
-
88
- return iconPosition;
89
- }
90
-
91
- /**
92
- * @param iconSize
93
- * @type {string}
94
- * @default 16
95
- * @description ensures that the correct icon size is used. Automatically calculated.
96
- */
97
- get iconSize() {
98
- if (this.args.size === 'large') {
99
- return '24';
100
- } else {
101
- return '16';
102
- }
103
- }
104
-
105
- /**
106
- * @param isFullWidth
107
- * @type {boolean}
108
- * @default false
109
- * @description Indicates that the component should take up the full width of the parent container. The default is false.
110
- */
111
- get isFullWidth() {
112
- return this.args.isFullWidth ?? false;
113
- }
114
-
115
- /**
116
- * @param route
117
- * @type {string|null}
118
- * @description Checks to make sure route is defined.
119
- */
120
- get route() {
121
- let { route } = this.args;
122
- assert(
123
- '@route must be defined for "Hds::LinkTo::Cta"',
124
- route !== undefined
125
- );
126
-
127
- return route;
128
- }
129
-
130
- /**
131
- * Get the class names to apply to the component.
132
- * @method classNames
133
- * @return {string} The "class" attribute to apply to the component.
134
- */
135
- get classNames() {
136
- let classes = [
137
- 'hds-button',
138
- 'hds-button--color-primary',
139
- 'hds-link-cta--inherit-button-styles',
140
- ];
141
-
142
- // add a class based on the @size argument
143
- classes.push(`hds-button--size-${this.size}`);
144
-
145
- // add a class based on the @isFullWidth argument
146
- if (this.isFullWidth) {
147
- classes.push('hds-button--width-full');
148
- }
149
-
150
- return classes.join(' ');
151
- }
152
-
153
- @action
154
- didInsert(el) {
155
- // we need to register the element to compare it with the one that triggered the "key/space" event
156
- this.el = el;
157
- }
158
-
159
- @action
160
- onKeySpace(event) {
161
- if (event.target === this.el) {
162
- event.target.click();
163
- }
164
- }
165
- }
@@ -1,25 +0,0 @@
1
- <LinkTo
2
- class={{this.classNames}}
3
- @current-when={{@current-when}}
4
- @models={{hds-link-to-models @model @models}}
5
- @query={{hds-link-to-query @query}}
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>