diff --git a/app.config.ts b/app.config.ts index 28be0c1..aa78161 100644 --- a/app.config.ts +++ b/app.config.ts @@ -28,6 +28,9 @@ export default defineAppConfig({ loadingIcon: 'material-symbols:sync-rounded', }, }, + badge: { + rounded: 'rounded-button', + }, input: { default: { loadingIcon: 'material-symbols:sync-rounded', diff --git a/components/BlockContainer.vue b/components/BlockContainer.vue index 7e18efc..e15967f 100644 --- a/components/BlockContainer.vue +++ b/components/BlockContainer.vue @@ -8,7 +8,7 @@ withDefaults(defineProps(), { }); diff --git a/components/Category.vue b/components/Category.vue index 3b09a7c..c19261c 100644 --- a/components/Category.vue +++ b/components/Category.vue @@ -26,18 +26,32 @@ const colorChoices = [ 'yellow', ]; -function randomBackgroundColor(seed, colors) { +function randomBackgroundColor(seed: number, colors: string[]) { return colors[seed % colors.length]; } const badgeColor = computed(() => { - return props.color || randomBackgroundColor(slots.default()[0].children.length, colorChoices); + if (props.color) return props.color; + + const defaultSlot = slots.default ? slots.default()[0] : undefined; + + if (!defaultSlot || !defaultSlot?.children) return null; + + return randomBackgroundColor(defaultSlot?.children.length as number, colorChoices); +}); + +const styleProp = computed(() => { + if (!props.color) return undefined; + return { + backgroundColor: props.color, + color: getContrastColor(props.color), + }; });