mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## What kind of change does this PR introduce? Refactor. Follow-up to #49871. ## What is the current behavior? Branded (green) text still uses the `text-brand` classname while the colour comes from `--primary`. ## What is the new behavior? **Rename-only:** `text-brand` → `text-primary` across callsites and docs. Leftover `bg-brand` / `border-brand` alias to `brand-default`. No intentional colour changes in this PR. This better matches how we treat our green in other components and props, like `variant="primary"` for green buttons. ## To test On light mode: smoke-test that branded text still looks like #49871 (readable green, not the bright fill). - [Homepage](https://zone-www-dot-com-git-dnywh-depr-316-text-brand-de2380-supabase.vercel.app/): “Scale to millions” uses `text-primary` - [Docs homepage](https://docs-git-dnywh-depr-316-text-brand-to-primary-supabase.vercel.app/docs): branded links like “More on self-hosting” are still readable - [Typography docs](https://design-system-git-dnywh-depr-316-text-brand-to-primary-supabase.vercel.app/design-system/docs/typography): documents `text-primary` - [Colour usage](https://design-system-git-dnywh-depr-316-text-brand-to-primary-supabase.vercel.app/design-system/docs/color-usage): `text-primary` is visibly darker than `bg-brand-default` _on light mode_ - [Studio auth providers](https://studio-staging-git-dnywh-depr-316-text-brand-to-60fa6c-supabase.vercel.app/dashboard/project/_/auth/providers): enabled provider badge text readable; status dot stays bright green <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Updated branded text, link hover states, icons, badges, indicators, and highlighted content across the Design System, Docs, Studio, Learn, UI Library, and marketing experiences to use the primary theme color. * Updated syntax highlighting and table-of-contents styling for consistent primary-color presentation. * Refined brand color fallback behavior for bright fills and borders. * **Documentation** * Updated color-usage and typography guidance to recommend the primary text utility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
118 lines
3.8 KiB
TypeScript
118 lines
3.8 KiB
TypeScript
import { useEffect, useRef, useState } from 'react'
|
|
|
|
const ANIMATION_DURATION = 600
|
|
|
|
// These values are calculated via static SQL queries under 'Key Stats' and rounded for display in data/surveys/state-of-startups-2025.tsx file
|
|
export function SurveyStatCard({ label, percent }: { label: string; percent: number }) {
|
|
const [displayValue, setDisplayValue] = useState(0)
|
|
const [hasAnimated, setHasAnimated] = useState(false)
|
|
const [shouldAnimateBar, setShouldAnimateBar] = useState(false)
|
|
const cardRef = useRef<HTMLDivElement>(null)
|
|
|
|
useEffect(() => {
|
|
if (!percent || hasAnimated) return
|
|
|
|
const observer = new IntersectionObserver(
|
|
(entries) => {
|
|
entries.forEach((entry) => {
|
|
if (entry.isIntersecting && !hasAnimated) {
|
|
setHasAnimated(true)
|
|
setShouldAnimateBar(true)
|
|
|
|
// Start counting animation
|
|
const startTime = Date.now()
|
|
const duration = ANIMATION_DURATION
|
|
const startValue = 0
|
|
const endValue = percent
|
|
|
|
const animate = () => {
|
|
const elapsed = Date.now() - startTime
|
|
const progress = Math.min(elapsed / duration, 1)
|
|
|
|
// Easing function for smooth animation
|
|
const easeOutQuart = 1 - Math.pow(1 - progress, 4)
|
|
const currentValue = Math.round(startValue + (endValue - startValue) * easeOutQuart)
|
|
|
|
setDisplayValue(currentValue)
|
|
|
|
if (progress < 1) {
|
|
requestAnimationFrame(animate)
|
|
}
|
|
}
|
|
|
|
requestAnimationFrame(animate)
|
|
}
|
|
})
|
|
},
|
|
{ threshold: 0.1 }
|
|
)
|
|
|
|
const currentCardRef = cardRef.current
|
|
if (currentCardRef) {
|
|
observer.observe(currentCardRef)
|
|
}
|
|
|
|
return () => {
|
|
if (currentCardRef) {
|
|
observer.unobserve(currentCardRef)
|
|
}
|
|
}
|
|
}, [percent, hasAnimated])
|
|
|
|
return (
|
|
<div ref={cardRef} className="flex-1 px-8 py-8 flex flex-col gap-4">
|
|
{/* Progress bar */}
|
|
<div
|
|
className="h-2 relative overflow-hidden"
|
|
style={
|
|
{
|
|
'--bar-value': percent,
|
|
} as React.CSSProperties
|
|
}
|
|
>
|
|
{/* Background pattern for the entire bar */}
|
|
<div
|
|
className="absolute inset-0 pointer-events-none bg-foreground-muted/80"
|
|
style={{
|
|
maskImage: 'url("/images/state-of-startups/pattern-stipple.svg")',
|
|
maskSize: '4px',
|
|
maskRepeat: 'repeat',
|
|
maskPosition: 'center',
|
|
}}
|
|
/>
|
|
|
|
{/* Filled portion of the bar */}
|
|
<div
|
|
className={`h-full relative bg-surface-100`}
|
|
style={{
|
|
width: `calc(max(0.5%, (var(--bar-value) / 100) * 100%))`,
|
|
clipPath: shouldAnimateBar ? 'inset(0 0 0 0)' : 'inset(0 100% 0 0)',
|
|
transition: `clip-path 0.5s steps(${Math.max(2, Math.floor((percent / 100) * 12))}, end)`,
|
|
}}
|
|
>
|
|
{/* Foreground pattern for the filled portion */}
|
|
<div
|
|
className={`absolute inset-0 pointer-events-none bg-brand-default`}
|
|
style={{
|
|
maskImage: 'url("/images/state-of-startups/pattern-checker.svg")',
|
|
maskSize: '4px',
|
|
maskRepeat: 'repeat',
|
|
maskPosition: 'top left',
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/* Text */}
|
|
<div className="flex flex-col gap-2">
|
|
<p
|
|
className={`md:-ml-1 md:mt-8 text-2xl md:text-6xl font-mono tracking-tight inline-block flex flex-row items-baseline ${hasAnimated ? 'text-primary' : 'text-foreground-muted'} transition-colors duration-1000`}
|
|
>
|
|
{displayValue}
|
|
<span className="md:text-4xl">%</span>
|
|
</p>
|
|
<p className="text-foreground-light text-sm text-balance md:mr-6">{label}</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|