@realmorg/ui 0.0.0-stage → 2.0.0-alpha.3
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/LICENSE +7 -0
- package/README.md +44 -2
- package/components/accordion.html +139 -0
- package/components/alert-dialog.html +236 -0
- package/components/alert.html +83 -0
- package/components/aspect-ratio.html +29 -0
- package/components/attachment.html +98 -0
- package/components/avatar.html +149 -0
- package/components/badge.html +62 -0
- package/components/breadcrumb.html +159 -0
- package/components/bubble.html +77 -0
- package/components/button-group.html +98 -0
- package/components/button.html +194 -0
- package/components/calendar.html +176 -0
- package/components/card.html +143 -0
- package/components/carousel.html +208 -0
- package/components/chart.html +168 -0
- package/components/checkbox.html +99 -0
- package/components/code-block.html +64 -0
- package/components/collapsible.html +90 -0
- package/components/combobox.html +237 -0
- package/components/command.html +201 -0
- package/components/context-menu.html +81 -0
- package/components/dialog.html +327 -0
- package/components/direction.html +23 -0
- package/components/drawer.html +267 -0
- package/components/dropdown-menu.html +421 -0
- package/components/empty.html +132 -0
- package/components/field.html +143 -0
- package/components/hover-card.html +111 -0
- package/components/input-group.html +91 -0
- package/components/input-otp.html +151 -0
- package/components/input.html +94 -0
- package/components/item.html +208 -0
- package/components/kbd.html +45 -0
- package/components/label.html +46 -0
- package/components/marker.html +41 -0
- package/components/menubar.html +137 -0
- package/components/message-scroller.html +68 -0
- package/components/message.html +95 -0
- package/components/navigation-menu.html +233 -0
- package/components/pagination.html +160 -0
- package/components/popover.html +164 -0
- package/components/progress.html +45 -0
- package/components/radio-group.html +120 -0
- package/components/resizable.html +170 -0
- package/components/scroll-area.html +56 -0
- package/components/select.html +103 -0
- package/components/separator.html +31 -0
- package/components/sheet.html +173 -0
- package/components/sidebar.html +393 -0
- package/components/skeleton.html +36 -0
- package/components/slider.html +108 -0
- package/components/spinner.html +53 -0
- package/components/switch.html +95 -0
- package/components/table.html +81 -0
- package/components/tabs.html +182 -0
- package/components/textarea.html +80 -0
- package/components/toaster.html +134 -0
- package/components/toggle-group.html +71 -0
- package/components/toggle.html +87 -0
- package/components/tooltip.html +114 -0
- package/dist/theme.css +158 -0
- package/dist/ui.html +7923 -0
- package/package.json +40 -3
- package/theme.css +158 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2023 RealmOrg
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @realmorg/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
About 60 accessible components built with [REALM](https://realm.js.org). Each one is a native custom element made of composable parts (such as `<ui-card-header>`) and styled with the design tokens in `theme.css`. Form controls work as native form fields.
|
|
4
|
+
|
|
5
|
+
Load REALM, the theme and the components from the CDN. There is no build step.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@realmorg/realm@alpha/dist/realm.css">
|
|
9
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@realmorg/ui@alpha/dist/theme.css">
|
|
10
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@realmorg/realm@alpha/dist/realm.js"></script>
|
|
11
|
+
<import-element from="https://cdn.jsdelivr.net/npm/@realmorg/ui@alpha/dist/ui.html"></import-element>
|
|
12
|
+
|
|
13
|
+
<ui-card>
|
|
14
|
+
<ui-card-header>
|
|
15
|
+
<ui-card-title>Create project</ui-card-title>
|
|
16
|
+
<ui-card-description>Deploy in one click.</ui-card-description>
|
|
17
|
+
</ui-card-header>
|
|
18
|
+
<ui-card-content>
|
|
19
|
+
<ui-field>
|
|
20
|
+
<ui-label for="name">Name</ui-label>
|
|
21
|
+
<ui-input id="name" name="name"></ui-input>
|
|
22
|
+
</ui-field>
|
|
23
|
+
</ui-card-content>
|
|
24
|
+
<ui-card-footer justify="end"><ui-button>Create</ui-button></ui-card-footer>
|
|
25
|
+
</ui-card>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
To load only what you use, import single files instead of `ui.html`:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<import-element from="https://cdn.jsdelivr.net/npm/@realmorg/ui@alpha/components/button.html"></import-element>
|
|
32
|
+
<import-element from="https://cdn.jsdelivr.net/npm/@realmorg/ui@alpha/components/card.html"></import-element>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Each file imports its own dependencies (`sheet.html` loads `dialog.html`), and each file is fetched once.
|
|
36
|
+
|
|
37
|
+
- `dist/ui.html` holds every component in one file.
|
|
38
|
+
- `components/*.html` holds one component per file. Import a file on its own, or copy it into your project and edit it.
|
|
39
|
+
- `dist/theme.css` defines the colour, spacing, radius, shadow and type tokens, with a dark theme.
|
|
40
|
+
|
|
41
|
+
Docs and live demos for each component are at [realm.js.org/components](https://realm.js.org/components/).
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<custom-element name="ui-accordion">
|
|
2
|
+
<script>
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
type: prop.enum(["single", "multiple"]).default("single"),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
listen("toggle", (event) => {
|
|
8
|
+
const item = event.target;
|
|
9
|
+
if (props.type !== "single" || item.localName !== "ui-accordion-item" || !item.open) return;
|
|
10
|
+
for (const other of host.querySelectorAll("ui-accordion-item")) {
|
|
11
|
+
if (other !== item && other.open) other.open = false;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<style>
|
|
17
|
+
/* A double tap must not zoom the page. Set inside the shadow root, because a page-level
|
|
18
|
+
touch-action does not reach shadow content in iOS Safari. */
|
|
19
|
+
:host,
|
|
20
|
+
* {
|
|
21
|
+
touch-action: manipulation;
|
|
22
|
+
}
|
|
23
|
+
:host {
|
|
24
|
+
display: block;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
|
|
28
|
+
<slot></slot>
|
|
29
|
+
</custom-element>
|
|
30
|
+
|
|
31
|
+
<custom-element name="ui-accordion-item">
|
|
32
|
+
<script>
|
|
33
|
+
const props = defineProps({
|
|
34
|
+
open: prop.boolean().reflect(),
|
|
35
|
+
disabled: prop.boolean(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function toggled(details) {
|
|
39
|
+
if (details.open === props.open) return;
|
|
40
|
+
props.open = details.open;
|
|
41
|
+
dispatch("toggle");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function guard() {
|
|
45
|
+
return !props.disabled;
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
:host,
|
|
51
|
+
* {
|
|
52
|
+
touch-action: manipulation;
|
|
53
|
+
}
|
|
54
|
+
:host {
|
|
55
|
+
display: block;
|
|
56
|
+
border-bottom: 1px solid var(--border);
|
|
57
|
+
}
|
|
58
|
+
:host(:last-of-type) {
|
|
59
|
+
border-bottom: 0;
|
|
60
|
+
}
|
|
61
|
+
summary {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: flex-start;
|
|
64
|
+
justify-content: space-between;
|
|
65
|
+
gap: calc(var(--spacing) * 4);
|
|
66
|
+
padding: calc(var(--spacing) * 4) 0;
|
|
67
|
+
border-radius: var(--radius-md);
|
|
68
|
+
font-size: var(--text-sm);
|
|
69
|
+
font-weight: var(--font-weight-medium);
|
|
70
|
+
list-style: none;
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
outline: none;
|
|
73
|
+
}
|
|
74
|
+
summary::-webkit-details-marker {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
summary:hover {
|
|
78
|
+
text-decoration: underline;
|
|
79
|
+
}
|
|
80
|
+
summary:focus-visible {
|
|
81
|
+
box-shadow: var(--focus-ring);
|
|
82
|
+
}
|
|
83
|
+
:host(:state(attr-disabled)) summary {
|
|
84
|
+
pointer-events: none;
|
|
85
|
+
opacity: 0.5;
|
|
86
|
+
}
|
|
87
|
+
svg {
|
|
88
|
+
flex-shrink: 0;
|
|
89
|
+
width: calc(var(--spacing) * 4);
|
|
90
|
+
height: calc(var(--spacing) * 4);
|
|
91
|
+
color: var(--muted-foreground);
|
|
92
|
+
transition: rotate 0.2s;
|
|
93
|
+
}
|
|
94
|
+
details[open] svg {
|
|
95
|
+
rotate: 180deg;
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
98
|
+
|
|
99
|
+
<details _open="@open" ontoggle="toggled(this)">
|
|
100
|
+
<summary part="summary" onclick="return guard()">
|
|
101
|
+
<slot name="trigger"></slot>
|
|
102
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6" /></svg>
|
|
103
|
+
</summary>
|
|
104
|
+
<slot></slot>
|
|
105
|
+
</details>
|
|
106
|
+
</custom-element>
|
|
107
|
+
|
|
108
|
+
<custom-element name="ui-accordion-trigger" slot="trigger">
|
|
109
|
+
<style>
|
|
110
|
+
:host,
|
|
111
|
+
* {
|
|
112
|
+
touch-action: manipulation;
|
|
113
|
+
}
|
|
114
|
+
:host {
|
|
115
|
+
display: flex;
|
|
116
|
+
flex: 1;
|
|
117
|
+
align-items: center;
|
|
118
|
+
gap: calc(var(--spacing) * 2);
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
121
|
+
|
|
122
|
+
<slot></slot>
|
|
123
|
+
</custom-element>
|
|
124
|
+
|
|
125
|
+
<custom-element name="ui-accordion-content">
|
|
126
|
+
<style>
|
|
127
|
+
:host,
|
|
128
|
+
* {
|
|
129
|
+
touch-action: manipulation;
|
|
130
|
+
}
|
|
131
|
+
:host {
|
|
132
|
+
display: block;
|
|
133
|
+
padding-bottom: calc(var(--spacing) * 4);
|
|
134
|
+
font-size: var(--text-sm);
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
137
|
+
|
|
138
|
+
<slot></slot>
|
|
139
|
+
</custom-element>
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
<import-element from="./button.html"></import-element>
|
|
2
|
+
|
|
3
|
+
<custom-element name="ui-alert-dialog">
|
|
4
|
+
<script>
|
|
5
|
+
const props = defineProps({ open: prop.boolean().reflect() });
|
|
6
|
+
|
|
7
|
+
const parts = useChildren("ui-alert-dialog-header, ui-alert-dialog-title, ui-alert-dialog-description");
|
|
8
|
+
const alert = useState({
|
|
9
|
+
get label() {
|
|
10
|
+
return text("ui-alert-dialog-title");
|
|
11
|
+
},
|
|
12
|
+
get description() {
|
|
13
|
+
return text("ui-alert-dialog-description");
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
function text(selector) {
|
|
18
|
+
const found = parts.flatMap((part) => (part.matches(selector) ? [part] : [...part.querySelectorAll(selector)]));
|
|
19
|
+
return found.map((part) => part.textContent.trim()).join(" ") || null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function show() {
|
|
23
|
+
props.open = true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function showFrom(trigger) {
|
|
27
|
+
trigger.firstElementChild?.focus();
|
|
28
|
+
show();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function close(value) {
|
|
32
|
+
if (value !== undefined) refs.dialog.returnValue = String(value);
|
|
33
|
+
props.open = false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function closed() {
|
|
37
|
+
if (refs.dialog.open) return;
|
|
38
|
+
props.open = false;
|
|
39
|
+
dispatch("close", undefined, { bubbles: false, composed: false });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
defineMethods({
|
|
43
|
+
showModal: show,
|
|
44
|
+
show,
|
|
45
|
+
close,
|
|
46
|
+
get returnValue() {
|
|
47
|
+
return refs.dialog.returnValue;
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const COMMANDS = { "show-modal": show, close: () => close(), "request-close": () => close() };
|
|
52
|
+
|
|
53
|
+
listen("command", (event) => COMMANDS[event.command.replace(/^--/, "")]?.());
|
|
54
|
+
|
|
55
|
+
observe(() => {
|
|
56
|
+
const dialog = refs.dialog;
|
|
57
|
+
if (!dialog || props.open === dialog.open) return;
|
|
58
|
+
if (props.open) dialog.showModal();
|
|
59
|
+
else dialog.close();
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<style>
|
|
64
|
+
/* A double tap must not zoom the page. Set inside the shadow root, because a page-level
|
|
65
|
+
touch-action does not reach shadow content in iOS Safari. */
|
|
66
|
+
:host,
|
|
67
|
+
* {
|
|
68
|
+
touch-action: manipulation;
|
|
69
|
+
}
|
|
70
|
+
:host {
|
|
71
|
+
display: contents;
|
|
72
|
+
}
|
|
73
|
+
dialog {
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
width: 100%;
|
|
76
|
+
max-width: min(calc(var(--spacing) * 128), calc(100% - calc(var(--spacing) * 8)));
|
|
77
|
+
/* See ui-dialog: an explicit height keeps it from stretching, svh from resizing on scroll. */
|
|
78
|
+
height: fit-content;
|
|
79
|
+
max-height: calc(100svh - calc(var(--spacing) * 8));
|
|
80
|
+
overflow: auto;
|
|
81
|
+
padding: calc(var(--spacing) * 6);
|
|
82
|
+
border: 1px solid var(--border);
|
|
83
|
+
border-radius: var(--radius-lg);
|
|
84
|
+
background: var(--background);
|
|
85
|
+
color: var(--foreground);
|
|
86
|
+
box-shadow: var(--shadow-lg);
|
|
87
|
+
}
|
|
88
|
+
dialog[open] {
|
|
89
|
+
display: grid;
|
|
90
|
+
/* Safari stretches a grid overlay to its max-height unless the rows are packed at the start. */
|
|
91
|
+
align-content: start;
|
|
92
|
+
gap: calc(var(--spacing) * 4);
|
|
93
|
+
}
|
|
94
|
+
dialog::backdrop {
|
|
95
|
+
background: rgb(0 0 0 / 0.5);
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
98
|
+
|
|
99
|
+
<slot name="trigger"></slot>
|
|
100
|
+
<dialog
|
|
101
|
+
ref="dialog"
|
|
102
|
+
part="dialog"
|
|
103
|
+
role="alertdialog"
|
|
104
|
+
_aria-label="#alert.label"
|
|
105
|
+
_aria-description="#alert.description"
|
|
106
|
+
onclose="closed()"
|
|
107
|
+
oncancel="event.preventDefault()">
|
|
108
|
+
<slot name="header"></slot>
|
|
109
|
+
<slot></slot>
|
|
110
|
+
<slot name="footer"></slot>
|
|
111
|
+
</dialog>
|
|
112
|
+
</custom-element>
|
|
113
|
+
|
|
114
|
+
<custom-element name="ui-alert-dialog-trigger" slot="trigger">
|
|
115
|
+
<style>
|
|
116
|
+
:host,
|
|
117
|
+
* {
|
|
118
|
+
touch-action: manipulation;
|
|
119
|
+
}
|
|
120
|
+
:host,
|
|
121
|
+
span {
|
|
122
|
+
display: contents;
|
|
123
|
+
}
|
|
124
|
+
</style>
|
|
125
|
+
|
|
126
|
+
<span part="trigger" onclick="showFrom(host)"><slot></slot></span>
|
|
127
|
+
</custom-element>
|
|
128
|
+
|
|
129
|
+
<custom-element name="ui-alert-dialog-header" slot="header">
|
|
130
|
+
<style>
|
|
131
|
+
:host,
|
|
132
|
+
* {
|
|
133
|
+
touch-action: manipulation;
|
|
134
|
+
}
|
|
135
|
+
:host {
|
|
136
|
+
display: grid;
|
|
137
|
+
gap: calc(var(--spacing) * 2);
|
|
138
|
+
}
|
|
139
|
+
</style>
|
|
140
|
+
|
|
141
|
+
<slot></slot>
|
|
142
|
+
</custom-element>
|
|
143
|
+
|
|
144
|
+
<custom-element name="ui-alert-dialog-title">
|
|
145
|
+
<style>
|
|
146
|
+
:host,
|
|
147
|
+
* {
|
|
148
|
+
touch-action: manipulation;
|
|
149
|
+
}
|
|
150
|
+
:host {
|
|
151
|
+
display: block;
|
|
152
|
+
}
|
|
153
|
+
h2 {
|
|
154
|
+
margin: 0;
|
|
155
|
+
font-size: var(--text-lg);
|
|
156
|
+
font-weight: var(--font-weight-semibold);
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
159
|
+
|
|
160
|
+
<h2 part="title"><slot></slot></h2>
|
|
161
|
+
</custom-element>
|
|
162
|
+
|
|
163
|
+
<custom-element name="ui-alert-dialog-description">
|
|
164
|
+
<style>
|
|
165
|
+
:host,
|
|
166
|
+
* {
|
|
167
|
+
touch-action: manipulation;
|
|
168
|
+
}
|
|
169
|
+
:host {
|
|
170
|
+
display: block;
|
|
171
|
+
}
|
|
172
|
+
p {
|
|
173
|
+
margin: 0;
|
|
174
|
+
font-size: var(--text-sm);
|
|
175
|
+
color: var(--muted-foreground);
|
|
176
|
+
}
|
|
177
|
+
</style>
|
|
178
|
+
|
|
179
|
+
<p part="description"><slot></slot></p>
|
|
180
|
+
</custom-element>
|
|
181
|
+
|
|
182
|
+
<custom-element name="ui-alert-dialog-footer" slot="footer">
|
|
183
|
+
<style>
|
|
184
|
+
:host,
|
|
185
|
+
* {
|
|
186
|
+
touch-action: manipulation;
|
|
187
|
+
}
|
|
188
|
+
:host {
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-wrap: wrap;
|
|
191
|
+
justify-content: flex-end;
|
|
192
|
+
gap: calc(var(--spacing) * 2);
|
|
193
|
+
}
|
|
194
|
+
</style>
|
|
195
|
+
|
|
196
|
+
<slot></slot>
|
|
197
|
+
</custom-element>
|
|
198
|
+
|
|
199
|
+
<custom-element name="ui-alert-dialog-action">
|
|
200
|
+
<script>
|
|
201
|
+
const props = defineProps({
|
|
202
|
+
value: prop.string().default("action"),
|
|
203
|
+
variant: prop.enum(["default", "destructive"]).default("default"),
|
|
204
|
+
});
|
|
205
|
+
</script>
|
|
206
|
+
|
|
207
|
+
<style>
|
|
208
|
+
:host,
|
|
209
|
+
* {
|
|
210
|
+
touch-action: manipulation;
|
|
211
|
+
}
|
|
212
|
+
:host {
|
|
213
|
+
display: inline-flex;
|
|
214
|
+
}
|
|
215
|
+
</style>
|
|
216
|
+
|
|
217
|
+
<ui-button part="button" _variant="@variant" onclick="close(props.value)"><slot></slot></ui-button>
|
|
218
|
+
</custom-element>
|
|
219
|
+
|
|
220
|
+
<custom-element name="ui-alert-dialog-cancel">
|
|
221
|
+
<script>
|
|
222
|
+
const props = defineProps({ value: prop.string().default("cancel") });
|
|
223
|
+
</script>
|
|
224
|
+
|
|
225
|
+
<style>
|
|
226
|
+
:host,
|
|
227
|
+
* {
|
|
228
|
+
touch-action: manipulation;
|
|
229
|
+
}
|
|
230
|
+
:host {
|
|
231
|
+
display: inline-flex;
|
|
232
|
+
}
|
|
233
|
+
</style>
|
|
234
|
+
|
|
235
|
+
<ui-button part="button" variant="outline" onclick="close(props.value)"><slot></slot></ui-button>
|
|
236
|
+
</custom-element>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<custom-element name="ui-alert" role="alert">
|
|
2
|
+
<script>
|
|
3
|
+
defineProps({
|
|
4
|
+
variant: prop.enum(["default", "destructive"]).default("default"),
|
|
5
|
+
});
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
/* A double tap must not zoom the page. Set inside the shadow root, because a page-level
|
|
10
|
+
touch-action does not reach shadow content in iOS Safari. */
|
|
11
|
+
:host,
|
|
12
|
+
* {
|
|
13
|
+
touch-action: manipulation;
|
|
14
|
+
}
|
|
15
|
+
:host {
|
|
16
|
+
position: relative;
|
|
17
|
+
display: grid;
|
|
18
|
+
grid-template-columns: auto 1fr;
|
|
19
|
+
row-gap: calc(var(--spacing) * 0.5);
|
|
20
|
+
align-items: start;
|
|
21
|
+
width: 100%;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
padding: calc(var(--spacing) * 3) calc(var(--spacing) * 4);
|
|
24
|
+
border: 1px solid var(--border);
|
|
25
|
+
border-radius: var(--radius-lg);
|
|
26
|
+
background: var(--card);
|
|
27
|
+
color: var(--card-foreground);
|
|
28
|
+
font-size: var(--text-sm);
|
|
29
|
+
}
|
|
30
|
+
:host(:state(attr-variant-is-destructive)) {
|
|
31
|
+
color: var(--destructive);
|
|
32
|
+
}
|
|
33
|
+
::slotted(svg) {
|
|
34
|
+
width: calc(var(--spacing) * 4);
|
|
35
|
+
height: calc(var(--spacing) * 4);
|
|
36
|
+
margin-inline-end: calc(var(--spacing) * 3);
|
|
37
|
+
translate: 0 calc(var(--spacing) * 0.5);
|
|
38
|
+
grid-row: span 2;
|
|
39
|
+
}
|
|
40
|
+
::slotted(:not(svg)) {
|
|
41
|
+
grid-column: 2;
|
|
42
|
+
}
|
|
43
|
+
:host(:state(attr-variant-is-destructive)) ::slotted(ui-alert-description) {
|
|
44
|
+
color: color-mix(in oklab, var(--destructive) 90%, transparent);
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
47
|
+
|
|
48
|
+
<slot></slot>
|
|
49
|
+
</custom-element>
|
|
50
|
+
|
|
51
|
+
<custom-element name="ui-alert-title">
|
|
52
|
+
<style>
|
|
53
|
+
:host,
|
|
54
|
+
* {
|
|
55
|
+
touch-action: manipulation;
|
|
56
|
+
}
|
|
57
|
+
:host {
|
|
58
|
+
display: block;
|
|
59
|
+
min-height: calc(var(--spacing) * 4);
|
|
60
|
+
font-weight: var(--font-weight-medium);
|
|
61
|
+
letter-spacing: -0.01em;
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
64
|
+
|
|
65
|
+
<slot></slot>
|
|
66
|
+
</custom-element>
|
|
67
|
+
|
|
68
|
+
<custom-element name="ui-alert-description">
|
|
69
|
+
<style>
|
|
70
|
+
:host,
|
|
71
|
+
* {
|
|
72
|
+
touch-action: manipulation;
|
|
73
|
+
}
|
|
74
|
+
:host {
|
|
75
|
+
display: grid;
|
|
76
|
+
justify-items: start;
|
|
77
|
+
gap: calc(var(--spacing) * 1);
|
|
78
|
+
color: var(--muted-foreground);
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
|
|
82
|
+
<slot></slot>
|
|
83
|
+
</custom-element>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<custom-element name="ui-aspect-ratio">
|
|
2
|
+
<script>
|
|
3
|
+
defineProps({ ratio: prop.string().default("16 / 9") });
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<style>
|
|
7
|
+
/* A double tap must not zoom the page. Set inside the shadow root, because a page-level
|
|
8
|
+
touch-action does not reach shadow content in iOS Safari. */
|
|
9
|
+
:host,
|
|
10
|
+
* {
|
|
11
|
+
touch-action: manipulation;
|
|
12
|
+
}
|
|
13
|
+
:host {
|
|
14
|
+
display: block;
|
|
15
|
+
position: relative;
|
|
16
|
+
aspect-ratio: var(--attr-ratio);
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
::slotted(img),
|
|
20
|
+
::slotted(video),
|
|
21
|
+
::slotted(iframe) {
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
object-fit: cover;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
|
|
28
|
+
<slot></slot>
|
|
29
|
+
</custom-element>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<custom-element name="ui-attachment">
|
|
2
|
+
<script>
|
|
3
|
+
defineProps({ name: prop.string(), size: prop.string(), href: prop.string() });
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<style>
|
|
7
|
+
/* A double tap must not zoom the page. Set inside the shadow root, because a page-level
|
|
8
|
+
touch-action does not reach shadow content in iOS Safari. */
|
|
9
|
+
:host,
|
|
10
|
+
* {
|
|
11
|
+
touch-action: manipulation;
|
|
12
|
+
}
|
|
13
|
+
:host {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: calc(var(--spacing) * 2);
|
|
17
|
+
max-width: 100%;
|
|
18
|
+
min-width: 0;
|
|
19
|
+
padding: calc(var(--spacing) * 2) calc(var(--spacing) * 2.5);
|
|
20
|
+
border: 1px solid var(--border);
|
|
21
|
+
border-radius: var(--radius-xl);
|
|
22
|
+
background: var(--card);
|
|
23
|
+
color: var(--card-foreground);
|
|
24
|
+
font-size: var(--text-sm);
|
|
25
|
+
}
|
|
26
|
+
:host(:focus-within) {
|
|
27
|
+
box-shadow: 0 0 0 1px var(--ring);
|
|
28
|
+
}
|
|
29
|
+
.content {
|
|
30
|
+
display: grid;
|
|
31
|
+
min-width: 0;
|
|
32
|
+
}
|
|
33
|
+
.title {
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
text-overflow: ellipsis;
|
|
36
|
+
white-space: nowrap;
|
|
37
|
+
font-weight: var(--font-weight-medium);
|
|
38
|
+
color: inherit;
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
}
|
|
41
|
+
.size {
|
|
42
|
+
font-size: var(--text-xs);
|
|
43
|
+
color: var(--muted-foreground);
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
|
|
47
|
+
<slot name="media"></slot>
|
|
48
|
+
<div class="content" part="content">
|
|
49
|
+
<a class="title" part="title" _href="@href" _download="@name"><slot name="@name"></slot></a>
|
|
50
|
+
<span class="size" _hidden="!@size"><slot name="@size"></slot></span>
|
|
51
|
+
</div>
|
|
52
|
+
<slot name="actions"></slot>
|
|
53
|
+
</custom-element>
|
|
54
|
+
|
|
55
|
+
<custom-element name="ui-attachment-media" slot="media">
|
|
56
|
+
<style>
|
|
57
|
+
:host,
|
|
58
|
+
* {
|
|
59
|
+
touch-action: manipulation;
|
|
60
|
+
}
|
|
61
|
+
:host {
|
|
62
|
+
display: grid;
|
|
63
|
+
place-content: center;
|
|
64
|
+
flex-shrink: 0;
|
|
65
|
+
width: calc(var(--spacing) * 8);
|
|
66
|
+
height: calc(var(--spacing) * 8);
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
border-radius: var(--radius-md);
|
|
69
|
+
background: var(--muted);
|
|
70
|
+
}
|
|
71
|
+
::slotted(svg) {
|
|
72
|
+
width: calc(var(--spacing) * 4);
|
|
73
|
+
height: calc(var(--spacing) * 4);
|
|
74
|
+
}
|
|
75
|
+
::slotted(img) {
|
|
76
|
+
width: calc(var(--spacing) * 8);
|
|
77
|
+
height: calc(var(--spacing) * 8);
|
|
78
|
+
object-fit: cover;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
|
|
82
|
+
<slot></slot>
|
|
83
|
+
</custom-element>
|
|
84
|
+
|
|
85
|
+
<custom-element name="ui-attachment-actions" slot="actions">
|
|
86
|
+
<style>
|
|
87
|
+
:host,
|
|
88
|
+
* {
|
|
89
|
+
touch-action: manipulation;
|
|
90
|
+
}
|
|
91
|
+
:host {
|
|
92
|
+
display: flex;
|
|
93
|
+
gap: calc(var(--spacing) * 1);
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
96
|
+
|
|
97
|
+
<slot></slot>
|
|
98
|
+
</custom-element>
|