pleroma-fe/src/components/popover/popover.vue

143 lines
2.9 KiB
Vue
Raw Normal View History

2020-02-28 17:39:47 +01:00
<template>
<span
2020-02-28 17:39:47 +01:00
@mouseenter="onMouseenter"
@mouseleave="onMouseleave"
>
2020-11-24 13:52:01 +01:00
<button
2020-02-28 17:39:47 +01:00
ref="trigger"
class="popover-trigger-button"
:class="normalButton ? 'button-default btn' : 'button-unstyled'"
type="button"
2022-11-07 19:22:40 +01:00
v-bind="triggerAttrs"
@click="onClick"
2020-02-28 17:39:47 +01:00
>
<slot name="trigger" />
2020-11-24 13:52:01 +01:00
</button>
2022-11-21 21:17:33 +01:00
<teleport
:disabled="!teleport"
to="#popovers"
>
<transition name="fade">
<div
v-if="!hidden"
ref="content"
:style="styles"
class="popover"
:class="popoverClass || 'popover-default'"
@mouseenter="onMouseenterContent"
@mouseleave="onMouseleaveContent"
@click="onClickContent"
>
<slot
name="content"
class="popover-inner"
:close="hidePopover"
/>
</div>
</transition>
2022-05-19 23:56:23 +02:00
</teleport>
</span>
2020-02-28 17:39:47 +01:00
</template>
<script src="./popover.js" />
<style lang="scss">
2023-01-09 19:02:16 +01:00
@import "../../variables";
2020-02-28 17:39:47 +01:00
.popover-trigger-button {
2022-02-03 21:10:45 +01:00
display: inline-block;
}
2020-02-28 17:39:47 +01:00
.popover {
z-index: var(--ZI_popover_override, var(--ZI_popovers));
2022-06-13 12:45:04 +02:00
position: fixed;
2020-02-28 17:39:47 +01:00
min-width: 0;
2022-06-21 00:05:42 +02:00
max-width: calc(100vw - 20px);
box-shadow: var(--shadow);
}
.popover-default {
2023-01-09 19:02:16 +01:00
&::after {
content: "";
2022-04-11 22:49:46 +02:00
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 3;
box-shadow: var(--shadow);
2022-04-11 22:49:46 +02:00
pointer-events: none;
}
2024-02-13 01:09:43 +01:00
border-radius: var(--roundness);
border-color: var(--border);
border-style: solid;
border-width: 1px;
2020-02-28 17:39:47 +01:00
}
.dropdown-menu {
display: block;
2024-02-13 01:09:43 +01:00
padding: 0;
2022-04-10 21:09:46 +02:00
font-size: 1em;
2020-02-28 17:39:47 +01:00
text-align: left;
list-style: none;
max-width: 100vw;
z-index: var(--ZI_popover_override, var(--ZI_popovers));
2020-02-28 17:39:47 +01:00
white-space: nowrap;
.dropdown-divider {
height: 0;
2023-01-09 19:02:16 +01:00
margin: 0.5rem 0;
2020-02-28 17:39:47 +01:00
overflow: hidden;
border-top: 1px solid $fallback--border;
border-top: 1px solid var(--border, $fallback--border);
}
.dropdown-item {
2024-02-28 00:23:43 +01:00
border-bottom: none;
2020-02-28 17:39:47 +01:00
&-icon {
svg {
2024-02-28 00:23:43 +01:00
width: var(--__line-height);
margin-right: var(--__horizontal-gap);
2020-02-28 17:39:47 +01:00
}
}
&.-has-submenu {
.chevron-icon {
margin-right: 0.25rem;
margin-left: 2rem;
}
}
.menu-checkbox {
display: inline-block;
vertical-align: middle;
2024-02-28 00:23:43 +01:00
min-width: calc(var(--__line-height) + 1px);
max-width: calc(var(--__line-height) + 1px);
min-height: calc(var(--__line-height) + 1px);
max-height: calc(var(--__line-height) + 1px);
line-height: var(--__line-height);
text-align: center;
2023-01-09 19:02:16 +01:00
border-radius: 0;
2024-02-13 01:09:43 +01:00
box-shadow: var(--shadow);
2024-02-28 00:23:43 +01:00
margin-right: var(--__horizontal-gap);
&.menu-checkbox-checked::after {
font-size: 1.25em;
2023-01-09 19:02:16 +01:00
content: "✓";
}
&.-radio {
border-radius: 9999px;
&.menu-checkbox-checked::after {
font-size: 2em;
2023-01-09 19:02:16 +01:00
content: "•";
}
}
}
2020-02-28 17:39:47 +01:00
}
}
</style>