-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1463 from kleros/feat(web)/case-cards-indicators
Feat(web)/case cards indicators
- Loading branch information
Showing
22 changed files
with
381 additions
and
10 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { useMemo } from "react"; | ||
import styled, { Theme, useTheme } from "styled-components"; | ||
|
||
const COLORS: Record<string, Array<keyof Theme>> = { | ||
red: ["error", "errorLight"], | ||
green: ["success", "successLight"], | ||
blue: ["primaryBlue", "mediumBlue"], | ||
purple: ["secondaryPurple", "mediumPurple"], | ||
lightPurple: ["tint", "mediumPurple"], | ||
grey: ["secondaryText", "lightGrey"], | ||
}; | ||
|
||
export type IColors = keyof typeof COLORS; | ||
|
||
const LabelContainer = styled.div<{ backgroundColor: string }>` | ||
display: inline-flex; | ||
padding: 4px 8px; | ||
align-items: center; | ||
gap: 10px; | ||
border-radius: 300px; | ||
background-color: ${({ backgroundColor }) => backgroundColor}; | ||
`; | ||
|
||
const IconContainer = styled.div<{ contentColor: string }>` | ||
height: 14px; | ||
width: 14px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
> svg { | ||
fill: ${({ contentColor }) => contentColor}; | ||
} | ||
`; | ||
|
||
const StyledText = styled.label<{ contentColor: string }>` | ||
font-size: 12px; | ||
font-weight: 400; | ||
color: ${({ contentColor }) => contentColor}; | ||
`; | ||
|
||
export interface ILabelProps { | ||
text: string; | ||
icon: React.FC<React.SVGAttributes<SVGElement>>; | ||
color: keyof typeof COLORS; | ||
} | ||
|
||
const Label: React.FC<ILabelProps> = ({ text, icon: Icon, color }) => { | ||
const theme = useTheme(); | ||
const [contentColor, backgroundColor] = useMemo(() => { | ||
return COLORS[color].map((color) => theme[color]); | ||
}, [theme, color]); | ||
|
||
return ( | ||
<LabelContainer {...{ backgroundColor }}> | ||
<IconContainer {...{ contentColor }}> | ||
<Icon /> | ||
</IconContainer> | ||
<StyledText {...{ contentColor }}>{text}</StyledText> | ||
</LabelContainer> | ||
); | ||
}; | ||
|
||
export default Label; |
46 changes: 46 additions & 0 deletions
46
web/src/components/DisputeCard/CardLabels/RewardsAndFundLabel.tsx
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
import styled, { useTheme } from "styled-components"; | ||
import EthIcon from "assets/svgs/icons/eth.svg"; | ||
import PnkIcon from "assets/svgs/icons/kleros.svg"; | ||
import NumberDisplay from "components/NumberDisplay"; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
gap: 4px; | ||
align-items: center; | ||
flex-wrap: wrap; | ||
`; | ||
|
||
const StyledIcon = styled.div<{ color: string }>` | ||
width: 12px; | ||
height: 12px; | ||
path { | ||
fill: ${({ color }) => color}; | ||
} | ||
`; | ||
|
||
const StyledLabel = styled.label<{ color: string }>` | ||
color: ${({ color }) => color}; | ||
`; | ||
interface IRewardsAndFundLabel { | ||
value: string; | ||
unit: "ETH" | "PNK"; | ||
isFund?: boolean; | ||
} | ||
|
||
const RewardsAndFundLabel: React.FC<IRewardsAndFundLabel> = ({ value, unit = "ETH", isFund = false }) => { | ||
const theme = useTheme(); | ||
const isWon = Number(value) > 0; | ||
const color = isWon ? theme.success : theme.error; | ||
return Number(value) !== 0 ? ( | ||
<Container> | ||
<StyledLabel color={isFund ? theme.tint : color}> | ||
<NumberDisplay {...{ value, unit }} showUnitInDisplay={false} /> | ||
</StyledLabel> | ||
<StyledIcon as={unit === "ETH" ? EthIcon : PnkIcon} color={isFund ? theme.tint : color} /> | ||
</Container> | ||
) : null; | ||
}; | ||
|
||
export default RewardsAndFundLabel; |
Oops, something went wrong.