Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 812bc24

Browse files
committed
docs(breadcrumb): write tests for teh breadcrumb component
1 parent 4e535ef commit 812bc24

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

docs/.vitepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function getSetupSidebar() {
5454
children: [
5555
{ text: 'Alert', link: '/components/alert' },
5656
{ text: 'Badge', link: '/components/badge' },
57+
{ text: 'Breadcrumb', link: '/components/breadcrumb' },
5758
{ text: 'Button', link: '/components/button' },
5859
{ text: 'Code', link: '/components/code' },
5960
{ text: 'Icon', link: '/components/icon' },

docs/components/breadcrumb.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Breadcrumb
2+
3+
Breadcrumbs help users visualize their current location in relation to the rest of the website or application by showing the hierarchy of pages
4+
5+
## Installation
6+
7+
```sh
8+
yarn add @chakra-ui/c-breadcrumb
9+
# or
10+
npm i @chakra-ui/c-breadcrumb
11+
```
12+
13+
14+
## Import components
15+
16+
Chakra UI Vue exports 3 breadcrumb related components:
17+
18+
- `CBreadcrumb`: The parent container for breadcrumbs.
19+
- `CBreadcrumbItem`: Individual breadcrumb element containing a link and a
20+
divider.
21+
- `CBreadcrumbLink`: The breadcrumb link.
22+
23+
```js
24+
import { CBreadcrumb, CBreadcrumbItem, CBreadcrumbLink } from "@chakra-ui/vue-next"
25+
```
26+
27+
## Usage
28+
29+
Add `isCurrentPage` prop to the `CBreadcrumbItem` that matches the current path.
30+
When this prop is present, the `CBreadcrumbItem` doesn't have a separator, and
31+
the `CBreadcrumbLink` has `aria-current` set to `page`.
32+
33+
```html
34+
<c-breadcrumb>
35+
<c-breadcrumb-item>
36+
<c-breadcrumb-link href="#">Home</c-breadcrumb-link>
37+
</c-breadcrumb-item>
38+
39+
<c-breadcrumb-item>
40+
<c-breadcrumb-link as="router-link" to="/docs">Docs</c-breadcrumb-link>
41+
</c-breadcrumb-item>
42+
43+
<c-breadcrumb-item isCurrentPage>
44+
<c-breadcrumb-link>Help</c-breadcrumb-link>
45+
</c-breadcrumb-item>
46+
</c-breadcrumb>
47+
```
48+
49+
### Separators
50+
51+
Change the separator used in the breadcrumb by passing a string, like `-` element.
52+
53+
```html
54+
<c-breadcrumb separator="-">
55+
<c-breadcrumb-item>
56+
<c-breadcrumb-link href="#">Home</c-breadcrumb-link>
57+
</c-breadcrumb-item>
58+
59+
<c-breadcrumb-item>
60+
<c-breadcrumb-link as="router-link" to="/docs">Docs</c-breadcrumb-link>
61+
</c-breadcrumb-item>
62+
63+
<c-breadcrumb-item isCurrentPage>
64+
<c-breadcrumb-link>Help</c-breadcrumb-link>
65+
</c-breadcrumb-item>
66+
</c-breadcrumb>
67+
```
68+
### Using the separator slot
69+
70+
You can override the rendered spearator by using the `v-slot:separator` which will render any component you want as the separator for the `CBreadcrumb` component
71+
72+
```html
73+
<c-breadcrumb>
74+
<template v-slot:separator>
75+
<c-icon name="chevron-right" />
76+
</template>
77+
<c-breadcrumb-item>
78+
<c-breadcrumb-link as="router-link" to="/">Home</c-breadcrumb-link>
79+
</c-breadcrumb-item>
80+
<c-breadcrumb-item>
81+
<c-breadcrumb-link href="#">Docs</c-breadcrumb-link>
82+
</c-breadcrumb-item>
83+
<c-breadcrumb-item is-current-page>
84+
<c-breadcrumb-link href="#">About</c-breadcrumb-link>
85+
</c-breadcrumb-item>
86+
</c-breadcrumb>
87+
```
88+
### Using a functional icon component as the separator
89+
90+
You can also pass a functional component into the `:separator` prop
91+
92+
```html
93+
94+
<template>
95+
<c-breadcrumb :separator="SunIcon">
96+
<c-breadcrumb-item>
97+
<c-breadcrumb-link as="router-link" to="/">Home</c-breadcrumb-link>
98+
</c-breadcrumb-item>
99+
<c-breadcrumb-item>
100+
<c-breadcrumb-link href="#">Docs</c-breadcrumb-link>
101+
</c-breadcrumb-item>
102+
<c-breadcrumb-item is-current-page>
103+
<c-breadcrumb-link href="#">About</c-breadcrumb-link>
104+
</c-breadcrumb-item>
105+
</c-breadcrumb>
106+
</template>
107+
108+
<script setup>
109+
const SunIcon = () => {
110+
return h(CIcon, {
111+
name: 'sun',
112+
})
113+
}
114+
</script>
115+
116+
```
117+
118+
::: tip
119+
When cusomizing the breadcrumb separator with a component like a custom icon, It is recommended to use the `v-slot:separator` slot as compared to the `:separator` prop.
120+
:::

0 commit comments

Comments
 (0)