mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
feat(message): Add container-style
prop to n-message-provider
(#831)
* feat(message): Add `container-style` prop to `n-message-provider` * Update CHANGELOG.zh-CN.md Co-authored-by: 07akioni <07akioni2@gmail.com> * Remove default value from containerStyle Co-authored-by: Yugang Cao <34439652+Talljack@users.noreply.github.com> Co-authored-by: 07akioni <07akioni2@gmail.com> Co-authored-by: Yugang Cao <34439652+Talljack@users.noreply.github.com>
This commit is contained in:
parent
4b2798c017
commit
35d76dcf4d
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## Pending
|
## Pending
|
||||||
|
|
||||||
|
### Feats
|
||||||
|
|
||||||
|
- `n-message-provider` add `container-style` prop
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
- Fix `n-rate` half star overlays star background in dark mode.
|
- Fix `n-rate` half star overlays star background in dark mode.
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
|
||||||
## Pending
|
## Pending
|
||||||
|
|
||||||
|
### Feats
|
||||||
|
|
||||||
|
- `n-message-provider` 新增 `container-style` 属性
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
- 修复 `n-rate` 在深色模式下半个星星重叠
|
- 修复 `n-rate` 在深色模式下半个星星重叠
|
||||||
|
@ -11,7 +11,8 @@ import {
|
|||||||
ExtractPropTypes,
|
ExtractPropTypes,
|
||||||
renderSlot,
|
renderSlot,
|
||||||
Ref,
|
Ref,
|
||||||
PropType
|
PropType,
|
||||||
|
CSSProperties
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import { createId } from 'seemly'
|
import { createId } from 'seemly'
|
||||||
import { ExtractPublicPropTypes, omit } from '../../_utils'
|
import { ExtractPublicPropTypes, omit } from '../../_utils'
|
||||||
@ -71,7 +72,8 @@ const messageProviderProps = {
|
|||||||
default: 3000
|
default: 3000
|
||||||
},
|
},
|
||||||
max: Number,
|
max: Number,
|
||||||
closable: Boolean
|
closable: Boolean,
|
||||||
|
containerStyle: [String, Object] as PropType<string | CSSProperties>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MessageProviderProps = ExtractPublicPropTypes<
|
export type MessageProviderProps = ExtractPublicPropTypes<
|
||||||
@ -164,6 +166,7 @@ export default defineComponent({
|
|||||||
<div
|
<div
|
||||||
class={`${this.mergedClsPrefix}-message-container`}
|
class={`${this.mergedClsPrefix}-message-container`}
|
||||||
key="message-container"
|
key="message-container"
|
||||||
|
style={this.containerStyle}
|
||||||
>
|
>
|
||||||
{this.messageList.map((message) => {
|
{this.messageList.map((message) => {
|
||||||
return (
|
return (
|
||||||
|
@ -111,4 +111,31 @@ describe('message-provider', () => {
|
|||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('props.container-style', (done) => {
|
||||||
|
const Test = defineComponent({
|
||||||
|
setup () {
|
||||||
|
const message = useMessage()
|
||||||
|
message.info('string')
|
||||||
|
},
|
||||||
|
render () {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const wrapper = mount(NMessageProvider, {
|
||||||
|
props: {
|
||||||
|
'container-style': 'padding: 24px'
|
||||||
|
},
|
||||||
|
slots: {
|
||||||
|
default: () => <Test />
|
||||||
|
}
|
||||||
|
})
|
||||||
|
void nextTick(() => {
|
||||||
|
const container = document.querySelector('.n-message-container')
|
||||||
|
expect(container).not.toBe(null)
|
||||||
|
expect(container.attributes.style.value).toContain('padding: 24px')
|
||||||
|
wrapper.unmount()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user