Skip to content

Commit e9c7693

Browse files
committed
feat: add NqModulesGrid component and integrate it into the theme
1 parent 1a3af9d commit e9c7693

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ sidebar: false
77
# Nimiq UI
88

99
The home for Nimiq UI development and documentation.
10+
11+
<NqModulesGrid />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { NqCardProps } from './NqCard.vue'
33
import { defineAsyncComponent } from 'vue'
44
5-
const { cards, largeCards = false } = defineProps<{ cards?: NqCardInGrid[], largeCards?: boolean }>()
5+
const { cards = [], largeCards = false } = defineProps<{ cards?: NqCardInGrid[], largeCards?: boolean }>()
66
const NqCard = defineAsyncComponent(() => import('./NqCard.vue'))
77
const NqLargeCard = defineAsyncComponent(() => import('./NqLargeCard.vue'))
88
@@ -17,7 +17,7 @@ function getSpan({ span, bgColor }: NqCardInGrid): CardSpan | undefined {
1717
</script>
1818

1919
<template>
20-
<ul grid="~ cols-6 gap-16" class="nq-grid nq-raw">
20+
<ul v-if="cards.length > 0" grid="~ cols-6 gap-16" class="nq-grid nq-raw">
2121
<slot>
2222
<li v-for="(card, index) in cards" :key="index" :data-span="getSpan(card)">
2323
<component :is="largeCards ? NqLargeCard : NqCard" v-bind="card" />
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script setup lang="ts">
2+
import type { NimiqVitepressThemeConfig } from '../types'
3+
import type { NqCardProps } from './NqCard.vue'
4+
import { useData, withBase } from 'vitepress'
5+
import { computed } from 'vue'
6+
7+
const { theme } = useData<NimiqVitepressThemeConfig>()
8+
9+
const items = computed(() => {
10+
return theme.value.modules.map(({ text, icon, href, description }) => ({
11+
title: text,
12+
icon,
13+
href: withBase(`/${href}`),
14+
description,
15+
} satisfies NqCardProps))
16+
})
17+
</script>
18+
19+
<template>
20+
<NqGrid :cards="items" />
21+
</template>

packages/nimiq-vitepress-theme/src/theme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { DefineThemeNqVpOptions } from './types'
33
import NqCard from './components/NqCard.vue'
44
import NqGrid from './components/NqGrid.vue'
55
import NqLargeCard from './components/NqLargeCard.vue'
6+
import NqModulesGrid from './components/NqModulesGrid.vue'
67
import Layout from './layout/Layout.vue'
78

89
import './assets/index.css'
@@ -17,6 +18,7 @@ export function defineNimiqThemeConfig(options: DefineThemeNqVpOptions): Theme {
1718
ctx.app.component('NqCard', NqCard)
1819
ctx.app.component('NqGrid', NqGrid)
1920
ctx.app.component('NqLargeCard', NqLargeCard)
21+
ctx.app.component('NqModulesGrid', NqModulesGrid)
2022
},
2123
}
2224
}

0 commit comments

Comments
 (0)