Skip to content

Commit b6c6290

Browse files
committed
feat: enhance footer and MDX components with fluid layout and typography improvements
- Updated `Footer` component to support a fluid layout option, allowing it to use the parent column width. - Refactored `MDXProseWrapper` and `MDXProseSheetWrapper` to apply a custom font family for better typography. - Removed the deprecated `TinyAnalytics` component and adjusted styles accordingly. - Improved global CSS for prose font variables and Tinylytics icons.
1 parent 9647210 commit b6c6290

7 files changed

Lines changed: 139 additions & 117 deletions

File tree

src/components/client/MDX/MDX.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,24 @@ w-full max-w-full
3636
`;
3737

3838
export function MDXProseWrapper(props: { children: React.ReactNode }) {
39-
return <div className={proseClassName}>{props.children}</div>;
39+
return (
40+
<div
41+
className={proseClassName}
42+
style={{ fontFamily: "var(--prose-body-font-family)" }}
43+
>
44+
{props.children}
45+
</div>
46+
);
4047
}
4148
export function MDXProseSheetWrapper(props: { children: React.ReactNode }) {
42-
return <div className={proseClassName}>{props.children}</div>;
49+
return (
50+
<div
51+
className={proseClassName}
52+
style={{ fontFamily: "var(--prose-body-font-family)" }}
53+
>
54+
{props.children}
55+
</div>
56+
);
4357
}
4458

4559
export function Fields(props: { children: React.ReactNode }) {

src/components/server/Footer/Footer.tsx

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export function Footer(props: {
1212
theme?: ThemeType;
1313
size?: UI.ContainerProps["size"];
1414
maxWidth?: UI.ContainerProps["maxWidth"];
15+
fluid?: boolean; // when true, use parent column width instead of centered container
1516
}) {
1617
const [themeColorScheme, setThemeColorScheme] =
1718
useState<ThemeColorSchemeType>("system");
@@ -111,19 +112,54 @@ export function Footer(props: {
111112
}
112113
}
113114

114-
return (
115-
<Theme {...props.theme} hasBackground={false} className="min-h-0">
115+
const Wrapper = ({ children }: { children: any }) => {
116+
if (props.fluid) {
117+
return <div className="px-6 md:px-9">{children}</div>;
118+
}
119+
return (
116120
<UI.Container
117-
px={{
118-
initial: "6",
119-
md: "9",
120-
}}
121+
px={{ initial: "6", md: "9" }}
121122
size={props.size || "4"}
122123
maxWidth={props.maxWidth || undefined}
123124
>
125+
{children}
126+
</UI.Container>
127+
);
128+
};
129+
130+
return (
131+
<Theme
132+
{...props.theme}
133+
hasBackground={false}
134+
className="min-h-0"
135+
>
136+
<Wrapper>
124137
<div className="my-[10rem]">
125138
<MDXDivider />
126139
</div>
140+
{/* Tinylytics centered at top of footer */}
141+
<div
142+
className="mb-6 flex w-full justify-center px-4 md:px-0"
143+
style={{ fontFamily: "var(--default-font-family)" }}
144+
>
145+
<div
146+
aria-label="Page analytics and like"
147+
className="inline-flex items-center gap-2 rounded-full border border-black/10 dark:border-white/10 bg-white/80 dark:bg-neutral-900/80 backdrop-blur px-3.5 py-2 shadow-lg"
148+
>
149+
<span
150+
className="views-chip inline-flex items-center rounded-full border border-black/10 dark:border-white/10 bg-black/5 dark:bg-white/10 px-3 py-1.5 text-xs leading-none text-neutral-800 dark:text-neutral-200"
151+
>
152+
<span className="tinylytics_hits tabular-nums"></span>
153+
</span>
154+
<button
155+
className="tinylytics_kudos tabular-nums cursor-pointer relative inline-flex items-center rounded-full bg-gradient-to-r from-rose-500 to-orange-500 px-3 py-1.5 text-white text-xs leading-none font-medium shadow hover:shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-rose-500 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-neutral-900"
156+
type="button"
157+
aria-label="Like this page"
158+
>
159+
-
160+
</button>
161+
</div>
162+
</div>
127163
<div className="flex items-start justify-between gap-9">
128164
{Object.entries(links).map(([category, links]) => (
129165
<div className="flex flex-col items-start gap-2" key={category}>
@@ -137,12 +173,13 @@ export function Footer(props: {
137173
))}
138174
</div>
139175

140-
<div className="my-[5rem] flex items-center justify-between gap-2">
141-
<div className="flex items-center gap-2">
176+
<div className="my-[5rem] flex flex-col items-center justify-center gap-3 text-center md:flex-row md:items-center md:justify-between md:gap-2 md:text-left">
177+
<div className="flex flex-wrap items-center justify-center gap-2">
142178
<a href="https://www.netlify.com" target="_blank">
143179
<img
144180
src="https://www.netlify.com/v3/img/components/netlify-color-accent.svg"
145181
alt="Deploys by Netlify"
182+
className="h-6 w-auto"
146183
/>
147184
</a>
148185
<Text>
@@ -152,9 +189,11 @@ export function Footer(props: {
152189
</Link>
153190
</Text>
154191
</div>
155-
<div>{renderThemeToggleButton()}</div>
192+
<div className="flex justify-center">{renderThemeToggleButton()}</div>
156193
</div>
157-
</UI.Container>
194+
195+
196+
</Wrapper>
158197
</Theme>
159198
);
160199

src/components/server/Header/Header.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ import { wait } from "../../../domains/utils/wait";
3434
import { getSurfaceStyle } from "../../client/Surface/getSurfaceStyle";
3535
import { NameLogo } from "./Logo";
3636

37-
const fontFamily =
38-
"-apple-system, BlinkMacSystemFont, 'Segoe UI (Custom)', Roboto, 'Helvetica Neue', 'Open Sans (Custom)', system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'";
39-
4037
export function Header(props: { theme: ThemeType; pathname: string }) {
4138
const [open, setOpen] = useState(false);
4239

@@ -191,7 +188,6 @@ export function Header(props: { theme: ThemeType; pathname: string }) {
191188
className="bg-transparent hover:bg-(--accent-3) dark:hover:bg-(--accent-6)"
192189
color="gray"
193190
highContrast
194-
style={{ fontFamily }}
195191
>
196192
{params.icon}
197193
</Button>
@@ -202,7 +198,6 @@ export function Header(props: { theme: ThemeType; pathname: string }) {
202198
className="bg-transparent hover:bg-(--accent-3) dark:hover:bg-(--accent-6)"
203199
color="gray"
204200
highContrast
205-
style={{ fontFamily }}
206201
>
207202
{params.label}
208203
</Button>

src/components/server/TinyAnalytics/TinyAnalytics.astro

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/layouts/Layout.astro

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { Colors } from "../domains/colors/colors";
1212
import { DLAstro } from "../domains/dl/DLAstro";
1313
import { getTheme, type ThemeType } from "../domains/utils/getTheme";
1414
import PostHog from "../components/server/PostHog/PostHog.astro";
15-
import TinyAnalytics from "../components/server/TinyAnalytics/TinyAnalytics.astro";
1615
import "../styles/global.css";
1716
import { UI } from "../components/ui/ui";
1817
import { AppUrl } from "../domains/app-url/AppUrl";
@@ -223,30 +222,13 @@ const ogImageUrl = AppUrl.ogImage({
223222
</UI.Container>
224223

225224
<PostHog />
226-
<TinyAnalytics />
227225
</body>
228226

229-
<style
230-
is:global
231-
define:vars={{
232-
headingFont,
233-
bodyFont,
234-
}}
235-
>
227+
<style is:global define:vars={{ headingFont, bodyFont }}>
228+
/* Prose-only custom variables. Do not override Radix font variables. */
236229
.radix-themes {
237-
/* FONTS */
238-
/* Your custom heading font */
239-
--heading-font-family: var(--headingFont);
240-
/* Your custom default font */
241-
--default-font-family: var(--bodyFont);
242-
/* Your custom font for <Code> components */
243-
--code-font-family: var(--bodyFont);
244-
/* Your custom font for <Strong> components */
245-
--strong-font-family: var(--bodyFont);
246-
/* Your custom font for <Em> components */
247-
--em-font-family: var(--bodyFont);
248-
/* Your custom font for <Quote> components */
249-
--quote-font-family: var(--bodyFont);
230+
--prose-body-font-family: var(--bodyFont);
231+
--prose-heading-font-family: var(--headingFont);
250232

251233
/* CURSORS */
252234
--cursor-button: pointer;

src/routes/ResourceRoute/ResourceRoute.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function ResourceRoute(props: {
139139
</div>
140140
</div>
141141
</div>
142-
<div className="flex flex-col min-w-0">
142+
<div className="flex flex-col min-w-0 relative">
143143
<div className="block w-full">
144144
<div className="flex flex-col">
145145
<div className="mb-6">{renderPatreonBanner()}</div>
@@ -161,24 +161,24 @@ export function ResourceRoute(props: {
161161
color="gray"
162162
/>
163163
<div className="mb-6 flex flex-col gap-2 sm:flex-row">
164-
<UI.Button
164+
<UI.Button
165165
variant="soft"
166166
color="gray"
167-
size="1"
167+
size="3"
168168
radius="full"
169169
onClick={handleCopyMarkdown}
170-
className="flex items-center gap-2"
170+
className="flex w-full items-center justify-center gap-2 sm:w-auto"
171171
>
172172
<Copy size={"1em"} />
173173
Copy as Markdown
174174
</UI.Button>
175-
<UI.Button
175+
<UI.Button
176176
variant="soft"
177177
color="gray"
178-
size="1"
178+
size="3"
179179
radius="full"
180180
onClick={handleDownloadMarkdown}
181-
className="flex items-center gap-2"
181+
className="flex w-full items-center justify-center gap-2 sm:w-auto"
182182
>
183183
<DownloadCloudIcon size={"1em"} />
184184
Download as Markdown
@@ -190,14 +190,14 @@ export function ResourceRoute(props: {
190190
})}
191191
target="_blank"
192192
rel="noopener noreferrer"
193-
className="flex items-center gap-2 no-underline"
193+
className="flex w-full items-center gap-2 no-underline sm:w-auto"
194194
>
195195
<UI.Button
196196
variant="soft"
197197
color="gray"
198-
size="1"
198+
size="3"
199199
radius="full"
200-
className="flex items-center gap-2"
200+
className="flex w-full items-center justify-center gap-2 sm:w-auto"
201201
>
202202
<GitHubLogoIcon width={"1.2em"} height={"1.2em"} />
203203
Edit on GitHub
@@ -218,7 +218,7 @@ export function ResourceRoute(props: {
218218
{renderPreviousAndNextButtons()}
219219
{renderEditButton()}
220220
</div>
221-
<Footer ogImageUrl={ogImageUrl} />
221+
<Footer ogImageUrl={ogImageUrl} fluid />
222222
</div>
223223
</div>
224224
</div>
@@ -281,7 +281,7 @@ export function ResourceRoute(props: {
281281

282282
function renderPatreonBanner() {
283283
return (
284-
<UI.Card size="2" variant="ghost">
284+
<UI.Card size="2" variant="ghost" style={{ fontFamily: "var(--default-font-family)" }}>
285285
<div className="flex flex-col items-center justify-between gap-4 p-4 sm:flex-row">
286286
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-center">
287287
<div className="relative">
@@ -456,7 +456,11 @@ export function ResourceRoute(props: {
456456

457457
function renderSidebar(p: { withImage?: boolean }) {
458458
return (
459-
<UI.Card variant="surface" className="flex flex-col gap-4">
459+
<UI.Card
460+
variant="surface"
461+
className="flex flex-col gap-4"
462+
style={{ fontFamily: "var(--default-font-family)" }}
463+
>
460464
<div className="flex flex-col gap-5">
461465
{props.image && p.withImage && (
462466
<div className="">

0 commit comments

Comments
 (0)