Merge remote-tracking branch 'origin/main' into profile-modal
This commit is contained in:
commit
83d4f02c3a
18 changed files with 147 additions and 73 deletions
|
@ -1,11 +1,15 @@
|
|||
<template>
|
||||
<div v-for="item of props.menuItems" class="context-menu-item" @click="runCallback(item)">
|
||||
{{ item.name }}
|
||||
<div id="context-menu">
|
||||
<button v-for="item of props.menuItems" class="context-menu-item"
|
||||
:class="'context-menu-item-' + item.type"
|
||||
@click="runCallback(item)">
|
||||
{{ item.name }} <Icon v-if="item.icon" :name="item.icon" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ContextMenuItem } from '~/types/interfaces';
|
||||
import type { ContextMenuInterface, ContextMenuItem } from '~/types/interfaces';
|
||||
|
||||
const props = defineProps<{ menuItems: ContextMenuItem[], pointerX: number, pointerY: number }>();
|
||||
|
||||
|
@ -19,7 +23,8 @@ onMounted(() => {
|
|||
|
||||
|
||||
function runCallback(item: ContextMenuItem) {
|
||||
removeContextMenu();
|
||||
const contextMenu = useState<ContextMenuInterface>("contextMenu");
|
||||
removeContextMenu(contextMenu);
|
||||
item.callback();
|
||||
}
|
||||
|
||||
|
@ -31,14 +36,33 @@ function runCallback(item: ContextMenuItem) {
|
|||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 10dvw;
|
||||
border: .15rem solid cyan;
|
||||
background-color: var(--background-color);
|
||||
text-align: center;
|
||||
width: 10rem;
|
||||
border: .1rem solid var(--reply-text-color);
|
||||
background-color: var(--sidebar-highlighted-background-color);
|
||||
text-align: left;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.context-menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 2rem;
|
||||
width: 100%;
|
||||
color: var(--text-color);
|
||||
background-color: var(--sidebar-highlighted-background-color);
|
||||
border: none;
|
||||
text-align: left;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
.context-menu-item:hover {
|
||||
background-color: rgb(50, 50, 50);
|
||||
}
|
||||
|
||||
.context-menu-item-danger {
|
||||
color: var(--danger-text-color);
|
||||
}
|
||||
|
||||
</style>
|
|
@ -46,11 +46,22 @@ onMounted(async () => {
|
|||
function scrollToReply(e: MouseEvent) {
|
||||
e.preventDefault();
|
||||
console.log("clicked on reply box");
|
||||
const reply = document.querySelector(`.message[data-message-id="${props.replyId}"]`);
|
||||
if (reply) {
|
||||
let replyId: string;
|
||||
if (props.maxWidth == "reply") {
|
||||
replyId = props.replyId;
|
||||
} else {
|
||||
replyId = props.id;
|
||||
}
|
||||
const reply = document.querySelector(`.message[data-message-id="${replyId}"]`);
|
||||
if (reply instanceof HTMLDivElement) {
|
||||
console.log("reply:", reply);
|
||||
console.log("scrolling into view");
|
||||
reply.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
reply.style.transition = "background-color .3s";
|
||||
reply.style.backgroundColor = "var(--primary-highlighted-color)";
|
||||
setTimeout(() => {
|
||||
reply.style.backgroundColor = "";
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div ref="resizableSidebar" class="resizable-sidebar"
|
||||
:style="{
|
||||
'width': storedWidth ? `${storedWidth}px` : props.width,
|
||||
'width': storedWidth ? storedWidth : props.width,
|
||||
'min-width': props.minWidth,
|
||||
'max-width': props.maxWidth,
|
||||
'border': props.borderSides == 'all' ? borderStyling : undefined,
|
||||
|
@ -21,7 +21,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ContextMenuItem } from '~/types/interfaces';
|
||||
import type { ContextMenuInterface, ContextMenuItem } from '~/types/interfaces';
|
||||
|
||||
const props = defineProps<{ width?: string, minWidth: string, maxWidth: string, borderSides: "all" | "top" | "right" | "bottom" | "left" | ("top" | "right" | "bottom" | "left")[], localStorageName?: string }>();
|
||||
|
||||
|
@ -29,10 +29,18 @@ const borderStyling = ".1rem solid var(--padding-color)";
|
|||
|
||||
const resizableSidebar = ref<HTMLDivElement>();
|
||||
const widthResizer = ref<HTMLDivElement>();
|
||||
const storedWidth = ref<number>();
|
||||
const storedWidth = ref<string>();
|
||||
|
||||
const contextMenu = useState<ContextMenuInterface>("contextMenu");
|
||||
|
||||
const menuItems: ContextMenuItem[] = [
|
||||
{ name: "Reset", callback: () => { resizableSidebar.value!.style.width = props.width ?? props.minWidth } }
|
||||
{ name: "Reset", callback: () => {
|
||||
const defaultWidth = props.width ?? props.minWidth;
|
||||
resizableSidebar.value!.style.width = defaultWidth;
|
||||
if (props.localStorageName) {
|
||||
localStorage.setItem(props.localStorageName, defaultWidth);
|
||||
}
|
||||
} }
|
||||
]
|
||||
|
||||
onMounted(() => {
|
||||
|
@ -42,7 +50,7 @@ onMounted(() => {
|
|||
widthResizer.value.addEventListener("pointerdown", (e) => {
|
||||
e.preventDefault();
|
||||
if (e.button == 2) {
|
||||
createContextMenu(e, menuItems);
|
||||
showContextMenu(e, contextMenu.value, menuItems);
|
||||
return
|
||||
};
|
||||
document.body.style.cursor = "ew-resize";
|
||||
|
@ -88,7 +96,7 @@ function loadStoredWidth() {
|
|||
if (props.localStorageName) {
|
||||
const storedWidthValue = localStorage.getItem(props.localStorageName);
|
||||
if (storedWidthValue) {
|
||||
storedWidth.value = parseInt(storedWidthValue) || undefined;
|
||||
storedWidth.value = storedWidthValue;
|
||||
console.log("[res] loaded stored width");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue