Skip to content

Commit 2bf0d3e

Browse files
satnaingmiyayaLora
authored andcommitted
refactor: extract redundant max-width into utility (satnaing#525)
* refactor: extract redundant max-width into utility Extract redundant max-width into a universal tailwind utility class. By doing so, the width of the layout in different pages can be customized easily. * docs: update docs for modifying `max-w-app` utility (cherry picked from commit 5f72b93)
1 parent 2689666 commit 2bf0d3e

7 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/components/Breadcrumb.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (breadcrumbList[0] === "tags" && !isNaN(Number(breadcrumbList[2]))) {
2323
}
2424
---
2525

26-
<nav class="mx-auto mt-8 mb-1 w-full max-w-3xl px-4" aria-label="breadcrumb">
26+
<nav class="mx-auto mt-8 mb-1 w-full max-w-app px-4" aria-label="breadcrumb">
2727
<ul
2828
class="font-light [&>li]:inline [&>li:not(:last-child)>a]:hover:opacity-100"
2929
>

src/components/Hr.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export interface Props {
77
const { noPadding = false, ariaHidden = true } = Astro.props;
88
---
99

10-
<div class={`max-w-3xl mx-auto ${noPadding ? "px-0" : "px-4"}`}>
10+
<div class:list={["mx-auto max-w-app", noPadding ? "px-0" : "px-4"]}>
1111
<hr class="border-border" aria-hidden={ariaHidden} />
1212
</div>

src/data/blog/how-to-configure-astropaper-theme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ Here are SITE configuration options
7171
| `lang` | Used as HTML ISO Language code in `<html lang"en">`. Default is `en`. |
7272
| `timezone` | This option allows you to specify your timezone using the [IANA format](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). Setting this ensures consistent timestamps across your localhost and deployed site, eliminating time differences. |
7373

74+
## Update layout width
75+
76+
The default `max-width` for the entire blog is `768px` (`max-w-3xl`). If you'd like to change it, you can easily update the `max-w-app` utility in your `src/styles/global.css` file:
77+
78+
```css
79+
@utility max-w-app {
80+
@apply max-w-4xl xl:max-w-5xl;
81+
/* eg: max-w-4xl xl:max-w-5xl */
82+
}
83+
```
84+
85+
You can explore more `max-width` values in the [Tailwind CSS docs](https://tailwindcss.com/docs/max-width).
86+
7487
## Configuring logo or title
7588

7689
Prior to AstroPaper v5, you can update your site name/logo in `LOGO_IMAGE` object inside `src/config.ts` file. However, in AstroPaper v5, this option has been removed in favor of Astro's built-in SVG and Image components.

src/layouts/AboutLayout.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const { frontmatter } = Astro.props;
2424
</div>
2525
<section
2626
id="about"
27-
class="prose mb-28 max-w-3xl prose-img:border-0"
27+
class="prose mb-28 max-w-app prose-img:border-0"
2828
slot="main-body-slot"
2929
>
3030
<h1 class="text-2xl tracking-wider sm:text-3xl">{frontmatter.title}</h1>

src/layouts/Main.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const backUrl = SITE.showBackButton ? Astro.url.pathname : "/";
2525
<div
2626
data-backUrl={backUrl}
2727
id="main-content"
28-
class="mx-auto w-full max-w-3xl px-4 pb-4"
28+
class="mx-auto w-full max-w-app px-4 pb-4"
2929
>
3030
{
3131
"titleTransition" in props ? (

src/pages/404.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { SITE } from "@/config";
1313
>
1414
<h1 class="text-5xl font-bold text-accent md:text-9xl">404</h1>
1515
<span aria-hidden="true">¯\_(ツ)_/¯</span>
16-
<p class="mt-4 text-2xl md:text-3xl">Page Not Found</p>
16+
<p class="mt-4 text-2xl sm:text-3xl">Page Not Found</p>
1717
<LinkButton
1818
href="/"
1919
class="my-6 text-lg underline decoration-dashed underline-offset-8"

src/styles/global.css

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,29 @@ html[data-theme="dark"] {
4141
scrollbar-width: auto;
4242
scrollbar-color: var(--color-muted) transparent;
4343
}
44-
4544
html {
4645
@apply overflow-auto overscroll-auto scroll-smooth;
4746
}
48-
4947
body {
5048
@apply flex min-h-svh flex-col bg-background font-mono text-foreground selection:bg-accent/75 selection:text-background;
5149
}
52-
5350
a,
5451
button {
5552
@apply outline-offset-1 outline-accent focus-visible:no-underline focus-visible:outline-2 focus-visible:outline-dashed;
5653
}
57-
5854
button:not(:disabled),
5955
[role="button"]:not(:disabled) {
6056
cursor: pointer;
6157
}
62-
6358
section {
64-
@apply mx-auto max-w-3xl px-4;
59+
@apply mx-auto max-w-app px-4;
6560
}
6661
}
6762

63+
@utility max-w-app {
64+
@apply max-w-3xl;
65+
}
66+
6867
.active-nav {
6968
@apply underline decoration-wavy decoration-2 underline-offset-4;
7069
}

0 commit comments

Comments
 (0)