Skip to content

Commit 7881e1b

Browse files
committed
feat(style): use catppuccin-latte and one-dark-pro for code blocks
1 parent 1c66b54 commit 7881e1b

File tree

5 files changed

+70
-16
lines changed

5 files changed

+70
-16
lines changed

astro.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ export default defineConfig({
6060
syntaxHighlight: "shiki",
6161
// https://github.com/shikijs/shiki/blob/main/docs/languages.md
6262
shikiConfig: {
63-
theme: "nord",
63+
themes: {
64+
light: "catppuccin-latte",
65+
dark: "one-dark-pro",
66+
},
67+
defaultColor: false,
6468
// You can add options to the transformer here
6569
// For example, to change the 'copied' state duration:
6670
// toggle: 3000, // 3 seconds

src/components/Contributors.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const contributors = await getContributors()
3030
<Sponsors size="large" align="center" />
3131
</div>
3232

33-
<h3 class="text-base font-mono text-navy-300 text-center mb-8 dark:text-navy-100">
33+
<h3 class="mt-24 mb-8 text-base font-mono text-navy-300 text-center dark:text-navy-100">
3434
GitHub Contributors
3535
</h3>
3636
<div class="max-w-5xl mx-auto flex flex-wrap justify-center">

src/components/Terminal.astro

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ export interface Props {
2727
| "windows-terminal"
2828
| "ubuntu"
2929
// Added a language prop for Shiki, defaults to 'bash'
30-
lang?: 'bash' | 'sh' | 'powershell' | 'text'
30+
lang?: 'bash' | 'sh' | 'powershell' | 'text'
3131
}
3232
3333
// Destructure props, adding a default for lang
34-
const { code, codeTheme = "nord", type = "default", lang = "bash" } = Astro.props
34+
const { code, type = "default", lang = "bash" } = Astro.props
35+
36+
// Use dual themes for light/dark mode support
37+
const codeThemes = {
38+
light: "catppuccin-latte" as const,
39+
dark: "one-dark-pro" as const,
40+
}
3541
3642
const promptSymbols = {
3743
default: '',
@@ -146,6 +152,6 @@ const componentTransformers = [
146152
)}
147153
</div>
148154
<div class="terminal-code-container my-0">
149-
<Code code={rawCode} lang={lang} theme={codeTheme} transformers={componentTransformers} />
155+
<Code code={rawCode} lang={lang} themes={codeThemes} defaultColor={false} transformers={componentTransformers} />
150156
</div>
151157
</div>

src/components/quickstart/Cloud.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const { latestVersion } = Astro.props
4141
}
4242
}
4343
`}
44-
theme="nord"
44+
themes={{ light: "catppuccin-latte" as const, dark: "one-dark-pro" as const }}
45+
defaultColor={false}
4546
lang="json"
4647
/>
4748
</li>

src/styles/global.css

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ input[type="radio"]:checked + label {
8686

8787
.terminal-wrapper {
8888
@apply rounded-lg;
89-
background: #2e3440;
89+
background: var(--shiki-light-bg, #e6e9ef);
9090
img {
9191
margin-top: 0px;
9292
margin-bottom: 0px;
@@ -95,28 +95,44 @@ input[type="radio"]:checked + label {
9595
@apply font-normal overflow-x-auto font-mono bg-transparent rounded-t-none;
9696

9797
code {
98-
color: #d8dee9;
9998
.prompt {
100-
@apply select-none text-slate-400;
99+
@apply select-none opacity-60;
101100
}
102101
}
103102
}
104103
}
105104

105+
html.dark .terminal-wrapper {
106+
background: var(--shiki-dark-bg, #2e3440);
107+
}
108+
106109
.terminal-wrapper .top-bar {
110+
@apply bg-gray-200;
111+
107112
&.powershell {
108-
@apply justify-between text-white;
109-
background: #1f2023;
113+
@apply justify-between text-gray-800 bg-gray-300;
110114
}
111115
&.powershell-ubuntu {
112-
@apply justify-between text-white;
113-
background: #1f2023;
116+
@apply justify-between text-gray-800 bg-gray-300;
114117
}
115118
&.ubuntu {
116119
@apply justify-end;
117120
}
118121
}
119122

123+
html.dark .terminal-wrapper .top-bar {
124+
@apply bg-slate-700;
125+
126+
&.powershell {
127+
@apply text-white;
128+
background: #1f2023;
129+
}
130+
&.powershell-ubuntu {
131+
@apply text-white;
132+
background: #1f2023;
133+
}
134+
}
135+
120136
.prose .terminal-wrapper pre {
121137
@apply my-0;
122138
}
@@ -172,6 +188,19 @@ pre.astro-code code {
172188
padding-bottom: 2px;
173189
}
174190

191+
/* Shiki dual theme support */
192+
pre.astro-code,
193+
pre.astro-code span {
194+
color: var(--shiki-light) !important;
195+
background-color: var(--shiki-light-bg) !important;
196+
}
197+
198+
html.dark pre.astro-code,
199+
html.dark pre.astro-code span {
200+
color: var(--shiki-dark) !important;
201+
background-color: var(--shiki-dark-bg) !important;
202+
}
203+
175204
/* Copy buttons */
176205
button.copy,
177206
.shiki-copy,
@@ -183,8 +212,8 @@ pre.astro-code > button.copy {
183212
border: none;
184213
border-radius: 4px;
185214
cursor: pointer;
186-
background-color: rgba(255, 255, 255, 0.1);
187-
color: white;
215+
background-color: rgba(0, 0, 0, 0.1);
216+
color: #333;
188217
opacity: 0.5;
189218
z-index: 10;
190219
pointer-events: auto;
@@ -194,6 +223,13 @@ pre.astro-code > button.copy {
194223
background-color 0.2s;
195224
}
196225

226+
html.dark button.copy,
227+
html.dark .shiki-copy,
228+
html.dark pre.astro-code > button.copy {
229+
background-color: rgba(255, 255, 255, 0.1);
230+
color: white;
231+
}
232+
197233
.terminal-code-container button.copy,
198234
.terminal-code-container .shiki-copy,
199235
.terminal-code-container pre.astro-code > button.copy {
@@ -216,13 +252,20 @@ button.copy:hover,
216252
.shiki-copy:hover,
217253
pre.astro-code > button.copy:hover {
218254
opacity: 1;
255+
background-color: rgba(0, 0, 0, 0.2);
256+
}
257+
258+
html.dark button.copy:hover,
259+
html.dark .shiki-copy:hover,
260+
html.dark pre.astro-code > button.copy:hover {
219261
background-color: rgba(255, 255, 255, 0.2);
220262
}
221263

222264
button.copy.copied,
223265
.shiki-copy.copied,
224266
pre.astro-code > button.copy.copied {
225-
background-color: #28a745;
267+
background-color: #0891b2 !important;
268+
color: white !important;
226269
opacity: 1;
227270
}
228271

0 commit comments

Comments
 (0)