Skip to content

Commit 3e915d3

Browse files
committed
feat: add span prop to NqCard component and update grid layout for mixed spans
1 parent 55180c3 commit 3e915d3

File tree

4 files changed

+69
-10
lines changed

4 files changed

+69
-10
lines changed

docs/vitepress-theme/components/card.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ A simple card that can turn any boring content into something that looks intenti
44

55
## Props
66

7-
| Name | Type | Default | Description |
8-
| ------------- | -------- | ----------- | ---------------------------------------------------- |
9-
| `href` | `string` | `undefined` | Where your card wants to teleport users to |
10-
| `bg-color` | `string` | `undefined` | The mood lighting for your card |
11-
| `icon` | `string` | `undefined` | The tiny picture that makes your card feel important |
12-
| `title` | `string` | `undefined` | The card's title |
13-
| `description` | `string` | `undefined` | The card's description |
14-
| `label` | `string` | `undefined` | Optional label displayed above the title |
7+
| Name | Type | Default | Description |
8+
| ------------- | ----------------------------- | ----------- | ---------------------------------------------------- |
9+
| `href` | `string` | `undefined` | Where your card wants to teleport users to |
10+
| `bg-color` | `string` | `undefined` | The mood lighting for your card |
11+
| `icon` | `string` | `undefined` | The tiny picture that makes your card feel important |
12+
| `title` | `string` | `undefined` | The card's title |
13+
| `description` | `string` | `undefined` | The card's description |
14+
| `label` | `string` | `undefined` | Optional label displayed above the title |
15+
| `span` | `'full' \| 'half' \| 'default'` | `undefined` | Controls how many columns the card spans in a grid |
1516

1617
The component also supports using slots for custom content instead of props.
1718

docs/vitepress-theme/components/grid.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,52 @@ cards:
131131
</NqGrid>
132132

133133
</ComponentPreview>
134+
135+
## Grid with Mixed Spans
136+
137+
<ComponentPreview>
138+
139+
<NqGrid>
140+
141+
<NqCard
142+
span="full"
143+
bg-color="blue"
144+
icon="i-nimiq:icons-lg-browsermesh"
145+
title="Full Width Feature"
146+
description="I'm a special card that spans the entire width of the grid. Perfect for featured content or important announcements!"
147+
/>
148+
149+
<NqCard
150+
span="half"
151+
bg-color="green"
152+
icon="i-nimiq:tools"
153+
title="Half Width Card"
154+
description="I take up half the grid width, making me stand out more than standard cards."
155+
/>
156+
157+
<NqCard
158+
span="half"
159+
bg-color="orange"
160+
icon="i-nimiq:fire"
161+
title="Another Half"
162+
description="Together with my friend, we make a perfect pair across the row."
163+
/>
164+
165+
<NqCard
166+
title="Regular Card"
167+
description="I'm a standard card, happy with my default width."
168+
/>
169+
170+
<NqCard
171+
title="Another Regular"
172+
description="Me too! Default width is cozy."
173+
/>
174+
175+
<NqCard
176+
title="Last But Not Least"
177+
description="Completing this mixed layout showcase."
178+
/>
179+
180+
</NqGrid>
181+
182+
</ComponentPreview>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { computed } from 'vue';
33
44
export type CardColor = 'green' | 'blue' | 'red' | 'gold' | 'orange'
55
6-
const { bgColor, icon, href } = defineProps<{
6+
const { bgColor, icon, href, span } = defineProps<{
77
icon?: string
88
bgColor?: CardColor
99
href?: string
1010
title?: string
1111
description?: string
1212
label?: string
13+
span?: 'full' | 'half' | 'default'
1314
}>()
1415
1516
const hasLink = computed(() => !!href)
@@ -18,7 +19,7 @@ const colors: Partial<Record<CardColor, string>> = { blue: '#0E65C9', green: '#1
1819
</script>
1920

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

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ const {cards} = defineProps<{
3232
--uno: 'col-span-2';
3333
}
3434
35+
:global(.nq-grid [data-card][data-span="full"]) {
36+
--uno: 'col-span-6';
37+
}
38+
39+
:global(.nq-grid [data-card][data-span="half"]) {
40+
--uno: 'col-span-3';
41+
}
42+
3543
:global(.nq-grid [data-card]) {
3644
--uno: 'mt-0';
3745
}

0 commit comments

Comments
 (0)