Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix docs table overflow issues (#27322)

Francesco Sansalvadore407501b16c00
diff --git a/apps/docs/components/Table.tsx b/apps/docs/components/Table.tsx
new file mode 100644
index 00000000000..f6a75af1db8
--- /dev/null
+++ b/apps/docs/components/Table.tsx
@@ -0,0 +1,40 @@
+import React, { TableHTMLAttributes, useEffect, useRef, useState } from 'react'
+import { cn } from 'ui'
+
+type TableProps = TableHTMLAttributes<HTMLTableElement>
+
+const Table = ({ children, ...props }: TableProps) => {
+ const containerRef = useRef(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(() => {
+ containerRef?.current?.addEventListener('scroll', handleScroll)
+ return () => containerRef?.current?.removeEventListener('scroll', handleScroll)
+ }, [])
+
+ return (
+ <div className="relative">
+ <span
+ className={cn(
+ 'block md:hidden absolute inset-0 left-auto w-5 bg-gradient-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
diff --git a/apps/docs/components/index.tsx b/apps/docs/components/index.tsx
index 76ed777d98d..8fcca7efa37 100644
--- a/apps/docs/components/index.tsx
+++ b/apps/docs/components/index.tsx
@@ -28,6 +28,7 @@ import { CostWarning } from '~/components/AuthSmsProviderConfig/AuthSmsProviderC
import Options from '~/components/Options'
import Param from '~/components/Params'
import { ProjectConfigVariables } from '~/components/ProjectConfigVariables'
+import Table from '~/components/Table'
// Data wrappers
import { NavData } from './NavData'
@@ -163,6 +164,7 @@ const components = {
SocialProviderSetup,
SqlToRest,
StepHikeCompact,
+ table: Table,
TabPanel,
Tabs,
}
diff --git a/apps/docs/styles/main.scss b/apps/docs/styles/main.scss
index 7e86e881477..ea4ff194e60 100644
--- a/apps/docs/styles/main.scss
+++ b/apps/docs/styles/main.scss
@@ -271,3 +271,9 @@ article p code {
.dg.ac {
z-index: 9999 !important;
}
+
+/* tables */
+
+th code {
+ @apply text-nowrap;
+}