@supersoniks/concorde 5.0.1 → 5.0.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/build-infos.json +1 -1
- package/concorde-core.bundle.js +519 -586
- package/concorde-core.es.js +3783 -3689
- package/dist/concorde-core.bundle.js +519 -586
- package/dist/concorde-core.es.js +3783 -3689
- package/index.html +2 -2
- package/package.json +14 -1
- package/src/core/components/ui/_css/rounded.ts +36 -0
- package/src/core/components/ui/_css/type.ts +49 -0
- package/src/core/components/ui/_i18n/ui-aria-labels.ts +104 -0
- package/src/core/components/ui/alert/alert.md +128 -72
- package/src/core/components/ui/alert/alert.spec.ts +145 -0
- package/src/core/components/ui/alert/alert.ts +86 -91
- package/src/core/components/ui/alert-messages/alert-messages.ts +1 -1
- package/src/core/components/ui/badge/badge.md +126 -78
- package/src/core/components/ui/badge/badge.ts +29 -81
- package/src/core/components/ui/button/button.md +1 -0
- package/src/core/components/ui/button/button.ts +11 -8
- package/src/core/components/ui/card/card-header.ts +7 -2
- package/src/core/components/ui/card/card.md +120 -65
- package/src/core/components/ui/divider/divider.ts +4 -9
- package/src/core/components/ui/form/fieldset/legend-description.ts +1 -1
- package/src/core/components/ui/form/fieldset/legend.ts +1 -1
- package/src/core/components/ui/form/input/input.md +1 -1
- package/src/core/components/ui/form/input/input.ts +19 -15
- package/src/core/components/ui/form/textarea/textarea.md +1 -1
- package/src/core/components/ui/image/image.md +147 -53
- package/src/core/components/ui/image/image.ts +10 -44
- package/src/core/components/ui/link/link.md +2 -2
- package/src/core/components/ui/link/link.ts +42 -37
- package/src/core/components/ui/modal/modal-close.ts +8 -12
- package/src/core/components/ui/modal/modal.ts +18 -18
- package/src/core/components/ui/pop/pop.md +7 -5
- package/src/core/components/ui/pop/pop.ts +78 -38
- package/src/core/components/ui/table/table.ts +2 -8
- package/src/core/components/ui/toast/dismissed.ts +14 -0
- package/src/core/components/ui/toast/toast-item.ts +139 -91
- package/src/core/components/ui/toast/toast.ts +4 -7
- package/src/core/components/ui/tooltip/tooltip.ts +6 -8
- package/src/core/utils/LocationHandler.ts +12 -5
- package/src/core/utils/dismissed.ts +22 -0
- package/src/core/utils/positioning.spec.ts +28 -0
- package/src/core/utils/positioning.ts +19 -0
- package/src/docs/_getting-started/concorde-outside.md +3 -3
- package/src/docs/code.ts +3 -1
- package/src/docs/search/docs-search.json +541 -1
- package/src/docs/tailwind/css/tailwind.css +6 -0
- package/src/tsconfig.json +422 -383
- package/src/tsconfig.tsbuildinfo +1 -1
- package/tailwind.config.js +50 -3
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import { html, LitElement, css, nothing } from "lit";
|
|
1
|
+
import { html, LitElement, css, nothing, PropertyValues } from "lit";
|
|
2
2
|
import { customElement, property } from "lit/decorators.js";
|
|
3
3
|
import {
|
|
4
4
|
fontSize,
|
|
5
5
|
Size,
|
|
6
6
|
} from "@supersoniks/concorde/core/components/ui/_css/size";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import {
|
|
8
|
+
StatusIconKey,
|
|
9
|
+
statusAriaLive,
|
|
10
|
+
statusAriaRole,
|
|
11
|
+
statusColor,
|
|
12
|
+
statusIcon,
|
|
13
|
+
} from "@supersoniks/concorde/core/components/ui/_css/type";
|
|
14
|
+
import {
|
|
15
|
+
isDismissed,
|
|
16
|
+
markDismissed,
|
|
17
|
+
} from "@supersoniks/concorde/core/utils/dismissed";
|
|
18
|
+
import {
|
|
19
|
+
resolveUiLabel,
|
|
20
|
+
uiAriaLabels,
|
|
21
|
+
} from "@supersoniks/concorde/core/components/ui/_i18n/ui-aria-labels";
|
|
22
|
+
|
|
23
|
+
export type AlertStatus = StatusIconKey;
|
|
17
24
|
const tagName = "sonic-alert";
|
|
25
|
+
const dismissStorageKey = "sonic-alert-dismissed";
|
|
18
26
|
|
|
19
27
|
/**
|
|
20
28
|
* Affiche un message en ligne.
|
|
@@ -24,66 +32,29 @@ const tagName = "sonic-alert";
|
|
|
24
32
|
export class Alert extends LitElement {
|
|
25
33
|
static styles = [
|
|
26
34
|
fontSize,
|
|
35
|
+
statusColor,
|
|
27
36
|
css`
|
|
28
37
|
:host {
|
|
29
|
-
--
|
|
30
|
-
--sc_rounded: var(--sc-rounded);
|
|
31
|
-
--sc_fw: var(--sc-font-weight-base, 400);
|
|
32
|
-
--sc_fst: var(--sc-font-style-base, normal);
|
|
33
|
-
--sc_label-fw: bold;
|
|
34
|
-
|
|
35
|
-
font-weight: var(--sc_fw);
|
|
36
|
-
font-style: var(--sc_fst);
|
|
37
|
-
color: var(--sc_color);
|
|
38
|
+
--sc-_rounded: var(--sc-rounded);
|
|
38
39
|
position: relative;
|
|
39
40
|
display: flex;
|
|
40
41
|
gap: 0.4em;
|
|
41
|
-
border-radius: var(--
|
|
42
|
+
border-radius: var(--sc-_rounded);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
.label {
|
|
45
|
-
font-weight:
|
|
46
|
+
font-weight: bold;
|
|
46
47
|
margin-bottom: 0.15em;
|
|
47
48
|
display: block;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
:host([status="warning"]) {
|
|
51
|
-
--sc_color: var(--sc-warning, var(--sc-base-content, #000));
|
|
52
|
-
}
|
|
53
|
-
:host([status="error"]) {
|
|
54
|
-
--sc_color: var(--sc-danger, var(--sc-base-content, #000));
|
|
55
|
-
}
|
|
56
|
-
:host([status="info"]) {
|
|
57
|
-
--sc_color: var(--sc-info, var(--sc-base-content, #000));
|
|
58
|
-
}
|
|
59
|
-
:host([status="success"]) {
|
|
60
|
-
--sc_color: var(--sc-success, var(--sc-base-content, #000));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
51
|
/*background*/
|
|
64
|
-
:host([dismissible]),
|
|
65
52
|
:host([background]) {
|
|
66
|
-
background: var(--sc-base, #fff);
|
|
67
|
-
padding: 0.8em
|
|
68
|
-
}
|
|
69
|
-
:host([dismissible]):before,
|
|
70
|
-
:host([background]):before {
|
|
71
|
-
background-color: currentColor;
|
|
72
|
-
content: "";
|
|
73
|
-
display: block;
|
|
74
|
-
position: absolute;
|
|
75
|
-
left: 0;
|
|
76
|
-
top: 0;
|
|
77
|
-
right: 0;
|
|
78
|
-
bottom: 0;
|
|
79
|
-
opacity: 0.08;
|
|
80
|
-
border-radius: var(--sc_rounded);
|
|
81
|
-
pointer-events: none;
|
|
53
|
+
background: color-mix(in srgb, currentColor 8%, var(--sc-base, #fff));
|
|
54
|
+
padding: 0.8em;
|
|
82
55
|
}
|
|
83
56
|
|
|
84
57
|
.content {
|
|
85
|
-
z-index: 2;
|
|
86
|
-
position: relative;
|
|
87
58
|
flex: 1;
|
|
88
59
|
}
|
|
89
60
|
|
|
@@ -91,30 +62,34 @@ export class Alert extends LitElement {
|
|
|
91
62
|
display: block;
|
|
92
63
|
}
|
|
93
64
|
|
|
94
|
-
.hidden {
|
|
95
|
-
display: none !important;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
65
|
/*Rounded*/
|
|
99
66
|
:host([size="2xs"]),
|
|
100
67
|
:host([size="xs"]),
|
|
101
68
|
:host([size="sm"]) {
|
|
102
|
-
--
|
|
69
|
+
--sc-_rounded: var(--sc-rounded-sm);
|
|
103
70
|
}
|
|
104
71
|
|
|
105
72
|
/*Dismissible*/
|
|
106
|
-
|
|
73
|
+
.close-btn {
|
|
74
|
+
flex-shrink: 0;
|
|
75
|
+
align-self: flex-start;
|
|
76
|
+
border-left: var(--sc-border-width, 1px) solid currentColor;
|
|
77
|
+
padding-left: 0.5em;
|
|
78
|
+
margin-left: 0.5em;
|
|
79
|
+
}
|
|
80
|
+
:host([dismissible][background]) {
|
|
107
81
|
padding-right: 3rem;
|
|
108
82
|
}
|
|
109
|
-
:host([dismissible]) .close-btn {
|
|
83
|
+
:host([dismissible][background]) .close-btn {
|
|
110
84
|
position: absolute;
|
|
111
85
|
top: 0.4rem;
|
|
112
86
|
right: 0.3rem;
|
|
87
|
+
border-left: none;
|
|
113
88
|
}
|
|
114
89
|
`,
|
|
115
90
|
];
|
|
116
91
|
/**
|
|
117
|
-
* Titre du message
|
|
92
|
+
* Titre du message (texte brut, utiliser le slot pour du contenu riche)
|
|
118
93
|
*/
|
|
119
94
|
@property({ type: String }) label = "";
|
|
120
95
|
|
|
@@ -125,8 +100,6 @@ export class Alert extends LitElement {
|
|
|
125
100
|
*/
|
|
126
101
|
@property({ type: String }) text = "";
|
|
127
102
|
|
|
128
|
-
@property({ type: String }) id = new Date().getTime().toString();
|
|
129
|
-
|
|
130
103
|
@property({ type: String, reflect: true }) size?: Size;
|
|
131
104
|
|
|
132
105
|
@property({ type: Boolean, reflect: true }) dismissible = false;
|
|
@@ -135,33 +108,58 @@ export class Alert extends LitElement {
|
|
|
135
108
|
|
|
136
109
|
@property({ type: String, reflect: true }) status: AlertStatus = "default";
|
|
137
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Mémorise la fermeture dans le localStorage. Nécessite un `id`.
|
|
113
|
+
*/
|
|
138
114
|
@property({ type: Boolean, reflect: true }) dismissForever = false;
|
|
139
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Annonce le message aux lecteurs d'écran (role alert/status).
|
|
118
|
+
* À activer pour les messages injectés dynamiquement, pas pour une alerte déjà dans la page.
|
|
119
|
+
*/
|
|
120
|
+
@property({ type: Boolean, reflect: true }) announce = false;
|
|
121
|
+
|
|
140
122
|
connectedCallback() {
|
|
141
|
-
if (this.dismissForever) {
|
|
142
|
-
const dismissed = localStorage.getItem("sonic-alert-dismissed") || "{}";
|
|
143
|
-
const dismissedObj = JSON.parse(dismissed);
|
|
144
|
-
if (dismissedObj[this.id]) {
|
|
145
|
-
this.remove();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
123
|
super.connectedCallback();
|
|
124
|
+
if (
|
|
125
|
+
this.dismissForever &&
|
|
126
|
+
this.id &&
|
|
127
|
+
isDismissed(dismissStorageKey, this.id)
|
|
128
|
+
) {
|
|
129
|
+
this.remove();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
willUpdate(changed: PropertyValues<this>) {
|
|
134
|
+
if (changed.has("announce") || changed.has("status")) {
|
|
135
|
+
this._syncAnnounceA11y();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private _syncAnnounceA11y() {
|
|
140
|
+
if (!this.announce) {
|
|
141
|
+
this.removeAttribute("role");
|
|
142
|
+
this.removeAttribute("aria-live");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.setAttribute("role", statusAriaRole(this.status));
|
|
146
|
+
const live = statusAriaLive(this.status);
|
|
147
|
+
if (live) this.setAttribute("aria-live", live);
|
|
148
|
+
else this.removeAttribute("aria-live");
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
render() {
|
|
152
152
|
return html`
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
${this.noIcon
|
|
154
|
+
? nothing
|
|
155
|
+
: html`<slot name="icon">
|
|
156
|
+
<sonic-icon
|
|
157
|
+
aria-hidden="true"
|
|
158
|
+
name=${statusIcon[this.status] ?? statusIcon.default}
|
|
159
|
+
></sonic-icon>
|
|
160
|
+
</slot>`}
|
|
161
161
|
<div class="content">
|
|
162
|
-
${this.label
|
|
163
|
-
? html`<span class="label">${unsafeHTML(this.label)}</span>`
|
|
164
|
-
: nothing}
|
|
162
|
+
${this.label ? html`<span class="label">${this.label}</span>` : nothing}
|
|
165
163
|
<div>${this.text}<slot></slot></div>
|
|
166
164
|
</div>
|
|
167
165
|
${this.dismissible
|
|
@@ -171,6 +169,7 @@ export class Alert extends LitElement {
|
|
|
171
169
|
variant="unstyled"
|
|
172
170
|
shape="circle"
|
|
173
171
|
icon
|
|
172
|
+
.ariaLabel=${resolveUiLabel(uiAriaLabels.closeAlert)}
|
|
174
173
|
>
|
|
175
174
|
<sonic-icon name="cancel"></sonic-icon>
|
|
176
175
|
</sonic-button>`
|
|
@@ -180,15 +179,11 @@ export class Alert extends LitElement {
|
|
|
180
179
|
|
|
181
180
|
close() {
|
|
182
181
|
this.remove();
|
|
183
|
-
|
|
184
|
-
if (this.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
dismissedObj[this.id] = true;
|
|
188
|
-
localStorage.setItem(
|
|
189
|
-
"sonic-alert-dismissed",
|
|
190
|
-
JSON.stringify(dismissedObj)
|
|
191
|
-
);
|
|
182
|
+
if (!this.dismissForever) return;
|
|
183
|
+
if (!this.id) {
|
|
184
|
+
console.warn("sonic-alert : dismissForever nécessite un id.");
|
|
185
|
+
return;
|
|
192
186
|
}
|
|
187
|
+
markDismissed(dismissStorageKey, this.id);
|
|
193
188
|
}
|
|
194
189
|
}
|
|
@@ -4,7 +4,6 @@ import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
|
4
4
|
import { Message } from "@supersoniks/concorde/core/_types/types";
|
|
5
5
|
import { map } from "lit/directives/map.js";
|
|
6
6
|
import { Size } from "@supersoniks/concorde/core/components/ui/_css/size";
|
|
7
|
-
|
|
8
7
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
9
8
|
import { APIResult } from "@supersoniks/concorde/core/components/ui/toast/message-subscriber";
|
|
10
9
|
|
|
@@ -37,6 +36,7 @@ export class AlertMessages extends Subscriber(LitElement, {} as APIResult) {
|
|
|
37
36
|
${map(this.messages, (message) => {
|
|
38
37
|
if (message.type == "public") {
|
|
39
38
|
return html`<sonic-alert
|
|
39
|
+
announce
|
|
40
40
|
status=${message.status || "default"}
|
|
41
41
|
text=${ifDefined(message.content)}
|
|
42
42
|
size=${this.size}
|
|
@@ -1,127 +1,175 @@
|
|
|
1
1
|
# Badge
|
|
2
2
|
|
|
3
|
+
A **non-interactive** pill for labels, counts, or highlights (counter, status, category). The API mirrors `sonic-button` (`type`, `variant`, `size`) without focus or click states.
|
|
4
|
+
|
|
5
|
+
Colors come from theme tokens (`--sc-primary`, `--sc-danger`, …) or the semantic `type` values below.
|
|
6
|
+
|
|
3
7
|
## Type
|
|
8
|
+
|
|
9
|
+
`default` — subtle background (`base-100`). `neutral` — dark fill (`base-content`) with light text, useful on light backgrounds.
|
|
10
|
+
|
|
4
11
|
<sonic-code>
|
|
5
12
|
<template>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
<div class="flex flex-wrap gap-2">
|
|
14
|
+
<sonic-badge>Default</sonic-badge>
|
|
15
|
+
<sonic-badge type="primary">Primary</sonic-badge>
|
|
16
|
+
<sonic-badge type="neutral">Neutral</sonic-badge>
|
|
17
|
+
<sonic-badge type="warning">Warning</sonic-badge>
|
|
18
|
+
<sonic-badge type="info">Info</sonic-badge>
|
|
19
|
+
<sonic-badge type="success">Success</sonic-badge>
|
|
20
|
+
<sonic-badge type="danger">Danger</sonic-badge>
|
|
21
|
+
</div>
|
|
14
22
|
</template>
|
|
15
23
|
</sonic-code>
|
|
16
24
|
|
|
25
|
+
## Variant
|
|
26
|
+
|
|
27
|
+
`outline` — border and text in the `type` color. `ghost` — text only, no padding (except in forced-colors mode).
|
|
17
28
|
|
|
18
29
|
## Outline
|
|
30
|
+
|
|
19
31
|
<sonic-code>
|
|
20
32
|
<template>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</div>
|
|
33
|
+
<div class="flex items-center flex-wrap gap-3">
|
|
34
|
+
<sonic-badge variant="outline">Default</sonic-badge>
|
|
35
|
+
<sonic-badge variant="outline" type="primary">Primary</sonic-badge>
|
|
36
|
+
<sonic-badge variant="outline" type="neutral">Neutral</sonic-badge>
|
|
37
|
+
<sonic-badge variant="outline" type="warning">Warning</sonic-badge>
|
|
38
|
+
<sonic-badge variant="outline" type="info">Info</sonic-badge>
|
|
39
|
+
<sonic-badge variant="outline" type="success">Success</sonic-badge>
|
|
40
|
+
<sonic-badge variant="outline" type="danger">Danger</sonic-badge>
|
|
41
|
+
</div>
|
|
31
42
|
</template>
|
|
32
43
|
</sonic-code>
|
|
33
44
|
|
|
34
45
|
## Ghost
|
|
46
|
+
|
|
35
47
|
<sonic-code>
|
|
36
48
|
<template>
|
|
37
49
|
<div class="flex items-center flex-wrap gap-3">
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</div>
|
|
50
|
+
<sonic-badge variant="ghost">Default</sonic-badge>
|
|
51
|
+
<sonic-badge variant="ghost" type="primary">Primary</sonic-badge>
|
|
52
|
+
<sonic-badge variant="ghost" type="neutral">Neutral</sonic-badge>
|
|
53
|
+
<sonic-badge variant="ghost" type="warning">Warning</sonic-badge>
|
|
54
|
+
<sonic-badge variant="ghost" type="info">Info</sonic-badge>
|
|
55
|
+
<sonic-badge variant="ghost" type="success">Success</sonic-badge>
|
|
56
|
+
<sonic-badge variant="ghost" type="danger">Danger</sonic-badge>
|
|
57
|
+
</div>
|
|
47
58
|
</template>
|
|
48
59
|
</sonic-code>
|
|
49
60
|
|
|
50
61
|
## Size
|
|
62
|
+
|
|
63
|
+
Default size is `md` (omit the `size` attribute). Typography and padding follow `sonic-button`.
|
|
64
|
+
|
|
51
65
|
<sonic-code>
|
|
52
66
|
<template>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
68
|
+
<sonic-badge size="2xs">2Xs</sonic-badge>
|
|
69
|
+
<sonic-badge size="xs">Xs</sonic-badge>
|
|
70
|
+
<sonic-badge size="sm">Sm</sonic-badge>
|
|
71
|
+
<sonic-badge>Md</sonic-badge>
|
|
72
|
+
<sonic-badge size="lg">Lg</sonic-badge>
|
|
73
|
+
<sonic-badge size="xl">Xl</sonic-badge>
|
|
74
|
+
<sonic-badge size="2xl">2Xl</sonic-badge>
|
|
75
|
+
</div>
|
|
60
76
|
</template>
|
|
61
77
|
</sonic-code>
|
|
62
78
|
|
|
79
|
+
## Prefix and suffix slots
|
|
80
|
+
|
|
81
|
+
Icons or short text before / after the main label.
|
|
63
82
|
|
|
64
|
-
## Empty badges
|
|
65
83
|
<sonic-code>
|
|
66
84
|
<template>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<sonic-badge type="
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</div>
|
|
85
|
+
<sonic-badge type="info" size="sm">
|
|
86
|
+
<sonic-icon slot="prefix" name="info-empty" library="iconoir"></sonic-icon>
|
|
87
|
+
Info
|
|
88
|
+
</sonic-badge>
|
|
89
|
+
<sonic-badge type="success">
|
|
90
|
+
Verified
|
|
91
|
+
<sonic-icon slot="suffix" name="check" library="iconoir"></sonic-icon>
|
|
92
|
+
</sonic-badge>
|
|
76
93
|
</template>
|
|
77
94
|
</sonic-code>
|
|
78
95
|
|
|
96
|
+
## Empty badges
|
|
97
|
+
|
|
98
|
+
Badge with no text (visual dot). `min-width` / `min-height` keep a readable shape.
|
|
99
|
+
|
|
100
|
+
<sonic-code>
|
|
101
|
+
<template>
|
|
102
|
+
<div class="flex items-center flex-wrap gap-3">
|
|
103
|
+
<sonic-badge type="danger" size="2xs"></sonic-badge>
|
|
104
|
+
<sonic-badge type="danger" size="xs"></sonic-badge>
|
|
105
|
+
<sonic-badge type="danger" size="sm"></sonic-badge>
|
|
106
|
+
<sonic-badge type="danger"></sonic-badge>
|
|
107
|
+
<sonic-badge type="danger" size="lg"></sonic-badge>
|
|
108
|
+
<sonic-badge type="danger" size="xl"></sonic-badge>
|
|
109
|
+
<sonic-badge type="danger" size="2xl"></sonic-badge>
|
|
110
|
+
</div>
|
|
111
|
+
</template>
|
|
112
|
+
</sonic-code>
|
|
79
113
|
|
|
80
114
|
## Ellipsis
|
|
115
|
+
|
|
116
|
+
With `ellipsis`, long labels truncate. The parent must constrain width (`max-width`, grid, etc.).
|
|
117
|
+
|
|
81
118
|
<sonic-code>
|
|
82
119
|
<template>
|
|
83
|
-
<div class="grid grid-cols-
|
|
84
|
-
|
|
85
|
-
<sonic-icon slot="prefix" name="info-empty" library="iconoir"></sonic-icon>
|
|
86
|
-
|
|
120
|
+
<div class="grid grid-cols-2 gap-4 max-w-xl">
|
|
121
|
+
<sonic-badge ellipsis size="sm" variant="outline">
|
|
122
|
+
<sonic-icon slot="prefix" name="info-empty" library="iconoir"></sonic-icon>
|
|
123
|
+
Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod.
|
|
124
|
+
</sonic-badge>
|
|
125
|
+
<sonic-badge ellipsis size="sm">
|
|
126
|
+
<sonic-icon slot="prefix" name="info-empty" library="iconoir"></sonic-icon>
|
|
127
|
+
Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod.
|
|
128
|
+
</sonic-badge>
|
|
87
129
|
</div>
|
|
88
130
|
</template>
|
|
89
131
|
</sonic-code>
|
|
90
132
|
|
|
91
133
|
## Badge in button
|
|
134
|
+
|
|
135
|
+
Count inside a button (`slot="suffix"`) or a badge absolutely positioned on a button / icon.
|
|
136
|
+
|
|
92
137
|
<sonic-code>
|
|
93
138
|
<template>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</sonic-button>
|
|
98
|
-
<div class="relative inline-block">
|
|
99
|
-
<sonic-button type="success" class="relative"> Mon compte </sonic-button>
|
|
100
|
-
<sonic-badge type="danger" size="xs" class="absolute right-1 top-0 pe-none transform -translate-y-1/2"
|
|
101
|
-
>12</sonic-badge
|
|
102
|
-
>
|
|
103
|
-
</div>
|
|
104
|
-
<div class="relative inline-block">
|
|
105
|
-
<sonic-button type="neutral" shape="circle" variant="outline"
|
|
106
|
-
><sonic-icon library="iconoir" name="user"></sonic-icon>
|
|
107
|
-
</sonic-button>
|
|
108
|
-
<sonic-badge
|
|
109
|
-
type="danger"
|
|
110
|
-
size="xs"
|
|
111
|
-
class="absolute right-1 bottom-1 pe-none transform translate-y-1/2 translate-x-1/2"
|
|
112
|
-
>33</sonic-badge
|
|
113
|
-
>
|
|
114
|
-
</div>
|
|
115
|
-
<div class="relative inline-block">
|
|
116
|
-
<sonic-button type="neutral" shape="circle" variant="outline"
|
|
117
|
-
><sonic-icon library="iconoir" name="user"></sonic-icon>
|
|
139
|
+
<div class="flex flex-wrap gap-4 items-center">
|
|
140
|
+
<sonic-button type="default">
|
|
141
|
+
Messages <sonic-badge slot="suffix" type="danger" size="xs">5</sonic-badge>
|
|
118
142
|
</sonic-button>
|
|
119
|
-
<
|
|
120
|
-
type="
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
143
|
+
<div class="relative inline-block">
|
|
144
|
+
<sonic-button type="success" class="relative">My account</sonic-button>
|
|
145
|
+
<sonic-badge
|
|
146
|
+
type="danger"
|
|
147
|
+
size="xs"
|
|
148
|
+
class="absolute right-1 top-0 pe-none transform -translate-y-1/2"
|
|
149
|
+
>12</sonic-badge
|
|
150
|
+
>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="relative inline-block">
|
|
153
|
+
<sonic-button type="neutral" shape="circle" variant="outline">
|
|
154
|
+
<sonic-icon library="iconoir" name="user"></sonic-icon>
|
|
155
|
+
</sonic-button>
|
|
156
|
+
<sonic-badge
|
|
157
|
+
type="danger"
|
|
158
|
+
size="xs"
|
|
159
|
+
class="absolute right-1 bottom-1 pe-none transform translate-y-1/2 translate-x-1/2"
|
|
160
|
+
>33</sonic-badge
|
|
161
|
+
>
|
|
162
|
+
</div>
|
|
163
|
+
<div class="relative inline-block">
|
|
164
|
+
<sonic-button type="neutral" shape="circle" variant="outline">
|
|
165
|
+
<sonic-icon library="iconoir" name="user"></sonic-icon>
|
|
166
|
+
</sonic-button>
|
|
167
|
+
<sonic-badge
|
|
168
|
+
type="danger"
|
|
169
|
+
size="xs"
|
|
170
|
+
class="absolute right-2 bottom-2 pe-none transform translate-y-1/2 translate-x-1/2"
|
|
171
|
+
></sonic-badge>
|
|
172
|
+
</div>
|
|
124
173
|
</div>
|
|
125
|
-
</div>
|
|
126
174
|
</template>
|
|
127
175
|
</sonic-code>
|