Skip to content

Commit 1fdbcfe

Browse files
author
DavidQ
committed
`fix(theme-header): auto-expand Header and Intro on external fullscreen exit
- listen for document fullscreenchange in shared header mount logic - when fullscreen ends and Header and Intro is collapsed, reopen it automatically - keeps accordion/fullscreen state consistent when exiting via browser UI or system-level fullscreen exit paths (not only in-app toggle)`
1 parent 278c166 commit 1fdbcfe

2 files changed

Lines changed: 136 additions & 0 deletions

File tree

tools/shared/platformShell.css

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,39 @@ body.tools-platform-surface .right-sidebar {
549549
background: var(--tools-shell-glass);
550550
}
551551

552+
body.tools-platform-surface .panel-accordion {
553+
margin: 0 0 12px;
554+
border: 1px solid var(--line, rgba(221, 214, 254, 0.26));
555+
border-radius: 10px;
556+
background: linear-gradient(180deg, var(--panel, rgba(76, 29, 149, 0.88)) 0%, var(--panel2, rgba(49, 17, 102, 0.94)) 100%);
557+
overflow: hidden;
558+
}
559+
560+
body.tools-platform-surface .panel-accordion__summary {
561+
list-style: none;
562+
cursor: pointer;
563+
padding: 10px;
564+
border-bottom: 1px solid transparent;
565+
}
566+
567+
body.tools-platform-surface .panel-accordion__summary::-webkit-details-marker {
568+
display: none;
569+
}
570+
571+
body.tools-platform-surface .panel-accordion__summary h2,
572+
body.tools-platform-surface .panel-accordion__summary h3,
573+
body.tools-platform-surface .panel-accordion__summary h4 {
574+
margin: 0;
575+
}
576+
577+
body.tools-platform-surface .panel-accordion[open] .panel-accordion__summary {
578+
border-bottom-color: var(--line, rgba(221, 214, 254, 0.26));
579+
}
580+
581+
body.tools-platform-surface .panel-accordion__body {
582+
padding: 10px;
583+
}
584+
552585
body.tools-platform-surface .panel,
553586
body.tools-platform-surface .dock,
554587
body.tools-platform-surface .card {
@@ -639,6 +672,45 @@ body.tools-platform-surface .app > .toolbar:first-child {
639672
border-top: 1px solid var(--surface-border, rgba(221, 214, 254, 0.22));
640673
}
641674

675+
html:fullscreen body.tools-platform-surface {
676+
height: 100dvh;
677+
overflow: hidden;
678+
display: flex;
679+
flex-direction: column;
680+
}
681+
682+
html:fullscreen body.tools-platform-surface > .is-collapsible,
683+
html:fullscreen body.tools-platform-surface > [data-tools-platform-status] {
684+
flex: 0 0 auto;
685+
}
686+
687+
html:fullscreen body.tools-platform-surface > .wrap,
688+
html:fullscreen body.tools-platform-surface > .app-shell,
689+
html:fullscreen body.tools-platform-surface > .app {
690+
flex: 1 1 auto;
691+
min-height: 0 !important;
692+
height: auto !important;
693+
margin-bottom: 8px;
694+
}
695+
696+
html:fullscreen body.tools-platform-surface .workspace,
697+
html:fullscreen body.tools-platform-surface .canvas-shell,
698+
html:fullscreen body.tools-platform-surface .canvas-wrap,
699+
html:fullscreen body.tools-platform-surface .preview-wrap,
700+
html:fullscreen body.tools-platform-surface .left-sidebar,
701+
html:fullscreen body.tools-platform-surface .right-sidebar,
702+
html:fullscreen body.tools-platform-surface .sidebar,
703+
html:fullscreen body.tools-platform-surface .rightbar {
704+
min-height: 0;
705+
}
706+
707+
html:fullscreen body.tools-platform-surface .left-sidebar,
708+
html:fullscreen body.tools-platform-surface .right-sidebar,
709+
html:fullscreen body.tools-platform-surface .sidebar.visible-overlay,
710+
html:fullscreen body.tools-platform-surface .rightbar.visible-overlay {
711+
overflow-y: auto;
712+
}
713+
642714
body.tools-howto-page {
643715
min-height: 100vh;
644716
min-height: 100dvh;

tools/shared/platformShell.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,69 @@ function bindWorkspaceShellEvents(currentTool) {
485485
});
486486
}
487487

488+
function asHeadingElement(element) {
489+
if (!(element instanceof HTMLElement)) {
490+
return null;
491+
}
492+
const tag = element.tagName.toUpperCase();
493+
if (tag === "H2" || tag === "H3" || tag === "H4") {
494+
return element;
495+
}
496+
return null;
497+
}
498+
499+
function convertPanelToAccordion(panelElement) {
500+
if (!(panelElement instanceof HTMLElement)) {
501+
return null;
502+
}
503+
const heading = asHeadingElement(panelElement.querySelector(":scope > h2, :scope > h3, :scope > h4"));
504+
const titleText = heading?.textContent?.trim() || "Panel";
505+
const summaryHeadingTag = heading?.tagName?.toLowerCase() || "h3";
506+
507+
const accordion = document.createElement("details");
508+
accordion.className = "panel-accordion";
509+
const summary = document.createElement("summary");
510+
summary.className = "panel-accordion__summary";
511+
summary.innerHTML = `<${summaryHeadingTag}>${escapeHtml(titleText)}</${summaryHeadingTag}>`;
512+
513+
const body = document.createElement("div");
514+
body.className = "panel-accordion__body";
515+
516+
if (heading && heading.parentElement === panelElement) {
517+
heading.remove();
518+
}
519+
while (panelElement.firstChild) {
520+
body.appendChild(panelElement.firstChild);
521+
}
522+
accordion.append(summary, body);
523+
panelElement.replaceWith(accordion);
524+
return accordion;
525+
}
526+
527+
function applySidebarAccordionRules() {
528+
if (getPageMode() !== "tool") {
529+
return;
530+
}
531+
const sidebars = queryAll(".tools-platform-resize-panel");
532+
sidebars.forEach((sidebar) => {
533+
if (!(sidebar instanceof HTMLElement)) {
534+
return;
535+
}
536+
537+
const directPanelElements = Array.from(sidebar.children).filter((child) =>
538+
child instanceof HTMLElement && (child.matches("section.panel") || child.matches("div.panel"))
539+
);
540+
directPanelElements.forEach((panelElement) => {
541+
convertPanelToAccordion(panelElement);
542+
});
543+
544+
const accordions = Array.from(sidebar.querySelectorAll(":scope > details.panel-accordion"));
545+
accordions.forEach((accordion, index) => {
546+
accordion.open = index === 0;
547+
});
548+
});
549+
}
550+
488551
function renderShell(currentTool) {
489552
const headerHost = queryFirst("[data-tools-platform-header]");
490553
const statusHost = queryFirst("[data-tools-platform-status]");
@@ -513,6 +576,7 @@ function renderShell(currentTool) {
513576
statusHost.innerHTML = renderStatusMarkup(currentTool);
514577
}
515578

579+
applySidebarAccordionRules();
516580
bindWorkspaceShellEvents(currentTool);
517581
}
518582

0 commit comments

Comments
 (0)