Skip to content

Commit 0f84478

Browse files
committed
feat: add CardSpan type and update span handling in NqCard component
1 parent a45d5b9 commit 0f84478

File tree

1 file changed

+8
-2
lines changed
  • packages/nimiq-vitepress-theme/src/components

1 file changed

+8
-2
lines changed

packages/nimiq-vitepress-theme/src/components/NqCard.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { computed } from 'vue'
33
44
export type CardColor = 'green' | 'blue' | 'red' | 'gold' | 'orange'
5+
export type CardSpan = 'full' | 'half' | 'default'
56
67
const { bgColor, icon, href, span } = defineProps<{
78
icon?: string
@@ -10,17 +11,22 @@ const { bgColor, icon, href, span } = defineProps<{
1011
title?: string
1112
description?: string
1213
label?: string
13-
span?: 'full' | 'half' | 'default'
14+
span?: CardSpan
1415
}>()
1516
1617
const hasLink = computed(() => !!href)
1718
1819
const colors: Partial<Record<CardColor, string>> = { blue: '#0E65C9', green: '#1DA186', gold: '#ffffffaa' }
20+
21+
function getSpan(): CardSpan | undefined {
22+
if (span === undefined && bgColor) return 'half'
23+
return span
24+
}
1925
</script>
2026

2127
<template>
2228
<component
23-
:is="hasLink ? 'a' : 'div'" :href group :data-span="span" :data-inverted="bgColor ? '' : undefined" class="nq-raw"
29+
:is="hasLink ? 'a' : 'div'" :href group :data-span="getSpan()" :data-inverted="bgColor ? '' : undefined" class="nq-raw"
2430
f-mt-md relative :style="`background-image: ${bgColor ? `var(--nq-${bgColor}-gradient)` : ''}`" :data-card="bgColor ? 'colored' : 'default'"
2531
:target="hasLink && href?.startsWith('http') ? '_blank' : undefined"
2632
:class="{ 'nq-hoverable': hasLink, 'nq-card': !hasLink, 'children:max-w-[max(50%,240px)]': bgColor, 'bg-neutral-300': !bgColor }"

0 commit comments

Comments
 (0)