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"
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