Files
Anthony Lio 2e861b5415 fix(docs): guides table overflow (#50221)
## What kind of change does this PR introduce?

bug fix of table usage within guides

## What is the current behavior?

table markup is used within the observability guide causing overflow of
the content

## What is the new behavior?

favors table component usage within mdx guide to fix the overflow and
enable scroll

| state | preview |
| -------|------|
| before | <img width="1171" height="668" alt="image"
src="https://github.com/user-attachments/assets/bdbb905e-0ea9-4cde-b20b-84b4ef9a4137"
/> |
| after | <img width="1171" height="668" alt="image"
src="https://github.com/user-attachments/assets/9e062222-1dad-49da-bdbe-616d89703301"
/> |

## Test
1. visit
[/docs/guides/observability/log-field-reference](https://supabase.com/docs/guides/observability/log-field-reference?queryGroups=source&source=edge_logs)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
  - Improved table rendering in the log field reference documentation.
- Updated documentation tables to use the shared table presentation for
a more consistent layout.


<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-11 17:40:53 +03:00

46 lines
1.3 KiB
TypeScript

'use client'
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