Skip to content

Commit

Permalink
fix(status): fix status bar text overflow, fix #59
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 24, 2024
1 parent 4e176f8 commit 6ff13f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions plugins/status/client/load/load-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:class="[type, 'bar']"
:style="{ width: percentage(distribution[index]) }">
<template v-if="index === maxIndex">{{ caption }}</template>
<template v-else-if="maxIndex === -1 && distribution[index] >= 0.2">{{ percentage(distribution[index]) }}</template>
</span>
</span>
</div>
Expand All @@ -20,8 +21,8 @@ import { computed } from 'vue'
const props = defineProps<{ rate: LoadRate, title: string }>()
function percentage(value: number, digits = 3) {
return (value * 100).toFixed(digits) + '%'
function percentage(value: number, digits = 1) {
return +(value * 100).toFixed(digits) + '%'
}
const types = ['used', 'app', 'free'] as const
Expand All @@ -33,7 +34,7 @@ const distribution = computed(() => [
])
const maxIndex = computed(() => {
return distribution.value.indexOf(Math.max(...distribution.value))
return distribution.value.findIndex(value => value >= 0.5)
})
const caption = computed(() => {
Expand All @@ -58,7 +59,7 @@ const caption = computed(() => {
.body {
width: 10rem;
height: 0.8rem;
font-size: 0.8em;
font-size: 10px;
position: relative;
display: inline;
background-color: var(--k-c-divisor);
Expand All @@ -75,22 +76,23 @@ const caption = computed(() => {
display: flex;
align-items: center;
justify-content: center;
white-space: pre;
}
.used {
background-color: var(--primary);
color: white;
transition: color 0.3s ease, background-color 0.3s ease;
&:hover {
background-color: var(--primary-tint);
background-color: var(--primary-tint, var(--primary));
}
}
.app {
background-color: var(--k-color-warning);
transition: color 0.3s ease, background-color 0.3s ease;
&:hover {
background-color: var(--k-color-warning-tint);
background-color: var(--k-color-warning-tint, var(--k-color-warning));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/status/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@koishijs/plugin-status",
"description": "Status view for Koishi",
"version": "7.4.8",
"version": "7.4.10",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down

0 comments on commit 6ff13f0

Please sign in to comment.