Skip to content

Commit b8ff553

Browse files
committed
docs: add code-example component
1 parent 2eec95e commit b8ff553

File tree

6 files changed

+93
-25
lines changed

6 files changed

+93
-25
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {
2121
"@vue-js-cron/core": "2.0.0",
22-
"@vue-js-cron/light": "^1.0.0",
22+
"@vue-js-cron/light": "^1.0.1",
2323
"@vue-js-cron/vuetify": "2.0.0"
2424
}
2525
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<template>
2+
<v-app>
3+
4+
<v-card class="code-example">
5+
<v-toolbar dense class="elevation-1">
6+
<v-toolbar-title v-if="title">{{title}}</v-toolbar-title>
7+
8+
<v-spacer></v-spacer>
9+
10+
<v-tooltip bottom>
11+
<template #activator="{attrs, on}">
12+
<v-btn v-bind="attrs" v-on="on" icon @click="viewSource = !viewSource">
13+
<v-icon>mdi-code-tags</v-icon>
14+
</v-btn>
15+
</template>
16+
<span>View source</span>
17+
</v-tooltip>
18+
19+
</v-toolbar>
20+
21+
<v-expand-transition>
22+
<div v-show="viewSource" class="source">
23+
<slot name="source"></slot>
24+
</div>
25+
</v-expand-transition>
26+
27+
<v-card-text>
28+
<slot></slot>
29+
</v-card-text>
30+
</v-card>
31+
32+
<v-card-text>
33+
34+
</v-card-text>
35+
<slot name="code"></slot>
36+
37+
</v-app>
38+
</template>
39+
40+
<script>
41+
export default {
42+
props: {
43+
title: {
44+
type: String,
45+
default: ''
46+
}
47+
},
48+
data() {
49+
return {
50+
viewSource: false
51+
}
52+
},
53+
}
54+
</script>
55+
56+
<style>
57+
.code-example pre {
58+
margin: 0 !important;
59+
}
60+
.code-example .source {
61+
margin: 0.2em;
62+
}
63+
.code-example {
64+
overflow-wrap: unset;
65+
}
66+
67+
</style>
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="getting-started-light">
3-
<div>{{value}}</div>
3+
<div class="mb-2">{{value}}</div>
44
<CronLight v-model="value" @error="error=$event"></CronLight>
55
</div>
66
</template>
@@ -18,12 +18,3 @@ export default {
1818
}
1919
}
2020
</script>
21-
22-
<style scoped>
23-
24-
.getting-started-light > div {
25-
margin-top: 10px;
26-
margin-bottom: 6px;
27-
}
28-
29-
</style>

docs/src/.vuepress/components/getting-started-renderless.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<!-- period selection -->
1919
<v-col v-if="period.prefix" class="flex-grow-0">{{period.prefix}}</v-col>
2020
<v-col cols="auto">
21-
<v-select class="fit" v-bind="period.attrs" :items="period.items" @input="period.events.input" return-object dense :menu-props="{'offset-y': true}"></v-select>
21+
<v-select class="fit" v-bind="period.attrs" :items="period.items" @input="period.events.input" item-value="id" dense :menu-props="{'offset-y': true}"></v-select>
2222
</v-col>
2323
<v-col v-if="period.suffix" class="flex-grow-0">{{period.suffix}}</v-col>
2424

docs/src/guide/custom-periods.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Custom Periods
22

3-
## Code
3+
<code-example>
4+
<template v-slot:source>
45

56
<<< @/src/.vuepress/components/custom-periods.vue
67

7-
## Result
8-
9-
<custom-periods />
8+
</template>
9+
<custom-periods />
10+
</code-example>

docs/src/guide/getting-started.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ Vue.use(cronLight)
3333

3434
Now you can use the component `CronLight`.
3535

36-
#### Code
36+
<br />
3737

38-
<<< @/src/.vuepress/components/getting-started-light.vue
38+
<code-example title="CronLight example">
39+
<template v-slot:source>
3940

40-
#### Result
41+
<<< @/src/.vuepress/components/getting-started-light.vue
4142

43+
</template>
4244
<getting-started-light />
45+
</code-example>
4346

4447
#### API
4548

@@ -71,13 +74,16 @@ Vue.use(cronVuetify)
7174

7275
Now you can use the component `CronVuetify`.
7376

74-
#### Code
77+
<br />
7578

76-
<<< @/src/.vuepress/components/getting-started-vuetify.vue
79+
<code-example title="CronVuetify example">
80+
<template v-slot:source>
7781

78-
#### Result
82+
<<< @/src/.vuepress/components/getting-started-vuetify.vue
7983

84+
</template>
8085
<getting-started-vuetify />
86+
</code-example>
8187

8288
#### API
8389

@@ -116,13 +122,16 @@ Now you can use the component `CronCore`. The default [scoped slot](https://vuej
116122
- `period` - defines which fields are visible
117123
- `error` - error message
118124

119-
#### Code
125+
<br />
120126

121-
<<< @/src/.vuepress/components/getting-started-renderless.vue
127+
<code-example title="CronCore example">
128+
<template v-slot:source>
122129

123-
#### Result
130+
<<< @/src/.vuepress/components/getting-started-renderless.vue
124131

132+
</template>
125133
<getting-started-renderless />
134+
</code-example>
126135

127136
#### API
128137

0 commit comments

Comments
 (0)