Skip to content

Commit

Permalink
Resize composeWindow when contents change (#18)
Browse files Browse the repository at this point in the history
* Resize composeWindow when contents change

Before we used a fixed height window with a transparent background to
mimic resizing the window. This lead to problems with box shadows
showing up behind the full height window and the transparent part not
being clickable.

This new approach resizes the composeWindow to fit the contents.

* Bump version number to 1.4.7
  • Loading branch information
marckohlbrugge authored Oct 27, 2020
1 parent a065248 commit 04f1b1e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "WIP",
"description": "Menubar app for WIP",
"version": "1.4.6",
"version": "1.4.7",
"author": "Marc Köhlbrugge <[email protected]>",
"bugs": {
"url": "https://github.com/marckohlbrugge/wip-menubar/issues"
Expand Down
8 changes: 6 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,13 @@ app.on('ready', () => {
function createComposeWindow() {
composeWindow = new BrowserWindow({
width: 600,
height: 300,
height: 54,
frame: false,
show: false,
resizable: false,
maximizable: false,
minimizable: false,
fullscreenable: false,
transparent: true,
alwaysOnTop: true,
webPreferences: {
devTools: true,
Expand Down Expand Up @@ -562,6 +561,10 @@ app.on('ready', () => {
}
}

async function resize(event, height) {
composeWindow.setSize(600, height)
}

async function resetOAuth() {
logger.log('resetOAuth()');

Expand Down Expand Up @@ -625,6 +628,7 @@ app.on('ready', () => {
ipcMain.on('completeTodo', completeTodo);
ipcMain.on('resetOAuth', resetOAuth);
ipcMain.on('onlineStatusChanged', onlineStatusChange);
ipcMain.on('resize', resize);

if (!store.get('oauth.access_token')) {
// Ask user to connect
Expand Down
5 changes: 2 additions & 3 deletions src/compose/compose.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
html, body {
background: transparent;
background: black;
}

/* Hide scrollbar on Linux */
Expand All @@ -9,7 +9,6 @@ body::-webkit-scrollbar {

main {
-webkit-user-select: none;
background: black;
border-radius: 0.4em;
position: relative;
}
Expand Down Expand Up @@ -62,7 +61,6 @@ main.expanded {

.dropdown-menu {
padding-top: 0;
border-top: 1px #222 solid;
}

.autocomplete .dropdown-content {
Expand All @@ -73,6 +71,7 @@ main.expanded {
border-bottom-left-radius: 0.2rem;
border-bottom-right-radius: 0.2rem;
overflow: hidden;
border-top: 1px #222 solid;
}

.dropdown-item {
Expand Down
1 change: 1 addition & 0 deletions src/compose/compose.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
:icon="icon"
icon-pack="custom"
:placeholder="placeholder"
dropdown-position="bottom"
@keyup.native="keydown"
@keydown.native.enter="submitForm"
@drop.native="drop"
Expand Down
15 changes: 15 additions & 0 deletions src/compose/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,18 @@ const example = {

const app = new Vue(example);
app.$mount('#app');

resize();

function resize() {
let containerHeight = document.querySelector(".container").offsetHeight;
let dropdownHeight = document.querySelector(".dropdown-menu").offsetHeight;

let totalHeight = containerHeight + dropdownHeight;

ipc.send('resize', totalHeight);
}

const resizeObserver = new ResizeObserver(resize, { box : 'border-box' })
resizeObserver.observe(document.querySelector(".dropdown-menu"))
resizeObserver.observe(document.querySelector(".container"))

0 comments on commit 04f1b1e

Please sign in to comment.