Skip to content

Commit ffe1974

Browse files
committed
CSS: Collapse sidebar when window is narrow
1 parent 314ed19 commit ffe1974

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

ui/resources/static/assets/Global.css

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,13 @@ body > nav {
104104
background-color: var(--color-sidebar-background);
105105
padding: 0;
106106
border-right: 1px solid var(--color-light-grey);
107+
white-space: nowrap;
107108
}
108109

109110
/* brand link */
110111
body > nav > header a {
111112
background-color: #011f85;
112-
width: 179px;
113+
width: calc(var(--sidebar-width) - 1px);
113114
border-right: 1px solid darkblue;
114115
height: 40px;
115116
display: block;
@@ -163,6 +164,36 @@ body > nav ul > li > a > .icon {
163164
margin-right: 8px;
164165
}
165166

167+
/*
168+
* Collapse sidebar and only show icons when window is narrow
169+
*/
170+
@media (max-width: 700px) {
171+
body > nav {
172+
width: 32px !important;
173+
transition: width 0.3s;
174+
}
175+
body > nav .icon {
176+
flex-shrink: 0;
177+
}
178+
179+
body > nav ul > li > a {
180+
padding-left: 4px !important;
181+
}
182+
183+
body > nav .hide-when-sidebar-collapsed {
184+
display: none;
185+
}
186+
187+
body > nav ul > li > a {
188+
overflow: clip;
189+
}
190+
191+
body > main {
192+
padding-left: calc(32px + var(--margin-width)) !important;
193+
transition: padding-left 0.3s;
194+
}
195+
}
196+
166197
/*
167198
* Main
168199
*/
@@ -198,7 +229,7 @@ body > main > header, main > form > header {
198229

199230
height: var(--header-height);
200231
padding: 0 15px;
201-
margin-left: 180px;
232+
margin-left: var(--sidebar-width);
202233
box-sizing: border-box;
203234
}
204235

ui/resources/templates/_layout.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@
7373
<i class="icon forum"></i> Social</a></li>
7474
</ul>
7575

76-
<ul>
76+
<ul class="hide-when-sidebar-collapsed">
7777
<li sec:authorize="hasAuthority('PRIV_VIEW_GATHER_QUEUE')"><a th:href="@{/queue}" th:classappend="${activeItem == 'Gather Queue'}? 'active'">Gather Queue</a>
7878
<li><a th:href="@{/statistics}">Statistics</a>
7979
<li sec:authorize="hasRole('stduser')"><a th:href="@{/agencies}">Agencies</a>
8080
<li sec:authorize="hasRole('stduser')"><a href="https://webrecorder.archive.org.au/">Webrecorder</a>
8181
</ul>
8282

8383
<!-- Gather option administration -->
84-
<ul sec:authorize="hasRole('stduser')">
84+
<ul sec:authorize="hasRole('stduser')" class="hide-when-sidebar-collapsed">
8585
<li><a th:href="@{/settings}">System Settings</a>
8686
</ul>
87-
<ul>
87+
<ul class="hide-when-sidebar-collapsed">
8888
<li><a class="disabled">User: <th:block sec:authentication="name">jsmith</th:block></a></li>
8989
<li sec:authorize="hasAuthority('IS_MASQUERADING')" style="padding-left: 1rem; color: #999">
9090
Acting as: <span th:text="${@userService.effectiveRole}"></span>

0 commit comments

Comments
 (0)