mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03: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 -->
159 lines
4.9 KiB
TypeScript
159 lines
4.9 KiB
TypeScript
'use client'
|
|
|
|
import { Feedback } from '~/components/Feedback'
|
|
import { useSendTelemetryEvent } from '~/lib/telemetry'
|
|
import { askAiUrls, isFeatureEnabled, useCopyMarkdownFromUrl } from 'common'
|
|
import { Chatgpt, Claude } from 'icons'
|
|
import { Check, Copy, Sparkles } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { usePathname } from 'next/navigation'
|
|
import { cn } from 'ui'
|
|
import { ExpandableVideo } from 'ui-patterns/ExpandableVideo'
|
|
import { Toc, TOCItems, TOCScrollArea } from 'ui-patterns/Toc'
|
|
|
|
import { useTocAnchors } from '../features/docs/GuidesMdx.state'
|
|
|
|
interface TOCHeader {
|
|
id?: string
|
|
text: string
|
|
link: string
|
|
level: number
|
|
}
|
|
|
|
function AiTools({ className }: { className?: string }) {
|
|
const path = usePathname()
|
|
const sendTelemetryEvent = useSendTelemetryEvent()
|
|
const { copied, copyMarkdown } = useCopyMarkdownFromUrl()
|
|
const urls = askAiUrls(`https://supabase.com/docs${path}`)
|
|
|
|
function handleAgentSetupClick() {
|
|
sendTelemetryEvent({ action: 'agent_setup_clicked' })
|
|
}
|
|
|
|
async function handleCopy() {
|
|
const ok = await copyMarkdown(`/docs${path}.md`, {
|
|
fallback: () => document.getElementById('sb-docs-guide-main-article')?.innerHTML ?? '',
|
|
})
|
|
if (ok) {
|
|
sendTelemetryEvent({ action: 'copy_as_markdown_clicked', properties: { pageType: 'guide' } })
|
|
}
|
|
}
|
|
|
|
return (
|
|
<section className={cn(className)} aria-labelledby="ai-tools-title">
|
|
<h3
|
|
id="ai-tools-title"
|
|
className="block font-mono uppercase text-xs text-foreground-light mb-3"
|
|
>
|
|
AI Tools
|
|
</h3>
|
|
<div className="flex flex-col gap-2">
|
|
<Link
|
|
href="/guides/ai-tools"
|
|
onClick={handleAgentSetupClick}
|
|
className="flex items-center gap-1.5 text-xs text-foreground-lighter hover:text-foreground transition-colors"
|
|
>
|
|
<Sparkles size={14} strokeWidth={1.5} />
|
|
Connect your AI agent
|
|
</Link>
|
|
<button
|
|
tabIndex={0}
|
|
onClick={handleCopy}
|
|
className="flex cursor-pointer items-center gap-1.5 text-xs text-foreground-lighter hover:text-foreground text-left transition-colors"
|
|
>
|
|
{copied ? (
|
|
<Check size={14} strokeWidth={1.5} className="text-primary" aria-hidden />
|
|
) : (
|
|
<Copy size={14} strokeWidth={1.5} aria-hidden />
|
|
)}
|
|
{copied ? 'Copied!' : 'Copy as Markdown'}
|
|
</button>
|
|
<span className="sr-only" role="status">
|
|
{copied ? 'Copied to clipboard' : ''}
|
|
</span>
|
|
<a
|
|
href={urls.chatgpt}
|
|
target="_blank"
|
|
onClick={() =>
|
|
sendTelemetryEvent({
|
|
action: 'ask_ai_clicked',
|
|
properties: { agent: 'chatgpt', pageType: 'guide' },
|
|
})
|
|
}
|
|
rel="noreferrer noopener"
|
|
className="flex items-center gap-1.5 text-xs text-foreground-lighter hover:text-foreground transition-colors"
|
|
>
|
|
<Chatgpt size={14} aria-hidden />
|
|
Ask ChatGPT
|
|
</a>
|
|
<a
|
|
href={urls.claude}
|
|
target="_blank"
|
|
onClick={() =>
|
|
sendTelemetryEvent({
|
|
action: 'ask_ai_clicked',
|
|
properties: { agent: 'claude', pageType: 'guide' },
|
|
})
|
|
}
|
|
rel="noreferrer noopener"
|
|
className="flex items-center gap-1.5 text-xs text-foreground-lighter hover:text-foreground transition-colors"
|
|
>
|
|
<Claude size={14} aria-hidden />
|
|
Ask Claude
|
|
</a>
|
|
</div>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
const GuidesSidebar = ({
|
|
className,
|
|
video,
|
|
videoTitle,
|
|
hideToc,
|
|
}: {
|
|
className?: string
|
|
video?: string
|
|
videoTitle?: string
|
|
hideToc?: boolean
|
|
}) => {
|
|
const pathname = usePathname()
|
|
const { toc } = useTocAnchors()
|
|
const showFeedback = isFeatureEnabled('feedback:docs')
|
|
const tocVideoPreview = `https://img.youtube.com/vi/${video}/0.jpg`
|
|
|
|
return (
|
|
<div className={cn('thin-scrollbar overflow-y-auto h-fit', 'px-px', className)}>
|
|
<div className="w-full relative border-l flex flex-col gap-6 lg:gap-8 px-2 h-fit">
|
|
{video && (
|
|
<div className="relative pl-5">
|
|
<ExpandableVideo imgUrl={tocVideoPreview} videoId={video} videoTitle={videoTitle} />
|
|
</div>
|
|
)}
|
|
{showFeedback && (
|
|
<div className="pl-5">
|
|
<Feedback key={pathname} />
|
|
</div>
|
|
)}
|
|
<div className="pl-5">
|
|
<AiTools key={pathname} />
|
|
</div>
|
|
{!hideToc && toc.length !== 0 && (
|
|
<Toc className="-ml-[calc(0.25rem+6px)]">
|
|
<h3 className="inline-flex items-center gap-1.5 font-mono text-xs uppercase text-foreground pl-[calc(1.5rem+6px)]">
|
|
On this page
|
|
</h3>
|
|
<TOCScrollArea>
|
|
<TOCItems items={toc} />
|
|
</TOCScrollArea>
|
|
</Toc>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default GuidesSidebar
|
|
export { GuidesSidebar }
|
|
export type { TOCHeader }
|