mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
## What kind of change does this PR introduce? Mechanical cleanup on top of the Button default-variant change (#50160). ## What is the current behavior? Many callsites still pass `variant="default"` even though that is now the component default. ## What is the new behavior? Removes redundant static `variant="default"` from legacy `Button` and `ButtonTooltip` callsites. Keeps explicit defaults where they document the API: - `button-default.tsx` and `button-sizes.tsx` demos - `DocsButton`, which pins neutral styling at the wrapper boundary ## To test Studio: - [Auth → Rate Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits): dirty the form so Cancel appears; Cancel stays neutral, Save stays green - [Project Settings → API Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys): `DocsButton` in the header actions stays neutral Design system: - [Design system → Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button): `button-default` / `button-sizes` still show explicit default styling; Primary (green) is restricted to the Primary section (and `asChild`) WWW: - [www → Brand assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets): Download logo kit / Download button kit stay neutral
120 lines
3.8 KiB
TypeScript
120 lines
3.8 KiB
TypeScript
import { ArrowUpRight } from 'lucide-react'
|
|
// Import Swiper React components
|
|
import Link from 'next/link'
|
|
import { useState } from 'react'
|
|
import { Swiper, SwiperSlide } from 'swiper/react'
|
|
import { Button } from 'ui'
|
|
|
|
import CodeBlock from '../CodeBlock/CodeBlock'
|
|
|
|
interface Example {
|
|
lang: 'js' | 'py' | 'sql'
|
|
title: string
|
|
code: string
|
|
}
|
|
|
|
interface Props {
|
|
size?: 'small' | 'large'
|
|
content: Example[]
|
|
title: string | React.ReactNode
|
|
footer?: React.ReactNode
|
|
text?: React.ReactNode
|
|
autoHeight?: boolean
|
|
documentation_link?: string
|
|
}
|
|
|
|
function FunctionsUsecases(props: Props) {
|
|
// store API swiper instance
|
|
const [apiSwiper, setApiSwiper] = useState(undefined)
|
|
const [apiSwiperActiveIndex, setApiSwiperActiveIndex] = useState(0)
|
|
|
|
function handleApiSwiperNavChange(e: number) {
|
|
setApiSwiperActiveIndex(e)
|
|
// @ts-ignore
|
|
apiSwiper.slideTo(e)
|
|
}
|
|
|
|
return (
|
|
<div className="grid grid-cols-12 lg:gap-16">
|
|
<div className="col-span-12 pb-8 lg:col-span-5 xl:col-span-5">
|
|
<h2 className="h3">{props.title}</h2>
|
|
<div className="p">{props.text}</div>
|
|
|
|
<div className="flex flex-col gap-3">
|
|
{props.content.map((feat, i) => {
|
|
const active = i == apiSwiperActiveIndex
|
|
return (
|
|
<button
|
|
tabIndex={0}
|
|
key={`featureHighlighted-${i}`}
|
|
className={
|
|
'bg-background hover:bg-surface-100 hover:border group rounded-md border px-6 py-4 text-left transition-all' +
|
|
(active ? ' bg-surface-200 border-foreground-lighter' : '')
|
|
}
|
|
// onClick={() => setCurrentSelection(feat.highlightLines)}
|
|
onClick={() => handleApiSwiperNavChange(i)}
|
|
>
|
|
<div
|
|
className={
|
|
'transition-colors ' +
|
|
(active
|
|
? ' text-foreground'
|
|
: ' text-foreground-light group-hover:text-foreground')
|
|
}
|
|
>
|
|
{feat.title}
|
|
</div>
|
|
<div
|
|
className={
|
|
'text-sm transition-colors ' +
|
|
(active
|
|
? ' text-foreground-light'
|
|
: ' text-foreground-light group-hover:text-foreground-light ')
|
|
}
|
|
>
|
|
{/*
|
|
// @ts-ignore */}
|
|
{feat.description}
|
|
</div>
|
|
</button>
|
|
)
|
|
})}
|
|
{props.documentation_link && (
|
|
<Button asChild size="small" className="mt-4" icon={<ArrowUpRight />}>
|
|
<Link href={props.documentation_link} as={props.documentation_link}>
|
|
Explore documentation
|
|
</Link>
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div className="sbui-tabs--alt col-span-12 lg:col-span-7 xl:col-span-6 xl:col-start-7">
|
|
<div className="overflow-hidden">
|
|
<Swiper
|
|
// @ts-ignore
|
|
onSwiper={setApiSwiper}
|
|
style={{ zIndex: 0, marginRight: '1px' }}
|
|
initialSlide={apiSwiperActiveIndex}
|
|
spaceBetween={0}
|
|
slidesPerView={1}
|
|
speed={300}
|
|
allowTouchMove={false}
|
|
autoHeight={props.autoHeight ? props.autoHeight : false}
|
|
>
|
|
{props.content &&
|
|
props.content.map((content: Example, i) => (
|
|
<SwiperSlide key={i}>
|
|
<CodeBlock key={i} lang={content.lang} size={props.size ? props.size : 'small'}>
|
|
{content.code}
|
|
</CodeBlock>
|
|
</SwiperSlide>
|
|
))}
|
|
</Swiper>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default FunctionsUsecases
|