Map Music Disc
terrae/music-discFreeComponent
Rotating music disc with floating notes animation.
Install it
npx shadcn@latest add https://www.terrae.dev/music-disc.jsonSource
1"use client"23import { useEffect, useRef, useState } from "react"4import { createPortal } from "react-dom"5import { mapgl } from "./map-library"6import { cn } from "@/lib/utils"7import { useMap } from "./hooks"8import type { MapCoordinates } from "./types"910type MusicNote = {11 id: number12 offsetX: number13 delay: number14 duration: number15 type: "note" | "eighth" | "double"16}1718type MapMusicDiscProps = {19 coordinates: MapCoordinates20 size?: number21 image?: string22 spinning?: boolean23 spinDuration?: number24 showNotes?: boolean25 noteColor?: string26 discColor?: string27 centerColor?: string28 pitchAlignment?: "map" | "viewport" | "auto"29 className?: string30}3132type DiscContentProps = {33 size: number34 image?: string35 spinning: boolean36 spinDuration: number37 discColor: string38 centerColor: string39 className?: string40}4142type NotesContentProps = {43 size: number44 noteColor: string45 notes: MusicNote[]46}4748type MusicDiscContentProps = {49 size: number50 image?: string51 spinning: boolean52 spinDuration: number53 showNotes: boolean54 noteColor: string55 discColor: string56 centerColor: string57 notes: MusicNote[]58 className?: string59}6061type MusicNoteIconProps = {62 note: MusicNote63 color: string64}6566const DEFAULT_SIZE = 6467const DEFAULT_SPINNING = true68const DEFAULT_SPIN_DURATION = 400069const DEFAULT_SHOW_NOTES = true70const DEFAULT_NOTE_COLOR = "#a855f7"71const DEFAULT_DISC_COLOR = "#0a0a0a"72const DEFAULT_CENTER_COLOR = "#171717"73const DEFAULT_PITCH_ALIGNMENT = "viewport" as const7475const NOTE_SYMBOLS = {76 note: "♪",77 eighth: "♫",78 double: "♬",79} as const8081export const MapMusicDisc = ({82 coordinates,83 size = DEFAULT_SIZE,84 image,85 spinning = DEFAULT_SPINNING,86 spinDuration = DEFAULT_SPIN_DURATION,87 showNotes = DEFAULT_SHOW_NOTES,88 noteColor = DEFAULT_NOTE_COLOR,89 discColor = DEFAULT_DISC_COLOR,90 centerColor = DEFAULT_CENTER_COLOR,91 pitchAlignment = DEFAULT_PITCH_ALIGNMENT,92 className,93}: MapMusicDiscProps) => {94 const { map, isLoaded } = useMap()95 const discMarkerRef = useRef<mapboxgl.Marker | null>(null)96 const notesMarkerRef = useRef<mapboxgl.Marker | null>(null)97 const discContainerRef = useRef<HTMLDivElement | null>(null)98 const notesContainerRef = useRef<HTMLDivElement | null>(null)99 const [isMounted, setIsMounted] = useState(false)100101 const needsSeparateMarkers = showNotes && pitchAlignment === "map"102103 useEffect(() => {104 if (!map || !isLoaded) {105 return106 }107108// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from terrae
All 40 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Map Animated Circleanimated-circle | terrae | Components | Free | 1 dep | |
| Map Animated Footprintanimated-footprint | terrae | Components | Free | 2 deps | |
| Map Animated Polygonanimated-polygon | terrae | Components | Free | 1 dep | |
| Map Animated Pulseanimated-pulse | terrae | Components | Free | 1 dep | |
| Map Arc Animatedarc-animated | terrae | Components | Free | 1 dep | |
| Map Blur Areablur-area | terrae | Components | Free | 1 dep | |
| Map Camera Followcamera-follow | terrae | Components | Free | 1 dep | |
| Map Choroplethchoropleth | terrae | Components | Free | 1 dep |
