-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: desaturate & opacity for unapproved tokens #52
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ function TokenImg({ token, ...rest }: TokenImgProps) { | |
return <img src={src} alt={alt} key={alt} onError={onError} {...rest} /> | ||
} | ||
|
||
export default styled(TokenImg)<{ size?: number }>` | ||
export default styled(TokenImg)<{ size?: number; unapproved?: boolean }>` | ||
// radial-gradient calculates distance from the corner, not the edge: divide by sqrt(2) | ||
background: radial-gradient( | ||
${({ theme }) => theme.module} calc(100% / ${Math.sqrt(2)} - 1.5px), | ||
|
@@ -52,4 +52,6 @@ export default styled(TokenImg)<{ size?: number }>` | |
border-radius: 100%; | ||
height: ${({ size }) => size || 1}em; | ||
width: ${({ size }) => size || 1}em; | ||
|
||
${({ unapproved }) => unapproved && 'filter: grayscale(100%) opacity(60%)'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,11 @@ interface TokenButtonProps { | |
value?: Currency | ||
collapsed: boolean | ||
disabled?: boolean | ||
isUnapprovedToken?: boolean | ||
onClick: () => void | ||
} | ||
|
||
export default function TokenButton({ value, collapsed, disabled, onClick }: TokenButtonProps) { | ||
export default function TokenButton({ value, collapsed, disabled, isUnapprovedToken, onClick }: TokenButtonProps) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same - use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whatever you use here should be passed directly to |
||
const buttonBackgroundColor = useMemo(() => (value ? 'interactive' : 'accent'), [value]) | ||
const contentColor = useMemo(() => (value || disabled ? 'onInteractive' : 'onAccent'), [value, disabled]) | ||
|
||
|
@@ -85,7 +86,7 @@ export default function TokenButton({ value, collapsed, disabled, onClick }: Tok | |
> | ||
{value ? ( | ||
<> | ||
<TokenImg token={value} size={1.2} /> | ||
<TokenImg token={value} size={1.2} unapproved={isUnapprovedToken} /> | ||
{value.symbol} | ||
</> | ||
) : ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call this
approved
do the name doesn't include a boolean modifierThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chose to use
unapproved
so that the default tokenImg isn't unapproved and shows in full saturation; you'd have to explicitly set a tokenImg as unapprovedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading the code correctly, it looks like
approvalState
is this enum:Would you not get the desired behavior if you just pass down approval state to the style, then make the decision about saturation there?
like: