|
| 1 | +'use client' |
| 2 | + |
| 3 | +import Link from 'next/link' |
| 4 | +import { type MotionValue, motion, useMotionTemplate, useMotionValue } from 'framer-motion' |
| 5 | + |
| 6 | +import { GridPattern } from '@/components/GridPattern' |
| 7 | +import { Heading } from '@/components/Heading' |
| 8 | +import { ChatBubbleIcon } from '@/components/icons/ChatBubbleIcon' |
| 9 | +import { CalendarIcon } from '@/components/icons/CalendarIcon' |
| 10 | +import { BoltIcon } from './icons/BoltIcon' |
| 11 | +import { TagIcon } from './icons/TagIcon' |
| 12 | + |
| 13 | +interface Concept { |
| 14 | + href: string |
| 15 | + name: string |
| 16 | + description: string |
| 17 | + icon: React.ComponentType<{ className?: string }> |
| 18 | + pattern: Omit<React.ComponentPropsWithoutRef<typeof GridPattern>, 'width' | 'height' | 'x'> |
| 19 | +} |
| 20 | + |
| 21 | +const concepts: Array<Concept> = [ |
| 22 | + { |
| 23 | + href: '/v5/core/effects', |
| 24 | + name: 'Effects', |
| 25 | + description: |
| 26 | + 'Discover the powerful actions system that makes Firebot versatile. Effects are the cool stuff that happens in response to commands, events, and more.', |
| 27 | + icon: BoltIcon, |
| 28 | + pattern: { |
| 29 | + y: 16, |
| 30 | + squares: [ |
| 31 | + [0, 1], |
| 32 | + [1, 3], |
| 33 | + ], |
| 34 | + }, |
| 35 | + }, |
| 36 | + { |
| 37 | + href: '/v5/core/commands', |
| 38 | + name: 'Commands', |
| 39 | + description: |
| 40 | + 'Create custom chat commands that respond to viewer messages. Commands are a great way to engage with your audience and add interactivity.', |
| 41 | + icon: ChatBubbleIcon, |
| 42 | + pattern: { |
| 43 | + y: -6, |
| 44 | + squares: [ |
| 45 | + [-1, 2], |
| 46 | + [1, 3], |
| 47 | + ], |
| 48 | + }, |
| 49 | + }, |
| 50 | + { |
| 51 | + href: '/v5/core/events', |
| 52 | + name: 'Events', |
| 53 | + description: |
| 54 | + 'Automatic triggers that run effects in response to stream activities like follows, subs, raids, and more. Make your stream dynamic and interactive.', |
| 55 | + icon: CalendarIcon, |
| 56 | + pattern: { |
| 57 | + y: 32, |
| 58 | + squares: [ |
| 59 | + [0, 2], |
| 60 | + [1, 4], |
| 61 | + ], |
| 62 | + }, |
| 63 | + }, |
| 64 | + { |
| 65 | + href: '/variables', |
| 66 | + name: 'Variables', |
| 67 | + description: |
| 68 | + 'Use dynamic placeholders to insert real-time data into your effects. Variables can display user info, custom data, and much more.', |
| 69 | + icon: TagIcon, |
| 70 | + pattern: { |
| 71 | + y: 22, |
| 72 | + squares: [[0, 1]], |
| 73 | + }, |
| 74 | + }, |
| 75 | +] |
| 76 | + |
| 77 | +function ResourceIcon({ icon: Icon }: { icon: Concept['icon'] }) { |
| 78 | + return ( |
| 79 | + <div className="flex h-7 w-7 items-center justify-center rounded-full bg-zinc-900/5 ring-1 ring-zinc-900/25 backdrop-blur-[2px] transition duration-300 group-hover:bg-white/50 group-hover:ring-zinc-900/25 dark:bg-white/7.5 dark:ring-white/15 dark:group-hover:bg-amber-300/10 dark:group-hover:ring-amber-400"> |
| 80 | + <Icon className="h-5 w-5 fill-zinc-700/10 stroke-zinc-700 transition-colors duration-300 group-hover:stroke-zinc-900 dark:fill-white/10 dark:stroke-zinc-400 dark:group-hover:fill-amber-300/10 dark:group-hover:stroke-amber-400" /> |
| 81 | + </div> |
| 82 | + ) |
| 83 | +} |
| 84 | + |
| 85 | +function ResourcePattern({ |
| 86 | + mouseX, |
| 87 | + mouseY, |
| 88 | + ...gridProps |
| 89 | +}: Concept['pattern'] & { |
| 90 | + mouseX: MotionValue<number> |
| 91 | + mouseY: MotionValue<number> |
| 92 | +}) { |
| 93 | + let maskImage = useMotionTemplate`radial-gradient(180px at ${mouseX}px ${mouseY}px, white, transparent)` |
| 94 | + let style = { maskImage, WebkitMaskImage: maskImage } |
| 95 | + |
| 96 | + return ( |
| 97 | + <div className="pointer-events-none"> |
| 98 | + <div className="absolute inset-0 rounded-2xl transition duration-300 [mask-image:linear-gradient(white,transparent)] group-hover:opacity-50"> |
| 99 | + <GridPattern |
| 100 | + width={72} |
| 101 | + height={56} |
| 102 | + x="50%" |
| 103 | + className="absolute inset-x-0 inset-y-[-30%] h-[160%] w-full skew-y-[-18deg] fill-black/[0.02] stroke-black/5 dark:fill-white/1 dark:stroke-white/2.5" |
| 104 | + {...gridProps} |
| 105 | + /> |
| 106 | + </div> |
| 107 | + <motion.div |
| 108 | + className="absolute inset-0 rounded-2xl bg-gradient-to-r from-[#edecd7] to-[#F4FBDF] opacity-0 transition duration-300 group-hover:opacity-100 dark:from-[#2e2520] dark:to-[#343328]" |
| 109 | + style={style} |
| 110 | + /> |
| 111 | + <motion.div |
| 112 | + className="absolute inset-0 rounded-2xl opacity-0 mix-blend-overlay transition duration-300 group-hover:opacity-100" |
| 113 | + style={style} |
| 114 | + > |
| 115 | + <GridPattern |
| 116 | + width={72} |
| 117 | + height={56} |
| 118 | + x="50%" |
| 119 | + className="absolute inset-x-0 inset-y-[-30%] h-[160%] w-full skew-y-[-18deg] fill-black/50 stroke-black/70 dark:fill-white/2.5 dark:stroke-white/10" |
| 120 | + {...gridProps} |
| 121 | + /> |
| 122 | + </motion.div> |
| 123 | + </div> |
| 124 | + ) |
| 125 | +} |
| 126 | + |
| 127 | +function Concept({ resource }: { resource: Concept }) { |
| 128 | + let mouseX = useMotionValue(0) |
| 129 | + let mouseY = useMotionValue(0) |
| 130 | + |
| 131 | + function onMouseMove({ currentTarget, clientX, clientY }: React.MouseEvent<HTMLDivElement>) { |
| 132 | + let { left, top } = currentTarget.getBoundingClientRect() |
| 133 | + mouseX.set(clientX - left) |
| 134 | + mouseY.set(clientY - top) |
| 135 | + } |
| 136 | + |
| 137 | + return ( |
| 138 | + <div |
| 139 | + key={resource.href} |
| 140 | + onMouseMove={onMouseMove} |
| 141 | + className="group relative flex rounded-2xl bg-zinc-50 transition-shadow hover:shadow-md hover:shadow-zinc-900/5 dark:bg-white/2.5 dark:hover:shadow-black/5" |
| 142 | + > |
| 143 | + <ResourcePattern {...resource.pattern} mouseX={mouseX} mouseY={mouseY} /> |
| 144 | + <div className="absolute inset-0 rounded-2xl ring-1 ring-inset ring-zinc-900/7.5 group-hover:ring-zinc-900/10 dark:ring-white/10 dark:group-hover:ring-white/20" /> |
| 145 | + <div className="relative rounded-2xl px-4 pb-4 pt-16"> |
| 146 | + <ResourceIcon icon={resource.icon} /> |
| 147 | + <h3 className="mt-4 text-sm font-semibold leading-7 text-zinc-900 dark:text-white"> |
| 148 | + <Link href={resource.href}> |
| 149 | + <span className="absolute inset-0 rounded-2xl" /> |
| 150 | + {resource.name} |
| 151 | + </Link> |
| 152 | + </h3> |
| 153 | + <p className="mt-1 text-sm text-zinc-600 dark:text-zinc-400">{resource.description}</p> |
| 154 | + </div> |
| 155 | + </div> |
| 156 | + ) |
| 157 | +} |
| 158 | + |
| 159 | +export function Concepts() { |
| 160 | + return ( |
| 161 | + <div className="my-16 xl:max-w-none"> |
| 162 | + <Heading level={2} id="concepts"> |
| 163 | + Concepts |
| 164 | + </Heading> |
| 165 | + <div className="not-prose mt-4 grid grid-cols-1 gap-8 border-t border-zinc-900/5 pt-10 sm:grid-cols-2 xl:grid-cols-4 dark:border-white/5"> |
| 166 | + {concepts.map((resource) => ( |
| 167 | + <Concept key={resource.href} resource={resource} /> |
| 168 | + ))} |
| 169 | + </div> |
| 170 | + </div> |
| 171 | + ) |
| 172 | +} |
0 commit comments