Skip to content

Commit b1d51e6

Browse files
committed
feat: add NqLinks component with docs
1 parent 93099a6 commit b1d51e6

File tree

2 files changed

+131
-0
lines changed
  • docs/vitepress-theme/components
  • packages/nimiq-vitepress-theme/src/components

2 files changed

+131
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Links
2+
3+
A component for displaying external links with consistent styling. Perfect for showcasing related resources, external documentation, or social media links.
4+
5+
## Props
6+
7+
| Name | Type | Default | Description |
8+
| ------- | --------------- | ----------- | --------------------------------------- |
9+
| `item` | `NqLinksItem` | `undefined` | Single link item to display |
10+
| `items` | `NqLinksItem[]` | `undefined` | Array of multiple link items to display |
11+
12+
### NqLinksItem Interface
13+
14+
| Name | Type | Default | Description |
15+
| ------- | -------- | ----------- | ---------------------------------------------- |
16+
| `label` | `string` | required | The text displayed for the link |
17+
| `href` | `string` | required | The URL the link points to |
18+
| `icon` | `string` | `undefined` | Optional icon class (e.g., `i-nimiq:external`) |
19+
| `title` | `string` | `undefined` | Optional tooltip text for accessibility |
20+
21+
All links automatically open in a new tab with `target="_blank"` and include `rel="noopener noreferrer"` for security.
22+
23+
> [!TIP]
24+
> Remember to [register `NqLinks`](/vitepress-theme/#register-the-components) in your app.
25+
26+
## Examples
27+
28+
### Single Link
29+
30+
Display a single external link with an icon.
31+
32+
<ComponentPreview lang="vue">
33+
34+
<NqPlayground>
35+
<NqLinks :item="{
36+
label: 'GitHub Repository',
37+
href: 'https://github.com/nimiq/ui',
38+
icon: 'i-nimiq:external',
39+
title: 'View source code on GitHub'
40+
}" />
41+
</NqPlayground>
42+
43+
</ComponentPreview>
44+
45+
### Multiple Links
46+
47+
Display multiple related links in a horizontal layout.
48+
49+
<ComponentPreview lang="vue">
50+
51+
<NqPlayground>
52+
<NqLinks :items="[
53+
{
54+
label: 'Documentation',
55+
href: 'https://docs.nimiq.com',
56+
icon: 'i-nimiq:book',
57+
title: 'Read the documentation'
58+
},
59+
{
60+
label: 'Discord',
61+
href: 'https://discord.gg/nimiq',
62+
icon: 'i-nimiq:chat',
63+
title: 'Join our Discord community'
64+
},
65+
{
66+
label: 'Twitter',
67+
href: 'https://twitter.com/nimiq',
68+
icon: 'i-nimiq:twitter',
69+
title: 'Follow us on Twitter'
70+
}
71+
]" />
72+
</NqPlayground>
73+
74+
</ComponentPreview>
75+
76+
### Links Without Icons
77+
78+
Simple text links without icons for minimal designs.
79+
80+
<ComponentPreview lang="vue">
81+
82+
<NqPlayground>
83+
<NqLinks :items="[
84+
{
85+
label: 'Terms of Service',
86+
href: '/terms'
87+
},
88+
{
89+
label: 'Privacy Policy',
90+
href: '/privacy'
91+
},
92+
{
93+
label: 'Contact',
94+
href: '/contact'
95+
}
96+
]" />
97+
</NqPlayground>
98+
99+
</ComponentPreview>
100+
101+
## Usage Notes
102+
103+
- Use either `item` for a single link or `items` for multiple links, not both
104+
- If both props are provided, `items` takes precedence
105+
- Links are displayed with consistent spacing using `flex="~ gap-8"`
106+
- The component uses Nimiq's pill styling (`nq-pill-secondary`) and arrow indicator (`nq-arrow`)
107+
- All links automatically include security attributes for external navigation
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup lang="ts">
2+
import { computed } from 'vue'
3+
4+
interface NqLinksItem {
5+
label: string
6+
href: string
7+
icon?: string
8+
variant: `nq-pill-${'blue' | 'gold' | 'green' | 'secondary' | 'tertiary' | 'orange'}`
9+
title?: string
10+
}
11+
12+
const props = defineProps<{ item?: NqLinksItem, items?: NqLinksItems[] }>()
13+
14+
const items = computed(() => props.items?.length ? props.items : props.item ? [props.item] : [])
15+
</script>
16+
17+
<template>
18+
<div flex="~ gap-8" class="nq-raw">
19+
<a v-for="{ label, href, icon, title = label, variant = 'nq-pill-secondary' } in items" :key="href" :href :title target="_blank" rel="noopener noreferrer" nq-arrow f-text-xs mx-0 font-semibold z-100 :class="variant">
20+
<div v-if="icon" :class="icon" mr-4 />
21+
{{ label }}
22+
</a>
23+
</div>
24+
</template>

0 commit comments

Comments
 (0)