2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-04-23 02:21:38 +02:00
|
|
|
<button
|
2023-04-29 01:28:25 +02:00
|
|
|
ref="el"
|
2023-04-23 02:21:38 +02:00
|
|
|
class="_button"
|
2023-04-23 02:22:53 +02:00
|
|
|
:class="{ showLess: modelValue, fade: !modelValue }"
|
2023-04-23 02:21:38 +02:00
|
|
|
@click.stop="toggle"
|
|
|
|
>
|
2023-04-23 02:22:53 +02:00
|
|
|
<span
|
|
|
|
>{{ modelValue ? i18n.ts._cw.hide : i18n.ts._cw.show }}
|
2023-04-23 02:21:38 +02:00
|
|
|
<span v-if="!modelValue">{{ label }}</span>
|
|
|
|
</span>
|
2023-04-08 02:01:42 +02:00
|
|
|
</button>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-07 05:26:12 +01:00
|
|
|
<script lang="ts" setup>
|
2023-04-29 01:28:25 +02:00
|
|
|
import { computed, ref } from "vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { length } from "stringz";
|
2023-09-24 06:27:16 +02:00
|
|
|
import type * as firefish from "firefish-js";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { concat } from "@/scripts/array";
|
|
|
|
import { i18n } from "@/i18n";
|
2022-01-07 05:26:12 +01:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
modelValue: boolean;
|
2023-09-24 06:27:16 +02:00
|
|
|
note: firefish.entities.Note;
|
2022-01-07 05:26:12 +01:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "update:modelValue", v: boolean): void;
|
2022-01-07 05:26:12 +01:00
|
|
|
}>();
|
|
|
|
|
2023-04-30 22:27:27 +02:00
|
|
|
const el = ref<HTMLElement>();
|
2023-04-29 01:28:25 +02:00
|
|
|
|
2022-01-07 05:26:12 +01:00
|
|
|
const label = computed(() => {
|
|
|
|
return concat([
|
2023-04-08 02:01:42 +02:00
|
|
|
props.note.text
|
|
|
|
? [i18n.t("_cw.chars", { count: length(props.note.text) })]
|
|
|
|
: [],
|
|
|
|
props.note.files && props.note.files.length !== 0
|
|
|
|
? [i18n.t("_cw.files", { count: props.note.files.length })]
|
|
|
|
: [],
|
|
|
|
props.note.poll != null ? [i18n.ts.poll] : [],
|
2023-04-23 02:21:38 +02:00
|
|
|
props.note.renote != null ? [i18n.ts.quoteAttached] : [],
|
|
|
|
] as string[][]).join(", ");
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
2022-01-07 05:26:12 +01:00
|
|
|
|
|
|
|
const toggle = () => {
|
2023-04-08 02:01:42 +02:00
|
|
|
emit("update:modelValue", !props.modelValue);
|
2022-01-07 05:26:12 +01:00
|
|
|
};
|
2023-04-29 01:28:25 +02:00
|
|
|
|
|
|
|
function focus() {
|
|
|
|
el.value.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
2023-04-30 22:27:27 +02:00
|
|
|
focus,
|
2023-04-29 01:28:25 +02:00
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2023-04-23 02:21:38 +02:00
|
|
|
._button {
|
|
|
|
font-weight: 700;
|
2023-05-25 21:50:14 +02:00
|
|
|
z-index: 5;
|
2020-01-29 20:37:25 +01:00
|
|
|
> span {
|
2023-04-23 02:21:38 +02:00
|
|
|
background: var(--cwBg) !important;
|
|
|
|
color: var(--cwFg);
|
2023-07-06 03:28:27 +02:00
|
|
|
transition:
|
|
|
|
background 0.2s,
|
|
|
|
color 0.2s;
|
2023-04-23 02:21:38 +02:00
|
|
|
> span {
|
|
|
|
font-weight: 500;
|
|
|
|
&::before {
|
2023-04-23 02:22:53 +02:00
|
|
|
content: "(";
|
2023-04-23 02:21:38 +02:00
|
|
|
}
|
|
|
|
&::after {
|
2023-04-23 02:22:53 +02:00
|
|
|
content: ")";
|
2023-04-23 02:21:38 +02:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
2023-04-30 22:27:27 +02:00
|
|
|
&:hover > span,
|
|
|
|
&:focus > span {
|
2023-04-23 02:21:38 +02:00
|
|
|
background: var(--cwFg) !important;
|
|
|
|
color: var(--cwBg) !important;
|
|
|
|
}
|
2023-04-29 00:18:09 +02:00
|
|
|
|
|
|
|
&.fade {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
> span {
|
|
|
|
display: inline-block;
|
|
|
|
background: var(--panel);
|
|
|
|
padding: 0.4em 1em;
|
|
|
|
font-size: 0.8em;
|
|
|
|
border-radius: 999px;
|
|
|
|
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
|
|
|
|
}
|
2023-04-29 00:18:09 +02:00
|
|
|
&:hover {
|
2023-04-29 00:18:09 +02:00
|
|
|
> span {
|
|
|
|
background: var(--panelHighlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&.showLess {
|
|
|
|
width: 100%;
|
|
|
|
position: sticky;
|
2023-05-28 06:17:23 +02:00
|
|
|
bottom: calc(var(--stickyBottom) - 1em);
|
|
|
|
padding: 20px;
|
2023-04-29 00:18:09 +02:00
|
|
|
|
|
|
|
> span {
|
|
|
|
display: inline-block;
|
|
|
|
background: var(--panel);
|
|
|
|
padding: 6px 10px;
|
|
|
|
font-size: 0.8em;
|
|
|
|
border-radius: 999px;
|
|
|
|
box-shadow: 0 0 7px 7px var(--bg);
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|