Skip to content

Commit 507b751

Browse files
authored
feat(site): align docs code blocks with the landing page's VS Code themes (#1978)
1 parent 73489ce commit 507b751

3 files changed

Lines changed: 137 additions & 3 deletions

File tree

site/docusaurus.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import type {
44
} from '@docusaurus/preset-classic'
55
import type { Config } from '@docusaurus/types'
66
import type { MermaidConfig } from 'mermaid'
7-
import { themes } from 'prism-react-renderer'
87
import type { PluginOptions as LLMsTXTPluginOptions } from '@signalwire/docusaurus-plugin-llms-txt'
98
import type { PluginOptions as VercelAnalyticsPluginOptions } from '@docusaurus/plugin-vercel-analytics'
9+
import { darkPlus, lightPlus } from './src/prismThemes'
1010
import { socialIconPaths } from './src/components/socialIconPaths'
1111

1212
function socialNavbarItem(
@@ -245,8 +245,8 @@ export default {
245245
title: 'Kysely',
246246
},
247247
prism: {
248-
darkTheme: themes.dracula,
249-
theme: themes.github,
248+
darkTheme: darkPlus,
249+
theme: lightPlus,
250250
},
251251
} satisfies PresetClassicThemeConfig,
252252
clientModules: ['./src/clientModules/navbarScroll.ts'],

site/src/css/custom.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
}
4646

4747
[data-theme='dark'] {
48+
/* The light-mode value is a black tint, invisible on the #1e1e1e code
49+
background. */
50+
--docusaurus-highlighted-code-line-bg: rgba(255, 255, 255, 0.07);
4851
--ifm-color-primary: #38bdf8;
4952
--ifm-color-primary-dark: #0ea5e9;
5053
--ifm-color-primary-darker: #0284c7;

site/src/prismThemes.ts

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import type { PrismTheme } from 'prism-react-renderer'
2+
3+
/**
4+
* VS Code Dark+ / Light+ palettes mapped onto Prism token types, so docs
5+
* code blocks match the landing page figures (highlighted with shiki's
6+
* `dark-plus` / `light-plus` themes) and the hero demo video.
7+
*
8+
* Color sources: shiki's `dark-plus` / `light-plus` theme JSON. Prism
9+
* cannot tell control-flow keywords or object keys apart from regular
10+
* keywords and identifiers, so those keep the base keyword and variable
11+
* colors.
12+
*
13+
* Prism leaves TypeScript identifiers untokenized, so `plain` carries the
14+
* VS Code variable color in dark mode (#9cdcfe), matching how kysely
15+
* queries render in the editor. Punctuation and operators are tokenized
16+
* and pull those back to the editor foreground (#d4d4d4).
17+
*/
18+
19+
export const darkPlus = {
20+
plain: {
21+
backgroundColor: '#1e1e1e',
22+
color: '#9cdcfe',
23+
},
24+
styles: [
25+
{
26+
style: { color: '#6a9955' },
27+
types: ['comment', 'prolog', 'cdata'],
28+
},
29+
{
30+
style: { color: '#569cd6' },
31+
types: ['keyword', 'boolean', 'tag', 'changed'],
32+
},
33+
{
34+
style: { color: '#ce9178' },
35+
types: ['string', 'char', 'attr-value', 'template-string', 'deleted'],
36+
},
37+
{
38+
style: { color: '#b5cea8' },
39+
types: ['number', 'inserted'],
40+
},
41+
{
42+
style: { color: '#dcdcaa' },
43+
types: ['function'],
44+
},
45+
{
46+
style: { color: '#4ec9b0' },
47+
types: ['class-name', 'builtin', 'maybe-class-name', 'namespace'],
48+
},
49+
{
50+
style: { color: '#4fc1ff' },
51+
types: ['constant'],
52+
},
53+
{
54+
style: { color: '#9cdcfe' },
55+
types: ['variable', 'attr-name', 'property', 'literal-property'],
56+
},
57+
{
58+
style: { color: '#d4d4d4' },
59+
types: ['operator', 'punctuation'],
60+
},
61+
{
62+
style: { color: '#d16969' },
63+
types: ['regex'],
64+
},
65+
{
66+
style: { color: '#d7ba7d' },
67+
types: ['selector'],
68+
},
69+
],
70+
} satisfies PrismTheme
71+
72+
export const lightPlus = {
73+
plain: {
74+
backgroundColor: '#ffffff',
75+
color: '#000000',
76+
},
77+
styles: [
78+
{
79+
style: { color: '#008000' },
80+
types: ['comment', 'prolog', 'cdata'],
81+
},
82+
{
83+
style: { color: '#0000ff' },
84+
types: ['keyword', 'boolean'],
85+
},
86+
{
87+
style: { color: '#a31515' },
88+
types: ['string', 'char', 'attr-value', 'template-string', 'deleted'],
89+
},
90+
{
91+
style: { color: '#098658' },
92+
types: ['number', 'inserted'],
93+
},
94+
{
95+
style: { color: '#795e26' },
96+
types: ['function'],
97+
},
98+
{
99+
style: { color: '#267f99' },
100+
types: ['class-name', 'builtin', 'maybe-class-name', 'namespace'],
101+
},
102+
{
103+
style: { color: '#0070c1' },
104+
types: ['constant'],
105+
},
106+
{
107+
style: { color: '#001080' },
108+
types: ['variable', 'literal-property'],
109+
},
110+
{
111+
style: { color: '#0451a5' },
112+
types: ['property', 'changed'],
113+
},
114+
{
115+
style: { color: '#e50000' },
116+
types: ['attr-name'],
117+
},
118+
{
119+
style: { color: '#800000' },
120+
types: ['tag', 'selector'],
121+
},
122+
{
123+
style: { color: '#000000' },
124+
types: ['operator', 'punctuation'],
125+
},
126+
{
127+
style: { color: '#811f3f' },
128+
types: ['regex'],
129+
},
130+
],
131+
} satisfies PrismTheme

0 commit comments

Comments
 (0)