Skip to content

Commit fea2c17

Browse files
authored
Merge pull request beakerbrowser#446 from beakerbrowser/responsive-library
Make the library responsive
2 parents a92ec83 + 4897fc5 commit fea2c17

2 files changed

Lines changed: 100 additions & 5 deletions

File tree

‎app/builtin-pages/views/library.js‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var userProfileUrl
3434
var archivesList
3535
var trashList = []
3636
var isTrashOpen = false
37+
var isSidebarOpen = false
3738
var currentFilter = ''
3839
var currentSort = 'mtime'
3940
var currentSection = 'files'
@@ -54,6 +55,10 @@ async function setup () {
5455

5556
// load deleted archives
5657
trashList = await beaker.archives.list({isSaved: false})
58+
59+
// check if sidebar should be open
60+
isSidebarOpen = !selectedArchive
61+
5762
update()
5863

5964
// render graph regularly
@@ -156,7 +161,12 @@ async function reloadDiff () {
156161
function update () {
157162
yo.update(document.querySelector('main'), yo`
158163
<main>
159-
<div class="sidebar">
164+
<div class="sidebar ${isSidebarOpen ? 'open' : ''}">
165+
<div class="menu">
166+
<button onclick=${onToggleSidebar}>
167+
<i class="fa fa-bars"></i>
168+
</button>
169+
</div>
160170
<div class="sidebar-actions">
161171
<label for="filter">
162172
<input
@@ -197,6 +207,11 @@ function update () {
197207
</div>
198208
199209
<div class="view">
210+
<div onclick=${onToggleSidebar} class="menu">
211+
<button>
212+
<i class="fa fa-bars"></i>
213+
</button>
214+
</div>
200215
${rView()}
201216
</div>
202217
</main>
@@ -475,7 +490,7 @@ function rMetadata (archiveInfo) {
475490
<tr><td class="label">Files</td><td>${prettyBytes(archiveInfo.stagingSize)}</td></tr>
476491
<tr><td class="label">History</td><td>${prettyBytes(archiveInfo.metaSize)}</td></tr>
477492
<tr><td class="label">Updated</td><td>${niceDate(archiveInfo.mtime)}</td></tr>
478-
<tr><td class="label">URL</td><td>dat://${archiveInfo.key}</td></tr>
493+
<tr><td class="label">URL</td><td title="dat://${archiveInfo.key}">dat://${archiveInfo.key}</td></tr>
479494
<tr><td class="label">Path</td><td>${archiveInfo.userSettings.localPath || ''}</td></tr>
480495
<tr><td class="label">Editable</td><td>${archiveInfo.isOwner}</td></tr>
481496
</table>
@@ -575,6 +590,11 @@ function onToggleTrash () {
575590
update()
576591
}
577592

593+
function onToggleSidebar () {
594+
isSidebarOpen = !isSidebarOpen
595+
update()
596+
}
597+
578598
function onSelectArchive (archiveInfo) {
579599
return e => {
580600
history.pushState({}, null, 'beaker://library/' + archiveInfo.key)

‎app/stylesheets/builtin-pages/library.less‎

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,44 @@ body {
2727
&:extend(.vertical-scroll);
2828
&:extend(.hide-scrollbar all);
2929
position: fixed;
30-
left: 0;
30+
left: -250px;
3131
width: 250px;
3232
height: 100%;
3333
border-right: 1px solid @border-menu;
3434
background: #fff;
35+
z-index: 1;
36+
transition: left .2s ease;
37+
38+
.menu {
39+
position: absolute;
40+
right: 2px;
41+
top: 4px;
42+
z-index: 3;
43+
44+
i {
45+
font-size: 20px;
46+
}
47+
}
48+
49+
&.open {
50+
left: 0;
51+
52+
+ .view .trash {
53+
margin-left: 250px;
54+
55+
.menu {
56+
display: none;
57+
}
58+
}
59+
}
60+
61+
@media (min-width: 925px) {
62+
left: 0;
63+
64+
.menu {
65+
display: none;
66+
}
67+
}
3568
}
3669

3770
.message {
@@ -204,9 +237,28 @@ body {
204237
}
205238

206239
.view {
207-
margin-left: 250px;
208240
padding: 2rem;
209241
max-width: 675px;
242+
margin: auto;
243+
position: relative;
244+
245+
@media (min-width: 925px) {
246+
margin-left: 250px;
247+
}
248+
249+
.menu {
250+
position: absolute;
251+
top: 10px;
252+
left: 2em;
253+
254+
i {
255+
font-size: 20px;
256+
}
257+
258+
@media (min-width: 925px) {
259+
display: none;
260+
}
261+
}
210262

211263
h1 {
212264
font-size: 1.5rem;
@@ -231,6 +283,12 @@ body {
231283
.title {
232284
&:extend(.overflow-ellipsis);
233285
max-width: 450px;
286+
margin-top: 25px;
287+
288+
// max-width of .title + width of .actions
289+
@media (min-width: 665px) {
290+
margin-top: 0;
291+
}
234292

235293
&:hover {
236294
text-decoration: underline;
@@ -246,10 +304,24 @@ body {
246304
font-style: italic;
247305
}
248306

307+
.dat-url {
308+
&:extend(.overflow-ellipsis);
309+
max-width: 100%;
310+
311+
@media (min-width: 925px) {
312+
max-width: 450px;
313+
}
314+
}
315+
249316
.info .actions {
250317
position: absolute;
251318
right: 0;
252-
top: 1px;
319+
top: -45px;
320+
321+
// max-width of .title + width of .actions
322+
@media (min-width: 665px) {
323+
top: 1px;
324+
}
253325

254326
.btn {
255327
display: inline-block;
@@ -271,6 +343,9 @@ body {
271343
.metadata {
272344

273345
table {
346+
display: block;
347+
max-width: 100%;
348+
overflow: hidden;
274349
border: 1px solid @border-menu;
275350
border-collapse: collapse;
276351
font-size: 13px;

0 commit comments

Comments
 (0)