Skip to content

Commit b068980

Browse files
committed
Add code block styles inspired by GitHub, themed to match site design
1 parent a980c5b commit b068980

2 files changed

Lines changed: 115 additions & 0 deletions

File tree

src/css/app.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
/* Components */
66
@import './components/button.css';
7+
@import './components/code.css';
78
@import './components/get-involved.css';
89
@import './components/sponsors.css';
910
@import './components/profile-image.css';

src/css/components/code.css

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/* Inline code */
2+
:not(pre) > code {
3+
background-color: var(--color-lightblue);
4+
border: 1px solid color-mix(in srgb, var(--color-blue) 25%, transparent);
5+
border-radius: 4px;
6+
color: var(--color-mutednavy);
7+
font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
8+
font-size: 0.875em;
9+
padding: 0.15em 0.4em;
10+
}
11+
12+
/* Code block wrapper — Ghost wraps <pre><code> in a .kg-code-card */
13+
.kg-code-card {
14+
margin: 1.75rem 0;
15+
}
16+
17+
pre {
18+
background-color: var(--color-navy);
19+
border-radius: 6px;
20+
color: #cdd9e5;
21+
font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
22+
font-size: 0.875rem;
23+
line-height: 1.6;
24+
margin: 1.75rem 0;
25+
overflow-x: auto;
26+
padding: 1.25rem 1.5rem;
27+
position: relative;
28+
}
29+
30+
pre code {
31+
background: none;
32+
border: none;
33+
color: inherit;
34+
font-size: inherit;
35+
padding: 0;
36+
}
37+
38+
/* Language label — Ghost adds data-language on the <pre> element */
39+
pre[data-language]::before {
40+
background-color: var(--color-yellow);
41+
border-radius: 0 0 4px 4px;
42+
color: var(--color-navy);
43+
content: attr(data-language);
44+
font-family: 'Inter', sans-serif;
45+
font-size: 0.7rem;
46+
font-weight: 600;
47+
letter-spacing: 0.05em;
48+
padding: 2px 8px;
49+
position: absolute;
50+
right: 1rem;
51+
text-transform: uppercase;
52+
top: 0;
53+
}
54+
55+
/* Syntax token colors — tuned for the navy background */
56+
.kg-code-card .token.comment,
57+
.kg-code-card .token.prolog,
58+
.kg-code-card .token.doctype,
59+
.kg-code-card .token.cdata {
60+
color: #768390;
61+
font-style: italic;
62+
}
63+
64+
.kg-code-card .token.punctuation {
65+
color: #8dbbe8;
66+
}
67+
68+
.kg-code-card .token.namespace {
69+
opacity: 0.7;
70+
}
71+
72+
.kg-code-card .token.property,
73+
.kg-code-card .token.tag,
74+
.kg-code-card .token.boolean,
75+
.kg-code-card .token.number,
76+
.kg-code-card .token.constant,
77+
.kg-code-card .token.symbol,
78+
.kg-code-card .token.deleted {
79+
color: var(--color-red);
80+
}
81+
82+
.kg-code-card .token.selector,
83+
.kg-code-card .token.attr-name,
84+
.kg-code-card .token.string,
85+
.kg-code-card .token.char,
86+
.kg-code-card .token.builtin,
87+
.kg-code-card .token.inserted {
88+
color: var(--color-green);
89+
}
90+
91+
.kg-code-card .token.operator,
92+
.kg-code-card .token.entity,
93+
.kg-code-card .token.url,
94+
.language-css .token.string,
95+
.style .token.string {
96+
color: #8dbbe8;
97+
}
98+
99+
.kg-code-card .token.atrule,
100+
.kg-code-card .token.attr-value,
101+
.kg-code-card .token.keyword {
102+
color: var(--color-blue);
103+
}
104+
105+
.kg-code-card .token.function,
106+
.kg-code-card .token.class-name {
107+
color: var(--color-yellow);
108+
}
109+
110+
.kg-code-card .token.regex,
111+
.kg-code-card .token.important,
112+
.kg-code-card .token.variable {
113+
color: #f69d50;
114+
}

0 commit comments

Comments
 (0)