feat: 自分用メモ機能 (#10516)
* 自分用メモを作成する機能 * 不要なCSSを削除 * メモ: デザイン調整 * デザイン崩れを修正 * fix: メモ機能のe2eテストで見つかった不具合を修正 * デザイン調整 * fix(frontend): 自分用メモtextareaにline-heightが適用されない問題を修正
This commit is contained in:
parent
7d11cf8ec9
commit
605f149235
14 changed files with 358 additions and 3 deletions
|
@ -21,6 +21,9 @@
|
|||
<span v-if="user.isAdmin" :title="i18n.ts.isAdmin" style="color: var(--badge);"><i class="ti ti-shield"></i></span>
|
||||
<span v-if="user.isLocked" :title="i18n.ts.isLocked"><i class="ti ti-lock"></i></span>
|
||||
<span v-if="user.isBot" :title="i18n.ts.isBot"><i class="ti ti-robot"></i></span>
|
||||
<button v-if="!isEditingMemo && !memoDraft" class="_button add-note-button" @click="showMemoTextarea">
|
||||
<i class="ti ti-edit"/> {{ i18n.ts.addMemo }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<span v-if="$i && $i.id != user.id && user.isFollowed" class="followed">{{ i18n.ts.followsYou }}</span>
|
||||
|
@ -39,6 +42,17 @@
|
|||
<span v-if="user.isBot" :title="i18n.ts.isBot"><i class="ti ti-robot"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="isEditingMemo || memoDraft" class="memo" :class="{'no-memo': !memoDraft}">
|
||||
<div class="heading" v-text="i18n.ts.memo"/>
|
||||
<textarea
|
||||
ref="memoTextareaEl"
|
||||
v-model="memoDraft"
|
||||
rows="1"
|
||||
@focus="isEditingMemo = true"
|
||||
@blur="updateMemo"
|
||||
@input="adjustMemoTextarea"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="user.roles.length > 0" class="roles">
|
||||
<span v-for="role in user.roles" :key="role.id" v-tooltip="role.description" class="role" :style="{ '--color': role.color }">
|
||||
<img v-if="role.iconUrl" style="height: 1.3em; vertical-align: -22%;" :src="role.iconUrl"/>
|
||||
|
@ -113,7 +127,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { defineAsyncComponent, computed, onMounted, onUnmounted } from 'vue';
|
||||
import { defineAsyncComponent, computed, onMounted, onUnmounted, nextTick, watch } from 'vue';
|
||||
import calcAge from 's-age';
|
||||
import * as misskey from 'misskey-js';
|
||||
import MkNote from '@/components/MkNote.vue';
|
||||
|
@ -133,6 +147,7 @@ import { $i } from '@/account';
|
|||
import { dateString } from '@/filters/date';
|
||||
import { confetti } from '@/scripts/confetti';
|
||||
import MkNotes from '@/components/MkNotes.vue';
|
||||
import { api } from '@/os';
|
||||
|
||||
const XPhotos = defineAsyncComponent(() => import('./index.photos.vue'));
|
||||
const XActivity = defineAsyncComponent(() => import('./index.activity.vue'));
|
||||
|
@ -151,6 +166,10 @@ let parallaxAnimationId = $ref<null | number>(null);
|
|||
let narrow = $ref<null | boolean>(null);
|
||||
let rootEl = $ref<null | HTMLElement>(null);
|
||||
let bannerEl = $ref<null | HTMLElement>(null);
|
||||
let memoTextareaEl = $ref<null | HTMLElement>(null);
|
||||
let memoDraft = $ref(props.user.memo);
|
||||
|
||||
let isEditingMemo = $ref(false);
|
||||
|
||||
const pagination = {
|
||||
endpoint: 'users/notes' as const,
|
||||
|
@ -193,6 +212,31 @@ function parallax() {
|
|||
banner.style.backgroundPosition = `center calc(50% - ${pos}px)`;
|
||||
}
|
||||
|
||||
function showMemoTextarea() {
|
||||
isEditingMemo = true;
|
||||
nextTick(() => {
|
||||
memoTextareaEl?.focus();
|
||||
});
|
||||
}
|
||||
|
||||
function adjustMemoTextarea() {
|
||||
if (!memoTextareaEl) return;
|
||||
memoTextareaEl.style.height = '0px';
|
||||
memoTextareaEl.style.height = `${memoTextareaEl.scrollHeight}px`;
|
||||
}
|
||||
|
||||
async function updateMemo() {
|
||||
await api('users/update-memo', {
|
||||
memo: memoDraft,
|
||||
userId: props.user.id,
|
||||
});
|
||||
isEditingMemo = false;
|
||||
}
|
||||
|
||||
watch([props.user], () => {
|
||||
memoDraft = props.user.memo;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
window.requestAnimationFrame(parallaxLoop);
|
||||
narrow = rootEl!.clientWidth < 1000;
|
||||
|
@ -208,6 +252,9 @@ onMounted(() => {
|
|||
});
|
||||
}
|
||||
}
|
||||
nextTick(() => {
|
||||
adjustMemoTextarea();
|
||||
});
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
@ -323,6 +370,16 @@ onUnmounted(() => {
|
|||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
> .add-note-button {
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
color: #fff;
|
||||
-webkit-backdrop-filter: var(--blur, blur(8px));
|
||||
backdrop-filter: var(--blur, blur(8px));
|
||||
border-radius: 24px;
|
||||
padding: 4px 8px;
|
||||
font-size: 80%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -369,6 +426,38 @@ onUnmounted(() => {
|
|||
}
|
||||
}
|
||||
|
||||
> .memo {
|
||||
margin: 12px 24px 0 154px;
|
||||
background: transparent;
|
||||
color: var(--fg);
|
||||
border: 1px solid var(--divider);
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
line-height: 0;
|
||||
|
||||
> .heading {
|
||||
text-align: left;
|
||||
color: var(--fgTransparent);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
textarea {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
resize: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
min-height: 0;
|
||||
line-height: 1.5;
|
||||
color: var(--fg);
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
> .description {
|
||||
padding: 24px 24px 24px 154px;
|
||||
font-size: 0.95em;
|
||||
|
@ -504,6 +593,10 @@ onUnmounted(() => {
|
|||
justify-content: center;
|
||||
}
|
||||
|
||||
> .memo {
|
||||
margin: 16px 16px 0 16px;
|
||||
}
|
||||
|
||||
> .description {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue