switch case styled components

Solutions on MaxInterview for switch case styled components by the best coders in the world

showing results for - "switch case styled components"
Valentino
11 May 2019
1import { Feather } from '@expo/vector-icons';
2
3type IconProps = {
4    type: "up" | "down" | "total";
5}
6
7const handleColorType = ({ type }: IconProps ) => {
8    switch (type) {
9        case "up":
10            return '#12A454';
11        case "down":
12            return '#E83F5B';
13        case "total":
14            return '#363F5F';
15        default:
16            return "#fff";
17    }
18};
19
20export const Icon = styled(Feather) <IconProps>`
21    color: ${({ type }) => handleColorType({ type })}
22`;