Skip to content

Commit

Permalink
fix: export colors and radius
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Dec 17, 2023
1 parent e328655 commit 2c7bca6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function generateCSSVars(
return theme.map((t) => generateCSSVars(t, false)).join("\n")
}

const { color, radius } = theme
const { color = "zinc", radius = 0.5 } = theme
const { light, dark, name } = getColorTheme(color)
const lightVars = generateColorCSSVars(light)
const darkVars = generateColorCSSVars(dark)
Expand Down
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { generateCSSVars } from "./generate"
import { themes } from "./themes"

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

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

export function presetShadcn(options: PresetShadcnOptions = {}): Preset<Theme> {
return {
name: "unocss-preset-shadcn",
preflights: [
Expand All @@ -20,7 +19,7 @@ export function presetShadcn(options?: PresetShadcnOptions): Preset<Theme> {
@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)) } }
@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)) } }
${generateCSSVars(theme)}
${generateCSSVars(options)}
* {
border-color: hsl(var(--border));
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export type ThemeOptions = {
/**
* @default 'zinc'
*/
color: ColorOptions
color?: ColorOptions
/**
* @default 0.5
*/
radius: number
radius?: number
}

export type PresetShadcnOptions = ArrayOrSingle<ThemeOptions>

0 comments on commit 2c7bca6

Please sign in to comment.