Skip to content

Commit 2b6283d

Browse files
committed
docs: Update setup and usage component
1 parent 526d0f9 commit 2b6283d

File tree

10 files changed

+58
-31
lines changed

10 files changed

+58
-31
lines changed

docs/guide/README.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Setup
22

33
## Installation
4-
54
Add `@vue-a11y/dark-mode` in your Vue project.
65

76
### NPM
@@ -14,7 +13,11 @@ npm install @vue-a11y/dark-mode
1413
yarn add @vue-a11y/dark-mode
1514
```
1615

17-
## Basic usage
16+
## Usage
17+
18+
### Globally
19+
20+
You can use it globally in your main.js
1821

1922
```javascript
2023
import Vue from 'vue'
@@ -23,12 +26,36 @@ import VueDarkMode from '@vue-a11y/dark-mode'
2326
Vue.use(VueDarkMode)
2427
```
2528

29+
### Locally
30+
31+
You can import into your component:
32+
33+
```javascript
34+
import { DarkMode } from '@vue-a11y/dark-mode'
35+
36+
export default {
37+
// ...
38+
components: {
39+
DarkMode
40+
}
41+
}
42+
```
43+
44+
### Single file component
45+
<br>
46+
2647
```vue
27-
<VueDarkMode>
28-
<template v-slot="{ mode }">
29-
Color mode: {{ mode }}
30-
</template>
31-
</VueDarkMode>
48+
<template>
49+
<DarkMode>
50+
<template v-slot="{ mode }">
51+
Color mode: {{ mode }}
52+
</template>
53+
</DarkMode>
54+
</template>
55+
56+
<script>
57+
// ...
58+
</script>
3259
3360
<style>
3461
:root {

docs/guide/accessibility.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ After changing the color mode, the message will be changed in the element with `
3535
### Example (spanish)
3636

3737
```vue
38-
<VueDarkMode
38+
<DarkMode
3939
ariaLabel="Cambiar al modo de color %cm"
4040
ariaLive="Se eligió el modo de color %cm"
4141
>
4242
<template v-slot="{ mode }">
4343
Modo de color: {{ mode }}
4444
</template>
45-
</VueDarkMode>
45+
</DarkMode>
4646
```
4747

4848
**Output:**

docs/guide/class-naming.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ You can also customize the class name.
2727
**e.g.**
2828

2929
```vue
30-
<VueDarkMode className="%cm-theme">
30+
<DarkMode className="%cm-theme">
3131
<template v-slot="{ mode }">
3232
Color mode: {{ mode }}
3333
</template>
34-
</VueDarkMode>
34+
</DarkMode>
3535
```
3636

3737
**Output:**

docs/guide/events.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Event fired every color mode change.
1010
| `change-mode` | color mode token. (`light` \| `dark` \| `system` \| `myCustomMode`) |
1111

1212
```vue
13-
<VueDarkMode @change-mode="myColorModeHandler">
13+
<DarkMode @change-mode="myColorModeHandler">
1414
<template v-slot="{ mode }">
1515
Color mode: {{ mode }}
1616
</template>
17-
</VueDarkMode>
17+
</DarkMode>
1818
```
1919

2020
```js

docs/guide/examples.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
## Simple button
44

55
```vue
6-
<vue-dark-mode>
6+
<DarkMode>
77
<template v-slot="{ mode }">
88
Color mode: {{ mode }}
99
</template>
10-
</vue-dark-mode>
10+
</DarkMode>
1111
```
1212

1313
**Output**
1414

1515
<div style="padding: 10px;background-color: var(--bg-secondary);">
1616
<ClientOnly>
17-
<vue-dark-mode style="padding: 8px 12px;border: 1px solid var(--border-color);">
17+
<DarkMode style="padding: 8px 12px;border: 1px solid var(--border-color);">
1818
<template v-slot="{ mode }">
1919
Color mode: {{ mode }}
2020
</template>
21-
</vue-dark-mode>
21+
</DarkMode>
2222
</ClientOnly>
2323
</div>
2424

@@ -29,26 +29,26 @@
2929
## Icon Toggle button
3030

3131
```vue
32-
<vue-dark-mode>
32+
<DarkMode>
3333
<template v-slot="{ mode }">
3434
<MyLightIcon v-show="mode === 'light'">
3535
<MyDarkIcon v-show="mode === 'dark'">
3636
<MySystemIcon v-show="mode === 'system'">
3737
</template>
38-
</vue-dark-mode>
38+
</DarkMode>
3939
```
4040

4141
**Output**
4242

4343
<div style="padding: 10px;background-color: var(--bg-secondary);">
4444
<ClientOnly>
45-
<vue-dark-mode style="padding: 10px 14px;">
45+
<DarkMode style="padding: 10px 14px;">
4646
<template v-slot="{ mode }">
4747
<svg v-show="mode === 'dark'" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
4848
<svg v-show="mode === 'light'" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
4949
<svg v-show="mode === 'system'" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"></rect><line x1="8" y1="21" x2="16" y2="21"></line><line x1="12" y1="17" x2="12" y2="21"></line></svg>
5050
</template>
51-
</vue-dark-mode>
51+
</DarkMode>
5252
</ClientOnly>
5353
</div>
5454

docs/guide/meta-theme-color.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Since `system` assumes light or dark, then you do not need to define theme-color
1414
:::
1515

1616
```vue
17-
<VueDarkMode
17+
<DarkMode
1818
:metaThemeColor="{
1919
light: '#f2f2f2 ',
2020
dark: '#232b32',
@@ -29,5 +29,5 @@ Since `system` assumes light or dark, then you do not need to define theme-color
2929
<template v-slot="{ mode }">
3030
Color mode: {{ mode }}
3131
</template>
32-
</VueDarkMode>
32+
</DarkMode>
3333
```

docs/guide/modes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Both props are optional, if not declared in the component, default values will b
3333
:::
3434

3535
```vue
36-
<VueDarkMode
36+
<DarkMode
3737
defaultMode="sepia"
3838
:modes="[
3939
'light',
@@ -45,6 +45,6 @@ Both props are optional, if not declared in the component, default values will b
4545
<template v-slot="{ mode }">
4646
Color mode: {{ mode }}
4747
</template>
48-
</VueDarkMode>
48+
</DarkMode>
4949
```
5050

docs/guide/storage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ By default the `@vue-a11y/dark-mode` component use **localStorage** to store the
77
| `storage` | String | `localStorage` | `localStorage` or `sessionStorage`
88

99
```vue
10-
<VueDarkMode storage="sessionStorage">
10+
<DarkMode storage="sessionStorage">
1111
<template v-slot="{ mode }">
1212
Color mode: {{ mode }}
1313
</template>
14-
</VueDarkMode>
14+
</DarkMode>
1515
```
1616

1717
::: tip

docs/howto/tailwind.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ It is possible to [changing the Selector](https://github.com/ChanceArthur/tailwi
77
**e.g.**
88

99
```vue
10-
<VueDarkMode className="mode-%cm">
10+
<DarkMode className="mode-%cm">
1111
<template v-slot="{ mode }">
1212
Color mode: {{ mode }}
1313
</template>
14-
</VueDarkMode>
14+
</DarkMode>
1515
```
1616

1717

docs/howto/vuepress.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ VuePress applications are rendered by the server in Node.js when generating stat
2020

2121
```vue
2222
<ClientOnly>
23-
<VueDarkMode>
23+
<DarkMode>
2424
<template v-slot="{ mode }">
2525
Color mode: <span>{{ mode }}</span>
2626
</template>
27-
</VueDarkMode>
27+
</DarkMode>
2828
</ClientOnly>
2929
```

0 commit comments

Comments
 (0)