Connect, collaborate, and grow with a community of TypeScript developers
responsive layout & focus states (#26)
PickleNik22ce668216aa
diff --git a/src/components/explore/explore-card.tsx b/src/components/explore/explore-card.tsxindex 389870fb..b2bcb3b5 100644--- a/src/components/explore/explore-card.tsx+++ b/src/components/explore/explore-card.tsx@@ -20,11 +20,14 @@ const BORDERS_BY_DIFFICULTY = {};const SHADOWS_BY_DIFFICULTY = {- BEGINNER: 'hover:shadow-[0_0_1rem_-0.5rem_#f9a8d4,inset_0_0_1rem_-0.5rem_#f9a8d4]',- EASY: 'hover:shadow-[0_0_1rem_-0.5rem_#86efac,inset_0_0_1rem_-0.5rem_#86efac]',- MEDIUM: 'hover:shadow-[0_0_1rem_-0.5rem_#fde047,inset_0_0_1rem_-0.5rem_#fde047]',- HARD: 'hover:shadow-[0_0_1rem_-0.5rem_#fca5a5,inset_0_0_1rem_-0.5rem_#fca5a5]',- EXTREME: 'hover:shadow-[0_0_1rem_-0.5rem_#fdba74,inset_0_0_1rem_-0.5rem_#fdba74]',+ BEGINNER:+ 'hover:shadow-[0_0_1rem_-0.5rem_#f9a8d4,inset_0_0_1rem_-0.5rem_#f9a8d4] group-focus:shadow-[0_0_1rem_-0.5rem_#f9a8d4,inset_0_0_1rem_-0.5rem_#f9a8d4]',+ EASY: 'hover:shadow-[0_0_1rem_-0.5rem_#86efac,inset_0_0_1rem_-0.5rem_#86efac] group-focus:shadow-[0_0_1rem_-0.5rem_#86efac,inset_0_0_1rem_-0.5rem_#86efac]',+ MEDIUM:+ 'hover:shadow-[0_0_1rem_-0.5rem_#fde047,inset_0_0_1rem_-0.5rem_#fde047] group-focus:shadow-[0_0_1rem_-0.5rem_#fde047,inset_0_0_1rem_-0.5rem_#fde047]',+ HARD: 'hover:shadow-[0_0_1rem_-0.5rem_#fca5a5,inset_0_0_1rem_-0.5rem_#fca5a5] group-focus:shadow-[0_0_1rem_-0.5rem_#fca5a5,inset_0_0_1rem_-0.5rem_#fca5a5]',+ EXTREME:+ 'hover:shadow-[0_0_1rem_-0.5rem_#fdba74,inset_0_0_1rem_-0.5rem_#fdba74] group-focus:shadow-[0_0_1rem_-0.5rem_#fdba74,inset_0_0_1rem_-0.5rem_#fdba74]',};// in miliseconds@@ -39,7 +42,7 @@ const units = {const rtf = new Intl.RelativeTimeFormat('en', {numeric: 'auto',- // style: 'short'+ // TODO: style: 'short' on 640px - 720px});// TODO: typescript@@ -56,7 +59,7 @@ const getRelativeTime = (date) => {export function ExploreCard({ challenge }: Props) {return (<Card- className={`hover:bg-card-hovered group duration-300 ${+ className={`group duration-300 hover:bg-card-hovered group-focus:bg-card-hovered ${SHADOWS_BY_DIFFICULTY[challenge.difficulty]} ${BORDERS_BY_DIFFICULTY[challenge.difficulty]}`}>@@ -64,7 +67,7 @@ export function ExploreCard({ challenge }: Props) {<div className="space-y-1"><CardTitle>{challenge.name}</CardTitle><CardDescription className="relative h-48 overflow-hidden pb-4">- <div className="pointer-events-none absolute inset-0 h-full w-full shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card))] duration-300 group-hover:shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card-hovered))]" />+ <div className="pointer-events-none absolute inset-0 h-full w-full shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card))] duration-300 group-hover:shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card-hovered))] group-focus:shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card-hovered))]" />{challenge.description}</CardDescription></div>diff --git a/src/components/explore/section.tsx b/src/components/explore/section.tsxindex 6f9a6c36..67a3abf3 100644--- a/src/components/explore/section.tsx+++ b/src/components/explore/section.tsx@@ -13,7 +13,7 @@ export async function ExploreSection({ title, data }: Props) {return (<div><TypographyH3 className="mb-3">{title}</TypographyH3>- <div className="grid grid-cols-3 gap-2">+ <div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-3">{challenges.map((challenge) => (<LinkclassName="group focus:outline-none"diff --git a/src/components/ui/navigation-menu.tsx b/src/components/ui/navigation-menu.tsxindex 738c3117..77ac25f4 100644--- a/src/components/ui/navigation-menu.tsx+++ b/src/components/ui/navigation-menu.tsx@@ -1,9 +1,9 @@-import * as React from "react";-import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";-import { cva } from "class-variance-authority";-import { ChevronDown } from "lucide-react";+import * as React from 'react';+import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu';+import { cva } from 'class-variance-authority';+import { ChevronDown } from 'lucide-react';-import { cn } from "~/utils/cn";+import { cn } from '~/utils/cn';const NavigationMenu = React.forwardRef<React.ElementRef<typeof NavigationMenuPrimitive.Root>,@@ -11,10 +11,7 @@ const NavigationMenu = React.forwardRef<>(({ className, children, ...props }, ref) => (<NavigationMenuPrimitive.Rootref={ref}- className={cn(- "relative z-10 flex flex-1 items-center justify-center",- className- )}+ className={cn('relative z-10 flex flex-1 items-center justify-center', className)}{...props}>{children}@@ -29,10 +26,7 @@ const NavigationMenuList = React.forwardRef<>(({ className, ...props }, ref) => (<NavigationMenuPrimitive.Listref={ref}- className={cn(- "group flex flex-1 list-none items-center justify-center space-x-1",- className- )}+ className={cn('group flex flex-1 list-none items-center justify-center space-x-1', className)}{...props}/>));@@ -41,7 +35,7 @@ NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;const NavigationMenuItem = NavigationMenuPrimitive.Item;const navigationMenuTriggerStyle = cva(- "inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus:outline-none focus:bg-accent focus:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none bg-background hover:bg-accent hover:text-accent-foreground data-[state=open]:bg-accent/50 data-[active]:bg-accent/50 h-10 py-2 px-4 group w-max"+ 'inline-flex items-center justify-center rounded-xl text-sm font-medium transition-colors focus:outline-none focus:bg-accent focus:text-accent-foreground disabled:opacity-50 disabled:pointer-events-none bg-background hover:bg-accent hover:text-accent-foreground data-[state=open]:bg-accent/50 data-[active]:bg-accent/50 h-10 py-2 px-4 group w-max',);const NavigationMenuTrigger = React.forwardRef<@@ -50,12 +44,12 @@ const NavigationMenuTrigger = React.forwardRef<>(({ className, children, ...props }, ref) => (<NavigationMenuPrimitive.Triggerref={ref}- className={cn(navigationMenuTriggerStyle(), "group", className)}+ className={cn(navigationMenuTriggerStyle(), 'group', className)}{...props}>- {children}{" "}+ {children}{' '}<ChevronDown- className="relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180"+ className="relative top-[1px] ml-3 h-4 w-4 transition duration-200 group-data-[state=open]:rotate-180"aria-hidden="true"/></NavigationMenuPrimitive.Trigger>@@ -69,8 +63,8 @@ const NavigationMenuContent = React.forwardRef<<NavigationMenuPrimitive.Contentref={ref}className={cn(- "left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",- className+ 'left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ',+ className,)}{...props}/>@@ -83,19 +77,18 @@ const NavigationMenuViewport = React.forwardRef<React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>>(({ className, ...props }, ref) => (- <div className={cn("absolute left-0 top-full flex justify-center")}>+ <div className={cn('absolute left-0 top-full flex justify-center')}><NavigationMenuPrimitive.ViewportclassName={cn(- "origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",- className+ 'origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]',+ className,)}ref={ref}{...props}/></div>));-NavigationMenuViewport.displayName =- NavigationMenuPrimitive.Viewport.displayName;+NavigationMenuViewport.displayName = NavigationMenuPrimitive.Viewport.displayName;const NavigationMenuIndicator = React.forwardRef<React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,@@ -104,16 +97,15 @@ const NavigationMenuIndicator = React.forwardRef<<NavigationMenuPrimitive.Indicatorref={ref}className={cn(- "top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",- className+ 'top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in',+ className,)}{...props}><div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" /></NavigationMenuPrimitive.Indicator>));-NavigationMenuIndicator.displayName =- NavigationMenuPrimitive.Indicator.displayName;+NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName;export {navigationMenuTriggerStyle,diff --git a/src/components/ui/navigation.tsx b/src/components/ui/navigation.tsxindex 39ad1443..44a0b5d0 100644--- a/src/components/ui/navigation.tsx+++ b/src/components/ui/navigation.tsx@@ -28,10 +28,10 @@ export function Navigation() {<header className="w-full"><nav className="container flex h-14 items-center"><div className="flex w-full items-center justify-between">- <div className="flex">- <a className="mr-6 flex items-center space-x-2" href="/">+ <div className="relative flex basis-1/3">+ <a className="flex items-center space-x-2 duration-300" href="/"><svg- className="h-6 w-6 rounded-md"+ className="h-6 w-6 rounded-md bg-indigo-500 p-[2px]"viewBox="0 0 512 512"fill="none"xmlns="http://www.w3.org/2000/svg"@@ -59,30 +59,35 @@ export function Navigation() {</defs></svg>- <span className="hidden font-bold sm:inline-block">type/hero</span>+ <span className="font-bold leading-3">+ type+ <br />+ hero+ </span></a>- <NavigationMenu>- <NavigationMenuList>- <NavigationMenuItem>- <Link href="/explore" legacyBehavior passHref>- <NavigationMenuLink className={navigationMenuTriggerStyle()}>- Explore- </NavigationMenuLink>- </Link>- </NavigationMenuItem>- <NavigationMenuItem>- <NavigationMenuTrigger>Something Nice</NavigationMenuTrigger>- <NavigationMenuContent>- <NavigationMenuLink>Nice</NavigationMenuLink>- </NavigationMenuContent>- </NavigationMenuItem>- </NavigationMenuList>- </NavigationMenu></div>- <div className="flex items-center gap-4 pr-2">+ <NavigationMenu className="basis-1/3">+ <NavigationMenuList>+ <NavigationMenuItem>+ <Link href="/explore" legacyBehavior passHref>+ <NavigationMenuLink className={navigationMenuTriggerStyle()}>+ Explore+ </NavigationMenuLink>+ </Link>+ </NavigationMenuItem>+ <NavigationMenuItem className="hidden sm:block">+ <NavigationMenuTrigger>Something Nice</NavigationMenuTrigger>+ <NavigationMenuContent>+ <NavigationMenuLink>Nice</NavigationMenuLink>+ </NavigationMenuContent>+ </NavigationMenuItem>+ </NavigationMenuList>+ </NavigationMenu>+ <div className="flex basis-1/3 items-center justify-end gap-2">{mounted && (<buttontype="button"+ className="rounded-lg p-2 duration-300 focus:bg-accent focus:outline-none"onClick={() => {setTheme(resolvedTheme === 'dark' ? 'light' : 'dark');}}@@ -92,7 +97,10 @@ export function Navigation() {</button>)}- <button type="button">+ <button+ type="button"+ className="rounded-lg p-2 duration-300 focus:bg-accent focus:outline-none"+ ><Bell className="h-6 w-6" aria-hidden="true" /></button>diff --git a/src/styles/globals.css b/src/styles/globals.cssindex 3f0c207e..442f5e24 100644--- a/src/styles/globals.css+++ b/src/styles/globals.css@@ -14,6 +14,7 @@--popover-foreground: 240 10% 3.9%;--card: 0 0% 100%;+ --card-hovered: 0 0% 98%;--card-foreground: 240 10% 3.9%;--border: 240 5.9% 90%;