Files
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

183 lines
5.4 KiB
TypeScript

'use client'
import { Check, Copy, File, Terminal } from 'lucide-react'
import { useTheme } from 'next-themes'
import { useEffect, useState, type CSSProperties } from 'react'
import CopyToClipboard from 'react-copy-to-clipboard'
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'
import bash from 'react-syntax-highlighter/dist/cjs/languages/hljs/bash'
import js from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript'
import json from 'react-syntax-highlighter/dist/cjs/languages/hljs/json'
import kotlin from 'react-syntax-highlighter/dist/cjs/languages/hljs/kotlin'
import py from 'react-syntax-highlighter/dist/cjs/languages/hljs/python'
import sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql'
import yaml from 'react-syntax-highlighter/dist/cjs/languages/hljs/yaml'
import { Button, cn } from 'ui'
import monokaiCustomTheme, { codeHikeTheme } from './CodeBlock.utils'
export type LANG = 'js' | 'sql' | 'py' | 'bash' | 'ts' | 'tsx' | 'kotlin' | 'yaml' | 'json'
export interface CodeBlockProps {
lang: LANG
startingLineNumber?: number
hideCopy?: boolean
showLineNumbers?: boolean
className?: string
children?: string
size?: 'small' | 'medium' | 'large'
background?: string
filename?: string
theme?: 'monokai' | 'code-hike'
}
function CodeBlock(props: CodeBlockProps) {
const { resolvedTheme } = useTheme()
const isDarkTheme = resolvedTheme?.includes('dark') ?? false
const [copied, setCopied] = useState(false)
const [mounted, setMounted] = useState(false)
const firstLine = props.children ? props.children.split('\n')[0] : ''
let filename = ''
if (firstLine.includes('filename =')) {
filename = firstLine.split('=')[1]
}
const content =
props.children && filename ? props.children.replace(`${firstLine}\n\n`, '') : props.children
const handleCopy = () => {
setCopied(true)
setTimeout(() => {
setCopied(false)
}, 1000)
}
const isCodeHikeTheme = props.theme === 'code-hike'
let lang = props.lang
? props.lang
: props.className
? props.className.replace('language-', '')
: 'js'
// force jsx to be js highlighted
if (lang === 'jsx') lang = 'js'
SyntaxHighlighter.registerLanguage('js', js)
SyntaxHighlighter.registerLanguage('py', py)
SyntaxHighlighter.registerLanguage('sql', sql)
SyntaxHighlighter.registerLanguage('bash', bash)
SyntaxHighlighter.registerLanguage('kotlin', kotlin)
SyntaxHighlighter.registerLanguage('yaml', yaml)
SyntaxHighlighter.registerLanguage('json', json)
// const large = props.size === 'large' ? true : false
const large = false
useEffect(() => {
setMounted(true)
}, [])
if (!mounted) return null
return (
<div className="not-prose dark overflow-hidden">
{filename && (
<div
className="
bg-background
text-muted
flex
h-8 w-full
items-center
gap-1
rounded-tr
rounded-tl
border-t
border-r
border-l
px-4
font-sans
"
>
{lang === 'bash' ? (
<Terminal size={12} strokeWidth={2} />
) : (
<File size={12} strokeWidth={2} />
)}
<span className="text-xs">{filename ?? 'index.js'}</span>
</div>
)}
<div className="relative">
<SyntaxHighlighter
language={lang}
style={
(isCodeHikeTheme
? isDarkTheme
? codeHikeTheme.dark
: codeHikeTheme.light
: isDarkTheme
? monokaiCustomTheme.dark
: monokaiCustomTheme.light) as Record<string, CSSProperties>
}
className={cn(
'synthax-highlighter border border-default/15 rounded-lg',
!filename && 'rounded-t-lg',
'rounded-b-lg',
props.className
)}
customStyle={{
padding: props.showLineNumbers
? large
? '1.25rem 1rem'
: '1rem 0.8rem'
: large
? '1.25rem 1.5rem'
: '1.25rem 1.5rem',
fontSize: large ? 18 : '0.775rem',
lineHeight: large ? 1.6 : 1.4,
}}
showLineNumbers={props.showLineNumbers}
lineNumberStyle={{
padding: '0px',
marginRight: isCodeHikeTheme ? '16px' : '21px',
minWidth: '1.5em',
opacity: isCodeHikeTheme ? '0.7' : '0.3',
fontSize: large ? 14 : '0.75rem',
}}
>
{content ?? ''}
</SyntaxHighlighter>
{!props.hideCopy && props.children ? (
<div className="absolute right-2 top-2">
<CopyToClipboard text={props.children}>
<Button
variant="text"
icon={
copied ? (
<span className="text-primary">
<Check strokeWidth={3} />
</span>
) : (
<Copy />
)
}
onClick={() => handleCopy()}
aria-label="Copy"
className="px-1.5 py-1.5 border border-transparent hover:border-strong"
/>
</CopyToClipboard>
</div>
) : null}
</div>
</div>
)
}
export default CodeBlock