Skip to content

Commit 697f0dc

Browse files
authored
fix: improve mobile layout and fix news layout (#216)
1 parent 81b8804 commit 697f0dc

File tree

6 files changed

+54
-42
lines changed

6 files changed

+54
-42
lines changed

src/components/BackButton/index.tsx

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,37 @@ import { Button } from "@/components/ui/button";
22
import type { ReactNode } from "react";
33
import { MdArrowBack } from "react-icons/md";
44

5-
export const BackButton = (props: { href: string; children?: ReactNode }) => {
5+
export const BackButton = (props: {
6+
href: string;
7+
buttonLabel?: ReactNode;
8+
contextLabel?: ReactNode;
9+
}) => {
610
return (
7-
<Button asChild variant="secondary-dark" size="xs">
8-
<a
9-
href={props.href}
10-
onClick={(e) => {
11-
if (
12-
window.history.length > 1 &&
13-
document.referrer.indexOf(window.location.host) !== -1
14-
) {
15-
e.preventDefault();
16-
window.history.back();
17-
}
18-
}}
19-
>
20-
<MdArrowBack className="mr-2" /> {props.children ?? "Back"}
21-
</a>
22-
</Button>
11+
<div className="flex items-center gap-4">
12+
<Button asChild variant="secondary-dark" size="xs">
13+
<a
14+
href={props.href}
15+
onClick={(e) => {
16+
if (
17+
window.history.length > 1 &&
18+
document.referrer.indexOf(window.location.host) !== -1
19+
) {
20+
e.preventDefault();
21+
window.history.back();
22+
}
23+
}}
24+
>
25+
<MdArrowBack className="mr-2" /> {props.buttonLabel ?? "Back"}
26+
</a>
27+
</Button>
28+
{!!props.contextLabel && (
29+
<a
30+
href={props.href}
31+
className="text-xs font-medium uppercase tracking-widest opacity-60 transition hover:opacity-100"
32+
>
33+
{props.contextLabel}
34+
</a>
35+
)}
36+
</div>
2337
);
2438
};

src/components/MainPageTitle/index.astro

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
import { Logo } from "@/components/Logo";
32
import ImageBackgroundHero from "@/components/ImageBackgroundHero/index.astro";
43
import type { ReactNode } from "react";
54
import defaultImage from "@/assets/images/events.jpeg";
@@ -20,9 +19,8 @@ const { title, subtitle, imageSrc } = Astro.props;
2019
/>
2120

2221
<div
23-
class="flex w-full flex-col items-center gap-12 pb-12 pt-20 md:min-h-[35svh] md:justify-center"
22+
class="flex w-full flex-col items-center gap-12 py-12 md:min-h-[35svh] md:justify-center"
2423
>
25-
<a href="/" class="md:hidden"><Logo className="w-48" /></a>
2624
<div class="flex flex-col items-center gap-2">
2725
<h1
2826
class="text-balance text-center font-heading text-3xl font-medium uppercase tracking-wider max-md:flex-1 md:text-5xl"

src/layouts/MainLayout.astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ import MainNavMobile from "@/components/MainNavMobile/MainNavMobile.astro";
44
import RootLayout from "@/layouts/RootLayout.astro";
55
66
import Footer from "@/components/Footer/index.astro";
7+
import { Logo } from "@/components/Logo";
78
---
89

910
<RootLayout>
1011
<slot name="seo" slot="seo" />
1112
<slot name="ld+json" slot="ld+json" />
1213
<MainNavDesktop />
14+
<div class="flex w-full items-center justify-center pb-4 pt-16 md:hidden">
15+
<a href="/"><Logo className="w-48" /></a>
16+
</div>
1317
<div class="flex flex-1 flex-col"><slot /></div>
1418
<Footer />
1519
<MainNavMobile />

src/pages/index.astro

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
getUpcomingMajorEvent,
99
} from "@/lib/events";
1010
import { getPodcastsEpisodesCollection } from "@/lib/podcasts";
11-
import { Logo } from "@/components/Logo";
1211
import { Image } from "astro:assets";
1312
import defaultImage from "@/assets/images/events.jpeg";
1413
import aboutBackground from "@/assets/images/about.jpg";
@@ -64,9 +63,6 @@ const afterMovie = (await getEntry("events", "2024-france-rouen"))?.data
6463
blur
6564
/>
6665
<div class="mx-auto w-full max-w-screen-xl px-4">
67-
<div class="flex w-full items-center justify-center pb-4 pt-20 md:hidden">
68-
<Logo className="w-48" />
69-
</div>
7066
<div
7167
class="relative flex w-full flex-col items-center gap-8 py-16 sm:flex-row sm:py-[12vh] md:px-8 xl:gap-12"
7268
>

src/pages/news/article/[id]/index.astro

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,21 @@ const ogImage = new URL(
5151
className="h-[80vh] opacity-80"
5252
blur
5353
/>
54+
<div
55+
class={cn(
56+
"mx-auto w-full max-w-screen-md px-8 md:px-12 py-6",
57+
article.data.featuredImage &&
58+
"max-w-screen-lg px-4 pb-4 sm:px-8 md:px-6 md:py-4",
59+
)}
60+
>
61+
<BackButton client:load href="/news" contextLabel="Fork It! News" />
62+
</div>
63+
5464
{
5565
!!article.data.featuredImage && (
56-
<div class="relative mx-auto mt-2 w-full max-w-screen-lg px-2 lg:mt-10 lg:px-6">
57-
<div class="absolute left-8 top-8 z-10 lg:left-14">
58-
<BackButton client:visible href="/news" />
59-
</div>
66+
<div class="relative mx-auto w-full max-w-screen-lg px-2 lg:px-6">
6067
<div
61-
class="relative flex-[10] rounded-lg bg-black transition duration-500 group-hover:scale-105"
68+
class="relative flex-1 rounded-lg bg-black transition duration-500"
6269
style={{
6370
maskImage: "linear-gradient(180deg, black 20%, transparent 100%)",
6471
}}
@@ -77,20 +84,13 @@ const ogImage = new URL(
7784
}
7885
<div
7986
class={cn(
80-
"mx-auto w-full flex-1 max-w-screen-md flex flex-col gap-12 pb-40 relative z-10 pt-24 px-8 md:px-12",
81-
!!article.data.featuredImage && "-mt-36 md:-mt-96",
87+
"mx-auto w-full flex-1 max-w-screen-md flex flex-col gap-8 pt-4 pb-40 relative z-10 px-8 md:px-12",
88+
!!article.data.featuredImage && "-mt-24 sm:-mt-56 md:-mt-72",
8289
)}
8390
>
8491
<div class="flex flex-col gap-4">
85-
{
86-
!article.data.featuredImage && (
87-
<div class="pb-8">
88-
<BackButton client:visible href="/news" />
89-
</div>
90-
)
91-
}
9292
<h1
93-
class="text-balance font-heading text-2xl font-medium uppercase tracking-wider md:text-4xl/tight"
93+
class="text-balance font-heading text-2xl font-medium tracking-wider md:text-4xl/tight"
9494
>
9595
{article.data.title}
9696
</h1>
@@ -104,7 +104,7 @@ const ogImage = new URL(
104104
</div>
105105

106106
{
107-
authors ? (
107+
authors.length ? (
108108
<div class="flex flex-wrap gap-x-5 gap-y-3">
109109
{authors.map((author) => (
110110
<a

src/pages/podcasts/[id]/episodes/[episode]/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ const ogImage = new URL(
107107
/>
108108

109109
<ImageBackgroundHero src={bg} alt="" className="h-[80vh] opacity-80" />
110-
<div class="mx-auto w-full max-w-screen-lg px-4 py-8">
111-
<BackButton client:load href="/podcasts" />
110+
<div class="mx-auto w-full max-w-screen-lg px-4 pb-4 pt-8">
111+
<BackButton client:load href="/podcasts" contextLabel="Fork It! Podcast" />
112112
</div>
113113

114114
<div class="mx-auto w-full max-w-screen-lg p-4 md:py-8">

0 commit comments

Comments
 (0)