Skip to content

Fix #7595: Redesign dottydoc theme #7612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions doc-tool/bootstrap-theme/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/bin/sh
cd "$(dirname "$0")"
if [ ! -d "node_modules" ]; then
npm install
fi
npm run build
echo "Copying css file..."
echo "Copying CSS result..."
cp target/bootstrap.min.css ../resources/css/bootstrap.min.css
echo "Bootstrap css updated."

# Update the generated website without running sbt
gen_dir=../../docs/_site/css
if [ -d "$gen_dir" ]; then
cp ../resources/css/* $gen_dir/
fi

echo "Bootstrap CSS updated."
74 changes: 64 additions & 10 deletions doc-tool/bootstrap-theme/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,66 @@
@import "node_modules/bootstrap/scss/mixins";

// Web fonts
@import url('https://fonts.googleapis.com/css?family=Roboto+Slab:300|Source+Code+Pro:400,600|Source+Sans+Pro:400,600|Lobster&display=fallback');
@import url('https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:300|Fira+Code:400,700&display=fallback');

// Custom colors
$pro-grey: #414551;
$soft-red: #ca445e;
$light: #fafafa;
$code-color: $soft-red; // overrides bootstrap

// Custom values that override the default variables of Bootstrap
$theme-colors: (
"primary": #002b36, // primary toolbar+sidebar dark color
"secondary": #ca445e, // secondary color used on light backgrounds
"secondary-lite": #ca44c822, // less opaque version of secondary
"accent": #ca445e, // secondary-like for dark backgrounds
"contrast": #f26527, // used on dark backgrounds
"primary": $pro-grey,
"secondary": $soft-red
);

$colors: (
"light": $light,

"toolbar": $pro-grey,
"toolbar-entry": $light,
"toolbar-active": lighten($pro-grey, 25),

"sidebar": $light,
"sidebar-category": #000,
"sidebar-page": $pro-grey,
"sidebar-active": $soft-red,

"pre-bg": $light, // <pre> blocks of code background
"doc-bg": rgba($soft-red, 0.135) //#ca44c822
);

// Responsive control
$container-max-widths: (
md: 720px,
lg: 960px,
xl: 960px
);

$code-color: theme-color("secondary");
$font-family-monospace: "Source Code Pro", "Andale Mono", "Courier New", monospace;
$font-family-sans-serif: "Source Sans Pro", "Tahoma", "Geneva", sans-serif;
// Body Fonts
$font-family-monospace: "Fira Code", "Andale Mono", monospace;
$font-family-sans-serif: "Lato", sans-serif;
$font-family-serif: "Roboto Slab", "Georgia", serif;
$font-family-base: $font-family-serif;
$headings-font-family: $font-family-sans-serif;

$font-weight-light: 300;
$font-weight-normal: 400;
$font-weight-bold: 700;
$headings-font-weight: 400;

// Nav Fonts
$toolbar-main-font: $headings-font-family;
$toolbar-main-weight: $font-weight-normal;
$toolbar-details-font: $headings-font-family;
$toolbar-details-weight: $font-weight-normal;

$sidebar-font: $headings-font-family;
$sidebar-category-weight: $font-weight-normal;
$sidebar-category-size: 18px;
$sidebar-page-weight: $font-weight-normal;
$sidebar-page-size: 1rem;

// Features imports - follow the order of bootstrap.scss (bootstrap's module)
@import "node_modules/bootstrap/scss/root";
@import "node_modules/bootstrap/scss/reboot";
Expand All @@ -43,3 +80,20 @@ $headings-font-family: $font-family-sans-serif;
@import "node_modules/bootstrap/scss/badge";
@import "node_modules/bootstrap/scss/spinners";
@import "node_modules/bootstrap/scss/utilities";

// Additional CSS variables
:root {
--font-family-toolbar-main: #{inspect($toolbar-main-font)};
--font-weight-toolbar-main: #{$toolbar-main-weight};

--font-family-toolbar-details: #{inspect($toolbar-details-font)};
--font-weight-toolbar-details: #{$toolbar-details-weight};

--font-family-sidebar: #{inspect($sidebar-font)};

--font-size-sidebar-category: #{$sidebar-category-size};
--font-weight-sidebar-category: #{$sidebar-category-weight};

--font-size-sidebar-page: #{$sidebar-page-size};
--font-weight-sidebar-page: #{$sidebar-page-weight};
}
2 changes: 1 addition & 1 deletion doc-tool/resources/css/bootstrap.min.css

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions doc-tool/resources/css/dottydoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,16 @@ footer img#author-img {
line-height: 50px;
text-align: center;
text-decoration: none;
font-size: 42px;
font-size: 43px;
font-family: var(--font-family-sans-serif);
}

.api span.letter-anchor.object {
line-height: 48px;
}
.api span.letter-anchor.class {
line-height: 48px;
padding-right: 3px;
}
.letter-anchor.object {
background: #2c6c8d;
}
Expand Down Expand Up @@ -154,7 +160,7 @@ footer img#author-img {
width: 100%;
}
.api .member:hover {
background: var(--secondary-lite);
background: var(--doc-bg);
cursor: pointer;
}
.api .left-column {
Expand All @@ -175,10 +181,13 @@ footer img#author-img {
}

/* code */
pre, code {
font-variant-ligatures: none;
}
pre {
padding: 0;
font-size: 13px;
background: rgba(244, 243, 244, 0.6);
background: var(--pre-bg);
border-radius: 2px;
border: 1px solid rgba(0, 0, 0, 0.1);
}
Expand Down Expand Up @@ -222,10 +231,10 @@ aside.success {
background-color: grey;
}
.gitter-open-chat-button:focus, .gitter-open-chat-button:hover {
background-color: var(--secondary);
background-color: var(--primary);
}
.gitter-open-chat-button:focus {
box-shadow: 0 0 8px var(--secondary);
box-shadow: 0 0 8px var(--primary);
}
.gitter-chat-embed {
top: 40px; /* 50px (navbar) - 10px (aside's margin) */
Expand Down Expand Up @@ -253,4 +262,7 @@ aside.success {
display: flex;
flex-flow: wrap;
}
main.container {
padding: 15px 45px;
}
}
64 changes: 36 additions & 28 deletions doc-tool/resources/css/sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@
top: 50px;
left: 0;
z-index: 1000;
width: 100%;
width: 275px;
height: 100%;
/* Safari and some others don't support overflow: x y */
overflow-x: hidden;
overflow-x: hidden; /* Safari and some others don't support overflow: x y */
overflow-y: auto;
-webkit-overflow-scrolling: touch; /* nicer scrolling on touch screens */
font-family: var(--font-family-sans-serif);
font-weight: 400;
background: var(--primary);
border-top: 1px solid black;
/* hidden by default, shown by toggle (on small screens) */
visibility: hidden;
opacity: 0;
transition: visibility .25s ease-out, opacity .25s ease-out;
font-family: var(--font-family-sidebar);
background: var(--sidebar);
margin-left: -275px; /* invisible by default, shown by toggle */
transition: margin .25s ease-out;
}

.sidebar.toggled {
visibility: visible;
opacity: 1;
margin-left: 0;
box-shadow: -2px 0 8px var(--primary);
}

.sidebar ul.toc {
Expand Down Expand Up @@ -52,16 +47,28 @@
padding-left: 0;
}

.sidebar .toc > li {
border-left: 2px solid var(--accent);
.sidebar .index-entity.entity-package {
margin-left: 5px;
margin-top: .25em;
}

.sidebar .toc > li:not(.index-entities) > ul {
border-left: 2px solid var(--sidebar-active);
padding-left: 1em;
margin-left: 5px;
}

.sidebar li a {
font-size: var(--font-size-sidebar-page);
font-weight: var(--font-weight-sidebar-page);
}

.sidebar > ul > li.leaf > a, .sidebar li.section > a {
color: white;
font-size: 18px;
text-transform: uppercase;
font-size: var(--font-size-sidebar-category);
font-weight: var(--font-weight-sidebar-category);
text-transform: capitalize;
cursor: pointer;
color: var(--sidebar-category);
}

.sidebar .entity-package > .entity-name {
Expand All @@ -70,17 +77,18 @@

.sidebar a {
width: 100%;
color: var(--contrast);
color: var(--sidebar-page);
transition: color .2s ease-out;
}
.sidebar a:hover {
color: var(--accent) !important;
.sidebar a:hover, .sidebar a.toggled {
color: var(--sidebar-active) !important;
}

/* API Documentation */
.package-toggle i.fas {
font-size: 15px;
margin-right: 5px;
margin-right: 1px;
color: var(--sidebar-active);
}

.entity-kinds {
Expand All @@ -105,9 +113,11 @@
}
.entity-kinds a.class {
background: #44ad7d;
padding-right: 1px;
}
.entity-kinds a.trait {
background: #19aacf;
padding-right: 1px;
}

.with-companion .entity-kinds:not(:hover) a.object {
Expand All @@ -122,17 +132,15 @@

@media (min-width: 768px) {
.sidebar { /* visible by default, hidden by toggle */
width: 320px;
visibility: visible;
opacity: 1;
margin-left: 0;
transition: margin .25s ease-out;
box-shadow: -2px 0 8px var(--primary);
}
.sidebar.toggled {
margin-left: -320px;
margin-left: -275px;
box-shadow: none;
}
#content-wrapper {
margin-left: 320px !important;
margin-left: 275px !important;
transition: margin .25s ease-out;
}
.sidebar.toggled ~ #content-wrapper {
Expand Down
16 changes: 9 additions & 7 deletions doc-tool/resources/css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ nav.navbar {
height: 50px;
line-height: 1;
font-size: 24px;
font-family: var(--font-family-sans-serif);
background: var(--primary);
font-family: var(--font-family-toolbar-details);
background-color: var(--toolbar);
box-shadow: 0 0 6px;
}
nav.navbar-dark * {
color: white;
color: var(--toolbar-entry);
transition: color .2s ease-out;
}

nav.navbar-dark a:hover *, nav.navbar-dark a:focus * {
color: var(--accent);
color: var(--toolbar-active);
}
nav.navbar a:hover {
text-decoration: none;
Expand Down Expand Up @@ -43,13 +44,14 @@ nav.navbar a {
line-height: inherit;
}
.navbar-brand .project-details h1 {
font-size: 1.1em;
font-family: "Lobster", cursive;
font-size: 1em;
font-family: var(--font-family-toolbar-main);
font-weight: var(--font-weight-toolbar-main);
}
.navbar-brand .project-details h2 {
font-size: 0.5em;
color: grey;
margin-top: 2px;
font-weight: var(--font-weight-toolbar-details);
}

#search-api-input {
Expand Down
6 changes: 3 additions & 3 deletions doc-tool/src/dotty/tools/dottydoc/staticsite/tags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ object tags {
suffixes.find(url.endsWith(_)).map(url.replace(_, ".html")).getOrElse(url)
}
private def renderTitle(t: Title, pageUrl: String): String = {
val htmlPath = replaceSuffix(pageUrl, Seq("-spec.md", "-details.md", "-new.md", ".md"))
val marker = if (isParent(t, htmlPath)) "class=\"toggled\"" else ""
if (!t.url.isDefined && t.subsection.nonEmpty) {
val htmlPath = replaceSuffix(pageUrl, Seq("-spec.md", "-details.md", ".md"))
val marker = if (isParent(t, htmlPath)) "class=\"toggled\"" else ""
s"""|<li class="section">
| <a onclick='toggleSection(this);'>${t.title}</a>
| <ul $marker>
Expand All @@ -185,7 +185,7 @@ object tags {
}
else if (t.url.isDefined) {
val url = t.url.get
s"""<li class="leaf"><a href="$baseurl/$url">${t.title}</a></li>"""
s"""<li class="leaf"><a href="$baseurl/$url" $marker>${t.title}</a></li>"""
}
else {
ctx.docbase.error(
Expand Down
2 changes: 2 additions & 0 deletions docs/css/frontpage.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import url('https://fonts.googleapis.com/css?family=Lobster&display=swap');

body {
height: 100%;
width: 100%;
Expand Down