2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2023-02-10 11:04:11 +09:00
|
|
|
<button class="_button" :class="$style.root" @mousedown="toggle">
|
2022-01-28 11:39:49 +09:00
|
|
|
<b>{{ modelValue ? i18n.ts._cw.hide : i18n.ts._cw.show }}</b>
|
2023-01-14 11:46:22 +09:00
|
|
|
<span v-if="!modelValue" :class="$style.label">{{ label }}</span>
|
2020-01-30 04:37:25 +09:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2022-01-07 13:26:12 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue';
|
2023-09-04 13:33:38 +09:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-09-19 16:37:43 +09:00
|
|
|
import { concat } from '@/scripts/array.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2022-01-07 13:26:12 +09:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
modelValue: boolean;
|
2023-09-04 13:33:38 +09:00
|
|
|
note: Misskey.entities.Note;
|
2022-01-07 13:26:12 +09:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2022-05-26 22:53:09 +09:00
|
|
|
(ev: 'update:modelValue', v: boolean): void;
|
2022-01-07 13:26:12 +09:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const label = computed(() => {
|
|
|
|
return concat([
|
2023-02-20 17:04:57 +09:00
|
|
|
props.note.text ? [i18n.t('_cw.chars', { count: props.note.text.length })] : [],
|
2022-12-12 19:27:47 +09:00
|
|
|
props.note.files && props.note.files.length !== 0 ? [i18n.t('_cw.files', { count: props.note.files.length })] : [],
|
2022-12-22 16:01:59 +09:00
|
|
|
props.note.poll != null ? [i18n.ts.poll] : [],
|
2022-01-07 13:26:12 +09:00
|
|
|
] as string[][]).join(' / ');
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
2022-01-07 13:26:12 +09:00
|
|
|
|
|
|
|
const toggle = () => {
|
|
|
|
emit('update:modelValue', !props.modelValue);
|
|
|
|
};
|
2020-01-30 04:37:25 +09:00
|
|
|
</script>
|
|
|
|
|
2023-01-14 11:46:22 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-01-30 04:37:25 +09:00
|
|
|
display: inline-block;
|
|
|
|
padding: 4px 8px;
|
|
|
|
font-size: 0.7em;
|
|
|
|
color: var(--cwFg);
|
|
|
|
background: var(--cwBg);
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: var(--cwHoverBg);
|
|
|
|
}
|
2023-01-14 11:46:22 +09:00
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2023-01-14 11:46:22 +09:00
|
|
|
.label {
|
|
|
|
margin-left: 4px;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2023-01-14 11:46:22 +09:00
|
|
|
&:before {
|
|
|
|
content: '(';
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2023-01-14 11:46:22 +09:00
|
|
|
&:after {
|
|
|
|
content: ')';
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|