iceshrimp/packages/client/src/components/MkShowMoreButton.vue

75 lines
1.2 KiB
Vue
Raw Normal View History

2023-04-29 07:18:09 +09:00
<template>
2023-05-20 07:41:59 +09:00
<button
ref="el"
class="_button"
:class="{ fade: modelValue, showLess: !modelValue }"
@click.stop="toggle"
>
2023-05-18 04:24:51 +09:00
<span>{{ modelValue ? i18n.ts.showMore : i18n.ts.showLess }}</span>
2023-04-29 07:18:09 +09:00
</button>
</template>
<script lang="ts" setup>
import { i18n } from "@/i18n";
2023-05-18 04:24:51 +09:00
import { ref } from "vue";
2023-04-29 07:18:09 +09:00
const props = defineProps<{
modelValue: boolean;
}>();
2023-05-18 04:24:51 +09:00
const el = ref<HTMLElement>();
2023-04-29 07:18:09 +09:00
const emit = defineEmits<{
(ev: "update:modelValue", v: boolean): void;
}>();
const toggle = () => {
emit("update:modelValue", !props.modelValue);
};
2023-05-18 04:24:51 +09:00
function focus() {
el.value.focus();
}
defineExpose({
focus,
});
2023-04-29 07:18:09 +09:00
</script>
<style lang="scss" scoped>
.fade {
display: block;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
2023-05-18 04:24:51 +09:00
z-index: 2;
2023-04-29 07:18:09 +09:00
> span {
display: inline-block;
background: var(--panel);
padding: 0.4em 1em;
font-size: 0.8em;
border-radius: 999px;
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
}
&:hover {
> span {
background: var(--panelHighlight);
}
}
}
.showLess {
width: 100%;
margin-top: 1em;
position: sticky;
bottom: var(--stickyBottom);
> span {
display: inline-block;
background: var(--panel);
padding: 6px 10px;
font-size: 0.8em;
border-radius: 999px;
box-shadow: 0 0 7px 7px var(--bg);
}
}
</style>