-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from dabapps/tables
Tables
- Loading branch information
Showing
15 changed files
with
839 additions
and
12 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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
#!/bin/bash -l | ||
#!/usr/bin/env bash | ||
|
||
. /root/.nvm/nvm.sh | ||
|
||
set -e | ||
|
||
nvm install | ||
|
||
npm install | ||
|
||
npm test | ||
npm run dist | ||
npm run build |
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
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,179 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
CodeBlock, | ||
Column, | ||
Row, | ||
Section, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow | ||
} from '../../../src/ts'; | ||
|
||
const data = [ | ||
['', 'Column header 1', 'Column header 2', 'Column header 3', 'Column header 4', 'Column header 5'], | ||
['Row header 1', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'], | ||
['Row header 2', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'], | ||
['Row header 3', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'], | ||
['Row header 4', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'], | ||
['Row header 5', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'] | ||
]; | ||
|
||
const [ headers = [], ...body ] = data; | ||
const smallBody = [...body].splice(0, 2); | ||
|
||
const COLUMN_HEADER_WIDTH = 150; | ||
|
||
export const Tables = () => { | ||
return ( | ||
<Section> | ||
<Row> | ||
<Column> | ||
<h2> | ||
Tables | ||
</h2> | ||
</Column> | ||
</Row> | ||
<Row> | ||
<Column> | ||
<h3> | ||
Demo | ||
</h3> | ||
<Table bordered condensed> | ||
<TableBody> | ||
{ | ||
smallBody.map((row = [], rowIndex) => ( | ||
<TableRow key={rowIndex + row.join()}> | ||
{ | ||
row.map((cell) => ( | ||
<TableCell key={cell}> | ||
{cell} | ||
</TableCell> | ||
)) | ||
} | ||
</TableRow> | ||
)) | ||
} | ||
</TableBody> | ||
</Table> | ||
|
||
<Table striped hover fill fixColumnHeaders columnHeaderMaxWidth={COLUMN_HEADER_WIDTH}> | ||
<TableHead> | ||
<TableRow> | ||
{ | ||
headers.map((header, index) => index === 0 ? ( | ||
<TableHeader key={header} maxWidth={COLUMN_HEADER_WIDTH} /> | ||
) : ( | ||
<TableHeader key={header}> | ||
{header} | ||
</TableHeader> | ||
)) | ||
} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{ | ||
body.map((row = [], rowIndex) => ( | ||
<TableRow key={rowIndex + row.join()}> | ||
{ | ||
row.map((cell, index) => index === 0 ? ( | ||
<TableHeader key={cell} maxWidth={COLUMN_HEADER_WIDTH}> | ||
{cell} | ||
</TableHeader> | ||
) : ( | ||
<TableCell key={cell}> | ||
{cell} | ||
</TableCell> | ||
)) | ||
} | ||
</TableRow> | ||
)) | ||
} | ||
</TableBody> | ||
</Table> | ||
</Column> | ||
</Row> | ||
<Row> | ||
<Column> | ||
<h3> | ||
Code | ||
</h3> | ||
<CodeBlock language="javascript"> | ||
{` | ||
const data = [ | ||
['', 'Column header 1', 'Column header 2', 'Column header 3', 'Column header 4', 'Column header 5'], | ||
['Row header 1', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'], | ||
['Row header 2', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'], | ||
['Row header 3', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'], | ||
['Row header 4', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'], | ||
['Row header 5', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4', 'Cell 5'] | ||
]; | ||
const [ headers = [], ...body ] = data; | ||
const smallBody = [...body].splice(0, 2); | ||
`} | ||
</CodeBlock> | ||
<CodeBlock language="javascript"> | ||
{` | ||
<Table bordered condensed> | ||
<TableBody> | ||
{ | ||
smallBody.map((row = [], rowIndex) => ( | ||
<TableRow key={rowIndex + row.join()}> | ||
{ | ||
row.map((cell) => ( | ||
<TableCell key={cell}> | ||
{cell} | ||
</TableCell> | ||
)) | ||
} | ||
</TableRow> | ||
)) | ||
} | ||
</TableBody> | ||
</Table> | ||
<Table striped hover fill fixColumnHeaders columnHeaderMaxWidth={COLUMN_HEADER_WIDTH}> | ||
<TableHead> | ||
<TableRow> | ||
{ | ||
headers.map((header, index) => index === 0 ? ( | ||
<TableHeader key={header} maxWidth={COLUMN_HEADER_WIDTH} /> | ||
) : ( | ||
<TableHeader key={header}> | ||
{header} | ||
</TableHeader> | ||
)) | ||
} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{ | ||
body.map((row = [], rowIndex) => ( | ||
<TableRow key={rowIndex + row.join()}> | ||
{ | ||
row.map((cell, index) => index === 0 ? ( | ||
<TableHeader key={cell} maxWidth={COLUMN_HEADER_WIDTH}> | ||
{cell} | ||
</TableHeader> | ||
) : ( | ||
<TableCell key={cell}> | ||
{cell} | ||
</TableCell> | ||
)) | ||
} | ||
</TableRow> | ||
)) | ||
} | ||
</TableBody> | ||
</Table> | ||
`} | ||
</CodeBlock> | ||
</Column> | ||
</Row> | ||
</Section> | ||
); | ||
}; |
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
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
Oops, something went wrong.