Skip to content

Commit 9ca753e

Browse files
committed
css: fix swagger styling
* Change order of css include so swagger styles can be overridden * Add css file for fixing swagger-ui styles (especially in dark mode) Signed-off-by: Mike Szczys <[email protected]>
1 parent dd424d9 commit 9ca753e

File tree

3 files changed

+108
-6
lines changed

3 files changed

+108
-6
lines changed

docusaurus.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ module.exports = {
178178
// },
179179
theme: {
180180
customCss: [
181-
require.resolve("./src/css/custom.css"),
182181
require.resolve("swagger-ui-react/swagger-ui.css"),
182+
require.resolve("./src/css/custom.css"),
183+
require.resolve("./src/css/custom-swagger-ui.css"),
183184
],
184185
},
185186
},

src/css/custom-swagger-ui.css

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.swagger-ui pre {
2+
background-color: unset;
3+
}
4+
5+
.swagger-ui .info a,
6+
html[data-theme="dark"] .swagger-ui .info a {
7+
color: var(--ifm-color-primary);
8+
}
9+
10+
html[data-theme="dark"] .swagger-ui .info .title,
11+
html[data-theme="dark"] .swagger-ui .info .base-url,
12+
html[data-theme="dark"] .swagger-ui a.nostyle,
13+
html[data-theme="dark"] .swagger-ui [class^="parameter__"],
14+
html[data-theme="dark"] .swagger-ui .prop-format,
15+
html[data-theme="dark"] .swagger-ui table,
16+
html[data-theme="dark"] .swagger-ui .tab,
17+
html[data-theme="dark"] .swagger-ui .tab li,
18+
html[data-theme="dark"] .swagger-ui table thead tr td,
19+
html[data-theme="dark"] .swagger-ui table thead tr th,
20+
html[data-theme="dark"] .swagger-ui .response-col_status,
21+
html[data-theme="dark"] .swagger-ui [class^="responses-"] h4,
22+
html[data-theme="dark"] .swagger-ui [class^="responses-"] h5,
23+
html[data-theme="dark"] .swagger-ui .opblock .opblock-section-header h4,
24+
html[data-theme="dark"] .swagger-ui .opblock .opblock-section-header > label,
25+
html[data-theme="dark"] .swagger-ui label,
26+
html[data-theme="dark"] .swagger-ui .scheme-container .schemes > label ,
27+
html[data-theme="dark"] .swagger-ui .scheme-container .schemes > .schemes-server-container > label,
28+
html[data-theme="dark"] .swagger-ui section.models h4,
29+
html[data-theme="dark"] .swagger-ui [class^="model"],
30+
html[data-theme="dark"] .swagger-ui .model .property.primitive,
31+
html[data-theme="dark"] .swagger-ui .model-toggle.collapsed,
32+
html[data-theme="dark"] .swagger-ui .dialog-ux .modal-ux-header h3,
33+
html[data-theme="dark"] .swagger-ui .dialog-ux .modal-ux-content h4,
34+
html[data-theme="dark"] .swagger-ui .dialog-ux .modal-ux-content p,
35+
html[data-theme="dark"] .swagger-ui .errors-wrapper {
36+
color: var(--golioth-color-white);
37+
}
38+
39+
html[data-theme="dark"] .swagger-ui .scheme-container {
40+
box-shadow: 0 1px 2px 0 rgba(255, 255, 255, .3);
41+
}
42+
43+
html[data-theme="dark"] .swagger-ui .opblock-tag,
44+
html[data-theme="dark"] .swagger-ui section.models.is-open h4 {
45+
border-bottom: 1px solid rgba(255, 255, 255, .3);
46+
}
47+
48+
html[data-theme="dark"] .swagger-ui section.models {
49+
border: 1px solid rgba(255, 255, 255, .3);
50+
}
51+
52+
html[data-theme="dark"] .swagger-ui .dialog-ux .modal-ux {
53+
background-color: var(--golioth-color-cod-gray);
54+
}
55+
56+
html[data-theme="dark"] .swagger-ui .btn {
57+
color: var(--golioth-color-white);
58+
}
59+
60+
html[data-theme="dark"] .swagger-ui .parameter__name.required span,
61+
html[data-theme="dark"] .swagger-ui .parameter__name.required::after,
62+
html[data-theme="dark"] .swagger-ui .prop-type {
63+
color: var(--golioth-color-lightning-yellow);
64+
}
65+
66+
html[data-theme="dark"] .swagger-ui section.models .model-container {
67+
background: rgba(80,227,194,.1);
68+
border: 1px solid #50e3c2;
69+
}
70+
71+
html[data-theme="dark"] .swagger-ui .opblock-tag svg ,
72+
html[data-theme="dark"] .swagger-ui .opblock .opblock-summary svg,
73+
html[data-theme="dark"] .swagger-ui section.models h4 svg,
74+
html[data-theme="dark"] .swagger-ui .model-toggle,
75+
html[data-theme="dark"] .swagger-ui .model-toggle.collapsed {
76+
filter: invert(100%);
77+
}
78+
79+
/* Don't invert the clipboard icon in dark */
80+
html[data-theme="dark"] .swagger-ui .opblock .opblock-summary .view-line-link.copy-to-clipboard svg {
81+
filter: unset;
82+
}
83+
84+
html[data-theme="dark"] .swagger-ui .scheme-container,
85+
html[data-theme="dark"] .swagger-ui .opblock .opblock-section-header {
86+
background-color: unset;
87+
}
88+
89+
html[data-theme="dark"] .swagger-ui input[type],
90+
html[data-theme="dark"] .swagger-ui textarea .swagger-ui .opblock .opblock-section-header {
91+
color: var(--golioth-color-white);
92+
background-color: var(--golioth-color-cod-gray);
93+
}
94+
95+
html[data-theme="dark"] .swagger-ui .opblock-body pre.microlight {
96+
background-color: var(--golioth-color-cod-gray) !important;
97+
}
98+
99+
html[data-theme="dark"] .swagger-ui .loading-container .loading {
100+
filter: invert(100%);
101+
}
102+
103+
html[data-theme="dark"] .swagger-ui .markdown code, .swagger-ui .renderedMarkdown code {
104+
color: var(--golioth-color-lightning-yellow);
105+
}

src/css/custom.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
--golioth-color-cod-gray: #1a1a1a;
1515
--golioth-color-charcoal: #353535;
1616
--golioth-color-concrete: #f2f2f2;
17-
--golioth-color-blac: #000000;
17+
--golioth-color-black: #000000;
1818
--golioth-color-white: #ffffff;
1919

2020
--ifm-color-primary: var(--golioth-color-coral);
@@ -99,10 +99,6 @@ button [class^="lightToggleIcon"]:not(:hover) {
9999
padding: 0 var(--ifm-pre-padding);
100100
}
101101

102-
.swagger-ui pre {
103-
background-color: unset;
104-
}
105-
106102
html[data-theme="dark"] {
107103
--ifm-color-primary: var(--golioth-color-coral);
108104
--ifm-color-primary-dark: #d23c43;

0 commit comments

Comments
 (0)