-
-
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.
feat: support custom conditions / psuedo props (#8218)
* chore: wip * chore: update generated conditions * docs: update changeset * feat: add new pseudos
- Loading branch information
1 parent
80406fd
commit a89c598
Showing
18 changed files
with
198 additions
and
87 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,32 @@ | ||
--- | ||
"@chakra-ui/styled-system": minor | ||
"@chakra-ui/react": minor | ||
"@chakra-ui/theme": minor | ||
--- | ||
|
||
Add support for custom theme conditions or pseudo props via `theme.conditions` | ||
|
||
```ts | ||
// theme.ts | ||
|
||
const theme = extendTheme({ | ||
conditions: { | ||
_closed: "[data-state='closed']", // pseudo prop | ||
}, | ||
}) | ||
``` | ||
|
||
This allows you to use the pseudo prop in your components | ||
|
||
```jsx | ||
<Box data-state="closed" _closed={{ bg: "red.200" }}> | ||
This box is closed | ||
</Box> | ||
``` | ||
|
||
**For TypeScript users**, you need to use the Chakra CLI to generate the types | ||
for your custom conditions. | ||
|
||
```sh | ||
pnpm chakra-cli tokens src/theme/index.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,20 @@ | ||
--- | ||
"@chakra-ui/styled-system": minor | ||
--- | ||
|
||
Add support for `_open` and `_closed` pseudo props for styling their respective | ||
selectors. | ||
|
||
- `_open`: `&[data-state=open], &[open]` | ||
- `_closed`: `&[data-state=closed]` | ||
- `_groupOpen`: `[data-group][data-state=open] &` | ||
- `_groupClosed`: `[data-group][data-state=closed] &` | ||
|
||
Extend the existing pseudo props to support new selectors` | ||
|
||
- `_placeholder` now supports `&[data-placeholder]` | ||
- `_placeholderShow` now supports `&[data-placeholder-shown]` | ||
- `_fullscreen` now supports `&[data-fullscreen]` | ||
- `_empty` now supports `&[data-empty]` | ||
- `_expanded` now supports `&[data-state=expanded]` | ||
- `_checked` now supports `&[data-state-checked]` |
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
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
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
Oops, something went wrong.