Skip to content

Commit bf845ae

Browse files
hasparusKurant
andauthored
Merge pull request #69 from hasparus/remove-dead-css
* fix: drop dark mode code block background The --shiki-dark-bg variable (e.g. #24292e from github-dark) was adding a visible background to code blocks in dark mode. haspar.us prod had transparent backgrounds — keep it that way. * Restyle twoslash popup an run format * chore: remove dead CSS selectors and unused ColorSchemeSelect Remove ~150 lines of CSS targeting old remark-shiki-twoslash markup (.code-container, .query, .error/.error-behind, .tag-container, .logger, .inline-completions) — none matched in built output. Delete ColorSchemeSelect.tsx — exported but never imported anywhere, replaced by command palette theme switching. * Kill the animation * fix: use CSS anchor positioning for twoslash tooltips Replaces absolute positioning with CSS Anchor Positioning API so tooltips escape the pre's overflow clipping and center on the hovered token. Includes a fallback to flip above when near the bottom of the viewport. * fix: add fallback for browsers without CSS anchor positioning --------- Co-authored-by: Kurant <kuranttyka@gmail.com>
2 parents 05b566f + 8eb109a commit bf845ae

19 files changed

Lines changed: 77 additions & 281 deletions

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ jobs:
7878
--prod
7979

8080
- name: Deploy Preview to Vercel
81-
if: github.ref_name != 'main'
81+
if:
82+
${{ github.event_name != 'push' && (!github.event.pull_request.head.repo.fork ||
83+
(github.event_name == 'pull_request_target' &&
84+
contains(github.event.pull_request.labels.*.name, 'trusted'))) }}
8285
run: node .github/scripts/deploy.mjs --token=${{ secrets.VERCEL_TOKEN }}
8386

8487
- name: Debug Conditions

src/global-styles/base.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ html {
1818
}
1919

2020
* {
21-
@apply outline-black dark:outline-white
22-
selection:bg-gray-200 selection:text-black
23-
dark:selection:bg-gray-700 dark:selection:text-white;
21+
@apply outline-black selection:bg-gray-200 selection:text-black dark:outline-white dark:selection:bg-gray-700 dark:selection:text-white;
2422
}
2523

2624
body {
27-
@apply text-gray-800 dark:text-gray-300 bg-white dark:bg-gray-900 px-0 md:px-4 pt-4 pb-20 md:pt-8 md:pb-48 relative min-h-screen;
25+
@apply relative min-h-screen bg-white px-0 pb-20 pt-4 text-gray-800 dark:bg-gray-900 dark:text-gray-300 md:px-4 md:pb-48 md:pt-8;
2826
}
2927

3028
body,

src/global-styles/integrations.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
}
88

99
& ol > li > p {
10-
@apply inline -mx-1;
10+
@apply -mx-1 inline;
1111
}
1212
}

src/global-styles/shiki.css

Lines changed: 22 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
html.dark .astro-code-themes {
1010
color: var(--shiki-dark) !important;
11-
background-color: var(--shiki-dark-bg) !important;
11+
background-color: transparent !important;
1212
}
1313

1414
html.dark .astro-code-themes span {
@@ -61,14 +61,33 @@ pre.twoslash:hover .twoslash-hover {
6161
position: absolute;
6262
transform: translate(0, 1rem);
6363
z-index: 100;
64+
width: max-content;
65+
max-width: 80vw;
6466

65-
@apply bg-white text-gray-900 border border-gray-200 shadow-sm px-3 p-2 rounded-sm
66-
dark:bg-black dark:text-gray-50 dark:border-gray-700 dark:shadow-md;
67+
@apply rounded-sm border border-gray-200 bg-white p-2 px-3 text-gray-900 shadow-sm dark:border-gray-700 dark:bg-black dark:text-gray-50 dark:shadow-md;
6768

6869
text-align: left;
6970
white-space: pre-wrap;
7071
}
7172

73+
@supports (anchor-name: --x) {
74+
.twoslash-hover:hover {
75+
anchor-name: --twoslash-hover;
76+
}
77+
78+
.twoslash-popup-container {
79+
position: fixed;
80+
transform: none;
81+
position-anchor: --twoslash-hover;
82+
position-area: bottom;
83+
position-try-fallbacks: --above;
84+
}
85+
86+
@position-try --above {
87+
position-area: top;
88+
}
89+
}
90+
7291
.twoslash-hover:hover > .twoslash-popup-container {
7392
display: block;
7493
}
@@ -102,150 +121,10 @@ pre .twoslash-error-line {
102121
@apply bg-gray-100 dark:bg-gray-800 dark:text-white;
103122
}
104123

105-
/* --- Code container --- */
106-
107-
pre .code-container {
108-
overflow: auto;
109-
}
110-
111124
pre code {
112125
white-space: pre;
113126
-webkit-overflow-scrolling: touch;
114127
}
115128
pre code a {
116129
text-decoration: none;
117130
}
118-
119-
/* --- Query/Error blocks --- */
120-
121-
pre .query {
122-
margin-bottom: 10px;
123-
color: #137998;
124-
display: inline-block;
125-
}
126-
127-
pre .error,
128-
pre .error-behind {
129-
margin-top: 0.5em;
130-
padding: 0.5em 1em;
131-
width: var(--container-width);
132-
white-space: pre-wrap;
133-
display: block;
134-
}
135-
pre .error {
136-
@apply bg-gray-100 dark:bg-gray-800 dark:text-white;
137-
position: absolute;
138-
border-left: 2px solid #bf1818;
139-
display: flex;
140-
align-items: center;
141-
}
142-
pre .error .code {
143-
display: none;
144-
}
145-
pre .error-behind {
146-
user-select: none;
147-
visibility: transparent;
148-
color: #fee;
149-
}
150-
151-
/* --- Annotations --- */
152-
153-
.tag-container {
154-
position: relative;
155-
}
156-
.tag-container .twoslash-annotation {
157-
position: absolute;
158-
font-family: "JetBrains Mono", Menlo, Monaco, Consolas, Courier New, monospace;
159-
right: -10px;
160-
width: 200px;
161-
color: #187abf;
162-
background-color: #fcf3d9bb;
163-
}
164-
.tag-container .twoslash-annotation p {
165-
text-align: left;
166-
font-size: 0.8rem;
167-
line-height: 0.9rem;
168-
}
169-
.tag-container .twoslash-annotation svg {
170-
float: left;
171-
margin-left: -44px;
172-
}
173-
.tag-container .twoslash-annotation.left {
174-
right: auto;
175-
left: -200px;
176-
}
177-
.tag-container .twoslash-annotation.left svg {
178-
float: right;
179-
margin-right: -5px;
180-
}
181-
182-
/* --- Console log/warn/error --- */
183-
184-
pre .logger {
185-
display: flex;
186-
align-items: center;
187-
color: black;
188-
padding: 6px;
189-
padding-left: 8px;
190-
width: calc(100% - 19px);
191-
white-space: pre-wrap;
192-
}
193-
pre .logger svg {
194-
margin-right: 9px;
195-
}
196-
pre .logger.error-log {
197-
background-color: #fee;
198-
border-left: 2px solid #bf1818;
199-
}
200-
pre .logger.warn-log {
201-
background-color: #ffe;
202-
border-left: 2px solid #eae662;
203-
}
204-
pre .logger.log-log {
205-
background-color: #e9e9e9;
206-
border-left: 2px solid #ababab;
207-
}
208-
pre .logger.log-log svg {
209-
margin-left: 6px;
210-
margin-right: 9px;
211-
}
212-
213-
/* --- Completions --- */
214-
215-
pre .inline-completions ul.dropdown {
216-
display: inline-block;
217-
position: absolute;
218-
width: 240px;
219-
background-color: gainsboro;
220-
color: grey;
221-
padding-top: 4px;
222-
font-family: var(--code-font);
223-
font-size: 0.8rem;
224-
margin: 0;
225-
padding: 0;
226-
border-left: 4px solid #4b9edd;
227-
}
228-
pre .inline-completions ul.dropdown::before {
229-
background-color: #4b9edd;
230-
width: 2px;
231-
position: absolute;
232-
top: -1.2rem;
233-
left: -3px;
234-
content: " ";
235-
}
236-
pre .inline-completions ul.dropdown li {
237-
overflow-x: hidden;
238-
padding-left: 4px;
239-
margin-bottom: 4px;
240-
}
241-
pre .inline-completions ul.dropdown li.deprecated {
242-
text-decoration: line-through;
243-
}
244-
pre .inline-completions ul.dropdown li span.result-found {
245-
color: #4b9edd;
246-
}
247-
pre .inline-completions ul.dropdown li span.result {
248-
width: 100px;
249-
color: black;
250-
display: inline-block;
251-
}

src/layouts/BaseLayout.astro

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ interface Props {
2525
2626
const { title, description, ogImage } = Astro.props;
2727
28-
const postModules = import.meta.glob<{ frontmatter: PostFrontmatter }>("../../posts/**/*.mdx", { eager: true });
28+
const postModules = import.meta.glob<{ frontmatter: PostFrontmatter }>(
29+
"../../posts/**/*.mdx",
30+
{ eager: true },
31+
);
2932
const posts = Object.values(postModules)
3033
.filter((p) => (import.meta.env.PROD ? !p.frontmatter.draft : true))
3134
.map((p) => ({
@@ -64,9 +67,9 @@ posts.sort((a, b) => {
6467
<InitColorScheme />
6568
</head>
6669
<body>
67-
<div class="max-w-container mx-auto px-4">
70+
<div class="mx-auto max-w-container px-4">
6871
<header
69-
class="flex justify-between items-center -mt-2"
72+
class="-mt-2 flex items-center justify-between"
7073
style={{ height: "37.5px" }}
7174
>
7275
<slot name="header-content">

src/lib/GrainOverlay/GrainOverlay.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ const { opacity } = Astro.props;
1010

1111
<div
1212
style={{ opacity, background: `url(${grainSvg})` }}
13-
class="absolute inset-0 mix-blend-difference pointer-events-none select-none"
13+
class="pointer-events-none absolute inset-0 select-none mix-blend-difference"
1414
>
1515
</div>

src/lib/Kbd.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export function Kbd(props: KbdProps) {
1818
ref={ref}
1919
{...props}
2020
class={
21-
"p-1 border border-b-2 rounded-md bg-gray-50" +
21+
"rounded-md border border-b-2 bg-gray-50 p-1" +
2222
" dark:border-gray-700 dark:bg-gray-800" +
23-
" tracking-tighter leading-none text-xs" +
23+
" text-xs leading-none tracking-tighter" +
2424
" group-hover:border-b group-hover:shadow-[inset_0_1px_1px_0_rgba(0,0,0,0.025)] group-focus:outline" +
25-
" [&[data-pressed]]:border-b [&[data-pressed]]" +
25+
" [&[data-pressed]] [&[data-pressed]]:border-b" +
2626
(props.class ? ` ${props.class}` : "")
2727
}
2828
/>

src/lib/TableOfContents/PostProgressBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export function PostProgressBar(props: { children: JSX.Element }) {
3030

3131
return (
3232
<div class="relative">
33-
<div class="absolute h-full w-[2px] -left-4 rounded-sm bg-gray-100 dark:bg-gray-800 overflow-hidden">
33+
<div class="absolute -left-4 h-full w-[2px] overflow-hidden rounded-sm bg-gray-100 dark:bg-gray-800">
3434
<div
3535
class={
36-
"bg-gray-300 dark:bg-gray-700 absolute h-full w-full rounded-sm " +
36+
"absolute h-full w-full rounded-sm bg-gray-300 dark:bg-gray-700 " +
3737
"-translate-y-[var(--y,100%)] transition-transform duration-300 ease-linear"
3838
}
3939
ref={progressThumb}

src/lib/color-scheme/ColorSchemeSelect.tsx

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

src/lib/prose/Blockquote.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
&:after,
2525
&:before {
26-
@apply text-4xl leading-none text-gray-300 font-black;
26+
@apply text-4xl font-black leading-none text-gray-300;
2727
position: absolute;
2828

2929
:global(.dark) & {

0 commit comments

Comments
 (0)