Skip to content

Commit

Permalink
Better title handling for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Jul 9, 2023
1 parent 521c09b commit f9e247d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/GuideShell.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
border-radius: 8px;
margin: 5px;
}

/* Taken from Bulma */

.navbarBurger > span {
Expand Down Expand Up @@ -97,6 +98,18 @@
max-width: 100%;
}


.pageTitle {
display: flex;
border-bottom: calc(1px * var(--gui-scale)) solid var(--color-header1-separator);
}

.pageTitle > h1 {
border: none;
margin: 0;
align-self: center;
}

.main > article {
padding: calc(5px * var(--gui-scale));
background-color: #33333380;
Expand All @@ -117,6 +130,10 @@
grid-template-rows: max-content max-content 1fr max-content;
}

.pageTitle {
display: none;
}

:global(:root) {
--document-rect-margin: 0 !important;
}
Expand All @@ -131,6 +148,7 @@
.main.menuExpanded > aside, .main.menuExpanded > .versionPicker {
display: initial;
}

/* but then hide the article... */
.main.menuExpanded > article {
display: none;
Expand All @@ -142,4 +160,8 @@
.main .navbarBurger {
display: none;
}

:global(.inlinePageTitle) {
display: none;
}
}
2 changes: 1 addition & 1 deletion src/GuideShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function GuideShell() {
<span aria-hidden="true"></span>
</a>
</div>
<div>{pageTitle}</div>
<div className={css.pageTitle}>{pageTitle}</div>
<aside onClick={() => setMenuExpanded(false)}>
<GuideNavBar />
</aside>
Expand Down
14 changes: 13 additions & 1 deletion src/page-compiler/compilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,19 @@ export function compilePage(
if (child.type === "heading") {
if (child.depth === 1) {
title = compileHeading(context, child);
clonedRoot.children.splice(i, 1);
// Wrap the existing heading such that it can be re-enabled for mobile clients
clonedRoot.children[i] = {
type: "mdxJsxFlowElement",
name: "div",
attributes: [
{
type: "mdxJsxAttribute",
name: "className",
value: "inlinePageTitle",
},
],
children: [child],
};
}
break;
}
Expand Down

0 comments on commit f9e247d

Please sign in to comment.