refactor: improve semantic by replacing decorative hr with borders (#597)

Replace decorative usage of Hr component with borders to improve
semantic.

- remove Hr component
- replace decorative hr elements with borders
- introduce app-layout utility class
- update layout and spacing
- update docs about border css custom property
This commit is contained in:
Sat Naing
2026-01-04 20:24:34 +07:00
committed by GitHub
parent 93d491b7f3
commit ceb406314b
14 changed files with 161 additions and 180 deletions
+2 -2
View File
@@ -6,11 +6,11 @@ import { SITE } from "@/config";
{ {
SITE.showBackButton && ( SITE.showBackButton && (
<div class="mx-auto flex w-full max-w-app items-center justify-start px-2"> <div class="app-layout flex items-center justify-start">
<LinkButton <LinkButton
id="back-button" id="back-button"
href="/" href="/"
class="focus-outline mt-8 mb-2 flex hover:text-foreground/75" class="focus-outline -ms-2 mt-8 mb-2 hover:text-foreground/75"
> >
<IconChevronLeft class="inline-block size-6 rtl:rotate-180" /> <IconChevronLeft class="inline-block size-6 rtl:rotate-180" />
<span>Go back</span> <span>Go back</span>
+1 -1
View File
@@ -23,7 +23,7 @@ if (breadcrumbList[0] === "tags" && !isNaN(Number(breadcrumbList[2]))) {
} }
--- ---
<nav class="mx-auto mt-8 mb-1 w-full max-w-app px-4" aria-label="breadcrumb"> <nav class="app-layout mt-8 mb-1" aria-label="breadcrumb">
<ul <ul
class="font-light [&>li]:inline [&>li:not(:last-child)>a]:hover:opacity-100" class="font-light [&>li]:inline [&>li:not(:last-child)>a]:hover:opacity-100"
> >
+7 -5
View File
@@ -1,5 +1,4 @@
--- ---
import Hr from "./Hr.astro";
import Socials from "./Socials.astro"; import Socials from "./Socials.astro";
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
@@ -11,12 +10,15 @@ export interface Props {
const { noMarginTop = false } = Astro.props; const { noMarginTop = false } = Astro.props;
--- ---
<footer class:list={["w-full", { "mt-auto": !noMarginTop }]}> <footer class:list={["app-layout", { "mt-auto": !noMarginTop }]}>
<Hr noPadding />
<div <div
class="flex flex-col items-center justify-between py-6 sm:flex-row-reverse sm:py-4" class:list={[
"py-6 sm:py-4",
"border-t border-border",
"flex flex-col items-center justify-between sm:flex-row-reverse",
]}
> >
<Socials centered /> <Socials />
<div class="my-2 flex flex-col items-center whitespace-nowrap sm:flex-row"> <div class="my-2 flex flex-col items-center whitespace-nowrap sm:flex-row">
<span>Copyright &#169; {currentYear}</span> <span>Copyright &#169; {currentYear}</span>
<span class="hidden sm:inline">&nbsp;|&nbsp;</span> <span class="hidden sm:inline">&nbsp;|&nbsp;</span>
+111 -110
View File
@@ -1,5 +1,4 @@
--- ---
import Hr from "./Hr.astro";
import IconX from "@/assets/icons/IconX.svg"; import IconX from "@/assets/icons/IconX.svg";
import IconMoon from "@/assets/icons/IconMoon.svg"; import IconMoon from "@/assets/icons/IconMoon.svg";
import IconSearch from "@/assets/icons/IconSearch.svg"; import IconSearch from "@/assets/icons/IconSearch.svg";
@@ -23,121 +22,123 @@ const isActive = (path: string) => {
}; };
--- ---
<header> <a
<a id="skip-to-content"
id="skip-to-content" href="#main-content"
href="#main-content" class="absolute start-16 -top-full z-50 bg-background px-3 py-2 text-accent backdrop-blur-lg transition-all focus:top-4"
class="absolute start-16 -top-full z-50 bg-background px-3 py-2 text-accent backdrop-blur-lg transition-all focus:top-4" >
> Skip to content
Skip to content </a>
</a>
<header
class="app-layout flex flex-col items-center justify-between sm:flex-row"
>
<div <div
id="nav-container" id="top-nav-wrap"
class="mx-auto flex max-w-app flex-col items-center justify-between sm:flex-row" class:list={[
"py-4 sm:py-6",
"border-b border-border",
"relative w-full bg-background",
"flex items-baseline justify-between sm:items-center",
]}
> >
<div <a
id="top-nav-wrap" href="/"
class="relative flex w-full items-baseline justify-between bg-background p-4 sm:items-center sm:py-6" class="absolute py-1 text-xl leading-8 font-semibold whitespace-nowrap sm:static sm:my-auto sm:text-2xl sm:leading-none"
> >
<a {SITE.title}
href="/" </a>
class="absolute py-1 text-xl leading-8 font-semibold whitespace-nowrap sm:static sm:my-auto sm:text-2xl sm:leading-none" <nav
id="nav-menu"
class="flex w-full flex-col items-center sm:ms-2 sm:flex-row sm:justify-end sm:space-x-4 sm:py-0"
>
<button
id="menu-btn"
class="focus-outline self-end p-2 sm:hidden"
aria-label="Open Menu"
aria-expanded="false"
aria-controls="menu-items"
> >
{SITE.title} <IconX id="close-icon" class="hidden" />
</a> <IconMenuDeep id="menu-icon" />
<nav </button>
id="nav-menu" <ul
class="flex w-full flex-col items-center sm:ms-2 sm:flex-row sm:justify-end sm:space-x-4 sm:py-0" id="menu-items"
class:list={[
"mt-4 grid w-44 grid-cols-2 place-content-center gap-2",
"[&>li>a]:block [&>li>a]:px-4 [&>li>a]:py-3 [&>li>a]:text-center [&>li>a]:font-medium [&>li>a]:hover:text-accent sm:[&>li>a]:px-2 sm:[&>li>a]:py-1",
"hidden",
"sm:mt-0 sm:flex sm:w-auto sm:gap-x-5 sm:gap-y-0",
]}
> >
<button <li class="col-span-2">
id="menu-btn" <a href="/posts" class:list={{ "active-nav": isActive("/posts") }}>
class="focus-outline self-end p-2 sm:hidden" Posts
aria-label="Open Menu" </a>
aria-expanded="false" </li>
aria-controls="menu-items" <li class="col-span-2">
> <a href="/tags" class:list={{ "active-nav": isActive("/tags") }}>
<IconX id="close-icon" class="hidden" /> Tags
<IconMenuDeep id="menu-icon" /> </a>
</button> </li>
<ul <li class="col-span-2">
id="menu-items" <a href="/about" class:list={{ "active-nav": isActive("/about") }}>
class:list={[ About
"mt-4 grid w-44 grid-cols-2 place-content-center gap-2", </a>
"[&>li>a]:block [&>li>a]:px-4 [&>li>a]:py-3 [&>li>a]:text-center [&>li>a]:font-medium [&>li>a]:hover:text-accent sm:[&>li>a]:px-2 sm:[&>li>a]:py-1", </li>
"hidden", {
"sm:mt-0 sm:flex sm:w-auto sm:gap-x-5 sm:gap-y-0", SITE.showArchives && (
]} <li class="col-span-2">
> <LinkButton
<li class="col-span-2"> href="/archives"
<a href="/posts" class:list={{ "active-nav": isActive("/posts") }}> class:list={[
Posts "focus-outline flex justify-center p-3 sm:p-1",
</a> {
</li> "active-nav [&>svg]:stroke-accent": isActive("/archives"),
<li class="col-span-2"> },
<a href="/tags" class:list={{ "active-nav": isActive("/tags") }}> ]}
Tags ariaLabel="archives"
</a> title="Archives"
</li> >
<li class="col-span-2"> <IconArchive class="hidden sm:inline-block" />
<a href="/about" class:list={{ "active-nav": isActive("/about") }}> <span class="sm:sr-only">Archives</span>
About </LinkButton>
</a> </li>
</li> )
{ }
SITE.showArchives && ( <li class="col-span-1 flex items-center justify-center">
<li class="col-span-2"> <LinkButton
<LinkButton href="/search"
href="/archives" class:list={[
class:list={[ "focus-outline flex p-3 sm:p-1",
"focus-outline flex justify-center p-3 sm:p-1", { "[&>svg]:stroke-accent": isActive("/search") },
{ ]}
"active-nav [&>svg]:stroke-accent": isActive("/archives"), ariaLabel="search"
}, title="Search"
]} >
ariaLabel="archives" <IconSearch />
title="Archives" <span class="sr-only">Search</span>
> </LinkButton>
<IconArchive class="hidden sm:inline-block" /> </li>
<span class="sm:sr-only">Archives</span> {
</LinkButton> SITE.lightAndDarkMode && (
</li> <li class="col-span-1 flex items-center justify-center">
) <button
} id="theme-btn"
<li class="col-span-1 flex items-center justify-center"> class="focus-outline relative size-12 p-4 sm:size-8 hover:[&>svg]:stroke-accent"
<LinkButton title="Toggles light & dark"
href="/search" aria-label="auto"
class:list={[ aria-live="polite"
"focus-outline flex p-3 sm:p-1", >
{ "[&>svg]:stroke-accent": isActive("/search") }, <IconMoon class="absolute top-[50%] left-[50%] -translate-[50%] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
]} <IconSunHigh class="absolute top-[50%] left-[50%] -translate-[50%] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
ariaLabel="search" </button>
title="Search" </li>
> )
<IconSearch /> }
<span class="sr-only">Search</span> </ul>
</LinkButton> </nav>
</li>
{
SITE.lightAndDarkMode && (
<li class="col-span-1 flex items-center justify-center">
<button
id="theme-btn"
class="focus-outline relative size-12 p-4 sm:size-8 hover:[&>svg]:stroke-accent"
title="Toggles light & dark"
aria-label="auto"
aria-live="polite"
>
<IconMoon class="absolute top-[50%] left-[50%] -translate-[50%] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
<IconSunHigh class="absolute top-[50%] left-[50%] -translate-[50%] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
</button>
</li>
)
}
</ul>
</nav>
</div>
</div> </div>
<Hr />
</header> </header>
<script> <script>
-12
View File
@@ -1,12 +0,0 @@
---
export interface Props {
noPadding?: boolean;
ariaHidden?: boolean;
}
const { noPadding = false, ariaHidden = true } = Astro.props;
---
<div class:list={["mx-auto max-w-app", noPadding ? "px-0" : "px-4"]}>
<hr class="border-border" aria-hidden={ariaHidden} />
</div>
+5 -2
View File
@@ -22,7 +22,7 @@ const {
disabled ? ( disabled ? (
<span <span
id={id} id={id}
class:list={["group inline-block", className]} class:list={["group inline-flex items-center gap-1", className]}
title={title} title={title}
aria-disabled={disabled} aria-disabled={disabled}
> >
@@ -32,7 +32,10 @@ const {
<a <a
id={id} id={id}
{href} {href}
class:list={["group inline-block hover:text-accent", className]} class:list={[
"group inline-flex items-center gap-1 hover:text-accent",
className,
]}
aria-label={ariaLabel} aria-label={ariaLabel}
title={title} title={title}
> >
+1 -7
View File
@@ -1,15 +1,9 @@
--- ---
import { SOCIALS } from "@/constants"; import { SOCIALS } from "@/constants";
import LinkButton from "./LinkButton.astro"; import LinkButton from "./LinkButton.astro";
export interface Props {
centered?: boolean;
}
const { centered = false } = Astro.props;
--- ---
<div class:list={["flex-wrap justify-center gap-1", { flex: centered }]}> <div class="flex flex-wrap items-center gap-1">
{ {
SOCIALS.map(social => ( SOCIALS.map(social => (
<LinkButton <LinkButton
@@ -1,7 +1,7 @@
--- ---
author: Sat Naing author: Sat Naing
pubDatetime: 2022-09-25T15:20:35Z pubDatetime: 2022-09-25T15:20:35Z
modDatetime: 2025-06-13T16:46:34.155Z modDatetime: 2026-01-04T11:27:37.761Z
title: Customizing AstroPaper theme color schemes title: Customizing AstroPaper theme color schemes
featured: false featured: false
draft: false draft: false
@@ -109,13 +109,13 @@ To customize your own color scheme, specify your light colors inside `:root, htm
Here is the detail explanation of color properties. Here is the detail explanation of color properties.
| Color Property | Definition & Usage | | Color Property | Definition & Usage |
| -------------- | ---------------------------------------------------------- | | -------------- | ------------------------------------------------------------- |
| `--background` | Primary color of the website. Usually the main background. | | `--background` | Primary color of the website. Usually the main background. |
| `--foreground` | Secondary color of the website. Usually the text color. | | `--foreground` | Secondary color of the website. Usually the text color. |
| `--accent` | Accent color of the website. Link color, hover color etc. | | `--accent` | Accent color of the website. Link color, hover color etc. |
| `--muted` | Card and scrollbar background color for hover state etc. | | `--muted` | Card and scrollbar background color for hover state etc. |
| `--border` | Border color. Especially used in horizontal row (hr) | | `--border` | Border color. Used for border utilities and visual separation |
Here is an example of changing the light color scheme. Here is an example of changing the light color scheme.
+1 -1
View File
@@ -18,7 +18,7 @@ const { frontmatter } = Astro.props;
<Layout title={`${frontmatter.title} | ${SITE.title}`}> <Layout title={`${frontmatter.title} | ${SITE.title}`}>
<Header /> <Header />
<Breadcrumb /> <Breadcrumb />
<main id="main-content"> <main id="main-content" class="app-layout">
<section id="about" class="app-prose mb-28 max-w-app prose-img:border-0"> <section id="about" class="app-prose mb-28 max-w-app prose-img:border-0">
<h1 class="text-2xl tracking-wider sm:text-3xl">{frontmatter.title}</h1> <h1 class="text-2xl tracking-wider sm:text-3xl">{frontmatter.title}</h1>
<slot /> <slot />
+1 -5
View File
@@ -21,11 +21,7 @@ const backUrl = SITE.showBackButton ? Astro.url.pathname : "/";
--- ---
<Breadcrumb /> <Breadcrumb />
<main <main data-backUrl={backUrl} id="main-content" class="app-layout pb-4">
data-backUrl={backUrl}
id="main-content"
class="mx-auto w-full max-w-app px-4 pb-4"
>
{ {
"titleTransition" in props ? ( "titleTransition" in props ? (
<h1 class="text-2xl font-semibold sm:text-3xl"> <h1 class="text-2xl font-semibold sm:text-3xl">
+2 -5
View File
@@ -87,10 +87,7 @@ const nextPost =
<BackButton /> <BackButton />
<main <main
id="main-content" id="main-content"
class:list={[ class:list={["app-layout pb-12", { "mt-8": !SITE.showBackButton }]}
"mx-auto w-full max-w-app px-4 pb-12",
{ "mt-8": !SITE.showBackButton },
]}
data-pagefind-body data-pagefind-body
> >
<h1 <h1
@@ -112,7 +109,7 @@ const nextPost =
</div> </div>
<article <article
id="article" id="article"
class="app-prose mx-auto mt-8 max-w-app prose-pre:bg-(--shiki-light-bg) dark:prose-pre:bg-(--shiki-dark-bg)" class="app-prose mt-8 w-full max-w-app prose-pre:bg-(--shiki-light-bg) dark:prose-pre:bg-(--shiki-dark-bg)"
> >
<Content /> <Content />
</article> </article>
+1 -1
View File
@@ -11,7 +11,7 @@ import { SITE } from "@/config";
<main <main
id="main-content" id="main-content"
class="mx-auto flex max-w-app flex-1 items-center justify-center" class="app-layout flex flex-1 items-center justify-center"
> >
<div class="mb-14 flex flex-col items-center justify-center"> <div class="mb-14 flex flex-col items-center justify-center">
<h1 class="text-9xl font-bold text-accent">404</h1> <h1 class="text-9xl font-bold text-accent">404</h1>
+17 -17
View File
@@ -6,7 +6,6 @@ import Footer from "@/components/Footer.astro";
import Socials from "@/components/Socials.astro"; import Socials from "@/components/Socials.astro";
import LinkButton from "@/components/LinkButton.astro"; import LinkButton from "@/components/LinkButton.astro";
import Card from "@/components/Card.astro"; import Card from "@/components/Card.astro";
import Hr from "@/components/Hr.astro";
import getSortedPosts from "@/utils/getSortedPosts"; import getSortedPosts from "@/utils/getSortedPosts";
import IconRss from "@/assets/icons/IconRss.svg"; import IconRss from "@/assets/icons/IconRss.svg";
import IconArrowRight from "@/assets/icons/IconArrowRight.svg"; import IconArrowRight from "@/assets/icons/IconArrowRight.svg";
@@ -22,8 +21,8 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
<Layout> <Layout>
<Header /> <Header />
<main id="main-content" data-layout="index"> <main id="main-content" data-layout="index" class="app-layout">
<section id="hero" class="pt-8 pb-6"> <section id="hero" class:list={["pt-8 pb-6", "border-b border-border"]}>
<h1 class="my-4 inline-block text-4xl font-bold sm:my-8 sm:text-5xl"> <h1 class="my-4 inline-block text-4xl font-bold sm:my-8 sm:text-5xl">
Mingalaba Mingalaba
</h1> </h1>
@@ -60,7 +59,7 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
{ {
// only display if at least one social link is enabled // only display if at least one social link is enabled
SOCIALS.length > 0 && ( SOCIALS.length > 0 && (
<div class="mt-4 flex flex-col sm:flex-row sm:items-center"> <div class="mt-4 flex max-sm:flex-col sm:items-center">
<div class="me-2 mb-1 whitespace-nowrap sm:mb-0">Social Links:</div> <div class="me-2 mb-1 whitespace-nowrap sm:mb-0">Social Links:</div>
<Socials /> <Socials />
</div> </div>
@@ -68,21 +67,22 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
} }
</section> </section>
<Hr />
{ {
featuredPosts.length > 0 && ( featuredPosts.length > 0 && (
<> <section
<section id="featured" class="pt-12 pb-6"> id="featured"
<h2 class="text-2xl font-semibold tracking-wide">Featured</h2> class:list={[
<ul> "pt-12 pb-6",
{featuredPosts.map(data => ( { "border-b border-border": recentPosts.length > 0 },
<Card variant="h3" {...data} /> ]}
))} >
</ul> <h2 class="text-2xl font-semibold tracking-wide">Featured</h2>
</section> <ul>
{recentPosts.length > 0 && <Hr />} {featuredPosts.map(data => (
</> <Card variant="h3" {...data} />
))}
</ul>
</section>
) )
} }
+4 -4
View File
@@ -48,16 +48,16 @@ html[data-theme="dark"] {
[role="button"]:not(:disabled) { [role="button"]:not(:disabled) {
cursor: pointer; cursor: pointer;
} }
section,
footer {
@apply mx-auto max-w-app px-4;
}
} }
@utility max-w-app { @utility max-w-app {
@apply max-w-3xl; @apply max-w-3xl;
} }
@utility app-layout {
@apply mx-auto w-full max-w-app px-4;
}
.active-nav { .active-nav {
@apply underline decoration-wavy decoration-2 underline-offset-4; @apply underline decoration-wavy decoration-2 underline-offset-4;
} }