| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <div id="app">
- <img src="./assets/logo.png">
- <h3>Vue Monthly Picker</h3>
- <div class="demo-component">
- <vue-monthly-picker
- :inputClass="{'input': isDisplayInput}"
- :disabled="isDisable"
- :monthLabels="locale"
- :clearOption="clearOption"
- :min="min"
- :max="max"
- @selected="handleSelect"
- v-model="selectedMonth"
- :alignment="alignment"
- :selectedBackgroundColor="selectedBackgroundColor">
- </vue-monthly-picker>
- </div>
- <div class="columns option-list">
- <div class="column is-3">
- <b-field label="Disabled" expanded>
- <b-checkbox v-model="isDisable">
- {{ isDisable ? 'Disabled': 'Enable'}}
- </b-checkbox>
- </b-field>
- </div>
- <div class="column is-3">
- <b-field label="Range" expanded>
- <b-checkbox v-model="isLimitRange">
- {{ rangeDisplay }}
- </b-checkbox>
- </b-field>
- </div>
- <div class="column is-3">
- <b-field label="Display" expanded position="is-centered">
- <b-switch v-model="isDisplayInput"
- true-value="Input"
- false-value="Label">
- {{ isDisplayInput? 'Input': 'Label' }}
- </b-switch>
- </b-field>
- </div>
- <div class="column is-3">
- <b-field label="Clear icon" expanded>
- <b-checkbox v-model="clearOption">
- {{ clearOption ? 'Enable': 'Disabled'}}
- </b-checkbox>
- </b-field>
- </div>
- </div>
- <div class="columns">
- <div class="column is-4">
- <b-field label="Localization" expanded>
- <b-select placeholder="Select a language" v-model="locale">
- <option
- v-for="option in options"
- :value="option.monthLabels"
- :key="option.id">
- {{ option.title }}
- </option>
- </b-select>
- </b-field>
- </div>
- <div class="column is-4">
- <b-field label="Alignment" expanded>
- <b-select placeholder="Select an alignment" v-model="alignment">
- <option
- v-for="alignment in alignments"
- :value="alignment"
- :key="alignment">
- {{ alignment }}
- </option>
- </b-select>
- </b-field>
- </div>
- <div class="column is-4">
- <b-field label="Selected background color" expanded>
- <b-select placeholder="Select an color" v-model="selectedBackgroundColor">
- <option
- v-for="color in colorExamples"
- :value="color"
- :key="color">
- {{ color }}
- </option>
- </b-select>
- </b-field>
- </div>
- </div>
- </div>
- </template>
- <script>
- import moment from 'moment'
- import VueMonthlyPicker from './lib'
- export default {
- name: 'app',
- data () {
- return {
- selectedMonth: moment(),
- isDisable: false,
- isDisplayInput: true,
- locale: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
- alignment: 'left',
- selectedBackgroundColor: 'blue',
- options: [
- {
- id: 1,
- title: 'English',
- monthLabels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
- },
- {
- id: 2,
- title: 'Japanese',
- monthLabels: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
- },
- {
- id: 3,
- title: 'Korean',
- monthLabels: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']
- }
- ],
- alignments: ['left', 'center', 'right'],
- colorExamples: ['blue', 'red', 'black'],
- min: null,
- max: null,
- isLimitRange: false,
- clearOption: true
- }
- },
- computed: {
- rangeDisplay () {
- if (!this.min || !this.max) {
- return 'Disabled'
- }
- return this.min.format('YYYY/MM') + '-' + this.max.format('YYYY/MM')
- }
- },
- watch: {
- isLimitRange (newValue) {
- if (newValue) {
- this.setSelectRange(moment().subtract(6, 'months'), moment().add(6, 'months'))
- } else {
- this.setSelectRange(null, null)
- }
- }
- },
- methods: {
- handleSelect (value) {
- console.log('Select', value)
- },
- setSelectRange (min, max) {
- this.min = min
- this.max = max
- }
- },
- components: {
- VueMonthlyPicker
- }
- }
- </script>
- <style>
- #app {
- font-family: 'Avenir', Helvetica, Arial, sans-serif;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- text-align: center;
- color: #2c3e50;
- margin-top: 60px;
- }
- .demo-component {
- width: 250px;
- margin: auto;
- }
- .control-group {
- margin-top: 100px;
- }
- .control {
- text-align: center;
- }
- .option-list {
- margin-top: 20px;
- }
- </style>
|