1
1
import { FunctionComponent } from "react" ;
2
2
import { IDocumentationPageProps } from "../lib/content.interfaces" ;
3
- import { Card , CardContent , Theme , Typography } from "@mui/material" ;
4
- import { createStyles , makeStyles } from "@mui/styles" ;
3
+ import { Card , CardContent , Typography } from "@mui/material" ;
4
+ import { styled } from "@mui/material /styles" ;
5
5
6
- import Link from "next/link" ;
6
+ import Link , { LinkProps } from "next/link" ;
7
7
import Image from "next/image" ;
8
8
import { getImageUrl } from "../lib/frontendUtils/frontendTools" ;
9
9
@@ -15,64 +15,44 @@ export interface IBucketContentProps {
15
15
externalLinks ?: { title : string ; url : string } [ ] ;
16
16
}
17
17
18
- const useStyles = makeStyles ( ( theme : Theme ) =>
19
- createStyles ( {
20
- h3 : {
21
- borderTop : "1px solid" ,
22
- marginTop : "3.125rem !important" ,
23
- paddingTop : theme . spacing ( 2 ) ,
24
- } ,
25
- container : {
26
- display : "flex" ,
27
- flexWrap : "wrap" ,
28
- maxWidth : "100%" ,
29
- } ,
30
- divRoot : {
31
- padding : 16 ,
32
- height : 160 ,
33
- minHeight : 160 ,
34
- minWidth : 200 ,
35
- width : "100%" ,
18
+ const StyledLink = styled ( Link ) < LinkProps > ( ( { theme } ) => ( {
19
+ padding : 16 ,
20
+ height : 160 ,
21
+ minHeight : 160 ,
22
+ minWidth : 200 ,
23
+ width : "100%" ,
36
24
37
- [ theme . breakpoints . up ( "lg" ) ] : {
38
- width : "50% !important" ,
39
- } ,
40
- [ theme . breakpoints . up ( "xl" ) ] : {
41
- width : "33% !important" ,
42
- } ,
43
- } ,
44
- root : {
45
- display : "flex" ,
46
- height : "100%" ,
47
- cursor : "pointer" ,
48
- } ,
49
- details : {
50
- display : "flex" ,
51
- flexDirection : "column" ,
52
- width : "50% !important" ,
53
- flex : 1 ,
54
- } ,
55
- content : {
56
- flex : "1 0 auto" ,
57
- } ,
58
- imageContainer : {
59
- minHeight : "100%" ,
60
- cursor : "pointer" ,
61
- display : "inline-block" ,
62
- overflow : "hidden" ,
63
- position : "relative" ,
64
- minWidth : "150px !important" ,
65
- width : "unset !important" ,
66
- "& img" : {
67
- pointerEvents : "none" ,
68
- position : "absolute" ,
69
- minWidth : "100%" ,
70
- minHeight : "100%" ,
71
- objectFit : "cover" ,
72
- } ,
73
- } ,
74
- } ) ,
75
- ) ;
25
+ [ theme . breakpoints . up ( "lg" ) ] : {
26
+ width : "50% !important" ,
27
+ } ,
28
+ [ theme . breakpoints . up ( "xl" ) ] : {
29
+ width : "33% !important" ,
30
+ } ,
31
+ } ) ) ;
32
+
33
+ const ImageContainer = styled ( "div" ) ( ( { theme } ) => ( {
34
+ minHeight : "100%" ,
35
+ cursor : "pointer" ,
36
+ display : "inline-block" ,
37
+ overflow : "hidden" ,
38
+ position : "relative" ,
39
+ minWidth : "150px !important" ,
40
+ width : "unset !important" ,
41
+ "& img" : {
42
+ pointerEvents : "none" ,
43
+ position : "absolute" ,
44
+ minWidth : "100%" ,
45
+ minHeight : "100%" ,
46
+ objectFit : "cover" ,
47
+ } ,
48
+ } ) ) ;
49
+
50
+ const DetailsDiv = styled ( "div" ) ( ( { theme } ) => ( {
51
+ display : "flex" ,
52
+ flexDirection : "column" ,
53
+ width : "50% !important" ,
54
+ flex : 1 ,
55
+ } ) ) ;
76
56
77
57
interface IBucketItem {
78
58
title : string ;
@@ -82,30 +62,44 @@ interface IBucketItem {
82
62
}
83
63
84
64
const SingleBucketItem : FunctionComponent < IBucketItem > = ( { link, title, imageUrl, description } : IBucketItem ) => {
85
- const classes = useStyles ( ) ;
86
65
return (
87
- < Link key = { link } href = { link } className = { classes . divRoot } >
88
- < Card className = { classes . root } >
89
- < div className = { classes . details } >
90
- < CardContent className = { classes . content } >
66
+ < StyledLink key = { link } href = { link } >
67
+ < Card
68
+ sx = { {
69
+ display : "flex" ,
70
+ height : "100%" ,
71
+ cursor : "pointer" ,
72
+ } }
73
+ >
74
+ < DetailsDiv >
75
+ < CardContent
76
+ sx = { {
77
+ flex : "1 0 auto" ,
78
+ } }
79
+ >
91
80
< Typography component = "h6" variant = "h6" >
92
81
{ title }
93
82
</ Typography >
94
83
< Typography style = { { } } variant = "subtitle1" color = "textSecondary" title = { title } >
95
84
{ description }
96
85
</ Typography >
97
86
</ CardContent >
98
- </ div >
99
- < div className = { classes . imageContainer } >
87
+ </ DetailsDiv >
88
+ < ImageContainer >
100
89
< Image alt = { title } src = { imageUrl } fill = { true } > </ Image >
101
- </ div >
90
+ </ ImageContainer >
102
91
</ Card >
103
- </ Link >
92
+ </ StyledLink >
104
93
) ;
105
94
} ;
106
95
96
+ const DivContainer = styled ( "div" ) ( ( { theme } ) => ( {
97
+ display : "flex" ,
98
+ flexWrap : "wrap" ,
99
+ maxWidth : "100%" ,
100
+ } ) ) ;
101
+
107
102
export const BucketContent : FunctionComponent < IBucketContentProps > = ( { childPages, title = "Coming next" , externalLinks } ) => {
108
- const classes = useStyles ( ) ;
109
103
const bucketItems : IBucketItem [ ] = Object . keys ( childPages || [ ] ) . map ( ( child ) => {
110
104
const childData = childPages [ child ] . metadata ;
111
105
const title = ( childData . title || child ) . replace ( / _ / g, " " ) ;
@@ -117,15 +111,23 @@ export const BucketContent: FunctionComponent<IBucketContentProps> = ({ childPag
117
111
< >
118
112
{ ( ! ! bucketItems . length || ( externalLinks && ! ! externalLinks . length ) ) && (
119
113
< >
120
- < Typography className = { classes . h3 } component = "h3" variant = "h3" >
114
+ < Typography
115
+ sx = { {
116
+ borderTop : "1px solid" ,
117
+ marginTop : "3.125rem !important" ,
118
+ pt : 2 , // theme.spacing(2)
119
+ } }
120
+ component = "h3"
121
+ variant = "h3"
122
+ >
121
123
{ title }
122
124
</ Typography >
123
125
{ ! ! bucketItems . length && (
124
- < div className = { classes . container } >
126
+ < DivContainer >
125
127
{ bucketItems . map ( ( child , idx ) => {
126
128
return < SingleBucketItem key = { idx } { ...child } /> ;
127
129
} ) }
128
- </ div >
130
+ </ DivContainer >
129
131
) }
130
132
{ externalLinks && (
131
133
< ul >
0 commit comments