Skip to content

Commit

Permalink
refactor: badge theme
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Mar 18, 2023
1 parent e61a31b commit b6e0a6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-planes-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chakra-ui/theme": patch
---

Refactor badge theme to use more css variables
17 changes: 8 additions & 9 deletions packages/components/theme/src/components/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ import {
} from "@chakra-ui/styled-system"
import { transparentize } from "@chakra-ui/theme-tools"

const $bg = cssVar("badge-bg")
const $fg = cssVar("badge-color")
const $shadow = cssVar("badge-shadow")

const baseStyle = defineStyle({
px: 1,
textTransform: "uppercase",
fontSize: "xs",
borderRadius: "sm",
fontWeight: "bold",
bg: $bg.reference,
color: $fg.reference,
boxShadow: $shadow.reference,
})

const $bg = cssVar("badge-bg")
const $fg = cssVar("badge-color")

const variantSolid = defineStyle((props) => {
const { colorScheme: c, theme } = props
const dark = transparentize(`${c}.500`, 0.6)(theme)
Expand All @@ -26,8 +30,6 @@ const variantSolid = defineStyle((props) => {
[$bg.variable]: dark,
[$fg.variable]: `colors.whiteAlpha.800`,
},
bg: $bg.reference,
color: $fg.reference,
}
})

Expand All @@ -41,8 +43,6 @@ const variantSubtle = defineStyle((props) => {
[$bg.variable]: darkBg,
[$fg.variable]: `colors.${c}.200`,
},
bg: $bg.reference,
color: $fg.reference,
}
})

Expand All @@ -54,8 +54,7 @@ const variantOutline = defineStyle((props) => {
_dark: {
[$fg.variable]: darkColor,
},
color: $fg.reference,
boxShadow: `inset 0 0 0px 1px ${$fg.reference}`,
[$shadow.variable]: `inset 0 0 0px 1px ${$fg.reference}`,
}
})

Expand Down

1 comment on commit b6e0a6a

@vercel
Copy link

@vercel vercel bot commented on b6e0a6a Mar 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.