Skip to content

Commit

Permalink
chore: refactor theme - Modal (#6894)
Browse files Browse the repository at this point in the history
Co-authored-by: Segun Adebayo <joseshegs@gmail.com>
  • Loading branch information
anubra266 and segunadebayo committed Mar 19, 2023
1 parent 26800ee commit 0eeadd3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-deers-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chakra-ui/theme": patch
---

Refactor Modal theme to use css variables
16 changes: 13 additions & 3 deletions packages/components/theme/src/components/modal.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { modalAnatomy as parts } from "@chakra-ui/anatomy"
import {
createMultiStyleConfigHelpers,
cssVar,
defineStyle,
} from "@chakra-ui/styled-system"
import { mode } from "@chakra-ui/theme-tools"
import { runIfFn } from "../utils/run-if-fn"

const { defineMultiStyleConfig, definePartsStyle } =
createMultiStyleConfigHelpers(parts.keys)

const $bg = cssVar("modal-bg")
const $bs = cssVar("modal-box-shadow")

const baseStyleOverlay = defineStyle({
bg: "blackAlpha.600",
zIndex: "modal",
Expand All @@ -32,12 +35,19 @@ const baseStyleDialog = defineStyle((props) => {

return {
borderRadius: "md",
bg: mode("white", "gray.700")(props),

color: "inherit",
my: "16",
zIndex: "modal",
maxH: scrollBehavior === "inside" ? "calc(100% - 7.5rem)" : undefined,
boxShadow: mode("lg", "dark-lg")(props),
[$bg.variable]: "colors.white",
[$bs.variable]: "shadows.lg",
_dark: {
[$bg.variable]: "colors.gray.700",
[$bs.variable]: "shadows.dark-lg",
},
bg: $bg.reference,
boxShadow: $bs.reference,
}
})

Expand Down

1 comment on commit 0eeadd3

@vercel
Copy link

@vercel vercel bot commented on 0eeadd3 Mar 19, 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.