refactor(client): use css modules

This commit is contained in:
syuilo 2023-01-10 14:16:59 +09:00
parent af80fee899
commit 01d5e385ec
1 changed files with 146 additions and 149 deletions

View File

@ -1,10 +1,10 @@
<template> <template>
<div ref="elRef" class="qglefbjs" :class="notification.type"> <div ref="elRef" :class="$style.root">
<div v-once class="head"> <div v-once :class="$style.head">
<MkAvatar v-if="notification.type === 'pollEnded'" class="icon" :user="notification.note.user"/> <MkAvatar v-if="notification.type === 'pollEnded'" :class="$style.icon" :user="notification.note.user"/>
<MkAvatar v-else-if="notification.user" class="icon" :user="notification.user"/> <MkAvatar v-else-if="notification.user" :class="$style.icon" :user="notification.user"/>
<img v-else-if="notification.icon" class="icon" :src="notification.icon" alt=""/> <img v-else-if="notification.icon" :class="$style.icon" :src="notification.icon" alt=""/>
<div class="sub-icon" :class="notification.type"> <div :class="[$style.subIcon, $style['t_' + notification.type]]">
<i v-if="notification.type === 'follow'" class="ti ti-plus"></i> <i v-if="notification.type === 'follow'" class="ti ti-plus"></i>
<i v-else-if="notification.type === 'receiveFollowRequest'" class="ti ti-clock"></i> <i v-else-if="notification.type === 'receiveFollowRequest'" class="ti ti-clock"></i>
<i v-else-if="notification.type === 'followRequestAccepted'" class="ti ti-check"></i> <i v-else-if="notification.type === 'followRequestAccepted'" class="ti ti-check"></i>
@ -21,46 +21,47 @@
:reaction="notification.reaction ? notification.reaction.replace(/^:(\w+):$/, ':$1@.:') : notification.reaction" :reaction="notification.reaction ? notification.reaction.replace(/^:(\w+):$/, ':$1@.:') : notification.reaction"
:custom-emojis="notification.note.emojis" :custom-emojis="notification.note.emojis"
:no-style="true" :no-style="true"
style="width: 100%; height: 100%;"
/> />
</div> </div>
</div> </div>
<div class="tail"> <div :class="$style.tail">
<header> <header :class="$style.header">
<span v-if="notification.type === 'pollEnded'">{{ i18n.ts._notification.pollEnded }}</span> <span v-if="notification.type === 'pollEnded'">{{ i18n.ts._notification.pollEnded }}</span>
<MkA v-else-if="notification.user" v-user-preview="notification.user.id" class="name" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA> <MkA v-else-if="notification.user" v-user-preview="notification.user.id" :class="$style.headerName" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA>
<span v-else>{{ notification.header }}</span> <span v-else>{{ notification.header }}</span>
<MkTime v-if="withTime" :time="notification.createdAt" class="time"/> <MkTime v-if="withTime" :time="notification.createdAt" :class="$style.headerTime"/>
</header> </header>
<div v-once class="content"> <div v-once :class="$style.content">
<MkA v-if="notification.type === 'reaction'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)"> <MkA v-if="notification.type === 'reaction'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
<i class="ti ti-quote"></i> <i class="ti ti-quote" :class="$style.quote"></i>
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/> <Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/>
<i class="ti ti-quote"></i> <i class="ti ti-quote" :class="$style.quote"></i>
</MkA> </MkA>
<MkA v-else-if="notification.type === 'renote'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)"> <MkA v-else-if="notification.type === 'renote'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)">
<i class="ti ti-quote"></i> <i class="ti ti-quote" :class="$style.quote"></i>
<Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="!full"/> <Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="!full"/>
<i class="ti ti-quote"></i> <i class="ti ti-quote" :class="$style.quote"></i>
</MkA> </MkA>
<MkA v-else-if="notification.type === 'reply'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)"> <MkA v-else-if="notification.type === 'reply'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/> <Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/>
</MkA> </MkA>
<MkA v-else-if="notification.type === 'mention'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)"> <MkA v-else-if="notification.type === 'mention'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/> <Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/>
</MkA> </MkA>
<MkA v-else-if="notification.type === 'quote'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)"> <MkA v-else-if="notification.type === 'quote'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/> <Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/>
</MkA> </MkA>
<MkA v-else-if="notification.type === 'pollEnded'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)"> <MkA v-else-if="notification.type === 'pollEnded'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
<i class="ti ti-quote"></i> <i class="ti ti-quote" :class="$style.quote"></i>
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/> <Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full"/>
<i class="ti ti-quote"></i> <i class="ti ti-quote" :class="$style.quote"></i>
</MkA> </MkA>
<span v-else-if="notification.type === 'follow'" class="text" style="opacity: 0.6;">{{ i18n.ts.youGotNewFollower }}<div v-if="full"><MkFollowButton :user="notification.user" :full="true"/></div></span> <span v-else-if="notification.type === 'follow'" :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.youGotNewFollower }}<div v-if="full"><MkFollowButton :user="notification.user" :full="true"/></div></span>
<span v-else-if="notification.type === 'followRequestAccepted'" class="text" style="opacity: 0.6;">{{ i18n.ts.followRequestAccepted }}</span> <span v-else-if="notification.type === 'followRequestAccepted'" :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.followRequestAccepted }}</span>
<span v-else-if="notification.type === 'receiveFollowRequest'" class="text" style="opacity: 0.6;">{{ i18n.ts.receiveFollowRequest }}<div v-if="full && !followRequestDone"><button class="_textButton" @click="acceptFollowRequest()">{{ i18n.ts.accept }}</button> | <button class="_textButton" @click="rejectFollowRequest()">{{ i18n.ts.reject }}</button></div></span> <span v-else-if="notification.type === 'receiveFollowRequest'" :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.receiveFollowRequest }}<div v-if="full && !followRequestDone"><button class="_textButton" @click="acceptFollowRequest()">{{ i18n.ts.accept }}</button> | <button class="_textButton" @click="rejectFollowRequest()">{{ i18n.ts.reject }}</button></div></span>
<span v-else-if="notification.type === 'groupInvited'" class="text" style="opacity: 0.6;">{{ i18n.ts.groupInvited }}: <b>{{ notification.invitation.group.name }}</b><div v-if="full && !groupInviteDone"><button class="_textButton" @click="acceptGroupInvitation()">{{ i18n.ts.accept }}</button> | <button class="_textButton" @click="rejectGroupInvitation()">{{ i18n.ts.reject }}</button></div></span> <span v-else-if="notification.type === 'groupInvited'" :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.groupInvited }}: <b>{{ notification.invitation.group.name }}</b><div v-if="full && !groupInviteDone"><button class="_textButton" @click="acceptGroupInvitation()">{{ i18n.ts.accept }}</button> | <button class="_textButton" @click="rejectGroupInvitation()">{{ i18n.ts.reject }}</button></div></span>
<span v-else-if="notification.type === 'app'" class="text"> <span v-else-if="notification.type === 'app'" :class="$style.text">
<Mfm :text="notification.body" :nowrap="!full"/> <Mfm :text="notification.body" :nowrap="!full"/>
</span> </span>
</div> </div>
@ -156,8 +157,8 @@ useTooltip(reactionRef, (showing) => {
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.qglefbjs { .root {
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
padding: 24px 32px; padding: 24px 32px;
@ -165,23 +166,25 @@ useTooltip(reactionRef, (showing) => {
overflow-wrap: break-word; overflow-wrap: break-word;
display: flex; display: flex;
contain: content; contain: content;
}
> .head { .head {
position: sticky; position: sticky;
top: 0; top: 0;
flex-shrink: 0; flex-shrink: 0;
width: 42px; width: 42px;
height: 42px; height: 42px;
margin-right: 8px; margin-right: 8px;
}
> .icon { .icon {
display: block; display: block;
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 6px; border-radius: 6px;
} }
> .sub-icon { .subIcon {
position: absolute; position: absolute;
z-index: 1; z-index: 1;
bottom: -2px; bottom: -2px;
@ -194,110 +197,104 @@ useTooltip(reactionRef, (showing) => {
box-shadow: 0 0 0 3px var(--panel); box-shadow: 0 0 0 3px var(--panel);
font-size: 12px; font-size: 12px;
text-align: center; text-align: center;
color: #fff;
&:empty { &:empty {
display: none; display: none;
} }
> * {
color: #fff;
width: 100%;
height: 100%;
} }
&.follow, &.followRequestAccepted, &.receiveFollowRequest, &.groupInvited { .t_follow, .t_followRequestAccepted, .t_receiveFollowRequest, .t_groupInvited {
padding: 3px; padding: 3px;
background: #36aed2; background: #36aed2;
pointer-events: none; pointer-events: none;
} }
&.renote { .t_renote {
padding: 3px; padding: 3px;
background: #36d298; background: #36d298;
pointer-events: none; pointer-events: none;
} }
&.quote { .t_quote {
padding: 3px; padding: 3px;
background: #36d298; background: #36d298;
pointer-events: none; pointer-events: none;
} }
&.reply { .t_reply {
padding: 3px; padding: 3px;
background: #007aff; background: #007aff;
pointer-events: none; pointer-events: none;
} }
&.mention { .t_mention {
padding: 3px; padding: 3px;
background: #88a6b7; background: #88a6b7;
pointer-events: none; pointer-events: none;
} }
&.pollEnded { .t_pollEnded {
padding: 3px; padding: 3px;
background: #88a6b7; background: #88a6b7;
pointer-events: none; pointer-events: none;
} }
}
}
> .tail { .tail {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
}
> header { .header {
display: flex; display: flex;
align-items: baseline; align-items: baseline;
white-space: nowrap; white-space: nowrap;
}
> .name { .headerName {
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
min-width: 0; min-width: 0;
overflow: hidden; overflow: hidden;
} }
> .time { .headerTime {
margin-left: auto; margin-left: auto;
font-size: 0.9em; font-size: 0.9em;
} }
.content {
} }
> .content { .text {
> .text {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
}
> i { .quote {
vertical-align: super; vertical-align: super;
font-size: 50%; font-size: 50%;
opacity: 0.5; opacity: 0.5;
} }
> i:first-child { .quote:first-child {
margin-right: 4px; margin-right: 4px;
} }
> i:last-child { .quote:last-child {
margin-left: 4px; margin-left: 4px;
} }
}
}
}
}
@container (max-width: 600px) { @container (max-width: 600px) {
.qglefbjs { .root {
padding: 16px; padding: 16px;
font-size: 0.9em; font-size: 0.9em;
} }
} }
@container (max-width: 500px) { @container (max-width: 500px) {
.qglefbjs { .root {
padding: 12px; padding: 12px;
font-size: 0.85em; font-size: 0.85em;
} }