@reliability-design/web 1.0.3 → 1.1.1
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/README.md +132 -0
- package/dist/components/rel-accordion/rel-accordion.ts +47 -16
- package/dist/components/rel-alert/README.md +141 -0
- package/dist/components/rel-alert/rel-alert.ts +101 -20
- package/dist/components/rel-avatar/README.md +119 -0
- package/dist/components/rel-avatar/rel-avatar.ts +3 -2
- package/dist/components/rel-badge/README.md +86 -0
- package/dist/components/rel-badge/rel-badge.ts +11 -7
- package/dist/components/rel-breadcrumb/README.md +102 -0
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +12 -6
- package/dist/components/rel-button/README.md +130 -0
- package/dist/components/rel-button/rel-button.ts +64 -8
- package/dist/components/rel-calendar/README.md +109 -0
- package/dist/components/rel-calendar/index.ts +1 -0
- package/dist/components/rel-calendar/rel-calendar.ts +467 -0
- package/dist/components/rel-card/README.md +94 -0
- package/dist/components/rel-card/rel-card.ts +12 -3
- package/dist/components/rel-cardmedia/README.md +127 -0
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +14 -4
- package/dist/components/rel-carousel/README.md +166 -0
- package/dist/components/rel-carousel/index.ts +1 -0
- package/dist/components/rel-carousel/rel-carousel.ts +468 -0
- package/dist/components/rel-chart/README.md +286 -0
- package/dist/components/rel-chart/index.ts +1 -0
- package/dist/components/rel-chart/rel-chart.ts +736 -0
- package/dist/components/rel-checkbox/README.md +77 -0
- package/dist/components/rel-checkbox/rel-checkbox.ts +51 -12
- package/dist/components/rel-chip/README.md +114 -0
- package/dist/components/rel-chip/rel-chip.ts +83 -9
- package/dist/components/rel-container/README.md +99 -0
- package/dist/components/rel-date-picker/README.md +253 -0
- package/dist/components/rel-date-picker/index.ts +1 -0
- package/dist/components/rel-date-picker/rel-date-picker.ts +916 -0
- package/dist/components/rel-divider/README.md +100 -0
- package/dist/components/rel-divider/rel-divider.ts +9 -0
- package/dist/components/rel-drawer/README.md +200 -0
- package/dist/components/rel-drawer/index.ts +1 -0
- package/dist/components/rel-drawer/rel-drawer-footer.ts +29 -0
- package/dist/components/rel-drawer/rel-drawer.ts +612 -0
- package/dist/components/rel-kbd/README.md +151 -0
- package/dist/components/rel-kbd/rel-kbd.ts +118 -0
- package/dist/components/rel-layout/README.md +88 -0
- package/dist/components/rel-menu/README.md +151 -0
- package/dist/components/rel-menu/rel-menu.ts +64 -24
- package/dist/components/rel-menubar/README.md +329 -0
- package/dist/components/rel-menubar/index.ts +2 -0
- package/dist/components/rel-menubar/rel-menubar-menu.ts +16 -0
- package/dist/components/rel-menubar/rel-menubar.ts +605 -0
- package/dist/components/rel-nav-menu/README.md +289 -0
- package/dist/components/rel-nav-menu/index.ts +3 -0
- package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +240 -0
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +53 -0
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +227 -0
- package/dist/components/rel-navbar/README.md +126 -0
- package/dist/components/rel-navbar/rel-navbar.ts +104 -0
- package/dist/components/rel-otp/README.md +440 -0
- package/dist/components/rel-otp/index.ts +1 -0
- package/dist/components/rel-otp/rel-otp.ts +504 -0
- package/dist/components/rel-pagination/README.md +410 -0
- package/dist/components/rel-pagination/index.ts +1 -0
- package/dist/components/rel-pagination/rel-pagination.ts +381 -0
- package/dist/components/rel-popover/README.md +568 -0
- package/dist/components/rel-popover/index.ts +2 -0
- package/dist/components/rel-popover/rel-popover-content.ts +55 -0
- package/dist/components/rel-popover/rel-popover.ts +330 -0
- package/dist/components/rel-progress/README.md +110 -0
- package/dist/components/rel-progress/rel-progress.ts +32 -5
- package/dist/components/rel-radio/README.md +120 -0
- package/dist/components/rel-radio/rel-radio.ts +31 -6
- package/dist/components/rel-resizable/README.md +140 -0
- package/dist/components/rel-resizable/index.ts +3 -0
- package/dist/components/rel-resizable/rel-resizable-group.ts +374 -0
- package/dist/components/rel-resizable/rel-resizable-handle.ts +145 -0
- package/dist/components/rel-resizable/rel-resizable-panel.ts +47 -0
- package/dist/components/rel-segmented-button/README.md +141 -0
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +18 -13
- package/dist/components/rel-select/README.md +107 -0
- package/dist/components/rel-select/rel-select.ts +28 -14
- package/dist/components/rel-sheet/README.md +224 -0
- package/dist/components/rel-sheet/rel-sheet.ts +684 -0
- package/dist/components/rel-sidebar/README.md +209 -0
- package/dist/components/rel-sidebar/rel-sidebar.ts +1166 -0
- package/dist/components/rel-slider/README.md +135 -0
- package/dist/components/rel-slider/rel-slider.ts +44 -9
- package/dist/components/rel-snackbar/README.md +134 -0
- package/dist/components/rel-snackbar/rel-snackbar.ts +109 -14
- package/dist/components/rel-stepper/README.md +160 -0
- package/dist/components/rel-stepper/rel-stepper.ts +38 -27
- package/dist/components/rel-switch/README.md +102 -0
- package/dist/components/rel-switch/rel-switch.ts +34 -12
- package/dist/components/rel-tab/README.md +163 -0
- package/dist/components/rel-tab/rel-tab.ts +79 -23
- package/dist/components/rel-table/README.md +178 -0
- package/dist/components/rel-table/rel-table-body.ts +21 -0
- package/dist/components/rel-table/rel-table-caption.ts +27 -0
- package/dist/components/rel-table/rel-table-cell.ts +42 -0
- package/dist/components/rel-table/rel-table-footer.ts +23 -0
- package/dist/components/rel-table/rel-table-head.ts +45 -0
- package/dist/components/rel-table/rel-table-header.ts +21 -0
- package/dist/components/rel-table/rel-table-row.ts +36 -0
- package/dist/components/rel-table/rel-table.ts +53 -0
- package/dist/components/rel-textfield/README.md +90 -0
- package/dist/components/rel-textfield/rel-textfield.ts +55 -39
- package/dist/components/rel-toast/README.md +148 -0
- package/dist/components/rel-toast/rel-toast.ts +63 -24
- package/dist/components/rel-tooltip/README.md +103 -0
- package/dist/components/rel-tooltip/rel-tooltip.ts +123 -80
- package/dist/components/rel-topbar/rel-topbar-actions.ts +23 -0
- package/dist/components/rel-topbar/rel-topbar-brand.ts +46 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +33 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +28 -0
- package/dist/components/rel-topbar/rel-topbar-item.ts +315 -0
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +23 -0
- package/dist/components/rel-topbar/rel-topbar-profile.ts +248 -0
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +23 -0
- package/dist/components/rel-topbar/rel-topbar.ts +329 -0
- package/dist/index.d.mts +831 -7
- package/dist/index.d.ts +831 -7
- package/dist/index.js +9500 -1564
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9240 -1344
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +187 -25
- package/dist/vars-TBB4BMSD.css +346 -0
- package/package.json +2 -1
- package/dist/vars-6ZIUPIU4.css +0 -184
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# rel-accordion
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
An animated accordion component with a collapsible body section. Features a clickable header with chevron icon rotation, smooth expand/collapse transitions, and keyboard support. Respects reduced motion preferences.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
```html
|
|
8
|
+
<!-- Basic accordion -->
|
|
9
|
+
<rel-accordion title="Section 1">
|
|
10
|
+
<p>This is the content of section 1.</p>
|
|
11
|
+
</rel-accordion>
|
|
12
|
+
|
|
13
|
+
<!-- Initially open -->
|
|
14
|
+
<rel-accordion title="FAQ: How does it work?" open>
|
|
15
|
+
<p>This accordion starts in the open state.</p>
|
|
16
|
+
<ul>
|
|
17
|
+
<li>Bullet 1</li>
|
|
18
|
+
<li>Bullet 2</li>
|
|
19
|
+
</ul>
|
|
20
|
+
</rel-accordion>
|
|
21
|
+
|
|
22
|
+
<!-- Multiple accordions -->
|
|
23
|
+
<rel-accordion title="Introduction">
|
|
24
|
+
<p>Introduction content...</p>
|
|
25
|
+
</rel-accordion>
|
|
26
|
+
<rel-accordion title="Features">
|
|
27
|
+
<p>Features content...</p>
|
|
28
|
+
</rel-accordion>
|
|
29
|
+
<rel-accordion title="Pricing">
|
|
30
|
+
<p>Pricing content...</p>
|
|
31
|
+
</rel-accordion>
|
|
32
|
+
|
|
33
|
+
<!-- Listen for open state changes -->
|
|
34
|
+
<rel-accordion id="myAccordion" title="Details"></rel-accordion>
|
|
35
|
+
<script>
|
|
36
|
+
const accordion = document.getElementById('myAccordion');
|
|
37
|
+
accordion.addEventListener('open-change', (e) => {
|
|
38
|
+
console.log('Accordion open:', e.detail); // true or false
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
### Attributes/Properties
|
|
46
|
+
| Name | Type | Default | Description |
|
|
47
|
+
|------|------|---------|-------------|
|
|
48
|
+
| `title` | `string` | `"Accordion"` | Header title text |
|
|
49
|
+
| `open` (reflected) | `boolean` | `false` | Whether the accordion is expanded |
|
|
50
|
+
|
|
51
|
+
## Events
|
|
52
|
+
| Event | Detail | Description |
|
|
53
|
+
|-------|--------|-------------|
|
|
54
|
+
| `open-change` | `boolean` | Fired when the accordion is toggled (detail is the new `open` state) |
|
|
55
|
+
|
|
56
|
+
## Slots
|
|
57
|
+
| Slot | Description |
|
|
58
|
+
|------|-------------|
|
|
59
|
+
| (default) | Accordion body content |
|
|
60
|
+
|
|
61
|
+
## CSS Parts
|
|
62
|
+
None exposed.
|
|
63
|
+
|
|
64
|
+
## Tokens / CSS Variables
|
|
65
|
+
|
|
66
|
+
### Semantic Tokens
|
|
67
|
+
- `--rel-fontFamilies-primary` - Font family
|
|
68
|
+
|
|
69
|
+
### Font Tokens
|
|
70
|
+
- `--rel-fontSizes-lg` - Title font size (20px)
|
|
71
|
+
- `--rel-fontSizes-md` - Body font size (14px)
|
|
72
|
+
- `--rel-fontWeights-medium` - Title font weight (500)
|
|
73
|
+
|
|
74
|
+
### Color Tokens
|
|
75
|
+
- `--rel-colors-white` - Background color
|
|
76
|
+
- `--rel-text-heading` - Title text color
|
|
77
|
+
- `--rel-text-primary` - Body text color, icon stroke color
|
|
78
|
+
- `--rel-border-default` - Border color
|
|
79
|
+
- `--rel-border-info` - Focus outline color
|
|
80
|
+
|
|
81
|
+
### Shadow Tokens
|
|
82
|
+
- `--rel-shadows-shadow-100` - Shadow
|
|
83
|
+
|
|
84
|
+
### Border Tokens
|
|
85
|
+
- `--rel-borders-radius-border-radius-200` - Border radius (8px)
|
|
86
|
+
|
|
87
|
+
### Spacing Tokens
|
|
88
|
+
- `--rel-spacing-space-md` - Header horizontal padding, body horizontal padding in closed state (16px)
|
|
89
|
+
- `--rel-spacing-space-xl` - Body top padding when open (24px)
|
|
90
|
+
- `--rel-spacing-space-lg` - Body bottom padding when open (20px)
|
|
91
|
+
|
|
92
|
+
## Accessibility
|
|
93
|
+
- Header uses `role="button"` and `aria-expanded` attribute
|
|
94
|
+
- Header is keyboard accessible with `tabindex="0"`
|
|
95
|
+
- Supports Enter and Space key activation
|
|
96
|
+
- Focus visible outline on keyboard focus
|
|
97
|
+
|
|
98
|
+
### Keyboard Interactions
|
|
99
|
+
| Key | Action |
|
|
100
|
+
|-----|--------|
|
|
101
|
+
| `Enter` | Toggle accordion open/closed |
|
|
102
|
+
| `Space` | Toggle accordion open/closed |
|
|
103
|
+
| `Tab` | Navigate to/from the header |
|
|
104
|
+
|
|
105
|
+
### Focus Behavior
|
|
106
|
+
- Header receives focus outline (`outline: 2px solid --rel-border-info`)
|
|
107
|
+
- Focus offset is `-2px` inset
|
|
108
|
+
|
|
109
|
+
## Notes / Edge Cases
|
|
110
|
+
- **Animation details**:
|
|
111
|
+
- Chevron rotates 180° when open (`transform: rotate(180deg)`)
|
|
112
|
+
- Body expands from `max-height: 0` to `max-height: 1000px`
|
|
113
|
+
- Body padding animates from `0` to full padding when opening
|
|
114
|
+
- Transitions: `transform 0.25s ease`, `max-height 0.25s ease`, `padding 0.2s ease`
|
|
115
|
+
|
|
116
|
+
- **Reduced motion**: When `prefers-reduced-motion: reduce`, icon rotation and body transitions are disabled
|
|
117
|
+
|
|
118
|
+
- **Body rendering**: The slotted content is always in the DOM (not conditionally rendered), but hidden via `max-height: 0` and `overflow: hidden` when closed
|
|
119
|
+
|
|
120
|
+
- The header has hover styling (`background: --rel-surface-surface`)
|
|
121
|
+
|
|
122
|
+
- The component is `display: block` and `width: 100%`
|
|
123
|
+
|
|
124
|
+
- The accordion border is `1px solid` with rounded corners
|
|
125
|
+
|
|
126
|
+
- The chevron icon is an inline SVG (9-point downward-pointing chevron)
|
|
127
|
+
|
|
128
|
+
- When closed, the body has `padding: 0 var(--rel-spacing-space-md)` to maintain horizontal padding
|
|
129
|
+
|
|
130
|
+
- The `open` attribute is reflected in HTML when set
|
|
131
|
+
|
|
132
|
+
- Multiple accordions can be open simultaneously (no automatic closing of others)
|
|
@@ -10,13 +10,13 @@ export class RelAccordion extends LitElement {
|
|
|
10
10
|
:host {
|
|
11
11
|
display: block;
|
|
12
12
|
width: 100%;
|
|
13
|
-
font-family: var(--rel-fontFamilies-primary);
|
|
13
|
+
font-family: var(--rel-fontFamilies-primary, sans-serif);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.accordion {
|
|
17
|
-
background: var(--rel-colors-white);
|
|
18
|
-
border: 1px solid var(--rel-border-default);
|
|
19
|
-
border-radius: var(--rel-borders-radius-border-radius-200);
|
|
17
|
+
background: var(--rel-colors-white, #fff);
|
|
18
|
+
border: 1px solid var(--rel-border-default, #ddd);
|
|
19
|
+
border-radius: var(--rel-borders-radius-border-radius-200, 8px);
|
|
20
20
|
box-shadow: var(--rel-shadows-shadow-100);
|
|
21
21
|
overflow: hidden;
|
|
22
22
|
}
|
|
@@ -26,15 +26,29 @@ export class RelAccordion extends LitElement {
|
|
|
26
26
|
display: flex;
|
|
27
27
|
justify-content: space-between;
|
|
28
28
|
align-items: center;
|
|
29
|
-
padding: var(--rel-spacing-space-md);
|
|
29
|
+
padding: var(--rel-spacing-space-md, 16px);
|
|
30
30
|
cursor: pointer;
|
|
31
31
|
user-select: none;
|
|
32
|
+
border-radius: var(--rel-borders-radius-border-radius-200, 8px);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.header:hover {
|
|
36
|
+
background: var(--rel-surface-surface, #f5f5f5);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host([open]) .header:hover {
|
|
40
|
+
background: transparent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.header:focus-visible {
|
|
44
|
+
outline: 2px solid var(--rel-border-info, #0091ea);
|
|
45
|
+
outline-offset: -2px;
|
|
32
46
|
}
|
|
33
47
|
|
|
34
48
|
.title {
|
|
35
|
-
font-size: var(--rel-fontSizes-lg);
|
|
36
|
-
font-weight: var(--rel-fontWeights-medium);
|
|
37
|
-
color: var(--rel-
|
|
49
|
+
font-size: var(--rel-fontSizes-lg, 20px);
|
|
50
|
+
font-weight: var(--rel-fontWeights-medium, 500);
|
|
51
|
+
color: var(--rel-text-heading, #2b2b2b);
|
|
38
52
|
}
|
|
39
53
|
|
|
40
54
|
/* ICON ----------------------------------------------------- */
|
|
@@ -50,7 +64,7 @@ export class RelAccordion extends LitElement {
|
|
|
50
64
|
.icon svg {
|
|
51
65
|
width: 20px;
|
|
52
66
|
height: 20px;
|
|
53
|
-
stroke: var(--rel-
|
|
67
|
+
stroke: var(--rel-text-primary, #333);
|
|
54
68
|
stroke-width: 2;
|
|
55
69
|
fill: none;
|
|
56
70
|
stroke-linecap: round;
|
|
@@ -65,16 +79,23 @@ export class RelAccordion extends LitElement {
|
|
|
65
79
|
.body {
|
|
66
80
|
overflow: hidden;
|
|
67
81
|
max-height: 0;
|
|
68
|
-
padding: 0 var(--rel-spacing-space-md);
|
|
69
|
-
font-size: var(--rel-fontSizes-
|
|
70
|
-
color: var(--rel-
|
|
82
|
+
padding: 0 var(--rel-spacing-space-md, 16px);
|
|
83
|
+
font-size: var(--rel-fontSizes-md, 14px);
|
|
84
|
+
color: var(--rel-text-primary, #333);
|
|
71
85
|
transition: max-height 0.25s ease, padding 0.2s ease;
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
.body.open {
|
|
75
|
-
max-height: 1000px;
|
|
76
|
-
padding: var(--rel-spacing-space-xl) var(--rel-spacing-space-md)
|
|
77
|
-
var(--rel-spacing-space-lg);
|
|
89
|
+
max-height: 1000px;
|
|
90
|
+
padding: var(--rel-spacing-space-xl, 24px) var(--rel-spacing-space-md, 16px)
|
|
91
|
+
var(--rel-spacing-space-lg, 20px);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@media (prefers-reduced-motion: reduce) {
|
|
95
|
+
.icon,
|
|
96
|
+
.body {
|
|
97
|
+
transition: none;
|
|
98
|
+
}
|
|
78
99
|
}
|
|
79
100
|
`;
|
|
80
101
|
|
|
@@ -101,7 +122,17 @@ export class RelAccordion extends LitElement {
|
|
|
101
122
|
render() {
|
|
102
123
|
return html`
|
|
103
124
|
<div class="accordion">
|
|
104
|
-
<div class="header"
|
|
125
|
+
<div class="header"
|
|
126
|
+
role="button"
|
|
127
|
+
tabindex="0"
|
|
128
|
+
aria-expanded="${this.open}"
|
|
129
|
+
@click=${this.toggle}
|
|
130
|
+
@keydown=${(e: KeyboardEvent) => {
|
|
131
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
this.toggle();
|
|
134
|
+
}
|
|
135
|
+
}}>
|
|
105
136
|
<div class="title">${this.title}</div>
|
|
106
137
|
|
|
107
138
|
<div class="icon ${this.open ? "rotated" : ""}">
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# rel-alert
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
A versatile alert component for displaying informational, success, warning, error, or neutral messages. Features built-in icons, optional dismissibility, secondary message text, and inline links. Automatically hides when dismissed via the `dismissed` reflected attribute.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
```html
|
|
8
|
+
<!-- Basic neutral alert -->
|
|
9
|
+
<rel-alert
|
|
10
|
+
message1="This is a neutral alert"
|
|
11
|
+
type="neutral">
|
|
12
|
+
</rel-alert>
|
|
13
|
+
|
|
14
|
+
<!-- Info alert with secondary message -->
|
|
15
|
+
<rel-alert
|
|
16
|
+
type="info"
|
|
17
|
+
message1="System Notification"
|
|
18
|
+
message2="Your settings have been updated successfully.">
|
|
19
|
+
</rel-alert>
|
|
20
|
+
|
|
21
|
+
<!-- Success alert -->
|
|
22
|
+
<rel-alert
|
|
23
|
+
type="success"
|
|
24
|
+
message1="Operation Completed"
|
|
25
|
+
message2="Your data has been saved.">
|
|
26
|
+
</rel-alert>
|
|
27
|
+
|
|
28
|
+
<!-- Warning alert -->
|
|
29
|
+
<rel-alert
|
|
30
|
+
type="warning"
|
|
31
|
+
message1="Warning"
|
|
32
|
+
message2="Please verify your input before continuing.">
|
|
33
|
+
</rel-alert>
|
|
34
|
+
|
|
35
|
+
<!-- Error alert -->
|
|
36
|
+
<rel-alert
|
|
37
|
+
type="error"
|
|
38
|
+
message1="Error Occurred"
|
|
39
|
+
message2="Unable to process your request.">
|
|
40
|
+
</rel-alert>
|
|
41
|
+
|
|
42
|
+
<!-- With action link -->
|
|
43
|
+
<rel-alert
|
|
44
|
+
type="info"
|
|
45
|
+
message1="Update Available"
|
|
46
|
+
message2="A new version is ready."
|
|
47
|
+
urlText="Learn More"
|
|
48
|
+
urlHref="https://example.com/release-notes">
|
|
49
|
+
</rel-alert>
|
|
50
|
+
|
|
51
|
+
<!-- Non-dismissible -->
|
|
52
|
+
<rel-alert
|
|
53
|
+
type="warning"
|
|
54
|
+
message1="Required Action"
|
|
55
|
+
dismissible="false">
|
|
56
|
+
</rel-alert>
|
|
57
|
+
|
|
58
|
+
<!-- Listen for dismiss -->
|
|
59
|
+
<rel-alert id="myAlert" type="success" message1="Success!"></rel-alert>
|
|
60
|
+
<script>
|
|
61
|
+
const alert = document.getElementById('myAlert');
|
|
62
|
+
alert.addEventListener('dismiss', () => {
|
|
63
|
+
console.log('Alert was dismissed');
|
|
64
|
+
});
|
|
65
|
+
</script>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
### Attributes/Properties
|
|
71
|
+
| Name | Type | Default | Description |
|
|
72
|
+
|------|------|---------|-------------|
|
|
73
|
+
| `type` | `"info" \| "success" \| "warning" \| "error" \| "neutral"` | `"neutral"` | Alert type determining icon and color scheme |
|
|
74
|
+
| `message1` | `string` | `""` | Primary message text (bold) |
|
|
75
|
+
| `message2` | `string` | - | Optional secondary message text (smaller, slightly transparent) |
|
|
76
|
+
| `urlText` | `string` | - | Link text (shown below messages) |
|
|
77
|
+
| `urlHref` | `string` | - | Link URL (both `urlText` and `urlHref` required for link to show) |
|
|
78
|
+
| `dismissible` | `boolean` | `true` | Whether to show the close (✕) button |
|
|
79
|
+
| `dismissed` | `boolean` (reflected) | `false` | When true, hides the component via `:host([dismissed])` |
|
|
80
|
+
|
|
81
|
+
## Events
|
|
82
|
+
| Event | Detail | Description |
|
|
83
|
+
|-------|--------|-------------|
|
|
84
|
+
| `dismiss` | None | Fired when the close button is clicked (sets `dismissed` to true) |
|
|
85
|
+
|
|
86
|
+
## Slots
|
|
87
|
+
Default slot not used.
|
|
88
|
+
|
|
89
|
+
## CSS Parts
|
|
90
|
+
None exposed.
|
|
91
|
+
|
|
92
|
+
## Tokens / CSS Variables
|
|
93
|
+
|
|
94
|
+
### Semantic Tokens
|
|
95
|
+
- `--rel-fontFamilies-primary` - Font family
|
|
96
|
+
- `--rel-fontSizes-md` - Primary message font size
|
|
97
|
+
- `--rel-fontSizes-sm` - Secondary message and link font size
|
|
98
|
+
- `--rel-fontWeights-medium` - Primary message and link font weight
|
|
99
|
+
- `--rel-fontWeights-semibold` - Used implicitly in link styling
|
|
100
|
+
|
|
101
|
+
### Spacing Tokens
|
|
102
|
+
- `--rel-spacing-space-xs` - Gap between icon and content
|
|
103
|
+
- `--rel-spacing-space-sm` - Vertical padding
|
|
104
|
+
- `--rel-spacing-space-md` - Horizontal padding
|
|
105
|
+
- `--rel-spacing-space-2xs` - Close button padding
|
|
106
|
+
|
|
107
|
+
### Color Tokens (by type)
|
|
108
|
+
- **info**: `--rel-background-info` (background), `--rel-text-info` (text), `--rel-icon-info` (icon)
|
|
109
|
+
- **success**: `--rel-background-success`, `--rel-text-success`, `--rel-icon-success`
|
|
110
|
+
- **warning**: `--rel-background-warning`, `--rel-text-warning`, `--rel-icon-warning`
|
|
111
|
+
- **error**: `--rel-background-error`, `--rel-text-error`, `--rel-icon-error`
|
|
112
|
+
- **neutral**: `--rel-colors-white` (background), `--rel-text-primary` (text), `--rel-colors-black` (icon), `--rel-border-default` (border)
|
|
113
|
+
|
|
114
|
+
### Border Tokens
|
|
115
|
+
- `--rel-borders-radius-border-radius-200` - Border radius
|
|
116
|
+
|
|
117
|
+
## Accessibility
|
|
118
|
+
- Uses `role="alert"` for screen reader announcements
|
|
119
|
+
- Close button has `aria-label="Dismiss"`
|
|
120
|
+
- Focus visible states on close button with 2px outline
|
|
121
|
+
- Secondary message has reduced opacity for visual hierarchy
|
|
122
|
+
|
|
123
|
+
### Keyboard Interactions
|
|
124
|
+
- `Tab` - Focus the close button (if dismissible)
|
|
125
|
+
- `Space/Enter` - Dismiss the alert (when close button focused)
|
|
126
|
+
|
|
127
|
+
### Focus Behavior
|
|
128
|
+
- Close button shows 2px outline matching the alert's text color with 2px offset
|
|
129
|
+
- Border radius applied to maintain visual consistency
|
|
130
|
+
|
|
131
|
+
## Notes / Edge Cases
|
|
132
|
+
- Icons are built-in SVG graphics that change based on `type` (info: ℹ️, success: ✓, warning: ⚠️, error: ❗, neutral: ℹ️)
|
|
133
|
+
- Icon colors are controlled by type-specific `--rel-icon-*` tokens
|
|
134
|
+
- The alert has a minimum width of `360px`
|
|
135
|
+
- Both `urlText` and `urlHref` must be set for the link to appear
|
|
136
|
+
- Links inherit the alert's text color and are underlined
|
|
137
|
+
- `message2` has `opacity: 0.9` for subtle contrast with `message1`
|
|
138
|
+
- When `dismissed` is set to `true`, the component applies `display: none` via `:host([dismissed])`
|
|
139
|
+
- `dismissed` is a reflected attribute, meaning it appears in the HTML when true
|
|
140
|
+
- The close button is always positioned at the right edge via `margin-left: auto`
|
|
141
|
+
- Neutral type includes a 1px border while colored types do not
|
|
@@ -72,37 +72,118 @@ export class RelAlert extends LitElement {
|
|
|
72
72
|
border: none;
|
|
73
73
|
cursor: pointer;
|
|
74
74
|
opacity: 0.6;
|
|
75
|
+
color: inherit;
|
|
76
|
+
font-size: 16px;
|
|
77
|
+
padding: var(--rel-spacing-space-2xs);
|
|
78
|
+
line-height: 1;
|
|
79
|
+
border-radius: var(--rel-borders-radius-border-radius-100, 4px);
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
.rel-close:hover {
|
|
78
83
|
opacity: 1;
|
|
79
84
|
}
|
|
80
85
|
|
|
81
|
-
|
|
86
|
+
.rel-close:focus-visible {
|
|
87
|
+
outline: 2px solid currentColor;
|
|
88
|
+
outline-offset: 2px;
|
|
89
|
+
opacity: 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* COLORS — light mode (pinned Figma hex) */
|
|
93
|
+
.alert-neutral {
|
|
94
|
+
background: #ffffff;
|
|
95
|
+
color: #000000;
|
|
96
|
+
}
|
|
97
|
+
|
|
82
98
|
.alert-info {
|
|
83
|
-
background:
|
|
84
|
-
color:
|
|
99
|
+
background: #E1F2FF;
|
|
100
|
+
color: #000000;
|
|
101
|
+
--rel-icon-info: #0059F4;
|
|
85
102
|
}
|
|
86
103
|
|
|
87
104
|
.alert-success {
|
|
88
|
-
background:
|
|
89
|
-
color:
|
|
105
|
+
background: #E2FEEE;
|
|
106
|
+
color: #000000;
|
|
107
|
+
--rel-icon-success: #00A86B;
|
|
90
108
|
}
|
|
91
109
|
|
|
92
110
|
.alert-warning {
|
|
93
|
-
background:
|
|
94
|
-
color:
|
|
111
|
+
background: #F6EFD7;
|
|
112
|
+
color: #000000;
|
|
113
|
+
--rel-icon-warning: #F2915C;
|
|
95
114
|
}
|
|
96
115
|
|
|
97
116
|
.alert-error {
|
|
98
|
-
background:
|
|
99
|
-
color:
|
|
117
|
+
background: #FFDEDE;
|
|
118
|
+
color: #9C1E33;
|
|
119
|
+
--rel-icon-error: #9C1E33;
|
|
100
120
|
}
|
|
101
121
|
|
|
102
|
-
.alert-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
.alert-error .rel-close {
|
|
123
|
+
color: #000000;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* COLORS — dark mode (pinned Figma hex) */
|
|
127
|
+
:host-context([data-theme="dark"]) .rel-alert,
|
|
128
|
+
:host-context(.dark) .rel-alert {
|
|
129
|
+
background: #2B2B2B;
|
|
130
|
+
color: #ffffff;
|
|
131
|
+
border: none;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:host-context([data-theme="dark"]) .rel-close,
|
|
135
|
+
:host-context(.dark) .rel-close {
|
|
136
|
+
color: #ffffff;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
:host-context([data-theme="dark"]) .alert-neutral,
|
|
140
|
+
:host-context(.dark) .alert-neutral {
|
|
141
|
+
border: 1px solid #ffffff;
|
|
142
|
+
--rel-colors-black: #ffffff;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:host-context([data-theme="dark"]) .alert-info,
|
|
146
|
+
:host-context(.dark) .alert-info {
|
|
147
|
+
border: 1px solid #0059F4;
|
|
148
|
+
--rel-icon-info: #0059F4;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
:host-context([data-theme="dark"]) .alert-info .rel-message2,
|
|
152
|
+
:host-context(.dark) .alert-info .rel-message2 {
|
|
153
|
+
color: #0059F4;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
:host-context([data-theme="dark"]) .alert-warning,
|
|
157
|
+
:host-context(.dark) .alert-warning {
|
|
158
|
+
border: 1px solid #F2915C;
|
|
159
|
+
--rel-icon-warning: #F2915C;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
:host-context([data-theme="dark"]) .alert-warning .rel-message2,
|
|
163
|
+
:host-context(.dark) .alert-warning .rel-message2 {
|
|
164
|
+
color: #F2915C;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
:host-context([data-theme="dark"]) .alert-success,
|
|
168
|
+
:host-context(.dark) .alert-success {
|
|
169
|
+
border: 1px solid #00A86B;
|
|
170
|
+
--rel-icon-success: #00A86B;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
:host-context([data-theme="dark"]) .alert-success .rel-message2,
|
|
174
|
+
:host-context(.dark) .alert-success .rel-message2 {
|
|
175
|
+
color: #00A86B;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
:host-context([data-theme="dark"]) .alert-error,
|
|
179
|
+
:host-context(.dark) .alert-error {
|
|
180
|
+
border: 1px solid #9C1E33;
|
|
181
|
+
--rel-icon-error: #9C1E33;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
:host-context([data-theme="dark"]) .alert-error .rel-message2,
|
|
185
|
+
:host-context(.dark) .alert-error .rel-message2 {
|
|
186
|
+
color: #9C1E33;
|
|
106
187
|
}
|
|
107
188
|
`;
|
|
108
189
|
|
|
@@ -130,7 +211,7 @@ export class RelAlert extends LitElement {
|
|
|
130
211
|
>
|
|
131
212
|
<path
|
|
132
213
|
d="M9 4.75C8.75917 4.75 8.55715 4.8316 8.39395 4.9948C8.23132 5.15743 8.15 5.35917 8.15 5.6C8.15 5.84083 8.23132 6.04285 8.39395 6.20605C8.55715 6.36868 8.75917 6.45 9 6.45C9.24083 6.45 9.44257 6.36868 9.6052 6.20605C9.7684 6.04285 9.85 5.84083 9.85 5.6C9.85 5.35917 9.7684 5.15743 9.6052 4.9948C9.44257 4.8316 9.24083 4.75 9 4.75ZM9.85 8.15L8.15 8.15L8.15 13.25L9.85 13.25L9.85 8.15ZM9 0.499999C10.1758 0.499999 11.2808 0.723266 12.315 1.1698C13.3492 1.61633 14.2488 2.22182 15.0138 2.98625C15.7788 3.75068 16.3842 4.65027 16.8302 5.685C17.2762 6.71973 17.4994 7.82473 17.5 9C17.5006 10.1753 17.2773 11.2803 16.8302 12.315C16.3842 13.3492 15.7787 14.2487 15.0137 15.0137C14.2487 15.7787 13.3492 16.3845 12.315 16.831C11.2808 17.2776 10.1758 17.5006 9 17.5C7.82417 17.4994 6.71917 17.2764 5.685 16.831C4.65083 16.3845 3.75125 15.7787 2.98625 15.0137C2.22125 14.2487 1.61577 13.3492 1.1698 12.315C0.723834 11.2808 0.500567 10.1758 0.500001 9C0.499434 7.82417 0.722701 6.71917 1.1698 5.685C1.61577 4.65083 2.22125 3.75125 2.98625 2.98625C3.75125 2.22125 4.65084 1.61577 5.685 1.1698C6.71917 0.723832 7.82417 0.500566 9 0.499999ZM9 2.2C7.10167 2.2 5.49375 2.85875 4.17625 4.17625C2.85875 5.49375 2.2 7.10167 2.2 9C2.2 10.8983 2.85875 12.5062 4.17625 13.8237C5.49375 15.1412 7.10167 15.8 9 15.8C10.8983 15.8 12.5062 15.1412 13.8237 13.8237C15.1412 12.5062 15.8 10.8983 15.8 9C15.8 7.10167 15.1413 5.49375 13.8238 4.17625C12.5063 2.85875 10.8983 2.2 9 2.2Z"
|
|
133
|
-
fill="
|
|
214
|
+
fill="var(--rel-icon-info)"
|
|
134
215
|
/>
|
|
135
216
|
</svg>
|
|
136
217
|
`;
|
|
@@ -145,7 +226,7 @@ export class RelAlert extends LitElement {
|
|
|
145
226
|
>
|
|
146
227
|
<path
|
|
147
228
|
d="M7.81 12.91L13.8025 6.9175L12.6125 5.7275L7.81 10.53L5.3875 8.1075L4.1975 9.2975L7.81 12.91ZM9 17.5C7.82417 17.5 6.71917 17.2767 5.685 16.8302C4.65083 16.3837 3.75125 15.7782 2.98625 15.0138C2.22125 14.2493 1.61577 13.3497 1.1698 12.315C0.723834 11.2803 0.500568 10.1753 0.500001 9C0.499434 7.82473 0.722701 6.71973 1.1698 5.685C1.61577 4.65083 2.22125 3.75125 2.98625 2.98625C3.75125 2.22125 4.65083 1.61548 5.685 1.16895C6.71917 0.722418 7.82417 0.499434 9 0.500001C10.1758 0.500568 11.2808 0.723551 12.315 1.16895C13.3492 1.61548 14.2488 2.22125 15.0138 2.98625C15.7788 3.75125 16.3842 4.65083 16.8302 5.685C17.2762 6.71917 17.4994 7.82417 17.5 9C17.5006 10.1758 17.2773 11.2808 16.8302 12.315C16.3842 13.3492 15.7788 14.2488 15.0138 15.0138C14.2488 15.7788 13.3492 16.3842 12.315 16.8302C11.2808 17.2762 10.1758 17.4994 9 17.5ZM9 15.8C10.8983 15.8 12.5062 15.1412 13.8237 13.8237C15.1412 12.5062 15.8 10.8983 15.8 9C15.8 7.10167 15.1412 5.49375 13.8237 4.17625C12.5062 2.85875 10.8983 2.2 9 2.2C7.10167 2.2 5.49375 2.85875 4.17625 4.17625C2.85875 5.49375 2.2 7.10167 2.2 9C2.2 10.8983 2.85875 12.5062 4.17625 13.8237C5.49375 15.1412 7.10167 15.8 9 15.8Z"
|
|
148
|
-
fill="
|
|
229
|
+
fill="var(--rel-icon-success)"
|
|
149
230
|
/>
|
|
150
231
|
</svg>
|
|
151
232
|
`;
|
|
@@ -160,7 +241,7 @@ export class RelAlert extends LitElement {
|
|
|
160
241
|
>
|
|
161
242
|
<path
|
|
162
243
|
d="M0 14L8 0L16 14H0ZM2.50909 12.5263H13.4909L8 2.94737L2.50909 12.5263ZM8 11.7895C8.20606 11.7895 8.37891 11.7187 8.51855 11.5773C8.6577 11.4363 8.72727 11.2614 8.72727 11.0526C8.72727 10.8439 8.6577 10.669 8.51855 10.528C8.37891 10.3865 8.20606 10.3158 8 10.3158C7.79394 10.3158 7.62133 10.3865 7.48218 10.528C7.34255 10.669 7.27273 10.8439 7.27273 11.0526C7.27273 11.2614 7.34255 11.4363 7.48218 11.5773C7.62133 11.7187 7.79394 11.7895 8 11.7895ZM7.27273 9.57895H8.72727V5.89474H7.27273V9.57895Z"
|
|
163
|
-
fill="
|
|
244
|
+
fill="var(--rel-icon-warning)"
|
|
164
245
|
/>
|
|
165
246
|
</svg>
|
|
166
247
|
`;
|
|
@@ -175,7 +256,7 @@ export class RelAlert extends LitElement {
|
|
|
175
256
|
>
|
|
176
257
|
<path
|
|
177
258
|
d="M9 13.25C9.24083 13.25 9.44285 13.1684 9.60605 13.0052C9.76868 12.8426 9.85 12.6408 9.85 12.4C9.85 12.1592 9.76868 11.9571 9.60605 11.7939C9.44285 11.6313 9.24083 11.55 9 11.55C8.75917 11.55 8.55743 11.6313 8.3948 11.7939C8.2316 11.9571 8.15 12.1592 8.15 12.4C8.15 12.6408 8.2316 12.8426 8.3948 13.0052C8.55743 13.1684 8.75917 13.25 9 13.25ZM8.15 9.85H9.85V4.75H8.15V9.85ZM9 17.5C7.82417 17.5 6.71917 17.2767 5.685 16.8302C4.65083 16.3837 3.75125 15.7782 2.98625 15.0138C2.22125 14.2493 1.61577 13.3497 1.1698 12.315C0.723834 11.2803 0.500568 10.1753 0.500001 9C0.499434 7.82473 0.722701 6.71973 1.1698 5.685C1.61577 4.65083 2.22125 3.75125 2.98625 2.98625C3.75125 2.22125 4.65083 1.61548 5.685 1.16895C6.71917 0.722418 7.82417 0.499434 9 0.500001C10.1758 0.500568 11.2808 0.723551 12.315 1.16895C13.3492 1.61548 14.2488 2.22125 15.0138 2.98625C15.7788 3.75125 16.3842 4.65083 16.8302 5.685C17.2762 6.71917 17.4994 7.82417 17.5 9C17.5006 10.1758 17.2773 11.2808 16.8302 12.315C16.3842 13.3492 15.7788 14.2488 15.0138 15.0138C14.2488 15.7788 13.3492 16.3842 12.315 16.8302C11.2808 17.2762 10.1758 17.4994 9 17.5ZM9 15.8C10.8983 15.8 12.5062 15.1412 13.8237 13.8237C15.1412 12.5062 15.8 10.8983 15.8 9C15.8 7.10167 15.1412 5.49375 13.8237 4.17625C12.5062 2.85875 10.8983 2.2 9 2.2C7.10167 2.2 5.49375 2.85875 4.17625 4.17625C2.85875 5.49375 2.2 7.10167 2.2 9C2.2 10.8983 2.85875 12.5062 4.17625 13.8237C5.49375 15.1412 7.10167 15.8 9 15.8Z"
|
|
178
|
-
fill="
|
|
259
|
+
fill="var(--rel-icon-error)"
|
|
179
260
|
/>
|
|
180
261
|
</svg>
|
|
181
262
|
`;
|
|
@@ -190,7 +271,7 @@ export class RelAlert extends LitElement {
|
|
|
190
271
|
>
|
|
191
272
|
<path
|
|
192
273
|
d="M9 4.75C8.75917 4.75 8.55715 4.8316 8.39395 4.9948C8.23132 5.15743 8.15 5.35917 8.15 5.6C8.15 5.84083 8.23132 6.04285 8.39395 6.20605C8.55715 6.36868 8.75917 6.45 9 6.45C9.24083 6.45 9.44257 6.36868 9.6052 6.20605C9.7684 6.04285 9.85 5.84083 9.85 5.6C9.85 5.35917 9.7684 5.15743 9.6052 4.9948C9.44257 4.8316 9.24083 4.75 9 4.75ZM9.85 8.15L8.15 8.15L8.15 13.25L9.85 13.25L9.85 8.15ZM9 0.499999C10.1758 0.499999 11.2808 0.723266 12.315 1.1698C13.3492 1.61633 14.2488 2.22182 15.0138 2.98625C15.7788 3.75068 16.3842 4.65027 16.8302 5.685C17.2762 6.71973 17.4994 7.82473 17.5 9C17.5006 10.1753 17.2773 11.2803 16.8302 12.315C16.3842 13.3492 15.7787 14.2487 15.0137 15.0137C14.2487 15.7787 13.3492 16.3845 12.315 16.831C11.2808 17.2776 10.1758 17.5006 9 17.5C7.82417 17.4994 6.71917 17.2764 5.685 16.831C4.65083 16.3845 3.75125 15.7787 2.98625 15.0137C2.22125 14.2487 1.61577 13.3492 1.1698 12.315C0.723834 11.2808 0.500567 10.1758 0.500001 9C0.499434 7.82417 0.722701 6.71917 1.1698 5.685C1.61577 4.65083 2.22125 3.75125 2.98625 2.98625C3.75125 2.22125 4.65084 1.61577 5.685 1.1698C6.71917 0.723832 7.82417 0.500566 9 0.499999ZM9 2.2C7.10167 2.2 5.49375 2.85875 4.17625 4.17625C2.85875 5.49375 2.2 7.10167 2.2 9C2.2 10.8983 2.85875 12.5062 4.17625 13.8237C5.49375 15.1412 7.10167 15.8 9 15.8C10.8983 15.8 12.5062 15.1412 13.8237 13.8237C15.1412 12.5062 15.8 10.8983 15.8 9C15.8 7.10167 15.1413 5.49375 13.8238 4.17625C12.5063 2.85875 10.8983 2.2 9 2.2Z"
|
|
193
|
-
fill="black"
|
|
274
|
+
fill="var(--rel-colors-black)"
|
|
194
275
|
/>
|
|
195
276
|
</svg>
|
|
196
277
|
`;
|
|
@@ -199,7 +280,7 @@ export class RelAlert extends LitElement {
|
|
|
199
280
|
|
|
200
281
|
render() {
|
|
201
282
|
return html`
|
|
202
|
-
<div class="rel-alert alert-${this.type}">
|
|
283
|
+
<div class="rel-alert alert-${this.type}" role="alert">
|
|
203
284
|
<div class="rel-icon">${this.iconSvg}</div>
|
|
204
285
|
|
|
205
286
|
<div class="rel-content">
|
|
@@ -216,7 +297,7 @@ export class RelAlert extends LitElement {
|
|
|
216
297
|
</div>
|
|
217
298
|
|
|
218
299
|
${this.dismissible
|
|
219
|
-
? html`<button class="rel-close" @click=${this.dismissAlert}>
|
|
300
|
+
? html`<button class="rel-close" @click=${this.dismissAlert} aria-label="Dismiss">
|
|
220
301
|
✕
|
|
221
302
|
</button>`
|
|
222
303
|
: null}
|