Files
supabase/apps/docs/components/Table.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

44 lines
1.3 KiB
TypeScript

import React, { TableHTMLAttributes, useEffect, useRef, useState } from 'react'
import { cn } from 'ui'
type TableProps = TableHTMLAttributes<HTMLTableElement>
const Table = ({ children, ...props }: TableProps) => {
const containerRef = useRef<HTMLDivElement>(null)
const [showShadow, setShowShadow] = useState(true)
const handleScroll = () => {
const container = containerRef.current
if (container) {
const { scrollWidth, scrollLeft, offsetWidth } = container
const isAtEnd = scrollWidth - scrollLeft - 2 < offsetWidth
setShowShadow(!isAtEnd)
}
}
useEffect(() => {
const container = containerRef.current
if (container) {
container.addEventListener('scroll', handleScroll)
return () => container.removeEventListener('scroll', handleScroll)
}
}, [])
return (
<div className="relative">
<span
className={cn(
'block md:hidden absolute inset-0 left-auto w-5 bg-linear-to-r from-transparent to-background transition-opacity opacity-100',
!showShadow && 'opacity-0 duration-300'
)}
/>
<div ref={containerRef} className="w-full overflow-x-auto break-normal">
<table {...props}>{children}</table>
</div>
</div>
)
}
export default Table