refactor(client): use css modules

This commit is contained in:
syuilo 2023-01-14 10:57:34 +09:00
parent ebf8ef22e4
commit 668aa17eef

View file

@ -1,17 +1,20 @@
<template> <template>
<div ref="rootEl" class="dwzlatin" :class="{ opened }"> <div ref="rootEl" :class="[$style.root, { [$style.opened]: opened }]">
<div class="header _button" @click="toggle"> <div :class="$style.header" class="_button" @click="toggle">
<span class="icon"><slot name="icon"></slot></span> <span :class="$style.headerIcon"><slot name="icon"></slot></span>
<span class="text"><slot name="label"></slot></span> <span :class="$style.headerText"><slot name="label"></slot></span>
<span class="right"> <span :class="$style.headerRight">
<span class="text"><slot name="suffix"></slot></span> <span :class="$style.headerRightText"><slot name="suffix"></slot></span>
<i v-if="opened" class="ti ti-chevron-up icon"></i> <i v-if="opened" class="ti ti-chevron-up icon"></i>
<i v-else class="ti ti-chevron-down icon"></i> <i v-else class="ti ti-chevron-down icon"></i>
</span> </span>
</div> </div>
<div v-if="openedAtLeastOnce" class="body" :class="{ bgSame }" :style="{ maxHeight: maxHeight ? `${maxHeight}px` : null }"> <div v-if="openedAtLeastOnce" :class="[$style.body, { [$style.bgSame]: bgSame }]" :style="{ maxHeight: maxHeight ? `${maxHeight}px` : null }">
<Transition <Transition
:name="$store.state.animation ? 'folder-toggle' : ''" :enter-active-class="$store.state.animation ? $style.transition_toggle_enterActive : ''"
:leave-active-class="$store.state.animation ? $style.transition_toggle_leaveActive : ''"
:enter-from-class="$store.state.animation ? $style.transition_toggle_enterFrom : ''"
:leave-to-class="$store.state.animation ? $style.transition_toggle_leaveTo : ''"
@enter="enter" @enter="enter"
@after-enter="afterEnter" @after-enter="afterEnter"
@leave="leave" @leave="leave"
@ -94,26 +97,36 @@ onMounted(() => {
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.folder-toggle-enter-active, .folder-toggle-leave-active { .transition_toggle_enterActive,
.transition_toggle_leaveActive {
overflow-y: clip; overflow-y: clip;
transition: opacity 0.3s, height 0.3s, transform 0.3s !important; transition: opacity 0.3s, height 0.3s, transform 0.3s !important;
} }
.folder-toggle-enter-from, .folder-toggle-leave-to { .transition_toggle_enterFrom,
.transition_toggle_leaveTo {
opacity: 0; opacity: 0;
} }
.dwzlatin { .root {
display: block; display: block;
&.opened {
> .header { > .header {
border-radius: 6px 6px 0 0;
}
}
}
.header {
display: flex; display: flex;
align-items: center; align-items: center;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
padding: 9px 14px 9px 14px; padding: 9px 12px 9px 12px;
background: var(--buttonBg); background: var(--buttonBg);
border-radius: 6px; border-radius: 6px;
transition: border-radius 0.3s;
&:hover { &:hover {
text-decoration: none; text-decoration: none;
@ -124,8 +137,9 @@ onMounted(() => {
color: var(--accent); color: var(--accent);
background: var(--buttonHoverBg); background: var(--buttonHoverBg);
} }
}
> .icon { .headerIcon {
margin-right: 0.75em; margin-right: 0.75em;
flex-shrink: 0; flex-shrink: 0;
text-align: center; text-align: center;
@ -134,31 +148,30 @@ onMounted(() => {
&:empty { &:empty {
display: none; display: none;
& + .text { & + .headerText {
padding-left: 4px; padding-left: 4px;
} }
} }
} }
> .text { .headerText {
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
padding-right: 12px; padding-right: 12px;
} }
> .right { .headerRight {
margin-left: auto; margin-left: auto;
opacity: 0.7; opacity: 0.7;
white-space: nowrap; white-space: nowrap;
}
> .text:not(:empty) { .headerRightText:not(:empty) {
margin-right: 0.75em; margin-right: 0.75em;
} }
}
}
> .body { .body {
background: var(--panel); background: var(--panel);
border-radius: 0 0 6px 6px; border-radius: 0 0 6px 6px;
container-type: inline-size; container-type: inline-size;
@ -167,12 +180,5 @@ onMounted(() => {
&.bgSame { &.bgSame {
background: var(--bg); background: var(--bg);
} }
}
&.opened {
> .header {
border-radius: 6px 6px 0 0;
}
}
} }
</style> </style>