Only regenerate css when feature regenerate-css is enabled

This commit is contained in:
Mathieu David 2015-09-24 15:37:20 +02:00
parent efc0f40466
commit a177a9e10d
4 changed files with 464 additions and 15 deletions

2
.gitignore vendored
View File

@ -3,5 +3,3 @@ Cargo.lock
book-test book-test
book-example/book book-example/book
src/theme/book.css

View File

@ -26,6 +26,7 @@ tempdir = "*"
default = ["output"] default = ["output"]
debug = [] debug = []
output = [] output = []
regenerate-css = []
[[bin]] [[bin]]
doc = false doc = false

View File

@ -6,6 +6,8 @@ use std::path::Path;
fn main() { fn main() {
if let Ok(_) = env::var("CARGO_FEATURE_REGENERATE_CSS") {
// Compile stylus stylesheet to css // Compile stylus stylesheet to css
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
@ -22,5 +24,6 @@ fn main() {
.success() { .success() {
panic!("Stylus encoutered an error"); panic!("Stylus encoutered an error");
} }
}
} }

447
src/theme/book.css Normal file
View File

@ -0,0 +1,447 @@
html,
body {
font-family: "Open Sans", sans-serif;
color: #333;
}
.left {
float: left;
}
.right {
float: right;
}
.sidebar {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 300px;
overflow-y: auto;
padding: 10px 10px;
font-size: 0.875em;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
-webkit-transition: left 0.5s;
-moz-transition: left 0.5s;
-o-transition: left 0.5s;
-ms-transition: left 0.5s;
transition: left 0.5s;
}
@media only screen and (max-width: 1060px) {
.sidebar {
left: -300px;
}
}
.chapter {
list-style: none outside none;
padding-left: 0;
line-height: 1.9em;
}
.chapter li a {
padding: 5px 0;
text-decoration: none;
}
.chapter li a:hover {
text-decoration: none;
}
.chapter .spacer {
width: 100%;
height: 3px;
margin: 10px 0px;
}
.section {
list-style: none outside none;
padding-left: 20px;
line-height: 2.5em;
}
.section li {
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.page-wrapper {
position: absolute;
overflow-y: auto;
left: 315px;
right: 0;
top: 0;
bottom: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
min-height: 100%;
-webkit-transition: left 0.5s;
-moz-transition: left 0.5s;
-o-transition: left 0.5s;
-ms-transition: left 0.5s;
transition: left 0.5s;
}
@media only screen and (max-width: 1060px) {
.page-wrapper {
left: 15px;
padding-right: 15px;
}
}
.page {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
padding-right: 15px;
overflow-y: auto;
}
.content {
margin-left: auto;
margin-right: auto;
max-width: 750px;
padding-bottom: 50px;
}
.content a {
text-decoration: none;
}
.content a:hover {
text-decoration: underline;
}
.content img {
max-width: 100%;
}
.menu-bar {
position: relative;
height: 50px;
}
.menu-bar i {
position: relative;
margin: 0 10px;
z-index: 10;
line-height: 50px;
-webkit-transition: color 0.5s;
-moz-transition: color 0.5s;
-o-transition: color 0.5s;
-ms-transition: color 0.5s;
transition: color 0.5s;
}
.menu-bar i:hover {
cursor: pointer;
}
.menu-bar .left-buttons {
float: left;
}
.menu-bar .right-buttons {
float: right;
}
.menu-title {
display: inline-block;
font-weight: 200;
font-size: 20px;
line-height: 50px;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
text-align: center;
margin: 0;
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
-webkit-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out;
-o-transition: opacity 0.5s ease-in-out;
-ms-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
}
.menu-bar:hover .menu-title {
opacity: 1;
-ms-filter: none;
filter: none;
}
.nav-chapters {
font-size: 2.5em;
text-align: center;
text-decoration: none;
position: absolute;
top: 50px /* Height of menu-bar */;
bottom: 0;
margin: 0;
max-width: 150px;
min-width: 90px;
display: -webkit-box;
display: -moz-box;
display: -webkit-flex;
display: -ms-flexbox;
display: box;
display: flex;
-webkit-box-pack: center;
-moz-box-pack: center;
-o-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-ms-flex-line-pack: center;
-webkit-align-content: center;
align-content: center;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-o-box-orient: vertical;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-transition: color 0.5s;
-moz-transition: color 0.5s;
-o-transition: color 0.5s;
-ms-transition: color 0.5s;
transition: color 0.5s;
}
.mobile-nav-chapters {
display: none;
}
.nav-chapters:hover {
text-decoration: none;
}
.previous {
left: 0;
}
.next {
right: 0;
}
.theme-popup {
position: fixed;
left: -40px;
-webkit-border-radius: 4px;
border-radius: 4px;
font-size: 0.7em;
}
.theme-popup .theme {
margin: 0;
padding: 2px 10px;
line-height: 25px;
white-space: nowrap;
}
@media only screen and (max-width: 1250px) {
.nav-chapters {
display: none;
}
.mobile-nav-chapters {
font-size: 2.5em;
text-align: center;
text-decoration: none;
max-width: 150px;
min-width: 90px;
-webkit-box-pack: center;
-moz-box-pack: center;
-o-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-ms-flex-line-pack: center;
-webkit-align-content: center;
align-content: center;
position: relative;
display: inline-block;
margin-bottom: 50px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.next {
float: right;
}
.previous {
float: left;
}
}
.light {
color: #333;
background-color: #fff;
}
.light .sidebar {
background-color: #fafafa;
color: #364149;
}
.light .chapter li {
color: #aaa;
}
.light .chapter li a {
color: #364149;
}
.light .chapter li .active,
.light .chapter li a:hover {
/* Animate color change */
color: #008cff;
}
.light .chapter .spacer {
background-color: #f4f4f4;
}
.light .menu-bar,
.light .nav-chapters,
.light .mobile-nav-chapters {
color: #ccc;
}
.light .menu-bar i:hover,
.light .nav-chapters:hover,
.light .mobile-nav-chapters i:hover {
color: #333;
}
.light .mobile-nav-chapters i:hover {
color: #364149;
}
.light .mobile-nav-chapters {
background-color: #fafafa;
}
.light .content a {
color: #4183c4;
}
.light .theme-popup {
background: #fafafa;
border: 1px solid #ccc;
}
.light .theme-popup .theme:hover {
background-color: #e6e6e6;
}
.coal {
color: #98a3ad;
background-color: #141617;
}
.coal .sidebar {
background-color: #292c2f;
color: #a1adb8;
}
.coal .chapter li {
color: #505254;
}
.coal .chapter li a {
color: #a1adb8;
}
.coal .chapter li .active,
.coal .chapter li a:hover {
/* Animate color change */
color: #3473ad;
}
.coal .chapter .spacer {
background-color: #393939;
}
.coal .menu-bar,
.coal .nav-chapters,
.coal .mobile-nav-chapters {
color: #43484d;
}
.coal .menu-bar i:hover,
.coal .nav-chapters:hover,
.coal .mobile-nav-chapters i:hover {
color: #b3c0cc;
}
.coal .mobile-nav-chapters i:hover {
color: #a1adb8;
}
.coal .mobile-nav-chapters {
background-color: #292c2f;
}
.coal .content a {
color: #2b79a2;
}
.coal .theme-popup {
background: #141617;
border: 1px solid #43484d;
}
.coal .theme-popup .theme:hover {
background-color: #1f2124;
}
.navy {
color: #bcbdd0;
background-color: #161923;
}
.navy .sidebar {
background-color: #282d3f;
color: #c8c9db;
}
.navy .chapter li {
color: #505274;
}
.navy .chapter li a {
color: #c8c9db;
}
.navy .chapter li .active,
.navy .chapter li a:hover {
/* Animate color change */
color: #2b79a2;
}
.navy .chapter .spacer {
background-color: #2d334f;
}
.navy .menu-bar,
.navy .nav-chapters,
.navy .mobile-nav-chapters {
color: #737480;
}
.navy .menu-bar i:hover,
.navy .nav-chapters:hover,
.navy .mobile-nav-chapters i:hover {
color: #b7b9cc;
}
.navy .mobile-nav-chapters i:hover {
color: #c8c9db;
}
.navy .mobile-nav-chapters {
background-color: #282d3f;
}
.navy .content a {
color: #2b79a2;
}
.navy .theme-popup {
background: #161923;
border: 1px solid #737480;
}
.navy .theme-popup .theme:hover {
background-color: #282e40;
}
.rust {
color: #262625;
background-color: #e1e1db;
}
.rust .sidebar {
background-color: #3b2e2a;
color: #c8c9db;
}
.rust .chapter li {
color: #505254;
}
.rust .chapter li a {
color: #c8c9db;
}
.rust .chapter li .active,
.rust .chapter li a:hover {
/* Animate color change */
color: #e69f67;
}
.rust .chapter .spacer {
background-color: #45373a;
}
.rust .menu-bar,
.rust .nav-chapters,
.rust .mobile-nav-chapters {
color: #737480;
}
.rust .menu-bar i:hover,
.rust .nav-chapters:hover,
.rust .mobile-nav-chapters i:hover {
color: #262625;
}
.rust .mobile-nav-chapters i:hover {
color: #c8c9db;
}
.rust .mobile-nav-chapters {
background-color: #3b2e2a;
}
.rust .content a {
color: #2b79a2;
}
.rust .theme-popup {
background: #e1e1db;
border: 1px solid #b38f6b;
}
.rust .theme-popup .theme:hover {
background-color: #99908a;
}