1- import React from "react" ;
1+ import React , { useMemo } from "react" ;
2+ import styled , { Theme } from "styled-components" ;
3+
24import { Link } from "react-router-dom" ;
3- import styled , { Theme , useTheme } from "styled-components" ;
5+
46import KlerosCourtLogo from "svgs/header/kleros-court.svg" ;
57
6- const arbitratorType = process . env . REACT_APP_ARBITRATOR_TYPE ;
8+ import { arbitratorType , ArbitratorTypes } from "consts/index" ;
9+ import { isUndefined } from "utils/index" ;
710
811const Container = styled . div `
912 display: flex;
@@ -16,9 +19,9 @@ const StyledLink = styled(Link)`
1619 min-height: 48px;
1720` ;
1821
19- const BadgeContainer = styled . div < { backgroundColor : string } > `
22+ const BadgeContainer = styled . div < { backgroundColor : keyof Theme } > `
2023 transform: skewX(-15deg);
21- background-color: ${ ( { backgroundColor } ) => backgroundColor } ;
24+ background-color: ${ ( { theme , backgroundColor } ) => theme [ backgroundColor ] } ;
2225 border-radius: 3px;
2326 padding: 1px 8px;
2427 height: fit-content;
@@ -28,37 +31,32 @@ const BadgeText = styled.label`
2831 color: #220050;
2932` ;
3033
31- const Badge : React . FC < { text : string ; color : keyof Theme } > = ( { text, color } ) => {
32- const theme = useTheme ( ) ;
33- return (
34- < BadgeContainer { ...{ backgroundColor : theme [ color ] } } >
34+ const CourtBadge : React . FC = ( ) => {
35+ const { text, color } = useMemo < { text ?: string ; color ?: keyof Theme } > ( ( ) => {
36+ switch ( arbitratorType ( ) ) {
37+ case ArbitratorTypes [ "neo" ] :
38+ return { text : "Neo" , color : "paleCyan" } ;
39+ case ArbitratorTypes [ "university" ] :
40+ return { text : "Uni" , color : "limeGreen" } ;
41+ }
42+ return { } ;
43+ } , [ ] ) ;
44+
45+ return ! isUndefined ( color ) ? (
46+ < BadgeContainer { ...{ backgroundColor : color } } >
3547 < BadgeText > { text } </ BadgeText >
3648 </ BadgeContainer >
37- ) ;
49+ ) : null ;
3850} ;
3951
40- const Logo : React . FC = ( ) => {
41- let CourtBadge : JSX . Element | null = null ;
42- switch ( arbitratorType ) {
43- case "neo" :
44- CourtBadge = < Badge text = "Neo" color = "paleCyan" /> ;
45- break ;
46- case "university" :
47- CourtBadge = < Badge text = "Uni" color = "limeGreen" /> ;
48- break ;
49- default :
50- break ;
51- }
52-
53- return (
54- < Container >
55- { " " }
56- < StyledLink to = { "/" } >
57- < KlerosCourtLogo />
58- </ StyledLink >
59- { CourtBadge }
60- </ Container >
61- ) ;
62- } ;
52+ const Logo : React . FC = ( ) => (
53+ < Container >
54+ { " " }
55+ < StyledLink to = { "/" } >
56+ < KlerosCourtLogo />
57+ </ StyledLink >
58+ < CourtBadge />
59+ </ Container >
60+ ) ;
6361
6462export default Logo ;
0 commit comments