@hashicorp/design-system-components 0.0.8 → 0.0.9
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/.github/workflows/ci.yml +2 -2
- package/RELEASE.md +69 -0
- package/addon/components/hds/badge/index.hbs +8 -6
- package/addon/components/hds/badge/index.js +29 -0
- package/addon/components/hds/button/index.hbs +1 -1
- package/addon/components/hds/button/index.js +14 -3
- package/addon/components/hds/icon-tile/index.hbs +1 -1
- package/app/styles/components/button.scss +21 -13
- package/app/styles/components/icon-tile.scss +1 -1
- package/package.json +9 -3
package/.github/workflows/ci.yml
CHANGED
package/RELEASE.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# How To Release
|
|
2
|
+
|
|
3
|
+
Whenever there is an update to the components, and these changes have been approved, we need to release them as package to the npm registry.
|
|
4
|
+
|
|
5
|
+
Please see the instructions in the [CONTRIBUTING](CONTRIBUTING.md) file for more details about how to setup the project and make changes to the code for these packages.
|
|
6
|
+
|
|
7
|
+
## Bump
|
|
8
|
+
|
|
9
|
+
The "bump" step increases the _SemVer_ version number in the `package.json` file.
|
|
10
|
+
|
|
11
|
+
* Make sure your local `main` branch is up to date.
|
|
12
|
+
* Create new custom branch from `main`.
|
|
13
|
+
* `cd /design-system-components`
|
|
14
|
+
* Run `yarn bump` and choose the _SemVer_ version as agreed upon on the previous PR.
|
|
15
|
+
* _The `bump` command is interactive, you can move up and down with the keyboard, choose one option, and then hit "enter": the tool will automatically update the version in the `package.json` file for you._
|
|
16
|
+
* Check the `git diff` for the project, you should see only the `package.json` file changed (with the new version).
|
|
17
|
+
* Commit, push, open a pull request, and wait for approval.
|
|
18
|
+
|
|
19
|
+
Once the PR has been approved and merged, you can finally move to the next step, the actual release.
|
|
20
|
+
|
|
21
|
+
## Release
|
|
22
|
+
|
|
23
|
+
The "release" step publishes the package on the npm registry, using the version declared in the `package.json` file, and [tags](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-tag) that specific release on git.
|
|
24
|
+
|
|
25
|
+
_**IMPORTANT**: Once released a package on the public registry, you can't revert the changes: the only solution is to deprecate the package (this will hide it from the public, but remains there). If you need to do some tests, use a **local** package registry (see below), don't test directly in production!_
|
|
26
|
+
|
|
27
|
+
* Make sure your local `main` branch is up to date.
|
|
28
|
+
* You will need a company-approved 2FA-enabled account on npm to publish (see [npm 2FA docs](https://docs.npmjs.com/configuring-two-factor-authentication) for more info).
|
|
29
|
+
* `cd /design-system-components`
|
|
30
|
+
* `yarn release`
|
|
31
|
+
* Check the git diff, you should not see any change.
|
|
32
|
+
|
|
33
|
+
**Notice**: this action will automatically:
|
|
34
|
+
|
|
35
|
+
* publish the new version of the package on the [NPM registry](https://www.npmjs.com/) using the current _SemVer_ version declared in the `package.json` file (the one previously chosen in the `bump` step).
|
|
36
|
+
* tag the current last commit in the `main` branch and push the tag to the git origin
|
|
37
|
+
|
|
38
|
+
At this point check on npm that the package ([@hashicorp/design-system-components](https://www.npmjs.com/package/@hashicorp/design-system-components) has been successfully published, and if it's so... well done! You just published your new package 🎉.
|
|
39
|
+
|
|
40
|
+
🚨 **DON'T FORGET**:
|
|
41
|
+
|
|
42
|
+
You need to communicate to the product teams that are consuming the components!
|
|
43
|
+
|
|
44
|
+
## Using a local NPM registry for testing
|
|
45
|
+
|
|
46
|
+
To test the release of packages without actually polluting the real/production npm registry, you can setup a local private registry using [Verdaccio](https://verdaccio.org/docs/what-is-verdaccio), an open source solution, very easy to setup and use.
|
|
47
|
+
|
|
48
|
+
You can follow [the instructions here](https://verdaccio.org/docs/installation), but essentially here is what you have to:
|
|
49
|
+
|
|
50
|
+
* install the package: `npm install -g verdaccio` - this will install it globally
|
|
51
|
+
* launch the service: `verdaccio` - this will serve a web frontend to the registry at the URL [http://localhost:4873/](http://localhost:4873/)
|
|
52
|
+
* add a user to the registry: `npm adduser --registry http://localhost:4873` - this will ask you for a username/password/email, I suggest you use test/test/test@test.com because is only a local instance. This will also authenticate you with the registry so you don't need to login when you publish.
|
|
53
|
+
|
|
54
|
+
Now you need to add this entry in the `package.json` file of the bundle you want to publish on your local registry:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"registry": "http://localhost:4873"
|
|
59
|
+
},
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This will make sure the package is published on Verdaccio. Once the package is published, the web page will be available at at [http://localhost:4873/](http://localhost:4873/). It will show you all the packages' details, and if needed you can download the tarballs to check their content.
|
|
63
|
+
|
|
64
|
+
Once you've completed testing the package locally:
|
|
65
|
+
|
|
66
|
+
1. remove verdaccio via `npm uninstall -g verdaccio`
|
|
67
|
+
2. remove the files it created with `rm -fr ~/.local/share/verdaccio && rm -fr .config/verdaccio`
|
|
68
|
+
|
|
69
|
+
This same command can be used to cleanup the entire data storage of Verdaccio and start from scratch (no need to reinstall, only cleanup the data).
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div
|
|
2
|
+
class="hds-badge {{this.sizeClass}} {{this.typeClass}} {{this.colorClass}}"
|
|
3
|
+
...attributes>
|
|
2
4
|
{{#if @icon}}
|
|
3
5
|
<div class="hds-badge__icon">
|
|
4
6
|
<FlightIcon @name={{this.icon}} @size="16" @stretched="true" />
|
|
5
7
|
</div>
|
|
6
8
|
{{/if}}
|
|
7
|
-
{{#if
|
|
8
|
-
<
|
|
9
|
-
{{@text}}
|
|
10
|
-
</div>
|
|
9
|
+
{{#if this.isIconOnly}}
|
|
10
|
+
<span class="sr-only">{{this.text}}</span>
|
|
11
11
|
{{else}}
|
|
12
|
-
<
|
|
12
|
+
<div class="hds-badge__text">
|
|
13
|
+
{{this.text}}
|
|
14
|
+
</div>
|
|
13
15
|
{{/if}}
|
|
14
16
|
</div>
|
|
@@ -106,6 +106,22 @@ export default class HdsBadgeIndexComponent extends Component {
|
|
|
106
106
|
return `hds-badge--color-${this.color}`;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* @param text
|
|
111
|
+
* @type {string}
|
|
112
|
+
* @description The text of the badge. If `isIconOnly` is set to `true`, the text will be visually hidden but still available to assistive technology. If no text value is defined, an error will be thrown.
|
|
113
|
+
*/
|
|
114
|
+
get text() {
|
|
115
|
+
let { text } = this.args;
|
|
116
|
+
|
|
117
|
+
assert(
|
|
118
|
+
'@text for "Hds::Badge" must have a valid value',
|
|
119
|
+
text !== undefined
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
return text;
|
|
123
|
+
}
|
|
124
|
+
|
|
109
125
|
/**
|
|
110
126
|
* Sets the icon name if there is one
|
|
111
127
|
*
|
|
@@ -116,4 +132,17 @@ export default class HdsBadgeIndexComponent extends Component {
|
|
|
116
132
|
get icon() {
|
|
117
133
|
return this.args.icon ?? null;
|
|
118
134
|
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @param isIconOnly
|
|
138
|
+
* @type {boolean}
|
|
139
|
+
* @default false
|
|
140
|
+
* @description Indicates if the badge will only contain an icon; component will also ensure that accessible text is still applied to the component.
|
|
141
|
+
*/
|
|
142
|
+
get isIconOnly() {
|
|
143
|
+
if (this.icon) {
|
|
144
|
+
return this.args.isIconOnly ?? false;
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
119
148
|
}
|
|
@@ -4,9 +4,11 @@ import { assert } from '@ember/debug';
|
|
|
4
4
|
export const DEFAULT_SIZE = 'medium';
|
|
5
5
|
export const DEFAULT_COLOR = 'primary';
|
|
6
6
|
export const DEFAULT_TYPE = 'button';
|
|
7
|
+
export const DEFAULT_ICONPOSITION = 'leading';
|
|
7
8
|
export const SIZES = ['small', 'medium', 'large'];
|
|
8
9
|
export const COLORS = ['primary', 'secondary', 'destructive'];
|
|
9
10
|
export const TYPES = ['button', 'submit', 'reset'];
|
|
11
|
+
export const ICONPOSITIONS = ['leading', 'trailing'];
|
|
10
12
|
|
|
11
13
|
export default class HdsButtonIndexComponent extends Component {
|
|
12
14
|
/**
|
|
@@ -107,13 +109,22 @@ export default class HdsButtonIndexComponent extends Component {
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
/**
|
|
110
|
-
* @param
|
|
112
|
+
* @param iconPosition
|
|
111
113
|
* @type {string}
|
|
112
114
|
* @default leading
|
|
113
115
|
* @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
|
|
114
116
|
*/
|
|
115
|
-
get
|
|
116
|
-
|
|
117
|
+
get iconPosition() {
|
|
118
|
+
let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
|
|
119
|
+
|
|
120
|
+
assert(
|
|
121
|
+
`@iconPosition for "Hds::Button" must be one of the following: ${ICONPOSITIONS.join(
|
|
122
|
+
', '
|
|
123
|
+
)}; received: ${iconPosition}`,
|
|
124
|
+
ICONPOSITIONS.includes(iconPosition)
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
return iconPosition;
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div class="hds-icon-tile {{this.entityClass}} {{this.sizeClass}} {{this.colorClass}}" ...attributes>
|
|
1
|
+
<div class="hds-icon-tile {{this.entityClass}} {{this.sizeClass}} {{this.colorClass}}" aria-hidden="true" ...attributes>
|
|
2
2
|
{{#if @icon}}
|
|
3
3
|
<div class="hds-icon-tile__icon">
|
|
4
4
|
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched="true" />
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Button Component Styles
|
|
2
2
|
|
|
3
|
-
$border-radius: 5px;
|
|
3
|
+
$hds-button-border-radius: 5px;
|
|
4
|
+
$hds-button-border-width: 1px;
|
|
5
|
+
$hds-button-focus-border-width: 3px;
|
|
4
6
|
|
|
5
7
|
// TODO! generalize with the existing mixin in Card component
|
|
6
8
|
@mixin tempElevation() {
|
|
@@ -22,8 +24,8 @@ $border-radius: 5px;
|
|
|
22
24
|
@include tempElevation();
|
|
23
25
|
|
|
24
26
|
align-items: center;
|
|
25
|
-
border:
|
|
26
|
-
border-radius: $border-radius;
|
|
27
|
+
border: $hds-button-border-width solid transparent; // We need this to be transparent for a11y
|
|
28
|
+
border-radius: $hds-button-border-radius;
|
|
27
29
|
box-sizing: border-box; // TODO https://github.com/hashicorp/design-system-components/issues/46
|
|
28
30
|
display: flex;
|
|
29
31
|
font-family: var(--token-typography-body-base-font-family);
|
|
@@ -71,15 +73,17 @@ $border-radius: 5px;
|
|
|
71
73
|
&:focus,
|
|
72
74
|
&:focus-visible {
|
|
73
75
|
&::before {
|
|
74
|
-
border
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
// the position absolute is computed from the inside of the border, so we have to take in account the border width
|
|
77
|
+
$shift: $hds-button-border-width + $hds-button-focus-border-width;
|
|
78
|
+
border-radius: $hds-button-border-radius + $hds-button-focus-border-width;
|
|
79
|
+
border: $hds-button-focus-border-width solid transparent;
|
|
80
|
+
bottom: -$shift;
|
|
77
81
|
box-sizing: border-box;
|
|
78
82
|
content: '';
|
|
79
|
-
left:
|
|
83
|
+
left: -$shift;
|
|
80
84
|
position: absolute;
|
|
81
|
-
right:
|
|
82
|
-
top:
|
|
85
|
+
right: -$shift;
|
|
86
|
+
top: -$shift;
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
}
|
|
@@ -148,11 +152,15 @@ $border-radius: 5px;
|
|
|
148
152
|
border-color: var(--token-color-action-border-on-primary);
|
|
149
153
|
color: var(--token-color-palette-neutral-0);
|
|
150
154
|
&::before {
|
|
155
|
+
// the position absolute is computed from the inside of the border, so we have to take in account the border width
|
|
156
|
+
// plus for the primary button we want to have a 2px gap between the button and the focus
|
|
157
|
+
$shift: $hds-button-border-width + $hds-button-focus-border-width + 2px;
|
|
158
|
+
border-radius: $hds-button-border-radius + $hds-button-focus-border-width + 2px;
|
|
151
159
|
border-color: var(--token-color-action-background-primary);
|
|
152
|
-
bottom:
|
|
153
|
-
left:
|
|
154
|
-
right:
|
|
155
|
-
top:
|
|
160
|
+
bottom: -$shift;
|
|
161
|
+
left: -$shift;
|
|
162
|
+
right: -$shift;
|
|
163
|
+
top: -$shift;
|
|
156
164
|
}
|
|
157
165
|
}
|
|
158
166
|
&:hover,
|
|
@@ -140,7 +140,7 @@ $size-props: (
|
|
|
140
140
|
&.hds-icon-tile--color-#{$product} {
|
|
141
141
|
background: linear-gradient(135deg, var(--token-color-#{$product}-gradient-faint-start) 0%, var(--token-color-#{$product}-gradient-faint-stop) 100%);
|
|
142
142
|
border-color: var(--token-color-#{$product}-border);
|
|
143
|
-
color: var(--token-color-#{$product}-
|
|
143
|
+
color: var(--token-color-#{$product}-foreground);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashicorp/design-system-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "HashiCorp Design System Components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hashicorp",
|
|
@@ -53,11 +53,16 @@
|
|
|
53
53
|
"test": "npm-run-all lint test:*",
|
|
54
54
|
"test:ember": "ember test",
|
|
55
55
|
"test:ember-compatibility": "ember try:each",
|
|
56
|
-
"test:ember:percy": "percy exec ember test"
|
|
56
|
+
"test:ember:percy": "percy exec ember test",
|
|
57
|
+
"bump": "./node_modules/.bin/bump package.json",
|
|
58
|
+
"release": "yarn publish --new-version $npm_package_version",
|
|
59
|
+
"postrelease:git-tag": "TAG_VERSION=\"${npm_package_name}/${npm_package_version}\" && git tag $TAG_VERSION && git push origin $TAG_VERSION",
|
|
60
|
+
"postrelease": "yarn postrelease:git-tag"
|
|
57
61
|
},
|
|
58
62
|
"dependencies": {
|
|
59
63
|
"@hashicorp/design-system-tokens": "^0.0.13",
|
|
60
|
-
"@hashicorp/ember-flight-icons": "^1.2.
|
|
64
|
+
"@hashicorp/ember-flight-icons": "^1.2.1",
|
|
65
|
+
"@hashicorp/flight-icons": "^1.3.0",
|
|
61
66
|
"ember-cli-babel": "^7.26.6",
|
|
62
67
|
"ember-cli-htmlbars": "^5.7.1",
|
|
63
68
|
"ember-cli-sass": "^10.0.1",
|
|
@@ -103,6 +108,7 @@
|
|
|
103
108
|
"prettier": "^2.3.0",
|
|
104
109
|
"qunit": "^2.15.0",
|
|
105
110
|
"qunit-dom": "^1.6.0",
|
|
111
|
+
"version-bump-prompt": "^6.1.0",
|
|
106
112
|
"webpack": "^5.61.0"
|
|
107
113
|
},
|
|
108
114
|
"engines": {
|