typescript component cleanup

This commit is contained in:
Noah Swerhun 2024-04-08 17:43:55 -05:00
parent 03d58a4fc0
commit 70aa44e2f6
2 changed files with 8 additions and 9 deletions

View file

@ -1,11 +1,11 @@
import { For, onMount } from "solid-js"; import { For, onMount, type Component } from "solid-js";
import { useStore } from "@nanostores/solid"; import { useStore } from "@nanostores/solid";
import { $currentPage } from "@/scripts/currentPage" import { $currentPage } from "@/scripts/currentPage"
interface Page { type Page = {
path: string, path: string,
name: string, name: string,
} };
const pages: Page[] = [ const pages: Page[] = [
{ path: "/", name: "about" }, { path: "/", name: "about" },
@ -17,7 +17,7 @@ const inactiveClasses = "text-xl text-fg_light transition-all duration-300 hover
const activeClasses = "font-bold !text-foreground"; const activeClasses = "font-bold !text-foreground";
const Nav = () => { const Nav: Component = () => {
const currentPage = useStore($currentPage); const currentPage = useStore($currentPage);
onMount(() => { onMount(() => {

View file

@ -1,13 +1,12 @@
import { $currentPage } from "@/scripts/currentPage" import { $currentPage } from "@/scripts/currentPage"
import type { ParentComponent } from "solid-js"; import type { ComponentProps, ParentComponent } from "solid-js";
import { splitProps } from "solid-js"; import { splitProps } from "solid-js";
interface Props { type RequireProps = {
href: string, href: string,
class?: string, };
}
const PageLink: ParentComponent<Props> = (props) => { const PageLink: ParentComponent<ComponentProps<"a"> & RequireProps> = (props) => {
const [local, others] = splitProps(props, ["children"]); const [local, others] = splitProps(props, ["children"]);
return ( return (
<a {...others} onClick={() => $currentPage.set(others.href)}> <a {...others} onClick={() => $currentPage.set(others.href)}>