-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notify): Notify组件支持containerSelector和className配置 (#2055)
Co-authored-by: daitingyuan <[email protected]>
- Loading branch information
Showing
7 changed files
with
223 additions
and
27 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
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
32 changes: 32 additions & 0 deletions
32
packages/zent/src/notify/demos/custom-container-selector.md
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 @@ | ||
--- | ||
order: 7 | ||
zh-CN: | ||
title: 自定义父节点CSS selector | ||
name: 自定义父节点 | ||
|
||
en-US: | ||
title: Custom notify parent container css selector | ||
name: custom notify content container | ||
|
||
--- | ||
|
||
```jsx | ||
import { Notify, Button } from 'zent'; | ||
|
||
function customContent() { | ||
Notify.success('{i18n.name}', '', () => {}, '#custom-container'); | ||
} | ||
|
||
const relativeStyle = { | ||
position: 'relative' | ||
} | ||
|
||
ReactDOM.render( | ||
<div> | ||
<Button onClick={customContent}>{i18n.name}</Button> | ||
<div id="custom-container" style={relativeStyle}></div> | ||
</div> | ||
, mountNode | ||
); | ||
|
||
``` |
36 changes: 36 additions & 0 deletions
36
packages/zent/src/notify/demos/global-container-selector.md
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,36 @@ | ||
|
||
--- | ||
order: 8 | ||
zh-CN: | ||
title: 通过 config 调整全局挂载父节点 | ||
name: 调整挂载父节点 | ||
reset: 重置挂载父节点 | ||
info: 常规提示 | ||
en-US: | ||
title: Adjust the global default container selector through Notify.config | ||
name: Set global container selector to custom | ||
reset: Reset global container selector config | ||
info: info | ||
|
||
--- | ||
|
||
```jsx | ||
import { Notify, Button } from 'zent'; | ||
|
||
const relativeStyle = { | ||
position: 'relative' | ||
} | ||
|
||
ReactDOM.render( | ||
<div> | ||
<Button onClick={() => Notify.config({ containerSelector: '#global-custom-container' })}>{i18n.name}</Button> | ||
<Button onClick={() => Notify.config({ containerSelector: 'body' })}>{i18n.reset}</Button> | ||
<div id="global-custom-container" style={relativeStyle}></div> | ||
<br /> | ||
<br /> | ||
<Button onClick={() => Notify.info('{i18n.info}')}>{i18n.info}</Button> | ||
</div> | ||
, mountNode | ||
); | ||
|
||
``` |