-
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.
- Loading branch information
1 parent
01a5314
commit 1b7ca11
Showing
4 changed files
with
79 additions
and
20 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,11 +1,26 @@ | ||
import { css, type SerializedStyles } from '@emotion/react'; | ||
import type { Theme } from 'theme'; | ||
|
||
import type { TRProps } from './TR'; | ||
|
||
export const trContainer = | ||
({ sx }: Pick<TRProps, 'sx'>) => | ||
(): SerializedStyles => { | ||
({ isSelected, isSelectable, sx }: Pick<TRProps, 'sx' | 'isSelectable' | 'isSelected'>) => | ||
(theme: Theme): SerializedStyles => { | ||
return css` | ||
${isSelectable && | ||
` | ||
cursor: pointer; | ||
&:hover { | ||
background: ${theme.tokens.colors.get('palette.tertiary.muted')}; | ||
} | ||
`} | ||
${isSelected && | ||
` | ||
background: ${theme.tokens.colors.get('palette.tertiary.contrast')}; | ||
`} | ||
${sx}; | ||
`; | ||
}; |
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,16 +1,31 @@ | ||
import type { CSSObject } from '@emotion/react'; | ||
import React from 'react'; | ||
import isEqual from 'react-fast-compare'; | ||
import type { DivProps } from 'utils/common'; | ||
|
||
import { trContainer } from './TR.style'; | ||
|
||
export type TRProps = { | ||
/** Whether the row is selected */ | ||
isSelected?: boolean; | ||
/** Whether the row is selectable */ | ||
isSelectable?: boolean; | ||
/** Style overrides */ | ||
sx?: CSSObject; | ||
}; | ||
|
||
const TR: React.FCC<TRProps> = ({ sx, children }) => { | ||
return <tr css={trContainer({ sx })}>{children}</tr>; | ||
const TR: React.FCC<TRProps & Pick<DivProps, 'onClick'>> = ({ | ||
onClick, | ||
isSelected, | ||
isSelectable, | ||
sx, | ||
children, | ||
}) => { | ||
return ( | ||
<tr onClick={onClick} css={trContainer({ isSelected, isSelectable, sx })}> | ||
{children} | ||
</tr> | ||
); | ||
}; | ||
|
||
export default React.memo(TR, isEqual); |