Skip to content

Commit 1f0760a

Browse files
authored
Fix API docs CSS files so dark mode works (#112023)
1 parent c546d15 commit 1f0760a

File tree

8 files changed

+212
-172
lines changed

8 files changed

+212
-172
lines changed

dev/docs/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**Welcome to the Flutter API reference documentation!**
1+
# Welcome to the Flutter API reference documentation!
22

33
Flutter is Google's SDK for crafting beautiful, fast user experiences for
44
mobile, web, and desktop from a single codebase. Flutter works with existing
@@ -8,7 +8,7 @@ and open source.
88
This API reference covers all libraries that are exported by the Flutter
99
SDK.
1010

11-
### More Documentation
11+
## More Documentation
1212

1313
This site hosts Flutter's API documentation. Other documentation can be found at
1414
the following locations:
@@ -18,9 +18,9 @@ the following locations:
1818
* [Codelabs](https://flutter.dev/docs/codelabs)
1919
* [Contributing to Flutter](https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md)
2020

21-
### Importing a Library
21+
## Importing a Library
2222

23-
#### Framework Libraries
23+
### Framework Libraries
2424

2525
Libraries in the "Libraries" section below (or in the left navigation) are part
2626
of the core Flutter framework and are imported using
@@ -31,7 +31,7 @@ import 'package:flutter/material.dart';
3131
import 'package:flutter/services.dart';
3232
```
3333

34-
#### Dart Libraries
34+
### Dart Libraries
3535

3636
Libraries in the "Dart" section exist in the `dart:` namespace and are imported
3737
using `'dart:<library>'`, like so:
@@ -43,7 +43,7 @@ import 'dart:ui';
4343

4444
Except for `'dart:core'`, you must import a Dart library before you can use it.
4545

46-
#### Supporting Libraries
46+
### Supporting Libraries
4747

4848
Libraries in other sections are supporting libraries that ship with Flutter.
4949
They are organized by package and are imported using
@@ -54,7 +54,7 @@ import 'package:flutter_test/flutter_test.dart';
5454
import 'package:file/local.dart';
5555
```
5656

57-
### Packages on pub.dev
57+
## Packages on pub.dev
5858

5959
Flutter has a rich ecosystem of packages that have been contributed by the
6060
Flutter team and the broader open source community to a central repository.

dev/docs/assets/overrides.css

Lines changed: 97 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,162 @@
11
/* Overrides for dartdoc styles. */
2-
body {
3-
font-size: 15px;
4-
font-family: Roboto, sans-serif;
5-
line-height: 1.5;
6-
color: #111;
7-
background-color: #fdfdfd;
8-
-webkit-font-smoothing: auto;
9-
}
102

11-
header {
12-
background-color: white;
13-
color: #424242;
14-
}
15-
16-
nav.navbar {
17-
min-height: 57px;
18-
padding: 6px 0;
3+
/* Prefer Open Sans for paragraph and other text */
4+
body {
5+
font-family: "Open Sans", "Roboto", sans-serif;
196
}
207

21-
header.header-fixed nav.navbar-fixed-top {
22-
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.37);
8+
/* Prefer Google Sans for headers */
9+
h1, h2, h3, h4, h5, h6 .h1, .h2, .h3, .h4, .h5, .h6 {
10+
font-family: "Google Sans", "Roboto", sans-serif;
2311
}
2412

25-
h1 {
26-
font-size: 42px !important;
27-
letter-spacing: -1px;
13+
.section-title, .breadcrumbs {
14+
font-family: "Google Sans", "Roboto", sans-serif;
2815
}
2916

17+
/* Make all the h2 headings slightly bigger. */
3018
h2 {
31-
color: #111;
32-
font-size: 24px;
33-
}
34-
35-
.markdown h2 {
3619
font-size: 24px;
3720
}
3821

3922
section.summary h2 {
40-
font-size: 24px;
4123
color: inherit;
4224
border-bottom: none;
4325
}
4426

45-
.sidebar ol,
46-
.sidebar ol li.section-title {
47-
font-size: inherit;
48-
}
49-
50-
@media screen and (max-width: 768px) {
51-
.sidebar-offcanvas-left.active {
52-
padding: 10px;
53-
}
54-
}
55-
56-
.sidebar-offcanvas-left ol {
57-
padding: 0 16px 16px 0;
58-
}
59-
60-
.sidebar-offcanvas-left h5 {
61-
display: none;
62-
}
63-
64-
pre,
65-
pre.prettyprint,
66-
pre > code {
67-
font-size: 14px;
68-
}
69-
70-
pre,
71-
pre.prettyprint {
72-
background: #f5f2f0;
27+
pre {
7328
margin: 0 0 15px 0;
7429
padding: 8px 12px;
75-
border: 1px solid #cccccc;
7630
border-radius: 4px;
7731
}
7832

7933
code {
34+
/* Inherit the background color, otherwise all inline code blocks have a
35+
different color from the rest of the paragraph */
8036
background-color: inherit;
8137
font-size: 1em; /* browsers default to smaller font for code */
8238
padding-left: 0; /* otherwise we get ragged left margins */
8339
padding-right: 0;
8440
}
8541

42+
/* Otherwise the description text is limited to a particular size instead of
43+
filling up the center of the page. */
8644
.markdown.desc {
8745
max-width: inherit;
8846
}
8947

48+
/* Make the search box bigger and easier to read */
9049
#search-box {
91-
color: #555;
92-
background-color: #fff;
93-
background-image: none;
94-
border: 1px solid #ccc;
95-
border-radius: 2px;
96-
padding: 4px 6px;
50+
height: 24px;
9751
font-size: 15px;
52+
padding-left: 40px;
9853
}
9954

55+
/* Make the typeahead match the search box font size */
10056
input.form-control.typeahead {
101-
padding: 4px 7px;
10257
font-size: 15px;
10358
}
10459

60+
/* Make description list terms not be so dim. */
10561
dl.dl-horizontal dt {
10662
color: inherit;
10763
}
10864

109-
/* Line the material icons up with their labels */
65+
/* Line the material icons up with their labels
66+
See https://api.flutter.dev/flutter/material/Icons-class.html
67+
for where this matters.
68+
*/
11069
i.md-36 {
111-
vertical-align: bottom;
70+
vertical-align: middle;
11271
}
11372

114-
/* address a style issue with the background of code sections */
73+
/* Address a style issue with the background of code sections. Without this, the
74+
code inside a code block has a different background from the rest of the box. */
11575
code.hljs {
11676
background: inherit;
11777
}
11878

79+
/* Make the footer smaller and less prominent. */
11980
footer {
12081
font-size: 13px;
121-
padding: 12px 20px;
82+
padding: 8px;
12283
}
84+
12385
/* Override the comment color for highlight.js to make it more
124-
prominent/readable */
86+
prominent. */
12587
.hljs-comment {
12688
color: #128c00;
12789
font-style: italic;
12890
font-weight: bold;
12991
}
13092

131-
/* Constrain image width to container */
93+
/* Make the summary headers contrast a bit with text. */
94+
.summary h2 {
95+
opacity: 0.8;
96+
}
97+
98+
/* Constrain the image width to the container so that images resize instead of
99+
causing the page to scroll horizontally */
132100
img {
133101
max-width: 100%
134102
}
103+
104+
/* Light/Dark Theme adjustments */
105+
106+
.light-theme {
107+
/* This is the same link color as the main Flutter site */
108+
--main-hyperlinks-color: rgb(19, 137, 253);
109+
--main-footer-background: #eee;
110+
}
111+
112+
.dark-theme {
113+
--main-hyperlinks-color: rgb(81, 167, 254);
114+
}
115+
116+
.light-theme footer {
117+
color: rgb(74, 74, 74);
118+
}
119+
120+
.dark-theme footer {
121+
color:rgb(220, 220, 220);
122+
}
123+
124+
body.light-theme {
125+
color:rgb(74, 74, 74);
126+
}
127+
128+
body.dark-theme {
129+
color:rgb(220, 220, 220);
130+
}
131+
132+
.dark-theme .multi-line-signature .name {
133+
color: rgb(163, 163, 163);
134+
}
135+
136+
.dark-theme .parameter-name {
137+
color: rgb(163, 163, 163);
138+
}
139+
140+
.dark-theme .parameter {
141+
color: rgb(163, 163, 163);
142+
}
143+
144+
.light-theme pre {
145+
border: 1px solid white;
146+
color: #222;
147+
background-color:#eee;
148+
}
149+
150+
.dark-theme pre {
151+
border: 1px solid #444;
152+
color: white;
153+
background-color:rgb(23, 32, 43);
154+
}
155+
156+
.dark-theme .hljs-string {
157+
color:rgb(255, 100, 100);
158+
}
159+
160+
.dark-theme .hljs-title {
161+
color:rgb(192, 184, 255);
162+
}

0 commit comments

Comments
 (0)