diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-16 17:48:16 +0900 |
|---|---|---|
| committer | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-16 17:48:16 +0900 |
| commit | 22b0ace8b4fecb3a7a3d0c4a1e046dddaf692ec0 (patch) | |
| tree | 55ab40dae89f089a856debd4fd453aeecc81c7ad /packages/frontend/src/components/MkPostForm.TextCounter.vue | |
| parent | Revert "enhance(frontend): 投稿フォームの設定メニューを改良 (... (diff) | |
| download | sharkey-22b0ace8b4fecb3a7a3d0c4a1e046dddaf692ec0.tar.gz sharkey-22b0ace8b4fecb3a7a3d0c4a1e046dddaf692ec0.tar.bz2 sharkey-22b0ace8b4fecb3a7a3d0c4a1e046dddaf692ec0.zip | |
enhance(frontend): 投稿フォームの設定メニューを改良 (改)
This reverts commit a814395127aa1b4ea643fb40235e3e58c747b77f.
Diffstat (limited to 'packages/frontend/src/components/MkPostForm.TextCounter.vue')
| -rw-r--r-- | packages/frontend/src/components/MkPostForm.TextCounter.vue | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/packages/frontend/src/components/MkPostForm.TextCounter.vue b/packages/frontend/src/components/MkPostForm.TextCounter.vue new file mode 100644 index 0000000000..b1d39df5d3 --- /dev/null +++ b/packages/frontend/src/components/MkPostForm.TextCounter.vue @@ -0,0 +1,95 @@ +<!-- +SPDX-FileCopyrightText: syuilo and misskey-project +SPDX-License-Identifier: AGPL-3.0-only +--> + +<template> +<div :class="[$style.textCountRoot]"> + <div :class="$style.textCountLabel">{{ i18n.ts.textCount }}</div> + <div + :class="[$style.textCount, + { [$style.danger]: textCountPercentage > 100 }, + { [$style.warning]: textCountPercentage > 90 && textCountPercentage <= 100 }, + ]" + > + <div :class="$style.textCountGraph"></div> + <div><span :class="$style.textCountCurrent">{{ number(textLength) }}</span> / {{ number(maxTextLength) }}</div> + </div> +</div> +</template> + +<script lang="ts" setup> +import { computed, useTemplateRef } from 'vue'; +import { instance } from '@/instance.js'; +import { i18n } from '@/i18n.js'; +import number from '@/filters/number.js'; + +const props = defineProps<{ + textLength: number; +}>(); + +const maxTextLength = computed(() => { + return instance ? instance.maxNoteTextLength : 1000; +}); + +const textCountPercentage = computed(() => { + return props.textLength / maxTextLength.value * 100; +}); +</script> + +<style lang="scss" module> +.textCountRoot { + padding: 4px 14px; +} + +.textCountLabel { + font-size: 11px; + opacity: 0.8; + margin-bottom: 4px; +} + +.textCount { + display: flex; + gap: var(--MI-marginHalf); + align-items: center; + font-size: 12px; + --countColor: var(--MI_THEME-accent); + + &.danger { + --countColor: var(--MI_THEME-error); + } + + &.warning { + --countColor: var(--MI_THEME-warn); + } + + .textCountGraph { + position: relative; + width: 24px; + height: 24px; + border-radius: 50%; + background-image: conic-gradient( + var(--countColor) 0% v-bind("Math.min(100, textCountPercentage) + '%'"), + rgba(0, 0, 0, .2) v-bind("Math.min(100, textCountPercentage) + '%'") 100% + ); + + &::after { + content: ''; + position: absolute; + width: 16px; + height: 16px; + border-radius: 50%; + background-color: var(--MI_THEME-popup); + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + } + + .textCountCurrent { + color: var(--countColor); + font-weight: 700; + font-size: 18px; + } +} +</style> |