-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathcodeblock.css
More file actions
115 lines (102 loc) · 3.09 KB
/
Copy pathcodeblock.css
File metadata and controls
115 lines (102 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* SHIKI CODEBLOCK STYLES
Drives the highlighted output from <Codeblock />. Shiki emits CSS variables
(--shiki-light / --shiki-dark) so the theme switch happens without
re-highlighting on the client. */
.codeblock-shiki .shiki,
.codeblock-shiki .shiki span {
color: var(--shiki-light);
background-color: transparent;
}
.dark .codeblock-shiki .shiki,
.dark .codeblock-shiki .shiki span {
color: var(--shiki-dark);
background-color: transparent;
}
.codeblock-shiki .shiki,
.codeblock-shiki .shiki code {
font-size: 0.8125rem;
line-height: 1.55;
}
.codeblock-shiki .shiki {
margin: 0;
padding: 0.875rem 1rem;
width: fit-content;
min-width: 100%;
overflow: visible;
tab-size: 2;
}
/* When corner UI is overlaid, give the first line headroom so it never sits
underneath the language watermark / copy button. */
.codeblock-shiki.has-corner .shiki {
padding-top: 1.75rem;
}
/* Trim shiki's trailing empty line. */
.codeblock-shiki .shiki .line:last-child:has(> span:empty:only-child),
.codeblock-shiki .shiki .line:last-child:empty {
display: none;
}
/* Line numbers via CSS counter. Real disabled-color column with a hairline
inner separator — readable for keyboard users, still recedes visually. */
.codeblock-shiki.line-numbers .shiki code {
counter-reset: shiki-line;
}
.codeblock-shiki.line-numbers .shiki .line::before {
counter-increment: shiki-line;
content: counter(shiki-line);
display: inline-block;
width: 1.5rem;
padding-inline-end: 0.75rem;
margin-inline-end: 1rem;
border-inline-end: 1px solid hsla(var(--border-low-contrast));
text-align: end;
color: hsla(var(--disabled));
user-select: none;
font-variant-numeric: tabular-nums;
}
/* Collapsed surface: cap the code surface and flatten its bottom corners so
the expander row can sit flush beneath it. */
.codeblock-shiki.is-collapsed > [data-code-surface] {
max-height: calc((1.5rem * 8) + 1.75rem);
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
/* Fade overlay riding just above the expander row: dissolves the cut line of
code into the surface tint instead of hard-clipping it. */
.codeblock-shiki.is-collapsed::before {
content: "";
position: absolute;
inset-inline: 0;
bottom: 1.875rem;
height: 2.75rem;
background: linear-gradient(
to bottom,
transparent,
hsla(var(--background-highlight))
);
pointer-events: none;
z-index: 1;
}
/* Bottom inline expander — replaces the corner "Show all" button. Shares the
code surface tint so it reads as one continuous region. */
.codeblock-shiki .codeblock-expander {
display: flex;
align-items: center;
justify-content: center;
gap: 0.375rem;
width: 100%;
padding-block: 0.5rem 0.625rem;
font-size: 0.75rem;
line-height: 1;
color: hsla(var(--body-medium));
background: hsla(var(--background-highlight));
border-radius: 0 0 0.375rem 0.375rem;
cursor: pointer;
transition: color 120ms ease-out;
}
.codeblock-shiki .codeblock-expander:hover {
color: hsla(var(--primary));
}
.codeblock-shiki .codeblock-expander:focus-visible {
outline: 2px solid hsla(var(--primary));
outline-offset: 2px;
}