From 19de40450d7b357272c267fed230b02a70e0694c Mon Sep 17 00:00:00 2001 From: Bram Vanhoutte Date: Sat, 25 Jul 2020 16:07:05 +0200 Subject: [PATCH] docs(Table): write initial docs --- src/components/Table/Table.mdx | 65 +++++++++++++++++-- .../Table/TableCell/TableCell.module.css | 16 ++++- src/components/Table/TableCell/TableCell.tsx | 16 ++++- .../TableHeaderCell.module.css | 17 ++++- .../Table/TableHeaderCell/TableHeaderCell.tsx | 18 ++++- 5 files changed, 117 insertions(+), 15 deletions(-) diff --git a/src/components/Table/Table.mdx b/src/components/Table/Table.mdx index dcdc6e9a..e2845752 100644 --- a/src/components/Table/Table.mdx +++ b/src/components/Table/Table.mdx @@ -5,7 +5,7 @@ route: /table --- import { Playground, Props } from 'docz'; -import { Table } from '../..'; +import { Table, Button, CheckCircle, Circle, PauseCircle, Share2 } from '../..'; # Table @@ -30,27 +30,78 @@ Use the different building block to correctly structure your table: - First name + Course - Last name + Length + + + Status - Bram + Introduction To React - Vanhoutte + 2h 27m + + + Finished + + + + {' '} + + + + + + Introduction To Docker + + + 33m + + + Not started + + + + {' '} + - Robin + Introduction To Python - Wijnant + 1h 45m + + + Not started + + + + {' '} + + + + + + Introduction To Ventura + + + 15m + + + In progress + + + + {' '} + diff --git a/src/components/Table/TableCell/TableCell.module.css b/src/components/Table/TableCell/TableCell.module.css index f809ddcd..6372ff5d 100644 --- a/src/components/Table/TableCell/TableCell.module.css +++ b/src/components/Table/TableCell/TableCell.module.css @@ -2,7 +2,21 @@ text-align: left; height: 32px; line-height: 32px; - padding: 0 14px; + padding-left: 14px; + padding-right: 6px; + vertical-align: middle; +} + +.cellAlignLeft { + text-align: left; +} + +.cellAlignRight { + text-align: right; +} + +.cellAlignCenter { + text-align: center; } .cell:hover ~ .cell { diff --git a/src/components/Table/TableCell/TableCell.tsx b/src/components/Table/TableCell/TableCell.tsx index c329b251..b9d02091 100644 --- a/src/components/Table/TableCell/TableCell.tsx +++ b/src/components/Table/TableCell/TableCell.tsx @@ -7,13 +7,23 @@ type Props = { className?: string; children?: React.ReactNode; colSpan?: number; + align?: 'center' | 'left' | 'right'; }; -const TableCell: React.FC = ({ className, children, colSpan }: Props) => { - const tableClassNames = classNames(styles.cell, styles.row, className); +const TableCell: React.FC = ({ className, children, colSpan, align = 'left' }: Props) => { + const tableCellClassNames = classNames( + { + [styles.cellAlignLeft]: align === 'left', + [styles.cellAlignRight]: align === 'right', + [styles.cellAlignCenter]: align === 'center', + }, + styles.cell, + styles.row, + className, + ); return ( - ); diff --git a/src/components/Table/TableHeaderCell/TableHeaderCell.module.css b/src/components/Table/TableHeaderCell/TableHeaderCell.module.css index 03da701b..27a562c3 100644 --- a/src/components/Table/TableHeaderCell/TableHeaderCell.module.css +++ b/src/components/Table/TableHeaderCell/TableHeaderCell.module.css @@ -1,12 +1,25 @@ .headerCell { background-color: var(--color-primary-hover); - text-align: left; height: 36px; line-height: 36px; - padding: 0 14px; + padding-left: 14px; + padding-right: 6px; color: var(--font-color-sub) } +.cellAlignLeft { + text-align: left; +} + +.cellAlignRight { + text-align: right; +} + +.cellAlignCenter { + text-align: center; +} + + .headerCell:first-child { border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); } diff --git a/src/components/Table/TableHeaderCell/TableHeaderCell.tsx b/src/components/Table/TableHeaderCell/TableHeaderCell.tsx index 60ea1d86..2c4f9fc8 100644 --- a/src/components/Table/TableHeaderCell/TableHeaderCell.tsx +++ b/src/components/Table/TableHeaderCell/TableHeaderCell.tsx @@ -7,10 +7,24 @@ type Props = { className?: string; children?: React.ReactNode; colSpan?: number; + align?: 'center' | 'left' | 'right'; }; -const TableHeaderCell: React.FC = ({ className, children, colSpan }: Props) => { - const tableHeaderCellClassNames = classNames(styles.headerCell, className); +const TableHeaderCell: React.FC = ({ + className, + children, + colSpan, + align = 'left', +}: Props) => { + const tableHeaderCellClassNames = classNames( + { + [styles.cellAlignLeft]: align === 'left', + [styles.cellAlignRight]: align === 'right', + [styles.cellAlignCenter]: align === 'center', + }, + styles.headerCell, + className, + ); return (
+ {children}