-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: legg til tabelleksempel above the fold
affects: @fremtind/jkl-table-react
- Loading branch information
Showing
3 changed files
with
90 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { ExampleComponentProps } from "doc-utils"; | ||
import React, { VFC } from "react"; | ||
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "../src"; | ||
|
||
const columns = ["Dato", "Saksnummer", "Kundenummer", "Kundenavn", "Milepæl", "Følger saken"]; | ||
|
||
const rows = [ | ||
["24.02.2020", "20-1234567", "010203 99887", "Ola Nordmann", "Opprettet", "Siri Saksbehandler"], | ||
["13.04.2019", "20-8382811", "010203 99887", "Kari Nordkvinne", "Opprettet", "Siri Saksbehandler"], | ||
["31.07.2017", "20-1111", "010203 99887", "Kari Nordkvinne", "Opprettet", "Per Persen"], | ||
]; | ||
|
||
const TableExample: VFC<ExampleComponentProps> = ({ boolValues }) => { | ||
return ( | ||
<Table compact={boolValues?.["Kompakt"]} fullWidth> | ||
<TableCaption srOnly>Overskrift for skjermlesere</TableCaption> | ||
<TableHead> | ||
<TableRow> | ||
{columns.map((column, index) => ( | ||
<TableHeader key={index}>{column}</TableHeader> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{rows.map((row, rowIndex) => ( | ||
<TableRow key={rowIndex}> | ||
{row.map((cell, cellIndex) => ( | ||
<TableCell key={cellIndex}>{cell}</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
); | ||
}; | ||
|
||
export default TableExample; | ||
|
||
export const tableExampleCode = ({ boolValues }: ExampleComponentProps): string => ` | ||
const columnHeaders = ["Dato", "Saksnummer", "Kundenummer", "Kundenavn", "Milepæl", "Følger saken"]; | ||
const rows = [ | ||
["24.02.2020", "20-1234567", "010203 99887", "Ola Nordmann", "Opprettet", "Siri Saksbehandler"], | ||
["13.04.2019", "20-8382811", "010203 99887", "Kari Nordkvinne", "Opprettet", "Siri Saksbehandler"], | ||
["31.07.2017", "20-1111", "010203 99887", "Kari Nordkvinne", "Opprettet", "Per Persen"], | ||
]; | ||
<Table compact={${boolValues?.["Kompakt"]}} fullWidth> | ||
<TableCaption srOnly>Overskrift for skjermlesere</TableCaption> | ||
<TableHead> | ||
<TableRow> | ||
{columnHeaders.map((header, index) => ( | ||
<TableHeader key={index}> | ||
{header} | ||
</TableHeader> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{rows.map((row, rowIndex) => ( | ||
<TableRow key={rowIndex}> | ||
{row.map((cell, cellIndex) => ( | ||
<TableCell key={cellIndex}>{cell}</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters