Skip to content

Commit 2c7bca6

Browse files
committed
fix: export colors and radius
1 parent e328655 commit 2c7bca6

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function generateCSSVars(
5454
return theme.map((t) => generateCSSVars(t, false)).join("\n")
5555
}
5656

57-
const { color, radius } = theme
57+
const { color = "zinc", radius = 0.5 } = theme
5858
const { light, dark, name } = getColorTheme(color)
5959
const lightVars = generateColorCSSVars(light)
6060
const darkVars = generateColorCSSVars(dark)

src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { generateCSSVars } from "./generate"
2+
import { themes } from "./themes"
23

34
import type { PresetShadcnOptions } from "./types"
45
import type { Preset } from "unocss"
56
import type { Theme } from "unocss/preset-mini"
67

7-
export function presetShadcn(options?: PresetShadcnOptions): Preset<Theme> {
8-
const theme = options ?? {
9-
color: "zinc",
10-
radius: 0.5,
11-
}
8+
export const builtinColors = themes.map((theme) => theme.name)
9+
export const builtinRadiuses = [0, 0.3, 0.5, 0.75, 1] as const
1210

11+
export function presetShadcn(options: PresetShadcnOptions = {}): Preset<Theme> {
1312
return {
1413
name: "unocss-preset-shadcn",
1514
preflights: [
@@ -20,7 +19,7 @@ export function presetShadcn(options?: PresetShadcnOptions): Preset<Theme> {
2019
@keyframes shadcn-enter { from{ opacity: var(--un-enter-opacity, 1); transform: translate3d(var(--un-enter-translate-x, 0), var(--un-enter-translate-y, 0), 0) scale3d(var(--un-enter-scale, 1), var(--un-enter-scale, 1), var(--un-enter-scale, 1)) rotate(var(--un-enter-rotate, 0)) } }
2120
@keyframes shadcn-exit { to{ opacity: var(--un-exit-opacity, 1); transform: translate3d(var(--un-exit-translate-x, 0), var(--un-exit-translate-y, 0), 0) scale3d(var(--un-exit-scale, 1), var(--un-exit-scale, 1), var(--un-exit-scale, 1)) rotate(var(--un-exit-rotate, 0)) } }
2221
23-
${generateCSSVars(theme)}
22+
${generateCSSVars(options)}
2423
2524
* {
2625
border-color: hsl(var(--border));

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export type ThemeOptions = {
1717
/**
1818
* @default 'zinc'
1919
*/
20-
color: ColorOptions
20+
color?: ColorOptions
2121
/**
2222
* @default 0.5
2323
*/
24-
radius: number
24+
radius?: number
2525
}
2626

2727
export type PresetShadcnOptions = ArrayOrSingle<ThemeOptions>

0 commit comments

Comments
 (0)