Skip to content

Commit f8406d7

Browse files
committed
Use flexbox for styling
1 parent ceecae6 commit f8406d7

File tree

4 files changed

+76
-44
lines changed

4 files changed

+76
-44
lines changed

site/default/static/static.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
11
var packages = require("./packages");
22
require("./styles/styles.less!");
3-
window.PACKAGES = packages;
4-
5-
// sets sidebar height to window height
6-
function setSidebarHeightOnResize() {
7-
var windowHeight = window.innerHeight;
8-
document.getElementsByClassName("sidebar")[0].style.height = windowHeight + "px";
9-
}
10-
setSidebarHeightOnResize();
11-
window.onresize = function() {
12-
setSidebarHeightOnResize();
13-
};
3+
window.PACKAGES = packages;
+51-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,60 @@
11
@import "locate://bit-docs-site/styles/variables.less";
22

3-
@sidebar-width: 250px;
3+
.flex-mixin {
4+
display: -webkit-box;
5+
display: -moz-box;
6+
display: -ms-flexbox;
7+
display: -webkit-flex;
8+
display: flex;
9+
}
10+
11+
html {
12+
height: 100%;
13+
box-sizing: border-box;
14+
}
15+
16+
*, *:before, *:after {
17+
box-sizing: inherit; // https://css-tricks.com/box-sizing/
18+
}
419

520
body {
21+
.flex-mixin;
22+
width: 100%;
23+
height: 100vh;
24+
margin: auto;
25+
flex-direction: column;
26+
justify-content: space-between;
627
font-family: @defaultFontFamily;
7-
margin-left: (@sidebar-width + 25);
828
}
9-
.sidebar {
10-
float: left;
11-
margin: 0;
12-
margin-top: -19px;
13-
max-width: @sidebar-width;
14-
overflow: auto;
15-
position: fixed;
16-
left: 0;
17-
18-
ul {
19-
white-space: nowrap;
29+
30+
header, footer {
31+
width: 100%;
32+
flex-shrink: 0; // retain height
33+
}
34+
35+
.content {
36+
flex-grow: 1; // fill space vertical
37+
flex-shrink: 1; // IE10 sets flex-shrink to 0
38+
39+
@media @desktops {
40+
.flex-mixin;
41+
overflow: auto; // scroll .content when .main overflows
42+
}
43+
44+
.sidebar {
45+
overflow: auto; // scroll .sidebar when <ul> overflows
46+
flex-shrink: 0; // retain width
47+
48+
.current>a {
49+
font-weight: bold;
50+
}
2051
}
2152

22-
.current>a {
23-
font-weight: bold;
53+
.main {
54+
flex-grow: 1; // fill space horizontal
55+
flex-shrink: 1;
56+
padding-left: 25px;
57+
padding-right: 25px;
58+
overflow-x: hidden; // hide <pre> code overflow
2459
}
25-
}
60+
}

site/default/static/styles/variables.less

+5
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,8 @@
9292
@logo: "../img/logo.svg";
9393
@logoFooter: "../img/logo-grey.svg";
9494
@logoWidth: 170px;
95+
96+
// Breakpoints for use with @media
97+
98+
@smartphones: ~"only screen and (max-width: 767px)";
99+
@desktops: ~"only screen and (min-width: 767px)";
+19-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
{{#unless hideSidebar}}
2-
{{> sidebar.mustache}}
3-
{{/unless}}
4-
<article>
5-
{{#unless hideTitle}}
6-
{{> title.mustache}}
1+
<div class="content">
2+
{{#unless hideSidebar}}
3+
{{> sidebar.mustache}}
74
{{/unless}}
5+
<article class="main">
6+
{{#unless hideTitle}}
7+
{{> title.mustache}}
8+
{{/unless}}
89

9-
{{#unless hideDescription}}
10-
{{#if description}}
11-
{{> description.mustache}}
12-
{{/if}}
13-
{{/unless}}
10+
{{#unless hideDescription}}
11+
{{#if description}}
12+
{{> description.mustache}}
13+
{{/if}}
14+
{{/unless}}
1415

15-
{{#unless hideBody}}
16-
{{#if body}}
17-
{{> body.mustache}}
18-
{{/if}}
19-
{{/unless}}
20-
</article>
16+
{{#unless hideBody}}
17+
{{#if body}}
18+
{{> body.mustache}}
19+
{{/if}}
20+
{{/unless}}
21+
</article>
22+
</div>

0 commit comments

Comments
 (0)