Pages
Portfolio

Portfolio Page

A personal portfolio page for React: sticky intro with social icons and resume, Projects, Experience and Open source tabs, list and grid project cards, a GitHub-style contribution heatmap with hover tooltips, and light and dark themes.

portfolio-page.preview

2026

lumen-ui

A React component library with smooth animations and sensible defaults.

filesmith

Convert, organize and share files with fast, local tools. Offline-first.

★

Turn your repository stars into an animated, shareable video.

billbook

Create invoices with ease and export them in any format.

2025

bootstrapr

Generate boilerplate for new projects in multiple languages.

jotpad

Write, read, and manage your posts in one quiet place.

whispr

Chat with anyone, anytime, anywhere. Anonymously.

tickr

Minimal CLI tool for fetching live stock prices.

DecJanFebMarAprMayJunJulAugSepOctNov
239 contributions in the last yearLessMore

Install

Copies the source into components/blocks/portfolio-page.tsx and installs what it needs.

$ pnpm dlx shadcn@latest add https://makeui.xyz/r/portfolio-page.json

Usage

app/page.tsx
import { PortfolioPage } from "@/components/blocks/portfolio-page"

export default function Page() {
  return (
    <PortfolioPage
      name="Alex Morgan"
      role="Full Stack Developer"
      bio={["I build clean, modern websites and apps where the small details matter."]}
      email="hello@example.com"
      resume="https://example.com/resume.pdf"
      resumeIcon="/images/pdf.webp"
      github="https://github.com/alex"
      twitter="https://x.com/alex"
      linkedin="https://www.linkedin.com/in/alex"
      projects={[
        {
          name: "lumen-ui",
          description: "A React component library with smooth animations.",
          year: 2026,
          href: "https://lumen.dev",
          repo: "https://github.com/alex/lumen-ui",
          image: "/shots/lumen-ui.png",
        },
      ]}
      jobs={[
        {
          role: "Full-stack developer",
          company: "Northwind Labs",
          period: "jan 2026 – present",
          description: "Building product features end to end.",
          tags: ["TypeScript", "Next.js"],
        },
      ]}
      certs={[{ title: "Full stack web development", issuer: "Example Academy", href: "#" }]}
      openSource={[{ repo: "example/awesome-lib", title: "feat: added a text shadow feature.", href: "#" }]}
      // optional: one entry per day from the GitHub API, otherwise a sample year is drawn
      contributions={[{ date: "2026-11-14", count: 3 }]}
      updated="14th nov 2026"
      updatedHref="https://github.com/alex/portfolio/commits"
    />
  )
}

Source

Prefer to copy by hand? It's one file. Requires motion and the shadcn cn helper.

components/blocks/portfolio-page.tsx
"use client"

import { useEffect, useId, useMemo, useRef, useState } from "react"
import { AnimatePresence, motion, useReducedMotion } from "motion/react"
import { ArrowUpRight, LayoutGrid, List, PanelTop } from "lucide-react"
import { cn } from "@/lib/utils"

/* ───────────────────────────── types ───────────────────────────── */

type Project = {
  name: string
  description: string
  year: number
  href?: string
  repo?: string
  /** Screenshot URL. Leave out for a drawn placeholder. */
  image?: string
  tone?: [string, string]
  accent?: string
  heading?: string
}
type Job = { role: string; company: string; period: string; description?: string; tags?: string[]; logo?: string }
type Cert = { title: string; issuer: string; href?: string }
type OpenSource = { repo: string; title: string; href: string }
type Contribution = { date: string; count: number }
type ThemeName = "light" | "dark"

type Props = {
  name?: string
  role?: string
  bio?: string[]
  email?: string
  resume?: string
  /** Put pdf.webp in /public/images and this just works. */
  resumeIcon?: string
  github?: string
  twitter?: string
  linkedin?: string
  projects?: Project[]
  jobs?: Job[]
  certs?: Cert[]
  openSource?: OpenSource[]
  openToWork?: boolean
  /** Real GitHub data, one entry per day. Leave out for a generated sample. */
  contributions?: Contribution[]
  contributionsEnd?: string
  contributionsTotal?: number
  /** Text and link for the footer, e.g. your last commit page. */
  updated?: string
  updatedHref?: string
  layout?: "grid" | "list"
  /** Pin a theme. Leave out to follow the site (.dark on <html>) and let visitors toggle with the dot. */
  theme?: ThemeName
  className?: string
}

/* ───────────────────────────── dummy data ───────────────────────────── */

const themes: Record<ThemeName, Record<string, string>> = {
  light: { "--pf-bg": "#fdfdfc", "--pf-fg": "#1c1b19", "--pf-body": "#5f5d58", "--pf-muted": "#8b8983", "--pf-line": "rgb(28 27 25 / 0.12)", "--pf-card": "#f2f2f0", "--pf-accent": "#2f8f5b" },
  dark: { "--pf-bg": "#0a0a0a", "--pf-fg": "#f5f5f4", "--pf-body": "#a8a6a0", "--pf-muted": "#7d7b75", "--pf-line": "rgb(245 245 244 / 0.12)", "--pf-card": "#161615", "--pf-accent": "#4ade80" },
}

const defaultBio = [
  "Hey, I'm Alex, a full stack developer who loves building clean, modern websites and apps where design and the smallest details matter.",
  "I'm flexible with whatever a project needs, though I prefer modern frameworks and tools. Always open to new roles and interesting work.",
]

const defaultProjects: Project[] = [
  { name: "lumen-ui", description: "A React component library with smooth animations and sensible defaults.", year: 2026, href: "#", repo: "#", tone: ["#cddcfb", "#c3d4fa"], accent: "#1f4fe0", heading: "lumen-ui" },
  { name: "filesmith", description: "Convert, organize and share files with fast, local tools. Offline-first.", year: 2026, href: "#", repo: "#", tone: ["#c9f0e4", "#cfe6ff"], accent: "#0f9f84", heading: "filesmith" },
  { name: "starlight", description: "Turn your repository stars into an animated, shareable video.", year: 2026, href: "#", repo: "#", tone: ["#faf0dc", "#f7e9cf"], accent: "#d9a21b", heading: "★" },
  { name: "billbook", description: "Create invoices with ease and export them in any format.", year: 2026, href: "#", tone: ["#e3ebf4", "#dbe6f2"], accent: "#3f6f93", heading: "billbook" },
  { name: "bootstrapr", description: "Generate boilerplate for new projects in multiple languages.", year: 2025, href: "#", tone: ["#ffd9e2", "#ffe8c9"], accent: "#d9467a", heading: "bootstrapr" },
  { name: "jotpad", description: "Write, read, and manage your posts in one quiet place.", year: 2025, href: "#", tone: ["#fff0c2", "#ffd9c9"], accent: "#d98a14", heading: "jotpad" },
  { name: "whispr", description: "Chat with anyone, anytime, anywhere. Anonymously.", year: 2025, href: "#", tone: ["#e6d9ff", "#cfe0ff"], accent: "#6d4de0", heading: "whispr" },
  { name: "tickr", description: "Minimal CLI tool for fetching live stock prices.", year: 2025, repo: "#", tone: ["#e8ecef", "#dde3e8"], accent: "#334155", heading: "tickr" },
]

const defaultJobs: Job[] = [
  {
    role: "Full-stack developer",
    company: "Northwind Labs",
    period: "jan 2026 – present",
    description: "Building product features end to end, from database design to polished interfaces.",
    tags: ["TypeScript", "Next.js", "PostgreSQL"],
  },
  { role: "Frontend developer", company: "Brightside Studio", period: "jul 2025 – dec 2025", description: "Shipped design-system components and landing pages for client projects.", tags: ["React", "Tailwind"] },
]

const defaultCerts: Cert[] = [{ title: "Full stack web development", issuer: "Example Academy", href: "#" }]
const defaultOpenSource: OpenSource[] = [{ repo: "example/awesome-lib", title: "feat: added a text shadow feature.", href: "#" }]

/* ───────────────────────────── helpers ───────────────────────────── */

function mulberry32(seed: number) {
  return () => {
    seed |= 0
    seed = (seed + 0x6d2b79f5) | 0
    let t = Math.imul(seed ^ (seed >>> 15), 1 | seed)
    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t
    return ((t ^ (t >>> 14)) >>> 0) / 4294967296
  }
}

/** A year of sample contributions that adds up to exactly `total`. */
function sampleContributions(endISO: string, total: number): Contribution[] {
  const rand = mulberry32(239)
  const end = new Date(`${endISO}T00:00:00Z`)
  const start = new Date(end)
  start.setUTCDate(end.getUTCDate() - 364)
  start.setUTCDate(start.getUTCDate() - start.getUTCDay())
  const days: Contribution[] = []
  for (const d = new Date(start); d <= end; d.setUTCDate(d.getUTCDate() + 1)) {
    const busy = rand() < 0.42
    days.push({ date: d.toISOString().slice(0, 10), count: busy ? Math.min(12, 1 + Math.floor(Math.pow(rand(), 2.2) * 9)) : 0 })
  }
  let sum = days.reduce((a, d) => a + d.count, 0)
  let guard = 0
  while (sum !== total && guard++ < 20000) {
    const d = days[Math.floor(rand() * days.length)]
    if (sum < total && d.count < 12) (d.count++, sum++)
    else if (sum > total && d.count > 0) (d.count--, sum--)
  }
  return days
}

const level = (n: number) => (n === 0 ? 0 : n <= 2 ? 1 : n <= 4 ? 2 : n <= 7 ? 3 : 4)
const levelMix = [0, 28, 50, 75, 100]
const cellBg = (n: number) => (n === 0 ? "var(--pf-card)" : `color-mix(in oklab, var(--pf-accent) ${levelMix[level(n)]}%, var(--pf-card))`)
const fmtDay = (d: string) => new Date(`${d}T00:00:00Z`).toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric", timeZone: "UTC" })

function useHtmlDark() {
  const [dark, setDark] = useState(false)
  useEffect(() => {
    const el = document.documentElement
    const read = () => setDark(el.classList.contains("dark"))
    read()
    const mo = new MutationObserver(read)
    mo.observe(el, { attributes: true, attributeFilter: ["class"] })
    return () => mo.disconnect()
  }, [])
  return dark
}

/* ───────────────────────────── icons ───────────────────────────── */

const GithubIcon = () => (
  <svg viewBox="0 0 438.549 438.549" className="size-5" aria-hidden>
    <path fill="currentColor" d="M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8C295.736 15.166 259.057 5.365 219.271 5.365c-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z" />
  </svg>
)

const TwitterIcon = () => (
  <svg viewBox="0 0 248 204" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" className="size-5">
    <path fill="#1D9BF0" d="M221.95 51.29c.15 2.17.15 4.34.15 6.53 0 66.73-50.8 143.69-143.69 143.69v-.04c-27.44.04-54.31-7.82-77.41-22.64 3.99.48 8 .72 12.02.73 22.74.02 44.83-7.61 62.72-21.66-21.61-.41-40.56-14.5-47.18-35.07 7.57 1.46 15.37 1.16 22.8-.87C27.8 117.2 10.85 96.5 10.85 72.46v-.64c7.02 3.91 14.88 6.08 22.92 6.32C11.58 63.31 4.74 33.79 18.14 10.71c25.64 31.55 63.47 50.73 104.08 52.76-4.07-17.54 1.49-35.92 14.61-48.25 20.34-19.12 52.33-18.14 71.45 2.19 11.31-2.23 22.15-6.38 32.07-12.26-3.77 11.69-11.66 21.62-22.2 27.93 10.01-1.18 19.79-3.86 29-7.95-6.77 10.16-15.32 19.01-25.2 26.16z" />
  </svg>
)

const LinkedinIcon = () => (
  <svg viewBox="0 0 72 72" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" className="size-5">
    <rect width="72" height="72" rx="10" ry="10" fill="#0A66C2" />
    <path fill="#ffffff" d="M13.139 27.308h9.166v29.16h-9.166zm4.55-14.55a5.322 5.322 0 110 10.644 5.322 5.322 0 010-10.644m10.683 14.55h8.784v3.985h.124c1.224-2.32 4.21-4.76 8.669-4.76 9.27 0 10.983 6.1 10.983 14.03v16.145h-9.15V42.989c0-3.42-.061-7.816-4.76-7.816-4.766 0-5.494 3.723-5.494 7.57v13.725h-9.156V27.308z" />
  </svg>
)

const GmailIcon = () => (
  <svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" className="size-5">
    <path fill="#4caf50" d="M45,16.2l-5,2.75l-5,4.75L35,40h7c1.657,0,3-1.343,3-3V16.2z" />
    <path fill="#1e88e5" d="M3,16.2l3.614,1.71L13,23.7V40H6c-1.657,0-3-1.343-3-3V16.2z" />
    <polygon fill="#e53935" points="35,11.2 24,19.45 13,11.2 12,17 13,23.7 24,31.95 35,23.7 36,17" />
    <path fill="#c62828" d="M3,12.298V16.2l10,7.5V11.2L9.876,8.859C9.132,8.301,8.228,8,7.298,8h0 C4.924,8,3,9.924,3,12.298z" />
    <path fill="#fbc02d" d="M45,12.298V16.2l-10,7.5V11.2l3.124-2.341C38.868,8.301,39.772,8,40.702,8h0 C43.076,8,45,9.924,45,12.298z" />
  </svg>
)

/* ───────────────────────────── small pieces ───────────────────────────── */

function StatusBar({ url }: { url: string | null }) {
  return (
    <AnimatePresence>
      {url && url !== "#" && (
        <motion.div
          initial={{ opacity: 0 }}
          animate={{ opacity: 1 }}
          exit={{ opacity: 0 }}
          transition={{ duration: 0.1 }}
          className="pointer-events-none fixed bottom-0 left-0 z-50 rounded-tr-md border-r border-t border-black/10 bg-neutral-100 px-2 py-0.5 font-mono text-[11px] text-neutral-700"
        >
          {url}
        </motion.div>
      )}
    </AnimatePresence>
  )
}

/** Drawn stand-in for a screenshot. */
function Shot({ accent = "#3f6f93", image, name, heading }: { accent?: string; image?: string; name: string; heading?: string }) {
  const isMark = heading && heading.length <= 2
  return (
    <>
      {!image && (
        <div className="absolute inset-x-0 top-[14%] flex justify-center">
          {isMark ? (
            <span className="text-xl font-semibold" style={{ color: accent }}>{heading}</span>
          ) : (
            <span className="text-[15px] font-medium text-neutral-700">{heading ?? name}</span>
          )}
        </div>
      )}
      <div className="absolute inset-x-[9%] bottom-0 top-[42%] overflow-hidden rounded-t-xl bg-white shadow-[0_18px_40px_-18px_rgb(0_0_0/0.35)] ring-1 ring-black/5">
        <div className="flex h-5 items-center gap-1.5 border-b border-neutral-200 bg-neutral-50 px-2.5">
          <span className="size-1.5 rounded-full bg-neutral-300" />
          <span className="size-1.5 rounded-full bg-neutral-300" />
          <span className="size-1.5 rounded-full bg-neutral-300" />
          <span className="ml-2 h-2.5 w-24 rounded-full bg-neutral-200/80" />
        </div>
        {image ? (
          // eslint-disable-next-line @next/next/no-img-element
          <img src={image} alt={`${name} screenshot`} className="h-full w-full object-cover object-top" loading="lazy" />
        ) : (
          <div className="relative p-4">
            <div className="flex items-center justify-between">
              <span className="h-2 w-12 rounded-full" style={{ background: accent }} />
              <span className="flex gap-2">
                <span className="h-1.5 w-8 rounded-full bg-neutral-200" />
                <span className="h-1.5 w-8 rounded-full bg-neutral-200" />
                <span className="h-1.5 w-8 rounded-full bg-neutral-200" />
              </span>
            </div>
            <div className="mt-5 w-[52%] space-y-2">
              <span className="block h-3.5 w-full rounded-full bg-neutral-800" />
              <span className="block h-3.5 w-4/5 rounded-full bg-neutral-800" />
              <span className="mt-3 block h-1.5 w-full rounded-full bg-neutral-200" />
              <span className="block h-1.5 w-3/4 rounded-full bg-neutral-200" />
              <span className="mt-3 block h-6 w-20 rounded-full" style={{ background: accent }} />
            </div>
            <div className="absolute bottom-0 right-5 top-5 w-[34%]">
              <div className="absolute inset-x-0 bottom-0 h-[78%] rounded-t-lg opacity-20" style={{ background: accent }} />
              <div className="absolute bottom-0 left-[18%] h-full w-[34%] rounded-t-md opacity-40" style={{ background: accent }} />
              <div className="absolute bottom-0 right-[8%] h-[58%] w-[26%] rounded-t-md opacity-60" style={{ background: accent }} />
            </div>
          </div>
        )}
      </div>
    </>
  )
}

function Logo({ src, name, className }: { src?: string; name: string; className?: string }) {
  const [bad, setBad] = useState(false)
  return (
    <span className={cn("grid shrink-0 place-items-center overflow-hidden rounded-lg bg-(--pf-card) text-xs font-medium text-(--pf-fg) ring-1 ring-(--pf-line)", className)}>
      {src && !bad ? (
        // eslint-disable-next-line @next/next/no-img-element
        <img src={src} alt={`${name} logo`} className="size-full object-cover" onError={() => setBad(true)} />
      ) : (
        name[0]
      )}
    </span>
  )
}

/** GitHub-style contribution heatmap with a hover tooltip. */
function Heatmap({ data, total }: { data: Contribution[]; total: number }) {
  const [tip, setTip] = useState<{ x: number; y: number; text: string } | null>(null)
  const wrap = useRef<HTMLDivElement>(null)

  const firstDow = new Date(`${data[0].date}T00:00:00Z`).getUTCDay()
  const cols = Math.ceil((data.length + firstDow) / 7)

  const months = useMemo(() => {
    const out: { col: number; label: string }[] = []
    let last = -1
    data.forEach((d, i) => {
      const dt = new Date(`${d.date}T00:00:00Z`)
      const m = dt.getUTCMonth()
      if (m !== last && dt.getUTCDate() <= 7) {
        out.push({ col: Math.floor((i + firstDow) / 7), label: dt.toLocaleDateString("en-US", { month: "short", timeZone: "UTC" }) })
        last = m
      }
    })
    return out
  }, [data, firstDow])

  const show = (e: React.MouseEvent<HTMLSpanElement> | React.FocusEvent<HTMLSpanElement>, d: Contribution) => {
    const box = wrap.current
    if (!box) return
    const a = e.currentTarget.getBoundingClientRect()
    const b = box.getBoundingClientRect()
    setTip({
      x: a.left - b.left + a.width / 2,
      y: a.top - b.top,
      text: `${d.count === 0 ? "No" : d.count} contribution${d.count === 1 ? "" : "s"} on ${fmtDay(d.date)}`,
    })
  }

  return (
    <section className="mt-14">
      <div ref={wrap} className="relative">
        <div className="grid gap-[3px] text-[11px] text-(--pf-muted)" style={{ gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))` }}>
          {months.map((m) => (
            <span key={m.col} className="whitespace-nowrap" style={{ gridColumnStart: m.col + 1, gridRowStart: 1 }}>{m.label}</span>
          ))}
        </div>

        <div
          className="mt-1.5 grid gap-[3px]"
          style={{ gridTemplateRows: "repeat(7, auto)", gridAutoFlow: "column", gridAutoColumns: "minmax(0, 1fr)" }}
          onMouseLeave={() => setTip(null)}
        >
          {Array.from({ length: firstDow }).map((_, i) => (
            <span key={`pad-${i}`} className="aspect-square" />
          ))}
          {data.map((d) => (
            <span
              key={d.date}
              tabIndex={0}
              onMouseEnter={(e) => show(e, d)}
              onFocus={(e) => show(e, d)}
              onBlur={() => setTip(null)}
              className="aspect-square rounded-[2px] outline-none transition-transform duration-150 hover:z-10 hover:scale-[1.6] hover:ring-1 hover:ring-(--pf-fg)/50 focus-visible:scale-[1.6] focus-visible:ring-1 focus-visible:ring-(--pf-fg)/60"
              style={{ background: cellBg(d.count) }}
            />
          ))}
        </div>

        <AnimatePresence>
          {tip && (
            <motion.div
              initial={{ opacity: 0, y: 3 }}
              animate={{ opacity: 1, y: 0 }}
              exit={{ opacity: 0 }}
              transition={{ duration: 0.1 }}
              className="pointer-events-none absolute z-20 -translate-x-1/2 -translate-y-full whitespace-nowrap rounded-md bg-(--pf-fg) px-2 py-1 text-xs text-(--pf-bg) shadow-lg"
              style={{ left: tip.x, top: tip.y - 8 }}
            >
              {tip.text}
            </motion.div>
          )}
        </AnimatePresence>
      </div>

      <div className="mt-3 flex items-center justify-between text-xs text-(--pf-muted)">
        <span>{total} contributions in the last year</span>
        <span className="inline-flex items-center gap-1.5">
          Less
          {[0, 1, 2, 3, 4].map((l) => (
            <span key={l} className="size-2.5 rounded-[2px]" style={{ background: l === 0 ? "var(--pf-card)" : cellBg(l === 1 ? 1 : l === 2 ? 3 : l === 3 ? 6 : 9) }} />
          ))}
          More
        </span>
      </div>
    </section>
  )
}

const pill = "rounded-full outline-none focus-visible:ring-2 focus-visible:ring-(--pf-muted)/50"

/* ───────────────────────────── page ───────────────────────────── */

export function PortfolioPage({
  name = "Alex Morgan",
  role = "Full Stack Developer",
  bio = defaultBio,
  email = "hello@example.com",
  resume = "#",
  resumeIcon = "/images/pdf.webp",
  github = "#",
  twitter = "#",
  linkedin = "#",
  projects = defaultProjects,
  jobs = defaultJobs,
  certs = defaultCerts,
  openSource = defaultOpenSource,
  openToWork = true,
  contributions,
  contributionsEnd = "2026-11-14",
  contributionsTotal = 239,
  updated = "14th nov 2026",
  updatedHref = "#",
  layout: initialLayout = "grid",
  theme,
  className,
}: Props) {
  const reduce = useReducedMotion()
  const siteDark = useHtmlDark()
  const id = useId()
  const [choice, setChoice] = useState<ThemeName | null>(null)
  const [tab, setTab] = useState<"projects" | "experience" | "open source">("projects")
  const [layout, setLayout] = useState(initialLayout)
  /** split = sticky intro beside content, stacked = one centred column */
  const [split, setSplit] = useState(true)
  const [hoverUrl, setHoverUrl] = useState<string | null>(null)

  const data = useMemo(() => contributions ?? sampleContributions(contributionsEnd, contributionsTotal), [contributions, contributionsEnd, contributionsTotal])
  const total = contributions ? contributions.reduce((a, d) => a + d.count, 0) : contributionsTotal

  const current: ThemeName = theme ?? choice ?? (siteDark ? "dark" : "light")
  const vars = themes[current] as React.CSSProperties
  const spring = { type: "spring" as const, stiffness: 420, damping: 34 }
  const stageFilter = current === "dark" ? "brightness(0.62) saturate(0.9)" : "none"

  const iconBtn = cn(pill, "grid size-8 place-items-center text-(--pf-muted) transition-colors hover:text-(--pf-fg)")
  const hover = (url?: string) => ({
    onMouseEnter: () => url && setHoverUrl(url),
    onMouseLeave: () => setHoverUrl(null),
  })
  const years = Array.from(new Set(projects.map((p) => p.year))).sort((a, b) => b - a)

  const socials = [
    { label: "GitHub", href: github, icon: <GithubIcon /> },
    { label: "Twitter", href: twitter, icon: <TwitterIcon /> },
    { label: "LinkedIn", href: linkedin, icon: <LinkedinIcon /> },
    { label: "Email", href: `mailto:${email}`, icon: <GmailIcon /> },
  ]

  const renderProject = (p: Project) => {
    const tone = `linear-gradient(135deg, ${p.tone?.[0] ?? "#dfe8f5"}, ${p.tone?.[1] ?? "#ebe2f7"})`
    const main = p.href ?? p.repo
    const repoLink = p.repo && p.href && (
      <a href={p.repo} {...hover(p.repo)} aria-label={`${p.name} on GitHub`} className="text-(--pf-muted) transition-colors hover:text-(--pf-fg) [&_svg]:size-4">
        <GithubIcon />
      </a>
    )
    return (
      <motion.div key={p.name} layout={!reduce} transition={spring} className={cn("group min-w-0", layout === "list" && "rounded-2xl p-2 transition-colors hover:bg-(--pf-card)")}>
        {layout === "grid" ? (
          <>
            <a href={main ?? "#"} {...hover(main)} className="relative block aspect-[16/10] overflow-hidden rounded-2xl outline-none transition-[filter] duration-500" style={{ background: tone, filter: stageFilter }}>
              <Shot accent={p.accent} image={p.image} name={p.name} heading={p.heading} />
              <span className="absolute right-3 top-3 grid size-7 place-items-center rounded-full bg-white/85 text-neutral-700 opacity-0 shadow-sm backdrop-blur transition-all duration-200 group-hover:scale-110 group-hover:opacity-100">
                <ArrowUpRight className="size-3.5" />
              </span>
            </a>
            <div className="mt-3 flex items-center justify-between gap-3 px-1">
              <a href={main ?? "#"} {...hover(main)} className="truncate text-[15px] text-(--pf-fg) outline-none transition-colors hover:text-(--pf-accent)">{p.name}</a>
              {repoLink}
            </div>
            <p className="mt-1 px-1 text-sm leading-relaxed text-(--pf-muted)">{p.description}</p>
          </>
        ) : (
          <div className="flex items-center gap-4">
            <a href={main ?? "#"} {...hover(main)} className="relative block h-14 w-20 shrink-0 overflow-hidden rounded-lg" style={{ background: tone, filter: stageFilter }}>
              <span className="absolute inset-x-3 bottom-0 top-4 rounded-t-md bg-white/90" />
              <span className="absolute left-5 top-7 h-1.5 w-8 rounded-full" style={{ background: p.accent ?? "#3f6f93" }} />
            </a>
            <div className="min-w-0 flex-1">
              <div className="flex items-center justify-between gap-3">
                <a href={main ?? "#"} {...hover(main)} className="truncate text-[15px] text-(--pf-fg) transition-colors hover:text-(--pf-accent)">{p.name}</a>
                {repoLink}
              </div>
              <p className="mt-0.5 truncate text-sm text-(--pf-muted)">{p.description}</p>
            </div>
          </div>
        )}
      </motion.div>
    )
  }

  return (
    <div className="@container">
      <StatusBar url={hoverUrl} />
      <div style={vars} className={cn("relative overflow-hidden bg-(--pf-bg) text-(--pf-body) transition-colors duration-500", className)}>
        <div className="mx-auto max-w-4xl px-6 pb-20 pt-6">
          {/* top bar */}
          <div className="flex items-center justify-between gap-3">
            <nav className="flex items-center gap-5 text-sm">
              <span className="font-medium text-(--pf-fg)">{name.split(" ")[0].toLowerCase()}.</span>
              <button type="button" onClick={() => setTab("projects")} className="text-(--pf-muted) transition-colors hover:text-(--pf-fg)">projects</button>
            </nav>
            <div className="flex items-center gap-1">
              <button
                type="button"
                onClick={() => setSplit((s) => !s)}
                aria-label={split ? "Switch to single column" : "Switch to two columns"}
                aria-pressed={!split}
                title={split ? "Single column" : "Two columns"}
                className={iconBtn}
              >
                <PanelTop className="size-[18px]" strokeWidth={1.6} />
              </button>
              {!theme && (
                <button
                  type="button"
                  onClick={() => setChoice(current === "dark" ? "light" : "dark")}
                  aria-label={`Theme: ${current}. Switch to ${current === "dark" ? "light" : "dark"}`}
                  className={cn(pill, "grid size-8 place-items-center")}
                >
                  <motion.span
                    key={current}
                    initial={reduce ? false : { scale: 0.4, opacity: 0 }}
                    animate={{ scale: 1, opacity: 1 }}
                    transition={spring}
                    className="size-3 rounded-full bg-(--pf-fg) ring-2 ring-(--pf-muted)/30"
                  />
                </button>
              )}
            </div>
          </div>

          <motion.div
            layout={!reduce}
            transition={spring}
            className={cn("mt-8 grid gap-12", split ? "@3xl:grid-cols-[16rem_minmax(0,1fr)] @3xl:gap-16" : "mx-auto max-w-xl grid-cols-1")}
          >
            {/* intro */}
            <aside className={cn("flex flex-col gap-10", split && "@3xl:sticky @3xl:top-8 @3xl:min-h-[28rem] @3xl:justify-between @3xl:self-start")}>
              <div>
                <h1 className="text-base font-medium text-(--pf-fg)">{name}</h1>
                <p className="mt-0.5 text-base text-(--pf-muted) underline decoration-(--pf-line) decoration-dotted underline-offset-4">{role}</p>
                <div className="mt-6 space-y-5 text-[15px] leading-relaxed">
                  {bio.map((p, i) => (
                    <p key={i}>{p}</p>
                  ))}
                </div>
                <div className="mt-6 flex flex-wrap items-center gap-2">
                  <a href={`mailto:${email}`} className="rounded-full bg-(--pf-fg) px-4 py-1.5 text-sm text-(--pf-bg) transition-opacity hover:opacity-80">get in touch</a>
                  <a href={resume} {...hover(resume)} className="inline-flex items-center gap-1.5 rounded-full border border-(--pf-line) py-1.5 pl-2.5 pr-4 text-sm text-(--pf-fg) transition-colors hover:bg-(--pf-card)">
                    {/* eslint-disable-next-line @next/next/no-img-element */}
                    <img src={resumeIcon} alt="" className="size-5 object-contain" />
                    resume
                  </a>
                </div>
              </div>

              <ul className="flex items-center gap-4">
                {socials.map((s) => (
                  <li key={s.label}>
                    <a href={s.href} {...hover(s.href)} aria-label={s.label} className="block text-(--pf-fg) transition-opacity hover:opacity-60">
                      {s.icon}
                    </a>
                  </li>
                ))}
              </ul>
            </aside>

            {/* content */}
            <div className="min-w-0">
              <div className="flex items-center justify-between gap-3">
                <div role="tablist" className="flex items-center gap-1">
                  {(["projects", "experience", "open source"] as const).map((t) => {
                    const on = tab === t
                    return (
                      <button
                        key={t}
                        role="tab"
                        type="button"
                        aria-selected={on}
                        onClick={() => setTab(t)}
                        className={cn(pill, "relative h-8 whitespace-nowrap px-3 text-sm capitalize transition-colors", on ? "text-(--pf-fg)" : "text-(--pf-muted) hover:text-(--pf-fg)")}
                      >
                        {on && <motion.span layoutId={`tab-${id}`} transition={spring} className="absolute inset-0 rounded-full bg-(--pf-card)" />}
                        <span className="relative">{t}</span>
                      </button>
                    )
                  })}
                </div>

                {tab === "projects" && (
                  <div role="radiogroup" aria-label="Layout" className="flex items-center gap-0.5">
                    {([["list", List, "List view"], ["grid", LayoutGrid, "Grid view"]] as const).map(([o, Icon, label]) => (
                      <button
                        key={o}
                        type="button"
                        role="radio"
                        aria-checked={layout === o}
                        aria-label={label}
                        onClick={() => setLayout(o)}
                        className={cn(pill, "grid size-8 place-items-center transition-colors", layout === o ? "text-(--pf-fg)" : "text-(--pf-muted) hover:text-(--pf-fg)")}
                      >
                        <Icon className="size-[18px]" fill={layout === o ? "currentColor" : "none"} />
                      </button>
                    ))}
                  </div>
                )}
              </div>

              <AnimatePresence mode="wait" initial={false}>
                <motion.div
                  key={tab}
                  initial={reduce ? false : { opacity: 0, y: 8 }}
                  animate={{ opacity: 1, y: 0 }}
                  exit={{ opacity: 0, y: -6 }}
                  transition={{ duration: 0.2 }}
                  className="mt-5"
                >
                  {tab === "projects" && (
                    <div className="space-y-8">
                      {years.map((y) => (
                        <div key={y}>
                          <p className="mb-3 px-1 text-xs tabular-nums text-(--pf-muted)">{y}</p>
                          <div className={cn("grid gap-x-5", layout === "grid" ? "gap-y-9 @4xl:grid-cols-2" : "gap-y-1")}>
                            {projects.filter((p) => p.year === y).map(renderProject)}
                          </div>
                        </div>
                      ))}
                    </div>
                  )}

                  {tab === "experience" && (
                    <div>
                      {openToWork && (
                        <span className="inline-flex items-center gap-1.5 rounded-full bg-(--pf-card) px-2.5 py-1 text-xs text-(--pf-fg)">
                          <span className="relative grid size-1.5 place-items-center">
                            <span className="absolute size-full animate-ping rounded-full bg-emerald-400 opacity-70" />
                            <span className="size-1.5 rounded-full bg-emerald-500" />
                          </span>
                          open to work
                        </span>
                      )}

                      <h2 className="mt-6 text-sm text-(--pf-fg)">experience.</h2>
                      <ul className="mt-3 space-y-6">
                        {jobs.map((j) => (
                          <li key={j.company + j.period} className="flex gap-3">
                            <Logo src={j.logo} name={j.company} className="mt-0.5 size-9" />
                            <div className="min-w-0">
                              <div className="flex flex-wrap items-baseline justify-between gap-x-3">
                                <p className="text-[15px] text-(--pf-fg)">{j.role}</p>
                                <span className="text-xs text-(--pf-muted)">{j.period}</span>
                              </div>
                              <p className="text-sm text-(--pf-muted)">{j.company}</p>
                              {j.description && <p className="mt-2 text-sm leading-relaxed">{j.description}</p>}
                              {j.tags && (
                                <ul className="mt-2 flex flex-wrap gap-1.5">
                                  {j.tags.map((t) => (
                                    <li key={t} className="rounded-full bg-(--pf-card) px-2.5 py-0.5 text-xs text-(--pf-body)">{t}</li>
                                  ))}
                                </ul>
                              )}
                            </div>
                          </li>
                        ))}
                      </ul>

                      <h2 className="mt-10 text-sm text-(--pf-fg)">certifications.</h2>
                      <ul className="mt-3">
                        {certs.map((c) => (
                          <li key={c.title}>
                            <a href={c.href ?? "#"} {...hover(c.href)} className="group flex items-baseline justify-between gap-4 rounded-xl px-2 py-3 transition-colors hover:bg-(--pf-card)">
                              <span className="text-[15px] text-(--pf-fg)">{c.title}</span>
                              <span className="inline-flex items-center gap-1 text-xs text-(--pf-muted)">
                                {c.issuer}
                                <ArrowUpRight className="size-3 opacity-0 transition-opacity group-hover:opacity-100" />
                              </span>
                            </a>
                          </li>
                        ))}
                      </ul>
                    </div>
                  )}

                  {tab === "open source" && (
                    <ul>
                      {openSource.map((o) => (
                        <li key={o.href + o.repo}>
                          <a href={o.href} {...hover(o.href)} className="group block rounded-xl px-2 py-3 transition-colors hover:bg-(--pf-card)">
                            <span className="flex items-center justify-between gap-4">
                              <span className="inline-flex items-center gap-2 text-[15px] text-(--pf-fg)">
                                <span className="text-(--pf-muted) [&_svg]:size-4"><GithubIcon /></span>
                                {o.repo}
                              </span>
                              <ArrowUpRight className="size-3.5 text-(--pf-muted) opacity-0 transition-opacity group-hover:opacity-100" />
                            </span>
                            <span className="mt-1 block pl-6 text-sm text-(--pf-muted)">{o.title}</span>
                          </a>
                        </li>
                      ))}
                    </ul>
                  )}
                </motion.div>
              </AnimatePresence>

              <Heatmap data={data} total={total} />

              <footer className="mt-10 flex items-center justify-between gap-3 text-xs text-(--pf-muted)">
                <span>© 2026 {name.toLowerCase()}</span>
                <a href={updatedHref} {...hover(updatedHref)} className="transition-colors hover:text-(--pf-fg)">
                  updated {updated}
                </a>
              </footer>
            </div>
          </motion.div>
        </div>
      </div>
    </div>
  )
}