@reliability-design/web 1.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/dist/components/rel-accordion/rel-accordion.stories.ts +313 -0
- package/dist/components/rel-accordion/rel-accordion.ts +114 -0
- package/dist/components/rel-alert/rel-alert.stories.ts +412 -0
- package/dist/components/rel-alert/rel-alert.ts +194 -0
- package/dist/components/rel-avatar/rel-avatar.stories.ts +327 -0
- package/dist/components/rel-avatar/rel-avatar.ts +100 -0
- package/dist/components/rel-badge/rel-badge.stories.ts +350 -0
- package/dist/components/rel-badge/rel-badge.ts +70 -0
- package/dist/components/rel-breadcrumb/rel-breadcrumb.stories.ts +306 -0
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +97 -0
- package/dist/components/rel-button/rel-button.stories.ts +356 -0
- package/dist/components/rel-button/rel-button.ts +204 -0
- package/dist/components/rel-card/rel-card.stories.ts +299 -0
- package/dist/components/rel-card/rel-card.ts +33 -0
- package/dist/components/rel-cardmedia/rel-cardmedia.stories.ts +368 -0
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +80 -0
- package/dist/components/rel-checkbox/rel-checkbox.stories.ts +414 -0
- package/dist/components/rel-checkbox/rel-checkbox.ts +164 -0
- package/dist/components/rel-chip/rel-chip.stories.ts +552 -0
- package/dist/components/rel-chip/rel-chip.ts +261 -0
- package/dist/components/rel-container/rel-container.stories.ts +239 -0
- package/dist/components/rel-container/rel-container.ts +74 -0
- package/dist/components/rel-divider/rel-divider.stories.ts +229 -0
- package/dist/components/rel-divider/rel-divider.ts +44 -0
- package/dist/components/rel-layout/rel-layout.stories.ts +713 -0
- package/dist/components/rel-layout/rel-layout.ts +60 -0
- package/dist/components/rel-menu/rel-menu.stories.ts +910 -0
- package/dist/components/rel-menu/rel-menu.ts +319 -0
- package/dist/components/rel-progress/rel-progress.stories.ts +817 -0
- package/dist/components/rel-progress/rel-progress.ts +182 -0
- package/dist/components/rel-radio/rel-radio.stories.ts +1048 -0
- package/dist/components/rel-radio/rel-radio.ts +187 -0
- package/dist/components/rel-segmented-button/rel-segmented-button.stories.ts +1079 -0
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +150 -0
- package/dist/components/rel-select/rel-select.stories.ts +1201 -0
- package/dist/components/rel-select/rel-select.ts +261 -0
- package/dist/components/rel-slider/rel-slider.stories.ts +730 -0
- package/dist/components/rel-slider/rel-slider.ts +440 -0
- package/dist/components/rel-snackbar/rel-snackbar.stories.ts +808 -0
- package/dist/components/rel-snackbar/rel-snackbar.ts +212 -0
- package/dist/components/rel-stepper/rel-stepper.stories.ts +752 -0
- package/dist/components/rel-stepper/rel-stepper.ts +425 -0
- package/dist/components/rel-switch/rel-switch.stories.ts +441 -0
- package/dist/components/rel-switch/rel-switch.ts +161 -0
- package/dist/components/rel-tab/rel-tab.stories.ts +492 -0
- package/dist/components/rel-tab/rel-tab.ts +145 -0
- package/dist/components/rel-textfield/rel-textfield.stories.ts +710 -0
- package/dist/components/rel-textfield/rel-textfield.ts +224 -0
- package/dist/components/rel-toast/rel-toast.stories.ts +394 -0
- package/dist/components/rel-toast/rel-toast.ts +154 -0
- package/dist/components/rel-tooltip/rel-tooltip.stories.ts +364 -0
- package/dist/components/rel-tooltip/rel-tooltip.ts +80 -0
- package/dist/index.d.mts +372 -0
- package/dist/index.d.ts +372 -0
- package/dist/index.js +4593 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4544 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles/vars.css +184 -0
- package/package.json +32 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
export type SnackbarLines = "single" | "double";
|
|
5
|
+
|
|
6
|
+
@customElement("rel-snackbar")
|
|
7
|
+
export class RelSnackbar extends LitElement {
|
|
8
|
+
@property({ type: String }) message: string = "This is a snackbar message";
|
|
9
|
+
|
|
10
|
+
@property({ type: String }) action?: string;
|
|
11
|
+
|
|
12
|
+
@property({ type: Boolean }) longerAction: boolean = false;
|
|
13
|
+
|
|
14
|
+
@property({ type: Boolean }) iconClose: boolean = true;
|
|
15
|
+
|
|
16
|
+
@property({ type: String }) lines: SnackbarLines = "single";
|
|
17
|
+
|
|
18
|
+
@property({ type: Number }) duration: number = 4000;
|
|
19
|
+
|
|
20
|
+
@state() private visible: boolean = true;
|
|
21
|
+
|
|
22
|
+
private timeout: number | null = null;
|
|
23
|
+
|
|
24
|
+
static styles = css`
|
|
25
|
+
:host {
|
|
26
|
+
display: block;
|
|
27
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.snackbar {
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
align-items: center;
|
|
34
|
+
min-width: 280px;
|
|
35
|
+
max-width: 500px;
|
|
36
|
+
margin: 0;
|
|
37
|
+
padding: 12px 16px;
|
|
38
|
+
border-radius: var(--rel-borders-radius-border-radius-200);
|
|
39
|
+
background-color: var(--rel-colors-black);
|
|
40
|
+
color: var(--rel-colors-white);
|
|
41
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
42
|
+
box-shadow: var(--rel-shadows-shadow-300);
|
|
43
|
+
animation: slide-up 0.3s ease-out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.snackbar.two-line {
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
align-items: stretch;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.snackbar.hidden {
|
|
52
|
+
display: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.snackbar-message {
|
|
56
|
+
font-size: var(--rel-fontSizes-sm);
|
|
57
|
+
line-height: var(--rel-lineHeights-lineheight-200);
|
|
58
|
+
margin-right: 12px;
|
|
59
|
+
flex: 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.snackbar.two-line .snackbar-message {
|
|
63
|
+
margin-right: 0;
|
|
64
|
+
margin-bottom: 8px;
|
|
65
|
+
flex: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.snackbar-actions {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: var(--rel-spacing-space-2xs);
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
align-self: center;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.snackbar.two-line .snackbar-actions {
|
|
77
|
+
align-self: flex-end;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.snackbar-action {
|
|
81
|
+
background: none;
|
|
82
|
+
border: none;
|
|
83
|
+
color: var(--rel-colors-green-secondary);
|
|
84
|
+
font-weight: var(--rel-fontWeights-semibold);
|
|
85
|
+
font-size: var(--rel-fontSizes-sm);
|
|
86
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
padding: 0;
|
|
89
|
+
transition: opacity 0.2s ease;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.snackbar-action:hover {
|
|
93
|
+
opacity: 0.8;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.snackbar-action:active {
|
|
97
|
+
opacity: 0.6;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.snackbar-close {
|
|
101
|
+
background: none;
|
|
102
|
+
border: none;
|
|
103
|
+
color: var(--rel-colors-white);
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
font-size: 16px;
|
|
106
|
+
padding: 0;
|
|
107
|
+
width: 20px;
|
|
108
|
+
height: 20px;
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
transition: opacity 0.2s ease;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.snackbar-close:hover {
|
|
116
|
+
opacity: 0.8;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.snackbar-close:active {
|
|
120
|
+
opacity: 0.6;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@keyframes slide-up {
|
|
124
|
+
from {
|
|
125
|
+
transform: translateY(50px);
|
|
126
|
+
opacity: 0;
|
|
127
|
+
}
|
|
128
|
+
to {
|
|
129
|
+
transform: translateY(0);
|
|
130
|
+
opacity: 1;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
connectedCallback() {
|
|
136
|
+
super.connectedCallback();
|
|
137
|
+
this.setAutoDismiss();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
disconnectedCallback() {
|
|
141
|
+
super.disconnectedCallback();
|
|
142
|
+
this.clearTimeout();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private setAutoDismiss() {
|
|
146
|
+
if (this.duration > 0) {
|
|
147
|
+
this.clearTimeout();
|
|
148
|
+
const delay = this.longerAction ? this.duration * 2 : this.duration;
|
|
149
|
+
this.timeout = window.setTimeout(() => this.dismiss(), delay);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private clearTimeout() {
|
|
154
|
+
if (this.timeout !== null) {
|
|
155
|
+
window.clearTimeout(this.timeout);
|
|
156
|
+
this.timeout = null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private onActionClick() {
|
|
161
|
+
this.dispatchEvent(
|
|
162
|
+
new CustomEvent("actionClick", {
|
|
163
|
+
bubbles: true,
|
|
164
|
+
composed: true,
|
|
165
|
+
})
|
|
166
|
+
);
|
|
167
|
+
this.dismiss();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private dismiss() {
|
|
171
|
+
this.visible = false;
|
|
172
|
+
this.dispatchEvent(
|
|
173
|
+
new CustomEvent("close", {
|
|
174
|
+
bubbles: true,
|
|
175
|
+
composed: true,
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
render() {
|
|
181
|
+
const snackbarClasses = [
|
|
182
|
+
"snackbar",
|
|
183
|
+
this.lines === "double" ? "two-line" : "",
|
|
184
|
+
!this.visible ? "hidden" : "",
|
|
185
|
+
]
|
|
186
|
+
.filter(Boolean)
|
|
187
|
+
.join(" ");
|
|
188
|
+
|
|
189
|
+
return html`
|
|
190
|
+
<div class="${snackbarClasses}">
|
|
191
|
+
<div class="snackbar-message">${this.message}</div>
|
|
192
|
+
|
|
193
|
+
<div class="snackbar-actions">
|
|
194
|
+
${this.action
|
|
195
|
+
? html`
|
|
196
|
+
<button class="snackbar-action" @click="${this.onActionClick}">
|
|
197
|
+
${this.action}
|
|
198
|
+
</button>
|
|
199
|
+
`
|
|
200
|
+
: ""}
|
|
201
|
+
${this.iconClose
|
|
202
|
+
? html`
|
|
203
|
+
<button class="snackbar-close" @click="${this.dismiss}">
|
|
204
|
+
✖
|
|
205
|
+
</button>
|
|
206
|
+
`
|
|
207
|
+
: ""}
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
`;
|
|
211
|
+
}
|
|
212
|
+
}
|