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
7 changes: 7 additions & 0 deletions src/components/nav/NavActions.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
"use client";

import { EditorAboutDropdown } from "@/components/nav/EditorAboutDropdown";
import { IconButton } from "@/components/ui/IconButton";
import { ThemeToggle } from "@/components/ui/ThemeToggle";
import { GitHubIcon } from "@/icons/GitHubIcon";

const REPO_URL = "https://github.com/EarthyScience/EarthPrints";

export function NavActions() {
return (
<div className="ml-auto flex items-center gap-2 overflow-visible">
<IconButton href={REPO_URL} aria-label="View source on GitHub">
<GitHubIcon />
</IconButton>
<EditorAboutDropdown />
<ThemeToggle />
</div>
Expand Down
22 changes: 21 additions & 1 deletion src/components/ui/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ type IconButtonProps = {
"aria-label": string;
"aria-expanded"?: boolean;
"aria-controls"?: string;
/** When set, renders an anchor to this URL instead of a button. */
href?: string;
};

// Every IconButton renders inside the editor nav, so the editor sizing/colour
Expand All @@ -21,11 +23,29 @@ export function IconButton({
"aria-label": ariaLabel,
"aria-expanded": ariaExpanded,
"aria-controls": ariaControls,
href,
}: IconButtonProps) {
const classes = [ICON_BUTTON_CLASS, className].filter(Boolean).join(" ");

if (href) {
return (
<a
href={href}
target="_blank"
rel="noreferrer noopener"
className={classes}
aria-label={ariaLabel}
onClick={onClick}
>
{children}
</a>
);
}
Comment thread
aivanchenk marked this conversation as resolved.

return (
<button
type="button"
className={[ICON_BUTTON_CLASS, className].filter(Boolean).join(" ")}
className={classes}
onClick={onClick}
aria-label={ariaLabel}
aria-expanded={ariaExpanded}
Expand Down
13 changes: 13 additions & 0 deletions src/icons/GitHubIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function GitHubIcon() {
return (
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
>
<path d="M12 2C6.48 2 2 6.58 2 12.25c0 4.53 2.87 8.37 6.84 9.73.5.1.68-.22.68-.49 0-.24-.01-.87-.01-1.71-2.78.62-3.37-1.37-3.37-1.37-.46-1.18-1.11-1.5-1.11-1.5-.9-.63.07-.62.07-.62 1 .07 1.53 1.05 1.53 1.05.89 1.56 2.34 1.11 2.91.85.09-.66.35-1.11.63-1.36-2.22-.26-4.55-1.14-4.55-5.06 0-1.12.39-2.03 1.03-2.75-.1-.26-.45-1.3.1-2.71 0 0 .84-.28 2.75 1.05a9.34 9.34 0 0 1 2.5-.34c.85 0 1.71.12 2.5.34 1.91-1.33 2.75-1.05 2.75-1.05.55 1.41.2 2.45.1 2.71.64.72 1.03 1.63 1.03 2.75 0 3.93-2.34 4.8-4.57 5.05.36.32.68.94.68 1.9 0 1.37-.01 2.48-.01 2.82 0 .27.18.6.69.49A10.02 10.02 0 0 0 22 12.25C22 6.58 17.52 2 12 2Z" />
</svg>
);
}
Loading