Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(table): fix example and change iframe title #201

Merged
merged 2 commits into from
Jul 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions website/docs/table/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,52 @@ title: Example
[View Source on GitHub](https://github.com/h6s-dev/h6s/blob/main/examples/react/src/pages/table/index.tsx)

```tsx
import { useCalendar } from '@h6s/calendar'
import { useTable } from '@h6s/table'

export default function Calendar() {
const { headers, body, view } = useCalendar()
export default function Table() {
const [{ theadGroups, rows }, controls] = useTable({
model: myTableModel,
source: products,
})

return (
<Table>
<Thead>
<Tr>
{headers.weekDays.map(({ key, value }) => {
return <Th key={key}>{format(value, 'E', { locale })}</Th>
})}
</Tr>
</Thead>
<Tbody>
{body.value.map(({ key, value: days }) => (
<Tr key={key}>
{days.map(({ key, value }) => (
<Td key={key}>{getDate(value)}</Td>
))}
</Tr>
))}
</Tbody>
</Table>
<table>
<thead>
{theadGroups.map(({ theads, getRowProps }) => {
const props = getRowProps()

return (
<tr key={props.id} {...props}>
{theads.map(head => (
<th>{head.render({ cellProps: head })}</th>
))}
</tr>
)
})}
</thead>
<tbody>
{rows.map(({ cells, getRowProps }) => {
const props = getRowProps()

return (
<tr key={props.id} {...props}>
{cells.map(cell => (
cell.colSpan !== 0
? <td key={cell.id}>{cell.render({ cellProps: cell })}</td>
: null
)}
</tr>
)
})}
</tbody>
</table>
)
}
```

<iframe
src="https://react-examples.h6s.dev/table"
title="@h6s/calendar example"
title="@h6s/table example"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
style={{
Expand Down