Skip to content

TimZhangTHS/Scrapbook

Repository files navigation

My Scrapbook — Digital Portfolio

A personalized digital scrapbook/portfolio inspired by sharyap.com, built with Next.js, React, Tailwind CSS, and Howler.js. Use it to practice design, animations, and web development while learning how each part works.

Quick start

npm install
npm run dev

Open http://localhost:3000.

How each part works

1. Next.js (App Router)

  • src/app/layout.tsx — Root layout. Wraps every page; fonts and global providers (theme, sound) live here.
  • src/app/page.tsx — Home page. A Client Component ("use client") because it uses useState for the open modal.
  • src/app/globals.css — Global styles and Tailwind. CSS variables here drive light/dark theme colors.

Learning: In the App Router, layout.tsx is shared across routes and doesn’t re-mount on navigation. Use it for headers, providers, and fonts.

2. React

  • State: page.tsx holds openSection (which modal is open) and toastDismissed. Child components receive callbacks like onOpenSection and onDismiss.
  • Context: ThemeProvider and SoundProvider use createContext + useContext so any component can read theme/sound and trigger toggles without passing props through every level.

Learning: Lift state to the lowest common parent that needs it. Use Context for “global” settings (theme, sound).

3. Tailwind CSS

  • tailwind.config.ts — Custom colors (scrapbook.cream, scrapbook.ink, etc.), fonts, and keyframes (fade-in, slide-up, wiggle). darkMode: "class" means dark styles apply when <html> has the class dark.
  • Utility classes: Components use Tailwind for layout (flex, gap), spacing (p-4, mt-2), and responsive design (md:text-5xl). Dark variants use the dark: prefix.

Learning: Put design tokens (colors, animations) in tailwind.config.ts. Use dark: for dark-mode styles.

4. Howler.js

  • SoundProvider.tsx — Wraps the app and exposes sfxEnabled, toggleSfx, and playClick(). When SFX is on, playClick() lazy-loads Howler and plays a click sound.
  • Adding sounds: Put an audio file (e.g. click.mp3) in public/sounds/. The provider already points to /sounds/click.mp3. If the file is missing, the app still works (errors are handled).

Learning: Howler’s new Howl({ src: ['/sounds/click.mp3'], volume: 0.3 }) and .play() are enough for simple SFX. Lazy-load with import('howler') so the library only loads when needed.

5. Components (high level)

File Role
Header.tsx Top bar with dark mode and SFX toggles; uses useTheme() and useSound().
Hero.tsx Intro text with staggered CSS animations (animate-fade-in, animate-slide-up).
SectionButtons.tsx Buttons for about, links, work, faq, contact, downloads; toggles modal.
Modal.tsx Overlay + panel; Escape and backdrop click close it; locks body scroll when open.
sections/*.tsx Content for each modal. Replace with your own copy and links.
Footer.tsx Bottom bar.
DesktopToast.tsx “Best on desktop” notice; dismissible once.
ScrapbookSticker.tsx Small hover animation (Tailwind animate-wiggle) for practice.

6. Animations

  • CSS (Tailwind): Keyframes in tailwind.config.tsanimation: { "fade-in": "fade-in 0.4s ease-out forwards" } → use animate-fade-in in JSX. Delay with style={{ animationDelay: '100ms' }}.
  • Hover: hover:scale-105, hover:animate-wiggle on buttons and the sticker.

Learning: Start with Tailwind keyframes and utility classes. Later you can add Framer Motion or CSS @keyframes in globals.css for more complex animations.

Customize

  • Copy: Edit Hero.tsx and the section components in src/components/sections/ with your name, bio, links, and projects.
  • Colors/fonts: Change scrapbook.* colors and font variables in tailwind.config.ts and layout.tsx.
  • Sounds: Add public/sounds/click.mp3 (and others) and optionally add more Howl instances in SoundProvider.tsx for different actions.

Scripts

  • npm run dev — Dev server with hot reload.
  • npm run build — Production build.
  • npm run start — Run production build locally.
  • npm run lint — Run ESLint.

Enjoy building and learning.

About

My website for fun

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors