Skip to content

Commit

Permalink
upgrades to next.js 13
Browse files Browse the repository at this point in the history
  • Loading branch information
soupaJ committed Sep 4, 2023
1 parent 3b8463d commit 33b1917
Show file tree
Hide file tree
Showing 11 changed files with 293 additions and 253 deletions.
6 changes: 2 additions & 4 deletions components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import Logo from "./logo";
export default function Footer() {
return (
<div className="mx-4 my-10 flex items-center justify-center">
<Link href="/">
<a aria-label="Gistdoc" className="h-8 w-8">
<Logo />
</a>
<Link href="/" aria-label="Gistdoc" className="h-8 w-8">
<Logo />
</Link>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion components/link/link-with-avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ export default function LinkWithAvatar({
alt,
href,
children,
variant = "subtle",
...rest
}: LinkWithAvatarProps) {
return (
<Link
href={href}
variant="subtle"
variant={variant}
className="flex items-center text-gray-500"
{...rest}
>
Expand Down
18 changes: 9 additions & 9 deletions components/link/link.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import NextLink, { LinkProps as NextLinkProps } from "next/link";
import { AnchorHTMLAttributes } from "react";

export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
export type LinkProps = {
variant?: "subtle" | "button" | "unstyled";
}
} & NextLinkProps &
AnchorHTMLAttributes<HTMLAnchorElement>;

const variantClasses = {
normal: "text-sky-600 no-underline hover:underline",
Expand All @@ -15,18 +16,17 @@ const variantClasses = {

export default function Link({
href,
variant,
variant = "unstyled",
className,
...props
}: React.PropsWithChildren<LinkProps>) {
const baseClasses = variantClasses[variant] ?? variantClasses.normal;

return (
<NextLink href={href}>
<a
{...props}
className={`${baseClasses}${className ? ` ${className}` : ""}`}
/>
</NextLink>
<NextLink
href={href}
{...props}
className={`${baseClasses}${className ? ` ${className}` : ""}`}
/>
);
}
4 changes: 2 additions & 2 deletions components/theme-toggle/theme-toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function ThemeToggle() {
// This is required to prevent the animation from playing on
// initial mount as well as update the aria-label.
const changedRef = useRef(false);
const [colorScheme, setColorScheme] = useState(null);
const [colorScheme, setColorScheme] = useState<"dark" | "light" | null>(null);
const handleChange = useCallback(
(ev) => {
const colorScheme = resolveColorScheme(ev.target.checked);
Expand Down Expand Up @@ -56,7 +56,7 @@ export default function ThemeToggle() {
// It's set to auto for the first time since the user didn't
// actually change it and we set the theme automatically based
// on preference.
aria-label={hasThemeChanged ? colorScheme : "auto"}
aria-label={(hasThemeChanged && colorScheme) || "auto"}
aria-live="polite"
id="theme-toggle"
className={`sr-only peer`}
Expand Down
9 changes: 0 additions & 9 deletions constants.js

This file was deleted.

9 changes: 9 additions & 0 deletions constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const constants = {
GITHUB_API_BASE_URL: "https://api.github.com",
GIST: {
HOME: "59ff2b40f69fc7f4ea2fdd6b1a044648",
CHANGELOG: "2ff7302367044178af3eeaee4384a4ba",
},
};

export default constants;
1 change: 1 addition & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
Loading

0 comments on commit 33b1917

Please sign in to comment.