Skip to content

Commit

Permalink
feat(Table): Add components for tables (Table, Head, Row, Cell)
Browse files Browse the repository at this point in the history
Four new simple components for creating nice tables. These components have only style, and as such you should create your own component which holds state. The components are:
Table
    - no props
    - wraps all other table components
Head
    - first child of Table, contains column headings as Cells
    - no props
Row
    - The active prop will highlight a row.
Cell
    - The active prop will underline Cell text and change pointer. Use
      this with a clickable cell
  • Loading branch information
Ilari Sinkkonen committed Jun 8, 2017
1 parent 430ed02 commit f23747c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/components/Table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import styled from 'styled-components';

import colorGetter from './colorGetter';
import { Layout, Box } from './Layout';

export const Table = styled.div`
display: flex;
flex-direction: column;
margin-top: 16px;
`;
export const Row = styled(Layout)`
font-size: 0.9rem;
${props => props.active &&
`background-color: ${colorGetter(props, 'primaryColorLightest')};`}
&:nth-child(odd) {
background-color: ${props => colorGetter(props, 'greyLightest')};
${props => props.active &&
`background-color: ${colorGetter(props, 'primaryColorLightest')};`}
}
`;
export const Head = styled(Layout)`
border-bottom: 1px solid ${props => colorGetter(props, 'greyLight')};
font-size: 0.9rem;
color: ${props => colorGetter(props, 'primaryColor')};
`;
export const Cell = styled(Box)`
padding: 16px 8px;
${props => props.active && 'text-decoration: underline;'}
${props => props.active && 'cursor: pointer;'}
`;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export { default as Heading } from './components/Heading';
export { Layout, Box } from './components/Layout';
export { default as media } from './components/media';
export { default as withRipple } from './components/withRipple';
export { Table, Head, Row, Cell } from './components/Table';

0 comments on commit f23747c

Please sign in to comment.