Skip to content

Commit f7cb267

Browse files
authored
refactor: update tailwind typography css overrides (#538)
* refactor: update tailwind typography css overrides Update TailwindCSS typography overrides to use less `important`; and update selectors to make them easier to read. * refactor: update focus styles to be consistent
1 parent 4c2aebc commit f7cb267

File tree

4 files changed

+77
-21
lines changed

4 files changed

+77
-21
lines changed

src/components/BackToTopButton.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import IconArrowNarrowUp from "@/assets/icons/IconArrowNarrowUp.svg";
1616
class:list={[
1717
"group relative bg-background px-2 py-1",
1818
"size-14 rounded-full shadow-xl",
19-
"md:h-8 md:w-fit md:rounded-md md:shadow-none",
19+
"md:h-8 md:w-fit md:rounded-md md:shadow-none md:focus-visible:rounded-none",
2020
"md:bg-background/35 md:bg-clip-padding md:backdrop-blur-lg",
2121
]}
2222
>

src/components/Tag.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const { tag, tagName, size = "sm" } = Astro.props;
2020
href={`/tags/${tag}/`}
2121
transition:name={tag}
2222
class:list={[
23-
"relative pe-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1",
23+
"relative pe-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 focus-visible:no-underline",
2424
{ "text-sm": size === "sm" },
2525
]}
2626
>

src/layouts/PostDetails.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const nextPost =
105105
</div>
106106
<article
107107
id="article"
108-
class="mx-auto prose mt-8 max-w-app prose-pre:bg-(--shiki-light-bg) dark:prose-pre:bg-(--shiki-dark-bg)"
108+
class="app-prose mx-auto mt-8 max-w-app prose-pre:bg-(--shiki-light-bg) dark:prose-pre:bg-(--shiki-dark-bg)"
109109
>
110110
<Content />
111111
</article>

src/styles/typography.css

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,80 @@
22

33
@layer base {
44
/* ===== Override default Tailwind Typography styles ===== */
5-
.prose {
6-
@apply prose-headings:!mb-3 prose-headings:!text-foreground prose-h3:italic prose-p:!text-foreground prose-a:!text-foreground prose-a:!decoration-dashed prose-a:underline-offset-8 hover:prose-a:text-accent prose-blockquote:!border-l-accent/50 prose-blockquote:opacity-80 prose-figcaption:!text-foreground prose-figcaption:opacity-70 prose-strong:!text-foreground prose-code:rounded prose-code:bg-muted/75 prose-code:p-1 prose-code:!text-foreground prose-code:before:!content-none prose-code:after:!content-none prose-ol:!text-foreground prose-ul:overflow-x-clip prose-ul:!text-foreground prose-li:marker:!text-accent prose-table:text-foreground prose-th:border prose-th:border-border prose-td:border prose-td:border-border prose-img:mx-auto prose-img:!my-2 prose-img:border-2 prose-img:border-border prose-hr:!border-border;
5+
.app-prose {
6+
@apply prose;
7+
8+
h1,
9+
h2,
10+
h3,
11+
h4,
12+
th {
13+
@apply mb-3 text-foreground;
14+
}
15+
16+
h3 {
17+
@apply italic;
18+
}
19+
20+
p,
21+
strong,
22+
ol,
23+
ul,
24+
figcaption,
25+
table,
26+
code {
27+
@apply text-foreground;
28+
}
729

830
a {
9-
@apply break-words hover:!text-accent;
31+
@apply break-words text-foreground decoration-dashed underline-offset-4 hover:text-accent focus-visible:no-underline;
32+
}
33+
34+
ul {
35+
@apply overflow-x-clip;
36+
}
37+
38+
li {
39+
@apply marker:text-accent;
40+
}
41+
42+
hr {
43+
@apply border-border;
44+
}
45+
46+
img {
47+
@apply mx-auto border border-border;
48+
}
49+
50+
figcaption {
51+
@apply opacity-75;
52+
}
53+
54+
table {
55+
th,
56+
td {
57+
@apply border border-border p-2;
58+
}
59+
60+
th {
61+
@apply py-1.5;
62+
}
63+
64+
code {
65+
@apply break-all sm:break-normal;
66+
}
67+
}
68+
69+
code {
70+
@apply rounded bg-muted/75 p-1 break-words text-foreground before:content-none after:content-none;
71+
}
72+
73+
.astro-code code {
74+
@apply bg-inherit;
75+
}
76+
77+
blockquote {
78+
@apply border-s-accent/80 break-words opacity-80;
1079
}
1180

1281
details {
@@ -17,10 +86,8 @@
1786
@apply focus-visible:no-underline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent focus-visible:outline-dashed;
1887
}
1988

20-
thead th:first-child,
21-
tbody td:first-child,
22-
tfoot td:first-child {
23-
padding-inline-start: 0.5714286em !important;
89+
pre {
90+
@apply focus-visible:border-transparent focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-dashed;
2491
}
2592
}
2693

@@ -49,15 +116,4 @@
49116
@apply rounded-sm border border-border px-0.5 py-px;
50117
}
51118
}
52-
53-
/* Break words in code and blockqoute */
54-
.prose code,
55-
.prose blockquote {
56-
@apply break-words;
57-
}
58-
59-
.prose table code {
60-
/* add line breaks whenever necessary for codes under table */
61-
@apply break-all sm:break-normal;
62-
}
63119
}

0 commit comments

Comments
 (0)