Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have the width of left and right panels respond to browser size #793

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/fontra/views/editor/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as html from "/core/unlit.js";
import { clamp } from "../../core/utils.js";

const MIN_SIDEBAR_WIDTH = 200;
const MAX_SIDEBAR_WIDTH = 500;
const MIN_SIDEBAR_WIDTH = 20;
const MAX_SIDEBAR_WIDTH = 40;

export default class Sidebar {
constructor(identifier) {
Expand Down Expand Up @@ -108,8 +108,10 @@ export default class Sidebar {
width = initialWidth + (event.clientX - initialPointerCoordinateX);
cssProperty = "--sidebar-content-width-left";
}
const vw1 = window.innerWidth / 100;
width = width / vw1;
width = clamp(width, MIN_SIDEBAR_WIDTH, MAX_SIDEBAR_WIDTH);
document.documentElement.style.setProperty(cssProperty, `${width}px`);
document.documentElement.style.setProperty(cssProperty, `${width}vw`);
}
};
const onPointerUp = () => {
Expand Down Expand Up @@ -145,7 +147,7 @@ export default class Sidebar {
}
document.documentElement.style.setProperty(
`--sidebar-content-width-${this.identifier}`,
`${width}px`
`${width}vw`
);
}
}
Expand Down