@studiocms/ui 0.3.1 → 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.
Files changed (157) hide show
  1. package/dist/components/Accordion/Accordion.astro +23 -0
  2. package/dist/components/Accordion/Item.astro +21 -0
  3. package/dist/components/Accordion/accordion.css +64 -0
  4. package/dist/components/Accordion/accordion.d.ts +1 -0
  5. package/dist/components/Accordion/accordion.js +70 -0
  6. package/dist/components/Badge/Badge.astro +49 -0
  7. package/dist/components/Badge/badge.css +111 -0
  8. package/dist/components/Breadcrumbs/Breadcrumbs.astro +31 -0
  9. package/dist/components/Breadcrumbs/breadcrumbs.css +15 -0
  10. package/dist/components/Button/Button.astro +75 -0
  11. package/dist/components/Button/button.css +292 -0
  12. package/{src/components → dist/components/Card}/Card.astro +1 -48
  13. package/dist/components/Card/card.css +38 -0
  14. package/dist/components/Center/Center.astro +7 -0
  15. package/dist/components/Center/center.css +8 -0
  16. package/dist/components/Checkbox/Checkbox.astro +95 -0
  17. package/dist/components/Checkbox/checkbox.css +119 -0
  18. package/dist/components/Checkbox/checkbox.d.ts +2 -0
  19. package/dist/components/Checkbox/checkbox.js +20 -0
  20. package/dist/components/Divider/Divider.astro +26 -0
  21. package/dist/components/Divider/divider.css +21 -0
  22. package/dist/components/Dropdown/Dropdown.astro +116 -0
  23. package/dist/components/Dropdown/dropdown.css +180 -0
  24. package/dist/components/Dropdown/dropdown.d.ts +48 -0
  25. package/dist/components/Dropdown/dropdown.js +201 -0
  26. package/dist/components/Footer/Footer.astro +58 -0
  27. package/dist/components/Footer/footer.css +68 -0
  28. package/dist/components/Group/Group.astro +7 -0
  29. package/dist/components/Group/group.css +19 -0
  30. package/{src/utils → dist/components/Icon}/Icon.astro +1 -1
  31. package/{src/utils/iconType.ts → dist/components/Icon/iconType.d.ts} +0 -1
  32. package/dist/components/Icon/iconType.js +0 -0
  33. package/{src/components → dist/components/Input}/Input.astro +2 -48
  34. package/dist/components/Input/input.css +38 -0
  35. package/{src → dist}/components/Modal/Modal.astro +4 -122
  36. package/dist/components/Modal/modal.css +100 -0
  37. package/dist/components/Modal/modal.d.ts +48 -0
  38. package/dist/components/Modal/modal.js +129 -0
  39. package/dist/components/Progress/Progress.astro +21 -0
  40. package/dist/components/Progress/helper.d.ts +13 -0
  41. package/dist/components/Progress/helper.js +32 -0
  42. package/dist/components/Progress/progress.css +29 -0
  43. package/dist/components/Progress/progress.d.ts +1 -0
  44. package/dist/components/Progress/progress.js +10 -0
  45. package/dist/components/RadioGroup/RadioGroup.astro +124 -0
  46. package/dist/components/RadioGroup/radiogroup.css +96 -0
  47. package/dist/components/RadioGroup/radiogroup.d.ts +1 -0
  48. package/dist/components/RadioGroup/radiogroup.js +48 -0
  49. package/{src/components → dist/components/Row}/Row.astro +1 -24
  50. package/dist/components/Row/row.css +18 -0
  51. package/dist/components/SearchSelect/SearchSelect.astro +135 -0
  52. package/dist/components/SearchSelect/searchselect.css +95 -0
  53. package/dist/components/SearchSelect/searchselect.d.ts +6 -0
  54. package/dist/components/SearchSelect/searchselect.js +166 -0
  55. package/dist/components/Select/Select.astro +147 -0
  56. package/dist/components/Select/select.css +110 -0
  57. package/dist/components/Select/select.d.ts +1 -0
  58. package/dist/components/Select/select.js +143 -0
  59. package/dist/components/Sidebar/helpers.d.ts +76 -0
  60. package/dist/components/Sidebar/helpers.js +160 -0
  61. package/{src → dist}/components/Tabs/TabItem.astro +3 -4
  62. package/dist/components/Tabs/Tabs.astro +150 -0
  63. package/dist/components/Tabs/tabs.css +121 -0
  64. package/dist/components/Tabs/tabs.d.ts +1 -0
  65. package/dist/components/Tabs/tabs.js +82 -0
  66. package/{src/components → dist/components/Textarea}/Textarea.astro +2 -61
  67. package/dist/components/Textarea/textarea.css +49 -0
  68. package/dist/components/ThemeToggle/ThemeToggle.astro +21 -0
  69. package/dist/components/ThemeToggle/themetoggle.css +17 -0
  70. package/dist/components/ThemeToggle/themetoggle.d.ts +1 -0
  71. package/dist/components/ThemeToggle/themetoggle.js +4 -0
  72. package/dist/components/Toast/Toaster.astro +69 -0
  73. package/dist/components/Toast/toast.d.ts +8 -0
  74. package/dist/components/Toast/toast.js +9 -0
  75. package/dist/components/Toast/toaster.css +168 -0
  76. package/dist/components/Toast/toaster.d.ts +1 -0
  77. package/dist/components/Toast/toaster.js +160 -0
  78. package/dist/components/Toggle/Toggle.astro +84 -0
  79. package/dist/components/Toggle/toggle.css +93 -0
  80. package/dist/components/Toggle/toggle.d.ts +2 -0
  81. package/dist/components/Toggle/toggle.js +20 -0
  82. package/{src/components → dist/components/User}/User.astro +3 -43
  83. package/dist/components/User/user.css +35 -0
  84. package/dist/css/colors.css +95 -0
  85. package/dist/css/global.css +3 -0
  86. package/dist/css/radii.css +6 -0
  87. package/dist/css/resets.css +46 -0
  88. package/dist/index.d.ts +12 -0
  89. package/dist/index.js +379 -0
  90. package/dist/toolbar/ColorPicker.d.ts +7 -0
  91. package/dist/toolbar/ColorPicker.js +85 -0
  92. package/dist/toolbar/icon.d.ts +1 -0
  93. package/dist/toolbar/icon.js +4 -0
  94. package/dist/toolbar/index.d.ts +2 -0
  95. package/dist/toolbar/index.js +292 -0
  96. package/dist/types/index.d.ts +11 -0
  97. package/dist/types/index.js +0 -0
  98. package/dist/utils/ThemeHelper.d.ts +49 -0
  99. package/dist/utils/ThemeHelper.js +113 -0
  100. package/{src/utils/colors.ts → dist/utils/colors.d.ts} +1 -1
  101. package/dist/utils/colors.js +0 -0
  102. package/dist/utils/generateID.d.ts +2 -0
  103. package/dist/utils/generateID.js +6 -0
  104. package/dist/utils/headers.d.ts +43 -0
  105. package/dist/utils/headers.js +129 -0
  106. package/dist/utils/iconStrings.d.ts +4 -0
  107. package/dist/utils/iconStrings.js +13 -0
  108. package/dist/utils/integration-utils.d.ts +130 -0
  109. package/dist/utils/integration-utils.js +161 -0
  110. package/package.json +25 -9
  111. package/src/components/BaseHead.astro +0 -22
  112. package/src/components/Button.astro +0 -372
  113. package/src/components/Center.astro +0 -16
  114. package/src/components/Checkbox.astro +0 -250
  115. package/src/components/Divider.astro +0 -46
  116. package/src/components/Dropdown/Dropdown.astro +0 -314
  117. package/src/components/Dropdown/dropdown.ts +0 -258
  118. package/src/components/Dropdown/index.ts +0 -2
  119. package/src/components/Footer.astro +0 -137
  120. package/src/components/Modal/index.ts +0 -2
  121. package/src/components/Modal/modal.ts +0 -163
  122. package/src/components/RadioGroup.astro +0 -299
  123. package/src/components/SearchSelect.astro +0 -486
  124. package/src/components/Select.astro +0 -467
  125. package/src/components/Sidebar/helpers.ts +0 -179
  126. package/src/components/Sidebar/index.ts +0 -3
  127. package/src/components/Tabs/Tabs.astro +0 -376
  128. package/src/components/Tabs/index.ts +0 -2
  129. package/src/components/ThemeToggle.astro +0 -46
  130. package/src/components/Toast/Toaster.astro +0 -470
  131. package/src/components/Toast/index.ts +0 -2
  132. package/src/components/Toast/toast.ts +0 -16
  133. package/src/components/Toggle.astro +0 -214
  134. package/src/components/index.ts +0 -27
  135. package/src/components.ts +0 -26
  136. package/src/css/colors.css +0 -106
  137. package/src/css/global.css +0 -2
  138. package/src/css/resets.css +0 -54
  139. package/src/env.d.ts +0 -15
  140. package/src/integration.ts +0 -31
  141. package/src/layouts/RootLayout.astro +0 -33
  142. package/src/layouts/index.ts +0 -2
  143. package/src/layouts.ts +0 -1
  144. package/src/types/index.ts +0 -11
  145. package/src/utils/ThemeHelper.ts +0 -145
  146. package/src/utils/create-resolver.ts +0 -30
  147. package/src/utils/generateID.ts +0 -5
  148. package/src/utils/headers.ts +0 -190
  149. package/src/utils/iconStrings.ts +0 -29
  150. package/src/utils/index.ts +0 -1
  151. package/src/utils/virtual-module-plugin-builder.ts +0 -37
  152. /package/{src → dist}/components/Sidebar/Double.astro +0 -0
  153. /package/{src → dist}/components/Sidebar/Single.astro +0 -0
  154. /package/{src → dist}/icons/Checkmark.astro +0 -0
  155. /package/{src → dist}/icons/ChevronUpDown.astro +0 -0
  156. /package/{src → dist}/icons/User.astro +0 -0
  157. /package/{src → dist}/icons/X-Mark.astro +0 -0
@@ -0,0 +1,23 @@
1
+ ---
2
+ import './accordion.css';
3
+
4
+ interface Props {
5
+ /**
6
+ * Whether multiple items in the accordion can be open at once. Default is `true`.
7
+ */
8
+ multipleOpen?: boolean;
9
+ /**
10
+ * The style of the accordion. Default is `outlined`
11
+ */
12
+ style?: 'outlined' | 'separated' | 'filled' | 'blank';
13
+ }
14
+
15
+ const { style = 'outlined', multipleOpen = true } = Astro.props;
16
+ ---
17
+
18
+ <div class="sui-accordion" class:list={[style]} data-multiple={multipleOpen}>
19
+ <slot />
20
+ </div>
21
+ <script>
22
+ import 'studiocms:ui/scripts/accordion';
23
+ </script>
@@ -0,0 +1,21 @@
1
+ ---
2
+ import Icon from '../Icon/Icon.astro';
3
+
4
+ interface Props {
5
+ open?: boolean;
6
+ }
7
+
8
+ const { open = false } = Astro.props;
9
+ ---
10
+
11
+ <div class="sui-accordion-item" class:list={{ active: open }} data-open={open}>
12
+ <div class="sui-accordion-summary not-content" tabindex="0">
13
+ <Icon name="chevron-right-20-solid" class='sui-summary-chevron' width={20} height={20} />
14
+ <div class="sui-accordion-summary-content">
15
+ <slot name="summary" />
16
+ </div>
17
+ </div>
18
+ <div class="sui-accordion-details" class:list={{ active: open, open: open, initial: !open }}>
19
+ <slot name="default" />
20
+ </div>
21
+ </div>
@@ -0,0 +1,64 @@
1
+ .sui-accordion {
2
+ width: 100%;
3
+ }
4
+ .sui-accordion-item,
5
+ .sui-accordion-details {
6
+ margin-top: 0 !important;
7
+ }
8
+ .sui-accordion-details {
9
+ margin-left: calc(2.25rem);
10
+ }
11
+ .sui-accordion-details.initial {
12
+ visibility: hidden;
13
+ transition: none;
14
+ max-height: none;
15
+ position: absolute;
16
+ top: -200vh;
17
+ left: -200vh;
18
+ }
19
+ .sui-accordion-details.active {
20
+ overflow: hidden;
21
+ max-height: 0;
22
+ transition: all .3s ease;
23
+ position: relative;
24
+ bottom: .25rem;
25
+ }
26
+ .sui-accordion-details.open {
27
+ max-height: none;
28
+ }
29
+ .sui-accordion.outlined,
30
+ .sui-accordion.filled {
31
+ border: 1px solid hsl(var(--border));
32
+ border-radius: var(--radius-sm);
33
+ }
34
+ .sui-accordion.filled {
35
+ background-color: hsl(var(--background-step-1));
36
+ }
37
+ .sui-accordion.separated .sui-accordion-item,
38
+ .sui-accordion.outlined .sui-accordion-item,
39
+ .sui-accordion.filled .sui-accordion-item {
40
+ border-bottom: 1px solid hsl(var(--border));
41
+ }
42
+ .sui-accordion.separated .sui-accordion-item:first-of-type {
43
+ border-top: 1px solid hsl(var(--border));
44
+ }
45
+ .sui-accordion.filled .sui-accordion-item:last-of-type,
46
+ .sui-accordion.outlined .sui-accordion-item:last-of-type {
47
+ border-bottom: none;
48
+ }
49
+ .sui-accordion-summary {
50
+ color: hsl(var(--text-normal));
51
+ display: flex;
52
+ flex-direction: row;
53
+ gap: .5rem;
54
+ align-items: center;
55
+ padding-left: .5rem;
56
+ padding-bottom: .5rem;
57
+ padding-top: .5rem;
58
+ }
59
+ .sui-summary-chevron {
60
+ transition: all .3s ease;
61
+ }
62
+ .sui-accordion-item.active .sui-summary-chevron {
63
+ transform: rotate(90deg);
64
+ }
@@ -0,0 +1 @@
1
+ declare const allAccordions: NodeListOf<HTMLDivElement>;
@@ -0,0 +1,70 @@
1
+ const allAccordions = document.querySelectorAll(".sui-accordion");
2
+ for (const accordion of allAccordions) {
3
+ const multipleOpen = accordion.dataset.multiple === "true";
4
+ const items = accordion.querySelectorAll(".sui-accordion-item");
5
+ for (const item of items) {
6
+ const summary = item.querySelector(".sui-accordion-summary");
7
+ const content = item.querySelector(".sui-accordion-details");
8
+ if (!content || !summary) continue;
9
+ const itemWidth = item.getBoundingClientRect().width;
10
+ content.style.width = `${itemWidth - 36}px`;
11
+ let contentBoundingBox = content.getBoundingClientRect();
12
+ content.style.width = "auto";
13
+ if (content.classList.contains("initial")) {
14
+ content.classList.remove("initial");
15
+ content.classList.add("active");
16
+ }
17
+ const open = item.dataset.open === "true";
18
+ if (open) {
19
+ item.classList.add("active");
20
+ content.style.maxHeight = `${contentBoundingBox.height}px`;
21
+ }
22
+ const toggleElement = () => {
23
+ if (!multipleOpen) {
24
+ for (const otherItem of items) {
25
+ if (otherItem !== item) {
26
+ otherItem.classList.remove("active");
27
+ const otherContent = otherItem.querySelector(".sui-accordion-details");
28
+ if (otherContent) {
29
+ otherContent.style.maxHeight = "0";
30
+ }
31
+ }
32
+ }
33
+ }
34
+ item.classList.toggle("active");
35
+ if (item.classList.contains("active")) {
36
+ content.style.maxHeight = `${contentBoundingBox.height}px`;
37
+ } else {
38
+ content.style.maxHeight = "0";
39
+ content.classList.remove("open");
40
+ }
41
+ };
42
+ summary.addEventListener("click", toggleElement);
43
+ summary.addEventListener("keydown", (event) => {
44
+ if (event.key === "Enter" || event.key === " ") {
45
+ toggleElement();
46
+ }
47
+ });
48
+ let resetting = false;
49
+ window.addEventListener("resize", async () => {
50
+ if (item.classList.contains("active")) {
51
+ content.style.maxHeight = "none";
52
+ contentBoundingBox = content.getBoundingClientRect();
53
+ content.style.maxHeight = `${contentBoundingBox.height}px`;
54
+ } else if (!resetting) {
55
+ resetting = true;
56
+ content.classList.remove("active");
57
+ content.classList.add("initial");
58
+ const itemWidth2 = item.getBoundingClientRect().width;
59
+ content.style.width = `${itemWidth2 - 36}px`;
60
+ content.style.maxHeight = "none";
61
+ contentBoundingBox = content.getBoundingClientRect();
62
+ content.style.width = "auto";
63
+ content.style.maxHeight = "0";
64
+ content.classList.add("active");
65
+ content.classList.remove("initial");
66
+ resetting = false;
67
+ }
68
+ });
69
+ }
70
+ }
@@ -0,0 +1,49 @@
1
+ ---
2
+ import type { StudioCMSColorway } from '../../utils/colors.js';
3
+ import './badge.css';
4
+ import type { HTMLAttributes } from 'astro/types';
5
+ import Icon from '../Icon/Icon.astro';
6
+ import type { HeroIconName } from '../Icon/iconType.js';
7
+
8
+ interface Props extends Omit<HTMLAttributes<'span'>, 'color'> {
9
+ /**
10
+ * The color of the badge. Defaults to `primary`.
11
+ */
12
+ color?: Omit<StudioCMSColorway, 'default'>;
13
+ /**
14
+ * The icon to display in the badge.
15
+ */
16
+ icon?: HeroIconName;
17
+ /**
18
+ * The size of the badge. Defaults to `md`.
19
+ */
20
+ size?: 'sm' | 'md' | 'lg';
21
+ /**
22
+ * The variant of the badge. Defaults to `default`.
23
+ */
24
+ variant?: 'default' | 'flat' | 'outline';
25
+ /**
26
+ * The rounding of the badge. Full is a half-circle, semi is a quarter-circle. Defaults to `full`.
27
+ */
28
+ rounding?: 'full' | 'semi';
29
+ /**
30
+ * The label of the badge.
31
+ */
32
+ label: string;
33
+ }
34
+
35
+ const {
36
+ color = 'primary',
37
+ icon,
38
+ size = 'md',
39
+ variant = 'default',
40
+ rounding = 'full',
41
+ label,
42
+ ...props
43
+ } = Astro.props;
44
+ ---
45
+
46
+ <span class="sui-badge" class:list={[color, size, variant, rounding]} {...props}>
47
+ {icon && <Icon name={icon} width={16} height={16} />}
48
+ {label}
49
+ </span>
@@ -0,0 +1,111 @@
1
+ .sui-badge {
2
+ display: flex;
3
+ flex-direction: row;
4
+ gap: .5rem;
5
+ align-items: center;
6
+ padding: .125rem .75rem;
7
+ border-radius: var(--radius-full);
8
+ font-size: .875rem;
9
+ }
10
+ .sui-badge.semi {
11
+ border-radius: var(--radius-md);
12
+ }
13
+ .sui-badge.primary {
14
+ background-color: hsl(var(--primary-base));
15
+ color: hsl(var(--text-inverted));
16
+ }
17
+ .sui-badge.primary.flat,
18
+ .sui-badge.primary.outlined {
19
+ background-color: hsla(var(--primary-flat));
20
+ color: hsl(var(--primary-base));
21
+ }
22
+ .sui-badge.primary.outlined {
23
+ border: 1px solid hsl(var(--primary-base));
24
+ }
25
+ .sui-badge.success {
26
+ background-color: hsl(var(--success-base));
27
+ color: hsl(var(--text-inverted));
28
+ }
29
+ .sui-badge.success.flat,
30
+ .sui-badge.success.outlined {
31
+ background-color: hsla(var(--success-flat));
32
+ color: hsl(var(--success-base));
33
+ }
34
+ .sui-badge.success.outlined {
35
+ border: 1px solid hsl(var(--success-base));
36
+ }
37
+ .sui-badge.warning {
38
+ background-color: hsl(var(--warning-base));
39
+ color: hsl(var(--text-inverted));
40
+ }
41
+ .sui-badge.warning.flat,
42
+ .sui-badge.warning.outlined {
43
+ background-color: hsla(var(--warning-flat));
44
+ color: hsl(var(--warning-base));
45
+ }
46
+ .sui-badge.warning.outlined {
47
+ border: 1px solid hsl(var(--warning-base));
48
+ }
49
+ .sui-badge.danger {
50
+ background-color: hsl(var(--danger-base));
51
+ color: hsl(var(--text-normal));
52
+ }
53
+ .sui-badge.danger.flat,
54
+ .sui-badge.danger.outlined {
55
+ background-color: hsla(var(--danger-flat));
56
+ color: hsl(var(--danger-base));
57
+ }
58
+ .sui-badge.danger.outlined {
59
+ border: 1px solid hsl(var(--danger-base));
60
+ }
61
+ .sui-badge.info {
62
+ background-color: hsl(var(--info-base));
63
+ color: hsl(var(--text-normal));
64
+ }
65
+ .sui-badge.info.flat,
66
+ .sui-badge.info.outlined {
67
+ background-color: hsla(var(--info-flat));
68
+ color: hsl(var(--info-base));
69
+ }
70
+ .sui-badge.info.outlined {
71
+ border: 1px solid hsl(var(--info-base));
72
+ }
73
+ .sui-badge.mono {
74
+ background-color: hsl(var(--mono-base));
75
+ color: hsl(var(--text-inverted));
76
+ }
77
+ .sui-badge.mono.flat,
78
+ .sui-badge.mono.outlined {
79
+ background-color: hsla(var(--mono-flat));
80
+ color: hsl(var(--mono-base));
81
+ }
82
+ .sui-badge.mono.outlined {
83
+ border: 1px solid hsl(var(--mono-base));
84
+ }
85
+ [data-theme=light] .sui-badge.danger {
86
+ color: hsl(var(--text-inverted));
87
+ }
88
+ [data-theme=light] .sui-badge.info {
89
+ color: hsl(var(--text-inverted));
90
+ }
91
+ .sui-badge.sm {
92
+ padding: .125rem .75rem;
93
+ }
94
+ .sui-badge.sm {
95
+ font-size: .75rem;
96
+ }
97
+ .sui-badge.sm > svg {
98
+ width: 14px;
99
+ height: 14px;
100
+ }
101
+ .sui-badge.lg {
102
+ font-size: 1rem;
103
+ padding: .25rem 1rem;
104
+ }
105
+ .sui-badge.lg {
106
+ font-size: 1rem;
107
+ }
108
+ .sui-badge.lg > svg {
109
+ width: 20px;
110
+ height: 20px;
111
+ }
@@ -0,0 +1,31 @@
1
+ ---
2
+ import './breadcrumbs.css';
3
+
4
+ type Props = {
5
+ segments: {
6
+ label: string;
7
+ segment: string;
8
+ }[];
9
+ separator?: string;
10
+ };
11
+
12
+ const { segments, separator = '>' } = Astro.props;
13
+
14
+ const breadcrumbs = segments.map(({ label }, index) => {
15
+ const path = segments
16
+ .slice(0, index + 1)
17
+ .map(({ segment }) => segment)
18
+ .join('/')
19
+ .replaceAll('//', '/');
20
+ return {
21
+ label,
22
+ path,
23
+ };
24
+ });
25
+ ---
26
+
27
+ <div class="sui-breadcrumbs">
28
+ {breadcrumbs.map(({ label, path }) => (
29
+ <a href={path || '/'}>{label}</a><span>{separator}</span>
30
+ ))}
31
+ </div>
@@ -0,0 +1,15 @@
1
+ .sui-breadcrumbs {
2
+ display: flex;
3
+ flex-direction: row;
4
+ gap: .25rem;
5
+ }
6
+ .sui-breadcrumbs > *:last-child {
7
+ display: none;
8
+ }
9
+ .sui-breadcrumbs a {
10
+ color: hsl(var(--primary-base));
11
+ text-decoration: none;
12
+ }
13
+ .sui-breadcrumbs a:hover {
14
+ text-decoration: underline;
15
+ }
@@ -0,0 +1,75 @@
1
+ ---
2
+ import type { HTMLTag, Polymorphic } from 'astro/types';
3
+ import type { StudioCMSColorway } from '../../utils/colors.js';
4
+ import './button.css';
5
+
6
+ /**
7
+ * Props for the button component.
8
+ */
9
+ type Props<As extends HTMLTag = 'button'> = Omit<Polymorphic<{ as: As }>, 'as'> & {
10
+ /**
11
+ * The polymorphic component to render the button as. Defaults to `button`.
12
+ */
13
+ as?: As;
14
+ /**
15
+ * The size of the button. Defaults to `md`.
16
+ */
17
+ size?: 'sm' | 'md' | 'lg';
18
+ /**
19
+ * Whether the button should be full width. Defaults to `false`.
20
+ */
21
+ fullWidth?: boolean;
22
+ /**
23
+ * The colorway of the button. Defaults to `default`.
24
+ */
25
+ color?: StudioCMSColorway;
26
+ /**
27
+ * The variant of the button. Defaults to `solid`.
28
+ */
29
+ variant?: 'solid' | 'outlined' | 'flat';
30
+ /**
31
+ * Whether the button is disabled. Defaults to `false`.
32
+ */
33
+ disabled?: boolean;
34
+ /**
35
+ * An optional href to use for the button. If provided, the button will render as an anchor tag.
36
+ */
37
+ href?: string;
38
+ };
39
+
40
+ export type { Props };
41
+
42
+ const {
43
+ size = 'md',
44
+ fullWidth = false,
45
+ color = 'default',
46
+ variant = 'solid',
47
+ disabled = false,
48
+ ...props
49
+ } = Astro.props;
50
+
51
+ let As: HTMLTag = 'button';
52
+
53
+ if ('href' in props) {
54
+ As = 'a';
55
+ } else {
56
+ As = props.as || 'button';
57
+ }
58
+ ---
59
+
60
+ <As
61
+ class="sui-button"
62
+ class:list={[
63
+ fullWidth && "full",
64
+ disabled && "disabled",
65
+ size,
66
+ color,
67
+ variant,
68
+ ]}
69
+ disabled={disabled}
70
+ tabindex={0}
71
+ {...props}>
72
+ <slot name="start-content" />
73
+ <slot />
74
+ <slot name="end-content" />
75
+ </As>