Skip to content

Commit

Permalink
feat: add ability to resize left sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriansaliou committed Jan 21, 2025
1 parent a70c1d5 commit b94eb30
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1",
"thenby": "1.3.4",
"v-hotkey3": "0.1.4",
"v-resizable": "0.0.14",
"vue": "3.4.31",
"vue-logger-plugin": "2.2.3",
"vue-router": "4.2.5",
Expand Down
17 changes: 17 additions & 0 deletions src/assemblies/inbox/InboxMessaging.vue
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@ export default {
runtime.addEventListener("keyup", this.onFrameInnerKey);
runtime.addEventListener("keydown", this.onFrameInnerKey);
runtime.addEventListener("keypress", this.onFrameInnerKey);
runtime.addEventListener("mouseup", this.onFrameInnerMouse);
runtime.addEventListener("mousedown", this.onFrameInnerMouse);
runtime.addEventListener("mousemove", this.onFrameInnerMouse);
runtime.addEventListener("dragover", this.onFrameInnerDragOver);
},

Expand Down Expand Up @@ -1242,6 +1245,20 @@ export default {
this.$el.dispatchEvent(new KeyboardEvent(event.type, event));
},

onFrameInnerMouse(event: MouseEvent): void {
// Prevent frame to capture mouse events
// Notice: frames capture all mouse events when the mouse goes over it,
// meaning the parent document will not receive any such event. \
// In our case, we do not want the frame to capture mouse events at \
// all, therefore we need to intercept there at the frame document \
// level, and then re-dispatch the same mouse event to the parent \
// document.
event.stopPropagation();

// Re-dispatch the event on the wrapper component
this.$el.dispatchEvent(new MouseEvent(event.type, event));
},

onFrameInnerDragOver(event: DragEvent): void {
// Prevent frame to capture 'dragover' event (it is impossible to catch \
// for a parent if capture is not prevented there)
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { App } from "vue";
import VueClickAway from "vue3-click-away";
import VueHotkey from "v-hotkey3";
import VResizable from "v-resizable";

Check failure on line 15 in src/bootstrap/plugins.ts

View workflow job for this annotation

GitHub Actions / test

Could not find a declaration file for module 'v-resizable'. '/home/runner/work/prose-app-web/prose-app-web/node_modules/v-resizable/dist/index.js' implicitly has an 'any' type.

// PROJECT: UTILITIES
import logger from "@/utilities/logger";
Expand All @@ -28,6 +29,7 @@ class BootstrapPlugins {
// Vue directives
app.use(VueClickAway);
app.use(VueHotkey);
app.use(VResizable);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/views/app/AppBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<template lang="pug">
.v-app-base
app-sidebar(
v-resizable.r="{ minWidth: 220, maxWidth: 300, handleWidth: 8 }"
class="v-app-base__sidebar"
)

Expand Down Expand Up @@ -50,6 +51,9 @@ $c: ".v-app-base";
border-inline-end: 1px solid rgb(var(--color-border-secondary));
width: $size-sidebar-default-width;
flex: 0 0 auto;

// Hack: prevent v-resizable directive from applying its absolute position
position: relative !important;
}

#{$c}__content {
Expand Down

0 comments on commit b94eb30

Please sign in to comment.