allow top bar action buttons to be links and make home one (#417)

pull/418/head
JordanPaoletti 2023-06-10 08:15:16 -06:00 committed by GitHub
parent b035969402
commit 063a8e4767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 12 deletions

3
.gitignore vendored
View File

@ -8,4 +8,5 @@ website_build
.idea .idea
deno.lock deno.lock
fly.toml fly.toml
env.sh env.sh
test_space

View File

@ -13,6 +13,7 @@ export type ActionButton = {
icon: FunctionalComponent<FeatherProps>; icon: FunctionalComponent<FeatherProps>;
description: string; description: string;
callback: () => void; callback: () => void;
href?: string;
}; };
export function TopBar({ export function TopBar({
@ -118,17 +119,21 @@ export function TopBar({
</div> </div>
)} )}
<div className="sb-actions"> <div className="sb-actions">
{actionButtons.map((actionButton) => ( {actionButtons.map((actionButton) => {
<button const button =
onClick={(e) => { <button
actionButton.callback(); onClick={(e) => {
e.stopPropagation(); e.preventDefault();
}} actionButton.callback();
title={actionButton.description} e.stopPropagation();
> }}
<actionButton.icon size={18} /> title={actionButton.description}
</button> >
))} <actionButton.icon size={18} />
</button>
return actionButton.href !== undefined ? (<a href={actionButton.href}>{button}</a>) : button;
})}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1405,6 +1405,7 @@ export class Editor {
callback: () => { callback: () => {
editor.navigate(""); editor.navigate("");
}, },
href: "",
}, },
{ {
icon: BookIcon, icon: BookIcon,