From 003b2bc1c65251ec2fc80b78ed91c43fb35402ec Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 20 Jan 2018 21:12:00 +0100 Subject: [PATCH 1/6] Add possibility to have multiple themes --- src/librustdoc/html/layout.rs | 8 +- src/librustdoc/html/render.rs | 82 +++- src/librustdoc/html/static/main.js | 12 +- src/librustdoc/html/static/rustdoc.css | 38 +- src/librustdoc/html/static/themes/dark.css | 382 ++++++++++++++++++ .../html/static/{styles => themes}/main.css | 23 ++ 6 files changed, 537 insertions(+), 8 deletions(-) create mode 100644 src/librustdoc/html/static/themes/dark.css rename src/librustdoc/html/static/{styles => themes}/main.css (96%) diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 3a18c6b8a809e..105b5b103a565 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -47,8 +47,8 @@ r##" {title} - - + + {css_extension} {favicon} @@ -70,6 +70,10 @@ r##" {sidebar} +
🖌 +
+
+ -
🖌 +
+ Pick another theme!
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 95db6a8679e5d..ad785fb830a56 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -890,6 +890,8 @@ fn write_shared(cx: &Context, themes.insert(try_none!(try_none!(entry.file_stem(), &entry).to_str(), &entry).to_owned()); } + write(cx.dst.join("brush.svg"), + include_bytes!("static/brush.svg"))?; write(cx.dst.join("main.css"), include_bytes!("static/themes/main.css"))?; themes.insert("main".to_owned()); diff --git a/src/librustdoc/html/static/brush.svg b/src/librustdoc/html/static/brush.svg new file mode 100644 index 0000000000000..072264a640830 --- /dev/null +++ b/src/librustdoc/html/static/brush.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 43d00486ca228..05ac066039656 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -361,6 +361,7 @@ kbd { #theme-picker { border-color: #e0e0e0; + background: #f0f0f0; } #theme-choices { From 5f93159e9ddc05f479ade72e604a0267b5413be7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 22 Jan 2018 23:44:08 +0100 Subject: [PATCH 5/6] Fasten up theme loading --- src/librustdoc/html/layout.rs | 7 +++-- src/librustdoc/html/render.rs | 23 +------------- src/librustdoc/html/static/storage.js | 44 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 src/librustdoc/html/static/storage.js diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 753abf4eacf4f..7b4781870de66 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -48,7 +48,8 @@ r##" - + + {css_extension} {favicon} @@ -70,10 +71,10 @@ r##" {sidebar} -
+
+