color-picker-demo
cult-ui/color-picker-demoUnverifiedComponent
cult/ui publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/nolly-studio/cult-ui/HEAD/apps/www/color-picker-demo.jsonSource
1"use client"23import React, { useCallback, useState } from "react"4import { Check, Copy, Lock, LockOpen, Palette, RefreshCw } from "lucide-react"5import { motion } from "motion/react"6import { Poline, positionFunctions } from "poline"78import { Button } from "@/components/ui/button"9import { Card, CardContent } from "@/components/ui/card"10import {11 Tooltip,12 TooltipContent,13 TooltipProvider,14 TooltipTrigger,15} from "@/components/ui/tooltip"1617import ColorPicker from "../ui/color-picker"1819type ColorScheme = {20 [key: string]: string21}2223export default function ColorPickerDemo() {24 const [colorScheme, setColorScheme] = useState<ColorScheme>({25 background: "0 0% 100%",26 foreground: "240 10% 3.9%",27 card: "0 0% 100%",28 "card-foreground": "240 10% 3.9%",29 popover: "0 0% 100%",30 "popover-foreground": "240 10% 3.9%",31 primary: "240 5.9% 10%",32 "primary-foreground": "0 0% 98%",33 secondary: "240 4.8% 95.9%",34 "secondary-foreground": "240 5.9% 10%",35 muted: "240 4.8% 95.9%",36 "muted-foreground": "240 3.8% 46.1%",37 accent: "240 4.8% 95.9%",38 "accent-foreground": "240 5.9% 10%",39 destructive: "0 84.2% 60.2%",40 "destructive-foreground": "0 0% 98%",41 border: "240 5.9% 90%",42 input: "240 5.9% 90%",43 ring: "240 5.9% 10%",44 })45 const [lockedColor, setLockedColor] = useState<string | null>(null)46 const [copied, setCopied] = useState(false)4748 const generateHarmoniousColors = useCallback(() => {49 let anchorColors: [number, number, number][] = []5051 if (lockedColor) {52 const [h, s, l] = colorScheme[lockedColor].split(" ").map(parseFloat)53 anchorColors.push([h, s / 100, l / 100])54 }5556 while (anchorColors.length < 3) {57 anchorColors.push([Math.random() * 360, 0.7, 0.5])58 }5960 const poline = new Poline({61 numPoints: 20,62 anchorColors,63 positionFunctionX: positionFunctions.sinusoidalPosition,64 positionFunctionY: positionFunctions.quadraticPosition,65 positionFunctionZ: positionFunctions.linearPosition,66 })6768 const newColorScheme = { ...colorScheme }69 const colors = poline.colorsCSS7071 Object.keys(newColorScheme).forEach((key, index) => {72 if (key !== lockedColor) {73 const color = colors[index % colors.length]74 const [h, s, l] = color.match(/\d+(\.\d+)?/g)?.map(Number) || [0, 0, 0]7576 let adjustedLightness = l77 if (key.includes("foreground")) {78 adjustedLightness = Math.min(l - 30, 20)79// … truncated
What it pulls in
Other registry items
Files it writes
More from cult/ui
All 157 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-instructionsai-instructions | cult/ui | Components | Unverified | 2 deps | |
| ai-instructions-demoai-instructions-demo | cult/ui | Components | Unverified | no deps | |
| animated-numberanimated-number | cult/ui | Components | Unverified | 1 dep | |
| animated-number-demoanimated-number-demo | cult/ui | Components | Unverified | no deps | |
| bg-animate-buttonbg-animate-button | cult/ui | Components | Unverified | no deps | |
| bg-animate-button-demobg-animate-button-demo | cult/ui | Components | Unverified | no deps | |
| bg-animated-fractal-dot-gridbg-animated-fractal-dot-grid | cult/ui | Components | Unverified | 1 dep | |
| bg-animated-fractal-dot-grid-demobg-animated-fractal-dot-grid-demo | cult/ui | Components | Unverified | no deps |
