Skip to content

fix(demo): make the page responsive and follow the theme control - #59

Open
sidgaikwad wants to merge 1 commit into
unlayer:mainfrom
sidgaikwad:fix/demo-responsive-and-theme
Open

fix(demo): make the page responsive and follow the theme control#59
sidgaikwad wants to merge 1 commit into
unlayer:mainfrom
sidgaikwad:fix/demo-responsive-and-theme

Conversation

@sidgaikwad

Copy link
Copy Markdown
Contributor

Fixes #39.

1. The demo was not responsive

styles.css contained no @media query at all. .sidebar was a hard width: 240px; flex-shrink: 0, so on a 375px phone the editor got ~135px — and because useState(true) opened the sidebar by default, the first paint on mobile was the broken one.

Before (375×812): sidebar occupied ~64% of the viewport, the editor was a sliver, and the editor's own Save/Cancel controls were off-screen entirely.

After (same viewport): sidebar starts closed, editor gets the full 375px, tool rail and Save/Cancel all reachable.

Below 768px the sidebar now overlays the editor (position: absolute, min(280px, 85vw)) with a dismissable backdrop, rather than squeezing it. App.tsx starts it closed at those widths via matchMedia, keyed to the same breakpoint.

Measured in the running demo:

375×812 1280×800
sidebar open by default false true
sidebar position absolute (overlay) static (in flow)
editor width, sidebar closed 375
editor width, sidebar open 375 (unchanged — overlaid) 1040
backdrop shown display: none

Desktop layout is unchanged.

2. The theme control didn't theme the page

The Light/Dark selector drove options.theme, but the surrounding page was hardcoded — html/body light, .topbar and .sidebar dark, .preview white. Switching to dark gave a dark editor inside light chrome; switching to light still left a permanently dark sidebar. Since the demo is what people look at to judge whether theming works, it undersold it.

All chrome colours now come from CSS custom properties keyed off a data-theme attribute that App.tsx sets from the same theme state the editor receives:

themeAttr:  light  ->  dark
body bg:    rgb(255,255,255)  ->  rgb(15,17,21)
topbar bg:  follows to rgb(22,24,29)

Verification

Ran against the live demo at both viewports; tsc --noEmit and vite build clean; Prettier clean.

Two problems, both in the demo's own chrome.

styles.css had no @media query at all. The sidebar was a hard 240px that
could not shrink, so on a 375px phone the editor got ~135px and the
editor's own Save/Cancel controls were off-screen entirely. The sidebar
now overlays the editor below 768px with a dismissable backdrop, and
App.tsx starts it closed at those widths via matchMedia.

The Light/Dark control drove options.theme but the page around it was
hardcoded: html/body light, topbar and sidebar dark, preview card white.
Switching to dark produced a dark editor in light chrome, and switching to
light still left a permanently dark sidebar. All chrome colours now come
from CSS custom properties keyed off a data-theme attribute that App.tsx
sets from the same theme state the editor gets.

Verified at 375x812 and 1280x800.
@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

@sidgaikwad is attempting to deploy a commit to the Unlayer Team on Vercel.

A member of the Team first needs to authorize it.

@ivoIturrieta

Copy link
Copy Markdown
Collaborator

In landscape mobile view, the saved preview grows taller than the viewport and its Close/Download controls disappear above the screen. Please constrain the preview height and keep its header accessible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

demo: not responsive on mobile, and the page chrome ignores the theme toggle

2 participants