diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-01-30 04:37:25 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-30 04:37:25 +0900 |
| commit | f6154dc0af1a0d65819e87240f4385f9573095cb (patch) | |
| tree | 699a5ca07d6727b7f8497d4769f25d6d62f94b5a /src/client/components/cw-button.vue | |
| parent | Add Event activity-type support (#5785) (diff) | |
| download | misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.tar.gz misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.tar.bz2 misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.zip | |
v12 (#5712)
Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com>
Co-authored-by: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com>
Diffstat (limited to 'src/client/components/cw-button.vue')
| -rw-r--r-- | src/client/components/cw-button.vue | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/client/components/cw-button.vue b/src/client/components/cw-button.vue new file mode 100644 index 0000000000..4516e5210c --- /dev/null +++ b/src/client/components/cw-button.vue @@ -0,0 +1,73 @@ +<template> +<button class="nrvgflfuaxwgkxoynpnumyookecqrrvh _button" @click="toggle"> + <b>{{ value ? this.$t('_cw.hide') : this.$t('_cw.show') }}</b> + <span v-if="!value">{{ this.label }}</span> +</button> +</template> + +<script lang="ts"> +import Vue from 'vue'; +import i18n from '../i18n'; +import { length } from 'stringz'; +import { concat } from '../../prelude/array'; + +export default Vue.extend({ + i18n, + + props: { + value: { + type: Boolean, + required: true + }, + note: { + type: Object, + required: true + } + }, + + computed: { + label(): string { + return concat([ + this.note.text ? [this.$t('_cw.chars', { count: length(this.note.text) })] : [], + this.note.files && this.note.files.length !== 0 ? [this.$t('_cw.files', { count: this.note.files.length }) ] : [], + this.note.poll != null ? [this.$t('_cw.poll')] : [] + ] as string[][]).join(' / '); + } + }, + + methods: { + length, + + toggle() { + this.$emit('input', !this.value); + } + } +}); +</script> + +<style lang="scss" scoped> +.nrvgflfuaxwgkxoynpnumyookecqrrvh { + display: inline-block; + padding: 4px 8px; + font-size: 0.7em; + color: var(--cwFg); + background: var(--cwBg); + border-radius: 2px; + + &:hover { + background: var(--cwHoverBg); + } + + > span { + margin-left: 4px; + + &:before { + content: '('; + } + + &:after { + content: ')'; + } + } +} +</style> |