Skip to content

Commit 39893b3

Browse files
authored
Add docs (#16)
* add vuepress and basic doc demo * add email contacts example * add country selector example * update .vuepress/config.js * add remote example * release docs
1 parent 8766b93 commit 39893b3

36 files changed

+3508
-60
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [unreleased]
8+
79
## [0.3.0] - 2018-07-26
810
### Added
911
- disabled property control to input and prop
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<div>
3+
<div>Country:</div>
4+
<v-selectize :options="options" v-model="selected" key-by="id" label="name" :keys="['name', 'id']"/>
5+
<div>Current Value: {{ selected }}</div>
6+
</div>
7+
</template>
8+
9+
<script>
10+
import VSelectize from '@isneezy/vue-selectize'
11+
import countries from './countries'
12+
export default {
13+
name: 'country-selector',
14+
data: () => ({
15+
options: countries,
16+
selected: null
17+
}),
18+
components: {VSelectize}
19+
}
20+
</script>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<template>
2+
<div>
3+
<div>Email:</div>
4+
<v-selectize :options="options" @search="text = $event" v-model="selected" :create-item="maybeCreate()" multiple placeholder="Pick some people..." keyBy="email"
5+
label="name"
6+
keys="['name', 'email']">
7+
<template slot="item" slot-scope="{item}">{{item.name}} <{{item.email}}></template>
8+
<template slot="option" slot-scope="{option}">
9+
<label>{{ option.name }}</label>
10+
<span>{{ option.email }}</span>
11+
</template>
12+
</v-selectize>
13+
<div>Current Value: {{ selected }}</div>
14+
</div>
15+
</template>
16+
17+
<script>
18+
import VSelectize from '@isneezy/vue-selectize'
19+
20+
const REGEX_EMAIL = '([a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@' +
21+
'(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)'
22+
export default {
23+
name: 'email-contacts',
24+
data: () => ({
25+
text: '',
26+
options: [
27+
{name: 'Brian Reavis', email: '[email protected]'},
28+
{name: 'Nikola Tesla', email: '[email protected]'},
29+
{email: '[email protected]'}
30+
],
31+
selected: null
32+
}),
33+
methods: {
34+
maybeCreate () {
35+
const regex = new RegExp('^' + REGEX_EMAIL + '$', 'i')
36+
const match = this.text.match(regex)
37+
if (match) return this.createContact
38+
return false
39+
},
40+
createContact (email) {
41+
const contact = {email}
42+
this.options.push(contact)
43+
return contact
44+
}
45+
},
46+
components: {VSelectize}
47+
}
48+
</script>
49+
50+
<style scoped>
51+
label, span{
52+
display: block;
53+
}
54+
</style>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<div>
3+
<div>Tags:</div>
4+
<v-selectize :searchFn="search" :create-item="false" :options="options" v-model="selected" disableSearch>
5+
<template slot="item" slot-scope="{item}">{{item.username}}</template>
6+
</v-selectize>
7+
<div>Current Value: {{ selected }}</div>
8+
</div>
9+
</template>
10+
11+
<script>
12+
import VSelectize from '@isneezy/vue-selectize'
13+
import debounce from 'lodash.debounce'
14+
export default {
15+
name: 'remote-git-hub',
16+
data: () => ({
17+
options: [],
18+
selected: null
19+
}),
20+
methods: {
21+
search: debounce (function (text, done) {
22+
if (text.length < 3) done()
23+
fetch(`https://api.github.com/legacy/repos/search/${text}`).then(response => {
24+
return response.json()
25+
}).then(data => {
26+
this.options = data['repositories'] || []
27+
done()
28+
})
29+
}, 300)
30+
},
31+
components: {VSelectize}
32+
}
33+
</script>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div>
3+
<div>Beast:</div>
4+
<v-selectize :options="options" v-model="selected" placeholder="Select a person"/>
5+
<div>Current Value: {{ selected }}</div>
6+
</div>
7+
</template>
8+
9+
<script>
10+
import VSelectize from '@isneezy/vue-selectize'
11+
export default {
12+
name: 'single-item-select',
13+
data: () => ({
14+
options: ['Chuck Testa', 'Nikola Tesla', 'Sage Cattabriga-Alosa'],
15+
selected: []
16+
}),
17+
components: {VSelectize}
18+
}
19+
</script>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div>
3+
<div>Tags:</div>
4+
<v-selectize :options="options" v-model="selected" multiple/>
5+
<div>Current Value: {{ selected }}</div>
6+
</div>
7+
</template>
8+
9+
<script>
10+
import VSelectize from '@isneezy/vue-selectize'
11+
export default {
12+
name: 'tagging',
13+
data: () => ({
14+
options: ['neat', 'awesome'],
15+
selected: ['neat', 'awesome']
16+
}),
17+
components: {VSelectize}
18+
}
19+
</script>

0 commit comments

Comments
 (0)