-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed complete/incomplete list items
- Loading branch information
Phil Wing
committed
Jan 5, 2025
1 parent
42197bc
commit 71f74a3
Showing
5 changed files
with
205 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
src/components/DashboardComponents/MultiplayerToggle.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<template> | ||
<div | ||
class="slider-container" | ||
tabindex="0" | ||
@keydown.left.prevent="moveSlider(false)" | ||
@keydown.right.prevent="moveSlider(true)" | ||
> | ||
<label class="slider-label">{{ label }}</label> | ||
<div class="slider" @click="toggleSlider" :aria-checked="isChecked" role="switch"> | ||
<!--Needs to switch between an icon of one person and multiple --> | ||
<div class="slider-tab" :class="{ 'slider-checked': isChecked }">{{ isChecked ? 'Yes' : 'No' }}</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
name: 'BooleanSlider', | ||
props: { | ||
label: { | ||
type: String, | ||
default: 'Yes/No', | ||
}, | ||
modelValue: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
isChecked: this.modelValue, | ||
}; | ||
}, | ||
watch: { | ||
modelValue(newValue) { | ||
this.isChecked = newValue; // Update local state when parent prop changes | ||
}, | ||
}, | ||
methods: { | ||
emitSliderChange() { | ||
this.$emit('update:modelValue', this.isChecked); // Emit for v-model binding | ||
console.log("toggling"); | ||
}, | ||
toggleSlider() { | ||
this.isChecked = !this.isChecked; | ||
this.emitSliderChange(); // Emit the change | ||
}, | ||
moveSlider(direction) { | ||
// True for right arrow (Yes), false for left arrow (No) | ||
if (direction && !this.isChecked) { | ||
this.isChecked = true; | ||
} else if (!direction && this.isChecked) { | ||
this.isChecked = false; | ||
} | ||
this.emitSliderChange(); // Emit the change | ||
}, | ||
}, | ||
mounted() { | ||
this.isChecked = this.modelValue; // Set initial state based on prop value | ||
} | ||
}; | ||
//ee | ||
</script> | ||
|
||
<style scoped> | ||
.slider-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
cursor: pointer; | ||
outline: none; | ||
} | ||
.slider-label { | ||
text-align: center; | ||
margin-bottom: 2px; | ||
font-size: 16px; | ||
} | ||
.slider { | ||
position: relative; | ||
width: 80px; | ||
height: 30px; | ||
border-radius: 15px; | ||
display: flex; | ||
align-items: center; | ||
padding: 0 5px; | ||
transition: background-color 0.3s ease; | ||
} | ||
.slider-checked { | ||
transform: translateX(40px); | ||
} | ||
.slider-tab { | ||
width: 40px; | ||
height: 24px; | ||
border-radius: 12px; | ||
background-color: #fff; | ||
position: absolute; | ||
transition: transform 0.3s ease; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 14px; | ||
user-select: none; | ||
pointer-events: none; | ||
} | ||
.slider[aria-checked="true"] { | ||
background-color: blue; | ||
} | ||
.slider[aria-checked="false"] { | ||
background-color: #383444; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters