import { RadioIcon, UserCircleIcon } from "@heroicons/react/24/solid"; import { Link, NavLink } from "@remix-run/react"; import type { RemixLinkProps, RemixNavLinkProps } from "@remix-run/react/dist/components"; import type { ReactNode } from "react"; import * as React from "react"; import { createContext, useContext } from "react"; import type { StationWithTagsClientSide } from "~/models/station.server"; import type { TagWithStationsClientSide } from "~/models/tag.server"; import type { UserWithFavoriteStationsClientSide } from "~/models/user.server"; export type PageLayoutProps = { children: ReactNode; tags: TagWithStationsClientSide[]; user?: UserWithFavoriteStationsClientSide; station: StationWithTagsClientSide | null; } export type StationContextType = { station: StationWithTagsClientSide | null } const StationContext = createContext({ station: null }); export function useStationContext() { return useContext(StationContext); } export function ListenLink(props: RemixLinkProps & React.RefAttributes) { const { station } = useStationContext(); const url = props.to + (station ? `?station=${station.id}` : ""); return {props.children}; } export function ListenNavLink(props: RemixNavLinkProps & React.RefAttributes) { const { station } = useStationContext(); const url = props.to + (station ? `?station=${station.id}` : ""); return {props.children}; } export type ManageContentNavProps = { user?: UserWithFavoriteStationsClientSide; }; export function ManageContentNav({ user }: ManageContentNavProps) { if (!user) { return <>; } return ( <>
  • Manage Content
  • Sources
  • ); } export function PageLayout({ children, tags, user, station }: PageLayoutProps) { return (

    Awesome Radio

    {user ?
    • Logout
    : Join }
    {children}
    • Awesome Radio

    • Listen
    • Home
    • Tags
    • {tags .filter(tag => tag.stations.length > 0) .map((tag) => { return (
    • {tag.name} {tag.stations?.length ?? 0}
    • ); })}
    ); }