refactor(client): use css modules

This commit is contained in:
syuilo 2023-01-14 12:15:02 +09:00
parent 34a7b52105
commit 203a7ad073
1 changed files with 157 additions and 155 deletions

View File

@ -1,36 +1,36 @@
<template> <template>
<div v-if="show" ref="el" class="fdidabkb" :class="{ slim: narrow, thin: thin_ }" :style="{ background: bg }" @click="onClick"> <div v-if="show" ref="el" :class="[$style.root, { [$style.slim]: narrow, [$style.thin]: thin_ }]" :style="{ background: bg }" @click="onClick">
<div v-if="narrow" class="buttons left"> <div v-if="narrow" :class="$style.buttonsLeft">
<MkAvatar v-if="props.displayMyAvatar && $i" class="avatar" :user="$i" :disable-preview="true"/> <MkAvatar v-if="props.displayMyAvatar && $i" :class="$style.avatar" :user="$i" :disable-preview="true"/>
</div> </div>
<template v-if="metadata"> <template v-if="metadata">
<div v-if="!hideTitle" class="titleContainer" @click="showTabsPopup"> <div v-if="!hideTitle" :class="$style.titleContainer" @click="showTabsPopup">
<MkAvatar v-if="metadata.avatar" class="avatar" :user="metadata.avatar" :disable-preview="true" :show-indicator="true"/> <MkAvatar v-if="metadata.avatar" :class="$style.titleAvatar" :user="metadata.avatar" :disable-preview="true" :show-indicator="true"/>
<i v-else-if="metadata.icon" class="icon" :class="metadata.icon"></i> <i v-else-if="metadata.icon" :class="[$style.titleIcon, metadata.icon]"></i>
<div class="title"> <div :class="$style.title">
<MkUserName v-if="metadata.userName" :user="metadata.userName" :nowrap="true" class="title"/> <MkUserName v-if="metadata.userName" :user="metadata.userName" :nowrap="true"/>
<div v-else-if="metadata.title" class="title">{{ metadata.title }}</div> <div v-else-if="metadata.title">{{ metadata.title }}</div>
<div v-if="!narrow && metadata.subtitle" class="subtitle"> <div v-if="!narrow && metadata.subtitle" :class="$style.subtitle">
{{ metadata.subtitle }} {{ metadata.subtitle }}
</div> </div>
<div v-if="narrow && hasTabs" class="subtitle activeTab"> <div v-if="narrow && hasTabs" :class="[$style.subtitle, $style.activeTab]">
{{ tabs.find(tab => tab.key === props.tab)?.title }} {{ tabs.find(tab => tab.key === props.tab)?.title }}
<i class="chevron ti ti-chevron-down"></i> <i class="ti ti-chevron-down" :class="$style.chevron"></i>
</div> </div>
</div> </div>
</div> </div>
<div v-if="!narrow || hideTitle" class="tabs"> <div v-if="!narrow || hideTitle" :class="$style.tabs">
<button v-for="tab in tabs" :ref="(el) => tabRefs[tab.key] = (el as HTMLElement)" v-tooltip.noDelay="tab.title" class="tab _button" :class="{ active: tab.key != null && tab.key === props.tab }" @mousedown="(ev) => onTabMousedown(tab, ev)" @click="(ev) => onTabClick(tab, ev)"> <button v-for="tab in tabs" :ref="(el) => tabRefs[tab.key] = (el as HTMLElement)" v-tooltip.noDelay="tab.title" class="_button" :class="[$style.tab, { [$style.active]: tab.key != null && tab.key === props.tab }]" @mousedown="(ev) => onTabMousedown(tab, ev)" @click="(ev) => onTabClick(tab, ev)">
<i v-if="tab.icon" class="icon" :class="tab.icon"></i> <i v-if="tab.icon" :class="[$style.tabIcon, tab.icon]"></i>
<span v-if="!tab.iconOnly" class="title">{{ tab.title }}</span> <span v-if="!tab.iconOnly" :class="$style.tabTitle">{{ tab.title }}</span>
</button> </button>
<div ref="tabHighlightEl" class="highlight"></div> <div ref="tabHighlightEl" :class="$style.tabHighlight"></div>
</div> </div>
</template> </template>
<div class="buttons right"> <div :class="$style.buttonsRight">
<template v-for="action in actions"> <template v-for="action in actions">
<button v-tooltip.noDelay="action.text" class="_button button" :class="{ highlighted: action.highlighted }" @click.stop="action.handler" @touchstart="preventDrag"><i :class="action.icon"></i></button> <button v-tooltip.noDelay="action.text" class="_button" :class="[$style.button, { [$style.highlighted]: action.highlighted }]" @click.stop="action.handler" @touchstart="preventDrag"><i :class="action.icon"></i></button>
</template> </template>
</div> </div>
</div> </div>
@ -178,8 +178,8 @@ onUnmounted(() => {
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.fdidabkb { .root {
--height: 50px; --height: 50px;
display: flex; display: flex;
width: 100%; width: 100%;
@ -215,8 +215,9 @@ onUnmounted(() => {
} }
} }
} }
}
> .buttons { .buttons {
--margin: 8px; --margin: 8px;
display: flex; display: flex;
align-items: center; align-items: center;
@ -224,10 +225,22 @@ onUnmounted(() => {
height: var(--height); height: var(--height);
margin: 0 var(--margin); margin: 0 var(--margin);
&.left { &:empty {
margin-right: auto; width: var(--height);
}
}
> .avatar { .buttonsLeft {
composes: buttons;
margin-right: auto;
}
.buttonsRight {
composes: buttons;
margin-left: auto;
}
.avatar {
$size: 32px; $size: 32px;
display: inline-block; display: inline-block;
width: $size; width: $size;
@ -236,17 +249,8 @@ onUnmounted(() => {
margin: 0 8px; margin: 0 8px;
pointer-events: none; pointer-events: none;
} }
}
&.right { .button {
margin-left: auto;
}
&:empty {
width: var(--height);
}
> .button {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -265,14 +269,13 @@ onUnmounted(() => {
} }
} }
> .fullButton { .fullButton {
& + .fullButton { & + .fullButton {
margin-left: 12px; margin-left: 12px;
} }
} }
}
> .titleContainer { .titleContainer {
display: flex; display: flex;
align-items: center; align-items: center;
max-width: 400px; max-width: 400px;
@ -282,8 +285,9 @@ onUnmounted(() => {
font-weight: bold; font-weight: bold;
flex-shrink: 0; flex-shrink: 0;
margin-left: 24px; margin-left: 24px;
}
> .avatar { .titleAvatar {
$size: 32px; $size: 32px;
display: inline-block; display: inline-block;
width: $size; width: $size;
@ -293,20 +297,21 @@ onUnmounted(() => {
pointer-events: none; pointer-events: none;
} }
> .icon { .titleIcon {
margin-right: 8px; margin-right: 8px;
width: 16px; width: 16px;
text-align: center; text-align: center;
} }
> .title { .title {
min-width: 0; min-width: 0;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
line-height: 1.1; line-height: 1.1;
}
> .subtitle { .subtitle {
opacity: 0.6; opacity: 0.6;
font-size: 0.8em; font-size: 0.8em;
font-weight: normal; font-weight: normal;
@ -323,17 +328,16 @@ onUnmounted(() => {
} }
} }
} }
}
}
> .tabs { .tabs {
position: relative; position: relative;
margin-left: 16px; margin-left: 16px;
font-size: 0.8em; font-size: 0.8em;
overflow: auto; overflow: auto;
white-space: nowrap; white-space: nowrap;
}
> .tab { .tab {
display: inline-block; display: inline-block;
position: relative; position: relative;
padding: 0 10px; padding: 0 10px;
@ -348,13 +352,13 @@ onUnmounted(() => {
&.active { &.active {
opacity: 1; opacity: 1;
} }
}
> .icon + .title { .tabIcon + .tabTitle {
margin-left: 8px; margin-left: 8px;
} }
}
> .highlight { .tabHighlight {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
height: 3px; height: 3px;
@ -363,6 +367,4 @@ onUnmounted(() => {
transition: all 0.2s ease; transition: all 0.2s ease;
pointer-events: none; pointer-events: none;
} }
}
}
</style> </style>