@studiocms/ui 0.3.2 → 0.4.0
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/Accordion/Accordion.astro +23 -0
- package/dist/components/Accordion/Item.astro +21 -0
- package/dist/components/Accordion/accordion.css +64 -0
- package/dist/components/Accordion/accordion.d.ts +1 -0
- package/dist/components/Accordion/accordion.js +70 -0
- package/dist/components/Badge/Badge.astro +49 -0
- package/dist/components/Badge/badge.css +111 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.astro +31 -0
- package/dist/components/Breadcrumbs/breadcrumbs.css +15 -0
- package/dist/components/Button/Button.astro +75 -0
- package/dist/components/Button/button.css +292 -0
- package/{src/components → dist/components/Card}/Card.astro +1 -48
- package/dist/components/Card/card.css +38 -0
- package/dist/components/Center/Center.astro +7 -0
- package/dist/components/Center/center.css +8 -0
- package/dist/components/Checkbox/Checkbox.astro +95 -0
- package/dist/components/Checkbox/checkbox.css +119 -0
- package/dist/components/Checkbox/checkbox.d.ts +2 -0
- package/dist/components/Checkbox/checkbox.js +20 -0
- package/{src/components → dist/components/Divider}/Divider.astro +2 -25
- package/dist/components/Divider/divider.css +21 -0
- package/dist/components/Dropdown/Dropdown.astro +116 -0
- package/dist/components/Dropdown/dropdown.css +180 -0
- package/dist/components/Dropdown/dropdown.d.ts +48 -0
- package/dist/components/Dropdown/dropdown.js +201 -0
- package/dist/components/Footer/Footer.astro +58 -0
- package/dist/components/Footer/footer.css +68 -0
- package/dist/components/Group/Group.astro +7 -0
- package/dist/components/Group/group.css +19 -0
- package/{src/utils → dist/components/Icon}/Icon.astro +1 -1
- package/{src/utils/iconType.ts → dist/components/Icon/iconType.d.ts} +0 -1
- package/dist/components/Icon/iconType.js +0 -0
- package/{src/components → dist/components/Input}/Input.astro +2 -48
- package/dist/components/Input/input.css +38 -0
- package/{src → dist}/components/Modal/Modal.astro +4 -122
- package/dist/components/Modal/modal.css +100 -0
- package/dist/components/Modal/modal.d.ts +48 -0
- package/dist/components/Modal/modal.js +129 -0
- package/dist/components/Progress/Progress.astro +21 -0
- package/dist/components/Progress/helper.d.ts +13 -0
- package/dist/components/Progress/helper.js +32 -0
- package/dist/components/Progress/progress.css +29 -0
- package/dist/components/Progress/progress.d.ts +1 -0
- package/dist/components/Progress/progress.js +10 -0
- package/dist/components/RadioGroup/RadioGroup.astro +124 -0
- package/dist/components/RadioGroup/radiogroup.css +96 -0
- package/dist/components/RadioGroup/radiogroup.d.ts +1 -0
- package/dist/components/RadioGroup/radiogroup.js +48 -0
- package/{src/components → dist/components/Row}/Row.astro +1 -24
- package/dist/components/Row/row.css +18 -0
- package/dist/components/SearchSelect/SearchSelect.astro +135 -0
- package/dist/components/SearchSelect/searchselect.css +95 -0
- package/dist/components/SearchSelect/searchselect.d.ts +6 -0
- package/dist/components/SearchSelect/searchselect.js +166 -0
- package/dist/components/Select/Select.astro +147 -0
- package/dist/components/Select/select.css +110 -0
- package/dist/components/Select/select.d.ts +1 -0
- package/dist/components/Select/select.js +143 -0
- package/dist/components/Sidebar/helpers.d.ts +76 -0
- package/dist/components/Sidebar/helpers.js +160 -0
- package/{src → dist}/components/Tabs/TabItem.astro +3 -3
- package/dist/components/Tabs/Tabs.astro +150 -0
- package/dist/components/Tabs/tabs.css +121 -0
- package/dist/components/Tabs/tabs.d.ts +1 -0
- package/dist/components/Tabs/tabs.js +82 -0
- package/{src/components → dist/components/Textarea}/Textarea.astro +2 -61
- package/dist/components/Textarea/textarea.css +49 -0
- package/dist/components/ThemeToggle/ThemeToggle.astro +21 -0
- package/dist/components/ThemeToggle/themetoggle.css +17 -0
- package/dist/components/ThemeToggle/themetoggle.d.ts +1 -0
- package/dist/components/ThemeToggle/themetoggle.js +4 -0
- package/dist/components/Toast/Toaster.astro +69 -0
- package/dist/components/Toast/toast.d.ts +8 -0
- package/dist/components/Toast/toast.js +9 -0
- package/dist/components/Toast/toaster.css +168 -0
- package/dist/components/Toast/toaster.d.ts +1 -0
- package/dist/components/Toast/toaster.js +160 -0
- package/dist/components/Toggle/Toggle.astro +84 -0
- package/dist/components/Toggle/toggle.css +93 -0
- package/dist/components/Toggle/toggle.d.ts +2 -0
- package/dist/components/Toggle/toggle.js +20 -0
- package/{src/components → dist/components/User}/User.astro +3 -43
- package/dist/components/User/user.css +35 -0
- package/dist/css/colors.css +95 -0
- package/dist/css/global.css +3 -0
- package/dist/css/radii.css +6 -0
- package/dist/css/resets.css +46 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +379 -0
- package/dist/toolbar/ColorPicker.d.ts +7 -0
- package/dist/toolbar/ColorPicker.js +85 -0
- package/dist/toolbar/icon.d.ts +1 -0
- package/dist/toolbar/icon.js +4 -0
- package/dist/toolbar/index.d.ts +2 -0
- package/dist/toolbar/index.js +292 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/ThemeHelper.d.ts +49 -0
- package/dist/utils/ThemeHelper.js +113 -0
- package/{src/utils/colors.ts → dist/utils/colors.d.ts} +1 -1
- package/dist/utils/colors.js +0 -0
- package/dist/utils/generateID.d.ts +2 -0
- package/dist/utils/generateID.js +6 -0
- package/dist/utils/headers.d.ts +43 -0
- package/dist/utils/headers.js +129 -0
- package/dist/utils/iconStrings.d.ts +4 -0
- package/dist/utils/iconStrings.js +13 -0
- package/dist/utils/integration-utils.d.ts +130 -0
- package/dist/utils/integration-utils.js +161 -0
- package/package.json +25 -9
- package/src/components/BaseHead.astro +0 -22
- package/src/components/Button.astro +0 -372
- package/src/components/Center.astro +0 -16
- package/src/components/Checkbox.astro +0 -250
- package/src/components/Dropdown/Dropdown.astro +0 -314
- package/src/components/Dropdown/dropdown.ts +0 -258
- package/src/components/Dropdown/index.ts +0 -2
- package/src/components/Footer.astro +0 -137
- package/src/components/Modal/index.ts +0 -2
- package/src/components/Modal/modal.ts +0 -163
- package/src/components/RadioGroup.astro +0 -299
- package/src/components/SearchSelect.astro +0 -486
- package/src/components/Select.astro +0 -467
- package/src/components/Sidebar/helpers.ts +0 -179
- package/src/components/Sidebar/index.ts +0 -3
- package/src/components/Tabs/Tabs.astro +0 -393
- package/src/components/Tabs/index.ts +0 -2
- package/src/components/ThemeToggle.astro +0 -46
- package/src/components/Toast/Toaster.astro +0 -470
- package/src/components/Toast/index.ts +0 -2
- package/src/components/Toast/toast.ts +0 -16
- package/src/components/Toggle.astro +0 -214
- package/src/components/index.ts +0 -27
- package/src/components.ts +0 -26
- package/src/css/colors.css +0 -106
- package/src/css/global.css +0 -2
- package/src/css/resets.css +0 -54
- package/src/env.d.ts +0 -15
- package/src/integration.ts +0 -31
- package/src/layouts/RootLayout.astro +0 -33
- package/src/layouts/index.ts +0 -2
- package/src/layouts.ts +0 -1
- package/src/types/index.ts +0 -11
- package/src/utils/ThemeHelper.ts +0 -145
- package/src/utils/create-resolver.ts +0 -30
- package/src/utils/generateID.ts +0 -5
- package/src/utils/headers.ts +0 -190
- package/src/utils/iconStrings.ts +0 -29
- package/src/utils/index.ts +0 -1
- package/src/utils/virtual-module-plugin-builder.ts +0 -37
- /package/{src → dist}/components/Sidebar/Double.astro +0 -0
- /package/{src → dist}/components/Sidebar/Single.astro +0 -0
- /package/{src → dist}/icons/Checkmark.astro +0 -0
- /package/{src → dist}/icons/ChevronUpDown.astro +0 -0
- /package/{src → dist}/icons/User.astro +0 -0
- /package/{src → dist}/icons/X-Mark.astro +0 -0
package/src/components/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export { default as Button } from './Button.astro';
|
|
2
|
-
export { default as Divider } from './Divider.astro';
|
|
3
|
-
export { default as Input } from './Input.astro';
|
|
4
|
-
export { default as Row } from './Row.astro';
|
|
5
|
-
export { default as Center } from './Center.astro';
|
|
6
|
-
export { default as Textarea } from './Textarea.astro';
|
|
7
|
-
export { default as Checkbox } from './Checkbox.astro';
|
|
8
|
-
export { default as Toggle } from './Toggle.astro';
|
|
9
|
-
export { default as RadioGroup } from './RadioGroup.astro';
|
|
10
|
-
export { default as Toaster } from './Toast/Toaster.astro';
|
|
11
|
-
export { default as Card } from './Card.astro';
|
|
12
|
-
export { default as Modal } from './Modal/Modal.astro';
|
|
13
|
-
export { default as Select } from './Select.astro';
|
|
14
|
-
export { default as SearchSelect } from './SearchSelect.astro';
|
|
15
|
-
export { default as Dropdown } from './Dropdown/Dropdown.astro';
|
|
16
|
-
export { default as User } from './User.astro';
|
|
17
|
-
export { default as ThemeToggle } from './ThemeToggle.astro';
|
|
18
|
-
export { default as Footer } from './Footer.astro';
|
|
19
|
-
export { Tabs, TabItem } from './Tabs/index';
|
|
20
|
-
|
|
21
|
-
export { default as Sidebar } from './Sidebar/Single.astro';
|
|
22
|
-
export { default as DoubleSidebar } from './Sidebar/Double.astro';
|
|
23
|
-
export { SingleSidebarHelper, DoubleSidebarHelper } from './Sidebar/helpers';
|
|
24
|
-
|
|
25
|
-
export { toast } from './Toast/toast';
|
|
26
|
-
export { ModalHelper } from './Modal/modal';
|
|
27
|
-
export { DropdownHelper } from './Dropdown/dropdown';
|
package/src/components.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export { Button } from './components/index';
|
|
2
|
-
export { Divider } from './components/index';
|
|
3
|
-
export { Input } from './components/index';
|
|
4
|
-
export { Row } from './components/index';
|
|
5
|
-
export { Center } from './components/index';
|
|
6
|
-
export { Textarea } from './components/index';
|
|
7
|
-
export { Checkbox } from './components/index';
|
|
8
|
-
export { Toggle } from './components/index';
|
|
9
|
-
export { RadioGroup } from './components/index';
|
|
10
|
-
export { Toaster, toast } from './components/index';
|
|
11
|
-
export { Card } from './components/index';
|
|
12
|
-
export { Modal, ModalHelper } from './components/index';
|
|
13
|
-
export { Select } from './components/index';
|
|
14
|
-
export { SearchSelect } from './components/index';
|
|
15
|
-
export { Dropdown, DropdownHelper } from './components/index';
|
|
16
|
-
export { User } from './components/index';
|
|
17
|
-
export { ThemeToggle } from './components/index';
|
|
18
|
-
export { Footer } from './components/index';
|
|
19
|
-
export { Tabs, TabItem } from './components/index';
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
Sidebar,
|
|
23
|
-
DoubleSidebar,
|
|
24
|
-
SingleSidebarHelper,
|
|
25
|
-
DoubleSidebarHelper,
|
|
26
|
-
} from './components/index';
|
package/src/css/colors.css
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
[data-theme="light"],
|
|
2
|
-
[data-theme="light"] * {
|
|
3
|
-
color-scheme: light;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
[data-theme="dark"],
|
|
7
|
-
[data-theme="dark"] * {
|
|
8
|
-
color-scheme: dark;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
:root {
|
|
12
|
-
/* Default Styles (Dark Mode) */
|
|
13
|
-
--background-base: 0 0% 6%;
|
|
14
|
-
--background-step-1: 0 0% 8%;
|
|
15
|
-
--background-step-2: 0 0% 10%;
|
|
16
|
-
--background-step-3: 0 0% 14%;
|
|
17
|
-
|
|
18
|
-
--text-normal: 0 0% 100%;
|
|
19
|
-
--text-muted: 0 0% 54%;
|
|
20
|
-
--text-inverted: 0 0% 0%;
|
|
21
|
-
|
|
22
|
-
--border: 240 5% 17%;
|
|
23
|
-
|
|
24
|
-
--shadow: 0 0% 0%;
|
|
25
|
-
|
|
26
|
-
--default-base: 0 0% 14%;
|
|
27
|
-
--default-hover: 0 0% 21%;
|
|
28
|
-
--default-active: 0 0% 15%;
|
|
29
|
-
|
|
30
|
-
--primary-base: 259 83% 73%;
|
|
31
|
-
--primary-hover: 259 77% 78%;
|
|
32
|
-
--primary-active: 259 73% 67%;
|
|
33
|
-
|
|
34
|
-
--success-base: 142 71% 46%;
|
|
35
|
-
--success-hover: 142 72% 61%;
|
|
36
|
-
--success-active: 142 87% 52%;
|
|
37
|
-
|
|
38
|
-
--warning-base: 48 96% 53%;
|
|
39
|
-
--warning-hover: 48 97% 70%;
|
|
40
|
-
--warning-active: 48 100% 61%;
|
|
41
|
-
|
|
42
|
-
--danger-base: 339 97% 31%;
|
|
43
|
-
--danger-hover: 337 98% 37%;
|
|
44
|
-
--danger-active: 337 88% 32%;
|
|
45
|
-
|
|
46
|
-
/* Non-specific variables */
|
|
47
|
-
--text-light: 0 0% 100%;
|
|
48
|
-
--text-dark: 0 0% 0%;
|
|
49
|
-
|
|
50
|
-
/* Flat colorways since they use variables */
|
|
51
|
-
--default-flat: var(--default-base) / 0.5;
|
|
52
|
-
--default-flat-hover: var(--default-base) / 0.75;
|
|
53
|
-
--default-flat-active: var(--default-base) / 0.85;
|
|
54
|
-
|
|
55
|
-
--primary-flat: var(--primary-base) / 0.1;
|
|
56
|
-
--primary-flat-hover: var(--primary-base) / 0.25;
|
|
57
|
-
--primary-flat-active: var(--primary-base) / 0.35;
|
|
58
|
-
|
|
59
|
-
--success-flat: var(--success-base) / 0.1;
|
|
60
|
-
--success-flat-hover: var(--success-base) / 0.25;
|
|
61
|
-
--success-flat-active: var(--success-base) / 0.35;
|
|
62
|
-
|
|
63
|
-
--warning-flat: var(--warning-base) / 0.1;
|
|
64
|
-
--warning-flat-hover: var(--warning-base) / 0.25;
|
|
65
|
-
--warning-flat-active: var(--warning-base) / 0.35;
|
|
66
|
-
|
|
67
|
-
--danger-flat: var(--danger-base) / 0.1;
|
|
68
|
-
--danger-flat-hover: var(--danger-base) / 0.25;
|
|
69
|
-
--danger-flat-active: var(--danger-base) / 0.35;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
[data-theme="light"] {
|
|
73
|
-
/* Light Mode Styles */
|
|
74
|
-
--background-base: 0 0% 97%;
|
|
75
|
-
--background-step-1: 0 0% 90%;
|
|
76
|
-
--background-step-2: 0 0% 85%;
|
|
77
|
-
--background-step-3: 0 0% 80%;
|
|
78
|
-
|
|
79
|
-
--text-normal: 0 0% 0%;
|
|
80
|
-
--text-muted: 0 0% 24%;
|
|
81
|
-
--text-inverted: 0 0% 100%;
|
|
82
|
-
|
|
83
|
-
--border: 263 5% 68%;
|
|
84
|
-
|
|
85
|
-
--shadow: 0 0% 65%;
|
|
86
|
-
|
|
87
|
-
--default-base: 0 0% 74%;
|
|
88
|
-
--default-hover: 0 0% 81%;
|
|
89
|
-
--default-active: 0 0% 91%;
|
|
90
|
-
|
|
91
|
-
--primary-base: 259 85% 61%;
|
|
92
|
-
--primary-hover: 259 78% 56%;
|
|
93
|
-
--primary-active: 259 71% 50%;
|
|
94
|
-
|
|
95
|
-
--success-base: 142 59% 47%;
|
|
96
|
-
--success-hover: 142 62% 56%;
|
|
97
|
-
--success-active: 142 87% 59%;
|
|
98
|
-
|
|
99
|
-
--warning-base: 48 92% 46%;
|
|
100
|
-
--warning-hover: 48 88% 43%;
|
|
101
|
-
--warning-active: 48 85% 40%;
|
|
102
|
-
|
|
103
|
-
--danger-base: 339 97% 31%;
|
|
104
|
-
--danger-hover: 337 98% 37%;
|
|
105
|
-
--danger-active: 337 88% 45%;
|
|
106
|
-
}
|
package/src/css/global.css
DELETED
package/src/css/resets.css
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
*,
|
|
2
|
-
*::before,
|
|
3
|
-
*::after {
|
|
4
|
-
box-sizing: border-box !important;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
html {
|
|
8
|
-
color-scheme: dark;
|
|
9
|
-
accent-color: hsl(var(--primary-base));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
html,
|
|
13
|
-
body {
|
|
14
|
-
margin: 0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
html[data-theme="light"] {
|
|
18
|
-
color-scheme: light;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
body {
|
|
22
|
-
-webkit-font-smoothing: antialiased;
|
|
23
|
-
color: hsl(var(--text-normal));
|
|
24
|
-
background-color: hsl(var(--background-base));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
input,
|
|
28
|
-
button,
|
|
29
|
-
textarea,
|
|
30
|
-
select {
|
|
31
|
-
font: inherit;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
p,
|
|
35
|
-
h1,
|
|
36
|
-
h2,
|
|
37
|
-
h3,
|
|
38
|
-
h4,
|
|
39
|
-
h5,
|
|
40
|
-
h6,
|
|
41
|
-
code {
|
|
42
|
-
overflow-wrap: anywhere;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
code {
|
|
46
|
-
font-family: monospace;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
button {
|
|
50
|
-
border: none;
|
|
51
|
-
outline: none;
|
|
52
|
-
background: none;
|
|
53
|
-
padding: 0;
|
|
54
|
-
}
|
package/src/env.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference path="../.astro/types.d.ts" />
|
|
2
|
-
|
|
3
|
-
interface CustomEventMap {
|
|
4
|
-
createtoast: CustomEvent<import('./types').ToastProps>;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare global {
|
|
8
|
-
interface Document {
|
|
9
|
-
addEventListener<K extends keyof CustomEventMap>(
|
|
10
|
-
type: K,
|
|
11
|
-
listener: (this: Document, ev: CustomEventMap[K]) => void
|
|
12
|
-
): void;
|
|
13
|
-
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K]): void;
|
|
14
|
-
}
|
|
15
|
-
}
|
package/src/integration.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { AstroIntegration } from 'astro';
|
|
2
|
-
import { createResolver } from './utils/create-resolver';
|
|
3
|
-
import { viteVirtualModulePluginBuilder } from './utils/virtual-module-plugin-builder';
|
|
4
|
-
|
|
5
|
-
// biome-ignore lint/complexity/noBannedTypes: Will be implemented in v0.3.0
|
|
6
|
-
type Options = {};
|
|
7
|
-
|
|
8
|
-
export default function integration(options: Options = {}): AstroIntegration {
|
|
9
|
-
const { resolve } = createResolver(import.meta.url);
|
|
10
|
-
|
|
11
|
-
const globalCss = viteVirtualModulePluginBuilder(
|
|
12
|
-
'studiocms:ui/global-css',
|
|
13
|
-
'sui-global-css',
|
|
14
|
-
`import '${resolve('./css/global.css')}'`
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
name: '@studiocms/ui',
|
|
19
|
-
hooks: {
|
|
20
|
-
'astro:config:setup': ({ injectScript, updateConfig }) => {
|
|
21
|
-
updateConfig({
|
|
22
|
-
vite: {
|
|
23
|
-
plugins: [globalCss()],
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
injectScript('page-ssr', `import 'studiocms:ui/global-css';`);
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import '../css/global.css';
|
|
3
|
-
import BaseHead from '../components/BaseHead.astro';
|
|
4
|
-
import type { HeadConfig } from '../utils/headers';
|
|
5
|
-
|
|
6
|
-
export interface RootLayoutProps {
|
|
7
|
-
title: string;
|
|
8
|
-
description: string;
|
|
9
|
-
image?: string | undefined;
|
|
10
|
-
headers?: HeadConfig | undefined;
|
|
11
|
-
lang?: string;
|
|
12
|
-
defaultTheme?: 'dark' | 'light';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type Props = RootLayoutProps;
|
|
16
|
-
|
|
17
|
-
const { title, description, image, headers, lang = 'en', defaultTheme = 'dark' } = Astro.props;
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
<!doctype html>
|
|
21
|
-
<html lang={lang} data-theme={defaultTheme}>
|
|
22
|
-
<head>
|
|
23
|
-
<BaseHead
|
|
24
|
-
{title}
|
|
25
|
-
{description}
|
|
26
|
-
{headers}
|
|
27
|
-
{image}
|
|
28
|
-
/>
|
|
29
|
-
</head>
|
|
30
|
-
<body>
|
|
31
|
-
<slot />
|
|
32
|
-
</body>
|
|
33
|
-
</html>
|
package/src/layouts/index.ts
DELETED
package/src/layouts.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { RootLayout, type RootLayoutProps } from './layouts/index';
|
package/src/types/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface ToastProps {
|
|
2
|
-
title: string;
|
|
3
|
-
/**
|
|
4
|
-
* This will get passed to the component as unsanitized HTML. DO NOT PUT USER-GENERATED CONTENT HERE!
|
|
5
|
-
*/
|
|
6
|
-
description?: string;
|
|
7
|
-
type: 'success' | 'warning' | 'danger' | 'info';
|
|
8
|
-
duration?: number;
|
|
9
|
-
persistent?: boolean;
|
|
10
|
-
closeButton?: boolean;
|
|
11
|
-
}
|
package/src/utils/ThemeHelper.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
type Theme = 'dark' | 'light' | 'system';
|
|
2
|
-
type ThemeChangeCallback = (newTheme: Theme, oldTheme: Theme) => void;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A helper to toggle, set and get the current StudioCMS UI theme.
|
|
6
|
-
*/
|
|
7
|
-
class ThemeHelper {
|
|
8
|
-
private themeManagerElement: HTMLElement;
|
|
9
|
-
private observer: MutationObserver | undefined;
|
|
10
|
-
private themeChangeCallbacks: ThemeChangeCallback[] = [];
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A helper to toggle, set and get the current StudioCMS UI theme.
|
|
14
|
-
* @param themeProvider The element that should carry the data-theme attribute (replaces the document root)
|
|
15
|
-
*/
|
|
16
|
-
constructor(themeProvider?: HTMLElement) {
|
|
17
|
-
this.themeManagerElement = themeProvider || document.documentElement;
|
|
18
|
-
this.themeManagerElement.dataset.theme = this.getTheme(true);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get the current theme.
|
|
23
|
-
* @param {boolean} resolveSystemTheme Whether to resolve the `system` theme to the actual theme (`dark` or `light`)
|
|
24
|
-
* @returns {Theme} The current theme.
|
|
25
|
-
*/
|
|
26
|
-
public getTheme = <T extends boolean>(
|
|
27
|
-
resolveSystemTheme?: T
|
|
28
|
-
): T extends true ? 'dark' | 'light' : Theme => {
|
|
29
|
-
const theme = (this.themeManagerElement.dataset.theme as Theme) || 'system';
|
|
30
|
-
|
|
31
|
-
if (!resolveSystemTheme) {
|
|
32
|
-
// Side note: Don't ask me why this type wizardry is needed but it gives proper return types so I don't care
|
|
33
|
-
return theme as T extends true ? 'dark' | 'light' : Theme;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if ((this.themeManagerElement.dataset.theme ?? 'system') !== 'system') {
|
|
37
|
-
return this.themeManagerElement.dataset.theme as 'dark' | 'light';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
41
|
-
return 'dark';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (window.matchMedia('(prefers-color-scheme: light)').matches) {
|
|
45
|
-
return 'light';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// This should (in theory) never happen since, at time of writing, window.matchMedia is supported
|
|
49
|
-
// by 96.83% of all browsers in use. (https://caniuse.com/mdn-api_window_matchmedia)
|
|
50
|
-
throw new Error(
|
|
51
|
-
'Unable to resolve theme. (Most likely cause: window.matchMedia is not supported by the browser)'
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Sets the current theme.
|
|
57
|
-
* @param theme The new theme. One of `dark`, `light` or `system`.
|
|
58
|
-
*/
|
|
59
|
-
public setTheme = (theme: Theme): void => {
|
|
60
|
-
// Assign the new theme to the dataset
|
|
61
|
-
this.themeManagerElement.dataset.theme = theme;
|
|
62
|
-
|
|
63
|
-
// If starlight is used, we also want to set the theme in local storage.
|
|
64
|
-
if (typeof localStorage.getItem('starlight-theme') === 'string') {
|
|
65
|
-
localStorage.setItem('starlight-theme', theme === 'system' ? '' : theme);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Toggles the current theme.
|
|
71
|
-
*
|
|
72
|
-
* If the theme is set to `system` (or no theme is set via the root element),
|
|
73
|
-
* the theme is set depending on the user's color scheme preference (set in the browser).
|
|
74
|
-
*/
|
|
75
|
-
public toggleTheme = (): void => {
|
|
76
|
-
const theme = this.getTheme();
|
|
77
|
-
|
|
78
|
-
if (theme && theme === 'dark') {
|
|
79
|
-
this.setTheme('light');
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (theme && theme === 'light') {
|
|
84
|
-
this.setTheme('dark');
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
89
|
-
this.setTheme('light');
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (window.matchMedia('(prefers-color-scheme: light)').matches) {
|
|
94
|
-
this.setTheme('dark');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Register an element to act as a toggle! When clicked, it will toggle the theme.
|
|
101
|
-
* @param toggle The HTML element that should act as the toggle
|
|
102
|
-
*/
|
|
103
|
-
public registerToggle = (toggle: HTMLElement | null): void => {
|
|
104
|
-
if (!toggle) {
|
|
105
|
-
console.error('Element passed to toggle registration does not exist.');
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!toggle.dataset.suiThemeToggle) {
|
|
110
|
-
toggle.addEventListener('click', this.toggleTheme);
|
|
111
|
-
toggle.dataset.suiThemeToggle = 'true';
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Allows for adding a callback that gets called whenever the theme changes.
|
|
117
|
-
* @param callback The callback to be executed
|
|
118
|
-
*/
|
|
119
|
-
public onThemeChange = (callback: ThemeChangeCallback): void => {
|
|
120
|
-
if (!this.observer) {
|
|
121
|
-
this.observer = new MutationObserver(this.themeManagerMutationHandler);
|
|
122
|
-
this.observer.observe(this.themeManagerElement, {
|
|
123
|
-
attributes: true,
|
|
124
|
-
attributeOldValue: true,
|
|
125
|
-
attributeFilter: ['data-theme'],
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
this.themeChangeCallbacks.push(callback);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Simply gets the first mutation and calls all registered callbacks.
|
|
134
|
-
* @param mutations The mutations array from the observer. Due to the specified options, this will always be a 1-length array,
|
|
135
|
-
*/
|
|
136
|
-
private themeManagerMutationHandler = (mutations: MutationRecord[]): void => {
|
|
137
|
-
if (!mutations[0]) return;
|
|
138
|
-
|
|
139
|
-
for (const callback of this.themeChangeCallbacks) {
|
|
140
|
-
callback(this.getTheme(), (mutations[0].oldValue as Theme) || 'system');
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export { ThemeHelper, type Theme };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname, resolve } from 'pathe';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* From the Astro Integration Kit (https://astro-integration-kit.netlify.app/).
|
|
6
|
-
*
|
|
7
|
-
* Allows resolving paths relatively to the integration folder easily. Call it like this:
|
|
8
|
-
*
|
|
9
|
-
* @param {string} _base - The location you want to create relative references from. `import.meta.url` is usually what you'll want.
|
|
10
|
-
*
|
|
11
|
-
* @see https://astro-integration-kit.netlify.app/core/create-resolver/
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* const { resolve } = createResolver(import.meta.url);
|
|
16
|
-
* const pluginPath = resolve("./plugin.ts");
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* This way, you do not have to add your plugin to your package.json `exports`.
|
|
20
|
-
*/
|
|
21
|
-
export const createResolver = (_base: string) => {
|
|
22
|
-
let base = _base;
|
|
23
|
-
if (base.startsWith('file://')) {
|
|
24
|
-
base = dirname(fileURLToPath(base));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
resolve: (...path: Array<string>) => resolve(base, ...path),
|
|
29
|
-
};
|
|
30
|
-
};
|