mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
feat(Badge): add square prop (#4008)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -26,6 +26,8 @@ export interface BadgeProps extends Omit<UseComponentIconsProps, 'loading' | 'lo
|
||||
* @defaultValue 'md'
|
||||
*/
|
||||
size?: Badge['variants']['size']
|
||||
/** Render the badge with equal padding on all sides. */
|
||||
square?: boolean
|
||||
class?: any
|
||||
ui?: Badge['slots']
|
||||
}
|
||||
@@ -50,7 +52,7 @@ import UAvatar from './Avatar.vue'
|
||||
const props = withDefaults(defineProps<BadgeProps>(), {
|
||||
as: 'span'
|
||||
})
|
||||
defineSlots<BadgeSlots>()
|
||||
const slots = defineSlots<BadgeSlots>()
|
||||
|
||||
const appConfig = useAppConfig() as Badge['AppConfig']
|
||||
const { orientation, size: buttonGroupSize } = useButtonGroup<BadgeProps>(props)
|
||||
@@ -60,6 +62,7 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.badge || {})
|
||||
color: props.color,
|
||||
variant: props.variant,
|
||||
size: buttonGroupSize.value || props.size,
|
||||
square: props.square || (!slots.default && !props.label),
|
||||
buttonGroup: orientation.value
|
||||
}))
|
||||
</script>
|
||||
|
||||
@@ -53,6 +53,9 @@ export default (options: Required<ModuleOptions>) => ({
|
||||
leadingAvatarSize: '2xs',
|
||||
trailingIcon: 'size-6'
|
||||
}
|
||||
},
|
||||
square: {
|
||||
true: ''
|
||||
}
|
||||
},
|
||||
compoundVariants: [...(options.theme.colors || []).map((color: string) => ({
|
||||
@@ -87,6 +90,26 @@ export default (options: Required<ModuleOptions>) => ({
|
||||
color: 'neutral',
|
||||
variant: 'subtle',
|
||||
class: 'ring ring-inset ring-accented text-default bg-elevated'
|
||||
}, {
|
||||
size: 'xs',
|
||||
square: true,
|
||||
class: 'p-0.5'
|
||||
}, {
|
||||
size: 'sm',
|
||||
square: true,
|
||||
class: 'p-1'
|
||||
}, {
|
||||
size: 'md',
|
||||
square: true,
|
||||
class: 'p-1'
|
||||
}, {
|
||||
size: 'lg',
|
||||
square: true,
|
||||
class: 'p-1'
|
||||
}, {
|
||||
size: 'xl',
|
||||
square: true,
|
||||
class: 'p-1'
|
||||
}],
|
||||
defaultVariants: {
|
||||
color: 'primary',
|
||||
|
||||
Reference in New Issue
Block a user