Skip to content

Commit 326e28e

Browse files
authored
Restyle openapi blocks (#3169)
1 parent 90f0127 commit 326e28e

File tree

21 files changed

+468
-305
lines changed

21 files changed

+468
-305
lines changed

.changeset/lemon-actors-sing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gitbook/react-openapi": minor
3+
"gitbook": minor
4+
---
5+
6+
Design tweaks to code blocks and OpenAPI pages

packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlockRenderer.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525

2626
.highlight-line-number {
27-
@apply text-sm text-right pr-3.5 rounded-l pl-2 sticky left-[-3px] bg-gradient-to-r from-80% from-tint to-transparent;
27+
@apply text-sm text-right pr-3.5 rounded-l pl-2 sticky left-[-3px] bg-gradient-to-r from-80% from-tint-subtle contrast-more:from-tint-base theme-muted:from-tint-base [html.theme-bold.sidebar-filled_&]:from-tint-base to-transparent;
2828
@apply before:text-tint before:content-[counter(line)];
2929

3030
.highlight-line.highlighted > & {

packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlockRenderer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
3939
>
4040
<div className="flex items-center justify-start gap-2 text-sm [grid-area:1/1]">
4141
{title ? (
42-
<div className="inline-flex items-center justify-center rounded-t straight-corners:rounded-t-s bg-tint px-3 py-2 text-tint text-xs leading-none tracking-wide">
42+
<div className="relative top-px z-20 inline-flex items-center justify-center rounded-t straight-corners:rounded-t-s border border-tint-subtle border-b-0 bg-tint-subtle theme-muted:bg-tint-base px-3 py-2 text-tint text-xs leading-none tracking-wide contrast-more:border-tint contrast-more:bg-tint-base [html.theme-bold.sidebar-filled_&]:bg-tint-base">
4343
{title}
4444
</div>
4545
) : null}
@@ -50,8 +50,8 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
5050
/>
5151
<pre
5252
className={tcls(
53-
'hide-scroll relative overflow-auto bg-tint theme-gradient:bg-tint-12/1 ring-tint-subtle [grid-area:2/1]',
54-
'rounded-md straight-corners:rounded-sm',
53+
'hide-scroll relative overflow-auto border border-tint-subtle bg-tint-subtle theme-muted:bg-tint-base [grid-area:2/1] contrast-more:border-tint contrast-more:bg-tint-base [html.theme-bold.sidebar-filled_&]:bg-tint-base',
54+
'rounded-md straight-corners:rounded-sm shadow-sm',
5555
title && 'rounded-ss-none'
5656
)}
5757
>
Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,67 @@
11
:root {
22
--shiki-color-text: theme("colors.tint.11");
3-
--shiki-token-constant: #0a6355;
4-
--shiki-token-string: #8b6d32;
5-
--shiki-token-comment: theme("colors.teal.700/.64");
6-
--shiki-token-keyword: theme("colors.pomegranate.600");
7-
--shiki-token-parameter: #0a3069;
8-
--shiki-token-function: #8250df;
9-
--shiki-token-string-expression: #6a4906;
10-
--shiki-token-punctuation: theme("colors.pomegranate.700/.92");
11-
--shiki-token-link: theme("colors.tint.12");
12-
--shiki-token-inserted: #22863a;
13-
--shiki-token-deleted: #b31d28;
14-
--shiki-token-changed: #8250df;
3+
--shiki-token-punctuation: theme("colors.tint.11");
4+
--shiki-token-comment: theme("colors.neutral.9/.7");
5+
--shiki-token-link: theme("colors.primary.10");
6+
7+
--shiki-token-constant: theme("colors.warning.10");
8+
--shiki-token-string: theme("colors.success.10");
9+
--shiki-token-string-expression: theme("colors.success.10");
10+
--shiki-token-keyword: theme("colors.danger.10");
11+
--shiki-token-parameter: theme("colors.warning.10");
12+
--shiki-token-function: theme("colors.primary.10");
13+
14+
--shiki-token-inserted: theme("colors.success.10");
15+
--shiki-token-deleted: theme("colors.danger.10");
16+
--shiki-token-changed: theme("colors.tint.12");
17+
}
18+
19+
@media (prefers-contrast: more) {
20+
:root {
21+
--shiki-color-text: theme("colors.tint.12");
22+
--shiki-token-punctuation: theme("colors.tint.12");
23+
--shiki-token-comment: theme("colors.neutral.11");
24+
--shiki-token-link: theme("colors.primary.11");
25+
26+
--shiki-token-constant: theme("colors.warning.11");
27+
--shiki-token-string: theme("colors.success.11");
28+
--shiki-token-string-expression: theme("colors.success.11");
29+
--shiki-token-keyword: theme("colors.danger.11");
30+
--shiki-token-parameter: theme("colors.warning.11");
31+
--shiki-token-function: theme("colors.primary.11");
32+
33+
--shiki-token-inserted: theme("colors.success.11");
34+
--shiki-token-deleted: theme("colors.danger.11");
35+
--shiki-token-changed: theme("colors.tint.12");
36+
}
1537
}
1638

1739
html.dark {
18-
--shiki-color-text: theme("colors.tint.11");
19-
--shiki-token-constant: #d19a66;
20-
--shiki-token-string: theme("colors.pomegranate.300");
21-
--shiki-token-comment: theme("colors.teal.300/.64");
22-
--shiki-token-keyword: theme("colors.pomegranate.400");
23-
--shiki-token-parameter: theme("colors.yellow.500");
24-
--shiki-token-function: #56b6c2;
25-
--shiki-token-string-expression: theme("colors.tint.11");
26-
--shiki-token-punctuation: #acc6ee;
27-
--shiki-token-link: theme("colors.pomegranate.400");
28-
--shiki-token-inserted: #85e89d;
29-
--shiki-token-deleted: #fdaeb7;
30-
--shiki-token-changed: #56b6c2;
40+
/* Override select colors to have more contrast */
41+
--shiki-token-comment: theme("colors.neutral.9");
42+
43+
--shiki-token-constant: theme("colors.warning.11");
44+
--shiki-token-string: theme("colors.success.11");
45+
--shiki-token-string-expression: theme("colors.success.11");
46+
--shiki-token-keyword: theme("colors.danger.11");
47+
--shiki-token-parameter: theme("colors.warning.11");
48+
--shiki-token-function: theme("colors.primary.11");
49+
}
50+
51+
.code-monochrome {
52+
--shiki-token-constant: theme("colors.tint.11");
53+
--shiki-token-string: theme("colors.tint.12");
54+
--shiki-token-string-expression: theme("colors.tint.12");
55+
--shiki-token-keyword: theme("colors.primary.10");
56+
--shiki-token-parameter: theme("colors.tint.9");
57+
--shiki-token-function: theme("colors.primary.9");
58+
}
59+
60+
html.dark.code-monochrome {
61+
--shiki-token-constant: theme("colors.tint.11");
62+
--shiki-token-string: theme("colors.tint.12");
63+
--shiki-token-string-expression: theme("colors.tint.12");
64+
--shiki-token-keyword: theme("colors.primary.11");
65+
--shiki-token-parameter: theme("colors.tint.10");
66+
--shiki-token-function: theme("colors.primary.10");
3167
}

0 commit comments

Comments
 (0)