feat(XButton): merge script blocks
This commit is contained in:
parent
c90ee0142a
commit
ba5240f6ae
@ -14,9 +14,9 @@
|
|||||||
>
|
>
|
||||||
<template v-if="icon">
|
<template v-if="icon">
|
||||||
<Icon
|
<Icon
|
||||||
v-if="showIconOnly"
|
v-if="!$slots.default"
|
||||||
:icon="icon"
|
:icon="icon"
|
||||||
:style="{'color': iconColor !== '' ? iconColor : undefined}"
|
:style="{color: iconColor}"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
v-else
|
v-else
|
||||||
@ -24,7 +24,7 @@
|
|||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
:icon="icon"
|
:icon="icon"
|
||||||
:style="{'color': iconColor !== '' ? iconColor : undefined}"
|
:style="{color: iconColor}"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
@ -32,24 +32,13 @@
|
|||||||
</BaseButton>
|
</BaseButton>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
const BUTTON_TYPES_MAP = {
|
|
||||||
primary: 'is-primary',
|
|
||||||
secondary: 'is-outlined',
|
|
||||||
tertiary: 'is-text is-inverted underline-none',
|
|
||||||
} as const
|
|
||||||
|
|
||||||
export type ButtonTypes = keyof typeof BUTTON_TYPES_MAP
|
|
||||||
|
|
||||||
export default {name: 'XButton'}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {computed, useSlots} from 'vue'
|
import {computed} from 'vue'
|
||||||
import BaseButton, {type BaseButtonProps} from '@/components/base/BaseButton.vue'
|
import BaseButton, {type BaseButtonProps} from '@/components/base/BaseButton.vue'
|
||||||
import type {IconProp} from '@fortawesome/fontawesome-svg-core'
|
import type {IconProp} from '@fortawesome/fontawesome-svg-core'
|
||||||
|
|
||||||
// extending the props of the BaseButton
|
export type ButtonTypes = keyof typeof VARIANT_CLASS_MAP
|
||||||
|
|
||||||
export interface ButtonProps extends /* @vue-ignore */ BaseButtonProps {
|
export interface ButtonProps extends /* @vue-ignore */ BaseButtonProps {
|
||||||
variant?: ButtonTypes
|
variant?: ButtonTypes
|
||||||
icon?: IconProp
|
icon?: IconProp
|
||||||
@ -59,19 +48,24 @@ export interface ButtonProps extends /* @vue-ignore */ BaseButtonProps {
|
|||||||
wrap?: boolean
|
wrap?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const props = withDefaults(defineProps<ButtonProps>(), {
|
||||||
variant = 'primary',
|
variant: 'primary',
|
||||||
icon = '',
|
icon: undefined,
|
||||||
iconColor = '',
|
iconColor: undefined,
|
||||||
loading = false,
|
loading: false,
|
||||||
shadow = true,
|
shadow: true,
|
||||||
wrap = true,
|
wrap: true,
|
||||||
} = defineProps<ButtonProps>()
|
})
|
||||||
|
|
||||||
const variantClass = computed(() => BUTTON_TYPES_MAP[variant])
|
defineOptions({name: 'XButton'})
|
||||||
|
|
||||||
const slots = useSlots()
|
const VARIANT_CLASS_MAP = {
|
||||||
const showIconOnly = computed(() => icon !== '' && typeof slots.default === 'undefined')
|
primary: 'is-primary',
|
||||||
|
secondary: 'is-outlined',
|
||||||
|
tertiary: 'is-text is-inverted underline-none',
|
||||||
|
} as const
|
||||||
|
|
||||||
|
const variantClass = computed(() => VARIANT_CLASS_MAP[props.variant])
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user