From c55d9d2832a46d9dc265fec36936b1313f5af6f6 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 11 Feb 2024 20:44:17 -0700 Subject: birthdays --- src/components/person.tsx | 105 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/components/person.tsx (limited to 'src/components/person.tsx') diff --git a/src/components/person.tsx b/src/components/person.tsx new file mode 100644 index 0000000..35aa475 --- /dev/null +++ b/src/components/person.tsx @@ -0,0 +1,105 @@ +import { Layout, Node, NodeProps, SVG, Txt } from "@motion-canvas/2d"; +import { theme } from "../theme"; +import { all, createRef, waitFor } from "@motion-canvas/core"; + +export const PEOPLE: PersonI[] = [ + { + name: "Alan Turing", + birthday: new Date("06/23/1912"), + color: theme.green.hex, + }, + { + name: "Grace Hopper", + birthday: new Date("12/09/1906"), + color: theme.flamingo.hex, + }, + { + name: "Edsger Dijkstra", + birthday: new Date("07/11/1930"), + color: theme.red.hex, + }, + { + name: "Alonzo Church", + birthday: new Date("06/14/1912"), + color: theme.sapphire.hex, + }, + { + name: "Margaret Hamilton", + birthday: new Date("12/09/1902"), + color: theme.yellow.hex, + }, +]; + +const profileSrc = (color: string) => ` + + + + + + + + + + +`; + +export interface PersonI { + name: string; + birthday: Date; + color: string; +} + +export interface PersonProps extends NodeProps { + person: PersonI; + + width?: number; + height?: number; +} + +export class Person extends Node { + private readonly svg = createRef(); + + public constructor(props?: PersonProps) { + super({ ...props }); + + this.add( + + + + {props.person.name} + + , + ); + } + + public *emit(text: string, duration: number, cleanUp = true) { + const ref = createRef(); + + this.insert( + + {text} + , + 0, + ); + + yield* all(ref().fontSize(40, duration), ref().opacity(1, duration)); + if (cleanUp) { + yield* waitFor(duration); + yield* all(ref().fontSize(0, duration), ref().opacity(0, duration)); + yield ref().remove(); + } + } +} -- cgit v1.2.3-70-g09d2