Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): add paper state layout and hand-drawn doodles

Richie McIlroy7fdd9addf600
diff --git a/apps/web/components/paper-state/PaperState.tsx b/apps/web/components/paper-state/PaperState.tsx
new file mode 100644
index 000000000..f62256c8e
--- /dev/null
+++ b/apps/web/components/paper-state/PaperState.tsx
@@ -0,0 +1,70 @@
+import type { ReactNode } from "react";
+import styles from "./paper-state.module.css";
+
+export const paperStateStyles = styles;
+
+export function PaperState({
+ doodle,
+ title,
+ lede,
+ children,
+ footnote,
+ homeHref = "/",
+}: {
+ doodle: ReactNode;
+ title: ReactNode;
+ lede?: ReactNode;
+ children?: ReactNode;
+ footnote?: ReactNode;
+ homeHref?: string;
+}) {
+ return (
+ <div className={styles.page}>
+ <header className={styles.brand}>
+ <a href={homeHref} className={styles.brandLink} aria-label="Cap">
+ <CapWordmark />
+ </a>
+ </header>
+ <main className={styles.stage}>
+ {doodle}
+ <h1 className={styles.title}>{title}</h1>
+ {lede && <p className={styles.lede}>{lede}</p>}
+ {children}
+ </main>
+ {footnote && <p className={styles.footnote}>{footnote}</p>}
+ </div>
+ );
+}
+
+export function PaperActions({ children }: { children: ReactNode }) {
+ return <div className={styles.actions}>{children}</div>;
+}
+
+function CapWordmark() {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ viewBox="0 0 103 40"
+ height="28"
+ aria-hidden="true"
+ >
+ <path
+ fill="#4785FF"
+ d="M20 36c8.837 0 16-7.163 16-16S28.837 4 20 4 4 11.164 4 20s7.164 16 16 16"
+ />
+ <path
+ fill="#ADC9FF"
+ d="M20 33c7.18 0 13-5.82 13-13S27.18 7 20 7 7 12.82 7 20s5.82 13 13 13"
+ />
+ <path
+ fill="#fff"
+ d="M20 30c5.523 0 10-4.477 10-10s-4.477-10-10-10-10 4.477-10 10 4.477 10 10 10"
+ />
+ <path
+ fill="currentColor"
+ d="M58.416 30.448c-5.404 0-9.212-3.864-9.212-10.36 0-6.384 3.668-10.416 9.268-10.416 5.068 0 7.784 2.66 8.624 7.168l-3.808.196c-.476-2.604-2.072-4.2-4.816-4.2-3.388 0-5.488 2.828-5.488 7.252 0 4.48 2.156 7.196 5.46 7.196 2.94 0 4.508-1.708 4.956-4.564l3.808.196c-.784 4.676-3.752 7.532-8.792 7.532m16.23-.112c-3.137 0-5.209-1.484-5.209-4.088 0-2.576 1.596-3.948 4.872-4.592l4.956-.98c0-2.1-.98-3.192-2.856-3.192-1.764 0-2.716.812-3.052 2.324l-3.668-.168c.588-3.136 2.996-4.928 6.72-4.928 4.256 0 6.44 2.24 6.44 6.216v5.432c0 .812.28 1.036.84 1.036h.476V30c-.224.056-.812.112-1.288.112-1.624 0-2.828-.588-3.136-2.436-.728 1.596-2.632 2.66-5.096 2.66m.727-2.604c2.38 0 3.892-1.512 3.892-3.78v-.84l-3.864.784c-1.596.308-2.24.98-2.24 2.016 0 1.176.784 1.82 2.212 1.82M86.874 34.2V15.048h3.444l.056 2.212c.868-1.652 2.52-2.548 4.48-2.548 4.256 0 6.356 3.5 6.356 7.812s-2.128 7.812-6.384 7.812c-1.904 0-3.556-.924-4.368-2.38V34.2zm7.112-6.776c2.184 0 3.5-1.82 3.5-4.9s-1.316-4.9-3.5-4.9-3.528 1.652-3.528 4.9 1.316 4.9 3.528 4.9"
+ />
+ </svg>
+ );
+}
diff --git a/apps/web/components/paper-state/doodles.tsx b/apps/web/components/paper-state/doodles.tsx
new file mode 100644
index 000000000..4fde8b3e6
--- /dev/null
+++ b/apps/web/components/paper-state/doodles.tsx
@@ -0,0 +1,274 @@
+import type { CSSProperties, ReactNode } from "react";
+import styles from "./paper-state.module.css";
+
+const BOIL_ID = "paper-state-boil";
+
+const timing = (delay: number, duration?: number) =>
+ ({
+ "--d": `${delay}s`,
+ ...(duration === undefined ? {} : { "--t": `${duration}s` }),
+ }) as CSSProperties;
+
+const cx = (...names: (string | undefined)[]) =>
+ names.filter(Boolean).join(" ");
+
+function DoodleFrame({ children }: { children: ReactNode }) {
+ return (
+ <svg className={styles.doodle} viewBox="0 0 120 104" aria-hidden="true">
+ <defs>
+ <filter id={BOIL_ID} x="-15%" y="-15%" width="130%" height="130%">
+ <feTurbulence
+ type="fractalNoise"
+ baseFrequency="0.05"
+ numOctaves="2"
+ seed="1"
+ result="noise"
+ >
+ <animate
+ attributeName="seed"
+ values="1;3;5;7"
+ dur="0.6s"
+ repeatCount="indefinite"
+ calcMode="discrete"
+ />
+ </feTurbulence>
+ <feDisplacementMap
+ in="SourceGraphic"
+ in2="noise"
+ scale="3"
+ xChannelSelector="R"
+ yChannelSelector="G"
+ />
+ </filter>
+ </defs>
+ <g className={styles.boil} filter={`url(#${BOIL_ID})`}>
+ {children}
+ </g>
+ </svg>
+ );
+}
+
+function Sparks({
+ delay,
+ paths,
+}: {
+ delay: number;
+ paths: [string, string, string];
+}) {
+ return (
+ <>
+ {paths.map((d, i) => (
+ <path
+ key={d}
+ className={styles.spark}
+ style={timing(delay + i * 0.15)}
+ d={d}
+ />
+ ))}
+ </>
+ );
+}
+
+export function LockDoodle() {
+ return (
+ <DoodleFrame>
+ <g className={styles.rattle}>
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.75, 0.5)}
+ pathLength={1}
+ d="M 42 50 L 42 36 Q 42 17 60 17 Q 78 17 78 36 L 78 50"
+ />
+ </g>
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.15, 0.8)}
+ pathLength={1}
+ d="M 34 50 L 86 50 Q 94 50 94 58 L 94 86 Q 94 94 86 94 L 34 94 Q 26 94 26 86 L 26 58 Q 26 50 34 50 Z"
+ />
+ <circle
+ className={cx(styles.accentFill, styles.pop)}
+ style={timing(1.1)}
+ cx="60"
+ cy="68"
+ r="5.5"
+ />
+ <path
+ className={cx(styles.accentStroke, styles.draw)}
+ style={timing(1.25, 0.25)}
+ pathLength={1}
+ d="M 60 72 L 60 81"
+ />
+ <Sparks
+ delay={1.5}
+ paths={["M 92 22 L 99 15", "M 97 33 L 106 31", "M 21 25 L 14 19"]}
+ />
+ </DoodleFrame>
+ );
+}
+
+export function KeyDoodle() {
+ return (
+ <DoodleFrame>
+ <g className={styles.wiggle}>
+ <circle
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.15, 0.6)}
+ pathLength={1}
+ cx="36"
+ cy="52"
+ r="17"
+ />
+ <circle
+ className={cx(styles.accentFill, styles.pop)}
+ style={timing(1.15)}
+ cx="36"
+ cy="52"
+ r="5.5"
+ />
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.7, 0.45)}
+ pathLength={1}
+ d="M 53 52 L 102 52"
+ />
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(1.05, 0.3)}
+ pathLength={1}
+ d="M 88 52 L 88 65 M 99 52 L 99 62"
+ />
+ </g>
+ <Sparks
+ delay={1.45}
+ paths={[
+ "M 104 28 L 104 36 M 100 32 L 108 32",
+ "M 18 24 L 12 18",
+ "M 112 70 L 106 76",
+ ]}
+ />
+ </DoodleFrame>
+ );
+}
+
+export function EnvelopeDoodle() {
+ return (
+ <DoodleFrame>
+ <g className={styles.bob}>
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.15, 0.8)}
+ pathLength={1}
+ d="M 24 30 L 84 30 Q 92 30 92 38 L 92 76 Q 92 84 84 84 L 24 84 Q 16 84 16 76 L 16 38 Q 16 30 24 30 Z"
+ />
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.75, 0.45)}
+ pathLength={1}
+ d="M 20 35 L 54 60 L 88 35"
+ />
+ </g>
+ <g className={styles.pop} style={timing(1.15)}>
+ <circle className={styles.paperFill} cx="92" cy="80" r="19" />
+ <circle className={styles.accentStroke} cx="92" cy="80" r="14" />
+ <path className={styles.accentStroke} d="M 82.5 89.5 L 101.5 70.5" />
+ </g>
+ </DoodleFrame>
+ );
+}
+
+export function SearchDoodle() {
+ return (
+ <DoodleFrame>
+ <g className={styles.sway}>
+ <circle
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.15, 0.7)}
+ pathLength={1}
+ cx="50"
+ cy="46"
+ r="27"
+ />
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={{ ...timing(0.75, 0.35), strokeWidth: 7 }}
+ pathLength={1}
+ d="M 70 66 L 96 92"
+ />
+ <path
+ className={cx(styles.accentStroke, styles.draw)}
+ style={timing(1.05, 0.45)}
+ pathLength={1}
+ d="M 42 39 Q 42 30 50.5 30 Q 59 30 59 38 Q 59 44 51 47 L 51 51"
+ />
+ <circle
+ className={cx(styles.accentFill, styles.pop)}
+ style={timing(1.45)}
+ cx="51"
+ cy="59"
+ r="3"
+ />
+ </g>
+ </DoodleFrame>
+ );
+}
+
+export function PasswordDoodle() {
+ return (
+ <DoodleFrame>
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.15, 0.8)}
+ pathLength={1}
+ d="M 22 42 L 98 42 Q 108 42 108 52 L 108 72 Q 108 82 98 82 L 22 82 Q 12 82 12 72 L 12 52 Q 12 42 22 42 Z"
+ />
+ {[30, 45, 60, 75].map((x, i) => (
+ <circle
+ key={x}
+ className={cx(styles.inkFill, styles.typeDot)}
+ style={timing(1 + i * 0.22)}
+ cx={x}
+ cy="62"
+ r="4.5"
+ />
+ ))}
+ <path
+ className={cx(styles.accentStroke, styles.caret)}
+ d="M 90 53 L 90 71"
+ />
+ <Sparks
+ delay={1.2}
+ paths={[
+ "M 60 14 L 60 26 M 54.8 17 L 65.2 23 M 54.8 23 L 65.2 17",
+ "M 22 22 L 17 16",
+ "M 98 22 L 103 16",
+ ]}
+ />
+ </DoodleFrame>
+ );
+}
+
+export function RecordingDoodle() {
+ return (
+ <DoodleFrame>
+ <g className={styles.bob}>
+ <path
+ className={cx(styles.stroke, styles.draw)}
+ style={timing(0.15, 0.8)}
+ pathLength={1}
+ d="M 24 22 L 96 22 Q 104 22 104 30 L 104 70 Q 104 78 96 78 L 24 78 Q 16 78 16 70 L 16 30 Q 16 22 24 22 Z"
+ />
+ <path
+ className={cx(styles.accentStroke, styles.draw)}
+ style={timing(0.85, 0.45)}
+ pathLength={1}
+ d="M 52 38 L 72 50 L 52 62 Z"
+ />
+ </g>
+ <path
+ className={cx(styles.softStroke, styles.march)}
+ d="M 16 96 q 6 -6 12 0 t 12 0 t 12 0 t 12 0 t 12 0 t 12 0 t 12 0"
+ />
+ </DoodleFrame>
+ );
+}
diff --git a/apps/web/components/paper-state/paper-state.module.css b/apps/web/components/paper-state/paper-state.module.css
new file mode 100644
index 000000000..9a01d605f
--- /dev/null
+++ b/apps/web/components/paper-state/paper-state.module.css
@@ -0,0 +1,516 @@
+.page {
+ --paper: #fbfaf7;
+ --ink: #20242c;
+ --ink-soft: #8b8f98;
+ --accent: #4785ff;
+ --track: #dcdcd4;
+ --error: #e5484d;
+
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ min-height: 100dvh;
+ background: var(--paper);
+ color: var(--ink);
+ color-scheme: light;
+ -webkit-font-smoothing: antialiased;
+}
+
+.brand {
+ display: flex;
+ justify-content: center;
+ padding: 32px 24px 0;
+ animation: fade-up 0.5s ease both;
+}
+
+.brandLink {
+ display: inline-flex;
+ border-radius: 8px;
+ line-height: 0;
+ color: var(--ink);
+}
+
+.brandLink:focus-visible {
+ outline: 2px solid var(--accent);
+ outline-offset: 4px;
+}
+
+.stage {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 40px 24px 56px;
+ text-align: center;
+}
+
+.doodle {
+ width: 148px;
+ height: auto;
+ overflow: visible;
+ animation: fade-up 0.5s ease 0.05s both;
+}
+
+.title {
+ margin: 28px 0 0;
+ max-width: 520px;
+ font-size: 28px;
+ font-weight: 500;
+ line-height: 1.15;
+ letter-spacing: -0.015em;
+ text-wrap: balance;
+ animation: fade-up 0.5s ease 0.1s both;
+}
+
+.lede {
+ margin: 10px 0 0;
+ max-width: 420px;
+ font-size: 15.5px;
+ line-height: 1.55;
+ color: var(--ink-soft);
+ text-wrap: pretty;
+ animation: fade-up 0.5s ease 0.15s both;
+}
+
+.lede strong {
+ font-weight: 500;
+ color: var(--ink);
+}
+
+.actions {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: center;
+ gap: 10px;
+ margin-top: 28px;
+ animation: fade-up 0.5s ease 0.22s both;
+}
+
+.cta {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ min-height: 44px;
+ padding: 0 24px;
+ border: 1.5px solid var(--ink);
+ border-radius: 999px;
+ background: var(--ink);
+ color: var(--paper);
+ font: inherit;
+ font-size: 14.5px;
+ font-weight: 500;
+ text-decoration: none;
+ cursor: pointer;
+ transition:
+ background 0.18s ease,
+ border-color 0.18s ease,
+ color 0.18s ease,
+ opacity 0.18s ease,
+ transform 0.18s ease;
+}
+
+.cta:hover:not(:disabled) {
+ background: #353a45;
+ border-color: #353a45;
+}
+
+.cta:active:not(:disabled) {
+ transform: translateY(1px);
+}
+
+.cta:disabled {
+ cursor: not-allowed;
+ opacity: 0.45;
+}
+
+.cta:focus-visible,
+.ghost:focus-visible {
+ outline: 2px solid var(--accent);
+ outline-offset: 3px;
+}
+
+.ghost {
+ background: transparent;
+ border-color: var(--track);
+ color: var(--ink);
+}
+
+.ghost:hover:not(:disabled) {
+ background: rgba(32, 36, 44, 0.04);
+ border-color: var(--ink-soft);
+}
+
+.form {
+ display: grid;
+ gap: 10px;
+ width: min(360px, 100%);
+ margin-top: 28px;
+ animation: fade-up 0.5s ease 0.22s both;
+}
+
+.input {
+ width: 100%;
+ min-height: 46px;
+ padding: 0 18px;
+ border: 1.5px solid var(--track);
+ border-radius: 999px;
+ background: #ffffff;
+ color: var(--ink);
+ font: inherit;
+ font-size: 15px;
+ text-align: center;
+ transition: border-color 0.15s ease;
+}
+
+.input::placeholder {
+ color: #b4b7bd;
+}
+
+.input:focus {
+ outline: none;
+ border-color: var(--ink);
+}
+
+.input[aria-invalid="true"] {
+ border-color: var(--error);
+}
+
+.error {
+ margin: 2px 0 0;
+ font-size: 13.5px;
+ color: var(--error);
+ animation: fade-up 0.3s ease both;
+}
+
+.footnote {
+ margin: 0;
+ padding: 0 24px 32px;
+ text-align: center;
+ font-size: 13px;
+ line-height: 1.5;
+ color: var(--ink-soft);
+ animation: fade-up 0.5s ease 0.3s both;
+}
+
+.footnote a,
+.lede a {
+ color: var(--ink);
+ text-decoration: underline;
+ text-decoration-color: var(--track);
+ text-decoration-thickness: 1.5px;
+ text-underline-offset: 3px;
+ transition: text-decoration-color 0.15s ease;
+}
+
+.footnote a:hover,
+.lede a:hover {
+ text-decoration-color: var(--ink);
+}
+
+/* Doodle strokes */
+
+.stroke {
+ fill: none;
+ stroke: var(--ink);
+ stroke-width: 4.5;
+ stroke-linecap: round;
+ stroke-linejoin: round;
+}
+
+.accentStroke {
+ fill: none;
+ stroke: var(--accent);
+ stroke-width: 4.5;
+ stroke-linecap: round;
+ stroke-linejoin: round;
+}
+
+.softStroke {
+ fill: none;
+ stroke: var(--ink-soft);
+ stroke-width: 2.5;
+ stroke-linecap: round;
+}
+
+.accentFill {
+ fill: var(--accent);
+}
+
+.inkFill {
+ fill: var(--ink);
+}
+
+.paperFill {
+ fill: var(--paper);
+}
+
+.draw {
+ stroke-dasharray: 1;
+ stroke-dashoffset: 1;
+ animation-name: draw;
+ animation-duration: var(--t, 0.8s);
+ animation-timing-function: ease;
+ animation-delay: var(--d, 0s);
+ animation-fill-mode: forwards;
+}
+
+.appear {
+ opacity: 0;
+ animation-name: fade-in;
+ animation-duration: 0.3s;
+ animation-timing-function: ease;
+ animation-delay: var(--d, 0s);
+ animation-fill-mode: forwards;
+}
+
+.pop {
+ opacity: 0;
+ transform-box: fill-box;
+ transform-origin: center;
+ animation-name: pop;
+ animation-duration: 0.5s;
+ animation-timing-function: ease;
+ animation-delay: var(--d, 0s);
+ animation-fill-mode: forwards;
+}
+
+.spark {
+ fill: none;
+ stroke: var(--accent);
+ stroke-width: 3.5;
+ stroke-linecap: round;
+ opacity: 0;
+ transform-box: fill-box;
+ transform-origin: center;
+ animation-name: pop;
+ animation-duration: 0.5s;
+ animation-timing-function: ease;
+ animation-delay: var(--d, 0s);
+ animation-fill-mode: forwards;
+}
+
+.march {
+ stroke-dasharray: 2 4.2;
+ animation: march 1.2s linear infinite;
+}
+
+.bob {
+ animation: bob 3s ease-in-out 1.4s infinite;
+}
+
+.rattle {
+ transform-box: view-box;
+ transform-origin: 60px 50px;
+ animation: rattle 4.2s ease-in-out 1.5s infinite;
+}
+
+.sway {
+ transform-box: view-box;
+ transform-origin: 50px 46px;
+ animation: sway 3.6s ease-in-out 1.4s infinite;
+}
+
+.wiggle {
+ transform-box: view-box;
+ transform-origin: 36px 52px;
+ animation: wiggle 3.4s ease-in-out 1.4s infinite;
+}
+
+.typeDot {
+ opacity: 0;
+ transform-box: fill-box;
+ transform-origin: center;
+ animation-name: type-dot;
+ animation-duration: 3.2s;
+ animation-timing-function: ease;
+ animation-delay: var(--d, 0s);
+ animation-iteration-count: infinite;
+}
+
+.caret {
+ opacity: 0;
+ animation: blink 1s steps(1) 1s infinite;
+}
+
+.pulse {
+ transform-box: fill-box;
+ transform-origin: center;
+ animation: pulse 1.6s ease-in-out 1.2s infinite;
+}
+
+@keyframes draw {
+ to {
+ stroke-dashoffset: 0;
+ }
+}
+
+@keyframes fade-in {
+ to {
+ opacity: 1;
+ }
+}
+
+@keyframes fade-up {
+ from {
+ opacity: 0;
+ transform: translateY(10px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+@keyframes pop {
+ from {
+ opacity: 0;
+ transform: scale(0.2);
+ }
+ 60% {
+ opacity: 1;
+ transform: scale(1.15);
+ }
+ to {
+ opacity: 1;
+ transform: scale(1);
+ }
+}
+
+@keyframes march {
+ to {
+ stroke-dashoffset: -6.2;
+ }
+}
+
+@keyframes bob {
+ 0%,
+ 100% {
+ transform: translateY(0);
+ }
+ 50% {
+ transform: translateY(-4px);
+ }
+}
+
+@keyframes rattle {
+ 0%,
+ 24%,
+ 100% {
+ transform: translateY(0) rotate(0);
+ }
+ 6% {
+ transform: translateY(-6px) rotate(-3deg);
+ }
+ 12% {
+ transform: translateY(0) rotate(0);
+ }
+ 17% {
+ transform: translateY(-3px) rotate(2deg);
+ }
+}
+
+@keyframes sway {
+ 0%,
+ 100% {
+ transform: translate(0, 0) rotate(0);
+ }
+ 30% {
+ transform: translate(-4px, 2px) rotate(-6deg);
+ }
+ 70% {
+ transform: translate(4px, -1px) rotate(5deg);
+ }
+}
+
+@keyframes wiggle {
+ 0%,
+ 40%,
+ 100% {
+ transform: rotate(0);
+ }
+ 10% {
+ transform: rotate(-8deg);
+ }
+ 22% {
+ transform: rotate(6deg);
+ }
+ 32% {
+ transform: rotate(-2deg);
+ }
+}
+
+@keyframes type-dot {
+ 0%,
+ 8% {
+ opacity: 0;
+ transform: scale(0.3);
+ }
+ 14%,
+ 80% {
+ opacity: 1;
+ transform: scale(1);
+ }
+ 90%,
+ 100% {
+ opacity: 0;
+ transform: scale(1);
+ }
+}
+
+@keyframes blink {
+ 0% {
+ opacity: 1;
+ }
+ 50% {
+ opacity: 0;
+ }
+}
+
+@keyframes pulse {
+ 0%,
+ 100% {
+ transform: scale(1);
+ }
+ 50% {
+ transform: scale(1.08);
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .boil {
+ filter: none;
+ }
+
+ .brand,
+ .doodle,
+ .title,
+ .lede,
+ .actions,
+ .form,
+ .footnote,
+ .draw,
+ .appear,
+ .pop,
+ .spark {
+ animation-duration: 0.01ms;
+ animation-delay: 0s;
+ }
+
+ .march,
+ .bob,
+ .rattle,
+ .sway,
+ .wiggle,
+ .caret,
+ .pulse {
+ animation: none;
+ }
+
+ .typeDot {
+ animation: none;
+ opacity: 1;
+ }
+}