opui-css 3.3.5 → 4.0.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/CHANGELOG.md +241 -0
- package/LICENSE +21 -21
- package/MIGRATING.md +105 -0
- package/README.md +66 -29
- package/astro/index.ts +46 -0
- package/components/AGENTS.md +247 -0
- package/components/Accordion/Accordion.astro +42 -0
- package/components/Anchor/Anchor.astro +51 -0
- package/components/Avatar/Avatar.astro +44 -0
- package/components/Badge/Badge.astro +54 -0
- package/components/Button/Button.astro +45 -0
- package/components/ButtonGroup/ButtonGroup.astro +29 -0
- package/components/Callout/Callout.astro +75 -0
- package/components/Card/Card.astro +38 -0
- package/components/Checkbox/Checkbox.astro +76 -0
- package/components/Checkbox/CheckboxInput.astro +32 -0
- package/components/Chip/Chip.astro +37 -0
- package/components/ClassicSelect/ClassicSelect.astro +83 -0
- package/components/DescriptionList/Description.astro +12 -0
- package/components/DescriptionList/DescriptionList.astro +22 -0
- package/components/DescriptionList/Item.astro +12 -0
- package/components/DescriptionList/Term.astro +12 -0
- package/components/DescriptionList/index.ts +12 -0
- package/components/Dialog/Dialog.astro +43 -0
- package/components/Divider/Divider.astro +14 -0
- package/components/Drawer/Drawer.astro +49 -0
- package/components/Drawer/DrawerFooter.astro +14 -0
- package/components/Drawer/DrawerHeader.astro +31 -0
- package/components/FieldDescription/FieldDescription.astro +13 -0
- package/components/FieldGroup/FieldGroup.astro +31 -0
- package/components/FieldLegend/FieldLegend.astro +15 -0
- package/components/FieldSet/FieldSet.astro +15 -0
- package/components/Form/Form.astro +15 -0
- package/components/IconButton/IconButton.astro +26 -0
- package/components/List/List.astro +36 -0
- package/components/ListItem/ListItem.astro +118 -0
- package/components/Progress/Progress.astro +40 -0
- package/components/Radio/Radio.astro +70 -0
- package/components/Radio/RadioInput.astro +24 -0
- package/components/Range/Range.astro +136 -0
- package/components/Select/Select.astro +106 -0
- package/components/Switch/Switch.astro +101 -0
- package/components/Switch/SwitchInput.astro +25 -0
- package/components/Table/Body.astro +13 -0
- package/components/Table/Cell.astro +13 -0
- package/components/Table/Column.astro +15 -0
- package/components/Table/ColumnGroup.astro +13 -0
- package/components/Table/Head.astro +13 -0
- package/components/Table/HeaderCell.astro +13 -0
- package/components/Table/Row.astro +13 -0
- package/components/Table/Table.astro +15 -0
- package/components/Table/index.ts +20 -0
- package/components/Tabs/Tabs.astro +28 -0
- package/components/Tabs/TabsItem.astro +47 -0
- package/components/Tabs/TabsPanel.astro +21 -0
- package/components/Tabs/TabsTab.astro +19 -0
- package/components/Tabs/index.ts +14 -0
- package/components/TextField/TextField.astro +128 -0
- package/components/Textarea/Textarea.astro +106 -0
- package/components/Toast/Toast.astro +42 -0
- package/components/ToggleButton/ToggleButton.astro +53 -0
- package/components/ToggleGroup/ToggleGroup.astro +49 -0
- package/components/Tooltip/Tooltip.astro +30 -0
- package/{src/core → core}/normalize.css +194 -196
- package/core/palette.css +59 -0
- package/{src/core → core}/utils.css +71 -60
- package/css/components/accordion.css +174 -0
- package/css/components/anchor.css +27 -0
- package/{src/themes/theme-two → css}/components/avatar.css +65 -68
- package/css/components/badge.css +107 -0
- package/css/components/button-group.css +179 -0
- package/css/components/button.css +215 -0
- package/css/components/callout.css +109 -0
- package/css/components/card.css +117 -0
- package/css/components/checkbox.css +205 -0
- package/{src/themes/theme-one → css}/components/chip.css +87 -135
- package/{src/themes/theme-two/components/definition-list.css → css/components/description-list.css} +77 -68
- package/{src/themes/theme-two → css}/components/dialog.css +68 -59
- package/css/components/divider.css +20 -0
- package/css/components/drawer.css +171 -0
- package/css/components/form.css +146 -0
- package/css/components/icon-button.css +139 -0
- package/{src/themes/theme-two → css}/components/link.css +21 -21
- package/{src/themes/theme-two → css}/components/list.css +345 -318
- package/{src/themes/theme-one → css}/components/progress.css +97 -83
- package/css/components/radio.css +172 -0
- package/css/components/range.css +337 -0
- package/{src/themes/theme-two → css}/components/select.css +169 -162
- package/{src/themes/theme-two → css}/components/spinner.css +37 -38
- package/{src/themes/theme-two → css}/components/switch.css +268 -225
- package/css/components/table.css +179 -0
- package/css/components/tabs.css +77 -0
- package/css/components/text-field.css +450 -0
- package/css/components/text-input.css +64 -0
- package/{src/themes/theme-two → css}/components/textarea.css +24 -25
- package/css/components/toast.css +161 -0
- package/css/components/toggle-button.css +87 -0
- package/css/components/toggle-group.css +56 -0
- package/css/components/tooltip.css +67 -0
- package/css/components/typography.css +585 -0
- package/{src/themes/theme-two → css}/components.css +41 -37
- package/{src/themes/theme-two → css}/imports.css +16 -16
- package/css/js/checkbox.js +21 -0
- package/css/js/toast.js +94 -0
- package/css/theme.css +132 -0
- package/dist/op.css +1001 -32
- package/dist/op.css.map +1 -0
- package/dist/opui.components.css +5146 -0
- package/dist/opui.components.css.map +1 -0
- package/dist/opui.css +6615 -0
- package/dist/opui.css.map +1 -0
- package/env.d.ts +14 -0
- package/open-props.css +9 -0
- package/package.json +81 -72
- package/dist/theme-one/components.css +0 -3869
- package/dist/theme-one/theme-one.css +0 -4424
- package/dist/theme-two/components.css +0 -3591
- package/dist/theme-two/theme-two.css +0 -4141
- package/src/open-props.css +0 -10
- package/src/themes/theme-one/components/accordion.css +0 -172
- package/src/themes/theme-one/components/alert.css +0 -85
- package/src/themes/theme-one/components/avatar.css +0 -68
- package/src/themes/theme-one/components/badge.css +0 -101
- package/src/themes/theme-one/components/button-group.css +0 -69
- package/src/themes/theme-one/components/button.css +0 -281
- package/src/themes/theme-one/components/card.css +0 -82
- package/src/themes/theme-one/components/checkbox-radio.css +0 -123
- package/src/themes/theme-one/components/definition-list.css +0 -68
- package/src/themes/theme-one/components/dialog.css +0 -59
- package/src/themes/theme-one/components/divider.css +0 -7
- package/src/themes/theme-one/components/field-group.css +0 -83
- package/src/themes/theme-one/components/field.css +0 -494
- package/src/themes/theme-one/components/icon-button.css +0 -40
- package/src/themes/theme-one/components/link.css +0 -21
- package/src/themes/theme-one/components/list.css +0 -318
- package/src/themes/theme-one/components/range.css +0 -121
- package/src/themes/theme-one/components/rich-text.css +0 -210
- package/src/themes/theme-one/components/select.css +0 -163
- package/src/themes/theme-one/components/snackbar.css +0 -148
- package/src/themes/theme-one/components/spinner.css +0 -38
- package/src/themes/theme-one/components/switch.css +0 -225
- package/src/themes/theme-one/components/tab-buttons.css +0 -120
- package/src/themes/theme-one/components/table.css +0 -92
- package/src/themes/theme-one/components/text-field.css +0 -57
- package/src/themes/theme-one/components/textarea.css +0 -25
- package/src/themes/theme-one/components/toggle-button-group.css +0 -135
- package/src/themes/theme-one/components/tooltip.css +0 -94
- package/src/themes/theme-one/components/typography.css +0 -209
- package/src/themes/theme-one/components.css +0 -37
- package/src/themes/theme-one/imports.css +0 -16
- package/src/themes/theme-one/theme.css +0 -163
- package/src/themes/theme-two/components/accordion.css +0 -172
- package/src/themes/theme-two/components/alert.css +0 -85
- package/src/themes/theme-two/components/badge.css +0 -101
- package/src/themes/theme-two/components/button-group.css +0 -50
- package/src/themes/theme-two/components/button.css +0 -229
- package/src/themes/theme-two/components/card.css +0 -82
- package/src/themes/theme-two/components/checkbox-radio.css +0 -123
- package/src/themes/theme-two/components/chip.css +0 -135
- package/src/themes/theme-two/components/divider.css +0 -7
- package/src/themes/theme-two/components/field-group.css +0 -83
- package/src/themes/theme-two/components/field.css +0 -281
- package/src/themes/theme-two/components/icon-button.css +0 -40
- package/src/themes/theme-two/components/progress.css +0 -83
- package/src/themes/theme-two/components/range.css +0 -121
- package/src/themes/theme-two/components/rich-text.css +0 -210
- package/src/themes/theme-two/components/snackbar.css +0 -148
- package/src/themes/theme-two/components/tab-buttons.css +0 -120
- package/src/themes/theme-two/components/table.css +0 -99
- package/src/themes/theme-two/components/text-field.css +0 -57
- package/src/themes/theme-two/components/toggle-button-group.css +0 -135
- package/src/themes/theme-two/components/tooltip.css +0 -94
- package/src/themes/theme-two/components/typography.css +0 -209
- package/src/themes/theme-two/theme.css +0 -158
package/css/js/toast.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toast manager.
|
|
3
|
+
*
|
|
4
|
+
* - HTML owns structure (via <template id="toast-template">).
|
|
5
|
+
* - CSS owns lifetime (via attr(data-duration type(<time>))).
|
|
6
|
+
* - JS owns lifecycle (clone template, fill slots, append, remove on animationend).
|
|
7
|
+
*
|
|
8
|
+
* No setTimeout. No popovertargetaction. No innerHTML of user data.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const FALLBACK_TEMPLATE = `<div class="toast" role="alert">
|
|
12
|
+
<span class="icon" data-toast-icon></span>
|
|
13
|
+
<div class="content">
|
|
14
|
+
<div class="title" data-toast-title></div>
|
|
15
|
+
<div class="description" data-toast-description></div>
|
|
16
|
+
</div>
|
|
17
|
+
<button class="close-button" data-toast-close type="button" aria-label="Close">
|
|
18
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
19
|
+
</button>
|
|
20
|
+
</div>`
|
|
21
|
+
|
|
22
|
+
export function initToastManager() {
|
|
23
|
+
const manager = document.getElementById("toast-manager")
|
|
24
|
+
if (!manager) return
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
manager.showPopover()
|
|
28
|
+
} catch {
|
|
29
|
+
/* already open or unsupported */
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
manager.addEventListener("command", (event) => {
|
|
33
|
+
if (event.command !== "--show-toast") return
|
|
34
|
+
const trigger = event.source
|
|
35
|
+
if (!trigger) return
|
|
36
|
+
|
|
37
|
+
const data = trigger.dataset || {}
|
|
38
|
+
showToast(
|
|
39
|
+
{
|
|
40
|
+
description: data.description,
|
|
41
|
+
duration: data.duration,
|
|
42
|
+
severity: data.severity,
|
|
43
|
+
template: data.template,
|
|
44
|
+
title: data.title || trigger.textContent?.trim() || "",
|
|
45
|
+
},
|
|
46
|
+
manager,
|
|
47
|
+
)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
window.showToast = (options) => showToast(options || {}, manager)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function showToast(options, manager) {
|
|
54
|
+
const node = buildToast(options.template || "toast-template")
|
|
55
|
+
if (!node) return
|
|
56
|
+
|
|
57
|
+
fillSlot(node, "[data-toast-title]", options.title)
|
|
58
|
+
fillSlot(node, "[data-toast-description]", options.description)
|
|
59
|
+
|
|
60
|
+
if (options.severity) node.dataset.severity = options.severity
|
|
61
|
+
if (options.duration) node.dataset.duration = options.duration
|
|
62
|
+
|
|
63
|
+
wireToast(node)
|
|
64
|
+
manager.appendChild(node)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function buildToast(templateId) {
|
|
68
|
+
const tpl = document.getElementById(templateId)
|
|
69
|
+
if (tpl?.content?.firstElementChild) {
|
|
70
|
+
return tpl.content.firstElementChild.cloneNode(true)
|
|
71
|
+
}
|
|
72
|
+
const wrap = document.createElement("div")
|
|
73
|
+
wrap.innerHTML = FALLBACK_TEMPLATE.trim()
|
|
74
|
+
return wrap.firstElementChild
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function fillSlot(root, selector, text) {
|
|
78
|
+
const el = root.querySelector(selector)
|
|
79
|
+
if (!el) return
|
|
80
|
+
if (text == null || text === "") {
|
|
81
|
+
el.remove()
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
el.textContent = text
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function wireToast(node) {
|
|
88
|
+
node.querySelector("[data-toast-close]")?.addEventListener("click", () => {
|
|
89
|
+
node.classList.add("exiting")
|
|
90
|
+
})
|
|
91
|
+
node.addEventListener("animationend", (event) => {
|
|
92
|
+
if (event.animationName === "toast-exit") node.remove()
|
|
93
|
+
})
|
|
94
|
+
}
|
package/css/theme.css
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/*
|
|
2
|
+
theme three theme setup
|
|
3
|
+
*/
|
|
4
|
+
@layer theme {
|
|
5
|
+
|
|
6
|
+
/* 1. Color scheme */
|
|
7
|
+
.light {
|
|
8
|
+
--color-scheme: light;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dark {
|
|
12
|
+
--color-scheme: dark;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:where(html) {
|
|
16
|
+
color-scheme: var(--color-scheme, light dark);
|
|
17
|
+
|
|
18
|
+
/* 2. Palette source - one value to rule them all. Every other color is derived from this one.
|
|
19
|
+
Both light/dark branches are wired up via light-dark() so prefers-color-scheme works
|
|
20
|
+
automatically. Set them to different OKLCH values if you want a distinct dark-mode palette. */
|
|
21
|
+
--palette-source: light-dark(oklch(0.58 calc(0.21 * 0.5) var(--hue-blue)),
|
|
22
|
+
oklch(0.58 calc(0.21 * 0.5) var(--hue-blue)));
|
|
23
|
+
--palette-hue-rotate-by: 0;
|
|
24
|
+
|
|
25
|
+
/* Gray ramp lives in core/palette.css. Override --gray-chroma or
|
|
26
|
+
--gray-hue here if this theme wants warmer/cooler grays. */
|
|
27
|
+
|
|
28
|
+
/* 3. Named colors (no severity meaning) — use when you literally want a green/red/etc. dot */
|
|
29
|
+
--blue: oklch(from var(--color-9) l 0.2 210);
|
|
30
|
+
--green: oklch(from var(--color-9) l 0.2 145);
|
|
31
|
+
--orange: oklch(from var(--color-7) l 0.2 75);
|
|
32
|
+
--red: oklch(from var(--color-9) l 0.2 25);
|
|
33
|
+
|
|
34
|
+
/* 4. Intent tokens
|
|
35
|
+
Severity (have scope classes below): --success, --info, --warning, --critical
|
|
36
|
+
Non-severity (value-only): --primary, --neutral */
|
|
37
|
+
--success: var(--green);
|
|
38
|
+
--info: var(--blue);
|
|
39
|
+
--warning: var(--orange);
|
|
40
|
+
--critical: var(--red);
|
|
41
|
+
--neutral: var(--gray-9);
|
|
42
|
+
|
|
43
|
+
/* 5. Primary */
|
|
44
|
+
--primary: var(--color-8);
|
|
45
|
+
--primary-light: oklch(from var(--primary) calc(l * 1.25) c h);
|
|
46
|
+
--primary-dark: oklch(from var(--primary) calc(l * 0.75) c h);
|
|
47
|
+
--primary-contrast: var(--gray-1);
|
|
48
|
+
|
|
49
|
+
/* 6. Text */
|
|
50
|
+
--text-primary: light-dark(var(--gray-15), var(--gray-1));
|
|
51
|
+
--text-primary-contrast: light-dark(var(--gray-2), var(--gray-15));
|
|
52
|
+
--text-muted: light-dark(var(--gray-13), var(--gray-4));
|
|
53
|
+
--text-muted-contrast: light-dark(var(--gray-4), var(--gray-13));
|
|
54
|
+
|
|
55
|
+
/* 7. Surfaces */
|
|
56
|
+
--surface-default: light-dark(var(--gray-1), var(--gray-13));
|
|
57
|
+
--surface-filled: light-dark(var(--gray-4), var(--gray-15));
|
|
58
|
+
--surface-tonal: light-dark(var(--gray-3), var(--gray-12));
|
|
59
|
+
--surface-elevated: light-dark(var(--gray-1), var(--gray-12));
|
|
60
|
+
|
|
61
|
+
/* 8. Borders */
|
|
62
|
+
--border-color: light-dark(var(--gray-4), var(--gray-12));
|
|
63
|
+
--border-radius: var(--size-2);
|
|
64
|
+
--border-width: 1px;
|
|
65
|
+
|
|
66
|
+
/* 9. Focus ring — components consume these and may override locally
|
|
67
|
+
(e.g. .button.filled { --focus-ring-offset: 3px; }, .checkbox { --focus-ring-offset: 0; }) */
|
|
68
|
+
--focus-ring-color: var(--primary);
|
|
69
|
+
--focus-ring-width: 2px;
|
|
70
|
+
--focus-ring-offset: 2px;
|
|
71
|
+
--focus-ring-style: solid;
|
|
72
|
+
|
|
73
|
+
/* 10. Typography */
|
|
74
|
+
--font-size-h1: var(--font-size-fluid-3);
|
|
75
|
+
--font-size-h2: var(--font-size-fluid-2);
|
|
76
|
+
--font-size-h3: var(--font-size-fluid-1);
|
|
77
|
+
--font-size-h4: var(--font-size-3);
|
|
78
|
+
--font-size-h5: var(--font-size-2);
|
|
79
|
+
--font-size-h6: var(--font-size-fluid-0);
|
|
80
|
+
|
|
81
|
+
/* Sneaking in an extra font size I want but Open Props doesn't provide. You can do whatever you want with your own theme. It's just CSS. */
|
|
82
|
+
--font-size-05: 0.875rem;
|
|
83
|
+
|
|
84
|
+
/* 11. Control sizes — shared scale for fields and buttons so they line up
|
|
85
|
+
visually. --field-size-* and --button-size-* alias from --control-size-*. */
|
|
86
|
+
--control-size-x-small: 28px;
|
|
87
|
+
--control-size-small: 32px;
|
|
88
|
+
--control-size: 40px;
|
|
89
|
+
--control-size-large: 46px;
|
|
90
|
+
|
|
91
|
+
--field-size-x-small: var(--control-size-x-small);
|
|
92
|
+
--field-size-small: var(--control-size-small);
|
|
93
|
+
--field-size: var(--control-size);
|
|
94
|
+
--field-size-large: var(--control-size-large);
|
|
95
|
+
|
|
96
|
+
--button-size-x-small: var(--control-size-x-small);
|
|
97
|
+
--button-size-small: var(--control-size-small);
|
|
98
|
+
--button-size: var(--control-size);
|
|
99
|
+
--button-size-large: var(--control-size-large);
|
|
100
|
+
|
|
101
|
+
/* 12. Field / input */
|
|
102
|
+
--field-border-color: var(--border-color);
|
|
103
|
+
--field-border-radius: var(--size-2);
|
|
104
|
+
--field-border-width: 1px;
|
|
105
|
+
|
|
106
|
+
/* 13. Button */
|
|
107
|
+
--button-border-radius: var(--size-2);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* 14. Severity scope classes — re-source the palette inside these contexts.
|
|
111
|
+
Authoring `<div class="warning">` paints the entire subtree warning-orange.
|
|
112
|
+
Non-severity tokens (--primary, --neutral) deliberately have no scope class. */
|
|
113
|
+
:where(.critical, [data-invalid], del) {
|
|
114
|
+
--palette-source: oklch(0.58 0.21 var(--hue-red));
|
|
115
|
+
--palette-hue-rotate-by: 1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:where(.info, abbr, dfn) {
|
|
119
|
+
--palette-source: oklch(0.58 0.21 var(--hue-blue));
|
|
120
|
+
--palette-hue-rotate-by: 1;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
:where(.success, ins) {
|
|
124
|
+
--palette-source: oklch(0.58 0.21 var(--hue-green));
|
|
125
|
+
--palette-hue-rotate-by: 1;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
:where(.warning) {
|
|
129
|
+
--palette-source: oklch(0.58 0.21 var(--hue-orange));
|
|
130
|
+
--palette-hue-rotate-by: 1;
|
|
131
|
+
}
|
|
132
|
+
}
|