From 83de433991a5f610ac156e55c348f86da0b83e86 Mon Sep 17 00:00:00 2001 From: zcating Date: Fri, 24 Sep 2021 00:46:13 +0800 Subject: [PATCH 01/16] =?UTF-8?q?feat(modal):=20=E5=AE=8C=E6=88=90modal?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E5=B1=95=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devui/modal/index.ts | 18 +++++++ devui/modal/src/modal-footer.tsx | 0 devui/modal/src/modal-header.tsx | 0 devui/modal/src/modal-types.ts | 89 ++++++++++++++++++++++++++++++++ devui/modal/src/modal.scss | 46 +++++++++++++++++ devui/modal/src/modal.tsx | 60 +++++++++++++++++++++ docs/components/modal/index.md | 55 ++++++++++++++++++++ 7 files changed, 268 insertions(+) create mode 100644 devui/modal/index.ts create mode 100644 devui/modal/src/modal-footer.tsx create mode 100644 devui/modal/src/modal-header.tsx create mode 100644 devui/modal/src/modal-types.ts create mode 100644 devui/modal/src/modal.scss create mode 100644 devui/modal/src/modal.tsx create mode 100644 docs/components/modal/index.md diff --git a/devui/modal/index.ts b/devui/modal/index.ts new file mode 100644 index 00000000..ee646765 --- /dev/null +++ b/devui/modal/index.ts @@ -0,0 +1,18 @@ +import type { App } from 'vue' +import Modal from './src/modal' + +Modal.install = function(app: App): void { + app.component(Modal.name, Modal) +} + +export { Modal } + +export default { + title: 'Modal 弹窗', + category: '反馈', + status: undefined, // TODO: 组件若开发完成则填入"已完成",并删除该注释 + install(app: App): void { + + app.use(Modal as any) + } +} diff --git a/devui/modal/src/modal-footer.tsx b/devui/modal/src/modal-footer.tsx new file mode 100644 index 00000000..e69de29b diff --git a/devui/modal/src/modal-header.tsx b/devui/modal/src/modal-header.tsx new file mode 100644 index 00000000..e69de29b diff --git a/devui/modal/src/modal-types.ts b/devui/modal/src/modal-types.ts new file mode 100644 index 00000000..b91cb2ac --- /dev/null +++ b/devui/modal/src/modal-types.ts @@ -0,0 +1,89 @@ +import type { PropType, ExtractPropTypes } from 'vue' +import { IButtonStyle } from '../../button/src/button' + +interface ButtonProps { + bsStyle: IButtonStyle + text: string + disabled: boolean + handler: ($event: Event) => void +} + +export const modalProps = { + // id: { + // type: String, + // required: true + // }, + width: { + type: String, + default: '300px' + }, + maxHeight: { + type: String, + }, + + zIndex: { + type: Number, + default: 1050 + }, + backDropZIndex: { + type: Number, + default: 1049 + }, + + placement: { + type: String as PropType<'center' | 'top' | 'bottom'>, + default: 'center' + }, + offsetX: { + type: String, + default: '0px' + }, + + offsetY: { + type: String, + default: '0px' + }, + + title: { + type: String + }, + + showAnimation: { + type: Boolean, + default: true + }, + backdropCloseable: { + type: Boolean, + default: true + }, + bodyScrollable: { + type: Boolean, + default: true + }, + + escapeable: { + type: Boolean, + default: true + }, + + onClose: { + type: Function as PropType<() => void>, + }, + beforeHidden: { + type: Object as PropType | (() => void)> + }, + + buttons: { + type: Array as PropType, + default: [] + }, + + modelValue: { + type: Boolean, + }, + 'onUpdate:modelValue': { + type: Function as PropType<(value: boolean) => void> + } +} as const + +export type ModalProps = ExtractPropTypes diff --git a/devui/modal/src/modal.scss b/devui/modal/src/modal.scss new file mode 100644 index 00000000..f2278aa4 --- /dev/null +++ b/devui/modal/src/modal.scss @@ -0,0 +1,46 @@ +@import '../../style/theme/color'; +@import '../../style/theme/corner'; +@import '../../style/theme/font'; + +.modal-wrapper { + justify-content: center; + align-items: center; + background-color: $devui-shadow; +} + +.modal-content { + background: $devui-fullscreen-overlay-bg; + border-radius: $devui-border-radius; +} + +.modal-body { + padding: 20px 32px; + color: $devui-text-weak; +} + +.modal-header { + padding: 32px 32px 0; + height: 56px; + position: relative; + border: none; + + .btn-close { + position: absolute; + right: 20px; + top: 20px; + font-size: $devui-font-size-icon; + font-weight: 700; + line-height: 1; + color: #000000; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; + } +} + +.modal-footer { + border-top: none; + text-align: center; + padding: 0 32px 24px; +} diff --git a/devui/modal/src/modal.tsx b/devui/modal/src/modal.tsx new file mode 100644 index 00000000..a0a56d22 --- /dev/null +++ b/devui/modal/src/modal.tsx @@ -0,0 +1,60 @@ +import { computed, defineComponent } from 'vue' +import { modalProps, ModalProps } from './modal-types' +import { FixedOverlay } from '../../overlay' +import { Button } from '../../button'; +import { Icon } from '../../icon'; +import './modal.scss'; + +export default defineComponent({ + name: 'DModal', + props: modalProps, + emits: ['onUpdate:modelValue'], + setup(props: ModalProps, ctx) { + + const containerStyle = computed(() => { + return { + width: props.width, + maxHeight: props.maxHeight + }; + }); + + const buttons = computed(() => { + return props.buttons.map((buttonProps, index) => { + const {bsStyle, disabled, handler, text} = buttonProps; + return ( + + ); + }); + }); + + return () => ( + + + + ) + } +}) diff --git a/docs/components/modal/index.md b/docs/components/modal/index.md new file mode 100644 index 00000000..1c4316a8 --- /dev/null +++ b/docs/components/modal/index.md @@ -0,0 +1,55 @@ +:::demo + +```vue + + + +``` +::: -- Gitee From dc26d37c4cfd791774801ce8f774be4d83c13d8c Mon Sep 17 00:00:00 2001 From: zhuchenxi Date: Fri, 24 Sep 2021 09:41:49 +0800 Subject: [PATCH 02/16] =?UTF-8?q?fix(modal):=20=E6=A0=B7=E5=BC=8F=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devui/modal/src/modal.scss | 10 +++++----- devui/modal/src/modal.tsx | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/devui/modal/src/modal.scss b/devui/modal/src/modal.scss index f2278aa4..da8a56b5 100644 --- a/devui/modal/src/modal.scss +++ b/devui/modal/src/modal.scss @@ -2,23 +2,23 @@ @import '../../style/theme/corner'; @import '../../style/theme/font'; -.modal-wrapper { +.devui-modal-wrapper { justify-content: center; align-items: center; background-color: $devui-shadow; } -.modal-content { +.devui-modal-content { background: $devui-fullscreen-overlay-bg; border-radius: $devui-border-radius; } -.modal-body { +.devui-modal-body { padding: 20px 32px; color: $devui-text-weak; } -.modal-header { +.devui-modal-header { padding: 32px 32px 0; height: 56px; position: relative; @@ -39,7 +39,7 @@ } } -.modal-footer { +.devui-modal-footer { border-top: none; text-align: center; padding: 0 32px 24px; diff --git a/devui/modal/src/modal.tsx b/devui/modal/src/modal.tsx index a0a56d22..d751c6d8 100644 --- a/devui/modal/src/modal.tsx +++ b/devui/modal/src/modal.tsx @@ -20,11 +20,11 @@ export default defineComponent({ const buttons = computed(() => { return props.buttons.map((buttonProps, index) => { - const {bsStyle, disabled, handler, text} = buttonProps; + const { bsStyle, disabled, handler, text } = buttonProps; return ( - -