Skip to content

Commit

Permalink
chore(popup, notify): improve type def (#2898)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Jan 30, 2024
1 parent 488d620 commit 90c902b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/packages/__VUE/cascader/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
pop-class="nut-cascader__popup"
round
:closeable="closeable"
:close-icon="closeIcon"
:destroy-on-close="false"
:close-icon-position="closeIconPosition"
:lock-scroll="lockScroll"
Expand Down
27 changes: 20 additions & 7 deletions src/packages/__VUE/notify/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
</nut-popup>
</template>
<script lang="ts">
import { ref, watch, onUnmounted } from 'vue';
import { ref, watch, onUnmounted, type PropType } from 'vue';
import { createComponent } from '../../utils/create';
import NutPopup from '../popup/index.taro.vue';
import type { NotifyPosition, NotifyType } from './types';
const { create } = createComponent('notify');
export default create({
Expand All @@ -24,24 +25,36 @@ export default create({
},
props: {
id: String,
color: { type: String, default: '' },
msg: { type: String, default: '' },
duration: { type: Number, default: 3000 },
color: {
type: String,
default: ''
},
msg: {
type: String,
default: ''
},
duration: {
type: Number,
default: 3000
},
className: {
type: String,
default: ''
},
background: { type: String, default: '' },
type: {
background: {
type: String,
default: ''
},
type: {
type: String as PropType<NotifyType>,
default: 'danger'
},
visible: {
type: Boolean,
default: false
},
position: {
type: String,
type: String as PropType<NotifyPosition>,
default: 'top'
},
onClose: Function,
Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/notify/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createVNode, render, h, onMounted, VNode, ComponentInternalInstance } from 'vue';
import Notify from './index.vue';
import type { NotifyType } from './types';
const defaultOptions = {
type: 'base',
type: 'base' as NotifyType,
visible: true,
msg: '',
color: undefined,
Expand Down
27 changes: 20 additions & 7 deletions src/packages/__VUE/notify/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
</nut-popup>
</template>
<script lang="ts">
import { ref, watch } from 'vue';
import { ref, watch, type PropType } from 'vue';
import { createComponent } from '../../utils/create';
import NutPopup from '../popup/index.vue';
import type { NotifyPosition, NotifyType } from './types';
const { create } = createComponent('notify');
export default create({
Expand All @@ -24,24 +25,36 @@ export default create({
},
props: {
id: String,
color: { type: String, default: '' },
msg: { type: String, default: '' },
duration: { type: Number, default: 3000 },
color: {
type: String,
default: ''
},
msg: {
type: String,
default: ''
},
duration: {
type: Number,
default: 3000
},
className: {
type: String,
default: ''
},
background: { type: String, default: '' },
type: {
background: {
type: String,
default: ''
},
type: {
type: String as PropType<NotifyType>,
default: 'danger'
},
visible: {
type: Boolean,
default: false
},
position: {
type: String,
type: String as PropType<NotifyPosition>,
default: 'top'
},
teleportDisable: {
Expand Down
4 changes: 4 additions & 0 deletions src/packages/__VUE/notify/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { PopupPosition } from '../popup/types';

export type NotifyPosition = PopupPosition;
export type NotifyType = 'base' | 'danger' | 'primary' | 'success' | 'warning';
11 changes: 5 additions & 6 deletions src/packages/__VUE/popup/props.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import type { PropType } from 'vue';
import type { PopupCloseIconPosition, PopupPosition } from './types';

export const popupProps = {
visible: {
type: Boolean,
Expand All @@ -20,7 +23,7 @@ export const popupProps = {
default: true
},
position: {
type: String,
type: String as PropType<PopupPosition>,
default: 'center'
},
transition: {
Expand All @@ -40,13 +43,9 @@ export const popupProps = {
default: false
},
closeIconPosition: {
type: String,
type: String as PropType<PopupCloseIconPosition>,
default: 'top-right'
},
closeIcon: {
type: String,
default: 'close'
},
destroyOnClose: {
type: Boolean,
default: true
Expand Down
2 changes: 2 additions & 0 deletions src/packages/__VUE/popup/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type PopupPosition = 'center' | 'left' | 'right' | 'top' | 'bottom' | '';
export type PopupCloseIconPosition = 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right';

0 comments on commit 90c902b

Please sign in to comment.