Skip to content

Commit

Permalink
refactor(styles): sort defineProps, defineEmits with TS type
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jan 25, 2024
1 parent 9895a37 commit 37a64a5
Show file tree
Hide file tree
Showing 24 changed files with 94 additions and 91 deletions.
9 changes: 5 additions & 4 deletions packages/materials/src/libs/admin-layout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ const props = withDefaults(defineProps<AdminLayoutProps>(), {
rightFooter: false
});
const emit = defineEmits<Emits>();
const slots = defineSlots<Slots>();
interface Emits {
/** Update siderCollapse */
(e: 'update:siderCollapse', collapse: boolean): void;
}
const emit = defineEmits<Emits>();
type SlotFn = (props?: Record<string, unknown>) => any;
type Slots = {
Expand All @@ -51,6 +49,9 @@ type Slots = {
/** Footer */
footer?: SlotFn;
};
const slots = defineSlots<Slots>();
const cssVars = computed(() => createLayoutCssVars(props));
// config visible
Expand Down
16 changes: 8 additions & 8 deletions packages/materials/src/libs/color-picker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ defineOptions({
name: 'ColorPicker'
});
interface Props {
color: string;
palettes?: string[];
disabled?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
palettes: () => [
'#3b82f6',
Expand All @@ -29,18 +35,12 @@ const props = withDefaults(defineProps<Props>(), {
]
});
const emit = defineEmits<Emits>();
interface Props {
color: string;
palettes?: string[];
disabled?: boolean;
}
interface Emits {
(e: 'update:color', value: string): void;
}
const emit = defineEmits<Emits>();
const domRef = ref<HTMLElement | null>(null);
const instance = ref<ColorPicker | null>(null);
Expand Down
4 changes: 2 additions & 2 deletions packages/materials/src/libs/page-tab/button-tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ defineOptions({
defineProps<PageTabProps>();
defineSlots<Slots>();
type SlotFn = (props?: Record<string, unknown>) => any;
type Slots = {
Expand All @@ -32,6 +30,8 @@ type Slots = {
*/
suffix?: SlotFn;
};
defineSlots<Slots>();
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions packages/materials/src/libs/page-tab/chrome-tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ defineOptions({
defineProps<PageTabProps>();
defineSlots<Slots>();
type SlotFn = (props?: Record<string, unknown>) => any;
type Slots = {
Expand All @@ -33,6 +31,8 @@ type Slots = {
*/
suffix?: SlotFn;
};
defineSlots<Slots>();
</script>

<template>
Expand Down
8 changes: 4 additions & 4 deletions packages/materials/src/libs/page-tab/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ const props = withDefaults(defineProps<PageTabProps>(), {
closable: true
});
const emit = defineEmits<Emits>();
defineSlots<Slots>();
interface Emits {
(e: 'close'): void;
}
const emit = defineEmits<Emits>();
type SlotFn = (props?: Record<string, unknown>) => any;
type Slots = {
Expand All @@ -50,6 +48,8 @@ type Slots = {
suffix?: SlotFn;
};
defineSlots<Slots>();
const activeTabComponent = computed(() => {
const { mode, chromeClass, buttonClass } = props;
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/dark-mode-container.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup lang="ts">
defineOptions({ name: 'DarkModeContainer' });
defineProps<Props>();
interface Props {
inverted?: boolean;
}
defineProps<Props>();
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/exception-base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { $t } from '@/locales';
defineOptions({ name: 'ExceptionBase' });
const props = defineProps<Props>();
type ExceptionType = '403' | '404' | '500';
interface Props {
Expand All @@ -19,6 +17,8 @@ interface Props {
type: ExceptionType;
}
const props = defineProps<Props>();
const iconMap: Record<ExceptionType, string> = {
'403': 'no-permission',
'404': 'not-found',
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/full-screen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ defineOptions({
name: 'FullScreen'
});
defineProps<Props>();
interface Props {
full?: boolean;
}
defineProps<Props>();
</script>

<template>
Expand Down
12 changes: 6 additions & 6 deletions src/components/common/lang-switch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ defineOptions({
name: 'LangSwitch'
});
const props = withDefaults(defineProps<Props>(), {
showTooltip: true
});
const emit = defineEmits<Emits>();
interface Props {
/** Current language */
lang: App.I18n.LangType;
Expand All @@ -21,10 +15,16 @@ interface Props {
showTooltip?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
showTooltip: true
});
type Emits = {
(e: 'changeLang', lang: App.I18n.LangType): void;
};
const emit = defineEmits<Emits>();
const tooltipContent = computed(() => {
if (!props.showTooltip) return '';
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/menu-toggler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { $t } from '@/locales';
defineOptions({ name: 'MenuToggler' });
const props = defineProps<Props>();
interface Props {
/** Show collapsed icon */
collapsed?: boolean;
/** Arrow style icon */
arrowIcon?: boolean;
}
const props = defineProps<Props>();
type NumberBool = 0 | 1;
const icon = computed(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/pin-toggler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { $t } from '@/locales';
defineOptions({ name: 'PinToggler' });
const props = defineProps<Props>();
interface Props {
pin?: boolean;
}
const props = defineProps<Props>();
const icon = computed(() => (props.pin ? 'mdi-pin-off' : 'mdi-pin'));
</script>

Expand Down
4 changes: 2 additions & 2 deletions src/components/common/reload-button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ defineOptions({
name: 'ReloadButton'
});
defineProps<Props>();
interface Props {
loading?: boolean;
}
defineProps<Props>();
</script>

<template>
Expand Down
14 changes: 7 additions & 7 deletions src/components/common/theme-schema-switch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ import { $t } from '@/locales';
defineOptions({ name: 'ThemeSchemaSwitch' });
const props = withDefaults(defineProps<Props>(), {
showTooltip: true,
tooltipPlacement: 'bottom'
});
const emit = defineEmits<Emits>();
interface Props {
/** Theme schema */
themeSchema: UnionKey.ThemeScheme;
Expand All @@ -21,10 +14,17 @@ interface Props {
tooltipPlacement?: TooltipPlacement;
}
const props = withDefaults(defineProps<Props>(), {
showTooltip: true,
tooltipPlacement: 'bottom'
});
interface Emits {
(e: 'switch'): void;
}
const emit = defineEmits<Emits>();
function handleSwitch() {
emit('switch');
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/custom/better-scroll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import type { Options } from '@better-scroll/core';
defineOptions({ name: 'BetterScroll' });
const props = defineProps<Props>();
interface Props {
/**
* BetterScroll options
Expand All @@ -17,6 +15,8 @@ interface Props {
options: Options;
}
const props = defineProps<Props>();
const bsWrap = ref<HTMLElement>();
const bsContent = ref<HTMLElement>();
const { width: wrapWidth } = useElementSize(bsWrap);
Expand Down
16 changes: 8 additions & 8 deletions src/components/custom/button-icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ defineOptions({
inheritAttrs: false
});
const props = withDefaults(defineProps<Props>(), {
class: 'h-36px text-icon',
icon: '',
tooltipContent: '',
tooltipPlacement: 'bottom',
triggerParent: false
});
interface Props {
/** Button class */
class?: string;
Expand All @@ -29,6 +21,14 @@ interface Props {
triggerParent?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
class: 'h-36px text-icon',
icon: '',
tooltipContent: '',
tooltipPlacement: 'bottom',
triggerParent: false
});
interface ButtonProps {
className: string;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/custom/svg-icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { Icon } from '@iconify/vue';
defineOptions({ name: 'SvgIcon' });
const props = defineProps<Props>();
/**
* Props
*
Expand All @@ -19,6 +17,8 @@ interface Props {
localIcon?: string;
}
const props = defineProps<Props>();
const attrs = useAttrs();
const bindAttrs = computed<{ class: string; style: string }>(() => ({
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/modules/global-content/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ defineOptions({
name: 'GlobalContent'
});
withDefaults(defineProps<Props>(), {
showPadding: true
});
interface Props {
/** Show padding for content */
showPadding?: boolean;
}
withDefaults(defineProps<Props>(), {
showPadding: true
});
const appStore = useAppStore();
const themeStore = useThemeStore();
const routeStore = useRouteStore();
Expand Down
14 changes: 8 additions & 6 deletions src/layouts/modules/global-header/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import UserAvatar from './components/user-avatar.vue';
defineOptions({
name: 'GlobalHeader'
});
defineProps<Props>();
const appStore = useAppStore();
const themeStore = useThemeStore();
const routeStore = useRouteStore();
const { isFullscreen, toggle } = useFullscreen();
const { menus } = useMixMenuContext();
interface Props {
/** Whether to show the logo */
Expand All @@ -30,6 +24,14 @@ interface Props {
showMenu?: App.Global.HeaderProps['showMenu'];
}
defineProps<Props>();
const appStore = useAppStore();
const themeStore = useThemeStore();
const routeStore = useRouteStore();
const { isFullscreen, toggle } = useFullscreen();
const { menus } = useMixMenuContext();
const headerMenus = computed(() => {
if (themeStore.layout.mode === 'horizontal') {
return routeStore.menus;
Expand Down
Loading

0 comments on commit 37a64a5

Please sign in to comment.