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
deno.lock
fly.toml
env.sh
env.sh
test_space

View File

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

View File

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