s11e152 custom switch - not Nintendo! so cool

This commit is contained in:
Tyrel Souza 2018-04-19 00:11:34 -04:00
parent ef7f13b236
commit b843b4bfbc
2 changed files with 61 additions and 1 deletions

View File

@ -102,6 +102,11 @@
</select> </select>
</div> </div>
</div> </div>
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<app-switch v-model="dataSwitched"></app-switch>
</div>
</div>
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3"> <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
@ -110,6 +115,8 @@
</button> </button>
</div> </div>
</div> </div>
</form> </form>
<hr> <hr>
<div class="row"> <div class="row">
@ -131,6 +138,7 @@
</ul> </ul>
<p>Gender: {{userData.gender}}</p> <p>Gender: {{userData.gender}}</p>
<p>Priority: {{selectedPriority}}</p> <p>Priority: {{selectedPriority}}</p>
<p>Switched: {{dataSwitched}}</p>
</div> </div>
</div> </div>
</div> </div>
@ -139,6 +147,8 @@
</template> </template>
<script> <script>
import Switch from './components/Switch.vue'
export default { export default {
data(){ data(){
return { return {
@ -151,8 +161,12 @@
message: 'A new hope', message: 'A new hope',
sendMail: [], sendMail: [],
priorities: ['High', 'Medium', 'Low'], priorities: ['High', 'Medium', 'Low'],
selectedPriority: 'Medium' selectedPriority: 'Medium',
dataSwitched: false
}; };
},
components:{
appSwitch: Switch,
} }
} }
</script> </script>

View File

@ -0,0 +1,46 @@
<template>
<div>
<div
id="on"
@click="switched(true)"
:class="{active: value}"
> On</div>
<div
id="off"
@click="switched(false)"
:class="{active: !value}"
> Off</div>
</div>
</template>
<script>
export default {
props: ['value'],
methods: {
switched(value){
this.$emit('input', value)
}
}
}
</script>
<style scoped>
#on, #off {
width: 40px;
height: 20px;
background-color: lightgray;
padding: 2px;
display: inline-block;
margin: 10px -2px;
box-sizing: content-box;
cursor: pointer;
text-align:center;
}
#on:hover, #on.active{
background-color: lightgreen;
}
#off:hover, #off.active{
background-color: lightcoral;
}
</style>