Paper Shredder
NewInstallation
npx shadcn@latest add https://uibrik.com/r/paper-shredder.jsonInstall the packages
npm install @tabler/icons-react motion threeAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/paper-shredder/paper-shredder.tsx"use client"; import { useEffect, useRef, useState, type KeyboardEvent, type PointerEvent } from "react"; import { useReducedMotion } from "motion/react"; import { IconFileText } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; import { ShredScene, paintSheet } from "./strips"; // Paper shredder. Drag the document down into the slot; once its edge is in, // the motor takes it and pulls it through at a steady speed. The part that // has gone through comes out the bottom as strips of real paper, simulated // in three.js (see strips.ts): they hang and sway from the cutter, curl, // flutter down when the sheet lets go, and drape into a pile in the bin. // // The document and the shredder are DOM; the strips are a WebGL canvas // behind the body, textured with a paint of the same document, so the cut // lines up with the slot exactly. Paper travels through the body before it // comes out, so strips only appear once the sheet is pushed that far in. const STAGE_W = 320; const STAGE_H = 480; const W = 220; // document, px const H = 136; const CARD_X = (STAGE_W - W) / 2;
Adds the files to
components/uibrik/paper-shredder and installs @tabler/icons-react, motion and three. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/paper-shredder.Props
PaperShredder- files
- Type string[]
- ["Q3 numbers (final).pdf","Performance review.docx","Passwords.txt"]
- Documents to shred, one after another.
- meta
- Type string
- "Shared with 3 people"
- Small print on each document.
- stamp
- Type string
- "Confidential"
- Stamp in the corner. Empty hides it.
- strips
- Type number
- 14
- Columns the cutter makes.
- speed
- Type number
- 150
- How fast the motor pulls paper through.
- sound
- Type boolean
- true
- Motor and cutter noise while shredding.
- onShred
- Type (name: string) => void
- –
- Called once a document has gone through.
- className
- Type string
- –
- Classes for the stage.