Skip to content

Commit 4988ad5

Browse files
authored
docs: add responsive markdown tables (#2875)
* docs: add responsive markdown tables * Lint files Signed-off-by: gpbl <[email protected]> --------- Signed-off-by: gpbl <[email protected]>
1 parent e851689 commit 4988ad5

File tree

6 files changed

+60
-22
lines changed

6 files changed

+60
-22
lines changed

website/docs/selections/multiple-mode.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Set the `mode` prop to `"multiple"` to enable the selection of multiple dates in
1414
<Examples.Multiple />
1515
</BrowserWindow>
1616

17-
## Props
17+
## Multiple Mode Props
1818

1919
| Prop Name | Type | Description |
2020
| ---------- | -------------------------------------------------------------------------------- | ------------------------------------------------- |

website/docs/selections/range-mode.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Set the `mode` prop to `"range"` to enable the selection of a continuous range o
1414
<Examples.Range />
1515
</BrowserWindow>
1616

17-
## Props
17+
## Range Mode Props
1818

1919
| Prop Name | Type | Description |
2020
| ----------------- | ----------------------------------------------------------------------------------- | ------------------------------------------ |

website/docs/selections/single-mode.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ When the `mode` prop is set to `"single"`, only one date can be selected at a ti
1414
<Examples.Single />
1515
</BrowserWindow>
1616

17-
## Props
17+
## Single Mode Props
1818

19-
| Prop Name | Type | Description |
20-
| ---------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------- |
21-
| `selected` | `Date \| undefined` ([MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)) | The selected date. |
22-
| `onSelect` | [`OnSelectHandler<Date \| undefined>`](../api/type-aliases/OnSelectHandler.md) | Event callback when a date is selected. |
23-
| `required` | `boolean` | Make the selection required. |
19+
| Prop Name | Type | Description |
20+
| ---------- | ------------------------------------------------------------------------------ | --------------------------------------- |
21+
| `selected` | `Date \| undefined` | The selected date. |
22+
| `onSelect` | [`OnSelectHandler<Date \| undefined>`](../api/type-aliases/OnSelectHandler.md) | Event callback when a date is selected. |
23+
| `required` | `boolean` | Make the selection required. |
2424

2525
## Controlled Selections
2626

website/src/css/markdown.css

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.markdown {
22
min-height: calc(100vh - var(--ifm-navbar-height) - 17rem);
3+
--doc-table-min-width: 640px;
34
}
45

56
.markdown a {
@@ -56,9 +57,9 @@
5657

5758
.markdown table {
5859
margin: 2rem 0;
59-
display: table;
6060
width: 100%;
6161
font-size: 0.875rem;
62+
display: table;
6263
}
6364

6465
.markdown table tr {
@@ -77,12 +78,33 @@
7778
font-weight: 600;
7879
background-color: unset !important;
7980
text-align: left;
81+
white-space: nowrap;
8082
}
8183

8284
.markdown table thead tr {
8385
border-bottom-width: 1px;
8486
}
8587

88+
@media (max-width: 995px) {
89+
.table-scroll {
90+
margin: 2rem 0;
91+
padding-bottom: 0.5rem;
92+
}
93+
94+
.table-scroll table {
95+
margin: 0;
96+
}
97+
98+
.table-scroll {
99+
overflow-x: auto;
100+
-webkit-overflow-scrolling: touch;
101+
}
102+
103+
.table-scroll table {
104+
min-width: var(--doc-table-min-width);
105+
}
106+
}
107+
86108
.markdown details {
87109
font-size: 0.875rem;
88110
}

website/src/theme/MDXComponents.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Import the original mapper
2+
import MDXComponents from "@theme-original/MDXComponents";
3+
import type { ComponentProps, ComponentType } from "react";
4+
import * as Examples from "react-day-picker/examples";
5+
6+
import * as ExamplesV8 from "../../examples-v8";
7+
import { BrowserWindow } from "../components/BrowserWindow";
8+
9+
type TableComponent = ComponentType<ComponentProps<"table">>;
10+
11+
const Table: TableComponent =
12+
(MDXComponents as { table?: TableComponent }).table ??
13+
((props) => <table {...props} />);
14+
15+
function ResponsiveTable(props: ComponentProps<typeof Table>) {
16+
return (
17+
<div className="table-scroll" role="presentation">
18+
<Table {...props} />
19+
</div>
20+
);
21+
}
22+
23+
export default {
24+
...MDXComponents,
25+
table: ResponsiveTable,
26+
BrowserWindow,
27+
Examples,
28+
ExamplesV8,
29+
};

0 commit comments

Comments
 (0)