-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify getCss and expandResponsive (#6335)
* refactor: refactor getCss * perf: unify getCss and expandResponsive to not iterate styles twice * docs: add changeset * chore: add a benchmark script for styled-system * fix: import index file correctly
- Loading branch information
Showing
8 changed files
with
234 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@chakra-ui/styled-system": patch | ||
--- | ||
|
||
fix not to loop style processing twice for performance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// @ts-check | ||
|
||
const { isMainThread } = require("worker_threads") | ||
const { css, toCSSVar } = require("../dist/index.cjs.js") | ||
|
||
const theme = toCSSVar({ | ||
breakpoints: { | ||
sm: "40em", | ||
md: "52em", | ||
lg: "64em", | ||
xl: "80em", | ||
}, | ||
colors: { | ||
red: { | ||
500: "#ff0000", | ||
}, | ||
primary: "tomato", | ||
secondary: "cyan", | ||
}, | ||
fontSizes: [12, 14, 16, 24, 36], | ||
space: [0, 4, 8, 16, 32, 64, 128, 256, 512], | ||
fonts: { | ||
monospace: "Menlo, monospace", | ||
}, | ||
lineHeights: { | ||
body: 1.5, | ||
}, | ||
fontWeights: { | ||
bold: 600, | ||
}, | ||
sizes: { | ||
small: 4, | ||
medium: 8, | ||
large: 16, | ||
sidebar: 320, | ||
}, | ||
buttons: { | ||
primary: { | ||
p: 3, | ||
fontWeight: "bold", | ||
color: "white", | ||
bg: "primary", | ||
borderRadius: 2, | ||
}, | ||
}, | ||
text: { | ||
caps: { | ||
fontSize: [1, 2], | ||
letterSpacing: "0.1em", | ||
textTransform: "uppercase", | ||
}, | ||
title: { | ||
fontSize: [3, 4], | ||
letterSpacing: ["-0.01em", "-0.02em"], | ||
}, | ||
}, | ||
borderWidths: { | ||
thin: 1, | ||
}, | ||
borderStyles: { | ||
thick: "solid", | ||
}, | ||
radii: { | ||
small: 5, | ||
}, | ||
textTransform: { | ||
header: "uppercase", | ||
}, | ||
transition: { | ||
duration: { | ||
slow: "1s", | ||
}, | ||
easing: { | ||
smooth: "ease-in-out", | ||
}, | ||
property: { | ||
common: "opacity, transform, background-color, color", | ||
}, | ||
}, | ||
}) | ||
|
||
async function main() { | ||
const { cronometro } = await import("cronometro") | ||
|
||
return cronometro( | ||
{ | ||
systemProps() { | ||
css({ | ||
color: "primary", | ||
h1: { | ||
py: [3, 4], | ||
}, | ||
})(theme) | ||
}, | ||
}, | ||
{}, | ||
(err, _results) => { | ||
if (err) { | ||
throw err | ||
} | ||
}, | ||
) | ||
} | ||
|
||
if (isMainThread) { | ||
main() | ||
} else { | ||
module.exports = main | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
e0913e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
chakra-ui-storybook – ./
chakra-ui-storybook.vercel.app
chakra-ui-storybook-chakra-ui.vercel.app
storybook.chakra-ui.com
chakra-ui-storybook-git-main-chakra-ui.vercel.app