Skip to content

Commit 984266c

Browse files
authored
Use VuePress docs (#55)
1 parent 5f666cf commit 984266c

File tree

12 files changed

+3240
-404
lines changed

12 files changed

+3240
-404
lines changed

.github/workflows/docs.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: docs
2+
3+
on:
4+
# trigger deployment on every push to main branch
5+
push:
6+
branches: [update-docs]
7+
# trigger deployment manually
8+
workflow_dispatch:
9+
10+
jobs:
11+
docs:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
# fetch all commits to get last updated time or other git log info
18+
fetch-depth: 0
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v3
22+
with:
23+
# choose node.js version to use
24+
node-version: 18
25+
# cache deps for pnpm
26+
cache: npm
27+
28+
# run build script
29+
- run: npm ci
30+
- run: npm run build --if-present
31+
- run: npm run docs:build
32+
33+
# please check out the docs of the workflow for more details
34+
# @see https://github.com/crazy-max/ghaction-github-pages
35+
- name: Deploy to GitHub Pages
36+
uses: crazy-max/ghaction-github-pages@v2
37+
with:
38+
# deploy to gh-pages branch
39+
target_branch: gh-pages
40+
# deploy the default output dir of VuePress
41+
build_dir: docs/.vuepress/dist
42+
env:
43+
# @see https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ demo/dist
66
test/unit/coverage
77
*.map
88
.vscode
9-
docs/
109
temp/
1110
dist/src/
11+
.temp
12+
.cache

demo/index.html

Lines changed: 0 additions & 22 deletions
This file was deleted.

demo/src/main.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/.vuepress/client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineClientConfig } from "@vuepress/client"
2+
import Demo from "../.vuepress/components/Demo.vue"
3+
import Notification from "../../dist/index.es"
4+
5+
export default defineClientConfig({
6+
enhance(context) {
7+
context.app.use(Notification);
8+
context.app.component('Demo', Demo)
9+
},
10+
})
Lines changed: 16 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<template>
2-
<div id="app">
3-
<h2>
4-
Vue.js Notification
5-
<br>
6-
<a href="https://github.com/kyvg/vue3-notification/blob/master/README.md" target="readme">Readme</a>
7-
<a href="https://github.com/kyvg/vue3-notification/" target="issues">Github</a>
8-
</h2>
2+
93
<!-- CSS animation example -->
104
<Notifications
115
group="foo-css"
@@ -14,15 +8,6 @@
148
:speed="500"
159
/>
1610

17-
<!-- Velocity animation example -->
18-
<Notifications
19-
group="foo-velocity"
20-
position="bottom right"
21-
animation-type="velocity"
22-
dangerously-set-inner-html
23-
:speed="500"
24-
/>
25-
2611
<!-- Custom style example -->
2712
<notifications
2813
group="custom-style"
@@ -105,33 +90,6 @@
10590
</button>
10691
</div>
10792

108-
<p>
109-
Velocity animation:
110-
</p>
111-
112-
<div class="block">
113-
<button
114-
class="success"
115-
@click="show('foo-velocity', 'success')"
116-
>
117-
<i class="icon ion-information-circled" />
118-
SUCCESS
119-
</button>
120-
<button
121-
class="warn"
122-
@click="show('foo-velocity', 'warn')"
123-
>
124-
<i class="icon ion-alert-circled" />
125-
WARNING
126-
</button>
127-
<button
128-
class="error"
129-
@click="show('foo-velocity', 'error')"
130-
>
131-
<i class="icon ion-close-circled" />
132-
ERROR
133-
</button>
134-
</div>
13593
<div>
13694
<p>Custom style:</p>
13795
<button @click="show('custom-style')">
@@ -151,7 +109,6 @@
151109
</button>
152110
</div>
153111
</div>
154-
</div>
155112
</template>
156113

157114
<script>
@@ -162,17 +119,6 @@ export default defineComponent({
162119
data() {
163120
return {
164121
id: 0,
165-
animation: {
166-
enter: {
167-
opacity: [1, 0],
168-
translateX: [0, -300],
169-
scale: [1, 0.2],
170-
},
171-
leave: {
172-
opacity: 0,
173-
height: 0,
174-
},
175-
},
176122
};
177123
},
178124
methods: {
@@ -202,86 +148,36 @@ export default defineComponent({
202148
</script>
203149

204150
<style lang="scss">
205-
body {
206-
font-family: 'Avenir', Helvetica, Arial, sans-serif;
207-
-webkit-font-smoothing: antialiased;
208-
-moz-osx-font-smoothing: grayscale;
209-
210-
padding: 0;
211-
padding-top: 80px;
212-
margin: 0;
213-
214-
h2 {
215-
font-weight: 300;
216-
217-
a {
218-
color: black;
219-
font-size: 12px;
220-
}
221-
}
222-
151+
.content {
223152
button {
224-
display: inline-block;
225-
box-sizing: border-box;
226-
227-
border: 0;
228-
border-radius: 3px;
229-
color: white;
230-
vertical-align: top;
231-
text-decoration: none;
232-
font-size: 12px;
233-
font-family: inherit;
234-
cursor: pointer;
235-
236-
outline: none;
237-
238-
239-
transition: all 500ms;
240-
padding: 12px;
241-
box-shadow: none;
242-
background: #02ccba;
243-
font-weight: 600;
244-
width: 100%;
245-
246-
letter-spacing: 1px;
247-
box-shadow: 0 5px 15px 0px rgba(46,61,73,0.1);
153+
border: none;
154+
border-radius: 2000px;
155+
padding: 10px 20px;
156+
color: #FFFFFF;
157+
background-color: var(--code-bg-color);
248158
249159
&.success {
250-
background: #68CD86;
160+
background: var(--c-tip);
251161
}
252162
253163
&.warn {
254-
background: #ffb648;
164+
background: var(--c-warning);
255165
}
256166
257-
&.error {
258-
background: #E54D42;
259-
}
260167
261-
&:active {
262-
opacity: 0.8;
168+
&.error {
169+
background: var(--c-danger);
263170
}
264171
}
265172
266-
#app {
267-
text-align: center;
268-
color: #2c3e50;
269173
270-
.content {
271-
margin: 0 auto;
272-
max-width: 420px;
273-
}
174+
.block {
175+
display: flex;
176+
gap: 10px;
177+
align-items: center;
178+
width: 100%;
274179
}
275180
}
276-
277-
.sub-button {
278-
display: inline-block;
279-
float: right;
280-
background: #E54D42;
281-
padding: 4px;
282-
box-shadow: 0 5px 15px 0px rgba(46, 61, 73, 0.1);
283-
}
284-
285181
/*
286182
EXAMPLES
287183
*/

docs/.vuepress/config.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { defaultTheme, defineUserConfig } from 'vuepress'
2+
3+
export default defineUserConfig({
4+
lang: 'en-US',
5+
title: 'Vue.js Notification',
6+
base: "/vue3-notification/",
7+
theme: defaultTheme({
8+
repo: "https://github.com/kyvg/vue3-notification",
9+
contributors: false,
10+
editLink: true,
11+
docsBranch: 'master',
12+
colorMode: "light",
13+
colorModeSwitch: false,
14+
navbar: [
15+
{
16+
text: "Demo",
17+
link: '/'
18+
},
19+
{
20+
text: "Get started",
21+
link: "/guide",
22+
},
23+
{
24+
text: "API Reference",
25+
link: "/api",
26+
},
27+
]
28+
}),
29+
})

docs/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
sidebar: false
3+
---
4+
5+
<h2> Vue 3 notification library 💬 </h2>
6+
7+
<demo />

docs/api/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: API Reference
3+
---
4+
5+
<h2> API Reference </h2>
6+
7+
The majority of settings for the Notifications component are configured using props:
8+
9+
```vue
10+
<notifications
11+
position="bottom right"
12+
classes="my-custom-class"
13+
:width="200"
14+
/>
15+
```
16+
17+
### Props
18+
19+
::: tip
20+
Note that all props are optional.
21+
:::
22+
23+
| Name | Type | Default | Description |
24+
| ---------------- | ------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------- |
25+
| position | String/Array | 'top right' | Part of the screen where notifications will pop out |
26+
| width | Number/String | 300 | Width of notification holder, can be `%`, `px` string or number.<br>Valid values: '100%', '200px', 200 |
27+
| classes | String/Array | 'vue-notification' | List of classes that will be applied to notification element |
28+
| group | String | null | Name of the notification holder, if specified |
29+
| duration | Number | 3000 | Time (in ms) to keep the notification on screen (if **negative** - notification will stay **forever** or until clicked) |
30+
| speed | Number | 300 | Time (in ms) to show / hide notifications |
31+
| animation-type | String | 'css' | Type of animation, currently supported types are `css` and `velocity` |
32+
| animation-name | String | null | Animation name required for `css` animation |
33+
| animation | Object | Custom | Animation configuration for Velocity animation |
34+
| max | Number | Infinity | Maximum number of notifications that can be shown in notification holder |
35+
| reverse | Boolean | false | Show notifications in reverse order |
36+
| ignoreDuplicates | Boolean | false | Ignore repeated instances of the same notification |
37+
| closeOnClick | Boolean | true | Close notification when clicked |
38+
| pauseOnHover | Boolean | false | Keep the notification open while mouse hovers on notification |
39+
| dangerouslySetInnerHtml | Boolean | false | Use [v-html](https://vuejs.org/api/built-in-directives.html#v-html) to set `title` and `text` |
40+
41+
### Events
42+
| Name | Type | Description |
43+
| ---------------- | -------------------------------- | -------------------------------------------- |
44+
| click | (item: NotificationItem) => void | The callback function that is triggered when notification was clicked
45+
| destroy | (item: NotificationItem) => void | The callback function that is triggered when notification was destroyes
46+
| start | (item: NotificationItem) => void | The callback function that is triggered when notification was appeared
47+
48+
### Plugin options
49+
50+
Configure the plugin itself using an additional options object:
51+
52+
```js
53+
app.use(Notifications, { name: "alert" });
54+
```
55+
56+
::: warning
57+
Setting `componentName` can cause issues when using SSR.
58+
:::
59+
60+
All options are optional:
61+
62+
| Name | Type | Default | Description |
63+
| ------------- | ------ |----------------|-------------------------------------------------------------------------------|
64+
| name | String | notify | Defines the instance name. It's prefixed with the dollar sign. E.g. `this.$notify` |
65+
| componentName | String | notifications | The component's name |

0 commit comments

Comments
 (0)