Files
supabase/apps/www/components/Products/FunctionsVisual.tsx
Danny White ec53175b8a refactor(ui): rename text-brand to text-primary (#50564)
## 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 -->
2026-09-22 16:19:03 +10:00

119 lines
3.0 KiB
TypeScript

import React, { useEffect, useRef, useState } from 'react'
import Image from 'next/image'
import Typed from 'typed.js'
import type { TypedOptions } from 'typed.js'
import { useBreakpoint } from 'common'
import { cn } from 'ui'
interface Props {
className?: string
}
const FunctionsVisual: React.FC<Props> = ({ className }) => {
const typerRef = useRef<HTMLSpanElement>(null)
const isMobile = useBreakpoint('md')
const [typed, setTyped] = useState<Typed | null>(null)
const [isPlaying, setIsPlaying] = useState(false)
const firstString = 'deploy'
const strings = [firstString, 'serve']
const disableAnimation = isPlaying || isMobile
let hoverTimeoutRef: any
const handleMouseEnter = () => {
// Delay the animation to trigger animation only if hover is intentional
hoverTimeoutRef = setTimeout(() => {
triggerAnimation()
}, 200)
}
const handleMouseLeave = () => {
clearTimeout(hoverTimeoutRef)
}
const onComplete = () => {
setIsPlaying(false)
}
const onBegin = () => {
setIsPlaying(true)
}
const options: TypedOptions = {
strings,
typeSpeed: 40,
backSpeed: 30,
backDelay: 100,
showCursor: false,
loop: false,
fadeOutDelay: 100,
onBegin,
onComplete,
}
const triggerAnimation = () => {
// Disable triggering the animation on mobile and if it's already playing
if (disableAnimation) return
typed?.destroy()
setTyped(new Typed(typerRef.current, options))
typed?.reset()
typed?.start()
}
useEffect(() => {
return () => {
typed?.destroy()
hoverTimeoutRef && clearTimeout(hoverTimeoutRef)
}
}, [])
return (
<figure
className={cn('absolute inset-0 z-20', className)}
role="img"
aria-label="Supabase Edge Functions visual composition"
onMouseOver={handleMouseEnter}
onMouseOut={handleMouseLeave}
>
<Image
src="/images/index/products/edge-functions-dark.svg"
alt="Supabase Edge Functions globe"
fill
sizes="100%"
quality={100}
priority
className="hidden dark:block absolute inset-0 object-cover object-center"
/>
<Image
src="/images/index/products/edge-functions-light.svg"
alt="Supabase Edge Functions globe"
fill
sizes="100%"
quality={100}
priority
className="dark:hidden absolute inset-0 object-cover object-center"
/>
<div
className="
absolute
inset-0
top-[48%] xl:top-[45%]
w-full max-w-[200px] h-fit
mx-auto px-2.5 py-1.5
flex items-center justify-start
rounded-full bg-surface-100 border border-strong
text-xs text-foreground-lighter text-left
"
>
<span className="mr-2">$</span>
supabase
<span className="ml-1 text-primary inline-block">
functions <span ref={typerRef}>{firstString}</span>
</span>
</div>
</figure>
)
}
export default FunctionsVisual