Skip to content

Commit

Permalink
chore: connect asset token to props
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Feb 2, 2025
1 parent c183c22 commit 974961b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
11 changes: 7 additions & 4 deletions .changeset/itchy-planets-provide.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
---
"@chakra-ui/react": patch
"@chakra-ui/react": minor
---

- **Styled System:** Boost performance of style resolution by removing
`JSON.stringify` in `memo` function and avoid memoizing non-primitive
arguments.
- **Styled System:**

- Boost performance of style resolution by removing `JSON.stringify` in `memo`
function and avoid memoizing non-primitive arguments.
- Connect `assets` token to `backgroundImage` and `listStyleImage` css
properties.

- **Menu, Tooltip:** Set `lazyMount` and `unmountOnExit` to `true` in the `Root`
component to improve initial rendering performance.
Expand Down
6 changes: 3 additions & 3 deletions apps/www/content/docs/styling/style-props/background.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ Use `bgImage` or `backgroundImage` to set the background image of an element.
<Box bgImage="linear-gradient({colors.red.200}, {colors.blue.200})" />
```

| Prop | CSS Property | Token Category |
| ---------------------------- | ------------------ | -------------- |
| `bgImage`, `backgroundImage` | `background-image` | assets |
| Prop | CSS Property | Token Category |
| ---------------------------- | ------------------ | --------------------- |
| `bgImage`, `backgroundImage` | `background-image` | `assets`, `gradients` |

## Background Gradient

Expand Down
9 changes: 7 additions & 2 deletions packages/react/src/preset-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,12 @@ export const defaultBaseConfig = defineConfig({
}
},
},
backgroundImage: { values: "gradients", shorthand: ["bgImg", "bgImage"] },
backgroundImage: {
values(theme) {
return { ...theme("gradients"), ...theme("assets") }
},
shorthand: ["bgImg", "bgImage"],
},
// border
border: { values: "borders" },
borderTop: { values: "borders" },
Expand Down Expand Up @@ -785,7 +790,7 @@ export const defaultBaseConfig = defineConfig({
scrollSnapMarginRight: { values: "spacing" },
// list
listStylePosition: { shorthand: ["listStylePos"] },
listStyleImage: { shorthand: ["listStyleImg"] },
listStyleImage: { values: "assets", shorthand: ["listStyleImg"] },
// position
position: { shorthand: ["pos"] },
zIndex: { values: "zIndex" },
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/styled-system/generated/prop-types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface UtilityValues {
gradientFrom: Tokens["colors"] | "currentBg"
gradientTo: Tokens["colors"] | "currentBg"
gradientVia: Tokens["colors"] | "currentBg"
backgroundImage: Tokens["gradients"]
backgroundImage: Tokens["gradients"] | Tokens["assets"]
border: Tokens["borders"]
borderTop: Tokens["borders"]
borderLeft: Tokens["borders"]
Expand Down Expand Up @@ -163,6 +163,7 @@ export interface UtilityValues {
scrollSnapMarginBottom: Tokens["spacing"]
scrollSnapMarginLeft: Tokens["spacing"]
scrollSnapMarginRight: Tokens["spacing"]
listStyleImage: Tokens["assets"]
zIndex: Tokens["zIndex"]
inset: Tokens["spacing"]
insetInline: Tokens["spacing"]
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/styled-system/generated/system.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export interface SystemProperties {
lineHeight?: ConditionalValue<UtilityValues["lineHeight"] | CssVars | CssProperties["lineHeight"] | AnyString>
lineHeightStep?: ConditionalValue<CssProperties["lineHeightStep"] | AnyString>
listStyle?: ConditionalValue<CssProperties["listStyle"] | AnyString>
listStyleImage?: ConditionalValue<CssProperties["listStyleImage"] | AnyString>
listStyleImage?: ConditionalValue<UtilityValues["listStyleImage"] | CssVars | CssProperties["listStyleImage"] | AnyString>
listStylePosition?: ConditionalValue<CssProperties["listStylePosition"] | AnyString>
listStyleType?: ConditionalValue<CssProperties["listStyleType"] | AnyString>
margin?: ConditionalValue<UtilityValues["margin"] | CssVars | CssProperties["margin"] | AnyString>
Expand Down Expand Up @@ -581,7 +581,7 @@ export interface SystemProperties {
scrollPaddingX?: ConditionalValue<UtilityValues["scrollPaddingInline"] | CssVars | CssProperties["scrollPaddingInline"] | AnyString>
scrollPaddingY?: ConditionalValue<UtilityValues["scrollPaddingBlock"] | CssVars | CssProperties["scrollPaddingBlock"] | AnyString>
listStylePos?: ConditionalValue<CssProperties["listStylePosition"] | AnyString>
listStyleImg?: ConditionalValue<CssProperties["listStyleImage"] | AnyString>
listStyleImg?: ConditionalValue<UtilityValues["listStyleImage"] | CssVars | CssProperties["listStyleImage"] | AnyString>
pos?: ConditionalValue<CssProperties["position"] | AnyString>
insetX?: ConditionalValue<UtilityValues["insetInline"] | CssVars | CssProperties["insetInline"] | AnyString>
insetY?: ConditionalValue<UtilityValues["insetBlock"] | CssVars | CssProperties["insetBlock"] | AnyString>
Expand Down

0 comments on commit 974961b

Please sign in to comment.