Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(comp:modal): add animatable global config #1558

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/config/src/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export const defaultConfig: GlobalConfig = {
},
},
modal: {
animatable: true,
centered: false,
closable: true,
closeIcon: 'dialog-close',
Expand Down
1 change: 1 addition & 0 deletions packages/components/config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export interface MessageConfig {
}

export interface ModalConfig {
animatable: boolean
centered: boolean
closable: boolean
closeIcon: string
Expand Down
10 changes: 7 additions & 3 deletions packages/components/modal/src/ModalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export default defineComponent({
currentZIndex,
} = inject(modalToken)!
const { close, cancel, ok } = inject(MODAL_TOKEN)!
const { centered, closable, closeIcon, closeOnEsc, width, mask, maskClosable } = useConfig(props, config)
const { animatable, centered, closable, closeIcon, closeOnEsc, width, mask, maskClosable } = useConfig(
props,
config,
)

const cancelVisible = computed(() => props.type === 'default' || props.type === 'confirm')

Expand Down Expand Up @@ -156,7 +159,7 @@ export default defineComponent({
onKeydown={onWrapperKeydown}
>
<Transition
name={props.animatable ? `${common.prefixCls}-zoom` : undefined}
name={animatable.value ? `${common.prefixCls}-zoom` : undefined}
appear
onEnter={onEnter}
onAfterEnter={onAfterEnter}
Expand Down Expand Up @@ -209,6 +212,7 @@ export default defineComponent({
})

function useConfig(props: ModalProps, config: ModalConfig) {
const animatable = computed(() => props.animatable ?? config.animatable)
const centered = computed(() => props.centered ?? config.centered)
const closable = computed(() => props.closable ?? config.closable)
const closeIcon = computed(() => props.closeIcon ?? config.closeIcon)
Expand All @@ -224,7 +228,7 @@ function useConfig(props: ModalProps, config: ModalConfig) {
}
})

return { centered, closable, closeIcon, closeOnEsc, width, mask, maskClosable }
return { animatable, centered, closable, closeIcon, closeOnEsc, width, mask, maskClosable }
}

function watchVisibleChange(
Expand Down
2 changes: 1 addition & 1 deletion packages/components/modal/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const modalProps = {
},
animatable: {
type: Boolean,
default: true,
default: undefined,
},
offset: {
type: [String, Number] as PropType<string | number>,
Expand Down