@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,150 @@
|
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
export type SegmentSize = "small" | "medium";
|
|
5
|
+
export type SegmentAlign = "left" | "middle" | "right";
|
|
6
|
+
|
|
7
|
+
export interface SegmentOption {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@customElement("rel-segmented-button")
|
|
14
|
+
export class RelSegmentedButton extends LitElement {
|
|
15
|
+
@property({ type: Array }) options: SegmentOption[] = [];
|
|
16
|
+
|
|
17
|
+
@property({ type: String }) active: string = "";
|
|
18
|
+
|
|
19
|
+
@property({ type: String }) size: SegmentSize = "medium";
|
|
20
|
+
|
|
21
|
+
@property({ type: String }) align: SegmentAlign = "left";
|
|
22
|
+
|
|
23
|
+
static styles = css`
|
|
24
|
+
:host {
|
|
25
|
+
display: inline-block;
|
|
26
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.segmented-buttons {
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
border: 2px solid var(--rel-colors-gray-border);
|
|
32
|
+
border-radius: var(--rel-borders-radius-border-radius-300);
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Alignment */
|
|
37
|
+
.align-left {
|
|
38
|
+
justify-content: flex-start;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.align-middle {
|
|
42
|
+
justify-content: center;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.align-right {
|
|
46
|
+
justify-content: flex-end;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Base segment styling */
|
|
50
|
+
.segment {
|
|
51
|
+
background: var(--rel-colors-white);
|
|
52
|
+
border: none;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
font-weight: var(--rel-fontWeights-medium);
|
|
55
|
+
border-right: 2px solid var(--rel-colors-gray-border);
|
|
56
|
+
transition: all 0.2s ease-in-out;
|
|
57
|
+
color: var(--rel-colors-gray-heading);
|
|
58
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
59
|
+
outline: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.segment:last-child {
|
|
63
|
+
border-right: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Hover */
|
|
67
|
+
.segment:hover:not(.disabled):not(.active) {
|
|
68
|
+
background: var(--rel-colors-gray-bg);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Active */
|
|
72
|
+
.segment.active {
|
|
73
|
+
background: var(--rel-colors-black);
|
|
74
|
+
color: var(--rel-colors-white);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.segment.active:hover:not(.disabled) {
|
|
78
|
+
background: var(--rel-colors-black);
|
|
79
|
+
color: var(--rel-colors-white);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Disabled */
|
|
83
|
+
.segment.disabled,
|
|
84
|
+
.segment:disabled {
|
|
85
|
+
cursor: not-allowed;
|
|
86
|
+
opacity: 0.5;
|
|
87
|
+
background: var(--rel-colors-gray-bg);
|
|
88
|
+
color: var(--rel-colors-gray-placeholder);
|
|
89
|
+
pointer-events: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Sizes */
|
|
93
|
+
.segmented-buttons.small .segment {
|
|
94
|
+
padding: var(--rel-spacing-space-3xs) var(--rel-spacing-space-xs);
|
|
95
|
+
font-size: var(--rel-fontSizes-xs);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.segmented-buttons.medium .segment {
|
|
99
|
+
padding: var(--rel-spacing-space-2xs) var(--rel-spacing-space-sm);
|
|
100
|
+
font-size: var(--rel-fontSizes-sm);
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
private setActive(option: SegmentOption) {
|
|
105
|
+
if (!option.disabled) {
|
|
106
|
+
this.active = option.value;
|
|
107
|
+
this.dispatchEvent(
|
|
108
|
+
new CustomEvent("changed", {
|
|
109
|
+
detail: { value: option.value },
|
|
110
|
+
bubbles: true,
|
|
111
|
+
composed: true,
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private renderSegment(option: SegmentOption) {
|
|
118
|
+
const isActive = this.active === option.value;
|
|
119
|
+
const classes = [
|
|
120
|
+
"segment",
|
|
121
|
+
isActive ? "active" : "",
|
|
122
|
+
option.disabled ? "disabled" : "",
|
|
123
|
+
]
|
|
124
|
+
.filter(Boolean)
|
|
125
|
+
.join(" ");
|
|
126
|
+
|
|
127
|
+
return html`
|
|
128
|
+
<button
|
|
129
|
+
class="${classes}"
|
|
130
|
+
?disabled="${option.disabled}"
|
|
131
|
+
@click="${() => this.setActive(option)}">
|
|
132
|
+
${option.label}
|
|
133
|
+
</button>
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
render() {
|
|
138
|
+
const containerClasses = [
|
|
139
|
+
"segmented-buttons",
|
|
140
|
+
this.size,
|
|
141
|
+
`align-${this.align}`,
|
|
142
|
+
].join(" ");
|
|
143
|
+
|
|
144
|
+
return html`
|
|
145
|
+
<div class="${containerClasses}">
|
|
146
|
+
${this.options.map((option) => this.renderSegment(option))}
|
|
147
|
+
</div>
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
}
|