Skip to content

Commit 06305b6

Browse files
author
Niels Bosman
committed
Cleanup to make it more basic and clean
1 parent 0396564 commit 06305b6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/VueToggle.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
<template>
2-
<section class="wrapper" @click="toggled = !toggled">
3-
<span v-if="location === 'left'" class="title">{{ title }}</span>
2+
<section class="wrapper">
43
<input
54
:id="id"
65
v-model="toggled"
76
:name="name ? name : false"
87
class="toggle"
98
type="checkbox"
9+
@click="toggle()"
1010
/>
1111
<label :for="id" class="toggler" />
12-
<span v-if="location === 'right'" class="title">{{ title }}</span>
12+
<span class="title" @click="toggle()" v-text="title" />
1313
</section>
1414
</template>
1515

1616
<script>
17+
1718
export default {
1819
name: 'VueToggle',
1920
2021
props: {
2122
title: { type: String, required: true },
2223
name: { type: String, required: false },
2324
id: { type: Number, required: true },
24-
location: { type: String, default: 'right' },
2525
},
2626
2727
data() {
2828
return { toggled: false }
2929
},
30+
31+
methods: {
32+
toggle: () => this.toggled = !this.toggled,
33+
},
3034
}
3135
</script>
3236

0 commit comments

Comments
 (0)