Skip to content

Commit a5fcfd8

Browse files
committed
Chore(docs): add examples wrapper and document directive
1 parent b0b8446 commit a5fcfd8

File tree

6 files changed

+46
-20
lines changed

6 files changed

+46
-20
lines changed

docs/.vuepress/client.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ export default defineClientConfig({
77
enhance({ app, router, siteData }) {
88
const registerComponent = (fileName) => app.component(
99
fileName,
10-
defineAsyncComponent(() => import((`../components/examples/${fileName}.vue`)))
10+
defineAsyncComponent(() => import(`../components/examples/${fileName}.vue`))
1111
)
1212

1313
app.use(DialogPlugin, {})
1414
registerComponent('UIExamplesButton')
15+
registerComponent('UIExamplesWrapper')
1516
registerComponent('FeaturesExampleAlert')
1617
registerComponent('FeaturesExampleConfirm')
1718
registerComponent('FeaturesExampleConfirmSoft')
1819
registerComponent('FeaturesExampleConfirmHard')
1920
registerComponent('FeaturesExamplePrompt')
21+
registerComponent('FeaturesExampleDirective')
2022
},
2123
setup() {},
2224
rootComponents: [],

docs/components/examples/FeaturesExampleConfirm.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
const $dialog = inject('$dialog')
1313
const openDialog = () => $dialog.confirm({
1414
title: 'Confirm example',
15-
body: 'The requested resource is no longer available. It may have been moved or deleted',
15+
body: 'The is a low risk operation. Single click required to confirm.',
1616
}, {
1717
cancelText: 'No',
1818
okText: 'Yes'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<template>
2+
<a href="https://example.com"
3+
target="_blank"
4+
v-confirm="'Confirming this dialog will take you to an external website'"
5+
>A link</a>
6+
<span> or a </span>
7+
<button v-confirm="'Confirm to change button text to \'Already clicked\''"
8+
@click="($event) => $event.target.textContent = 'Already clicked'"
9+
>button</button>
10+
</template>

docs/components/examples/UIExamplesButton.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
</template>
44

55
<script setup>
6-
import {ref} from 'vue'
7-
86
defineEmits({
97
click: () => true,
108
})
@@ -32,5 +30,8 @@ button {
3230
appearance: none;
3331
font-size: 16px;
3432
font-weight: 700;
33+
34+
color: white;
35+
background-color: var(--vp-c-accent);
3536
}
3637
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div class="examples-wrapper"><slot></slot></div>
3+
</template>
4+
5+
<style lang="scss">
6+
h1, h2, h3, h4 {
7+
~ .examples-wrapper {
8+
margin-top: 0.75rem;
9+
}
10+
}
11+
</style>
12+
13+
<style lang="scss">
14+
.examples-wrapper {
15+
border: 1px solid var(--vp-c-gutter);
16+
padding: 1rem;
17+
border-radius: 4px;
18+
}
19+
</style>

docs/content/features/README.md

+10-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Alert
44
An alert dialog can be triggered using the `$dialog.alert()` method. This method returns a promise which resolves when the dialog is dismissed.
55

6-
<FeaturesExampleAlert />
6+
<UIExamplesWrapper><FeaturesExampleAlert /></UIExamplesWrapper>
77
@[code](../../components/examples/FeaturesExampleAlert.vue)
88

99

@@ -14,36 +14,30 @@ In this section we shall explore how to create a basic confirm dialog as well as
1414

1515

1616
### Basic confirm dialog
17-
18-
19-
<FeaturesExampleConfirm />
17+
<UIExamplesWrapper><FeaturesExampleConfirm /></UIExamplesWrapper>
2018
@[code](../../components/examples/FeaturesExampleConfirm.vue)
2119

2220

2321
### Soft confirm dialog
24-
<FeaturesExampleConfirmSoft />
22+
<UIExamplesWrapper><FeaturesExampleConfirmSoft /></UIExamplesWrapper>
2523
@[code](../../components/examples/FeaturesExampleConfirmSoft.vue)
2624

2725

2826
### Hard confirm dialog
29-
<FeaturesExampleConfirmHard />
27+
<UIExamplesWrapper><FeaturesExampleConfirmHard /></UIExamplesWrapper>
3028
@[code](../../components/examples/FeaturesExampleConfirmHard.vue)
3129

3230

3331
## Prompt
3432
The `$dialog.prompt()` method creates a prompt dialog. Use the prompt dialog to ask user directly for input.
3533

36-
<FeaturesExamplePrompt />
34+
<UIExamplesWrapper><FeaturesExamplePrompt /></UIExamplesWrapper>
3735
@[code](../../components/examples/FeaturesExamplePrompt.vue)
3836

3937

38+
4039
## Confirm directive
41-
Sample code block
42-
```ts title=".vuepress/config.ts"
43-
this.$dialog.alert({
44-
title: 'Request failed',
45-
body: 'The requested resource is no longer available. It may have been moved or deleted',
46-
}, {
47-
okText: 'Dismiss'
48-
})
49-
```
40+
Add the `v-confirm` directive to any element to instantly cause it to trigger a confirm dialog. This dialog upon confirmation will trigger the default action or the provided callback when available.
41+
42+
<UIExamplesWrapper><FeaturesExampleDirective /></UIExamplesWrapper>
43+
@[code](../../components/examples/FeaturesExampleDirective.vue)

0 commit comments

Comments
 (0)