forked from tusen-ai/naive-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(message-provider): add placement prop (tusen-ai#851)
* feat:n-input Support hidden password * feat(form): support require-mark-placement(tusen-ai#171) * Revert "feat(form): support require-mark-placement(tusen-ai#171)" This reverts commit 0627777. * Revert "feat:n-input Support hidden password" This reverts commit ea64917. * feat(message provider): add placement prop(wip) * feat(message provider): add placement prop * feat: add demo * feat: fix demo code * feat: fix code * feat: fix code * Update CHANGELOG.en-US.md * feat: fix style code
- Loading branch information
Showing
9 changed files
with
316 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Placement | ||
|
||
```html | ||
<n-message-provider :placement="placement"> | ||
<Buttons @changePlacement="changePlacement" /> | ||
</n-message-provider> | ||
``` | ||
|
||
```js | ||
import { useMessage, NButton } from 'naive-ui' | ||
import { h, ref } from 'vue' | ||
|
||
const Buttons = { | ||
emits: ['changePlacement'], | ||
setup() { | ||
const message = useMessage() | ||
return { | ||
message | ||
} | ||
}, | ||
render() { | ||
return [ | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'top') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => 'Top' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'bottom') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => 'Bottom' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'top-left') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => 'TopLeft' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'top-right') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => 'TopRight' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'bottom-left') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => 'BottomLeft' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'bottom-right') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => 'BottomRight' } | ||
) | ||
] | ||
} | ||
} | ||
|
||
export default { | ||
components: { | ||
Buttons | ||
}, | ||
setup() { | ||
const placement = ref('top') | ||
return { | ||
placement, | ||
changePlacement: (val) => { | ||
placement.value = val | ||
} | ||
} | ||
} | ||
} | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# 位置 | ||
|
||
```html | ||
<n-message-provider :placement="placement"> | ||
<Buttons @changePlacement="changePlacement" /> | ||
</n-message-provider> | ||
``` | ||
|
||
```js | ||
import { useMessage, NButton } from 'naive-ui' | ||
import { h, ref } from 'vue' | ||
|
||
const Buttons = { | ||
emits: ['changePlacement'], | ||
setup() { | ||
const message = useMessage() | ||
return { | ||
message | ||
} | ||
}, | ||
render() { | ||
return [ | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'top') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => '顶部' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'bottom') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => '底部' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'top-left') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => '左上' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'top-right') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => '右上' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'bottom-left') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => '左下' } | ||
), | ||
h( | ||
NButton, | ||
{ | ||
onClick: () => { | ||
this.$emit('changePlacement', 'bottom-right') | ||
this.message.info('How many roads must a man walk down') | ||
}, | ||
style: { | ||
marginRight: '10px' | ||
} | ||
}, | ||
{ default: () => '右下' } | ||
) | ||
] | ||
} | ||
} | ||
|
||
export default { | ||
components: { | ||
Buttons | ||
}, | ||
setup() { | ||
const placement = ref('top') | ||
return { | ||
placement, | ||
changePlacement: (val) => { | ||
placement.value = val | ||
} | ||
} | ||
} | ||
} | ||
``` |
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.