Files
supabase/apps/studio/components/interfaces/Linter/LintPageTabs.tsx
Ivan Vasilov 56de26fe22 chore: Migrate the monorepo to use Tailwind v4 (#45318)
This PR migrates the whole monorepo to use Tailwind v4:
- Removed `@tailwindcss/container-queries` plugin since it's included by
default in v4,
- Bump all instances of Tailwind to v4. Made minimal changes to the
shared config to remove non-supported features (`alpha` mentions),
- Migrate all apps to be compatible with v4 configs,
- Fix the `typography.css` import in 3 apps,
- Add missing rules which were included by default in v3,
- Run `pnpm dlx @tailwindcss/upgrade` on all apps, which renames a lot
of classes
- Rename all misnamed classes according to
https://tailwindcss.com/docs/upgrade-guide#renamed-utilities in all
apps.

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-04-30 10:53:24 +00:00

120 lines
3.9 KiB
TypeScript

import { InformationCircleIcon } from '@heroicons/react/16/solid'
import { MessageSquareMore } from 'lucide-react'
import { useRouter } from 'next/router'
import {
cn,
Tabs_Shadcn_,
TabsList_Shadcn_,
TabsTrigger_Shadcn_,
Tooltip,
TooltipContent,
TooltipTrigger,
} from 'ui'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { LINT_TABS, LINTER_LEVELS } from '@/components/interfaces/Linter/Linter.constants'
import { Lint } from '@/data/lint/lint-query'
interface LintPageTabsProps {
currentTab: string
setCurrentTab: (value: LINTER_LEVELS) => void
isLoading: boolean
activeLints: Lint[]
}
const LintPageTabs = ({ currentTab, setCurrentTab, isLoading, activeLints }: LintPageTabsProps) => {
const router = useRouter()
const warnLintsCount = activeLints.filter((x) => x.level === 'WARN').length
const errorLintsCount = activeLints.filter((x) => x.level === 'ERROR').length
const infoLintsCount = activeLints.filter((x) => x.level === 'INFO').length
const LintCountLabel = ({ tab }: { tab: (typeof LINT_TABS)[number] }) => {
let count = 0
let label = ''
if (tab.id === LINTER_LEVELS.ERROR) {
count = errorLintsCount
label = 'errors'
}
if (tab.id === LINTER_LEVELS.WARN) {
count = warnLintsCount
label = 'warnings'
}
if (tab.id === LINTER_LEVELS.INFO) {
count = infoLintsCount
label = 'suggestions'
}
return (
<span className="text-xs text-foreground-muted group-hover:text-foreground-lighter group-data-[state=active]:text-foreground-lighter transition">
{isLoading ? (
<ShimmeringLoader className="w-20 pt-1" />
) : (
<>
{count} {label}
</>
)}
</span>
)
}
return (
<Tabs_Shadcn_
defaultValue={currentTab}
onValueChange={(value) => {
setCurrentTab(value as LINTER_LEVELS)
const { sort, search, ...rest } = router.query
router.push({ ...router, query: { ...rest, preset: value, id: null } })
}}
>
<TabsList_Shadcn_ className={cn('flex gap-0 border-0 items-end z-10 relative')}>
{LINT_TABS.map((tab) => (
<TabsTrigger_Shadcn_
key={tab.id}
value={tab.id}
className={cn(
'group relative',
'px-6 py-3 border-b-0 flex flex-col items-start shadow-none! border-default border-t',
'even:border-x last:border-r even:border-x-strong! last:border-r-strong!',
tab.id === currentTab ? 'bg-surface-200!' : 'bg-surface-200/33!',
'hover:bg-surface-100!',
'data-[state=active]:bg-surface-200!',
'hover:text-foreground-light',
'transition'
)}
>
{tab.id === currentTab && (
<div className="absolute top-0 left-0 w-full h-px bg-foreground" />
)}
<div className="flex items-center gap-x-2">
<span
className={
tab.id === LINTER_LEVELS.ERROR
? 'text-destructive-600'
: tab.id === LINTER_LEVELS.WARN
? 'text-warning'
: 'text-brand-500'
}
>
<MessageSquareMore size={14} fill="currentColor" strokeWidth={0} />
</span>
<span className="">{tab.label}</span>
<Tooltip>
<TooltipTrigger asChild>
<InformationCircleIcon className="transition text-foreground-muted w-3 h-3 data-[state=delayed-open]:text-foreground-light" />
</TooltipTrigger>
<TooltipContent side="top">{tab.description}</TooltipContent>
</Tooltip>
</div>
<LintCountLabel tab={tab} />
</TabsTrigger_Shadcn_>
))}
</TabsList_Shadcn_>
</Tabs_Shadcn_>
)
}
export default LintPageTabs