mirror of
https://github.com/unraid/api.git
synced 2026-03-11 04:28:47 -05:00
refactor: abstract button compnoent props type
This commit is contained in:
@@ -1,24 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
computed,
|
||||
type Component,
|
||||
} from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import type { ButtonProps } from '~/types/ui/button';
|
||||
|
||||
export interface ButtonProps {
|
||||
btnStyle?: 'black' | 'fill' | 'gray' | 'outline' | 'outline-black' | 'outline-white' | 'underline' | 'white';
|
||||
btnType?: 'button' | 'submit' | 'reset';
|
||||
click?: () => void;
|
||||
disabled?: boolean;
|
||||
download?: boolean;
|
||||
external?: boolean;
|
||||
href?: string;
|
||||
icon?: Component;
|
||||
iconRight?: Component;
|
||||
iconRightHoverDisplay?: boolean;
|
||||
// iconRightHoverAnimate?: boolean;
|
||||
size?: '12px' | '14px' | '16px' | '18px' | '20px' | '24px';
|
||||
text?: string;
|
||||
}
|
||||
const props = withDefaults(defineProps<ButtonProps>(), {
|
||||
btnStyle: 'fill',
|
||||
btnType: 'button',
|
||||
@@ -30,6 +14,7 @@ const props = withDefaults(defineProps<ButtonProps>(), {
|
||||
// iconRightHoverAnimate: true,
|
||||
size: '16px',
|
||||
text: '',
|
||||
title: '',
|
||||
});
|
||||
|
||||
defineEmits(['click']);
|
||||
@@ -111,6 +96,7 @@ const classes = computed(() => {
|
||||
:target="external ? '_blank' : ''"
|
||||
:type="!href ? btnType : ''"
|
||||
:class="classes.button"
|
||||
:title="title"
|
||||
@click="click ?? $emit('click')"
|
||||
>
|
||||
<div
|
||||
|
||||
16
web/types/ui/button.ts
Normal file
16
web/types/ui/button.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export interface ButtonProps {
|
||||
btnStyle?: 'black' | 'fill' | 'gray' | 'outline' | 'outline-black' | 'outline-white' | 'underline' | 'white';
|
||||
btnType?: 'button' | 'submit' | 'reset';
|
||||
click?: () => void;
|
||||
disabled?: boolean;
|
||||
download?: boolean;
|
||||
external?: boolean;
|
||||
href?: string;
|
||||
icon?: Component;
|
||||
iconRight?: Component;
|
||||
iconRightHoverDisplay?: boolean;
|
||||
// iconRightHoverAnimate?: boolean;
|
||||
size?: '12px' | '14px' | '16px' | '18px' | '20px' | '24px';
|
||||
text?: string;
|
||||
title?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user