Commit bc90d416 authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

feat: add background-color transitions to table color changes (#4491)

* feat: add background-color transitions to table color changes:

* pr review--use theme transition info
parent 2fd1cd72
...@@ -12,7 +12,7 @@ import { useAtomValue } from 'jotai/utils' ...@@ -12,7 +12,7 @@ import { useAtomValue } from 'jotai/utils'
import { ReactNode } from 'react' import { ReactNode } from 'react'
import { ArrowDown, ArrowUp, Heart } from 'react-feather' import { ArrowDown, ArrowUp, Heart } from 'react-feather'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import styled, { useTheme } from 'styled-components/macro' import styled, { css, useTheme } from 'styled-components/macro'
import { formatDollarAmount } from 'utils/formatDollarAmt' import { formatDollarAmount } from 'utils/formatDollarAmt'
import { import {
...@@ -41,24 +41,37 @@ const Cell = styled.div` ...@@ -41,24 +41,37 @@ const Cell = styled.div`
align-items: center; align-items: center;
justify-content: center; justify-content: center;
` `
const StyledTokenRow = styled.div<{ first?: boolean; last?: boolean }>` const StyledTokenRow = styled.div<{ first?: boolean; last?: boolean; loading?: boolean }>`
width: 100%; background-color: transparent;
height: 60px;
display: grid; display: grid;
grid-template-columns: 1fr 7fr 4fr 4fr 4fr 4fr 5fr 1.2fr;
font-size: 15px; font-size: 15px;
grid-template-columns: 1fr 7fr 4fr 4fr 4fr 4fr 5fr 1.2fr;
height: 60px;
line-height: 24px; line-height: 24px;
max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT}; max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT};
min-width: 390px; min-width: 390px;
padding-top: ${({ first }) => (first ? '4px' : '0px')}; padding-top: ${({ first }) => (first ? '4px' : '0px')};
padding-bottom: ${({ last }) => (last ? '4px' : '0px')}; padding-bottom: ${({ last }) => (last ? '4px' : '0px')};
padding-left: 12px; padding-left: 12px;
padding-right: 12px; padding-right: 12px;
transition: ${({
theme: {
transition: { duration, timing },
},
}) => css`background-color ${duration.medium} ${timing.ease}`};
width: 100%;
&:hover { &:hover {
background-color: ${({ theme }) => theme.accentActionSoft}; ${({ loading, theme }) =>
${({ last }) => last && 'border-radius: 0px 0px 8px 8px;'} !loading &&
css`
background-color: ${theme.accentActionSoft};
`}
${({ last }) =>
last &&
css`
border-radius: 0px 0px 8px 8px;
`}
} }
@media only screen and (max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT}) { @media only screen and (max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT}) {
...@@ -147,6 +160,11 @@ const DataCell = styled(Cell)<{ sortable: boolean }>` ...@@ -147,6 +160,11 @@ const DataCell = styled(Cell)<{ sortable: boolean }>`
justify-content: flex-end; justify-content: flex-end;
min-width: 80px; min-width: 80px;
user-select: ${({ sortable }) => (sortable ? 'none' : 'unset')}; user-select: ${({ sortable }) => (sortable ? 'none' : 'unset')};
transition: ${({
theme: {
transition: { duration, timing },
},
}) => css`background-color ${duration.medium} ${timing.ease}`};
&:hover { &:hover {
color: ${({ theme, sortable }) => sortable && theme.white}; color: ${({ theme, sortable }) => sortable && theme.white};
...@@ -343,9 +361,8 @@ function HeaderCell({ ...@@ -343,9 +361,8 @@ function HeaderCell({
/* Token Row: skeleton row component */ /* Token Row: skeleton row component */
export function TokenRow({ export function TokenRow({
address,
header,
favorited, favorited,
header,
listNumber, listNumber,
tokenInfo, tokenInfo,
price, price,
...@@ -353,20 +370,19 @@ export function TokenRow({ ...@@ -353,20 +370,19 @@ export function TokenRow({
marketCap, marketCap,
volume, volume,
sparkLine, sparkLine,
first, ...rest
last,
}: { }: {
address: ReactNode
header: boolean
favorited: ReactNode favorited: ReactNode
first?: boolean
header: boolean
listNumber: ReactNode listNumber: ReactNode
tokenInfo: ReactNode loading?: boolean
marketCap: ReactNode
price: ReactNode price: ReactNode
percentChange: ReactNode percentChange: ReactNode
marketCap: ReactNode
volume: ReactNode
sparkLine: ReactNode sparkLine: ReactNode
first?: boolean tokenInfo: ReactNode
volume: ReactNode
last?: boolean last?: boolean
}) { }) {
const rowCells = ( const rowCells = (
...@@ -382,18 +398,13 @@ export function TokenRow({ ...@@ -382,18 +398,13 @@ export function TokenRow({
</> </>
) )
if (header) return <StyledHeaderRow>{rowCells}</StyledHeaderRow> if (header) return <StyledHeaderRow>{rowCells}</StyledHeaderRow>
return ( return <StyledTokenRow {...rest}>{rowCells}</StyledTokenRow>
<StyledTokenRow first={first} last={last}>
{rowCells}
</StyledTokenRow>
)
} }
/* Header Row: top header row component for table */ /* Header Row: top header row component for table */
export function HeaderRow() { export function HeaderRow() {
return ( return (
<TokenRow <TokenRow
address={null}
header={true} header={true}
favorited={null} favorited={null}
listNumber="#" listNumber="#"
...@@ -411,10 +422,10 @@ export function HeaderRow() { ...@@ -411,10 +422,10 @@ export function HeaderRow() {
export function LoadingRow() { export function LoadingRow() {
return ( return (
<TokenRow <TokenRow
address={null}
header={false}
favorited={null} favorited={null}
header={false}
listNumber={<SmallLoadingBubble />} listNumber={<SmallLoadingBubble />}
loading
tokenInfo={ tokenInfo={
<> <>
<IconLoadingBubble /> <IconLoadingBubble />
...@@ -476,7 +487,6 @@ export default function LoadedRow({ ...@@ -476,7 +487,6 @@ export default function LoadedRow({
onClick={() => sendAnalyticsEvent(EventName.EXPLORE_TOKEN_ROW_CLICKED, exploreTokenSelectedEventProperties)} onClick={() => sendAnalyticsEvent(EventName.EXPLORE_TOKEN_ROW_CLICKED, exploreTokenSelectedEventProperties)}
> >
<TokenRow <TokenRow
address={tokenAddress}
header={false} header={false}
favorited={ favorited={
<ClickFavorited <ClickFavorited
......
...@@ -43,6 +43,7 @@ const transitions = { ...@@ -43,6 +43,7 @@ const transitions = {
fast: 125, fast: 125,
}, },
timing: { timing: {
ease: 'ease',
in: 'ease-in', in: 'ease-in',
out: 'ease-out', out: 'ease-out',
inOut: 'ease-in-out', inOut: 'ease-in-out',
......
...@@ -149,6 +149,7 @@ declare module 'styled-components/macro' { ...@@ -149,6 +149,7 @@ declare module 'styled-components/macro' {
fast: number fast: number
} }
timing: { timing: {
ease: string
in: string in: string
out: string out: string
inOut: string inOut: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment