Created
August 23, 2019 20:37
-
-
Save SebastianHGonzalez/37ec87e46dfdc1f45c2bf8e3e2eb6fa4 to your computer and use it in GitHub Desktop.
Styled Components Table
This file contains hidden or 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
import React from "react"; | |
import styled from "styled-components"; | |
import font from "styled/font"; | |
export const Table = styled.table` | |
border-collapse: collapse; | |
background: ${({ theme }) => theme.table.head.background}; | |
`; | |
export const TableHead = styled.thead` | |
color: ${({ theme }) => theme.table.head.backgroundContrast}; | |
text-transform: uppercase; | |
`; | |
export const TableRow = styled.tr``; | |
export const TableBody = styled.tbody` | |
${TableRow} { | |
border-bottom: 1px solid ${({ theme }) => theme.table.separator}; | |
background: ${({ theme }) => theme.table.background}; | |
} | |
${TableRow}:nth-child(2n+2) { | |
background: ${({ theme }) => theme.table.backgroundOdd}; | |
} | |
`; | |
export const TableData = styled.td` | |
${font} | |
padding: 1rem; | |
`; |
This file contains hidden or 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
{ | |
"table": { | |
"head": { | |
"background": "#F0F0F0", | |
"backgroundContrast": "#666" | |
}, | |
"background": "#FFF", | |
"backgroundOdd": "#FAFAFA", | |
"separator": "#D4D4D4" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment