Skip to content

Commit

Permalink
feat(layout): fix for review comments
Browse files Browse the repository at this point in the history
* aside --> section
* header --> header + pageHeader
  • Loading branch information
vanadium23 committed Nov 30, 2024
1 parent 7c49f58 commit 232944a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
2 changes: 2 additions & 0 deletions quartz.layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const sharedPageComponents: SharedLayout = {

// components for pages that display a single page (e.g. a single note)
export const defaultContentPageLayout: PageLayout = {
pageHeader: [],
beforeBody: [
Component.Breadcrumbs(),
Component.ArticleTitle(),
Expand All @@ -38,6 +39,7 @@ export const defaultContentPageLayout: PageLayout = {

// components for pages that display lists of pages (e.g. tags or folders)
export const defaultListPageLayout: PageLayout = {
pageHeader: [],
beforeBody: [Component.Breadcrumbs(), Component.ArticleTitle(), Component.ContentMeta()],
left: [
Component.PageTitle(),
Expand Down
3 changes: 2 additions & 1 deletion quartz/cfg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface QuartzConfig {
export interface FullPageLayout {
head: QuartzComponent
header: QuartzComponent[]
pageHeader: QuartzComponent[]
beforeBody: QuartzComponent[]
pageBody: QuartzComponent
afterBody: QuartzComponent[]
Expand All @@ -93,5 +94,5 @@ export interface FullPageLayout {
footer: QuartzComponent
}

export type PageLayout = Pick<FullPageLayout, "beforeBody" | "left" | "right">
export type PageLayout = Pick<FullPageLayout, "pageHeader" | "beforeBody" | "left" | "right">
export type SharedLayout = Pick<FullPageLayout, "head" | "header" | "footer" | "afterBody">
2 changes: 1 addition & 1 deletion quartz/components/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clipboardStyle from "./styles/clipboard.scss"
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"

const Body: QuartzComponent = ({ children }: QuartzComponentProps) => {
return <div id="quartz-body">{children}</div>
return <main id="quartz-body">{children}</main>
}

Body.afterDOMLoaded = clipboardScript
Expand Down
3 changes: 1 addition & 2 deletions quartz/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"

const Header: QuartzComponent = ({ children }: QuartzComponentProps) => {
return children.length > 0 ? <header>{children}</header> : <header className={"empty"}></header>
return children.length > 0 ? <header>{children}</header> : null;
}

Header.css = `
header {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
padding: 1rem 2rem;
gap: 1.5rem;
}
Expand Down
19 changes: 13 additions & 6 deletions quartz/components/renderPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { i18n } from "../i18n"
interface RenderComponents {
head: QuartzComponent
header: QuartzComponent[]
pageHeader: QuartzComponent[]
beforeBody: QuartzComponent[]
pageBody: QuartzComponent
afterBody: QuartzComponent[]
Expand Down Expand Up @@ -191,6 +192,7 @@ export function renderPage(
const {
head: Head,
header,
pageHeader,
beforeBody,
pageBody: Content,
afterBody,
Expand All @@ -202,19 +204,19 @@ export function renderPage(
const Body = BodyConstructor()

const LeftComponent = (
<aside class="left sidebar">
<section class="left sidebar">
{left.map((BodyComponent) => (
<BodyComponent {...componentData} />
))}
</aside>
</section>
)

const RightComponent = (
<aside class="right sidebar">
<section class="right sidebar">
{right.map((BodyComponent) => (
<BodyComponent {...componentData} />
))}
</aside>
</section>
)

const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
Expand All @@ -230,8 +232,13 @@ export function renderPage(
</Header>
<Body {...componentData}>
{LeftComponent}
<main class="center">
<section class="center">
<div class="page-header">
<Header {...componentData}>
{pageHeader.map((HeaderComponent) => (
<HeaderComponent {...componentData} />
))}
</Header>
<div class="popover-hint">
{beforeBody.map((BodyComponent) => (
<BodyComponent {...componentData} />
Expand All @@ -245,7 +252,7 @@ export function renderPage(
<BodyComponent {...componentData} />
))}
</div>
</main>
</section>
{RightComponent}
<Footer {...componentData} />
</Body>
Expand Down
1 change: 1 addition & 0 deletions quartz/plugins/emitters/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const NotFoundPage: QuartzEmitterPlugin = () => {
const opts: FullPageLayout = {
...sharedPageComponents,
pageBody: NotFound(),
pageHeader: [],
beforeBody: [],
left: [],
right: [],
Expand Down
14 changes: 3 additions & 11 deletions quartz/styles/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,6 @@ a {
.page {
max-width: calc(#{map-get($breakpoints, desktop)} + 300px);
margin: 0 auto;
& header {
margin-top: 1rem;
margin-bottom: 1rem;
&.empty {
margin-top: 0;
margin-bottom: $topSpacing;
}
}

& article {
& > h1 {
Expand Down Expand Up @@ -191,7 +183,7 @@ a {
gap: 2rem;
top: 0;
box-sizing: border-box;
padding: 0 2rem 2rem 2rem;
padding: $topSpacing 2rem 2rem 2rem;
display: flex;
height: 100vh;
position: sticky;
Expand Down Expand Up @@ -241,8 +233,8 @@ a {
}

& .page-header {
grid-area: grid-before-body;
margin: 0 0 0 0;
grid-area: grid-page-header;
margin: $topSpacing 0 0 0;
@media all and ($mobile) {
margin-top: 0;
padding: 0;
Expand Down
6 changes: 3 additions & 3 deletions quartz/styles/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $mobileGrid: (
columnGap: "5px",
templateAreas:
'"grid-sidebar-left"\
"grid-before-body"\
"grid-page-header"\
"grid-center"\
"grid-sidebar-right"\
"grid-footer"',
Expand All @@ -39,7 +39,7 @@ $tabletGrid: (
rowGap: "5px",
columnGap: "5px",
templateAreas:
'"grid-sidebar-left grid-before-body"\
'"grid-sidebar-left grid-page-header"\
"grid-sidebar-left grid-center"\
"grid-sidebar-left grid-sidebar-right"\
"grid-sidebar-left grid-footer"',
Expand All @@ -50,7 +50,7 @@ $desktopGrid: (
rowGap: "5px",
columnGap: "5px",
templateAreas:
'"grid-sidebar-left grid-before-body grid-sidebar-right"\
'"grid-sidebar-left grid-page-header grid-sidebar-right"\
"grid-sidebar-left grid-center grid-sidebar-right"\
"grid-sidebar-left grid-footer grid-sidebar-right"',
);

0 comments on commit 232944a

Please sign in to comment.