Skip to content

Commit

Permalink
Decompose layouts a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Dec 29, 2024
1 parent 8d4cfa0 commit 68df423
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 34 deletions.
15 changes: 15 additions & 0 deletions src/components/PageContainer.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
import Footer from './Footer.astro'
import Header from './Header.astro'
---

<div id="main">
<Header />
<div id="page">
<div class="page-title">
<h1>{Astro.props.pageTitle}</h1>
</div>
<div class="page-body"><slot /></div>
</div>
<Footer />
</div>
17 changes: 1 addition & 16 deletions src/layouts/Layout.astro → src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
import Footer from '@/components/Footer.astro'
import Header from '@/components/Header.astro'
import '../styles/main.css'
let { pageTitle } = Astro.props
Expand Down Expand Up @@ -52,20 +50,7 @@ if (pageTitle) {
` : `` } -->
</head>
<body>
<!-- Figure out if this styling for main and it's wrapper is necessary -->
<!-- <style>
:host {
display: flex;
flex-direction: column;
min-height: 100vh;
}
#main {
flex: 1;
}
</style> -->
<Header />
<div id="main"><slot /></div>
<Footer />
<slot />
<script
src="https://kit.fontawesome.com/95fd764ad0.js"
crossorigin="anonymous"
Expand Down
15 changes: 6 additions & 9 deletions src/layouts/PageLayout.astro
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
---
import Layout from '@/layouts/Layout.astro'
const { pageTitle } = Astro.props
import PageContainer from '@/components/PageContainer.astro'
import Layout from '@/layouts/BaseLayout.astro'
---

<Layout pageTitle={pageTitle}>
<div id="page">
<div class="page-title">
<h1>{pageTitle}</h1>
</div>
<div class="page-body"><slot /></div>
</div>
<Layout pageTitle={Astro.props.pageTitle}>
<PageContainer pageTitle={Astro.props.pageTitle}>
<slot />
</PageContainer>
</Layout>
13 changes: 7 additions & 6 deletions src/pages/events/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import type { InferGetStaticPropsType, GetStaticPaths } from 'astro'
import { marked } from 'marked'
import { inflateEvent } from '@/utils/data'
import PageLayout from '@/layouts/PageLayout.astro'
import events from '@/data/events.json'
import BaseLayout from '@/layouts/BaseLayout.astro'
import PageContainer from '@/components/PageContainer.astro'
export const getStaticPaths = (async () => {
return events.map(event => ({ params: { id: event.id }, props: { event } }))
Expand Down Expand Up @@ -38,7 +39,7 @@ let location = event.location ?? null
// }
---

<PageLayout pageTitle={pageTitle}>
<BaseLayout pageTitle={pageTitle}>
<div id="email-container" class="container" hidden style={{ margin: '20px' }}>
<button id="copy-html-btn" type="button"> Copy HTML to clipboard </button>
<div id="html-contents">
Expand Down Expand Up @@ -118,7 +119,7 @@ let location = event.location ?? null
</div>
</div>

<div id="event-page-container">
<PageContainer pageTitle={pageTitle}>
{description && <p set:html={toHTML(description)} />}
{location && <p>{location}</p>}
{
Expand Down Expand Up @@ -184,8 +185,8 @@ let location = event.location ?? null
</div>
))
}
</div>
</PageLayout>
</PageContainer>
</BaseLayout>

<script>
import { initializeSwitch } from '@/scripts/queryParamSwitch'
Expand All @@ -200,6 +201,6 @@ let location = event.location ?? null

initializeSwitch([
['email', '#email-container'],
['', '#event-page-container'],
['', '#main'],
])
</script>
6 changes: 3 additions & 3 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import Layout from '@/layouts/Layout.astro'
import PageLayout from '@/layouts/PageLayout.astro'
import { Image } from 'astro:assets'
import Event from '@/components/Event.astro'
import Organizers from '@/components/Organizers.astro'
Expand All @@ -15,7 +15,7 @@ const TWELVE_HOURS = 1000 * 60 * 60 * 12
const futureEvents = [events.at(-1)]
---

<Layout pageTitle="SeattleJS">
<PageLayout pageTitle="SeattleJS">
<!-- <img
class="hero-image"
src="/_public/images/blank-seattlejs-header.png"
Expand Down Expand Up @@ -65,7 +65,7 @@ const futureEvents = [events.at(-1)]
<h2>Organizers</h2>
<Organizers />
</div>
</Layout>
</PageLayout>

<style>
.sponsors :global(div) {
Expand Down

0 comments on commit 68df423

Please sign in to comment.