Files
supabase/apps/www/components/Panel/Panel.tsx
Jonathan Summers-MuirandFrancesco Sansalvadore 1f1f8a5fa4 Feat/whale init (#28243)
* duplicate page

* whale init

* table background

* prepare

* sync undocumented remote schema from master

* revert remote schema sync

* add lw12 tickets migration file

* ticket init

* set up lw12 ticket layout

* finish ticket layout and customization form

* lw12 ticket og

* ticket styling

* code highlight border

* launch week migrations

* local dev progress

* keep local gh config

* comment section

* comment section

* comment out username.tsx

* remove lw/ticekts temp

* update copy

* fix migration view

* redirect to try

* use misc

* lw12 og

* share

* share correct

* env var

* username page

* update example env

* push new db schema

* trigger deploy

* update ticket og

* ticket themes

* bypass browser

* change env var name

* fix

* fix

* process env

* create client server side

* lw announcements

* promoToast

* animated bg

* update ticket og bg

* minor details

* secret ticket

* social share text

* social share textgst

* flow text

* update og

* update og handler

* Update index.ts

* use functions.invoke and use generic supabase URL

* Update index.ts

* Update handler.tsx

* Update package-lock.json

* Update handler.tsx

* add next api route

* moved to vercel edge function

* set revalidate

* Update route.tsx

* Delete lw-ticket-og.tsx

* Update route.tsx

* Update [username].tsx

* Update [username].tsx

* add more fetches

* Update turbo.json

* ticket themes updated

* copy and layout updated

* Update index.tsx

* Update Ticket.tsx

* Update TicketingFlow.tsx

* update countdown

* updated bg

* small updates

* moat

* Update [username].tsx

* Update 20240723155310_add_lw12_ticketing_schema.sql

* optimistic ticket stuff og generation

* Update index.tsx

* updated layout

* update themes in og

* Update constants.ts

* attr renamed

* Update TicketingFlow.tsx

* Update TicketActions.tsx

* grammar

* moar updates

* Update TicketActions.tsx

* Update TicketActions2.tsx

* Update TicketActions.tsx

* Update Hero.tsx

* Update TicketingFlow.tsx

* remove console logs

---------

Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com>
2024-08-01 01:59:01 +08:00

112 lines
3.4 KiB
TypeScript

import React, { PropsWithChildren, useEffect, useRef } from 'react'
import { motion } from 'framer-motion'
import { cn } from 'ui'
import { detectBrowser, isBrowser } from 'common'
interface Props {
outerClassName?: string
innerClassName?: string
hasActiveOnHover?: boolean
activeColor?: 'default' | 'brand'
hasShimmer?: boolean
hasInnerShimmer?: boolean
shimmerFromColor?: string
shimmerToColor?: string
style?: any
innerStyle?: any
hasMotion?: boolean
}
const Panel = ({
outerClassName,
innerClassName,
hasActiveOnHover = false,
activeColor = 'default',
hasShimmer = false,
hasInnerShimmer = false,
shimmerFromColor,
shimmerToColor,
hasMotion = false,
children,
style,
innerStyle,
}: PropsWithChildren<Props>) => {
const outerRef = useRef(null)
const innerRef = useRef(null)
const Component = hasMotion ? motion.div : 'div'
const isSafari = isBrowser && detectBrowser() === 'Safari'
const trackCursor = hasShimmer || hasInnerShimmer
const handleGlow = (event: any) => {
if (!outerRef.current || !innerRef.current) return
const outerElement = outerRef.current as HTMLDivElement
const innerElement = innerRef.current as HTMLDivElement
const { x: elX, y: elY, width, height } = outerElement.getBoundingClientRect()
const x = event.clientX - elX
const y = event.clientY - elY
const isActive = x > -0 && x < width + 0 && y > -0 && y < height + 0
if (hasShimmer) {
const activeGlow =
hasActiveOnHover && isActive
? `radial-gradient(65rem circle at ${x}px ${y}px, ${
activeColor === 'brand' ? 'var(--colors-brand9)' : 'hsl(var(--border-stronger))'
}, transparent), `
: ''
outerElement.style.backgroundImage = `
${activeGlow}radial-gradient(30rem circle at ${x}px ${y}px, ${
shimmerFromColor ?? 'hsl(var(--border-strong))'
}, ${shimmerToColor ?? 'hsl(var(--background-surface-300))'})`
}
if (hasInnerShimmer) {
innerElement.style.backgroundImage = isActive
? `radial-gradient(7rem circle at ${x}px ${y}px, hsl(var(--background-surface-300)), transparent), radial-gradient(20rem circle at ${x}px ${y}px, hsl(var(--background-surface-200)), transparent)`
: ''
}
}
useEffect(() => {
if (!isBrowser || trackCursor || isSafari) return
window.addEventListener('mousemove', handleGlow)
return () => {
window.removeEventListener('mousemove', handleGlow)
}
}, [])
return (
<Component
ref={outerRef}
className={cn(
'relative rounded-xl p-px bg-surface-75 bg-gradient-to-b from-border to-border/50 dark:to-surface-100 transition-all shadow-md flex items-center justify-center',
!trackCursor && hasActiveOnHover
? activeColor === 'brand'
? 'hover:bg-none hover:!bg-brand'
: 'hover:bg-none hover:!bg-border-stronger'
: '',
outerClassName
)}
{...(hasMotion ? { whileHover: 'hover', animate: 'initial' } : undefined)}
style={style}
>
<div
className={cn(
'relative z-10 w-full h-full rounded-xl bg-surface-75 overflow-hidden text-foreground-light',
innerClassName
)}
style={innerStyle}
>
{children}
<div
ref={innerRef}
className="absolute z-10 inset-0 w-full h-full pointer-events-none opacity-20"
/>
</div>
</Component>
)
}
export default Panel