2022-01-04 21:16:41 +09:00
|
|
|
<template>
|
|
|
|
<div class="dwzlatin" :class="{ opened }">
|
|
|
|
<div class="header _button" @click="toggle">
|
|
|
|
<span class="icon"><slot name="icon"></slot></span>
|
|
|
|
<span class="text"><slot name="label"></slot></span>
|
|
|
|
<span class="right">
|
|
|
|
<span class="text"><slot name="suffix"></slot></span>
|
2022-12-19 19:01:30 +09:00
|
|
|
<i v-if="opened" class="ti ti-chevron-up icon"></i>
|
|
|
|
<i v-else class="ti ti-chevron-down icon"></i>
|
2022-01-04 21:16:41 +09:00
|
|
|
</span>
|
|
|
|
</div>
|
2022-06-20 17:38:49 +09:00
|
|
|
<KeepAlive>
|
2022-01-04 21:16:41 +09:00
|
|
|
<div v-if="openedAtLeastOnce" v-show="opened" class="body">
|
|
|
|
<MkSpacer :margin-min="14" :margin-max="22">
|
|
|
|
<slot></slot>
|
|
|
|
</MkSpacer>
|
|
|
|
</div>
|
2022-06-20 17:38:49 +09:00
|
|
|
</KeepAlive>
|
2022-01-04 21:16:41 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2022-01-04 22:42:04 +09:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
defaultOpen: boolean;
|
|
|
|
}>(), {
|
2022-12-19 19:01:30 +09:00
|
|
|
defaultOpen: false,
|
2022-06-10 14:36:55 +09:00
|
|
|
});
|
2022-01-04 22:42:04 +09:00
|
|
|
|
|
|
|
let opened = $ref(props.defaultOpen);
|
|
|
|
let openedAtLeastOnce = $ref(props.defaultOpen);
|
2022-01-04 21:16:41 +09:00
|
|
|
|
|
|
|
const toggle = () => {
|
|
|
|
opened = !opened;
|
|
|
|
if (opened) {
|
|
|
|
openedAtLeastOnce = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.dwzlatin {
|
|
|
|
display: block;
|
|
|
|
|
|
|
|
> .header {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
2022-12-19 19:01:30 +09:00
|
|
|
padding: 10px 14px 10px 14px;
|
2022-01-04 21:16:41 +09:00
|
|
|
background: var(--buttonBg);
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
background: var(--buttonHoverBg);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
color: var(--accent);
|
|
|
|
background: var(--buttonHoverBg);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
margin-right: 0.75em;
|
|
|
|
flex-shrink: 0;
|
|
|
|
text-align: center;
|
|
|
|
opacity: 0.8;
|
|
|
|
|
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
|
|
|
|
& + .text {
|
|
|
|
padding-left: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .text {
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
padding-right: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .right {
|
|
|
|
margin-left: auto;
|
|
|
|
opacity: 0.7;
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
|
|
> .text:not(:empty) {
|
|
|
|
margin-right: 0.75em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
background: var(--panel);
|
|
|
|
border-radius: 0 0 6px 6px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.opened {
|
|
|
|
> .header {
|
|
|
|
border-radius: 6px 6px 0 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|