Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add forced to color mode context * fix: css var resolution bug * feat: attach data-theme attr if forced * chore: add storybook example * fix: allow data attr to be overriden * docs: add changeset * fix: ts errors
- Loading branch information
1 parent
1ce7017
commit c2d1c36
Showing
8 changed files
with
104 additions
and
8 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,19 @@ | ||
--- | ||
"@chakra-ui/styled-system": patch | ||
"@chakra-ui/system": patch | ||
--- | ||
|
||
Improve style resolution when components are wrapped within forced color mode | ||
elements (`DarkMode`, `LightMode`). | ||
|
||
We now dynamically attach the `data-theme` attribute to chakra elements when in | ||
forced color mode. | ||
|
||
```jsx live=false | ||
<DarkMode> | ||
<chakra.div bg="gray.800" padding="40px"> | ||
{/* Forced: Badge will now have `data-theme='dark' attached` */} | ||
<Badge>Total</Badge> | ||
</chakra.div> | ||
</DarkMode> | ||
``` |
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 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
27 changes: 27 additions & 0 deletions
27
packages/components/styled-system/src/utils/split-by-comma.ts
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,27 @@ | ||
export function splitByComma(value: string) { | ||
const chunks = [] | ||
let chunk = "" | ||
let inParens = false | ||
for (let i = 0; i < value.length; i++) { | ||
const char = value[i] | ||
if (char === "(") { | ||
inParens = true | ||
chunk += char | ||
} else if (char === ")") { | ||
inParens = false | ||
chunk += char | ||
} else if (char === "," && !inParens) { | ||
chunks.push(chunk) | ||
chunk = "" | ||
} else { | ||
chunk += char | ||
} | ||
} | ||
|
||
chunk = chunk.trim() | ||
if (chunk) { | ||
chunks.push(chunk) | ||
} | ||
|
||
return chunks | ||
} |
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 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
c2d1c36
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-chakra-ui.vercel.app
chakra-ui-storybook-git-main-chakra-ui.vercel.app
storybook.chakra-ui.com
chakra-ui-storybook.vercel.app