Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

update InteractiveShimmerCard

Francesco Sansalvadore32df30c767f7
diff --git a/apps/www/components/InteractiveShimmerCard/index.tsx b/apps/www/components/InteractiveShimmerCard/index.tsx
index d6017544f96..474b5912907 100644
--- a/apps/www/components/InteractiveShimmerCard/index.tsx
+++ b/apps/www/components/InteractiveShimmerCard/index.tsx
@@ -3,6 +3,8 @@ import React, { PropsWithChildren, useEffect, useRef } from 'react'
interface Props {
outerClassName?: string
innerClassName?: string
+ activeColor?: 'default' | 'brand'
+ hasShimmer?: boolean
hasActiveOnHover?: boolean
hasInnerShimmer?: boolean
shimmerFromColor?: string
@@ -12,6 +14,8 @@ interface Props {
const InteractiveShimmerCard = ({
outerClassName,
innerClassName,
+ activeColor = 'default',
+ hasShimmer = false,
hasActiveOnHover = false,
hasInnerShimmer = false,
shimmerFromColor,
@@ -20,32 +24,36 @@ const InteractiveShimmerCard = ({
}: PropsWithChildren<Props>) => {
const outerRef = useRef(null)
const innerRef = useRef(null)
+ const trackCursor = hasShimmer || hasInnerShimmer
const handleGlow = (event: any) => {
- if (!outerRef.current || !innerRef.current) return null
+ if (!trackCursor || !outerRef.current || !innerRef.current) return null
+
const outerElement = outerRef.current as HTMLDivElement
const innerElement = innerRef.current as HTMLDivElement
- let x: any
- let y: any
-
const { x: elX, y: elY, width, height } = outerElement.getBoundingClientRect()
- x = event.clientX - elX
- y = event.clientY - elY
- const isActive = x > -3 && x < width + 3 && y > -3 && y < height + 3
- const activeGlow =
- hasActiveOnHover && isActive
- ? `radial-gradient(65rem circle at ${x}px ${y}px, hsl(var(--brand-default)), transparent), `
- : ''
- outerElement.style.background = isActive ? `hsl(var(--brand-default))` : `var(--colors-scale3)`
- outerElement.style.backgroundImage = `
+ 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, var(${
+ activeColor === 'brand' ? '--colors-brand9' : '--colors-scale9'
+ }), transparent), `
+ : ''
+ outerElement.style.backgroundImage = `
${activeGlow}radial-gradient(30rem circle at ${x}px ${y}px, ${
- shimmerFromColor ?? 'var(--colors-scale8)'
- }, ${shimmerToColor ?? 'var(--colors-scale3)'})`
+ shimmerFromColor ?? 'var(--colors-scale8)'
+ }, ${shimmerToColor ?? 'var(--colors-scale5)'})`
+ }
- innerElement.style.backgroundImage =
- hasInnerShimmer && isActive
+ if (hasInnerShimmer) {
+ innerElement.style.backgroundImage = isActive
? `radial-gradient(7rem circle at ${x}px ${y}px, var(--colors-scale5), transparent), radial-gradient(20rem circle at ${x}px ${y}px, var(--colors-scale4), transparent)`
: ''
+ }
}
useEffect(() => {
@@ -62,6 +70,11 @@ const InteractiveShimmerCard = ({
ref={outerRef}
className={[
'relative rounded-xl bg-scale-400 from-scale-800 to-scale-800 p-px transition-all shadow-md',
+ !trackCursor && hasActiveOnHover
+ ? activeColor === 'brand'
+ ? 'hover:bg-none hover:!bg-brand'
+ : 'hover:bg-none hover:!bg-scale-900'
+ : '',
outerClassName,
].join(' ')}
>
diff --git a/apps/www/components/Sections/HighlightCards.tsx b/apps/www/components/Sections/HighlightCards.tsx
index 9e2493492a2..8d9e8987e6a 100644
--- a/apps/www/components/Sections/HighlightCards.tsx
+++ b/apps/www/components/Sections/HighlightCards.tsx
@@ -44,7 +44,7 @@ const HighlightCard = ({ highlight, index }: { highlight: Highlight; index: numb
onMouseLeave={() => setIsHovered(false)}
animate={isInView ? animate : initial}
>
- <InteractiveShimmerCard innerClassName="flex flex-col !bg-scale-100">
+ <InteractiveShimmerCard hasShimmer innerClassName="flex flex-col !bg-scale-100">
<div className="relative w-full aspect-[1.35/1] mb-4">
<div
className="absolute inset-0 w-full h-full z-10"
diff --git a/apps/www/pages/partners/index.tsx b/apps/www/pages/partners/index.tsx
index c6063980417..6c3ae25aa8d 100644
--- a/apps/www/pages/partners/index.tsx
+++ b/apps/www/pages/partners/index.tsx
@@ -112,6 +112,7 @@ const Partners = () => {
</div>
<div className="col-span-1 lg:col-span-3 w-full max-w-4xl grid gap-8 rounded md:grid-cols-2">
<InteractiveShimmerCard
+ hasShimmer
hasInnerShimmer={false}
hasActiveOnHover={true}
innerClassName="px-8 py-6 group flex flex-col gap-4"