@ukic/web-components 2.35.0 → 2.35.2
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/README.md +1 -0
- package/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/ic-badge.cjs.entry.js +23 -0
- package/dist/cjs/ic-badge.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-navigation-button.cjs.entry.js +2 -2
- package/dist/cjs/ic-navigation-button.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-navigation-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-item.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-toast.cjs.entry.js +2 -2
- package/dist/cjs/ic-toast.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/ic-accordion/ic-accordion.stories.js +635 -0
- package/dist/collection/components/ic-alert/ic-alert.stories.js +257 -0
- package/dist/collection/components/ic-back-to-top/ic-back-to-top.stories.js +162 -0
- package/dist/collection/components/ic-badge/ic-badge.js +39 -1
- package/dist/collection/components/ic-badge/ic-badge.js.map +1 -1
- package/dist/collection/components/ic-badge/ic-badge.stories.js +1082 -0
- package/dist/collection/components/ic-badge/test/basic/ic-badge.spec.js +194 -0
- package/dist/collection/components/ic-badge/test/basic/ic-badge.spec.js.map +1 -1
- package/dist/collection/components/ic-breadcrumb-group/ic-breadcrumb-group.stories.js +502 -0
- package/dist/collection/components/ic-button/ic-button.stories.js +2218 -0
- package/dist/collection/components/ic-card/ic-card.stories.js +1034 -0
- package/dist/collection/components/ic-checkbox-group/ic-checkbox-group.stories.js +687 -0
- package/dist/collection/components/ic-chip/ic-chip.stories.js +670 -0
- package/dist/collection/components/ic-classification-banner/ic-classification-banner.stories.js +131 -0
- package/dist/collection/components/ic-data-entity/ic-data-entity.stories.js +487 -0
- package/dist/collection/components/ic-dialog/ic-dialog.stories.js +1256 -0
- package/dist/collection/components/ic-empty-state/ic-empty-state.stories.js +397 -0
- package/dist/collection/components/ic-footer/ic-footer.stories.js +383 -0
- package/dist/collection/components/ic-hero/ic-hero.stories.js +489 -0
- package/dist/collection/components/ic-link/ic-link.stories.js +114 -0
- package/dist/collection/components/ic-loading-indicator/ic-loading-indicator.stories.js +416 -0
- package/dist/collection/components/ic-navigation-button/ic-navigation-button.css +4 -0
- package/dist/collection/components/ic-navigation-button/ic-navigation-button.js +1 -1
- package/dist/collection/components/ic-navigation-button/ic-navigation-button.js.map +1 -1
- package/dist/collection/components/ic-navigation-item/ic-navigation-item.css +7 -35
- package/dist/collection/components/ic-page-header/ic-page-header.stories.js +557 -0
- package/dist/collection/components/ic-pagination/ic-pagination.stories.js +125 -0
- package/dist/collection/components/ic-popover-menu/ic-popover-menu.stories.js +486 -0
- package/dist/collection/components/ic-radio-group/ic-radio-group.stories.js +450 -0
- package/dist/collection/components/ic-search-bar/ic-search-bar.stories.js +591 -0
- package/dist/collection/components/ic-section-container/ic-section-container.stories.js +62 -0
- package/dist/collection/components/ic-select/ic-select-searchable.stories.js +953 -0
- package/dist/collection/components/ic-select/ic-select-single.stories.js +780 -0
- package/dist/collection/components/ic-side-navigation/ic-side-navigation.stories.js +2526 -0
- package/dist/collection/components/ic-skeleton/ic-skeleton.stories.js +141 -0
- package/dist/collection/components/ic-status-tag/ic-status-tag.stories.js +161 -0
- package/dist/collection/components/ic-stepper/ic-stepper.stories.js +327 -0
- package/dist/collection/components/ic-switch/ic-switch.stories.js +171 -0
- package/dist/collection/components/ic-tab-context/ic-tabs.stories.js +388 -0
- package/dist/collection/components/ic-text-field/ic-text-field.stories.js +1083 -0
- package/dist/collection/components/ic-theme/ic-theme.stories.js +171 -0
- package/dist/collection/components/ic-toast/ic-toast.js +2 -2
- package/dist/collection/components/ic-toast/ic-toast.js.map +1 -1
- package/dist/collection/components/ic-toast/ic-toast.stories.js +413 -0
- package/dist/collection/components/ic-toast/test/basic/ic-toast.spec.js +3 -3
- package/dist/collection/components/ic-toast/test/basic/ic-toast.spec.js.map +1 -1
- package/dist/collection/components/ic-toggle-button/ic-toggle-button.stories.js +537 -0
- package/dist/collection/components/ic-toggle-button-group/ic-toggle-button-group.stories.js +610 -0
- package/dist/collection/components/ic-tooltip/ic-tooltip.js +2 -5
- package/dist/collection/components/ic-tooltip/ic-tooltip.js.map +1 -1
- package/dist/collection/components/ic-tooltip/ic-tooltip.stories.js +356 -0
- package/dist/collection/components/ic-top-navigation/ic-top-navigation.stories.js +1083 -0
- package/dist/collection/components/ic-typography/ic-typography.stories.js +437 -0
- package/dist/collection/patterns/top-nav-content-footer.stories.js +109 -0
- package/dist/collection/patterns/z-index.stories.js +474 -0
- package/dist/components/ic-badge.js +25 -2
- package/dist/components/ic-badge.js.map +1 -1
- package/dist/components/ic-navigation-button.js +2 -2
- package/dist/components/ic-navigation-button.js.map +1 -1
- package/dist/components/ic-navigation-item.js +1 -1
- package/dist/components/ic-navigation-item.js.map +1 -1
- package/dist/components/ic-toast.js +2 -2
- package/dist/components/ic-toast.js.map +1 -1
- package/dist/components/ic-tooltip2.js.map +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/p-3e8023ff.entry.js +2 -0
- package/dist/core/p-3e8023ff.entry.js.map +1 -0
- package/dist/core/p-ba06cc95.entry.js.map +1 -1
- package/dist/core/{p-7e8a4abd.entry.js → p-bfaa257c.entry.js} +2 -2
- package/dist/core/{p-7e8a4abd.entry.js.map → p-bfaa257c.entry.js.map} +1 -1
- package/dist/core/p-c05474f3.entry.js +2 -0
- package/dist/core/p-c05474f3.entry.js.map +1 -0
- package/dist/core/{p-5d3c6ea1.entry.js → p-d0299926.entry.js} +2 -2
- package/dist/core/p-d0299926.entry.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/ic-badge.entry.js +23 -0
- package/dist/esm/ic-badge.entry.js.map +1 -1
- package/dist/esm/ic-button_3.entry.js.map +1 -1
- package/dist/esm/ic-navigation-button.entry.js +2 -2
- package/dist/esm/ic-navigation-button.entry.js.map +1 -1
- package/dist/esm/ic-navigation-item.entry.js +1 -1
- package/dist/esm/ic-navigation-item.entry.js.map +1 -1
- package/dist/esm/ic-toast.entry.js +2 -2
- package/dist/esm/ic-toast.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-badge/ic-badge.d.ts +5 -0
- package/dist/types/components/ic-tooltip/ic-tooltip.d.ts +1 -1
- package/dist/types/components.d.ts +7 -0
- package/hydrate/index.js +30 -7
- package/package.json +17 -12
- package/vscode-data.json +4 -0
- package/dist/core/p-405d89bb.entry.js +0 -2
- package/dist/core/p-405d89bb.entry.js.map +0 -1
- package/dist/core/p-5d3c6ea1.entry.js.map +0 -1
- package/dist/core/p-dfb3e76e.entry.js +0 -2
- package/dist/core/p-dfb3e76e.entry.js.map +0 -1
@@ -0,0 +1,257 @@
|
|
1
|
+
import { html } from "lit-html";
|
2
|
+
|
3
|
+
const defaultArgs = {
|
4
|
+
dismissible: false,
|
5
|
+
heading: "Heading",
|
6
|
+
message: "Message",
|
7
|
+
titleAbove: false,
|
8
|
+
variant: "neutral",
|
9
|
+
showAction: false,
|
10
|
+
showDefaultIcon: true,
|
11
|
+
showSlottedIcon: false,
|
12
|
+
};
|
13
|
+
|
14
|
+
export default {
|
15
|
+
title: "Web Components/Alert",
|
16
|
+
component: "ic-alert",
|
17
|
+
};
|
18
|
+
|
19
|
+
export const Variants = {
|
20
|
+
render: () =>
|
21
|
+
html`<ic-alert
|
22
|
+
heading="Neutral"
|
23
|
+
message="This alert is for displaying miscellaneous messages"
|
24
|
+
></ic-alert>
|
25
|
+
<ic-alert
|
26
|
+
variant="info"
|
27
|
+
heading="Info"
|
28
|
+
message="This alert is for displaying information"
|
29
|
+
></ic-alert>
|
30
|
+
<ic-alert
|
31
|
+
variant="error"
|
32
|
+
heading="Error"
|
33
|
+
message="This alert is for displaying errors"
|
34
|
+
></ic-alert>
|
35
|
+
<ic-alert
|
36
|
+
variant="warning"
|
37
|
+
heading="Warning"
|
38
|
+
message="This alert is for displaying warnings"
|
39
|
+
></ic-alert>
|
40
|
+
<ic-alert
|
41
|
+
variant="success"
|
42
|
+
heading="Success"
|
43
|
+
message="This alert is for displaying success messages. It has a very long message with lots of text which goes over multiple
|
44
|
+
lines so the alert should expand as well to make sure it doesn't overflow"
|
45
|
+
></ic-alert>`,
|
46
|
+
|
47
|
+
name: "Variants",
|
48
|
+
};
|
49
|
+
|
50
|
+
export const MessageOnly = {
|
51
|
+
render: () =>
|
52
|
+
html`<ic-alert
|
53
|
+
message="This alert is for displaying miscellaneous messages"
|
54
|
+
></ic-alert>`,
|
55
|
+
|
56
|
+
name: "Message only",
|
57
|
+
};
|
58
|
+
|
59
|
+
export const Dismissible = {
|
60
|
+
render: () =>
|
61
|
+
html`<ic-alert
|
62
|
+
heading="Neutral"
|
63
|
+
message="This alert is for displaying miscellaneous messages"
|
64
|
+
dismissible="true"
|
65
|
+
></ic-alert>`,
|
66
|
+
|
67
|
+
name: "Dismissible",
|
68
|
+
};
|
69
|
+
|
70
|
+
export const WithAction = {
|
71
|
+
render: () =>
|
72
|
+
html`<ic-alert
|
73
|
+
heading="Neutral"
|
74
|
+
message="This alert is for displaying miscellaneous messages"
|
75
|
+
><ic-button slot="action" variant="secondary">Button</ic-button></ic-alert
|
76
|
+
>`,
|
77
|
+
|
78
|
+
name: "With action",
|
79
|
+
};
|
80
|
+
|
81
|
+
export const DismissibleWithAction = {
|
82
|
+
render: () =>
|
83
|
+
html`<ic-alert
|
84
|
+
heading="Neutral"
|
85
|
+
message="This alert is for displaying miscellaneous messages"
|
86
|
+
dismissible="true"
|
87
|
+
><ic-button slot="action" variant="secondary">Button</ic-button></ic-alert
|
88
|
+
>`,
|
89
|
+
|
90
|
+
name: "Dismissible with action",
|
91
|
+
};
|
92
|
+
|
93
|
+
export const TitleAbove = {
|
94
|
+
render: () =>
|
95
|
+
html`<ic-alert
|
96
|
+
heading="Neutral"
|
97
|
+
message="This alert is for displaying miscellaneous messages"
|
98
|
+
title-above="true"
|
99
|
+
></ic-alert>`,
|
100
|
+
|
101
|
+
name: "Title above",
|
102
|
+
};
|
103
|
+
|
104
|
+
export const ResponsiveTitle = {
|
105
|
+
render: () =>
|
106
|
+
html`<ic-alert
|
107
|
+
heading="This title is very long so should force the alert to add 'title-above'"
|
108
|
+
message="This alert does not have 'title-above' added as a prop but it is forced to add it due to the length of the title"
|
109
|
+
></ic-alert>
|
110
|
+
<ic-alert
|
111
|
+
variant="success"
|
112
|
+
heading="Shorter title"
|
113
|
+
message="Neither of these has 'title-above' set to true"
|
114
|
+
></ic-alert>`,
|
115
|
+
|
116
|
+
name: "Responsive title",
|
117
|
+
};
|
118
|
+
|
119
|
+
export const CustomMessage = {
|
120
|
+
render: () =>
|
121
|
+
html`<ic-alert heading="This alert uses a custom message slot">
|
122
|
+
<ic-typography variant="body" slot="message">
|
123
|
+
<p>
|
124
|
+
This is some text and
|
125
|
+
<ic-link href="/" inline>this is an inline link</ic-link> within the
|
126
|
+
text.
|
127
|
+
</p>
|
128
|
+
</ic-typography>
|
129
|
+
</ic-alert>`,
|
130
|
+
|
131
|
+
name: "Custom message",
|
132
|
+
};
|
133
|
+
|
134
|
+
export const CustomMessageAndTitleAbove = {
|
135
|
+
render: () => html`<ic-alert
|
136
|
+
heading="Want to know more about our coffee?"
|
137
|
+
title-above="true"
|
138
|
+
>
|
139
|
+
<span slot="message" style="font:var(--ic-font-body)">
|
140
|
+
Go to our <ic-link href="/">coffee page</ic-link> to learn more.
|
141
|
+
</ic-typography>
|
142
|
+
</ic-alert>`,
|
143
|
+
|
144
|
+
name: "Custom message and title above",
|
145
|
+
};
|
146
|
+
|
147
|
+
export const Announced = {
|
148
|
+
render: () => html`
|
149
|
+
<ic-alert
|
150
|
+
id="alert"
|
151
|
+
heading="Neutral"
|
152
|
+
message="This alert is for displaying miscellaneous messages"
|
153
|
+
announced="false"
|
154
|
+
></ic-alert>
|
155
|
+
<br />
|
156
|
+
<br />
|
157
|
+
<ic-button variant="primary" size="small" onClick="onClick()" id="btn"
|
158
|
+
>Toggle announced prop</ic-button
|
159
|
+
>
|
160
|
+
<script>
|
161
|
+
const alert = document.getElementById("alert");
|
162
|
+
const btn = document.getElementById("btn");
|
163
|
+
btn.addEventListener("click", onClick);
|
164
|
+
function onClick(e) {
|
165
|
+
e.preventDefault();
|
166
|
+
alert.announced
|
167
|
+
? (alert.announced = "false")
|
168
|
+
: (alert.announced = "true");
|
169
|
+
}
|
170
|
+
</script>
|
171
|
+
`,
|
172
|
+
|
173
|
+
name: "Announced",
|
174
|
+
};
|
175
|
+
|
176
|
+
export const SlottedIcon = {
|
177
|
+
render: () => html`
|
178
|
+
<ic-alert
|
179
|
+
id="alert"
|
180
|
+
heading="Neutral"
|
181
|
+
message="This alert contains a slotted icon"
|
182
|
+
show-default-icon="false"
|
183
|
+
>
|
184
|
+
<svg
|
185
|
+
slot="neutral-icon"
|
186
|
+
xmlns="http://www.w3.org/2000/svg"
|
187
|
+
height="24px"
|
188
|
+
viewBox="0 0 24 24"
|
189
|
+
width="24px"
|
190
|
+
fill="#000000"
|
191
|
+
>
|
192
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
193
|
+
<path
|
194
|
+
d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
|
195
|
+
/>
|
196
|
+
</svg>
|
197
|
+
</ic-alert>
|
198
|
+
`,
|
199
|
+
|
200
|
+
name: "Slotted icon",
|
201
|
+
};
|
202
|
+
|
203
|
+
export const NoIcon = {
|
204
|
+
render: () => html`
|
205
|
+
<ic-alert
|
206
|
+
id="alert"
|
207
|
+
heading="Neutral"
|
208
|
+
message="This alert has no icon"
|
209
|
+
show-default-icon="false"
|
210
|
+
></ic-alert>
|
211
|
+
`,
|
212
|
+
|
213
|
+
name: "No icon",
|
214
|
+
};
|
215
|
+
|
216
|
+
export const Playground = {
|
217
|
+
render: (args) =>
|
218
|
+
html`<ic-alert
|
219
|
+
dismissible=${args.dismissible}
|
220
|
+
variant=${args.variant}
|
221
|
+
heading=${args.heading}
|
222
|
+
message=${args.message}
|
223
|
+
title-above=${args.titleAbove}
|
224
|
+
show-default-icon=${args.showDefaultIcon}
|
225
|
+
>
|
226
|
+
${args.showAction &&
|
227
|
+
html`<ic-button slot="action" variant="secondary">Button</ic-button>`}
|
228
|
+
${args.showSlottedIcon &&
|
229
|
+
html`<svg
|
230
|
+
slot="neutral-icon"
|
231
|
+
xmlns="http://www.w3.org/2000/svg"
|
232
|
+
height="24px"
|
233
|
+
viewBox="0 0 24 24"
|
234
|
+
width="24px"
|
235
|
+
fill="#000000"
|
236
|
+
>
|
237
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
238
|
+
<path
|
239
|
+
d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
|
240
|
+
/>
|
241
|
+
</svg>`}
|
242
|
+
</ic-alert>`,
|
243
|
+
|
244
|
+
args: defaultArgs,
|
245
|
+
|
246
|
+
argTypes: {
|
247
|
+
variant: {
|
248
|
+
options: ["neutral", "info", "warning", "error", "success"],
|
249
|
+
|
250
|
+
control: {
|
251
|
+
type: "select",
|
252
|
+
},
|
253
|
+
},
|
254
|
+
},
|
255
|
+
|
256
|
+
name: "Playground",
|
257
|
+
};
|
@@ -0,0 +1,162 @@
|
|
1
|
+
import { html } from "lit-html";
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: "Web Components/Back to top",
|
5
|
+
component: "ic-back-to-top",
|
6
|
+
};
|
7
|
+
|
8
|
+
export const Default = {
|
9
|
+
render: () => html`
|
10
|
+
<div id="topEl" style="margin-top:-20px;">
|
11
|
+
<ic-typography variant="h2">Top of the page</ic-typography>
|
12
|
+
</div>
|
13
|
+
<div style="height:1200px;"></div>
|
14
|
+
<ic-back-to-top target="topEl"></ic-back-to-top>
|
15
|
+
`,
|
16
|
+
|
17
|
+
name: "Default",
|
18
|
+
};
|
19
|
+
|
20
|
+
export const IconOnly = {
|
21
|
+
render: () => html`
|
22
|
+
<div id="topEl" style="margin-top:-20px;">
|
23
|
+
<ic-typography variant="h2">Top of the page</ic-typography>
|
24
|
+
</div>
|
25
|
+
<div style="height:1200px;"></div>
|
26
|
+
<ic-back-to-top target="topEl" variant="icon"></ic-back-to-top>
|
27
|
+
`,
|
28
|
+
|
29
|
+
name: "Icon Only",
|
30
|
+
};
|
31
|
+
|
32
|
+
export const PageExample = {
|
33
|
+
render: () => html`
|
34
|
+
<div
|
35
|
+
id="header"
|
36
|
+
style="width:100%;height:100px;background-color:#23508e;color:var(--ic-architectural-white)"
|
37
|
+
>
|
38
|
+
<ic-typography variant="h1">Header</ic-typography>
|
39
|
+
<ic-button variant="secondary" appearance="light">Button</ic-button>
|
40
|
+
</div>
|
41
|
+
<div id="topPageEl">
|
42
|
+
<ic-typography variant="h2">Top of the page</ic-typography>
|
43
|
+
</div>
|
44
|
+
<ic-typography variant="h3">Some content</ic-typography>
|
45
|
+
<p>
|
46
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vel velit
|
47
|
+
turpis. Cras ac ligula et lectus mollis molestie in a enim. In ac turpis
|
48
|
+
in leo rutrum eleifend. Fusce consectetur posuere ligula, vitae semper
|
49
|
+
lorem mollis vitae. Fusce vel blandit turpis. Nulla justo ligula, egestas
|
50
|
+
quis rutrum id, vulputate eget diam. Integer mattis quis nisi id blandit.
|
51
|
+
Duis nisi lectus, suscipit elementum iaculis sed, porta et risus.
|
52
|
+
</p>
|
53
|
+
<br />
|
54
|
+
<br />
|
55
|
+
<br />
|
56
|
+
<ic-typography variant="h3">More content</ic-typography>
|
57
|
+
<p>
|
58
|
+
Phasellus accumsan ligula enim, a iaculis sapien rhoncus vitae. Curabitur
|
59
|
+
pulvinar posuere diam in luctus. Sed blandit diam id odio aliquam aliquet.
|
60
|
+
Pellentesque eros enim, tristique vel mattis eu, blandit at enim.
|
61
|
+
Pellentesque sollicitudin pellentesque tellus vel eleifend. Nulla mauris
|
62
|
+
lorem, porttitor vel orci eu, iaculis maximus nunc. Ut rhoncus ex ipsum.
|
63
|
+
Mauris ultricies, augue sed eleifend pellentesque, leo purus efficitur
|
64
|
+
orci, sit amet volutpat tortor diam non lorem. Morbi venenatis neque vel
|
65
|
+
accumsan sagittis. Nunc rutrum augue non urna tincidunt auctor in at
|
66
|
+
libero. Sed in risus sit amet nisl tempor viverra. Phasellus maximus
|
67
|
+
sapien eu erat maximus iaculis. Praesent ultricies id orci eu euismod.
|
68
|
+
Fusce eu urna turpis. Praesent ut neque tincidunt, porta sem id, accumsan
|
69
|
+
massa.
|
70
|
+
</p>
|
71
|
+
<br />
|
72
|
+
<br />
|
73
|
+
<br />
|
74
|
+
<ic-typography variant="h3">Some other content</ic-typography>
|
75
|
+
<p>
|
76
|
+
Curabitur eu tempor justo. Nunc congue viverra tristique. Maecenas massa
|
77
|
+
enim, tincidunt consequat maximus at, fermentum vel lectus. Curabitur at
|
78
|
+
ligula tellus. Ut a elit sit amet augue sagittis feugiat. Mauris mi enim,
|
79
|
+
viverra id turpis ac, auctor vulputate ipsum. Nunc efficitur volutpat
|
80
|
+
augue eget sollicitudin. Pellentesque eget pharetra ligula. Integer
|
81
|
+
finibus feugiat sapien a pulvinar. Phasellus fermentum est lacus, quis
|
82
|
+
volutpat justo pellentesque vitae. Sed vitae diam porta, facilisis metus
|
83
|
+
ut, dictum lorem. Proin sed bibendum libero. Maecenas justo neque,
|
84
|
+
ultricies sed magna ac, mattis vehicula elit. Donec ac lacus eget sapien
|
85
|
+
luctus ultricies in in nibh.
|
86
|
+
</p>
|
87
|
+
<p>
|
88
|
+
Curabitur in nulla urna. Donec ligula est, suscipit eget malesuada vitae,
|
89
|
+
elementum et quam. Lorem ipsum dolor sit amet, consectetur adipiscing
|
90
|
+
elit. Nulla eu dui a quam mollis porta. Nulla ante nunc, ultrices luctus
|
91
|
+
dolor at, ullamcorper convallis erat. Aenean viverra semper arcu nec
|
92
|
+
semper. Sed non magna purus. Integer accumsan dui et volutpat auctor.
|
93
|
+
Phasellus nec risus ultricies, maximus nunc eu, placerat diam. Etiam
|
94
|
+
pulvinar lacinia urna eget molestie. Suspendisse semper hendrerit ipsum,
|
95
|
+
vel porttitor lacus venenatis sit amet. Nullam non elit in sem vestibulum
|
96
|
+
molestie tempor eget augue. Sed neque ligula, tempus ac mollis bibendum,
|
97
|
+
ultrices suscipit risus. Duis suscipit pulvinar varius.
|
98
|
+
</p>
|
99
|
+
<br />
|
100
|
+
<br />
|
101
|
+
<br />
|
102
|
+
<ic-typography variant="h3">Some more</ic-typography>
|
103
|
+
<p>
|
104
|
+
Etiam accumsan nibh erat, condimentum tempus metus suscipit nec. Duis
|
105
|
+
placerat varius dolor eget ornare. Vestibulum egestas tellus non tellus
|
106
|
+
ornare, eu scelerisque erat pulvinar. Nam tempus lacus eu libero
|
107
|
+
consequat, in elementum magna ultricies. Etiam at suscipit odio. Duis quis
|
108
|
+
quam vitae quam varius luctus. Aliquam erat volutpat. Fusce laoreet
|
109
|
+
consectetur tortor, ac suscipit sem feugiat non. Etiam tempus tellus
|
110
|
+
aliquet orci pretium, nec pretium nulla faucibus
|
111
|
+
</p>
|
112
|
+
<br />
|
113
|
+
<ic-button>Button</ic-button>
|
114
|
+
<br />
|
115
|
+
<br />
|
116
|
+
<br />
|
117
|
+
<ic-typography variant="h3">Nearly there</ic-typography>
|
118
|
+
<p>
|
119
|
+
Curabitur eu tempor justo. Nunc congue viverra tristique. Maecenas massa
|
120
|
+
enim, tincidunt consequat maximus at, fermentum vel lectus. Curabitur at
|
121
|
+
ligula tellus. Ut a elit sit amet augue sagittis feugiat. Mauris mi enim,
|
122
|
+
viverra id turpis ac, auctor vulputate ipsum. Nunc efficitur volutpat
|
123
|
+
augue eget sollicitudin. Pellentesque eget pharetra ligula. Integer
|
124
|
+
finibus feugiat sapien a pulvinar. Phasellus fermentum est lacus, quis
|
125
|
+
volutpat justo pellentesque vitae. Sed vitae diam porta, facilisis metus
|
126
|
+
ut, dictum lorem. Proin sed bibendum libero. Maecenas justo neque,
|
127
|
+
ultricies sed magna ac, mattis vehicula elit. Donec ac lacus eget sapien
|
128
|
+
luctus ultricies in in nibh.
|
129
|
+
</p>
|
130
|
+
<p>
|
131
|
+
Curabitur in nulla urna. Donec ligula est, suscipit eget malesuada vitae,
|
132
|
+
elementum et quam. Lorem ipsum dolor sit amet, consectetur adipiscing
|
133
|
+
elit. Nulla eu dui a quam mollis porta. Nulla ante nunc, ultrices luctus
|
134
|
+
dolor at, ullamcorper convallis erat. Aenean viverra semper arcu nec
|
135
|
+
semper. Sed non magna purus. Integer accumsan dui et volutpat auctor.
|
136
|
+
Phasellus nec risus ultricies, maximus nunc eu, placerat diam. Etiam
|
137
|
+
pulvinar lacinia urna eget molestie. Suspendisse semper hendrerit ipsum,
|
138
|
+
vel porttitor lacus venenatis sit amet. Nullam non elit in sem vestibulum
|
139
|
+
molestie tempor eget augue. Sed neque ligula, tempus ac mollis bibendum,
|
140
|
+
ultrices suscipit risus. Duis suscipit pulvinar varius.
|
141
|
+
</p>
|
142
|
+
<br />
|
143
|
+
<br />
|
144
|
+
<br />
|
145
|
+
<ic-typography variant="h3">The end</ic-typography>
|
146
|
+
<br />
|
147
|
+
<ic-back-to-top target="topPageEl"></ic-back-to-top>
|
148
|
+
<footer>
|
149
|
+
<div
|
150
|
+
id="footer"
|
151
|
+
style="width:100%;height:200px;background-color:#23508e;color:var(--ic-architectural-white)"
|
152
|
+
>
|
153
|
+
<ic-typography variant="h3">Footer</ic-typography>
|
154
|
+
</div>
|
155
|
+
</footer>
|
156
|
+
<ic-classification-banner
|
157
|
+
classification="official"
|
158
|
+
></ic-classification-banner>
|
159
|
+
`,
|
160
|
+
|
161
|
+
name: "Page example",
|
162
|
+
};
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Host, h, } from "@stencil/core";
|
2
2
|
import { convertToRGBA, getCssProperty, getThemeForegroundColor, hexToRgba, isPropDefined, onComponentRequiredPropUndefined, rgbaStrToObj, } from "../../utils/helpers";
|
3
|
+
const NAVIGATION_BUTTON = "IC-NAVIGATION-BUTTON";
|
4
|
+
const TOP_NAVIGATION = "IC-TOP-NAVIGATION";
|
3
5
|
/**
|
4
6
|
* @slot badge-icon - Icon will be rendered inside the badge if type is set to icon.
|
5
7
|
*/
|
@@ -59,6 +61,18 @@ export class Badge {
|
|
59
61
|
}
|
60
62
|
}
|
61
63
|
};
|
64
|
+
this.setPositionInTopNavigation = () => {
|
65
|
+
const parentTopNavEl = this.el.parentElement.parentElement;
|
66
|
+
parentTopNavEl.classList.contains("mobile-mode")
|
67
|
+
? (this.position = "inline")
|
68
|
+
: (this.position = "near");
|
69
|
+
};
|
70
|
+
this.isInTopNav = () => {
|
71
|
+
const parentEl = this.el.parentElement;
|
72
|
+
const grandparentEl = parentEl.parentElement;
|
73
|
+
return (parentEl.tagName === NAVIGATION_BUTTON &&
|
74
|
+
grandparentEl.tagName === TOP_NAVIGATION);
|
75
|
+
};
|
62
76
|
this.isAccessibleLabelDefined = () => isPropDefined(this.accessibleLabel) && this.accessibleLabel !== null;
|
63
77
|
this.accessibleLabel = undefined;
|
64
78
|
this.customColor = null;
|
@@ -95,6 +109,15 @@ export class Badge {
|
|
95
109
|
this.type === "text" &&
|
96
110
|
onComponentRequiredPropUndefined([{ prop: this.textLabel, propName: "text-label" }], "Badge");
|
97
111
|
}
|
112
|
+
componentWillRender() {
|
113
|
+
this.isInTopNav() && this.setPositionInTopNavigation();
|
114
|
+
}
|
115
|
+
navBarMenuOpenHandler() {
|
116
|
+
this.isInTopNav() && (this.position = "inline");
|
117
|
+
}
|
118
|
+
navBarMenuCloseHandler() {
|
119
|
+
this.isInTopNav() && (this.position = "near");
|
120
|
+
}
|
98
121
|
/**
|
99
122
|
* @deprecated This method should not be used anymore. Use visible prop to set badge visibility.
|
100
123
|
*/
|
@@ -193,7 +216,7 @@ export class Badge {
|
|
193
216
|
},
|
194
217
|
"position": {
|
195
218
|
"type": "string",
|
196
|
-
"mutable":
|
219
|
+
"mutable": true,
|
197
220
|
"complexType": {
|
198
221
|
"original": "IcBadgePositions",
|
199
222
|
"resolved": "\"far\" | \"inline\" | \"near\"",
|
@@ -384,5 +407,20 @@ export class Badge {
|
|
384
407
|
"methodName": "visibleHandler"
|
385
408
|
}];
|
386
409
|
}
|
410
|
+
static get listeners() {
|
411
|
+
return [{
|
412
|
+
"name": "icNavigationMenuOpened",
|
413
|
+
"method": "navBarMenuOpenHandler",
|
414
|
+
"target": "document",
|
415
|
+
"capture": false,
|
416
|
+
"passive": false
|
417
|
+
}, {
|
418
|
+
"name": "icNavigationMenuClosed",
|
419
|
+
"method": "navBarMenuCloseHandler",
|
420
|
+
"target": "document",
|
421
|
+
"capture": false,
|
422
|
+
"passive": false
|
423
|
+
}];
|
424
|
+
}
|
387
425
|
}
|
388
426
|
//# sourceMappingURL=ic-badge.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-badge.js","sourceRoot":"","sources":["../../../src/components/ic-badge/ic-badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,CAAC,GACF,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,SAAS,EACT,aAAa,EACb,gCAAgC,EAChC,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AAQH,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@stencil/core\";\nimport {\n IcBadgePositions,\n IcBadgeTypes,\n IcBadgeVariants,\n} from \"./ic-badge.types\";\nimport {\n IcColorRGBA,\n IcSizes,\n IcThemeForeground,\n IcColor,\n} from \"../../utils/types\";\nimport {\n convertToRGBA,\n getCssProperty,\n getThemeForegroundColor,\n hexToRgba,\n isPropDefined,\n onComponentRequiredPropUndefined,\n rgbaStrToObj,\n} from \"../../utils/helpers\";\n\n/**\n * @slot badge-icon - Icon will be rendered inside the badge if type is set to icon.\n */\n@Component({\n tag: \"ic-badge\",\n styleUrl: \"ic-badge.css\",\n shadow: {\n delegatesFocus: true,\n },\n})\nexport class Badge {\n private ariaLabel: string = null;\n private customColorRGBA: IcColorRGBA;\n private foregroundColour: IcThemeForeground;\n private parentAriaLabel: string;\n\n @Element() el: HTMLIcBadgeElement;\n\n /**\n * The accessible label of the badge component to provide context for screen reader users.\n */\n @Prop() accessibleLabel?: string;\n\n @Watch(\"accessibleLabel\")\n accessibleLabelHandler(): void {\n this.setAccessibleLabel();\n }\n\n /**\n * The custom badge colour. This will only style the badge component if variant=\"custom\".\n * Can be a hex value e.g. \"#ff0000\", RGB e.g. \"rgb(255, 0, 0)\", or RGBA e.g. \"rgba(255, 0, 0, 1)\".\n */\n @Prop() customColor?: IcColor = null;\n\n @Watch(\"customColor\")\n customColorHandler(): void {\n this.variant === \"custom\" && this.setBadgeColour();\n }\n\n /**\n * The maximum number shown on the badge appended with a +.\n * This will only be displayed if type=\"text\" and textLabel is not empty.\n */\n @Prop() maxNumber?: number;\n\n /**\n * The positioning of the badge in reference to the parent element.\n */\n @Prop() position?: IcBadgePositions = \"far\";\n\n /**\n * The size of the badge to be displayed.\n */\n @Prop() size?: IcSizes = \"default\";\n\n /**\n * The text displayed in the badge. This will only be displayed if type=\"text\".\n */\n @Prop() textLabel?: string;\n\n /**\n * The type of badge to be displayed.\n */\n @Prop() type?: IcBadgeTypes = \"text\";\n\n /**\n * The variant of the badge to be displayed.\n */\n @Prop() variant?: IcBadgeVariants = \"neutral\";\n\n @Watch(\"variant\")\n variantHandler(): void {\n this.getBadgeForeground();\n }\n\n /**\n * If `true`, the badge will be displayed.\n */\n @Prop({ mutable: true }) visible: boolean = true;\n\n @Watch(\"visible\")\n visibleHandler(): void {\n this.setAccessibleLabel();\n }\n\n componentWillLoad(): void {\n this.variant === \"custom\" && this.setBadgeColour();\n\n this.getBadgeForeground();\n\n const ariaLabel = this.el.parentElement?.ariaLabel;\n if (ariaLabel) this.parentAriaLabel = ariaLabel;\n this.setAccessibleLabel();\n }\n\n componentDidLoad(): void {\n this.type === \"text\" &&\n onComponentRequiredPropUndefined(\n [{ prop: this.textLabel, propName: \"text-label\" }],\n \"Badge\"\n );\n }\n\n /**\n * @deprecated This method should not be used anymore. Use visible prop to set badge visibility.\n */\n @Method()\n async showBadge(): Promise<void> {\n this.visible = true;\n }\n\n /**\n * @deprecated This method should not be used anymore. Use visible prop to set badge visibility.\n */\n @Method()\n async hideBadge(): Promise<void> {\n this.visible = false;\n }\n\n private setBadgeColour = () => {\n const colorRGBA = convertToRGBA(this.customColor);\n\n if (colorRGBA) {\n this.customColorRGBA = colorRGBA;\n const { r, g, b, a } = colorRGBA;\n this.el.style.backgroundColor = `rgba(${r}, ${g}, ${b}, ${a})`;\n }\n };\n\n private getBadgeRGB = () => {\n switch (this.variant) {\n case \"custom\":\n return this.customColorRGBA;\n case \"error\":\n case \"success\":\n case \"warning\":\n case \"info\": {\n return rgbaStrToObj(getCssProperty(`--ic-status-${this.variant}`));\n }\n case \"neutral\":\n case \"light\":\n return hexToRgba(\n getCssProperty(\n `--ic-architectural-${this.variant === \"neutral\" ? 500 : 40}`\n )\n );\n }\n };\n\n private getBadgeForeground = () => {\n const { r, g, b } = this.getBadgeRGB();\n this.foregroundColour = getThemeForegroundColor(\n (r * 299 + g * 587 + b * 114) / 1000\n );\n };\n\n private getTextLabel = () =>\n this.maxNumber && Number(this.textLabel) > this.maxNumber\n ? `${this.maxNumber}+`\n : this.textLabel;\n\n // Set aria-label on badge and / or parent element\n // Aria-describedby seems to not work, probably due to shadow DOM\n private setAccessibleLabel = () => {\n const parentEl = this.el.parentElement;\n const defaultAriaLabel = this.isAccessibleLabelDefined()\n ? this.accessibleLabel\n : this.textLabel || \"with badge being displayed\";\n\n if (parentEl) {\n const { tagName } = parentEl;\n if (\n tagName !== \"IC-CARD\" &&\n (tagName !== \"IC-TAB\" || (tagName === \"IC-TAB\" && this.parentAriaLabel))\n ) {\n const ariaLabelPrefix = this.parentAriaLabel\n ? `${this.parentAriaLabel} ,`\n : \"\";\n parentEl.ariaLabel = this.visible\n ? `${ariaLabelPrefix} ${defaultAriaLabel}`\n : undefined;\n } else {\n this.ariaLabel = `, ${defaultAriaLabel}`;\n }\n }\n };\n\n private isAccessibleLabelDefined = () =>\n isPropDefined(this.accessibleLabel) && this.accessibleLabel !== null;\n\n render() {\n const {\n ariaLabel,\n el,\n foregroundColour,\n getTextLabel,\n position,\n size,\n textLabel,\n type,\n variant,\n visible,\n } = this;\n\n return (\n <Host\n class={{\n [`${position}`]: true,\n [`${size}`]: true,\n [`${variant}`]: true,\n [`${type}`]: true,\n [`foreground-${foregroundColour}`]: foregroundColour !== null,\n [`${visible ? \"show\" : \"hide\"}`]: true,\n }}\n id={el.id || null}\n aria-label={ariaLabel}\n role=\"status\"\n >\n {type === \"icon\" && <slot name=\"badge-icon\"></slot>}\n {type === \"text\" && textLabel && (\n <ic-typography variant={size === \"small\" ? \"badge-small\" : \"badge\"}>\n {getTextLabel()}\n </ic-typography>\n )}\n {type === \"dot\" && <span class=\"sr-only\">badge</span>}\n </Host>\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ic-badge.js","sourceRoot":"","sources":["../../../src/components/ic-badge/ic-badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,CAAC,EACD,MAAM,GACP,MAAM,eAAe,CAAC;AAYvB,OAA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C,EAAE,IAAI;gBACrB,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI;gBACjB,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,IAAI;gBACpB,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI;gBACjB,CAAC,cAAc,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,KAAK,IAAI;gBAC7D,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI;aACvC,EACD,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,IAAI,gBACL,SAAS,EACrB,IAAI,EAAC,QAAQ;YAEZ,IAAI,KAAK,MAAM,IAAI,YAAM,IAAI,EAAC,YAAY,GAAQ;YAClD,IAAI,KAAK,MAAM,IAAI,SAAS,IAAI,CAC/B,qBAAe,OAAO,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,IAC/D,YAAY,EAAE,CACD,CACjB;YACA,IAAI,KAAK,KAAK,IAAI,YAAM,KAAK,EAAC,SAAS,YAAa,CAChD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Element,\n Host,\n Method,\n Prop,\n Watch,\n h,\n Listen,\n} from \"@stencil/core\";\nimport {\n IcBadgePositions,\n IcBadgeTypes,\n IcBadgeVariants,\n} from \"./ic-badge.types\";\nimport {\n IcColorRGBA,\n IcSizes,\n IcThemeForeground,\n IcColor,\n} from \"../../utils/types\";\nimport {\n convertToRGBA,\n getCssProperty,\n getThemeForegroundColor,\n hexToRgba,\n isPropDefined,\n onComponentRequiredPropUndefined,\n rgbaStrToObj,\n} from \"../../utils/helpers\";\n\nconst NAVIGATION_BUTTON = \"IC-NAVIGATION-BUTTON\";\nconst TOP_NAVIGATION = \"IC-TOP-NAVIGATION\";\n\n/**\n * @slot badge-icon - Icon will be rendered inside the badge if type is set to icon.\n */\n@Component({\n tag: \"ic-badge\",\n styleUrl: \"ic-badge.css\",\n shadow: {\n delegatesFocus: true,\n },\n})\nexport class Badge {\n private ariaLabel: string = null;\n private customColorRGBA: IcColorRGBA;\n private foregroundColour: IcThemeForeground;\n private parentAriaLabel: string;\n\n @Element() el: HTMLIcBadgeElement;\n\n /**\n * The accessible label of the badge component to provide context for screen reader users.\n */\n @Prop() accessibleLabel?: string;\n\n @Watch(\"accessibleLabel\")\n accessibleLabelHandler(): void {\n this.setAccessibleLabel();\n }\n\n /**\n * The custom badge colour. This will only style the badge component if variant=\"custom\".\n * Can be a hex value e.g. \"#ff0000\", RGB e.g. \"rgb(255, 0, 0)\", or RGBA e.g. \"rgba(255, 0, 0, 1)\".\n */\n @Prop() customColor?: IcColor = null;\n\n @Watch(\"customColor\")\n customColorHandler(): void {\n this.variant === \"custom\" && this.setBadgeColour();\n }\n\n /**\n * The maximum number shown on the badge appended with a +.\n * This will only be displayed if type=\"text\" and textLabel is not empty.\n */\n @Prop() maxNumber?: number;\n\n /**\n * The positioning of the badge in reference to the parent element.\n */\n @Prop({ mutable: true }) position?: IcBadgePositions = \"far\";\n\n /**\n * The size of the badge to be displayed.\n */\n @Prop() size?: IcSizes = \"default\";\n\n /**\n * The text displayed in the badge. This will only be displayed if type=\"text\".\n */\n @Prop() textLabel?: string;\n\n /**\n * The type of badge to be displayed.\n */\n @Prop() type?: IcBadgeTypes = \"text\";\n\n /**\n * The variant of the badge to be displayed.\n */\n @Prop() variant?: IcBadgeVariants = \"neutral\";\n\n @Watch(\"variant\")\n variantHandler(): void {\n this.getBadgeForeground();\n }\n\n /**\n * If `true`, the badge will be displayed.\n */\n @Prop({ mutable: true }) visible: boolean = true;\n\n @Watch(\"visible\")\n visibleHandler(): void {\n this.setAccessibleLabel();\n }\n\n componentWillLoad(): void {\n this.variant === \"custom\" && this.setBadgeColour();\n\n this.getBadgeForeground();\n\n const ariaLabel = this.el.parentElement?.ariaLabel;\n if (ariaLabel) this.parentAriaLabel = ariaLabel;\n this.setAccessibleLabel();\n }\n\n componentDidLoad(): void {\n this.type === \"text\" &&\n onComponentRequiredPropUndefined(\n [{ prop: this.textLabel, propName: \"text-label\" }],\n \"Badge\"\n );\n }\n\n componentWillRender(): void {\n this.isInTopNav() && this.setPositionInTopNavigation();\n }\n\n @Listen(\"icNavigationMenuOpened\", { target: \"document\" })\n navBarMenuOpenHandler(): void {\n this.isInTopNav() && (this.position = \"inline\");\n }\n\n @Listen(\"icNavigationMenuClosed\", { target: \"document\" })\n navBarMenuCloseHandler(): void {\n this.isInTopNav() && (this.position = \"near\");\n }\n\n /**\n * @deprecated This method should not be used anymore. Use visible prop to set badge visibility.\n */\n @Method()\n async showBadge(): Promise<void> {\n this.visible = true;\n }\n\n /**\n * @deprecated This method should not be used anymore. Use visible prop to set badge visibility.\n */\n @Method()\n async hideBadge(): Promise<void> {\n this.visible = false;\n }\n\n private setBadgeColour = () => {\n const colorRGBA = convertToRGBA(this.customColor);\n\n if (colorRGBA) {\n this.customColorRGBA = colorRGBA;\n const { r, g, b, a } = colorRGBA;\n this.el.style.backgroundColor = `rgba(${r}, ${g}, ${b}, ${a})`;\n }\n };\n\n private getBadgeRGB = () => {\n switch (this.variant) {\n case \"custom\":\n return this.customColorRGBA;\n case \"error\":\n case \"success\":\n case \"warning\":\n case \"info\": {\n return rgbaStrToObj(getCssProperty(`--ic-status-${this.variant}`));\n }\n case \"neutral\":\n case \"light\":\n return hexToRgba(\n getCssProperty(\n `--ic-architectural-${this.variant === \"neutral\" ? 500 : 40}`\n )\n );\n }\n };\n\n private getBadgeForeground = () => {\n const { r, g, b } = this.getBadgeRGB();\n this.foregroundColour = getThemeForegroundColor(\n (r * 299 + g * 587 + b * 114) / 1000\n );\n };\n\n private getTextLabel = () =>\n this.maxNumber && Number(this.textLabel) > this.maxNumber\n ? `${this.maxNumber}+`\n : this.textLabel;\n\n // Set aria-label on badge and / or parent element\n // Aria-describedby seems to not work, probably due to shadow DOM\n private setAccessibleLabel = () => {\n const parentEl = this.el.parentElement;\n const defaultAriaLabel = this.isAccessibleLabelDefined()\n ? this.accessibleLabel\n : this.textLabel || \"with badge being displayed\";\n\n if (parentEl) {\n const { tagName } = parentEl;\n if (\n tagName !== \"IC-CARD\" &&\n (tagName !== \"IC-TAB\" || (tagName === \"IC-TAB\" && this.parentAriaLabel))\n ) {\n const ariaLabelPrefix = this.parentAriaLabel\n ? `${this.parentAriaLabel} ,`\n : \"\";\n parentEl.ariaLabel = this.visible\n ? `${ariaLabelPrefix} ${defaultAriaLabel}`\n : undefined;\n } else {\n this.ariaLabel = `, ${defaultAriaLabel}`;\n }\n }\n };\n\n private setPositionInTopNavigation = () => {\n const parentTopNavEl = this.el.parentElement.parentElement;\n parentTopNavEl.classList.contains(\"mobile-mode\")\n ? (this.position = \"inline\")\n : (this.position = \"near\");\n };\n\n private isInTopNav = (): boolean => {\n const parentEl = this.el.parentElement;\n const grandparentEl = parentEl.parentElement;\n return (\n parentEl.tagName === NAVIGATION_BUTTON &&\n grandparentEl.tagName === TOP_NAVIGATION\n );\n };\n\n private isAccessibleLabelDefined = () =>\n isPropDefined(this.accessibleLabel) && this.accessibleLabel !== null;\n\n render() {\n const {\n ariaLabel,\n el,\n foregroundColour,\n getTextLabel,\n position,\n size,\n textLabel,\n type,\n variant,\n visible,\n } = this;\n\n return (\n <Host\n class={{\n [`${position}`]: true,\n [`${size}`]: true,\n [`${variant}`]: true,\n [`${type}`]: true,\n [`foreground-${foregroundColour}`]: foregroundColour !== null,\n [`${visible ? \"show\" : \"hide\"}`]: true,\n }}\n id={el.id || null}\n aria-label={ariaLabel}\n role=\"status\"\n >\n {type === \"icon\" && <slot name=\"badge-icon\"></slot>}\n {type === \"text\" && textLabel && (\n <ic-typography variant={size === \"small\" ? \"badge-small\" : \"badge\"}>\n {getTextLabel()}\n </ic-typography>\n )}\n {type === \"dot\" && <span class=\"sr-only\">badge</span>}\n </Host>\n );\n }\n}\n"]}
|