Skip to content

Commit

Permalink
Datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Jul 13, 2016
0 parents commit 529c926
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "vue-bulma-datepicker",
"version": "1.0.0",
"description": "Datepicker Component for Vue Bulma",
"main": "src/Datepicker.vue",
"devDependencies": {
"bulma": "^0.1.0",
"vue": "^1.0.26"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "git+https://github.com/vue-bulma/datepicker.git",
"keywords": [
"vue",
"bulma",
"vue-bulma",
"vue-bulma-component",
"vue-bulma-datepicker",
"datepicker"
],
"author": "Fangdun Cai <[email protected]>",
"license": "MIT",
"dependencies": {
"flatpickr": "github:chmln/flatpickr#gh-pages"
}
}
10 changes: 10 additions & 0 deletions src/Datepicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { init as Flatpickr } from 'flatpickr'

function Datepicker (selector, config, l10n) {
this.l10n = Object.assign({}, Flatpickr.prototype.l10n, l10n)
return Flatpickr.call(this, selector, config)
}

Datepicker.prototype = Flatpickr.prototype

export default Datepicker
76 changes: 76 additions & 0 deletions src/Datepicker.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<template>
<partial :name="name">
<slot></slot>
</partial>
</template>

<script>
import Datepicker from './Datepicker.js'
export default {
partials: {
singleInput: require('./datepicker/singleInput.html'),
wrapperInput: require('./datepicker/wrapperInput.html')
},
props: {
alignment: String,
config: {
type: Object,
default () {
return {}
}
},
l10n: {
type: Object,
default () {
return {}
}
},
placeholder: {
type: String,
default: 'Pick date'
},
readonly: Boolean,
value: String
},
ready () {
this.datepicker = new Datepicker(this.$el.nextSibling, this.config, this.l10n)
this.datepicker.set('onChange', (d, s) => {
this.$set('value', s)
})
},
beforeDestroy () {
this.datepicker.destroy()
},
computed: {
wrap () {
return !!this.config.wrap
},
name () {
return this.wrap ? 'wrapperInput' : 'singleInput'
}
}
}
</script>

<style lang="stylus">
$calendar_background = #ffffff
$calendar_border_color = #d3d6db
$months_color = #111
$months_background = transparent
$weekdays_background = transparent
$day_text_color = #222324
$day_hover_background_color = #d3d6db
$today_color = #ed6c63
$selected_day_background = #1fc8db
@import '~flatpickr/src/style/flatpickr_base'
</style>
1 change: 1 addition & 0 deletions src/singleInput.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<input class="input" type="text" :placeholder="placeholder" :readonly="readonly" v-model="value"/>
4 changes: 4 additions & 0 deletions src/wrapperInput.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p class="control has-addons flatpickr" data-wrap="true" data-clickOpens="false" :class="{ [`has-addons-${alignment}`]: alignment }">
<input class="input" type="text" :placeholder="placeholder" :readonly="readonly" v-model="value" data-input/>
<slot></slot>
</p>

0 comments on commit 529c926

Please sign in to comment.