Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ build:
cargo lbuild

serve: build
./target/debug/filepack serve --address localhost --http-port 8000
./target/debug/filepack --unstable serve --address localhost --http-port 8000

open:
open http://localhost:8000
Expand Down
6 changes: 0 additions & 6 deletions src/templates/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ mod tests {
</a>
</p>
</hgroup>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</footer>
"
),
Expand Down Expand Up @@ -402,7 +401,6 @@ mod tests {
</a>
</p>
</hgroup>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</footer>
"
),
Expand Down Expand Up @@ -430,7 +428,6 @@ mod tests {
</a>
</p>
</hgroup>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</footer>
"
),
Expand Down Expand Up @@ -465,7 +462,6 @@ mod tests {
</a>
</p>
</hgroup>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</footer>
"
),
Expand Down Expand Up @@ -493,7 +489,6 @@ mod tests {
</a>
</p>
</hgroup>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</footer>
"
),
Expand Down Expand Up @@ -524,7 +519,6 @@ mod tests {
</a>
</p>
</hgroup>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</footer>
"
)),
Expand Down
29 changes: 23 additions & 6 deletions src/templates/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ impl<T: Page> PageHtml<T> {

shortcuts.extend(self.content.shortcuts());

if !shortcuts.is_empty() {
shortcuts.push(Shortcut {
description: "toggle shortcuts",
key: '?',
});
}
shortcuts.push(Shortcut {
description: "toggle shortcuts",
key: '?',
});

shortcuts
}
Expand Down Expand Up @@ -161,6 +159,7 @@ mod tests {
<a href=/packages>Packages</a>
<a href=https://filepack.com/book>Book</a>
<a href=https://github.com/casey/filepack>GitHub</a>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</nav>
</header>
<main>
Expand Down Expand Up @@ -213,11 +212,17 @@ mod tests {
<a href=/packages>Packages</a>
<a href=https://filepack.com/book>Book</a>
<a href=https://github.com/casey/filepack>GitHub</a>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</nav>
</header>
<main>
foo
</main>
<div id=shortcuts popover>
<dl>
<div><dt><kbd>?</kbd></dt><dd>toggle shortcuts</dd></div>
</dl>
</div>
</body>
</html>
"
Expand Down Expand Up @@ -248,11 +253,17 @@ mod tests {
<a href=/packages>Packages</a>
<a href=https://filepack.com/book>Book</a>
<a href=https://github.com/casey/filepack>GitHub</a>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</nav>
</header>
<main>
foo
</main>
<div id=shortcuts popover>
<dl>
<div><dt><kbd>?</kbd></dt><dd>toggle shortcuts</dd></div>
</dl>
</div>
</body>
</html>
"
Expand Down Expand Up @@ -286,11 +297,17 @@ mod tests {
<a href=/packages>Packages</a>
<a href=https://filepack.com/book>Book</a>
<a href=https://github.com/casey/filepack>GitHub</a>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</nav>
</header>
<main>
bar
</main>
<div id=shortcuts popover>
<dl>
<div><dt><kbd>?</kbd></dt><dd>toggle shortcuts</dd></div>
</dl>
</div>
</body>
</html>
"
Expand Down
16 changes: 0 additions & 16 deletions static/item.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,6 @@ footer {
}
}
}

button {
background-color: transparent;
border: 1px solid var(--border);
border-radius: 50%;
color: var(--muted);
cursor: pointer;
font: inherit;
height: 1.75em;
padding: 0;
width: 1.75em;

&:hover {
color: var(--text);
}
}
}

audio {
Expand Down
21 changes: 20 additions & 1 deletion static/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,28 @@ body > header > nav {
color: var(--text);
}

a:last-child {
a:last-of-type {
margin-inline-start: auto;
}

button {
align-self: center;
background-color: transparent;
border: 1px solid var(--border);
border-radius: 50%;
color: var(--muted);
cursor: pointer;
font: inherit;
font-size: 0.7em;
height: 1.5em;
padding: 0;
transition: color var(--duration);
width: 1.5em;

&:hover {
color: var(--text);
}
}
}

[popover] {
Expand Down
2 changes: 1 addition & 1 deletion static/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ document.addEventListener('keydown', (event) => {
return;
}

if (event.key === '?' && shortcuts !== null) {
if (event.key === '?') {
shortcuts.togglePopover();
return;
}
Expand Down
1 change: 0 additions & 1 deletion templates/item.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ <h1>{{ self.item().display_title(self.index) }}</h1>
</a>
</p>
</hgroup>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</footer>
8 changes: 3 additions & 5 deletions templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,18 @@
<a href=/packages>Packages</a>
<a href=https://filepack.com/book>Book</a>
<a href=https://github.com/casey/filepack>GitHub</a>
<button aria-label='Keyboard shortcuts' popovertarget=shortcuts title='Keyboard shortcuts'>?</button>
</nav>
</header>
<main>
{{ Trusted(&self.content) }}
</main>
%% let shortcuts = self.shortcuts();
%% if !shortcuts.is_empty() {
<div id=shortcuts popover>
<dl>
%% for shortcut in shortcuts {
%% for shortcut in self.shortcuts() {
<div><dt><kbd>{{ shortcut.key }}</kbd></dt><dd>{{ shortcut.description }}</dd></div>
%% }
%% }
</dl>
</div>
%% }
</body>
</html>
Loading