Skip to content

Commit 432b662

Browse files
committed
fix(site): style overflowing tables
1 parent a5f73c7 commit 432b662

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
---
2+
import type { HTMLTag, Polymorphic } from "astro/types";
3+
import { clsx } from "clsx";
4+
import { twMerge } from "tailwind-merge";
25
3-
import type { HTMLTag, Polymorphic } from 'astro/types';
4-
import { clsx } from 'clsx';
5-
import { twMerge } from 'tailwind-merge';
6-
7-
type Props<Tag extends HTMLTag = 'table'> = Polymorphic<{ as: Tag }> & {
8-
maxWidth?: boolean;
9-
class?: string;
6+
type Props<Tag extends HTMLTag = "table"> = Polymorphic<{ as: Tag }> & {
7+
maxWidth?: boolean;
8+
class?: string;
109
};
1110
12-
const { as: Tag = 'table', maxWidth = true, class: className, ...props } = Astro.props;
11+
const {
12+
as: Tag = "table",
13+
maxWidth = true,
14+
class: className,
15+
...props
16+
} = Astro.props;
1317
---
1418

15-
<Tag class={twMerge(clsx('w-full my-12 border-collapse', maxWidth && 'max-w-3xl mx-auto'), className)} {...props}>
16-
<slot />
17-
</Tag>
19+
<div class={clsx("my-12", maxWidth && "mx-auto max-w-3xl")}>
20+
<div class="overflow-x-auto flex -mx-6">
21+
<div
22+
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"
23+
aria-hidden="true"
24+
>
25+
</div>
26+
<Tag class={twMerge("w-full border-collapse", className)} {...props}>
27+
<slot />
28+
</Tag>
29+
<div
30+
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"
31+
aria-hidden="true"
32+
>
33+
</div>
34+
</div>
35+
</div>

site/src/content/docs/how-to/write-guides.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ The blockquote element represents content that is quoted from another source, op
149149
| --------- | -------- | ------ |
150150
| _italics_ | **bold** | `code` |
151151

152+
When a table is really wide, it overflows nicely on mobile
153+
154+
| A | Table | With | A | Lot | Of | Columns |
155+
| --- | --- | --- | --- | --- | --- | --- |
156+
| contentcontentcontent | contentcontentcontent | contentcontentcontent | contentcontentcontent | contentcontentcontent | contentcontentcontent | contentcontentcontent |
157+
158+
152159
### Code Blocks
153160

154161
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';
445452
</TabsPanel>
446453
<MyDemo client:visible />
447454
</TabsRoot>
448-
```
455+
```

0 commit comments

Comments
 (0)