Skip to content

Commit

Permalink
enh: add possibility to define previous/next date icons in pickers (#…
Browse files Browse the repository at this point in the history
…2709)

* enh: add possibility to define previous/next date icons in pickers

fixes #2123

* changed prop names
  • Loading branch information
jacekkarczmarczyk authored and johnleider committed Dec 8, 2017
1 parent 164feb5 commit 51e59e2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/components/VDatePicker/VDatePicker.date.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,17 @@ test('VDatePicker.js', ({ mount, compileToFunctions }) => {
wrapper.setProps({ type: 'date' })
expect(wrapper.vm.activePicker).toBe('YEAR')
})

it('should use prev and next icons', () => {
const wrapper = mount(VDatePicker, {
propsData: {
prependIcon: 'block',
appendIcon: 'check'
}
})

const icons = wrapper.find('.picker--date__header-selector .icon')
expect(icons[0].element.textContent).toBe('block')
expect(icons[1].element.textContent).toBe('check')
})
})
8 changes: 8 additions & 0 deletions src/components/VDatePicker/VDatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export default {
type: [Array, Object, Function],
default: () => (null)
},
appendIcon: {
type: String,
default: 'chevron_right'
},
// Function formatting the day in date picker table
dayFormat: {
type: Function,
Expand All @@ -74,6 +78,10 @@ export default {
type: Function,
default: null
},
prependIcon: {
type: String,
default: 'chevron_left'
},
// Function formatting currently selected date in the picker title
titleDateFormat: {
type: Function,
Expand Down
14 changes: 14 additions & 0 deletions src/components/VDatePicker/VDatePicker.month.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,18 @@ test('VDatePicker.js', ({ mount, compileToFunctions }) => {
wrapper.setProps({ type: 'year' })
expect(wrapper.vm.activePicker).toBe('YEAR')
})

it('should use prev and next icons', () => {
const wrapper = mount(VDatePicker, {
propsData: {
type: 'month',
prependIcon: 'block',
appendIcon: 'check'
}
})

const icons = wrapper.find('.picker--date__header-selector .icon')
expect(icons[0].element.textContent).toBe('block')
expect(icons[1].element.textContent).toBe('check')
})
})
4 changes: 2 additions & 2 deletions src/components/VDatePicker/mixins/date-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export default {
'class': 'picker--date__header-selector'
}, [
this.genBtn(keyValue - 1, [
this.$createElement('v-icon', 'chevron_left')
this.$createElement('v-icon', this.prependIcon)
]),
this.genHeader(keyValue, selectorText),
this.genBtn(keyValue + 1, [
this.$createElement('v-icon', 'chevron_right')
this.$createElement('v-icon', this.appendIcon)
])
])
}
Expand Down

0 comments on commit 51e59e2

Please sign in to comment.