改进得分选择板的外观

master
cflsxjw 2 months ago
parent 1fc150ea02
commit 0ee1536c2b

2
package-lock.json generated

@ -1,5 +1,5 @@
{ {
"name": "roller", "name": "roller-frontend",
"version": "0.0.0", "version": "0.0.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,

@ -1,5 +1,5 @@
{ {
"name": "roller", "name": "roller-frontend",
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",

@ -2,16 +2,20 @@
import {ref, computed} from "vue"; import {ref, computed} from "vue";
const emit = defineEmits(['score-changed']) const emit = defineEmits(['score-changed'])
const prop = defineProps(['currentScore']) const prop = defineProps(['currentScore'])
const n = 1; const reset = ref(true)
const tag = ref(0) const tag = ref(0)
function clicked(num) function clicked(num)
{ {
reset.value=false;
tag.value=num tag.value=num
emit('score-changed', num) emit('score-changed', num)
} }
function getButtonColor(score) { function getButtonColor(score) {
if (score <= prop.currentScore) if (reset.value) {
{ return {background: '#D9D9D9'}
}
if (score <= prop.currentScore) {
if (prop.currentScore < 0) { if (prop.currentScore < 0) {
return {background: '#6D3939'} return {background: '#6D3939'}
} }
@ -28,19 +32,19 @@ function getButtonColor(score) {
<template> <template>
<div class="score-board-container"> <div class="score-board-container">
<div class="score-container"> <div class="score-container">
<div class="score"> <button class="score" @dblclick="reset=true;currentScore=0;$emit('score-changed',0)" :style="computed(()=>{return currentScore>=0?{background: '#297561'}:{background: '#754F29'}}).value">
<span v-if="currentScore >= 0">{{computed(()=>{return currentScore.toFixed(1)})}}</span> <span>{{computed(()=>{return currentScore.toFixed(1)})}}</span>
</div> </button>
<span class="score-text">s<br>c<br>o<br>r<br>e</span> <span class="score-text">s<br>c<br>o<br>r<br>e</span>
</div> </div>
<div class="buttons-group"> <div class="buttons-group">
<el-button class="button" @click="clicked(3)" :style="getButtonColor(3)"></el-button> <button class="button" @click="clicked(3)" :style="getButtonColor(3)"></button>
<el-button class="button" @click="clicked(2.5)" :style="getButtonColor(2.5)"></el-button> <button class="button" @click="clicked(2.5)" :style="getButtonColor(2.5)"></button>
<el-button class="button" @click="clicked(2)" :style="getButtonColor(2)"></el-button> <button class="button" @click="clicked(2)" :style="getButtonColor(2)"></button>
<el-button class="button" @click="clicked(1.5)" :style="getButtonColor(1.5)"></el-button> <button class="button" @click="clicked(1.5)" :style="getButtonColor(1.5)"></button>
<el-button class="button" @click="clicked(1)" :style="getButtonColor(1)"></el-button> <button class="button" @click="clicked(1)" :style="getButtonColor(1)"></button>
<el-button class="button" @click="clicked(0.5)" :style="getButtonColor(0.5)"></el-button> <button class="button" @click="clicked(0.5)" :style="getButtonColor(0.5)"></button>
<el-button class="button" @click="clicked(-1)" :style="getButtonColor(-1)"></el-button> <button class="button" @click="clicked(-1)" :style="getButtonColor(-1)"></button>
</div> </div>
</div> </div>
</template> </template>
@ -50,6 +54,7 @@ function getButtonColor(score) {
font-family: Itim; font-family: Itim;
src: url("/src/assets/fonts/Itim-Regular.ttf"); src: url("/src/assets/fonts/Itim-Regular.ttf");
} }
* { * {
padding: 0; padding: 0;
margin: 0; margin: 0;
@ -58,7 +63,6 @@ function getButtonColor(score) {
height: 60px; height: 60px;
width: 60px; width: 60px;
border-radius: 50px; border-radius: 50px;
background-color: #297561;
margin: 15px 5px 15px 5px; margin: 15px 5px 15px 5px;
border: #2A3F45 3px solid; border: #2A3F45 3px solid;
font-size: 32px; font-size: 32px;

Loading…
Cancel
Save