2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
2024-02-13 09:50:11 -06:00
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
2023-07-27 00:31:52 -05:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
2023-10-10 04:08:54 -05:00
|
|
|
<MkButton rounded full small @click="toggle"><b>{{ modelValue ? i18n.ts._cw.hide : i18n.ts._cw.show }}</b><span v-if="!modelValue" :class="$style.label">{{ label }}</span></MkButton>
|
2020-01-29 13:37:25 -06:00
|
|
|
</template>
|
|
|
|
|
2022-01-06 22:26:12 -06:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue';
|
2023-09-03 23:33:38 -05:00
|
|
|
import * as Misskey from 'misskey-js';
|
2024-01-30 04:53:53 -06:00
|
|
|
import type { PollEditorModelValue } from '@/components/MkPollEditor.vue';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { concat } from '@/scripts/array.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2023-10-10 04:08:54 -05:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2022-01-06 22:26:12 -06:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
modelValue: boolean;
|
2023-11-29 22:49:31 -06:00
|
|
|
text: string | null;
|
2024-01-30 04:53:53 -06:00
|
|
|
renote?: Misskey.entities.Note | null;
|
|
|
|
files?: Misskey.entities.DriveFile[];
|
|
|
|
poll?: Misskey.entities.Note['poll'] | PollEditorModelValue | null;
|
2022-01-06 22:26:12 -06:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2022-05-26 08:53:09 -05:00
|
|
|
(ev: 'update:modelValue', v: boolean): void;
|
2022-01-06 22:26:12 -06:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const label = computed(() => {
|
|
|
|
return concat([
|
2024-01-19 17:11:59 -06:00
|
|
|
props.text ? [i18n.tsx._cw.chars({ count: props.text.length })] : [],
|
2023-12-19 03:30:31 -06:00
|
|
|
props.renote ? [i18n.ts.quote] : [],
|
2024-01-30 04:53:53 -06:00
|
|
|
props.files && props.files.length !== 0 ? [i18n.tsx._cw.files({ count: props.files.length })] : [],
|
2023-11-29 22:49:31 -06:00
|
|
|
props.poll != null ? [i18n.ts.poll] : [],
|
2022-01-06 22:26:12 -06:00
|
|
|
] as string[][]).join(' / ');
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
2022-01-06 22:26:12 -06:00
|
|
|
|
2023-10-10 04:08:54 -05:00
|
|
|
function toggle() {
|
2022-01-06 22:26:12 -06:00
|
|
|
emit('update:modelValue', !props.modelValue);
|
2023-10-10 04:08:54 -05:00
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
</script>
|
|
|
|
|
2023-01-13 20:46:22 -06:00
|
|
|
<style lang="scss" module>
|
|
|
|
.label {
|
|
|
|
margin-left: 4px;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2023-01-13 20:46:22 -06:00
|
|
|
&:before {
|
|
|
|
content: '(';
|
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2023-01-13 20:46:22 -06:00
|
|
|
&:after {
|
|
|
|
content: ')';
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|