@starwind-ui/core 1.0.0 → 1.3.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 (54) hide show
  1. package/dist/index.js +22 -99
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/components/accordion/Accordion.astro +5 -12
  4. package/dist/src/components/accordion/AccordionContent.astro +11 -7
  5. package/dist/src/components/accordion/AccordionItem.astro +6 -10
  6. package/dist/src/components/accordion/AccordionTrigger.astro +12 -9
  7. package/dist/src/components/alert/Alert.astro +18 -28
  8. package/dist/src/components/alert/AlertDescription.astro +4 -1
  9. package/dist/src/components/alert/AlertTitle.astro +6 -7
  10. package/dist/src/components/avatar/Avatar.astro +19 -23
  11. package/dist/src/components/avatar/AvatarFallback.astro +7 -6
  12. package/dist/src/components/avatar/AvatarImage.astro +9 -23
  13. package/dist/src/components/avatar/index.ts +1 -1
  14. package/dist/src/components/badge/Badge.astro +39 -34
  15. package/dist/src/components/button/Button.astro +37 -50
  16. package/dist/src/components/card/Card.astro +4 -4
  17. package/dist/src/components/card/CardContent.astro +4 -1
  18. package/dist/src/components/card/CardDescription.astro +4 -1
  19. package/dist/src/components/card/CardFooter.astro +4 -1
  20. package/dist/src/components/card/CardHeader.astro +4 -1
  21. package/dist/src/components/card/CardTitle.astro +4 -1
  22. package/dist/src/components/checkbox/Checkbox.astro +82 -54
  23. package/dist/src/components/dialog/DialogContent.astro +32 -29
  24. package/dist/src/components/dialog/DialogDescription.astro +4 -1
  25. package/dist/src/components/dialog/DialogFooter.astro +4 -1
  26. package/dist/src/components/dialog/DialogHeader.astro +4 -1
  27. package/dist/src/components/dialog/DialogTitle.astro +4 -1
  28. package/dist/src/components/input/Input.astro +15 -17
  29. package/dist/src/components/label/Label.astro +12 -16
  30. package/dist/src/components/pagination/Pagination.astro +5 -9
  31. package/dist/src/components/pagination/PaginationContent.astro +5 -4
  32. package/dist/src/components/pagination/PaginationEllipsis.astro +6 -5
  33. package/dist/src/components/pagination/PaginationItem.astro +5 -4
  34. package/dist/src/components/pagination/PaginationLink.astro +25 -32
  35. package/dist/src/components/pagination/PaginationNext.astro +7 -8
  36. package/dist/src/components/pagination/PaginationPrevious.astro +7 -8
  37. package/dist/src/components/select/Select.astro +5 -13
  38. package/dist/src/components/select/SelectContent.astro +25 -11
  39. package/dist/src/components/select/SelectGroup.astro +1 -3
  40. package/dist/src/components/select/SelectItem.astro +14 -9
  41. package/dist/src/components/select/SelectLabel.astro +4 -1
  42. package/dist/src/components/select/SelectSeparator.astro +4 -1
  43. package/dist/src/components/select/SelectTrigger.astro +12 -9
  44. package/dist/src/components/select/SelectValue.astro +5 -2
  45. package/dist/src/components/switch/Switch.astro +40 -41
  46. package/dist/src/components/tabs/Tabs.astro +5 -4
  47. package/dist/src/components/tabs/TabsContent.astro +4 -1
  48. package/dist/src/components/tabs/TabsList.astro +6 -9
  49. package/dist/src/components/tabs/TabsTrigger.astro +11 -7
  50. package/dist/src/components/textarea/Textarea.astro +18 -15
  51. package/dist/src/components/tooltip/Tooltip.astro +4 -1
  52. package/dist/src/components/tooltip/TooltipContent.astro +44 -22
  53. package/dist/src/components/tooltip/TooltipTrigger.astro +1 -3
  54. package/package.json +1 -2
package/dist/index.js CHANGED
@@ -3,104 +3,27 @@ import { join } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
 
5
5
  // src/registry.json
6
- var registry_default = [
7
- {
8
- name: "accordion",
9
- type: "component",
10
- version: "1.0.0",
11
- dependencies: []
12
- },
13
- {
14
- name: "alert",
15
- type: "component",
16
- version: "1.0.0",
17
- dependencies: []
18
- },
19
- {
20
- name: "avatar",
21
- type: "component",
22
- version: "1.0.0",
23
- dependencies: []
24
- },
25
- {
26
- name: "badge",
27
- type: "component",
28
- version: "1.0.0",
29
- dependencies: []
30
- },
31
- {
32
- name: "button",
33
- type: "component",
34
- version: "1.0.0",
35
- dependencies: []
36
- },
37
- {
38
- name: "card",
39
- type: "component",
40
- version: "1.0.0",
41
- dependencies: []
42
- },
43
- {
44
- name: "checkbox",
45
- type: "component",
46
- version: "1.0.0",
47
- dependencies: []
48
- },
49
- {
50
- name: "dialog",
51
- type: "component",
52
- version: "1.0.0",
53
- dependencies: []
54
- },
55
- {
56
- name: "input",
57
- type: "component",
58
- version: "1.0.0",
59
- dependencies: []
60
- },
61
- {
62
- name: "label",
63
- type: "component",
64
- version: "1.0.0",
65
- dependencies: []
66
- },
67
- {
68
- name: "pagination",
69
- type: "component",
70
- version: "1.0.0",
71
- dependencies: []
72
- },
73
- {
74
- name: "select",
75
- type: "component",
76
- version: "1.0.0",
77
- dependencies: []
78
- },
79
- {
80
- name: "switch",
81
- type: "component",
82
- version: "1.0.0",
83
- dependencies: []
84
- },
85
- {
86
- name: "tabs",
87
- type: "component",
88
- version: "1.0.0",
89
- dependencies: []
90
- },
91
- {
92
- name: "textarea",
93
- type: "component",
94
- version: "1.0.0",
95
- dependencies: []
96
- },
97
- {
98
- name: "tooltip",
99
- type: "component",
100
- version: "1.0.0",
101
- dependencies: []
102
- }
103
- ];
6
+ var registry_default = {
7
+ $schema: "https://starwind.dev/registry-schema.json",
8
+ components: [
9
+ { name: "accordion", type: "component", version: "1.1.0", dependencies: [] },
10
+ { name: "alert", type: "component", version: "1.1.0", dependencies: [] },
11
+ { name: "avatar", type: "component", version: "1.1.0", dependencies: [] },
12
+ { name: "badge", type: "component", version: "1.1.0", dependencies: [] },
13
+ { name: "button", type: "component", version: "2.0.0", dependencies: [] },
14
+ { name: "card", type: "component", version: "1.1.0", dependencies: [] },
15
+ { name: "checkbox", type: "component", version: "1.1.0", dependencies: [] },
16
+ { name: "dialog", type: "component", version: "1.1.0", dependencies: [] },
17
+ { name: "input", type: "component", version: "1.1.0", dependencies: [] },
18
+ { name: "label", type: "component", version: "1.1.0", dependencies: [] },
19
+ { name: "pagination", type: "component", version: "2.0.0", dependencies: [] },
20
+ { name: "select", type: "component", version: "1.1.0", dependencies: [] },
21
+ { name: "switch", type: "component", version: "1.1.0", dependencies: [] },
22
+ { name: "tabs", type: "component", version: "1.1.0", dependencies: [] },
23
+ { name: "textarea", type: "component", version: "1.1.0", dependencies: [] },
24
+ { name: "tooltip", type: "component", version: "1.1.0", dependencies: [] }
25
+ ]
26
+ };
104
27
 
105
28
  // src/index.ts
106
29
  var __dirname = fileURLToPath(new URL(".", import.meta.url));
@@ -108,7 +31,7 @@ var getComponentPath = (componentName, fileName) => {
108
31
  const componentsDir = __dirname.includes("dist") ? "src/components" : "src/components";
109
32
  return join(__dirname, componentsDir, componentName, fileName);
110
33
  };
111
- var registry = registry_default;
34
+ var registry = registry_default.components;
112
35
  export {
113
36
  getComponentPath,
114
37
  registry
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/registry.json"],"sourcesContent":["import { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport componentRegistry from \"./registry.json\" assert { type: \"json\" };\n\n/**\n * Component metadata interface describing a Starwind UI component\n */\nexport interface ComponentMeta {\n\tname: string;\n\tversion: string;\n\ttype: \"component\";\n\tdependencies: string[];\n}\n\n/**\n * Registry interface containing all available components\n */\nexport interface Registry {\n\tcomponents: ComponentMeta[];\n}\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\n\n/**\n * Get the absolute path to a component file\n * @param {string} componentName - The name of the component\n * @param {string} fileName - The name of the file within the component\n * @returns {string} The absolute path to the component file\n */\nexport const getComponentPath = (componentName: string, fileName: string): string => {\n\t// In production (when installed as a dependency), the components will be in dist/src/components\n\t// In development, they will be in src/components\n\tconst componentsDir = __dirname.includes(\"dist\") ? \"src/components\" : \"src/components\";\n\treturn join(__dirname, componentsDir, componentName, fileName);\n};\n\n/**\n * Map of all components and their metadata from registry\n */\nexport const registry = componentRegistry as ComponentMeta[];\n","[\n\t{\n\t\t\"name\": \"accordion\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"alert\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"avatar\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"badge\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"button\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"card\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"checkbox\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"dialog\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"input\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"label\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"pagination\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"select\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"switch\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"tabs\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"textarea\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t},\n\t{\n\t\t\"name\": \"tooltip\",\n\t\t\"type\": \"component\",\n\t\t\"version\": \"1.0.0\",\n\t\t\"dependencies\": []\n\t}\n]\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,qBAAqB;;;ACD9B;AAAA,EACC;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,IACC,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,cAAgB,CAAC;AAAA,EAClB;AACD;;;AD5EA,IAAM,YAAY,cAAc,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC;AAQtD,IAAM,mBAAmB,CAAC,eAAuB,aAA6B;AAGpF,QAAM,gBAAgB,UAAU,SAAS,MAAM,IAAI,mBAAmB;AACtE,SAAO,KAAK,WAAW,eAAe,eAAe,QAAQ;AAC9D;AAKO,IAAM,WAAW;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/registry.json"],"sourcesContent":["import { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport componentRegistry from \"./registry.json\" with { type: \"json\" };\n\n/**\n * Component metadata interface describing a Starwind UI component\n */\nexport interface ComponentMeta {\n\tname: string;\n\tversion: string;\n\ttype: \"component\";\n\tdependencies: string[];\n}\n\n/**\n * Registry interface containing all available components\n */\nexport interface Registry {\n\tcomponents: ComponentMeta[];\n}\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\n\n/**\n * Get the absolute path to a component file\n * @param {string} componentName - The name of the component\n * @param {string} fileName - The name of the file within the component\n * @returns {string} The absolute path to the component file\n */\nexport const getComponentPath = (componentName: string, fileName: string): string => {\n\t// In production (when installed as a dependency), the components will be in dist/src/components\n\t// In development, they will be in src/components\n\tconst componentsDir = __dirname.includes(\"dist\") ? \"src/components\" : \"src/components\";\n\treturn join(__dirname, componentsDir, componentName, fileName);\n};\n\n/**\n * Map of all components and their metadata from registry\n */\nexport const registry = componentRegistry.components as ComponentMeta[];\n","{\n\t\"$schema\": \"https://starwind.dev/registry-schema.json\",\n\t\"components\": [\n\t\t{ \"name\": \"accordion\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"alert\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"avatar\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"badge\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"button\", \"type\": \"component\", \"version\": \"2.0.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"card\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"checkbox\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"dialog\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"input\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"label\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"pagination\", \"type\": \"component\", \"version\": \"2.0.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"select\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"switch\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"tabs\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"textarea\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"tooltip\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] }\n\t]\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,qBAAqB;;;ACD9B;AAAA,EACC,SAAW;AAAA,EACX,YAAc;AAAA,IACb,EAAE,MAAQ,aAAa,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACnF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,QAAQ,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC9E,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,cAAc,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACpF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,QAAQ,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC9E,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,WAAW,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,EAClF;AACD;;;ADCA,IAAM,YAAY,cAAc,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC;AAQtD,IAAM,mBAAmB,CAAC,eAAuB,aAA6B;AAGpF,QAAM,gBAAgB,UAAU,SAAS,MAAM,IAAI,mBAAmB;AACtE,SAAO,KAAK,WAAW,eAAe,eAAe,QAAQ;AAC9D;AAKO,IAAM,WAAW,iBAAkB;","names":[]}
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
3
4
 
4
5
  type Props = HTMLAttributes<"div"> & {
5
6
  /**
@@ -12,15 +13,12 @@ type Props = HTMLAttributes<"div"> & {
12
13
  defaultValue?: string;
13
14
  };
14
15
 
16
+ const accordion = tv({ base: "starwind-accordion" });
17
+
15
18
  const { type = "single", defaultValue, class: className, ...rest } = Astro.props;
16
19
  ---
17
20
 
18
- <div
19
- class:list={["starwind-accordion", className]}
20
- data-type={type}
21
- data-value={defaultValue}
22
- {...rest}
23
- >
21
+ <div class={accordion({ class: className })} data-type={type} data-value={defaultValue} {...rest}>
24
22
  <slot />
25
23
  </div>
26
24
 
@@ -79,12 +77,7 @@ const { type = "single", defaultValue, class: className, ...rest } = Astro.props
79
77
 
80
78
  if (!trigger || !content) return null;
81
79
 
82
- return {
83
- element,
84
- trigger,
85
- content,
86
- value,
87
- };
80
+ return { element, trigger, content, value };
88
81
  })
89
82
  .filter((item): item is AccordionItem => item !== null);
90
83
  }
@@ -4,20 +4,24 @@
4
4
  * It is later removed in the Accordion.astro script
5
5
  */
6
6
  import type { HTMLAttributes } from "astro/types";
7
+ import { tv } from "tailwind-variants";
7
8
 
8
9
  type Props = HTMLAttributes<"div">;
9
10
 
10
- const { class: className, ...rest } = Astro.props;
11
- ---
12
-
13
- <div
14
- class:list={[
11
+ const accordionContent = tv({
12
+ base: [
15
13
  "starwind-accordion-content",
16
14
  "transform-gpu overflow-hidden",
17
15
  "data-[state=closed]:animate-accordion-up data-[state=closed]:h-0",
18
16
  "data-[state=open]:animate-accordion-down",
19
- className,
20
- ]}
17
+ ],
18
+ });
19
+
20
+ const { class: className, ...rest } = Astro.props;
21
+ ---
22
+
23
+ <div
24
+ class={accordionContent({ class: className })}
21
25
  data-state="closed"
22
26
  style="animation: none;"
23
27
  {...rest}
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
3
4
 
4
5
  type Props = HTMLAttributes<"div"> & {
5
6
  /**
@@ -8,18 +9,13 @@ type Props = HTMLAttributes<"div"> & {
8
9
  value: string;
9
10
  };
10
11
 
12
+ const accordionItem = tv({
13
+ base: "starwind-accordion-item border-x border-b first:rounded-t-lg first:border-t last:rounded-b-lg",
14
+ });
15
+
11
16
  const { value, class: className, ...rest } = Astro.props;
12
17
  ---
13
18
 
14
- <div
15
- class:list={[
16
- "starwind-accordion-item",
17
- "border-x border-b first:rounded-t-lg first:border-t last:rounded-b-lg",
18
- className,
19
- ]}
20
- data-value={value}
21
- data-state="closed"
22
- {...rest}
23
- >
19
+ <div class={accordionItem({ class: className })} data-value={value} data-state="closed" {...rest}>
24
20
  <slot />
25
21
  </div>
@@ -1,23 +1,26 @@
1
1
  ---
2
2
  import ChevronDown from "@tabler/icons/outline/chevron-down.svg";
3
-
4
3
  import type { HTMLAttributes } from "astro/types";
4
+ import { tv } from "tailwind-variants";
5
5
 
6
6
  type Props = HTMLAttributes<"button">;
7
7
 
8
- const { class: className, ...rest } = Astro.props;
9
- ---
10
-
11
- <button
12
- type="button"
13
- class:list={[
8
+ const accordionTrigger = tv({
9
+ base: [
14
10
  "starwind-accordion-trigger",
15
11
  "flex w-full items-center justify-between gap-4 rounded-md px-5 py-4",
16
12
  "starwind-transition-colors hover:text-muted-foreground text-left font-medium",
17
13
  "[&[data-state=open]>svg]:rotate-180",
18
14
  "focus-visible:outline-outline focus-visible:outline-2 focus-visible:outline-offset-0",
19
- className,
20
- ]}
15
+ ],
16
+ });
17
+
18
+ const { class: className, ...rest } = Astro.props;
19
+ ---
20
+
21
+ <button
22
+ type="button"
23
+ class={accordionTrigger({ class: className })}
21
24
  aria-expanded="false"
22
25
  {...rest}
23
26
  >
@@ -1,5 +1,22 @@
1
1
  ---
2
2
  import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
4
+
5
+ const alert = tv({
6
+ base: "text-foreground relative w-full rounded-lg border p-4",
7
+ variants: {
8
+ variant: {
9
+ default: "bg-background [&>h5>svg]:text-foreground",
10
+ primary: "border-primary bg-primary/7 [&>h5>svg]:text-primary",
11
+ secondary: "border-secondary bg-secondary/7 [&>h5>svg]:text-secondary",
12
+ info: "border-info bg-info/7 [&>h5>svg]:text-info",
13
+ success: "border-success bg-success/7 [&>h5>svg]:text-success",
14
+ warning: "border-warning bg-warning/7 [&>h5>svg]:text-warning",
15
+ error: "border-error bg-error/7 [&>h5>svg]:text-error",
16
+ },
17
+ },
18
+ defaultVariants: { variant: "default" },
19
+ });
3
20
 
4
21
  type Props = HTMLAttributes<"div"> & {
5
22
  /**
@@ -12,33 +29,6 @@ type Props = HTMLAttributes<"div"> & {
12
29
  const { variant = "default", class: className, ...rest } = Astro.props;
13
30
  ---
14
31
 
15
- <div
16
- class:list={[
17
- "text-foreground relative w-full rounded-lg border p-4",
18
- {
19
- "bg-background [&>h5>svg]:text-foreground": variant === "default",
20
- },
21
- {
22
- "border-primary bg-primary/7 [&>h5>svg]:text-primary": variant === "primary",
23
- },
24
- {
25
- "border-secondary bg-secondary/7 [&>h5>svg]:text-secondary": variant === "secondary",
26
- },
27
- {
28
- "border-info bg-info/7 [&>h5>svg]:text-info": variant === "info",
29
- },
30
- {
31
- "border-success bg-success/7 [&>h5>svg]:text-success": variant === "success",
32
- },
33
- {
34
- "border-warning bg-warning/7 [&>h5>svg]:text-warning": variant === "warning",
35
- },
36
- {
37
- "border-error bg-error/7 [&>h5>svg]:text-error": variant === "error",
38
- },
39
- className,
40
- ]}
41
- {...rest}
42
- >
32
+ <div class={alert({ variant, class: className })} {...rest}>
43
33
  <slot />
44
34
  </div>
@@ -1,11 +1,14 @@
1
1
  ---
2
2
  import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
4
+
5
+ const alertDescription = tv({ base: "[&_p]:leading-relaxed" });
3
6
 
4
7
  type Props = HTMLAttributes<"div">;
5
8
 
6
9
  const { class: className, ...rest } = Astro.props;
7
10
  ---
8
11
 
9
- <div class:list={["[&_p]:leading-relaxed", className]} {...rest}>
12
+ <div class={alertDescription({ class: className })} {...rest}>
10
13
  <slot />
11
14
  </div>
@@ -1,17 +1,16 @@
1
1
  ---
2
2
  import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
4
+
5
+ const alertTitle = tv({
6
+ base: "mb-2 flex items-center gap-2 text-lg leading-none font-medium tracking-tight",
7
+ });
3
8
 
4
9
  type Props = HTMLAttributes<"div">;
5
10
 
6
11
  const { class: className, ...rest } = Astro.props;
7
12
  ---
8
13
 
9
- <h5
10
- class:list={[
11
- "mb-2 flex items-center gap-2 text-lg leading-none font-medium tracking-tight",
12
- className,
13
- ]}
14
- {...rest}
15
- >
14
+ <h5 class={alertTitle({ class: className })} {...rest}>
16
15
  <slot />
17
16
  </h5>
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
3
4
 
4
5
  interface Props extends HTMLAttributes<"div"> {
5
6
  /**
@@ -14,31 +15,26 @@ interface Props extends HTMLAttributes<"div"> {
14
15
  size?: "sm" | "md" | "lg";
15
16
  }
16
17
 
17
- const { variant = "default", size = "md", class: className, ...rest } = Astro.props;
18
+ const avatar = tv({
19
+ base: "text-foreground bg-muted relative overflow-hidden rounded-full border-2",
20
+ variants: {
21
+ variant: {
22
+ default: "border-border",
23
+ primary: "border-primary",
24
+ secondary: "border-secondary",
25
+ info: "border-info",
26
+ success: "border-success",
27
+ warning: "border-warning",
28
+ error: "border-error",
29
+ },
30
+ size: { sm: "h-8 w-8 text-xs", md: "h-10 w-10 text-sm", lg: "h-12 w-12 text-base" },
31
+ },
32
+ defaultVariants: { variant: "default", size: "md" },
33
+ });
18
34
 
19
- const sizeClasses = {
20
- sm: "h-8 w-8 text-xs",
21
- md: "h-10 w-10 text-sm",
22
- lg: "h-12 w-12 text-base",
23
- }[size];
35
+ const { variant, size, class: className, ...rest } = Astro.props;
24
36
  ---
25
37
 
26
- <figure
27
- class:list={[
28
- "text-foreground bg-muted relative overflow-hidden rounded-full border-2",
29
- {
30
- "border-border": variant === "default",
31
- "border-primary": variant === "primary",
32
- "border-secondary": variant === "secondary",
33
- "border-info": variant === "info",
34
- "border-success": variant === "success",
35
- "border-warning": variant === "warning",
36
- "border-error": variant === "error",
37
- },
38
- sizeClasses,
39
- className,
40
- ]}
41
- {...rest}
42
- >
38
+ <figure class={avatar({ variant, size, class: className })} {...rest}>
43
39
  <slot />
44
40
  </figure>
@@ -1,4 +1,10 @@
1
1
  ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const avatarFallback = tv({
5
+ base: "absolute inset-0.5 flex items-center justify-center rounded-full font-medium",
6
+ });
7
+
2
8
  interface Props {
3
9
  class?: string;
4
10
  }
@@ -6,11 +12,6 @@ interface Props {
6
12
  const { class: className } = Astro.props;
7
13
  ---
8
14
 
9
- <div
10
- class:list={[
11
- "absolute inset-0.5 flex items-center justify-center rounded-full font-medium",
12
- className,
13
- ]}
14
- >
15
+ <div class={avatarFallback({ class: className })}>
15
16
  <slot />
16
17
  </div>
@@ -1,23 +1,18 @@
1
1
  ---
2
2
  import { Image } from "astro:assets";
3
+ import { tv } from "tailwind-variants";
3
4
 
4
- type BaseProps = {
5
- alt: string;
6
- };
5
+ const avatarImage = tv({ base: "relative z-1 h-full w-full object-cover" });
7
6
 
8
- type WithSrc = BaseProps & {
9
- src: string;
10
- image?: never;
11
- };
7
+ type BaseProps = { alt: string; class?: string };
12
8
 
13
- type WithImage = BaseProps & {
14
- src?: never;
15
- image: ImageMetadata;
16
- };
9
+ type WithSrc = BaseProps & { src: string; image?: never };
10
+
11
+ type WithImage = BaseProps & { src?: never; image: ImageMetadata };
17
12
 
18
13
  type Props = WithSrc | WithImage;
19
14
 
20
- const { src, image, alt } = Astro.props;
15
+ const { src, image, alt, class: className } = Astro.props;
21
16
 
22
17
  if (!src && !image) {
23
18
  throw new Error("Either 'src' or 'image' is required for an avatar image.");
@@ -29,20 +24,11 @@ if (!src && !image) {
29
24
  <img
30
25
  src={src}
31
26
  alt={alt}
32
- class="relative z-1 h-full w-full rounded-full object-cover"
27
+ class={avatarImage({ class: className })}
33
28
  width={64}
34
29
  height={64}
35
30
  onerror="this.style.display='none'"
36
31
  />
37
32
  )
38
33
  }
39
- {
40
- image && (
41
- <Image
42
- src={image}
43
- alt={alt}
44
- class="relative z-1 h-full w-full rounded-full object-cover"
45
- width={64}
46
- />
47
- )
48
- }
34
+ {image && <Image src={image} alt={alt} class={avatarImage({ class: className })} width={64} />}
@@ -1,6 +1,6 @@
1
1
  import Avatar from "./Avatar.astro";
2
- import AvatarImage from "./AvatarImage.astro";
3
2
  import AvatarFallback from "./AvatarFallback.astro";
3
+ import AvatarImage from "./AvatarImage.astro";
4
4
 
5
5
  export { Avatar, AvatarImage, AvatarFallback };
6
6
 
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
3
4
 
4
5
  interface Props extends HTMLAttributes<"div">, Omit<HTMLAttributes<"a">, "type"> {
5
6
  /**
@@ -21,44 +22,48 @@ interface Props extends HTMLAttributes<"div">, Omit<HTMLAttributes<"a">, "type">
21
22
  * @default "md"
22
23
  */
23
24
  size?: "sm" | "md" | "lg";
25
+ /**
26
+ * URL to link to when badge is clicked
27
+ */
28
+ href?: string;
24
29
  }
25
30
 
26
- const { variant = "default", size = "md", class: className, ...rest } = Astro.props;
31
+ const badgeVariants = tv({
32
+ base: "starwind-badge starwind-transition-colors inline-flex items-center rounded-full font-semibold focus-visible:outline-2 focus-visible:outline-offset-2",
33
+ variants: {
34
+ variant: {
35
+ default: "bg-foreground text-background",
36
+ primary: "bg-primary text-primary-foreground focus-visible:outline-primary",
37
+ secondary: "bg-secondary text-secondary-foreground focus-visible:outline-secondary",
38
+ outline: "border-border focus-visible:outline-outline border",
39
+ ghost: "bg-foreground/10 text-foreground focus-visible:outline-outline",
40
+ info: "bg-info text-info-foreground focus-visible:outline-info",
41
+ success: "bg-success text-success-foreground focus-visible:outline-success",
42
+ warning: "bg-warning text-warning-foreground focus-visible:outline-warning",
43
+ error: "bg-error text-error-foreground focus-visible:outline-error",
44
+ },
45
+ size: { sm: "px-2.5 py-0.5 text-xs", md: "px-3 py-0.5 text-sm", lg: "px-4 py-1 text-base" },
46
+ isLink: { true: "cursor-pointer", false: "" },
47
+ },
48
+ compoundVariants: [
49
+ { isLink: true, variant: "default", className: "hover:bg-foreground/80" },
50
+ { isLink: true, variant: "primary", className: "hover:bg-primary/80" },
51
+ { isLink: true, variant: "secondary", className: "hover:bg-secondary/80" },
52
+ { isLink: true, variant: "outline", className: "hover:border-border/80" },
53
+ { isLink: true, variant: "ghost", className: "hover:bg-foreground/7" },
54
+ { isLink: true, variant: "info", className: "hover:bg-info/80" },
55
+ { isLink: true, variant: "success", className: "hover:bg-success/80" },
56
+ { isLink: true, variant: "warning", className: "hover:bg-warning/80" },
57
+ { isLink: true, variant: "error", className: "hover:bg-error/80" },
58
+ ],
59
+ defaultVariants: { variant: "default", size: "md", isLink: false },
60
+ });
27
61
 
28
- const Tag = Astro.props.href ? "a" : "div";
62
+ const { variant = "default", size = "md", class: className, href, ...rest } = Astro.props;
63
+ const isLink = !!href;
64
+ const Tag = isLink ? "a" : "div";
29
65
  ---
30
66
 
31
- <Tag
32
- class:list={[
33
- "starwind-badge starwind-transition-colors inline-flex items-center rounded-full font-semibold",
34
- "focus-visible:outline-2 focus-visible:outline-offset-2",
35
- {
36
- "bg-foreground text-background hover:bg-foreground/80": variant === "default",
37
- "bg-primary text-primary-foreground hover:bg-primary/80 focus-visible:outline-primary":
38
- variant === "primary",
39
- "bg-secondary text-secondary-foreground hover:bg-secondary/80 focus-visible:outline-secondary":
40
- variant === "secondary",
41
- "border-border hover:border-border/80 focus-visible:outline-outline border":
42
- variant === "outline",
43
- "bg-info text-info-foreground hover:bg-info/80 focus-visible:outline-info":
44
- variant === "info",
45
- "bg-success text-success-foreground hover:bg-success/80 focus-visible:outline-success":
46
- variant === "success",
47
- "bg-warning text-warning-foreground hover:bg-warning/80 focus-visible:outline-warning":
48
- variant === "warning",
49
- "bg-error text-error-foreground hover:bg-error/80 focus-visible:outline-error":
50
- variant === "error",
51
- "bg-foreground/10 text-foreground hover:bg-foreground/7 focus-visible:outline-outline":
52
- variant === "ghost",
53
- },
54
- {
55
- "px-2.5 py-0.5 text-xs": size === "sm",
56
- "px-3 py-0.5 text-sm": size === "md",
57
- "px-4 py-1 text-base": size === "lg",
58
- },
59
- className,
60
- ]}
61
- {...rest}
62
- >
67
+ <Tag class={badgeVariants({ variant, size, isLink, class: className })} href={href} {...rest}>
63
68
  <slot />
64
69
  </Tag>