1
1
import * as Common from "@frontend/common" ;
2
- import { CircularProgress , Divider , Stack , Tooltip , Typography , TypographyProps , styled } from "@mui/material" ;
2
+ import { Badge , CircularProgress , Divider , Stack , Tooltip , Typography , TypographyProps , styled } from "@mui/material" ;
3
3
import { ErrorBoundary , Suspense } from "@suspensive/react" ;
4
4
import { Link } from "react-router-dom" ;
5
5
6
6
import { useAppContext } from "../../../contexts/app_context" ;
7
7
8
8
const LogoHeight : React . CSSProperties [ "height" ] = "8rem" ;
9
9
const LogoWidth : React . CSSProperties [ "width" ] = "15rem" ;
10
+ const LogoContainerHeight : React . CSSProperties [ "height" ] = `calc(${ LogoHeight } + 2rem)` ;
11
+ const LogoContainerWidth : React . CSSProperties [ "width" ] = `calc(${ LogoWidth } + 4rem)` ;
10
12
11
13
const SponsorContainer = styled ( Stack ) ( {
12
14
width : "100%" ,
@@ -26,27 +28,89 @@ const SponsorStack = styled(Stack)({
26
28
justifyContent : "center" ,
27
29
alignItems : "center" ,
28
30
padding : "0 1rem" ,
29
- gap : "2rem " ,
31
+ gap : "4rem " ,
30
32
} ) ;
31
33
32
- const LogoImageContainer = styled ( Stack ) ( {
34
+ const LogoImageEqualWidthContainer = styled ( Stack ) ( ( { theme } ) => ( {
35
+ position : "relative" ,
33
36
alignItems : "center" ,
34
37
justifyContent : "center" ,
35
38
alignContent : "stretch" ,
36
- height : LogoHeight ,
37
- maxHeight : LogoHeight ,
39
+ height : LogoContainerHeight ,
40
+ maxHeight : LogoContainerHeight ,
41
+ minWidth : LogoContainerWidth ,
42
+ maxWidth : LogoContainerWidth ,
43
+ border : `1px solid ${ theme . palette . primary . light } ` ,
44
+ borderRadius : "0.5rem" ,
45
+
46
+ transition : "all 0.3s ease-in-out" ,
47
+
48
+ "&:hover" : {
49
+ borderColor : theme . palette . primary . dark ,
50
+ boxShadow : theme . shadows [ 3 ] ,
51
+ } ,
52
+ } ) ) ;
53
+
54
+ const LogoImageContainer = styled ( Stack ) ( {
55
+ width : "auto" ,
56
+ height : "auto" ,
57
+ minHeight : LogoHeight ,
38
58
maxWidth : LogoWidth ,
59
+ maxHeight : LogoHeight ,
60
+ objectFit : "contain" ,
61
+ alignItems : "center" ,
62
+ justifyContent : "center" ,
63
+ margin : "4rem 8rem" ,
39
64
} ) ;
40
65
41
66
const LogoImage = styled ( "img" ) ( {
42
- height : `calc(${ LogoHeight } * 0.9)` , // 90% of LogoHeight
67
+ width : "auto" ,
68
+ height : "auto" ,
43
69
minHeight : LogoHeight ,
44
- minWidth : `calc(${ LogoWidth } * 0.9)` , // 80% of LogoWidth
45
- maxWidth : "100%" ,
46
- maxHeight : "100%" ,
70
+ maxWidth : LogoWidth ,
71
+ maxHeight : LogoHeight ,
47
72
objectFit : "contain" ,
48
73
} ) ;
49
74
75
+ const LogoBadgeContainer = styled ( Stack ) ( {
76
+ position : "absolute" ,
77
+ width : "auto" ,
78
+ height : "auto" ,
79
+ top : "0.5rem" ,
80
+ right : "-0.5rem" ,
81
+ flexDirection : "column" ,
82
+ alignItems : "flex-end" ,
83
+ justifyContent : "center" ,
84
+ gap : "0.25rem" ,
85
+ } ) ;
86
+
87
+ const LogoBadge = styled ( Badge ) ( ( { theme } ) => ( {
88
+ alignItems : "flex-end" ,
89
+
90
+ "& .MuiBadge-badge" : {
91
+ position : "relative" ,
92
+ borderRadius : "0.25rem" ,
93
+ // height: "1rem",
94
+ padding : "0 0.5rem" ,
95
+ backgroundColor : theme . palette . primary . main ,
96
+ // color: theme.palette.primary.main,
97
+ // border: `1px solid ${theme.palette.primary.main}`,
98
+ borderEndEndRadius : "0" ,
99
+ transform : "none" ,
100
+
101
+ "&:after" : {
102
+ content : '""' ,
103
+ position : "absolute" ,
104
+ bottom : "-8px" ,
105
+ right : "-0.1px" ,
106
+ width : 0 ,
107
+ height : 0 ,
108
+ border : "solid 4px" ,
109
+ borderColor : `${ theme . palette . primary . dark } transparent transparent ${ theme . palette . primary . dark } ` ,
110
+ } ,
111
+ } ,
112
+ } ) ) ;
113
+
50
114
export const Sponsor : React . FC = ErrorBoundary . with (
51
115
{
52
116
fallback : (
@@ -87,11 +151,18 @@ export const Sponsor: React.FC = ErrorBoundary.with(
87
151
const sponsorName = sponsor . name . replace ( / \\ n / g, "\n" ) ;
88
152
const sponsorNameContent = < Typography variant = "body1" { ...textProps } children = { sponsorName } sx = { { whiteSpace : "pre-wrap" } } /> ;
89
153
const sponsorImg = (
90
- < LogoImageContainer >
91
- < Tooltip title = { sponsorNameContent } arrow placement = "top" >
92
- < LogoImage src = { sponsor . logo } alt = { sponsor . name } loading = "lazy" />
93
- </ Tooltip >
94
- </ LogoImageContainer >
154
+ < Tooltip title = { sponsorNameContent } arrow placement = "top" >
155
+ < LogoImageEqualWidthContainer >
156
+ < LogoBadgeContainer >
157
+ { sponsor . tags . map ( ( tag , i ) => (
158
+ < LogoBadge key = { i } badgeContent = { tag } />
159
+ ) ) }
160
+ </ LogoBadgeContainer >
161
+ < LogoImageContainer >
162
+ < LogoImage src = { sponsor . logo } alt = { sponsor . name } loading = "lazy" />
163
+ </ LogoImageContainer >
164
+ </ LogoImageEqualWidthContainer >
165
+ </ Tooltip >
95
166
) ;
96
167
return sponsor . sitemap_id ? < Link to = { flatSiteMapObj [ sponsor . sitemap_id ] . route } children = { sponsorImg } /> : sponsorImg ;
97
168
} ) }
0 commit comments