|
1 | 1 | <template> |
2 | | - <div> |
3 | | - <label class="checkbox-container"> |
4 | | - <input type="checkbox" @click="changeStatus" :disabled="disable"> |
5 | | - <span class="checkmark"></span> |
6 | | - </label> |
7 | | - </div> |
| 2 | + <div class="checkboxContainer" @click="changeStatus"> |
| 3 | + <div v-if="checkboxValue" class="checkboxBlueContent"> |
| 4 | + <div class="checkmark"> |
| 5 | + </div> |
| 6 | + </div> |
| 7 | + </div> |
8 | 8 | </template> |
| 9 | + |
9 | 10 | <script> |
| 11 | +import {eventBus} from "@/buses/eventBus" |
10 | 12 | export default { |
11 | | - name:"iv-tickbox", |
12 | | - props:{ |
13 | | - initialState: { |
14 | | - type: Boolean, |
15 | | - default: true |
16 | | - }, |
17 | | - disable: { |
18 | | - type: Boolean, |
19 | | - default: false |
20 | | - } |
21 | | - }, |
22 | | - data() { |
23 | | - return { |
24 | | - checkboxStatus: this.initialState, |
25 | | - isDisabled: this.disable |
26 | | - } |
27 | | - }, |
28 | | - methods:{ |
29 | | - changeStatus(){ |
30 | | - this.checkboxStatus = !this.checkboxStatus; |
31 | | - if(!this.checkboxStatus == true){ |
32 | | - this.$emit("checked", this.checkboxStatus) |
33 | | - }else{ |
34 | | - this.$emit("unchecked", this.checkboxStatus) |
35 | | - } |
36 | | - } |
37 | | - }, |
| 13 | + name: "iv-tickbox", |
| 14 | + props: { |
| 15 | + value: { |
| 16 | + type: Boolean, |
| 17 | + required: true, |
| 18 | + default: false |
| 19 | + } |
| 20 | + }, |
| 21 | + data(){ |
| 22 | + return{ |
| 23 | + checkboxValue: this.value |
| 24 | + } |
| 25 | + }, |
| 26 | + methods: { |
| 27 | + changeStatus() { |
| 28 | + this.checkboxValue = !this.checkboxValue |
| 29 | + this.$emit("check", this.checkboxValue); |
| 30 | + } |
| 31 | + }, |
| 32 | + mounted(){ |
| 33 | + eventBus.$on("reset-data", data => { |
| 34 | + console.log(data); |
| 35 | + this.checkboxValue = this.value; |
| 36 | + this.$emit("check", this.checkboxValue); |
| 37 | + }); |
| 38 | + } |
38 | 39 | } |
39 | 40 | </script> |
40 | | -<style> |
41 | | -.checkbox-container { |
42 | | - display: block; |
43 | | - position: relative; |
44 | | - padding-left: 35px; |
45 | | - margin-bottom: 12px; |
46 | | - cursor: pointer; |
47 | | - font-size: 22px; |
48 | | - -webkit-user-select: none; |
49 | | - -moz-user-select: none; |
50 | | - -ms-user-select: none; |
51 | | - user-select: none; |
52 | | -} |
53 | | -
|
54 | | -.checkbox-container input { |
55 | | - position: absolute; |
56 | | - opacity: 0; |
| 41 | +<style lang="scss"> |
| 42 | +.checkboxContainer{ |
57 | 43 | cursor: pointer; |
58 | | - height: 0; |
59 | | - width: 0; |
60 | | -} |
61 | | -
|
62 | | -.checkmark { |
63 | | - position: absolute; |
64 | | - top: 0; |
65 | | - left: 0; |
66 | | - height: 25px; |
67 | | - width: 25px; |
68 | | - background-color: #eee; |
69 | | - outline: 1px solid #000305; |
70 | | -} |
71 | | -
|
72 | | -
|
73 | | -.checkbox-container:hover input ~ .checkmark { |
74 | | - background-color: #ccc; |
75 | | - outline: 1px solid #000305; |
76 | | -} |
77 | | -
|
78 | | -.checkbox-container input:checked ~ .checkmark { |
79 | | - background-color: #2196F3; |
80 | | - outline: 1px solid #000305; |
81 | | -} |
82 | | -
|
83 | | -
|
84 | | -.checkmark:after { |
85 | | - content: ""; |
86 | | - position: absolute; |
87 | | - display: none; |
88 | | -} |
89 | | -
|
90 | | -.checkbox-container input:checked ~ .checkmark:after { |
91 | | - display: block; |
92 | | -} |
93 | | -
|
94 | | -.checkbox-container .checkmark:after { |
95 | | - left: 9px; |
96 | | - top: 5px; |
97 | | - width: 5px; |
98 | | - height: 10px; |
| 44 | + background-color: lightgrey; |
| 45 | + width: 20px; |
| 46 | + height: 20px; |
| 47 | + border: 1px solid black; |
| 48 | +} |
| 49 | +.checkboxBlueContent{ |
| 50 | + background-color: blue; |
| 51 | + width: 21px; |
| 52 | + height: 21px; |
| 53 | +} |
| 54 | +.checkmark{ |
| 55 | + height: 12px; |
| 56 | + width: 8px; |
99 | 57 | border: solid white; |
100 | 58 | border-width: 0 3px 3px 0; |
101 | | - -webkit-transform: rotate(45deg); |
102 | | - -ms-transform: rotate(45deg); |
103 | | - transform: rotate(45deg); |
104 | | -} |
105 | | -.checkbox-container input:disabled ~ .checkmark{ |
106 | | - background-color: rgb(211, 209, 209); |
107 | | - outline: 1px solid #b4b4b4; |
108 | | -} |
109 | | -.checkbox-container input:disabled ~ .checkmark:after { |
110 | | - left: 9px; |
111 | | - top: 5px; |
112 | | - width: 5px; |
113 | | - height: 10px; |
114 | | - border: solid #7e7e7e; |
115 | | - border-width: 0 3px 3px 0; |
116 | | - -webkit-transform: rotate(45deg); |
117 | | - -ms-transform: rotate(45deg); |
118 | | - transform: rotate(45deg); |
| 59 | + transform: rotate(45deg) translate(3px,-4px); |
119 | 60 | } |
120 | 61 | </style> |
| 62 | + |
0 commit comments