@studiocms/ui 0.3.1 → 0.3.2
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/package.json
CHANGED
|
@@ -9,11 +9,16 @@ interface Props {
|
|
|
9
9
|
background?: 'background-base' | 'background-step-1' | 'background-step-2' | 'background-step-3';
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
const hasDefaultSlot = Astro.slots.has('default');
|
|
13
|
+
|
|
12
14
|
const { background = 'background-base' } = Astro.props;
|
|
13
15
|
---
|
|
14
16
|
<div class="sui-divider-container">
|
|
15
17
|
<hr class="sui-divider-line" />
|
|
16
|
-
<div
|
|
18
|
+
<div
|
|
19
|
+
class="sui-divider-content"
|
|
20
|
+
style={`background-color: hsl(var(--${background})); padding: ${hasDefaultSlot ? '.25rem .5rem;' : '0'}`}
|
|
21
|
+
>
|
|
17
22
|
<slot />
|
|
18
23
|
</div>
|
|
19
24
|
</div>
|
|
@@ -28,9 +33,8 @@ const { background = 'background-base' } = Astro.props;
|
|
|
28
33
|
|
|
29
34
|
.sui-divider-line {
|
|
30
35
|
position: absolute;
|
|
31
|
-
top: 50%;
|
|
32
36
|
left: 50%;
|
|
33
|
-
transform: translate(-50%,
|
|
37
|
+
transform: translate(-50%, 0);
|
|
34
38
|
width: 100%;
|
|
35
39
|
height: 1px;
|
|
36
40
|
background-color: hsl(var(--border));
|
|
@@ -39,7 +43,6 @@ const { background = 'background-base' } = Astro.props;
|
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
.sui-divider-content {
|
|
42
|
-
padding: .25rem .5rem;
|
|
43
46
|
z-index: 2;
|
|
44
47
|
color: hsl(var(--text-muted));
|
|
45
48
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { AstroError } from 'astro/errors';
|
|
2
3
|
import { Icon } from '../../utils';
|
|
3
4
|
import type { StudioCMSColorway } from '../../utils/colors';
|
|
4
5
|
import { generateID } from '../../utils/generateID';
|
|
@@ -77,8 +78,21 @@ const markTabAsActive = (tabId: string, html: string): string => {
|
|
|
77
78
|
if (!tabId) return html;
|
|
78
79
|
|
|
79
80
|
const updatedHtml = html.replace(
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
}
|
|
82
96
|
);
|
|
83
97
|
|
|
84
98
|
return updatedHtml;
|
|
@@ -288,6 +302,9 @@ const containerId = generateID('sui-tabs-container');
|
|
|
288
302
|
font-size: 0.875em;
|
|
289
303
|
outline: 2px solid transparent;
|
|
290
304
|
outline-offset: 2px;
|
|
305
|
+
display: flex;
|
|
306
|
+
align-items: center;
|
|
307
|
+
justify-content: center;
|
|
291
308
|
}
|
|
292
309
|
|
|
293
310
|
.sui-tab-header * {
|