generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: 支持 StyleProvider 上指定 container 进行样式点插入
- Loading branch information
Showing
5 changed files
with
78 additions
and
9 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
30 changes: 30 additions & 0 deletions
30
docs/demos/api/createInstance/createInstanceWithContainer.tsx
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,30 @@ | ||
/** | ||
* iframe: true | ||
*/ | ||
import { Button } from 'antd'; | ||
import { createInstance } from 'antd-style'; | ||
|
||
const { css, StyleProvider, createStyles } = createInstance({ | ||
key: 'test', | ||
container: document.body, | ||
}); | ||
|
||
const useStyles = createStyles({ | ||
text: css` | ||
color: blue; | ||
`, | ||
}); | ||
|
||
const Text = () => { | ||
const { styles } = useStyles(); | ||
return <div className={styles.text}>我是文本</div>; | ||
}; | ||
|
||
export default () => { | ||
return ( | ||
<StyleProvider> | ||
<Text /> | ||
<Button>按钮</Button> | ||
</StyleProvider> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
docs/demos/api/createInstance/createInstanceWithStyleProviderContainer.tsx
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,29 @@ | ||
/** | ||
* iframe: true | ||
*/ | ||
import { Button } from 'antd'; | ||
import { createInstance } from 'antd-style'; | ||
|
||
const { css, StyleProvider, createStyles } = createInstance({ | ||
key: 'test', | ||
}); | ||
|
||
const useStyles = createStyles({ | ||
text: css` | ||
color: red; | ||
`, | ||
}); | ||
|
||
const Text = () => { | ||
const { styles } = useStyles(); | ||
return <div className={styles.text}>我是文本</div>; | ||
}; | ||
|
||
export default () => { | ||
return ( | ||
<StyleProvider container={document.body}> | ||
<Text /> | ||
<Button>按钮</Button> | ||
</StyleProvider> | ||
); | ||
}; |
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