Skip to content

Commit 8b06c88

Browse files
committed
Changed: Use new v-bind directive for inline styling in CSS. Updated Vue versions.
1 parent b834927 commit 8b06c88

File tree

3 files changed

+8556
-8385
lines changed

3 files changed

+8556
-8385
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
"dependencies": {
1515
"sass": "^1.32.11",
1616
"sass-loader": "^10.1.1",
17-
"vue": "^3.0.11",
17+
"vue": "^3.2.20",
1818
"vue-sfc-rollup": "^4.0.5"
1919
},
2020
"devDependencies": {
2121
"@vue/cli-plugin-babel": "^4.5.12",
2222
"@vue/cli-plugin-eslint": "~4.5.0",
2323
"@vue/cli-service": "^4.5.12",
24-
"@vue/compiler-sfc": "^3.0.11",
24+
"@vue/compiler-sfc": "^3.2.20",
2525
"babel-eslint": "^10.1.0",
2626
"eslint": "^7.25.0",
2727
"eslint-plugin-vue": "^7.9.0"

src/components/VueToggle.vue

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<section
33
:class="{
4-
'm-toggle--is-dark': darkTheme,
4+
'm-toggle--is-dark': darkTheme,
55
'm-toggle--is-disabled': disabled,
66
}"
77
class="m-toggle"
@@ -19,20 +19,14 @@
1919
:aria-disabled="disabled"
2020
:aria-labelledby="`${id}-label`"
2121
:aria-readonly="disabled"
22-
:style="toggleState && {
23-
'background-color': activeColor
24-
}"
2522
class="m-toggle__content"
23+
:class="{'m-toggle__content--active': toggleState}"
2624
role="checkbox"
2725
@click="toggle"
2826
/>
2927
<label
3028
:id="`${id}-label`"
3129
:for="id"
32-
:style="{
33-
'font-size': fontSize,
34-
'font-weight': fontWeight,
35-
}"
3630
class="m-toggle__label"
3731
>
3832
{{ title }}
@@ -46,17 +40,17 @@ export default {
4640
4741
props: {
4842
activeColor: { type: String, default: '#9FD6AE' },
49-
darkTheme: { type: Boolean, default: false },
50-
disabled: { type: Boolean, default: false },
51-
fontSize: { type: String, default: '16px' },
52-
fontWeight: { type: String, default: 'normal' },
53-
name: { type: String, required: true },
54-
title: { type: String, required: true },
55-
toggled: { type: Boolean, default: false },
43+
darkTheme: { type: Boolean, default: false },
44+
disabled: { type: Boolean, default: false },
45+
fontSize: { type: String, default: '16px' },
46+
fontWeight: { type: String, default: 'normal' },
47+
name: { type: String, required: true },
48+
title: { type: String, required: true },
49+
toggled: { type: Boolean, default: false },
5650
},
5751
5852
data() {
59-
return { toggleState: this.toggled }
53+
return { toggleState: this.toggled };
6054
},
6155
6256
methods: {
@@ -72,7 +66,7 @@ export default {
7266
return this.name.replace(/ /g, '').toLowerCase();
7367
},
7468
},
75-
}
69+
};
7670
</script>
7771

7872
<style lang="scss" scoped>
@@ -90,6 +84,8 @@ export default {
9084
9185
&__label {
9286
user-select: none;
87+
font-weight: v-bind(fontWeight);
88+
font-size: v-bind(fontSize);
9389
9490
#{$self}--is-disabled & {
9591
cursor: not-allowed;
@@ -124,6 +120,10 @@ export default {
124120
width: 4em;
125121
will-change: background-color;
126122
123+
&--active {
124+
background-color: v-bind(activeColor);
125+
}
126+
127127
&:after {
128128
background: white;
129129
border-radius: 50%;

0 commit comments

Comments
 (0)