@reliability-design/web 1.0.3 → 1.0.6
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 +43 -16
- package/dist/components/rel-alert/README.md +141 -0
- package/dist/components/rel-alert/rel-alert.ts +18 -7
- package/dist/components/rel-avatar/README.md +119 -0
- package/dist/components/rel-badge/README.md +86 -0
- package/dist/components/rel-badge/rel-badge.ts +6 -6
- 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-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 +469 -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 +18 -10
- package/dist/components/rel-chip/README.md +114 -0
- package/dist/components/rel-chip/rel-chip.ts +20 -4
- 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-drawer/README.md +200 -0
- package/dist/components/rel-drawer/index.ts +1 -0
- package/dist/components/rel-drawer/rel-drawer.ts +621 -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 +18 -10
- 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 +576 -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 +143 -0
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +53 -0
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +331 -0
- package/dist/components/rel-navbar/README.md +126 -0
- package/dist/components/rel-navbar/rel-navbar.ts +91 -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 +376 -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 +327 -0
- package/dist/components/rel-progress/README.md +110 -0
- package/dist/components/rel-progress/rel-progress.ts +32 -5
- package/dist/components/rel-quote-page/README.md +166 -0
- package/dist/components/rel-quote-page/rel-quote-page.ts +816 -0
- package/dist/components/rel-radio/README.md +120 -0
- package/dist/components/rel-radio/rel-radio.ts +13 -5
- 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 +149 -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 +14 -14
- package/dist/components/rel-sheet/README.md +224 -0
- package/dist/components/rel-sheet/rel-sheet.ts +683 -0
- package/dist/components/rel-sidebar/README.md +209 -0
- package/dist/components/rel-sidebar/rel-sidebar.ts +1158 -0
- package/dist/components/rel-slider/README.md +135 -0
- package/dist/components/rel-slider/rel-slider.ts +19 -7
- package/dist/components/rel-snackbar/README.md +134 -0
- package/dist/components/rel-snackbar/rel-snackbar.ts +67 -2
- package/dist/components/rel-stepper/README.md +160 -0
- package/dist/components/rel-stepper/rel-stepper.ts +6 -6
- package/dist/components/rel-switch/README.md +102 -0
- package/dist/components/rel-switch/rel-switch.ts +15 -6
- package/dist/components/rel-tab/README.md +163 -0
- package/dist/components/rel-tab/rel-tab.ts +36 -14
- package/dist/components/rel-table/README.md +178 -0
- package/dist/components/rel-table/rel-table-body.ts +16 -0
- package/dist/components/rel-table/rel-table-caption.ts +22 -0
- package/dist/components/rel-table/rel-table-cell.ts +49 -0
- package/dist/components/rel-table/rel-table-footer.ts +18 -0
- package/dist/components/rel-table/rel-table-head.ts +33 -0
- package/dist/components/rel-table/rel-table-header.ts +16 -0
- package/dist/components/rel-table/rel-table-row.ts +32 -0
- package/dist/components/rel-table/rel-table.ts +47 -0
- package/dist/components/rel-textfield/README.md +90 -0
- package/dist/components/rel-textfield/rel-textfield.ts +35 -19
- package/dist/components/rel-toast/README.md +148 -0
- package/dist/components/rel-toast/rel-toast.ts +32 -14
- package/dist/components/rel-tooltip/README.md +103 -0
- package/dist/components/rel-tooltip/rel-tooltip.ts +9 -9
- package/dist/index.d.mts +836 -1
- package/dist/index.d.ts +836 -1
- package/dist/index.js +10658 -1493
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10616 -1499
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +293 -183
- package/dist/{vars-6ZIUPIU4.css → vars-ITL2K3KO.css} +293 -183
- package/package.json +1 -1
|
@@ -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,25 @@ 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
|
+
.header:focus-visible {
|
|
40
|
+
outline: 2px solid var(--rel-border-info, #0091ea);
|
|
41
|
+
outline-offset: -2px;
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
.title {
|
|
35
|
-
font-size: var(--rel-fontSizes-lg);
|
|
36
|
-
font-weight: var(--rel-fontWeights-medium);
|
|
37
|
-
color: var(--rel-
|
|
45
|
+
font-size: var(--rel-fontSizes-lg, 20px);
|
|
46
|
+
font-weight: var(--rel-fontWeights-medium, 500);
|
|
47
|
+
color: var(--rel-text-heading, #2b2b2b);
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
/* ICON ----------------------------------------------------- */
|
|
@@ -50,7 +60,7 @@ export class RelAccordion extends LitElement {
|
|
|
50
60
|
.icon svg {
|
|
51
61
|
width: 20px;
|
|
52
62
|
height: 20px;
|
|
53
|
-
stroke: var(--rel-
|
|
63
|
+
stroke: var(--rel-text-primary, #333);
|
|
54
64
|
stroke-width: 2;
|
|
55
65
|
fill: none;
|
|
56
66
|
stroke-linecap: round;
|
|
@@ -65,16 +75,23 @@ export class RelAccordion extends LitElement {
|
|
|
65
75
|
.body {
|
|
66
76
|
overflow: hidden;
|
|
67
77
|
max-height: 0;
|
|
68
|
-
padding: 0 var(--rel-spacing-space-md);
|
|
69
|
-
font-size: var(--rel-fontSizes-
|
|
70
|
-
color: var(--rel-
|
|
78
|
+
padding: 0 var(--rel-spacing-space-md, 16px);
|
|
79
|
+
font-size: var(--rel-fontSizes-md, 14px);
|
|
80
|
+
color: var(--rel-text-primary, #333);
|
|
71
81
|
transition: max-height 0.25s ease, padding 0.2s ease;
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
.body.open {
|
|
75
|
-
max-height: 1000px;
|
|
76
|
-
padding: var(--rel-spacing-space-xl) var(--rel-spacing-space-md)
|
|
77
|
-
var(--rel-spacing-space-lg);
|
|
85
|
+
max-height: 1000px;
|
|
86
|
+
padding: var(--rel-spacing-space-xl, 24px) var(--rel-spacing-space-md, 16px)
|
|
87
|
+
var(--rel-spacing-space-lg, 20px);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@media (prefers-reduced-motion: reduce) {
|
|
91
|
+
.icon,
|
|
92
|
+
.body {
|
|
93
|
+
transition: none;
|
|
94
|
+
}
|
|
78
95
|
}
|
|
79
96
|
`;
|
|
80
97
|
|
|
@@ -101,7 +118,17 @@ export class RelAccordion extends LitElement {
|
|
|
101
118
|
render() {
|
|
102
119
|
return html`
|
|
103
120
|
<div class="accordion">
|
|
104
|
-
<div class="header"
|
|
121
|
+
<div class="header"
|
|
122
|
+
role="button"
|
|
123
|
+
tabindex="0"
|
|
124
|
+
aria-expanded="${this.open}"
|
|
125
|
+
@click=${this.toggle}
|
|
126
|
+
@keydown=${(e: KeyboardEvent) => {
|
|
127
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
this.toggle();
|
|
130
|
+
}
|
|
131
|
+
}}>
|
|
105
132
|
<div class="title">${this.title}</div>
|
|
106
133
|
|
|
107
134
|
<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,12 +72,23 @@ 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
|
|
|
86
|
+
.rel-close:focus-visible {
|
|
87
|
+
outline: 2px solid currentColor;
|
|
88
|
+
outline-offset: 2px;
|
|
89
|
+
opacity: 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
81
92
|
/* COLORS */
|
|
82
93
|
.alert-info {
|
|
83
94
|
background: var(--rel-background-info);
|
|
@@ -130,7 +141,7 @@ export class RelAlert extends LitElement {
|
|
|
130
141
|
>
|
|
131
142
|
<path
|
|
132
143
|
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="
|
|
144
|
+
fill="var(--rel-icon-info)"
|
|
134
145
|
/>
|
|
135
146
|
</svg>
|
|
136
147
|
`;
|
|
@@ -145,7 +156,7 @@ export class RelAlert extends LitElement {
|
|
|
145
156
|
>
|
|
146
157
|
<path
|
|
147
158
|
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="
|
|
159
|
+
fill="var(--rel-icon-success)"
|
|
149
160
|
/>
|
|
150
161
|
</svg>
|
|
151
162
|
`;
|
|
@@ -160,7 +171,7 @@ export class RelAlert extends LitElement {
|
|
|
160
171
|
>
|
|
161
172
|
<path
|
|
162
173
|
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="
|
|
174
|
+
fill="var(--rel-icon-warning)"
|
|
164
175
|
/>
|
|
165
176
|
</svg>
|
|
166
177
|
`;
|
|
@@ -175,7 +186,7 @@ export class RelAlert extends LitElement {
|
|
|
175
186
|
>
|
|
176
187
|
<path
|
|
177
188
|
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="
|
|
189
|
+
fill="var(--rel-icon-error)"
|
|
179
190
|
/>
|
|
180
191
|
</svg>
|
|
181
192
|
`;
|
|
@@ -190,7 +201,7 @@ export class RelAlert extends LitElement {
|
|
|
190
201
|
>
|
|
191
202
|
<path
|
|
192
203
|
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"
|
|
204
|
+
fill="var(--rel-colors-black)"
|
|
194
205
|
/>
|
|
195
206
|
</svg>
|
|
196
207
|
`;
|
|
@@ -199,7 +210,7 @@ export class RelAlert extends LitElement {
|
|
|
199
210
|
|
|
200
211
|
render() {
|
|
201
212
|
return html`
|
|
202
|
-
<div class="rel-alert alert-${this.type}">
|
|
213
|
+
<div class="rel-alert alert-${this.type}" role="alert">
|
|
203
214
|
<div class="rel-icon">${this.iconSvg}</div>
|
|
204
215
|
|
|
205
216
|
<div class="rel-content">
|
|
@@ -216,7 +227,7 @@ export class RelAlert extends LitElement {
|
|
|
216
227
|
</div>
|
|
217
228
|
|
|
218
229
|
${this.dismissible
|
|
219
|
-
? html`<button class="rel-close" @click=${this.dismissAlert}>
|
|
230
|
+
? html`<button class="rel-close" @click=${this.dismissAlert} aria-label="Dismiss">
|
|
220
231
|
✕
|
|
221
232
|
</button>`
|
|
222
233
|
: null}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# rel-avatar
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
A circular avatar component supporting three display types: image, text initials, or custom icon content. Provides four size variants with automatic text transformation and SVG sizing for icons.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
```html
|
|
8
|
+
<!-- Image avatar -->
|
|
9
|
+
<rel-avatar
|
|
10
|
+
type="image"
|
|
11
|
+
src="./user-photo.jpg"
|
|
12
|
+
alt="John Doe">
|
|
13
|
+
</rel-avatar>
|
|
14
|
+
|
|
15
|
+
<!-- Text initials avatar -->
|
|
16
|
+
<rel-avatar
|
|
17
|
+
type="text"
|
|
18
|
+
text="JD">
|
|
19
|
+
</rel-avatar>
|
|
20
|
+
|
|
21
|
+
<!-- Icon avatar with slotted SVG -->
|
|
22
|
+
<rel-avatar type="icon">
|
|
23
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
24
|
+
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
|
|
25
|
+
</svg>
|
|
26
|
+
</rel-avatar>
|
|
27
|
+
|
|
28
|
+
<!-- Different sizes -->
|
|
29
|
+
<rel-avatar type="text" text="XS" size="xs"></rel-avatar>
|
|
30
|
+
<rel-avatar type="text" text="SM" size="sm"></rel-avatar>
|
|
31
|
+
<rel-avatar type="text" text="MD" size="md"></rel-avatar>
|
|
32
|
+
<rel-avatar type="text" text="LG" size="lg"></rel-avatar>
|
|
33
|
+
|
|
34
|
+
<!-- User list with avatars -->
|
|
35
|
+
<div style="display: flex; gap: 8px; align-items: center;">
|
|
36
|
+
<rel-avatar type="image" src="user1.jpg" size="sm"></rel-avatar>
|
|
37
|
+
<span>John Doe</span>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- Avatar group -->
|
|
41
|
+
<div style="display: flex; margin-left: -8px;">
|
|
42
|
+
<rel-avatar type="text" text="A" size="md" style="margin-left: -8px;"></rel-avatar>
|
|
43
|
+
<rel-avatar type="text" text="B" size="md" style="margin-left: -8px;"></rel-avatar>
|
|
44
|
+
<rel-avatar type="text" text="C" size="md" style="margin-left: -8px;"></rel-avatar>
|
|
45
|
+
</div>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### Attributes/Properties
|
|
51
|
+
| Name | Type | Default | Description |
|
|
52
|
+
|------|------|---------|-------------|
|
|
53
|
+
| `size` (reflected) | `"lg" \| "md" \| "sm" \| "xs"` | `"md"` | Avatar size variant |
|
|
54
|
+
| `type` (reflected) | `"image" \| "text" \| "icon"` | `"image"` | Display type |
|
|
55
|
+
| `src` | `string` | `""` | Image URL (for `type="image"`) |
|
|
56
|
+
| `text` | `string` | `""` | Text content (for `type="text"`, usually initials) |
|
|
57
|
+
| `alt` | `string` | `"Avatar"` | Alt text for the image |
|
|
58
|
+
|
|
59
|
+
## Events
|
|
60
|
+
None.
|
|
61
|
+
|
|
62
|
+
## Slots
|
|
63
|
+
| Slot | Description |
|
|
64
|
+
|------|-------------|
|
|
65
|
+
| (default) | Custom icon content (for `type="icon"`, typically an SVG) |
|
|
66
|
+
|
|
67
|
+
## CSS Parts
|
|
68
|
+
None exposed.
|
|
69
|
+
|
|
70
|
+
## Tokens / CSS Variables
|
|
71
|
+
|
|
72
|
+
### Semantic Tokens
|
|
73
|
+
- `--rel-fontFamilies-primary` - Font family
|
|
74
|
+
|
|
75
|
+
### Font Tokens
|
|
76
|
+
- `--rel-fontSizes-xl` - Large avatar text size
|
|
77
|
+
- `--rel-fontSizes-lg` - Medium avatar text size
|
|
78
|
+
- `--rel-fontSizes-md` - Small avatar text size
|
|
79
|
+
- `--rel-fontSizes-xs` - Extra small avatar text size
|
|
80
|
+
- `--rel-fontWeights-bold` - Text font weight
|
|
81
|
+
|
|
82
|
+
### Color Tokens
|
|
83
|
+
- `--rel-colors-gray-heading` - Avatar background color
|
|
84
|
+
- `--rel-colors-white` - Text/icon color
|
|
85
|
+
|
|
86
|
+
## Accessibility
|
|
87
|
+
- Image avatars include `alt` attribute for screen readers
|
|
88
|
+
- Text is automatically uppercased for consistency
|
|
89
|
+
- Ensure meaningful `alt` text is provided for image avatars
|
|
90
|
+
|
|
91
|
+
### Keyboard Interactions
|
|
92
|
+
- None (purely presentational)
|
|
93
|
+
|
|
94
|
+
### Focus Behavior
|
|
95
|
+
- Does not receive focus
|
|
96
|
+
|
|
97
|
+
## Notes / Edge Cases
|
|
98
|
+
- **Size variants**:
|
|
99
|
+
- **lg**: 40px × 40px, font-size: `--rel-fontSizes-xl`
|
|
100
|
+
- **md**: 32px × 32px, font-size: `--rel-fontSizes-lg`
|
|
101
|
+
- **sm**: 24px × 24px, font-size: `--rel-fontSizes-md`
|
|
102
|
+
- **xs**: 18px × 18px, font-size: `--rel-fontSizes-xs`
|
|
103
|
+
|
|
104
|
+
- **Display types**:
|
|
105
|
+
- **image**: Displays an `<img>` with `src` and `alt`
|
|
106
|
+
- Uses `object-fit: cover` for proper image scaling
|
|
107
|
+
- Image is `width: 100%`, `height: 100%`
|
|
108
|
+
- **text**: Displays the `text` property in a `<span>`
|
|
109
|
+
- Text is automatically uppercased via `text-transform: uppercase`
|
|
110
|
+
- **icon**: Displays slotted content (typically SVG)
|
|
111
|
+
- Slotted SVGs are automatically sized to 50% of the avatar size
|
|
112
|
+
|
|
113
|
+
- The avatar is always circular via `border-radius: 50%`
|
|
114
|
+
- The avatar uses `overflow: hidden` to clip images to circle shape
|
|
115
|
+
- Text and icons are centered using flexbox
|
|
116
|
+
- The avatar is `inline-flex` for easy inline usage with text
|
|
117
|
+
- The `size` and `type` attributes are reflected in HTML
|
|
118
|
+
- The component uses `user-select: none` to prevent text selection
|
|
119
|
+
- If `type` is `image` but `src` is empty, nothing is displayed (no fallback)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# rel-badge
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
A simple notification badge component displaying numeric counts or dot indicators. Supports three sizes (sm, md, lg) and two variants (number, dot). Ideal for indicating counts, status, or notifications in UI elements.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
```html
|
|
8
|
+
<!-- Number badges -->
|
|
9
|
+
<rel-badge number="5"></rel-badge>
|
|
10
|
+
<rel-badge number="12" size="md"></rel-badge>
|
|
11
|
+
<rel-badge number="99+" size="lg"></rel-badge>
|
|
12
|
+
|
|
13
|
+
<!-- Dot badges (no number shown) -->
|
|
14
|
+
<rel-badge variant="dot" size="sm"></rel-badge>
|
|
15
|
+
<rel-badge variant="dot" size="md"></rel-badge>
|
|
16
|
+
<rel-badge variant="dot" size="lg"></rel-badge>
|
|
17
|
+
|
|
18
|
+
<!-- Common use case: Badge on icon/button -->
|
|
19
|
+
<div style="position: relative; display: inline-block;">
|
|
20
|
+
<button>🔔 Notifications</button>
|
|
21
|
+
<rel-badge number="3" size="sm" style="position: absolute; top: -8px; right: -8px;"></rel-badge>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<!-- Sizes comparison -->
|
|
25
|
+
<rel-badge number="1" size="sm"></rel-badge>
|
|
26
|
+
<rel-badge number="2" size="md"></rel-badge>
|
|
27
|
+
<rel-badge number="3" size="lg"></rel-badge>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API
|
|
31
|
+
|
|
32
|
+
### Attributes/Properties
|
|
33
|
+
| Name | Type | Default | Description |
|
|
34
|
+
|------|------|---------|-------------|
|
|
35
|
+
| `number` | `string` | `""` | Text to display in number variant (can be numeric or text like "99+") |
|
|
36
|
+
| `size` | `"sm" \| "md" \| "lg"` (reflected) | `"md"` | Size variant |
|
|
37
|
+
| `variant` | `"dot" \| "number"` (reflected) | `"number"` | Display mode (number shows text, dot shows indicator only) |
|
|
38
|
+
|
|
39
|
+
## Events
|
|
40
|
+
None.
|
|
41
|
+
|
|
42
|
+
## Slots
|
|
43
|
+
Default slot not used.
|
|
44
|
+
|
|
45
|
+
## CSS Parts
|
|
46
|
+
None exposed.
|
|
47
|
+
|
|
48
|
+
## Tokens / CSS Variables
|
|
49
|
+
|
|
50
|
+
### Semantic Tokens
|
|
51
|
+
- `--rel-fontFamilies-primary` - Font family
|
|
52
|
+
- `--rel-fontWeights-semibold` - Font weight (number variant)
|
|
53
|
+
- `--rel-fontSizes-xs`, `--rel-fontSizes-sm`, `--rel-fontSizes-lg` - Font sizes for number variant sizes
|
|
54
|
+
|
|
55
|
+
### Color Tokens
|
|
56
|
+
- `--rel-colors-red-primary` - Background color
|
|
57
|
+
- `--rel-colors-white` - Text color
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
- Purely visual indicator (no ARIA roles)
|
|
61
|
+
- For critical information, ensure accompanying text or ARIA labels on parent elements
|
|
62
|
+
- Screen readers will not announce badge content unless used with proper labeling
|
|
63
|
+
|
|
64
|
+
### Keyboard Interactions
|
|
65
|
+
- None (not focusable)
|
|
66
|
+
|
|
67
|
+
### Focus Behavior
|
|
68
|
+
- Not focusable
|
|
69
|
+
|
|
70
|
+
## Notes / Edge Cases
|
|
71
|
+
- **Number variant sizes**:
|
|
72
|
+
- **sm**: 20px × 20px, 12px font
|
|
73
|
+
- **md**: 28px × 28px, 14px font
|
|
74
|
+
- **lg**: 40px × 40px, 20px font
|
|
75
|
+
- **Dot variant sizes**:
|
|
76
|
+
- **sm**: 8px × 8px
|
|
77
|
+
- **md**: 10px × 10px
|
|
78
|
+
- **lg**: 12px × 12px
|
|
79
|
+
- All badges are circular (`border-radius: 50%`)
|
|
80
|
+
- The `number` property accepts any string (e.g., "99+", "NEW", or numeric values)
|
|
81
|
+
- In dot variant, the `number` property is ignored and nothing is rendered inside
|
|
82
|
+
- The component is `display: inline-flex` for easy positioning
|
|
83
|
+
- Badges use `justify-content: center` and `align-items: center` for centering content
|
|
84
|
+
- `size` and `variant` are reflected attributes (appear in HTML when set)
|
|
85
|
+
- Common pattern: position badges absolutely over parent elements (e.g., icons, avatar images)
|
|
86
|
+
- For very large numbers, consider truncating or using "99+" format to avoid overflow
|