fix(site): style overflowing tables

This commit is contained in:
Darius Cepulis
2026-01-27 13:50:06 -08:00
parent a5f73c755e
commit 432b662440
2 changed files with 37 additions and 12 deletions
+29 -11
View File
@@ -1,17 +1,35 @@
---
import type { HTMLTag, Polymorphic } from "astro/types";
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import type { HTMLTag, Polymorphic } from 'astro/types';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
type Props<Tag extends HTMLTag = 'table'> = Polymorphic<{ as: Tag }> & {
maxWidth?: boolean;
class?: string;
type Props<Tag extends HTMLTag = "table"> = Polymorphic<{ as: Tag }> & {
maxWidth?: boolean;
class?: string;
};
const { as: Tag = 'table', maxWidth = true, class: className, ...props } = Astro.props;
const {
as: Tag = "table",
maxWidth = true,
class: className,
...props
} = Astro.props;
---
<Tag class={twMerge(clsx('w-full my-12 border-collapse', maxWidth && 'max-w-3xl mx-auto'), className)} {...props}>
<slot />
</Tag>
<div class={clsx("my-12", maxWidth && "mx-auto max-w-3xl")}>
<div class="overflow-x-auto flex -mx-6">
<div
class="sticky left-0 z-10 shrink-0 basis-6 bg-linear-to-r from-light-80 dark:from-dark-80 to-transparent pointer-events-none"
aria-hidden="true"
>
</div>
<Tag class={twMerge("w-full border-collapse", className)} {...props}>
<slot />
</Tag>
<div
class="sticky right-0 z-10 shrink-0 basis-6 bg-linear-to-l from-light-80 dark:from-dark-80 to-transparent pointer-events-none"
aria-hidden="true"
>
</div>
</div>
</div>
@@ -149,6 +149,13 @@ The blockquote element represents content that is quoted from another source, op
| --------- | -------- | ------ |
| _italics_ | **bold** | `code` |
When a table is really wide, it overflows nicely on mobile
| A | Table | With | A | Lot | Of | Columns |
| --- | --- | --- | --- | --- | --- | --- |
| contentcontentcontent | contentcontentcontent | contentcontentcontent | contentcontentcontent | contentcontentcontent | contentcontentcontent | contentcontentcontent |
### Code Blocks
we can use 3 backticks ``` in new line and write snippet and close with 3 backticks on new line and to highlight language specific syntax, write one word of language name after first 3 backticks, for eg. html, javascript, css, markdown, typescript, txt, bash
@@ -445,4 +452,4 @@ import ServerCode from '@/components/Code/ServerCode.astro';
</TabsPanel>
<MyDemo client:visible />
</TabsRoot>
```
```