Skip to content

Commit e7bad07

Browse files
hhandokofelixmulder
authored andcommitted
Make dottydoc main page responsive (#2052)
* Add CSS media queries to support off-canvas sidebar * Add sidebar toggle interactivity for small viewports * Re-add sidebar toggle support for desktop viewport widths * Widen sidebar in mobile viewport and removed extra padding in content body * Reduce sidebar width back to 250px on Desktop and Tablet viewports Tablet (576px <= x < 768px) viewport sidebar is now limited to 250px to follow Desktop viewports whilst still retaining its off-canvas behaviour like Mobile. Mobile viewport (x < 576px) still implements 60% sidebar width. * Refactor media queries to follow mobile-first strategy Instead of specifying specific styles at a viewport width range, e.g. Tablet (576px <= x < 768px), the CSS properties are arranged as such that default CSS properties applies to Mobile, with Tablet and Desktop styles defined within media queries. Mobile-first strategy will ensure more consistency as style resolution will go in one direction, e.g. from Mobile -> Tablet -> Desktop. * Move `div#entity-container` and `div#doc-page-container` further down The change above, in addition to qualifying `button#menu-toggle` with `div#content-wrapper` parent selector will make the existing CSS easier to refactor removing duplicates, and to swap it into CSS pre-processor languages such as SASS or Less. * Merge redundant `div#content-body` styles Two different `div#content-body` styles was defined, one with only `position: relative` and another with the complete styles. In addition, a `div#content-body` Tablet and Desktop padding style was moved into the relevant media query to make future changes more transparent. * Change `rgba(...)` properties to insert space and prefix decimals with `0` Within the CSS file, RGBA property declaration is inconsistent: some with space after comma and some without, some has leading `0` for decimals and some dont'. This change make sure that one style is followed (space after comma and always use the leading `0` in decimals). * Move hamburger menu to original location and restore hover styling Hamburger menu now stays in the content body as per original design. However to prevent overlap with body text, a permanent 30px left padding on the body container has been added. * Remove hamburger menu transformation into arrow on expansion As per PR review comments (#2052) the old hamburger menu style is restored by removing CSS transforms. * Change hamburger menu positioning to `absolute` As per PR review comments (#2052) the hamburger menu positioning is changed back to absolute, which also means the left padding on content body is no longer needed and can be removed.
1 parent 4f4e373 commit e7bad07

File tree

3 files changed

+95
-33
lines changed

3 files changed

+95
-33
lines changed

doc-tool/resources/_layouts/main.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi"
1414
crossorigin="anonymous"
1515
>
16+
1617
<link
1718
rel="stylesheet"
1819
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"

doc-tool/resources/_layouts/sidebar.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@
3333
</ul>
3434
</div>
3535
<div id="content-body">
36-
<div id="menu-toggle" onclick="toggleMenu()">
37-
<i class="fa fa-bars" aria-hidden="true"></i>
38-
</div>
36+
<button type="button" id="menu-toggle" onclick="toggleMenu()" aria-expanded="false">
37+
<span class="sr-only" aria-hidden="true">Toggle navigation</span>
38+
<span class="icon-bar"></span>
39+
<span class="icon-bar"></span>
40+
<span class="icon-bar"></span>
41+
</button>
3942
{{ content }}
4043
</div>
4144
</div>

doc-tool/resources/css/dottydoc.css

Lines changed: 88 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1+
html, body {
2+
overflow-x: hidden;
3+
}
4+
15
html {
26
height: 100%;
37
}
8+
49
body {
510
min-height: 100%;
611
}
712

813
div#content-wrapper {
914
min-height: 100vh;
10-
padding-left: 250px;
11-
transition: all 0.5s ease;
15+
padding-left: 0;
1216
}
1317

14-
div#content-wrapper.toggled {
15-
padding-left: 0;
18+
div#content-wrapper div#content-body {
19+
background-color: #f4f3f4;
20+
border-left: 1px solid #e0e0e0;
21+
box-shadow: -3px 0 5px -2px rgba(0, 0, 0, 0.14);
22+
padding: 40px 1px 1px 1px;
23+
position: relative;
24+
min-height: 100vh;
1625
}
1726

18-
div.index-wrapper {
27+
div#content-wrapper div.index-wrapper {
1928
background-color: #fafafa;
20-
width: 250px;
2129
position: fixed;
2230
top: 0;
2331
left: 0;
@@ -26,6 +34,77 @@ div.index-wrapper {
2634
overflow-x: hidden;
2735
}
2836

37+
/** Animations: Easing for content body slide on toggle */
38+
div#content-wrapper,
39+
div#content-wrapper div#content-body {
40+
-webkit-transition: all .25s ease-out;
41+
-o-transition: all .25s ease-out;
42+
transition: all .25s ease-out;
43+
}
44+
45+
/** Mobile (x < 576px) sidebar: Defaults closed with 60% wide sidebar */
46+
div#content-wrapper {}
47+
div#content-wrapper div#content-body { left: 0; }
48+
div#content-wrapper div.index-wrapper { width: 60%; }
49+
50+
div#content-wrapper.toggled {}
51+
div#content-wrapper.toggled div#content-body { left: 60%; }
52+
div#content-wrapper.toggled div.index-wrapper {}
53+
54+
/** Tablet (576px <= x < 768px) sidebar: Defaults closed with 250px wide sidebar */
55+
@media screen and (min-width: 576px) {
56+
57+
div#content-wrapper {}
58+
div#content-wrapper div#content-body {}
59+
div#content-wrapper div.index-wrapper { width: 250px; }
60+
61+
div#content-wrapper.toggled {}
62+
div#content-wrapper.toggled div#content-body { left: 250px; }
63+
div#content-wrapper.toggled div.index-wrapper {}
64+
65+
}
66+
67+
/** Desktop (x >= 768px) sidebar: Defaults open with 250px wide sidebar */
68+
@media screen and (min-width: 768px) {
69+
70+
div#content-wrapper { padding-left: 250px; }
71+
div#content-wrapper div#content-body {}
72+
div#content-wrapper div.index-wrapper { width: 250px; }
73+
74+
div#content-wrapper.toggled { padding-left: 0; }
75+
div#content-wrapper.toggled div#content-body { left: 0; }
76+
div#content-wrapper.toggled div.index-wrapper {}
77+
78+
}
79+
80+
div#content-wrapper button#menu-toggle {
81+
background: rgba(244, 243, 244, 0.4) none;
82+
border: 1px solid transparent;
83+
color: #837f84;
84+
margin: -30px 0 0 10px;
85+
padding: 9px 10px;
86+
position: absolute;
87+
}
88+
89+
div#content-wrapper button#menu-toggle:hover {
90+
cursor: pointer;
91+
}
92+
93+
div#content-wrapper button#menu-toggle:focus {
94+
outline: none;
95+
}
96+
97+
div#content-wrapper button#menu-toggle span.icon-bar {
98+
background-color: #837f84;
99+
border-radius: 2px;
100+
border-color: #837f84;
101+
color: #837f84;
102+
display: block;
103+
margin: 3px 0;
104+
width: 22px;
105+
height: 2px;
106+
}
107+
29108
div#doc-page-container > h1 {
30109
border-bottom: 1px solid #eee;
31110
padding-bottom: 0.3em;
@@ -93,27 +172,6 @@ div#doc-page-container > h6 > a:focus {
93172
outline: none;
94173
}
95174

96-
div#content-body {
97-
border-left: 1px solid #e0e0e0;
98-
box-shadow: -3px 0px 5px -2px rgba(0,0,0,0.14);
99-
position: relative;
100-
padding: 10px;
101-
background-color: #f4f3f4;
102-
min-height: 100vh;
103-
}
104-
105-
div#menu-toggle {
106-
color: #837F84;
107-
outline: none;
108-
padding-left: 20px;
109-
padding-top: 10px;
110-
}
111-
112-
div#menu-toggle:hover {
113-
color: rgba(0, 0, 0, 0.4);
114-
cursor: pointer;
115-
}
116-
117175
ul.index-entities {
118176
list-style-type: none;
119177
padding-left: 0;
@@ -195,7 +253,7 @@ ul.index-entities > li > a.entity-name {
195253
font-size: 13px;
196254
display: block;
197255
padding: 0 0 0 24px;
198-
color: rgba(0,0,0,.87);
256+
color: rgba(0, 0, 0, 0.87);
199257
background: transparent;
200258
cursor: pointer;
201259
float: left;
@@ -245,7 +303,7 @@ ul.toc > li > ul.hide {
245303
ul.index-entities > li.index-title > span {
246304
font-size: 16px;
247305
font-weight: bold;
248-
color: rgba(0,0,0,.87);
306+
color: rgba(0, 0, 0, 0.87);
249307
padding: 0 24px;
250308
}
251309

@@ -319,7 +377,7 @@ pre {
319377
background: rgba(244, 243, 244, 0.6);
320378
border-radius: 2px;
321379
margin-top: 20px;
322-
border: 1px solid rgba(0,0,0,0.1);
380+
border: 1px solid rgba(0, 0, 0, 0.1);
323381
}
324382

325383
pre > code.language-none,

0 commit comments

Comments
 (0)