forked from mirror/misskey

* refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ
60 lines
1.2 KiB
Vue
60 lines
1.2 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<svg :class="$style.root" viewBox="0 0 1 1" preserveAspectRatio="none">
|
|
<circle
|
|
:r="r"
|
|
cx="50%" cy="50%"
|
|
fill="none"
|
|
stroke-width="0.1"
|
|
stroke="rgba(0, 0, 0, 0.05)"
|
|
:class="$style.circle"
|
|
/>
|
|
<circle
|
|
:r="r"
|
|
cx="50%" cy="50%"
|
|
:stroke-dasharray="Math.PI * (r * 2)"
|
|
:stroke-dashoffset="strokeDashoffset"
|
|
fill="none"
|
|
stroke-width="0.1"
|
|
:class="$style.circle"
|
|
:stroke="color"
|
|
/>
|
|
<text x="50%" y="50%" dy="0.05" text-anchor="middle" :class="$style.text">{{ (value * 100).toFixed(0) }}%</text>
|
|
</svg>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed } from 'vue';
|
|
|
|
const props = defineProps<{
|
|
value: number;
|
|
}>();
|
|
|
|
const r = 0.45;
|
|
|
|
const color = computed(() => `hsl(${180 - (props.value * 180)}, 80%, 70%)`);
|
|
const strokeDashoffset = computed(() => (1 - props.value) * (Math.PI * (r * 2)));
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.root {
|
|
display: block;
|
|
height: 100%;
|
|
}
|
|
|
|
.circle {
|
|
transform-origin: center;
|
|
transform: rotate(-90deg);
|
|
transition: stroke-dashoffset 0.5s ease;
|
|
}
|
|
|
|
.text {
|
|
font-size: 0.15px;
|
|
fill: currentColor;
|
|
}
|
|
</style>
|