@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
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { AstroError } from 'astro/errors';
|
|
3
|
-
import { Icon } from '../../utils';
|
|
4
|
-
import type { StudioCMSColorway } from '../../utils/colors';
|
|
5
|
-
import { generateID } from '../../utils/generateID';
|
|
6
|
-
import type { HeroIconName } from '../../utils/iconType';
|
|
7
|
-
|
|
8
|
-
interface Tab {
|
|
9
|
-
icon?: HeroIconName;
|
|
10
|
-
label: string;
|
|
11
|
-
color: Exclude<StudioCMSColorway, 'default'>;
|
|
12
|
-
tabId: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The props for the Tabs component.
|
|
17
|
-
*/
|
|
18
|
-
interface Props {
|
|
19
|
-
/**
|
|
20
|
-
* The sync key for the tabs. If provided, the active tab will be synced across all instances of the tabs with the same sync key.
|
|
21
|
-
* Additionally, the active tab will be stored session- or local storage depending on the `storage` prop.
|
|
22
|
-
*/
|
|
23
|
-
syncKey?: string;
|
|
24
|
-
/**
|
|
25
|
-
* The storage type for the tabs. Defaults to `session`.
|
|
26
|
-
*/
|
|
27
|
-
storage?: 'session' | 'persistent';
|
|
28
|
-
/**
|
|
29
|
-
* The variant of the tabs. Defaults to `default`.
|
|
30
|
-
*/
|
|
31
|
-
variant?: 'default' | 'starlight';
|
|
32
|
-
/**
|
|
33
|
-
* The alignment of the tabs. Defaults to `left`.
|
|
34
|
-
*/
|
|
35
|
-
align?: 'left' | 'center' | 'right';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const extractTabInfoWithRegex = (input: string) => {
|
|
39
|
-
const tabItemRegex = /<sui-tab-item([^>]*)>/g;
|
|
40
|
-
|
|
41
|
-
const attributeRegex = /data-([\w-]+)="([^"]*)"/g;
|
|
42
|
-
|
|
43
|
-
const tabs: Tab[] = [];
|
|
44
|
-
let tabMatch: RegExpExecArray | null;
|
|
45
|
-
|
|
46
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: Nop
|
|
47
|
-
while ((tabMatch = tabItemRegex.exec(input)) !== null) {
|
|
48
|
-
let attributes: { [key: string]: string } = {};
|
|
49
|
-
|
|
50
|
-
let attributeMatch: RegExpExecArray | null;
|
|
51
|
-
|
|
52
|
-
if (!tabMatch[1]) continue;
|
|
53
|
-
|
|
54
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: Nop
|
|
55
|
-
while ((attributeMatch = attributeRegex.exec(tabMatch[1])) !== null) {
|
|
56
|
-
if (!attributeMatch[1] || !attributeMatch[2]) continue;
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
attributeMatch[1] === 'icon' ||
|
|
60
|
-
attributeMatch[1] === 'label' ||
|
|
61
|
-
attributeMatch[1] === 'color'
|
|
62
|
-
) {
|
|
63
|
-
attributes[attributeMatch[1]] = attributeMatch[2];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (attributeMatch[1] === 'tab-id') {
|
|
67
|
-
attributes.tabId = attributeMatch[2];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
tabs.push(attributes as unknown as Tab);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return tabs;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const markTabAsActive = (tabId: string, html: string): string => {
|
|
78
|
-
if (!tabId) return html;
|
|
79
|
-
|
|
80
|
-
const updatedHtml = html.replace(
|
|
81
|
-
/<sui-tab-item[^>]*data-tab-id="([^"]*)"[^>]*>/g,
|
|
82
|
-
(match, tabIdValue) => {
|
|
83
|
-
// Check if the tabId matches
|
|
84
|
-
if (tabIdValue === tabId) {
|
|
85
|
-
// Check if the element already has a class attribute
|
|
86
|
-
if (match.includes('class="')) {
|
|
87
|
-
// If class attribute exists, add 'active' to the class attribute
|
|
88
|
-
return match.replace(/(class="[^"]*)"/, '$1 active"');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// If class attribute does not exist, add it
|
|
92
|
-
return match.replace(/(<sui-tab-item[^>]*data-tab-id="[^"]*")/, '$1 class="active"');
|
|
93
|
-
}
|
|
94
|
-
return match; // Return original if the tabId does not match
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
return updatedHtml;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const uniqueId = generateID('sui-tabs-container');
|
|
102
|
-
|
|
103
|
-
const {
|
|
104
|
-
syncKey: originalSyncKey,
|
|
105
|
-
storage = 'session',
|
|
106
|
-
variant = 'default',
|
|
107
|
-
align = 'left',
|
|
108
|
-
} = Astro.props;
|
|
109
|
-
|
|
110
|
-
const syncKey = originalSyncKey ? `sui-tabs-${originalSyncKey}` : undefined;
|
|
111
|
-
|
|
112
|
-
const tabContents = await Astro.slots.render('default');
|
|
113
|
-
const tabs = extractTabInfoWithRegex(tabContents);
|
|
114
|
-
const finalizedTabContents = markTabAsActive(tabs[0]?.tabId || '', tabContents);
|
|
115
|
-
const containerId = generateID('sui-tabs-container');
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
<div
|
|
119
|
-
class="sui-tabs-container"
|
|
120
|
-
id={containerId}
|
|
121
|
-
data-sync-key={syncKey}
|
|
122
|
-
data-unique-id={uniqueId}
|
|
123
|
-
data-storage-strategy={storage}
|
|
124
|
-
class:list={[variant, align]}
|
|
125
|
-
>
|
|
126
|
-
<div class="sui-tabs-list" role="tablist">
|
|
127
|
-
{tabs.map((tab, i) => (
|
|
128
|
-
<button
|
|
129
|
-
role="tab"
|
|
130
|
-
class="sui-tab-header"
|
|
131
|
-
id={syncKey ? `${syncKey}-${i}` : undefined}
|
|
132
|
-
tabindex={i === 0 ? 0 : -1}
|
|
133
|
-
data-tab-child={tab.tabId}
|
|
134
|
-
class:list={[i === 0 && "active", tab.color, syncKey && `${syncKey}:${i}`]}
|
|
135
|
-
>
|
|
136
|
-
{tab.icon && (
|
|
137
|
-
<Icon name={tab.icon} width={24} height={24} />
|
|
138
|
-
)}
|
|
139
|
-
<span>{tab.label}</span>
|
|
140
|
-
</button>
|
|
141
|
-
))}
|
|
142
|
-
</div>
|
|
143
|
-
<div class="sui-tabs-content">
|
|
144
|
-
<Fragment set:html={finalizedTabContents} />
|
|
145
|
-
</div>
|
|
146
|
-
</div>
|
|
147
|
-
<script>
|
|
148
|
-
const tabContainers = document.querySelectorAll<HTMLDivElement>('.sui-tabs-container');
|
|
149
|
-
|
|
150
|
-
for (const tabContainer of tabContainers) {
|
|
151
|
-
const storage = tabContainer.dataset.storageStrategy!;
|
|
152
|
-
const syncKey = tabContainer.dataset.syncKey!;
|
|
153
|
-
|
|
154
|
-
let storageLayer = storage === 'session' ? sessionStorage : localStorage;
|
|
155
|
-
|
|
156
|
-
const constructCustomEvent = (tabIndex: number, uniqueId: string) => {
|
|
157
|
-
return new CustomEvent(`sui-tab-switch:${syncKey}`, {
|
|
158
|
-
detail: {
|
|
159
|
-
tabIndex,
|
|
160
|
-
uniqueId
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const switchTab = (target: HTMLElement, container: HTMLElement, originatedFromSync = false) => {
|
|
166
|
-
const activeChildren = container.querySelectorAll<HTMLElement>('.active');
|
|
167
|
-
|
|
168
|
-
for (const child of activeChildren) {
|
|
169
|
-
child.tabIndex = -1;
|
|
170
|
-
child.classList.remove('active');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const newActiveTab = target as HTMLElement;
|
|
174
|
-
newActiveTab.classList.add('active');
|
|
175
|
-
newActiveTab.tabIndex = 0;
|
|
176
|
-
|
|
177
|
-
const newActiveTabContentId = newActiveTab.dataset.tabChild;
|
|
178
|
-
const newActiveTabContent = container.querySelector<HTMLElement>(`sui-tab-item[data-tab-id="${newActiveTabContentId}"]`)!;
|
|
179
|
-
|
|
180
|
-
newActiveTabContent.classList.add('active');
|
|
181
|
-
|
|
182
|
-
if (syncKey && !originatedFromSync) {
|
|
183
|
-
const tabIndex = Array.prototype.indexOf.call(newActiveTab.parentElement!.children, newActiveTab);
|
|
184
|
-
storageLayer.setItem(syncKey, tabIndex.toString());
|
|
185
|
-
|
|
186
|
-
document.dispatchEvent(constructCustomEvent(tabIndex, container.dataset.uniqueId!));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const tabHeaders = tabContainer.querySelectorAll<HTMLElement>('.sui-tab-header');
|
|
192
|
-
|
|
193
|
-
for (const tab of tabHeaders) {
|
|
194
|
-
tab.addEventListener('click', (e) => switchTab(e.target as HTMLElement, tabContainer));
|
|
195
|
-
|
|
196
|
-
tab.addEventListener('keydown', (e) => {
|
|
197
|
-
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
|
198
|
-
const activeTabIndex = Array.prototype.indexOf.call(tab.parentElement!.children, tab);
|
|
199
|
-
const nextTabIndex = e.key === 'ArrowLeft' ? activeTabIndex - 1 : activeTabIndex + 1;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (nextTabIndex >= 0 && nextTabIndex < tab.parentElement!.children.length) {
|
|
203
|
-
tab.tabIndex = -1;
|
|
204
|
-
|
|
205
|
-
const nextTab = tab.parentElement!.children[nextTabIndex]! as HTMLElement;
|
|
206
|
-
|
|
207
|
-
nextTab.tabIndex = 0;
|
|
208
|
-
nextTab.click();
|
|
209
|
-
nextTab.focus();
|
|
210
|
-
} else if (nextTabIndex < 0) {
|
|
211
|
-
tab.tabIndex = -1;
|
|
212
|
-
|
|
213
|
-
const lastTab = tab.parentElement!.children[tab.parentElement!.children.length - 1] as HTMLElement;
|
|
214
|
-
|
|
215
|
-
lastTab.tabIndex = 0;
|
|
216
|
-
lastTab.click();
|
|
217
|
-
lastTab.focus();
|
|
218
|
-
} else {
|
|
219
|
-
tab.tabIndex = -1;
|
|
220
|
-
|
|
221
|
-
const firstTab = tab.parentElement!.children[0] as HTMLElement;
|
|
222
|
-
|
|
223
|
-
firstTab.tabIndex = 0;
|
|
224
|
-
firstTab.click();
|
|
225
|
-
firstTab.focus();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (syncKey) {
|
|
232
|
-
// Retrieve the sync key value from localstorage, set the tab.
|
|
233
|
-
const activeTabIndex = storageLayer.getItem(syncKey);
|
|
234
|
-
|
|
235
|
-
if (activeTabIndex) {
|
|
236
|
-
const activeTab = tabContainer.querySelector<HTMLElement>(`#${syncKey}-${activeTabIndex}`);
|
|
237
|
-
|
|
238
|
-
if (activeTab) {
|
|
239
|
-
activeTab.click();
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
document.addEventListener(`sui-tab-switch:${syncKey}`, (e) => {
|
|
244
|
-
const event = e as CustomEvent<{ tabIndex: number, uniqueId: string }>;
|
|
245
|
-
const { tabIndex, uniqueId } = event.detail;
|
|
246
|
-
|
|
247
|
-
if (uniqueId === tabContainer.dataset.uniqueId) return;
|
|
248
|
-
|
|
249
|
-
const newTab = tabContainer.querySelector<HTMLElement>(`#${syncKey}-${tabIndex}`)!;
|
|
250
|
-
|
|
251
|
-
switchTab(newTab, tabContainer, true);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
</script>
|
|
256
|
-
<style>
|
|
257
|
-
.sui-tabs-container {
|
|
258
|
-
width: 100%;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.sui-tabs-list {
|
|
262
|
-
display: flex;
|
|
263
|
-
flex-direction: row;
|
|
264
|
-
gap: 1rem;
|
|
265
|
-
align-items: center;
|
|
266
|
-
width: 100%;
|
|
267
|
-
overflow-x: auto;
|
|
268
|
-
overflow-y: visible;
|
|
269
|
-
position: relative;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
.default .sui-tabs-list {
|
|
273
|
-
margin-top: -4px;
|
|
274
|
-
margin-bottom: calc(2rem - 4px);
|
|
275
|
-
padding: 4px 4px;
|
|
276
|
-
margin-left: -4px;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
.center .sui-tabs-list {
|
|
280
|
-
justify-content: center;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
.right .sui-tabs-list {
|
|
284
|
-
justify-content: flex-end;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.sui-tab-header {
|
|
288
|
-
margin-top: 0 !important;
|
|
289
|
-
display: flex;
|
|
290
|
-
flex-direction: row;
|
|
291
|
-
gap: .5rem;
|
|
292
|
-
cursor: pointer;
|
|
293
|
-
position: relative;
|
|
294
|
-
min-width: fit-content;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
.default .sui-tab-header {
|
|
298
|
-
border-radius: 0.5rem;
|
|
299
|
-
height: 40px;
|
|
300
|
-
padding: 0.5rem 0.75rem;
|
|
301
|
-
transition: all .15s ease;
|
|
302
|
-
font-size: 0.875em;
|
|
303
|
-
outline: 2px solid transparent;
|
|
304
|
-
outline-offset: 2px;
|
|
305
|
-
display: flex;
|
|
306
|
-
align-items: center;
|
|
307
|
-
justify-content: center;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
.sui-tab-header * {
|
|
311
|
-
pointer-events: none;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.default .sui-tab-header:focus-visible {
|
|
315
|
-
outline: 2px solid hsl(var(--text-normal));
|
|
316
|
-
outline-offset: 2px;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
.default .sui-tab-header:hover {
|
|
320
|
-
background-color: hsla(var(--default-flat-active)) !important;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
.default .sui-tab-header.active {
|
|
324
|
-
background-color: hsla(var(--primary-flat-active)) !important;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
.default .sui-tab-header.success.active {
|
|
328
|
-
background-color: hsla(var(--success-flat-active)) !important;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.default .sui-tab-header.warning.active {
|
|
332
|
-
background-color: hsla(var(--warning-flat-active)) !important;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
.default .sui-tab-header.danger.active {
|
|
336
|
-
background-color: hsla(var(--danger-flat-active)) !important;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
.starlight .sui-tabs-list {
|
|
340
|
-
margin-bottom: 1rem;
|
|
341
|
-
gap: 0;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
.starlight .sui-tabs-list::before {
|
|
345
|
-
content: "";
|
|
346
|
-
position: absolute;
|
|
347
|
-
bottom: 0;
|
|
348
|
-
left: 0;
|
|
349
|
-
width: 100%;
|
|
350
|
-
height: 2px;
|
|
351
|
-
background-color: hsl(var(--border));
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
.starlight .sui-tab-header {
|
|
355
|
-
padding: 0.25rem 1.25rem;
|
|
356
|
-
color: hsl(var(--text-muted));
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
.starlight .sui-tab-header.active {
|
|
360
|
-
font-weight: 600;
|
|
361
|
-
color: hsl(var(--text-normal));
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
.starlight .sui-tab-header.active::after {
|
|
365
|
-
content: "";
|
|
366
|
-
width: 100%;
|
|
367
|
-
height: 2px;
|
|
368
|
-
background-color: hsl(var(--primary-base));
|
|
369
|
-
position: absolute;
|
|
370
|
-
bottom: 0;
|
|
371
|
-
left: 0;
|
|
372
|
-
z-index: 15;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
.starlight .sui-tab-header:focus-visible::after {
|
|
376
|
-
height: calc(100% - 2px);
|
|
377
|
-
width: calc(100% - 2px);
|
|
378
|
-
bottom: 1px;
|
|
379
|
-
left: 1px;
|
|
380
|
-
border: 2px solid hsl(var(--primary-base));
|
|
381
|
-
background-color: transparent;
|
|
382
|
-
outline: 1px solid hsl(var(--text-normal));
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
.default .sui-tab-header.active {
|
|
386
|
-
background-color: hsla(var(--primary-flat-active)) !important;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
.sui-tabs-content {
|
|
390
|
-
width: 100%;
|
|
391
|
-
margin: 0 !important;
|
|
392
|
-
}
|
|
393
|
-
</style>
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import Button, { type Props as ButtonProps } from './Button.astro';
|
|
3
|
-
|
|
4
|
-
interface Props extends ButtonProps {}
|
|
5
|
-
|
|
6
|
-
const props = Astro.props;
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
<Button id='sui-theme-toggle' {...props}>
|
|
10
|
-
<div id="dark-content">
|
|
11
|
-
<slot name="dark" />
|
|
12
|
-
</div>
|
|
13
|
-
<div id="light-content">
|
|
14
|
-
<slot name="light" />
|
|
15
|
-
</div>
|
|
16
|
-
</Button>
|
|
17
|
-
|
|
18
|
-
<script>
|
|
19
|
-
import { ThemeHelper } from '../utils/ThemeHelper';
|
|
20
|
-
|
|
21
|
-
const themeToggle = document.getElementById('sui-theme-toggle');
|
|
22
|
-
const themeHelper = new ThemeHelper();
|
|
23
|
-
|
|
24
|
-
themeHelper.registerToggle(themeToggle);
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<style is:global>
|
|
28
|
-
#sui-theme-toggle, #sui-theme-toggle * {
|
|
29
|
-
color: hsl(var(--text-normal));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
#sui-theme-toggle #dark-content, #sui-theme-toggle #light-content {
|
|
33
|
-
display: none;
|
|
34
|
-
width: fit-content;
|
|
35
|
-
height: fit-content;
|
|
36
|
-
max-height: 100%;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
[data-theme="dark"] #sui-theme-toggle #dark-content {
|
|
40
|
-
display: block;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
[data-theme="light"] #sui-theme-toggle #light-content {
|
|
44
|
-
display: block;
|
|
45
|
-
}
|
|
46
|
-
</style>
|