UNPKG

1.97 kBTypeScriptView Raw
1import { Component, Prop, Vue } from 'vue-property-decorator'
2import { Mark, Styles } from './typings'
3
4import './styles/mark.scss'
5
6@Component({ name: 'VueSlideMark' })
7export default class VueSlideMark extends Vue {
8 @Prop({ required: true })
9 mark!: Mark
10
11 @Prop(Boolean) hideLabel?: boolean
12
13 @Prop() stepStyle?: Styles
14
15 @Prop() stepActiveStyle?: Styles
16
17 @Prop() labelStyle?: Styles
18
19 @Prop() labelActiveStyle?: Styles
20
21 get marksClasses() {
22 return [
23 'vue-slider-mark',
24 {
25 'vue-slider-mark-active': this.mark.active,
26 },
27 ]
28 }
29
30 get stepClasses() {
31 return [
32 'vue-slider-mark-step',
33 {
34 'vue-slider-mark-step-active': this.mark.active,
35 },
36 ]
37 }
38
39 get labelClasses() {
40 return [
41 'vue-slider-mark-label',
42 {
43 'vue-slider-mark-label-active': this.mark.active,
44 },
45 ]
46 }
47
48 labelClickHandle(e: MouseEvent | TouchEvent) {
49 e.stopPropagation()
50 this.$emit('pressLabel', this.mark.pos)
51 }
52
53 render() {
54 const mark = this.mark
55 return (
56 <div class={this.marksClasses}>
57 {this.$slots.step || (
58 <div
59 class={this.stepClasses}
60 style={[
61 this.stepStyle || {},
62 mark.style || {},
63 mark.active ? this.stepActiveStyle || {} : {},
64 mark.active ? mark.activeStyle || {} : {},
65 ]}
66 />
67 )}
68 {!this.hideLabel
69 ? this.$slots.label || (
70 <div
71 class={this.labelClasses}
72 style={[
73 this.labelStyle || {},
74 mark.labelStyle || {},
75 mark.active ? this.labelActiveStyle || {} : {},
76 mark.active ? mark.labelActiveStyle || {} : {},
77 ]}
78 onClick={this.labelClickHandle}
79 >
80 {mark.label}
81 </div>
82 )
83 : null}
84 </div>
85 )
86 }
87}