@hashicorp/design-system-components 0.2.0 → 0.3.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 +6 -0
- package/addon/components/hds/breadcrumb/index.hbs +13 -0
- package/addon/components/hds/breadcrumb/index.js +40 -0
- package/addon/components/hds/breadcrumb/item.hbs +26 -0
- package/addon/components/hds/breadcrumb/item.js +50 -0
- package/addon/components/hds/breadcrumb/truncation.hbs +23 -0
- package/addon/components/hds/button/index.js +1 -1
- package/app/components/hds/breadcrumb/index.js +1 -0
- package/app/components/hds/breadcrumb/item.js +1 -0
- package/app/components/hds/breadcrumb/truncation.js +1 -0
- package/app/styles/@hashicorp/design-system-components.scss +1 -0
- package/app/styles/components/breadcrumb.scss +189 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hashicorp/design-system-components
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#48](https://github.com/hashicorp/design-system/pull/48) [`971efb9e`](https://github.com/hashicorp/design-system/commit/971efb9e92478e4d88c24aeee835f448f35d2066) Thanks [@didoo](https://github.com/didoo)! - Added "Breadcrumb" component
|
|
8
|
+
|
|
3
9
|
## 0.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<nav
|
|
2
|
+
class={{this.classNames}}
|
|
3
|
+
{{!
|
|
4
|
+
TODO: should this string be localized, like in Structure? https://github.com/hashicorp/structure/blob/dffbb0e0ae5246d3b832586ab25bcb981a052b30/packages/pds-ember/addon/components/pds/breadcrumbs/index.hbs#L3
|
|
5
|
+
(in which case, we need to expose a prop? or start to have localization in the HDS system?)
|
|
6
|
+
}}
|
|
7
|
+
aria-label="breadcrumbs"
|
|
8
|
+
...attributes
|
|
9
|
+
>
|
|
10
|
+
<ol class="hds-breadcrumb__list" {{did-insert this.didInsert}}>
|
|
11
|
+
{{yield}}
|
|
12
|
+
</ol>
|
|
13
|
+
</nav>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
|
|
3
|
+
const noop = () => {};
|
|
4
|
+
|
|
5
|
+
export default class HdsBreadcrumbComponent extends Component {
|
|
6
|
+
/**
|
|
7
|
+
* @param onDidInsert
|
|
8
|
+
* @type {function}
|
|
9
|
+
* @default () => {}
|
|
10
|
+
*/
|
|
11
|
+
get didInsert() {
|
|
12
|
+
// TODO discuss with Matthew if this is the right way to create a guard for this method
|
|
13
|
+
return this.args.didInsert ?? noop;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param itemsCanWrap
|
|
18
|
+
* @type {boolean}
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
get itemsCanWrap() {
|
|
22
|
+
return this.args.itemsCanWrap ?? true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get the class names to apply to the component.
|
|
27
|
+
* @method Breadcrumb#classNames
|
|
28
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
29
|
+
*/
|
|
30
|
+
get classNames() {
|
|
31
|
+
let classes = ['hds-breadcrumb'];
|
|
32
|
+
|
|
33
|
+
// add a class based on the @itemsCanWrap argument
|
|
34
|
+
if (this.itemsCanWrap) {
|
|
35
|
+
classes.push('hds-breadcrumb--items-can-wrap');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return classes.join(' ');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<li class="hds-breadcrumb__item" style={{this.itemStyle}} ...attributes>
|
|
2
|
+
{{#if @current}}
|
|
3
|
+
<div class="hds-breadcrumb__current">
|
|
4
|
+
{{#if @icon}}
|
|
5
|
+
<div class="hds-breadcrumb__icon">
|
|
6
|
+
<FlightIcon @name={{@icon}} @size="16" @stretched={{true}} />
|
|
7
|
+
</div>
|
|
8
|
+
{{/if}}
|
|
9
|
+
<span class="hds-breadcrumb__text">{{@text}}</span>
|
|
10
|
+
</div>
|
|
11
|
+
{{else}}
|
|
12
|
+
<LinkTo
|
|
13
|
+
class="hds-breadcrumb__link {{if @hover 'is-hover'}} {{if @active 'is-active'}} {{if @focus 'is-focus'}}"
|
|
14
|
+
@models={{hds-link-to-models @model @models}}
|
|
15
|
+
@query={{hds-link-to-query @query}}
|
|
16
|
+
@route={{@route}}
|
|
17
|
+
>
|
|
18
|
+
{{#if @icon}}
|
|
19
|
+
<div class="hds-breadcrumb__icon">
|
|
20
|
+
<FlightIcon @name={{@icon}} @size="16" @stretched={{true}} />
|
|
21
|
+
</div>
|
|
22
|
+
{{/if}}
|
|
23
|
+
<span class="hds-breadcrumb__text">{{@text}}</span>
|
|
24
|
+
</LinkTo>
|
|
25
|
+
{{/if}}
|
|
26
|
+
</li>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { htmlSafe } from '@ember/template';
|
|
3
|
+
import { assert } from '@ember/debug';
|
|
4
|
+
|
|
5
|
+
export default class HdsBreadcrumbItemComponent extends Component {
|
|
6
|
+
/**
|
|
7
|
+
* @param maxWidth
|
|
8
|
+
* @type {string}
|
|
9
|
+
* @default undefined
|
|
10
|
+
* @description A parameter that can be applied to an "item" to limit its max-width
|
|
11
|
+
*/
|
|
12
|
+
get maxWidth() {
|
|
13
|
+
let { maxWidth } = this.args;
|
|
14
|
+
|
|
15
|
+
if (maxWidth) {
|
|
16
|
+
assert(
|
|
17
|
+
`@maxWidth for "Hds::Breadcrumb::Item" must be a size as number in 'px' or in 'em' (eg. '200px' or '24em'), received: ${maxWidth}`,
|
|
18
|
+
maxWidth.match(/^\d+(px|em)$/)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
return maxWidth;
|
|
22
|
+
} else {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get the inline style to apply to the item.
|
|
29
|
+
* @method BreadcrumbItem#itemStyle
|
|
30
|
+
* @return {string} The "style" attribute to apply to the item.
|
|
31
|
+
*/
|
|
32
|
+
get itemStyle() {
|
|
33
|
+
if (this.maxWidth) {
|
|
34
|
+
return htmlSafe(`max-width: ${this.maxWidth}`);
|
|
35
|
+
} else {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get the class names to apply to the component.
|
|
42
|
+
* @method BreadcrumbItem#classNames
|
|
43
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
44
|
+
*/
|
|
45
|
+
get classNames() {
|
|
46
|
+
let classes = ['hds-breadcrumb__item'];
|
|
47
|
+
|
|
48
|
+
return classes.join(' ');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<li class="hds-breadcrumb__item hds-breadcrumb__item--is-truncation" ...attributes>
|
|
2
|
+
<Hds::Disclosure>
|
|
3
|
+
<:toggle as |t|>
|
|
4
|
+
<button
|
|
5
|
+
type="button"
|
|
6
|
+
class="hds-breadcrumb__truncation-toggle
|
|
7
|
+
{{if @hover 'is-hover'}}
|
|
8
|
+
{{if @active 'is-active'}}
|
|
9
|
+
{{if @focus 'is-focus'}}"
|
|
10
|
+
{{on "click" t.onClickToggle}}
|
|
11
|
+
>
|
|
12
|
+
<FlightIcon @name="more-horizontal" @size="16" @isInlineBlock={{false}} />
|
|
13
|
+
</button>
|
|
14
|
+
</:toggle>
|
|
15
|
+
<:content>
|
|
16
|
+
<div class="hds-breadcrumb__truncation-content">
|
|
17
|
+
<ol class="hds-breadcrumb__sublist">
|
|
18
|
+
{{yield}}
|
|
19
|
+
</ol>
|
|
20
|
+
</div>
|
|
21
|
+
</:content>
|
|
22
|
+
</Hds::Disclosure>
|
|
23
|
+
</li>
|
|
@@ -167,7 +167,7 @@ export default class HdsButtonIndexComponent extends Component {
|
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Get the class names to apply to the component.
|
|
170
|
-
* @method
|
|
170
|
+
* @method Button#classNames
|
|
171
171
|
* @return {string} The "class" attribute to apply to the component.
|
|
172
172
|
*/
|
|
173
173
|
// "hds-button {{this.sizeClass}} {{this.colorClass}} {{this.widthClass}}"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/breadcrumb/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/breadcrumb/item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/breadcrumb/truncation';
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
//
|
|
2
|
+
// BREADCRUMB
|
|
3
|
+
//
|
|
4
|
+
// properties within each class are sorted alphabetically
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
@use "../mixins/focus-ring" as *;
|
|
9
|
+
|
|
10
|
+
$hds-breadcrumb-item-height: 28px;
|
|
11
|
+
$hds-breadcrumb-item-border-radius: 5px;
|
|
12
|
+
$hds-breadcrumb-item-visual-horizontal-padding: 4px;
|
|
13
|
+
|
|
14
|
+
// MAIN CONTAINER (NAV)
|
|
15
|
+
.hds-breadcrumb {
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// LIST (OL)
|
|
20
|
+
|
|
21
|
+
.hds-breadcrumb__list {
|
|
22
|
+
display: flex;
|
|
23
|
+
list-style: none;
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: 0;
|
|
26
|
+
|
|
27
|
+
.hds-breadcrumb--items-can-wrap & {
|
|
28
|
+
flex-wrap: wrap;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.hds-breadcrumb__sublist {
|
|
33
|
+
list-style: none;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ITEM (LI)
|
|
39
|
+
|
|
40
|
+
.hds-breadcrumb__item {
|
|
41
|
+
align-items: center;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: row;
|
|
44
|
+
min-width: 0;
|
|
45
|
+
position: relative;
|
|
46
|
+
|
|
47
|
+
.hds-breadcrumb__list > & {
|
|
48
|
+
&:not(:last-child)::after {
|
|
49
|
+
color: var(--token-color-palette-neutral-300);
|
|
50
|
+
content: "/";
|
|
51
|
+
padding: 0 8px;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.hds-breadcrumb__sublist > & + & {
|
|
56
|
+
margin-top: 4px;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.hds-breadcrumb__item--is-truncation {
|
|
61
|
+
flex: none; // needed to avoid that the "flex" parent collapses the truncation element (it happens with very long strings and no-wrapping)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// LINK (A)
|
|
65
|
+
|
|
66
|
+
.hds-breadcrumb__link {
|
|
67
|
+
align-items: center;
|
|
68
|
+
border-radius: $hds-breadcrumb-item-border-radius;
|
|
69
|
+
color: var(--token-color-foreground-faint);
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: row;
|
|
72
|
+
margin: 0 (-$hds-breadcrumb-item-visual-horizontal-padding); // we use a negative horizontal margin to counter-balance the horizonal padding (used to shift the focus from the content)
|
|
73
|
+
min-width: 0;
|
|
74
|
+
padding: 0 $hds-breadcrumb-item-visual-horizontal-padding;
|
|
75
|
+
// notice: the text decoration is applied directly to the "text" container because of a bug in Safari (see https://github.com/hashicorp/design-system-components/issues/159)
|
|
76
|
+
text-decoration-color: transparent;
|
|
77
|
+
|
|
78
|
+
// we apply the focus directly to the element, without using a pseudo-element
|
|
79
|
+
@include hds-focus-ring-basic();
|
|
80
|
+
|
|
81
|
+
&:hover,
|
|
82
|
+
&.is-hover {
|
|
83
|
+
color: var(--token-color-palette-neutral-600);
|
|
84
|
+
|
|
85
|
+
> .hds-breadcrumb__text {
|
|
86
|
+
text-decoration-color: currentColor;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&:active,
|
|
91
|
+
&.is-active {
|
|
92
|
+
color: var(--token-color-foreground-secondary);
|
|
93
|
+
|
|
94
|
+
> .hds-breadcrumb__text {
|
|
95
|
+
text-decoration-color: currentColor;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// CURRENT
|
|
101
|
+
|
|
102
|
+
.hds-breadcrumb__current {
|
|
103
|
+
align-items: center;
|
|
104
|
+
color: var(--token-color-foreground-strong);
|
|
105
|
+
display: flex;
|
|
106
|
+
flex-direction: row;
|
|
107
|
+
margin: 0 (-$hds-breadcrumb-item-visual-horizontal-padding); // we use a negative horizontal margin to counter-balance the horizonal padding (used to shift the focus from the content)
|
|
108
|
+
min-width: 0;
|
|
109
|
+
padding: 0 $hds-breadcrumb-item-visual-horizontal-padding;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// SUB-ELEMENTS
|
|
113
|
+
|
|
114
|
+
.hds-breadcrumb__icon {
|
|
115
|
+
flex: none;
|
|
116
|
+
margin-right: 6px;
|
|
117
|
+
height: 13px;
|
|
118
|
+
width: 13px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.hds-breadcrumb__text {
|
|
122
|
+
font-family: var(--token-typography-font-stack-text);
|
|
123
|
+
font-size: 0.8125rem; // 13px
|
|
124
|
+
line-height: 1rem; // 16px
|
|
125
|
+
overflow: hidden;
|
|
126
|
+
// we use the extra vertical padding to force the height of the parent item to be exactly $hds-breadcrumb-item-height
|
|
127
|
+
padding: calc((#{$hds-breadcrumb-item-height} - 1rem) / 2) 0;
|
|
128
|
+
text-decoration: underline;
|
|
129
|
+
text-decoration-color: transparent;
|
|
130
|
+
text-overflow: ellipsis;
|
|
131
|
+
white-space: nowrap;
|
|
132
|
+
|
|
133
|
+
.hds-breadcrumb__sublist & {
|
|
134
|
+
white-space: normal;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// TRUNCATION
|
|
139
|
+
|
|
140
|
+
.hds-breadcrumb__truncation-toggle {
|
|
141
|
+
align-items: center;
|
|
142
|
+
background-color: transparent;
|
|
143
|
+
border: 1px solid transparent; // We need this to be transparent for a11y
|
|
144
|
+
border-radius: $hds-breadcrumb-item-border-radius;
|
|
145
|
+
color: var(--token-color-foreground-faint);
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
display: flex;
|
|
148
|
+
flex: none;
|
|
149
|
+
height: $hds-breadcrumb-item-height;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
margin: 0 (-$hds-breadcrumb-item-visual-horizontal-padding); // the horizontal negative margin applied here is for visual balance of the spacing between items
|
|
152
|
+
outline: none; // TODO check with @melanie
|
|
153
|
+
padding: 0;
|
|
154
|
+
width: $hds-breadcrumb-item-height;
|
|
155
|
+
|
|
156
|
+
// we apply the focus directly to the element, without using a pseudo-element
|
|
157
|
+
@include hds-focus-ring-basic();
|
|
158
|
+
|
|
159
|
+
&:hover,
|
|
160
|
+
&.is-hover {
|
|
161
|
+
border-color: var(--token-color-border-strong);
|
|
162
|
+
color: var(--token-color-foreground-faint);
|
|
163
|
+
}
|
|
164
|
+
&:active,
|
|
165
|
+
&.is-active {
|
|
166
|
+
background-color: var(--token-color-surface-interactive-active);
|
|
167
|
+
border-color: var(--token-color-border-strong);
|
|
168
|
+
color: var(--token-color-foreground-primary);
|
|
169
|
+
}
|
|
170
|
+
&:focus,
|
|
171
|
+
&.is-focus {
|
|
172
|
+
background-color: transparent;
|
|
173
|
+
border: none; // important: we need to completely remove the border, of the inner box-shadow of the focus ring will be drawn inside the border
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.hds-breadcrumb__truncation-content {
|
|
178
|
+
background-color: var(--token-color-surface-primary);
|
|
179
|
+
border-radius: 6px;
|
|
180
|
+
box-shadow: var(--token-surface-high-box-shadow);
|
|
181
|
+
left: -$hds-breadcrumb-item-visual-horizontal-padding;
|
|
182
|
+
margin-top: 4px;
|
|
183
|
+
max-width: 200px; // by design
|
|
184
|
+
padding: 6px 12px;
|
|
185
|
+
position: absolute;
|
|
186
|
+
top: 100%;
|
|
187
|
+
width: max-content;
|
|
188
|
+
z-index: 300; // this is the z-index used in Structure for this kind of things, I am reusing the same value
|
|
189
|
+
}
|