-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eea6df0
commit a54d74d
Showing
7 changed files
with
102 additions
and
44 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
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,70 +1,54 @@ | ||
import styled from 'styled-components'; | ||
import { theme } from '@interlay/theme'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
const StyledTable = styled.table` | ||
width: 100%; | ||
border-collapse: separate; | ||
border-spacing: 0; | ||
isolation: isolate; | ||
border: ${theme.table.border}; | ||
border-radius: 4px; | ||
overflow: hidden; | ||
${({ theme }) => theme.table.base}; | ||
`; | ||
|
||
const StyledTableColumnHeader = styled.th` | ||
color: ${theme.colors.textTertiary}; | ||
font-size: ${theme.text.s}; | ||
line-height: ${theme.lineHeight.s}; | ||
font-weight: ${theme.fontWeight.bold}; | ||
padding: ${theme.spacing.spacing4} 0; | ||
text-align: left; | ||
position: relative; | ||
padding-left: ${theme.spacing.spacing4}; | ||
&:last-of-type { | ||
text-align: right; | ||
padding-right: ${theme.spacing.spacing4}; | ||
} | ||
${({ theme }) => theme.table.columnHeader}; | ||
`; | ||
|
||
const StyledTableCell = styled.td` | ||
color: ${theme.colors.textPrimary}; | ||
padding-top: ${theme.spacing.spacing4}; | ||
padding-bottom: ${theme.spacing.spacing4}; | ||
vertical-align: middle; | ||
padding-left: ${theme.spacing.spacing4}; | ||
&:last-of-type { | ||
text-align: right; | ||
padding-right: ${theme.spacing.spacing4}; | ||
} | ||
${({ theme }) => theme.table.cell}; | ||
`; | ||
|
||
const StyledTableHeaderRow = styled.tr` | ||
background-color: ${theme.table.header.bg}; | ||
${({ theme }) => theme.table.headerRow}; | ||
`; | ||
|
||
type StyledTableRowProps = { | ||
$isHovered: boolean; | ||
$isSelected: boolean; | ||
}; | ||
|
||
const StyledTableRow = styled.tr<StyledTableRowProps>` | ||
outline: none; | ||
font-size: ${theme.text.s}; | ||
line-height: ${theme.lineHeight.s}; | ||
cursor: ${({ $isHovered }) => $isHovered && 'pointer'}; | ||
&:nth-child(odd) { | ||
background-color: ${({ $isHovered }) => ($isHovered ? theme.table.row.bgHover : theme.table.row.odd.bg)}; | ||
} | ||
${({ theme, $isHovered, $isSelected }) => { | ||
const { even, odd, selected } = theme.table.row; | ||
&:nth-child(even) { | ||
background-color: ${({ $isHovered }) => ($isHovered ? theme.table.row.bgHover : theme.table.row.even.bg)}; | ||
} | ||
return css` | ||
&:nth-child(odd) { | ||
${$isSelected ? selected : $isHovered ? odd.hover : odd.base}; | ||
} | ||
&:focus-visible { | ||
background-color: ${theme.table.row.bgHover}; | ||
} | ||
&:nth-child(even) { | ||
${$isSelected ? selected : $isHovered ? even.hover : even.base}; | ||
} | ||
`; | ||
}}; | ||
`; | ||
|
||
export { StyledTable, StyledTableCell, StyledTableColumnHeader, StyledTableHeaderRow, StyledTableRow }; |
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,3 +1,21 @@ | ||
type TableTheme = {}; | ||
import { StyledObject } from 'styled-components'; | ||
|
||
type TableTheme = { | ||
base: StyledObject<object>; | ||
columnHeader: StyledObject<object>; | ||
cell: StyledObject<object>; | ||
headerRow: StyledObject<object>; | ||
row: { | ||
odd: { | ||
base: StyledObject<object>; | ||
hover: StyledObject<object>; | ||
}; | ||
even: { | ||
base: StyledObject<object>; | ||
hover: StyledObject<object>; | ||
}; | ||
selected: StyledObject<object>; | ||
}; | ||
}; | ||
|
||
export type { TableTheme }; |
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,5 +1,58 @@ | ||
import { hexToRgba } from '../../utils'; | ||
import { fontWeight, spacing, typography } from '../../core'; | ||
import { TableTheme } from '../../components'; | ||
|
||
const table: TableTheme = {}; | ||
import { color } from './colors'; | ||
|
||
const table: TableTheme = { | ||
base: {}, | ||
columnHeader: { | ||
paddingTop: spacing('lg'), | ||
paddingLeft: spacing('lg'), | ||
paddingBottom: spacing('lg'), | ||
color: color('light'), | ||
fontWeight: fontWeight('bold'), | ||
...typography('xs'), | ||
'&:last-of-type': { | ||
textAlign: 'right', | ||
paddingRight: spacing('lg') | ||
} | ||
}, | ||
cell: { | ||
paddingTop: spacing('md'), | ||
paddingLeft: spacing('md'), | ||
paddingBottom: spacing('md'), | ||
color: color('light'), | ||
...typography('s'), | ||
'&:last-of-type': { | ||
textAlign: 'right', | ||
paddingRight: spacing('md') | ||
} | ||
}, | ||
headerRow: { | ||
backgroundColor: color('grey-800') | ||
}, | ||
row: { | ||
odd: { | ||
base: { | ||
backgroundColor: color('grey-500') | ||
}, | ||
hover: { | ||
backgroundColor: hexToRgba(color('grey-500'), 70) | ||
} | ||
}, | ||
even: { | ||
base: { | ||
backgroundColor: color('grey-700') | ||
}, | ||
hover: { | ||
backgroundColor: hexToRgba(color('grey-700'), 70) | ||
} | ||
}, | ||
selected: { | ||
backgroundColor: hexToRgba(color('primary-500'), 50) | ||
} | ||
} | ||
}; | ||
|
||
export { table }; |