Skip to content

Commit

Permalink
refactor(drawer): refactor props detailType to isDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 25, 2020
1 parent 491ba9a commit 2628fb5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
- 面包屑支持显示图标
- 新增 tinymce 富文本组件
- 表单新增 submitOnReset 控制是否在重置时重新发起请求
- 表格新增`sortFn`支持自定义排序

### ✨ Refactor

- Drawer 组件的 detailType 修改为 isDetail

### 🎫 Chores

Expand Down
6 changes: 3 additions & 3 deletions src/components/Drawer/src/BasicDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { FullLoading } from '/@/components/Loading/index';

import { getSlot } from '/@/utils/helper/tsxHelper';

import { DrawerInstance, DrawerProps, DrawerType } from './types';
import { DrawerInstance, DrawerProps } from './types';

import { basicProps } from './props';
import { isFunction, isNumber } from '/@/utils/is';
Expand Down Expand Up @@ -54,7 +54,7 @@ export default defineComponent({
};
opt.title = undefined;

if (opt.drawerType === DrawerType.DETAIL) {
if (opt.isDetail) {
if (!opt.width) {
opt.width = '100%';
}
Expand Down Expand Up @@ -157,7 +157,7 @@ export default defineComponent({

function renderHeader() {
const { title } = unref(getMergeProps);
return props.drawerType === DrawerType.DETAIL ? (
return props.isDetail ? (
getSlot(slots, 'title') || (
<Row type="flex" align="middle" class={`${prefixCls}__detail-header`}>
{() => (
Expand Down
7 changes: 3 additions & 4 deletions src/components/Drawer/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { PropType } from 'vue';
import { DrawerType } from './types';
// import {DrawerProps} from './types'
export const footerProps = {
confirmLoading: Boolean as PropType<boolean>,
Expand Down Expand Up @@ -41,9 +40,9 @@ export const footerProps = {
},
};
export const basicProps = {
drawerType: {
type: Number as PropType<number>,
default: DrawerType.DEFAULT,
isDetail: {
type: Boolean as PropType<boolean>,
default: false,
},
title: {
type: String as PropType<string>,
Expand Down
6 changes: 1 addition & 5 deletions src/components/Drawer/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export interface ReturnInnerMethods extends DrawerInstance {

export type UseDrawerReturnType = [RegisterFn, ReturnMethods];
export type UseDrawerInnerReturnType = [RegisterFn, ReturnInnerMethods];
export enum DrawerType {
DETAIL,
DEFAULT,
}

export interface DrawerFooterProps {
showOkBtn: boolean;
Expand Down Expand Up @@ -69,7 +65,7 @@ export interface DrawerFooterProps {
footerHeight: string | number;
}
export interface DrawerProps extends DrawerFooterProps {
drawerType: DrawerType;
isDetail?: boolean;
loading?: boolean;
showDetailBack?: boolean;
visible?: boolean;
Expand Down
8 changes: 3 additions & 5 deletions src/views/demo/comp/drawer/Drawer5.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<template>
<BasicDrawer v-bind="$attrs" :drawerType="DrawerType.DETAIL" title="Drawer Title5">
<BasicDrawer v-bind="$attrs" :isDetail="true" title="Drawer Title5">
<p class="h-20">Content Message</p>
</BasicDrawer>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { BasicDrawer, DrawerType } from '/@/components/Drawer';
import { BasicDrawer } from '/@/components/Drawer';
export default defineComponent({
components: { BasicDrawer },
setup() {
return { DrawerType };
},
setup() {},
});
</script>

0 comments on commit 2628fb5

Please sign in to comment.