Files
supabase/apps/www/components/OpenSource/OSSHero.tsx
Ivan Vasilov 0abe792889 chore: Migrate the main Tailwind JS config to CSS (#45686)
This PR migrates the JS config for Tailwind into a CSS config. As such,
all variables have been defined as CSS variables and they're using the
specialized Tailwind syntax for generating utility classes.

Beside the migration, these changes were also added:
- Added `tailwind.config.css` to few packages to make the Tailwind
Intellisense work.
- Migrated away from Radix style color classes to our defined classes,
the values will remain the same.
- Most of the CSS is generated by scripts, they'll be removed in next
PRs.
* Removed redundant `border-light` classes from several components since
it was undefined.
* Removed redundant `text-strong` classes from several components since
it was undefined.

How to test:
- Open all apps, compare the UI (mainly colors) to builds from #45417
and try to find a difference.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Style**
* Harmonized color variable usages and updated UI color references
(affects palettes, charts, gradients, hero illustrations, and
scrollbars).
  * Tweaked border, tab, and selection visuals across components.

* **New Features**
* Added a suite of theme animations and refined typography presets used
by site prose and docs.

* **Refactor**
* Overhauled Tailwind/theme configuration and color token generation for
more consistent theming.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-13 13:14:58 +02:00

202 lines
6.5 KiB
TypeScript

import { useBreakpoint } from 'common'
import { motion } from 'framer-motion'
import { useTheme } from 'next-themes'
import React from 'react'
import { useWindowSize } from 'react-use'
import { cn } from 'ui'
import styles from './hero.module.css'
const OSSHero = () => (
<>
<div className="absolute z-[-4] flex flex-col top-0 left-0 w-full h-[500px] overflow-hidden pointer-events-none">
<div className="absolute bottom-0 z-1 w-full h-4/5 bg-linear-to-t from-background to-transparent" />
<div className="absolute top-0 z-1 w-full h-2/5 bg-linear-to-b from-background to-transparent" />
</div>
<div
className={cn(
'absolute inset-0 w-full h-[300px] lg:h-[500px] overflow-hidden pointer-events-none',
styles['hero-container']
)}
>
<div
className="absolute select-none pointer-events-none inset-0 z-3 blur-[100px] w-full h-full opacity-60"
style={{ transform: 'translateZ(0px)' }}
/>
<div className="absolute bottom-0 z-[-2] w-full h-full bg-linear-to-t from-background to-transparent" />
<HeroGrid />
</div>
</>
)
const HeroGrid = () => {
const { resolvedTheme } = useTheme()
const { width } = useWindowSize()
const isSm = useBreakpoint(640)
const svgGridOptions = {
color: resolvedTheme?.includes('dark') ? '#00d4ad' : '#015a42',
boxWidth: width ? width * 7 : 7500,
boxHeight: width ? width * 5 : 6000,
xLines: isSm ? 20 : 49,
yLines: isSm ? 65 : 130,
strokeWidth: 1,
}
const GridSVG = () => (
<svg
preserveAspectRatio="none"
width="100%"
height="100%"
viewBox={`0 0 ${svgGridOptions.boxWidth} ${svgGridOptions.boxHeight}`}
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
{[...new Array(svgGridOptions.yLines)].map((_: any, i: number) => {
const y = (svgGridOptions.boxWidth * i) / svgGridOptions.yLines
return (
<line
key={`y-${i}`}
x1={svgGridOptions.boxHeight}
y1={y}
x2="0"
y2={y}
stroke={svgGridOptions.color}
strokeWidth={svgGridOptions.strokeWidth}
shapeRendering="geometricPrecision"
/>
)
})}
{[...new Array(svgGridOptions.xLines)].map((_: any, i: number) => {
const x = (svgGridOptions.boxHeight * i) / svgGridOptions.xLines
return (
<>
<line
key={`x-${i}`}
x1={x}
y1={svgGridOptions.boxWidth}
x2={x}
y2="0"
stroke={svgGridOptions.color}
strokeWidth={svgGridOptions.strokeWidth}
shapeRendering="geometricPrecision"
/>
{isSm
? i === 9 && (
<line
x1={x}
y1={svgGridOptions.boxWidth}
x2={x}
y2="0"
stroke="url(#electric-pulse)"
strokeLinecap="round"
strokeWidth={4}
shapeRendering="geometricPrecision"
/>
)
: i === 25 && (
<line
x1={x}
y1={svgGridOptions.boxWidth}
x2={x}
y2="0"
stroke="url(#electric-pulse)"
strokeLinecap="round"
strokeWidth={4}
shapeRendering="geometricPrecision"
/>
)}
{isSm
? i === 14 && (
<line
x1={x}
y1={svgGridOptions.boxWidth}
x2={x}
y2="0"
stroke="url(#electric-pulse-2)"
strokeLinecap="round"
strokeWidth={4}
shapeRendering="geometricPrecision"
/>
)
: i === 33 && (
<line
x1={x}
y1={svgGridOptions.boxWidth}
x2={x}
y2="0"
stroke="url(#electric-pulse-2)"
strokeLinecap="round"
strokeWidth={4}
shapeRendering="geometricPrecision"
/>
)}
</>
)
})}
<defs>
<motion.linearGradient
animate={{
x2: [svgGridOptions.boxWidth / 2, 0, svgGridOptions.boxWidth / 2],
x1: [svgGridOptions.boxWidth / 2, 0, svgGridOptions.boxWidth / 2],
y1: [svgGridOptions.boxHeight, svgGridOptions.boxHeight / 3, 0],
y2: [svgGridOptions.boxHeight, svgGridOptions.boxHeight / 2, 0],
}}
transition={{
duration: isSm ? 4 : 5,
repeat: Infinity,
ease: 'linear',
}}
id="electric-pulse"
gradientUnits="userSpaceOnUse"
>
<stop stopColor={svgGridOptions.color} stopOpacity="0" />
<stop stopColor={svgGridOptions.color} stopOpacity="0.8" />
<stop offset="1" stopColor="var(--color-brand-900)" stopOpacity="0" />
</motion.linearGradient>
<motion.linearGradient
animate={{
x2: [svgGridOptions.boxWidth / 2, 0, svgGridOptions.boxWidth / 2],
x1: [svgGridOptions.boxWidth / 2, 0, svgGridOptions.boxWidth / 2],
y1: [svgGridOptions.boxHeight, svgGridOptions.boxHeight / 3, 0],
y2: [svgGridOptions.boxHeight, svgGridOptions.boxHeight / 2, 0],
}}
transition={{
duration: isSm ? 4 : 5,
repeat: Infinity,
ease: 'linear',
delay: 2,
}}
id="electric-pulse-2"
gradientUnits="userSpaceOnUse"
>
<stop stopColor={svgGridOptions.color} stopOpacity="0" />
<stop stopColor={svgGridOptions.color} stopOpacity="0.8" />
<stop offset="1" stopColor="var(--color-brand-900)" stopOpacity="0" />
</motion.linearGradient>
</defs>
</svg>
)
return (
<div className="relative -z-10 perspective-distant! sm:perspective-distant! md:perspective-distant! lg:perspective-distant!">
<div
style={{
transform: 'rotateX(85deg)',
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
}}
>
<div className={[styles['hero-grid-lines']].join(' ')}>
<GridSVG />
</div>
</div>
</div>
)
}
export default OSSHero