Skip to content

Commit

Permalink
improve content layout, change bg image
Browse files Browse the repository at this point in the history
going to start filling in the "content" pages so want a standard way of doing this. extracting strings can leave room for Intl if we want to do that down the road

sharing the structured text logic that was roughed in in the Post component with the content pages for use in strings.json
  • Loading branch information
sterlingwes committed Jan 31, 2024
1 parent 8ac971c commit 953a1d6
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 166 deletions.
Binary file added site/public/fonts/PTSerif-Regular.ttf
Binary file not shown.
Binary file added site/public/gaza-drone.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed site/public/gaza_wapo.jpeg
Binary file not shown.
17 changes: 17 additions & 0 deletions site/src/components/ContentBox.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
---

<div class="content-box">
<slot />
</div>
<style>
.content-box {
background-color: rgba(0, 0, 0, 50%);
margin-bottom: 2rem;
border: 1px solid rgba(255, 255, 255, 25%);
padding: 1.5rem;
border-radius: 8px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 50%);
}
</style>
34 changes: 3 additions & 31 deletions site/src/components/Post.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import PostTypeIcon from "../components/PostTypeIcon.astro";
import StructuredText from "./StructuredText.astro";
import type { getEnhancedPosts } from "../lib/server/posts";
interface Props {
Expand Down Expand Up @@ -28,19 +29,7 @@ const { post, postDelayLookup, enablerImageUrl } = Astro.props;
{
post.structuredText.length > 0 && (
<div class="post-body">
{post.structuredText.map((part) =>
part.type === "url" ? (
<a href={part.href} title={part.href} target="_blank">
{part.text}
</a>
) : part.type === "space" ? (
<span>&nbsp;</span>
) : part.type === "break" ? (
<div class="post-linebreak" />
) : (
part.text
)
)}
<StructuredText parts={post.structuredText} />
</div>
)
}
Expand All @@ -59,19 +48,7 @@ const { post, postDelayLookup, enablerImageUrl } = Astro.props;
<div class="post-quoted-body">
{post.structuredQuoteText.length > 0 && (
<div class="post-body">
{post.structuredQuoteText.map((part) =>
part.type === "url" ? (
<a href={part.href} title={part.href} target="_blank">
{part.text}
</a>
) : part.type === "space" ? (
<span>&nbsp;</span>
) : part.type === "break" ? (
<div class="post-linebreak" />
) : (
part.text
)
)}
<StructuredText parts={post.structuredQuoteText} />
</div>
)}
</div>
Expand Down Expand Up @@ -189,11 +166,6 @@ const { post, postDelayLookup, enablerImageUrl } = Astro.props;
overflow: hidden;
}

.post-linebreak {
display: block;
margin-bottom: 10px;
}

.post-image img,
.post-quoted-image img {
max-width: 100%;
Expand Down
43 changes: 43 additions & 0 deletions site/src/components/StructuredText.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
import type { StructuredText } from "../lib/shared/structured-text";
interface Props {
parts: StructuredText[];
}
const { parts } = Astro.props;
---

<span>
{
parts.map((part) =>
part.type === "url" ? (
<a href={part.href} title={part.href} target="_blank">
{part.text}
</a>
) : part.type === "space" ? (
<span>&nbsp;</span>
) : part.type === "break" ? (
<span class="linebreak" />
) : part.type === "para" ? (
<p>{part.text}</p>
) : (
part.text
)
)
}
</span>

<style>
p {
margin: 0;
margin-bottom: 2rem;
}
p:last-of-type {
margin-bottom: 0;
}
.linebreak {
display: block;
margin-bottom: 10px;
}
</style>
72 changes: 72 additions & 0 deletions site/src/layouts/ContentPageLayout.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
import OpacityOverlay from "../components/OpacityOverlay.astro";
interface Props {
title: string;
clip?: boolean;
}
const { title, clip } = Astro.props;
---

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<title>{title}</title>
</head>
<body class={clip ? "clip" : undefined}>
<OpacityOverlay />
<main>
<div class="content">
<h1>{title}</h1>
<slot />
</div>
</main>
</body>
</html>
<style is:global>
html {
font-family: system-ui, sans-serif;
background: rgb(28, 14, 14);
min-height: 100vh;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-image: url("/gaza-drone.jpeg");
background-attachment: fixed;
}
@font-face {
font-family: "PTSerif";
src: url("/fonts/PTSerif-Regular.ttf") format("ttf");
font-weight: normal;
font-style: normal;
font-display: swap;
}

main {
margin: auto;
padding: 1rem;
width: 800px;
max-width: calc(100% - 2rem);
color: white;
font-size: 20px;
line-height: 1.6;
}
.content {
position: relative;
z-index: 1;
color: rgba(255, 255, 255, 80%);
}
h1 {
font-family: "PTSerif";
font-size: 3rem;
font-weight: 700;
line-height: 1;
text-align: center;
margin-bottom: 1em;
}
</style>
File renamed without changes.
6 changes: 6 additions & 0 deletions site/src/lib/constants/strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mission_statement": {
"type": "text",
"text": "This website seeks to collect public statements from those supporting Israel's strategy of mass displacement, starvation, and murder of Palestinian people, and to contrast those statements with the human toll of that inhumane campaign."
}
}
9 changes: 9 additions & 0 deletions site/src/lib/constants/strings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { StructuredText } from "../shared/structured-text";
import strings from "./strings.json";

export const getString = (key: keyof typeof strings) => {
if (!strings[key]) {
throw new Error(`No match for string lookup by key: ${key}`);
}
return strings[key] as StructuredText;
};
7 changes: 1 addition & 6 deletions site/src/lib/server/posts.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { parseISO, format } from "date-fns";
import readingTime from "reading-time";
import type { EnablerPost } from "../../schemas/enabler";
import type { StructuredText } from "../shared/structured-text";

const orderEarliestToLatest = (posts: EnablerPost[]) => {
return posts.slice(0).sort((a, b) => {
return parseISO(a.date).valueOf() - parseISO(b.date).valueOf();
});
};

type StructuredText =
| { type: "text"; text: string }
| { type: "url"; text: string; href: string }
| { type: "space" }
| { type: "break" };

const naiveSingleUrlMatcher = /\s+(http[^\s]+)\s+/;

const formatDisplayUrl = (url: string) => {
Expand Down
6 changes: 6 additions & 0 deletions site/src/lib/shared/structured-text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type StructuredText =
| { type: "text"; text: string }
| { type: "para"; text: string }
| { type: "url"; text: string; href: string }
| { type: "space" }
| { type: "break" };
70 changes: 6 additions & 64 deletions site/src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -1,68 +1,10 @@
---
import Layout from "../layouts/Layout.astro";
import OpacityOverlay from "../components/OpacityOverlay.astro";
import Layout from "../layouts/ContentPageLayout.astro";
import ContentBox from "../components/ContentBox.astro";
---

<Layout title="genocide.club">
<main>
<OpacityOverlay />
<div class="content">
<h1>404 : genocide club</h1>
<div class="about-text">
<p>Page not found.</p>
</div>
<div class="about-text">
<p>
This website seeks to collect public statements from those supporting
Israel's strategy of mass displacement, starvation, and murder of the
Palestinian people, and to contrast those statements with the human
toll of that horrific campaign.
</p>
<p>
An individual or group does not have to explicitly call for these
specific brutal acts to be a member of the Genocide Club. Simple
indifference to the plight of Palestinians while unquestioningly
supporting Israel's campaign is enough to implicitly condone those
actions and the resulting effects.
</p>
</div>
</div>
</main>
<Layout title="genocide.club • 404 Not Found">
<ContentBox>
<p>Sorry, the page you were looking for was not found.</p>
</ContentBox>
</Layout>

<style>
main {
margin: auto;
padding: 1rem;
width: 800px;
max-width: calc(100% - 2rem);
color: white;
font-size: 20px;
line-height: 1.6;
}
.content {
position: relative;
z-index: 1;
color: rgba(255, 255, 255, 80%);
}
h1 {
font-size: 3rem;
font-weight: 700;
line-height: 1;
text-align: center;
margin-bottom: 1em;
}
.about-text {
margin-bottom: 2rem;
border: 1px solid rgba(255, 255, 255, 25%);
padding: 1.5rem;
border-radius: 8px;
}
.about-text p {
margin: 0;
margin-bottom: 2rem;
}
.about-text p:last-of-type {
margin-bottom: 0;
}
</style>
8 changes: 4 additions & 4 deletions site/src/pages/[...enabler].astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { Enabler } from "../schemas/enabler";
import { getCollection } from "astro:content";
import Post from "../components/Post.astro";
import Layout from "../layouts/Layout.astro";
import PlayerLayout from "../layouts/PlayerLayout.astro";
import KilledGraph from "../generated/killed.astro";
import OpacityOverlay from "../components/OpacityOverlay.astro";
import PlayerControls from "../components/PlayerControls.astro";
Expand Down Expand Up @@ -37,7 +37,7 @@ const {
} = getTimeline({ svgDomain, posts });
---

<Layout clip title={`genocide.club • ${enabler.name}`}>
<PlayerLayout clip title={`genocide.club • ${enabler.name}`}>
<main>
<OpacityOverlay />
<div class="graph">
Expand Down Expand Up @@ -236,7 +236,7 @@ const {
<div class="scroll-bottom-fade"></div>
<PlayerControls />
</main>
</Layout>
</PlayerLayout>

<style define:vars={{ aspectRatio: svgDomain.aspectRatio }}>
@import url("https://fonts.googleapis.com/css2?family=Martian+Mono:wght@400;600;700&display=swap");
Expand All @@ -249,7 +249,7 @@ const {
aspect-ratio: var(--aspectRatio);
background-size: cover;
background-repeat: no-repeat;
background-image: url("/gaza_wapo.jpeg");
background-image: url("/gaza-drone.jpeg");
overflow: hidden;
}

Expand Down
Loading

0 comments on commit 953a1d6

Please sign in to comment.