feat(Overlay): add custom-style prop (#4572)

This commit is contained in:
neverland 2019-09-25 15:22:25 +08:00 committed by GitHub
parent a70c0ac5f4
commit 89d97ee5cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 2 deletions

View File

@ -39,6 +39,7 @@ export default {
| z-index | z-index | *string \| number* | `1` | - |
| duration | Animation duration | *string \| number* | `0.3` | - |
| class-name | ClassName | *string* | - | - |
| custom-class | Custom style | *object* | - | - |
### Events

View File

@ -43,6 +43,7 @@ export default {
| z-index | z-index 层级 | *string \| number* | `1` | - |
| duration | 动画时长,单位秒 | *string \| number* | `0.3` | - |
| class-name | 自定义类名 | *string* | - | - |
| custom-style | 自定义样式 | *object* | - | - |
### Events

View File

@ -11,7 +11,7 @@ export type OverlayProps = {
zIndex?: number | string;
duration: number | string | null;
className?: any;
customStyle?: any;
customStyle?: object;
};
export type OverlayEvents = {
@ -58,7 +58,7 @@ Overlay.props = {
show: Boolean,
duration: [Number, String],
className: null as any,
customStyle: null as any,
customStyle: Object,
zIndex: {
type: [Number, String],
default: 1

View File

@ -2,6 +2,8 @@
exports[`class-name prop 1`] = `<div class="van-overlay my-overlay" style="z-index: 1;" name="van-fade"></div>`;
exports[`custom style prop 1`] = `<div class="van-overlay" style="z-index: 1; background-color: red;" name="van-fade"></div>`;
exports[`default slot 1`] = `<div class="van-overlay" style="z-index: 1; display: none;" name="van-fade">Custom Default</div>`;
exports[`duration prop 1`] = `<div class="van-overlay" style="z-index: 1; animation-duration: 1s;" name="van-fade"></div>`;

View File

@ -23,6 +23,19 @@ test('class-name prop', () => {
expect(wrapper).toMatchSnapshot();
});
test('custom style prop', () => {
const wrapper = mount(Overlay, {
propsData: {
show: true,
customStyle: {
backgroundColor: 'red'
}
}
});
expect(wrapper).toMatchSnapshot();
});
test('duration prop', () => {
const wrapper = mount(Overlay, {
propsData: {