Skip to content

Commit

Permalink
Added parent button to explorer
Browse files Browse the repository at this point in the history
Added explorer context menu
  • Loading branch information
james-pre committed Oct 14, 2024
1 parent fa6f643 commit 395773e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
20 changes: 19 additions & 1 deletion src/explorer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fs } from '@zenfs/core';
import { cwd, join } from '@zenfs/core/emulation/path.js';
import { cwd, dirname, join } from '@zenfs/core/emulation/path.js';
import $ from 'jquery';
import { formatCompact } from 'utilium';
import { cloneTemplate } from 'utilium/dom.js';
Expand Down Expand Up @@ -31,6 +31,19 @@ function createEntry(name: string) {
}

li.toggleClass('selected');
$('#explorer .menu').hide();
});

li.on('contextmenu', e => {
e.preventDefault();

$('#explorer .menu')
.toggle()
.css({
left: e.clientX + 'px',
top: e.clientY + 'px',
});
return false;
});

li.appendTo('#explorer');
Expand All @@ -43,3 +56,8 @@ export function update() {
createEntry(file);
}
}

$('#explorer .parent').on('click', () => {
openPath(dirname(cwd));
update();
});
15 changes: 14 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,20 @@
</ul>

<ul id="explorer" class="tab" style="display: none">
<strong class="top">Explorer</strong>
<div class="top">
<p><strong>Explorer</strong></p>
<div>
<button class="parent"><strong></strong> Parent</button>
</div>
</div>

<div class="menu" style="display: none">
<div class="contents">
<div>Open</div>
<div>Rename</div>
<div>Delete</div>
</div>
</div>

<li class="header">
<p class="name">Name</p>
Expand Down
32 changes: 26 additions & 6 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ input:focus {

li {
position: relative;
top: 2em;
top: 6em;
border-radius: 0.25em;
padding: 0.25em;
}
Expand All @@ -105,11 +105,6 @@ input:focus {
right: 1em;
bottom: 1em;
}

li {
position: relative;
top: 6em;
}
}

#explorer {
Expand Down Expand Up @@ -155,6 +150,31 @@ input:focus {
border: 1px solid #777;
border-radius: 0.5em;
}

.menu {
position: fixed;
left: 0;
top: 0;
}

.menu .contents {
padding: 1em;
display: flex;
flex-direction: column;
border: 1px solid #888;
background-color: #555;
border-radius: 0.5em;
z-index: 10;

div {
padding: 0.5em;
}

div:hover {
background-color: #666;
border-radius: 0.5em;
}
}
}

#editor textarea.content {
Expand Down

0 comments on commit 395773e

Please sign in to comment.