Skip to content

Commit f0b3f5d

Browse files
committed
style(switch): adjust border-radius handling for square variant
1 parent fcfd98a commit f0b3f5d

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

frontend/src/components/Progress/index.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const circleStyle = computed(() => {
2323
props.status
2424
]
2525
const radius = props.radius * 2 + 'px'
26-
const percent = props.percent >= 100 ? 101 : props.percent || 0
26+
const percent = Math.min(props.percent || 0, 100)
2727
const mask = `radial-gradient(transparent ${props.radius * 0.6}px, #fff 0px)`
2828
const bg = `conic-gradient(${color} 0%, ${color} ${percent}%, var(--progress-bg) ${percent}%, var(--progress-bg) 100%)`
2929
return {
@@ -38,7 +38,11 @@ const circleStyle = computed(() => {
3838

3939
<template>
4040
<div v-if="type === 'line'" class="gui-progress-line h-10 rounded-8 overflow-hidden">
41-
<div :style="innerStyle" :class="status" class="inner h-full rounded-8 duration-200"></div>
41+
<div
42+
:style="innerStyle"
43+
:class="props.status"
44+
class="inner h-full rounded-8 duration-200"
45+
></div>
4246
</div>
4347
<div
4448
v-if="type === 'circle'"

frontend/src/components/Switch/index.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,19 @@ const toggle = () => {
3535
<div
3636
@click="toggle"
3737
v-tips.slow="label"
38-
:class="[size, border, model ? 'on' : 'off', disabled ? 'disabled' : '']"
39-
class="gui-switch relative cursor-pointer h-24 inline-flex items-center rounded-full text-12"
38+
:class="[
39+
size,
40+
border,
41+
model ? 'on' : 'off',
42+
disabled ? 'disabled' : '',
43+
border === 'square' ? 'rounded-4' : 'rounded-full',
44+
]"
45+
class="gui-switch relative cursor-pointer h-24 inline-flex items-center text-12"
4046
>
41-
<div class="dot absolute h-18 w-18 rounded-full duration-200"></div>
47+
<div
48+
:class="[border === 'square' ? 'rounded-4' : 'rounded-full']"
49+
class="dot absolute h-18 w-18 duration-200"
50+
></div>
4251

4352
<div v-if="$slots.default || label" class="slot line-clamp-1 break-all">
4453
<span v-if="label">{{ t(label) }}</span>
@@ -64,10 +73,8 @@ const toggle = () => {
6473
}
6574
6675
.square {
67-
border-radius: 4px;
6876
.dot {
6977
width: 4px;
70-
border-radius: 2px;
7178
}
7279
}
7380

0 commit comments

Comments
 (0)