1
1
import React from "react"
2
- import { Box , Typography } from "@material-ui/core"
2
+ import { Box , makeStyles , SvgIcon , Typography } from "@material-ui/core"
3
3
4
4
export interface ProjectIconProps {
5
5
title : string
6
- icon : string
6
+ icon ? : string
7
7
description ?: string
8
8
onClick : ( ) => void
9
9
}
10
10
11
- export const ProjectIcon : React . FC < ProjectIconProps > = ( { title, icon, onClick } ) => {
11
+ const useStyles = makeStyles ( ( theme ) => ( {
12
+ container : {
13
+ boxShadow : theme . shadows [ 1 ] ,
14
+ cursor : "pointer" ,
15
+ transition : "box-shadow 250ms ease-in-out" ,
16
+ backgroundColor : "lightgrey" ,
17
+ "&:hover" : {
18
+ boxShadow : theme . shadows [ 8 ] ,
19
+ } ,
20
+ } ,
21
+ } ) )
22
+
23
+ const Circle : React . FC = ( ) => {
24
+ return (
25
+ < Box
26
+ css = { {
27
+ width : "96px" ,
28
+ height : "96px" ,
29
+ borderRadius : "96px" ,
30
+ border : "48px solid white" ,
31
+ } }
32
+ />
33
+ )
34
+ }
35
+
36
+ const useStyles2 = makeStyles ( ( theme ) => ( {
37
+ root : {
38
+ color : theme . palette . text . secondary ,
39
+ display : "-webkit-box" , // See (1)
40
+ marginTop : theme . spacing ( 0.5 ) ,
41
+ maxWidth : "110%" ,
42
+ minWidth : 0 ,
43
+ overflow : "hidden" , // See (1)
44
+ textAlign : "center" ,
45
+ textOverflow : "ellipsis" , // See (1)
46
+ whiteSpace : "normal" , // See (1)
47
+
48
+ // (1) - These styles, along with clamping make it so that not only
49
+ // can text not overflow horizontally, but there can also only be a
50
+ // maximum of 2 line breaks. This is standard behaviour on OS files
51
+ // (ex: Windows 10 Desktop application) to prevent excessive vertical
52
+ // line wraps. This is important in Generic Applications, as we have no
53
+ // control over the application name used in the manifest.
54
+ [ "-webkit-line-clamp" ] : 2 ,
55
+ [ "-webkit-box-orient" ] : "vertical" ,
56
+ } ,
57
+ } ) )
58
+
59
+ export const ProjectName : React . FC = ( { children } ) => {
60
+ const styles = useStyles2 ( )
61
+
62
+ return (
63
+ < Typography className = { styles . root } noWrap variant = "body2" >
64
+ { children }
65
+ </ Typography >
66
+ )
67
+ }
68
+
69
+ export const ProjectIcon : React . FC < ProjectIconProps > = ( { icon, title, onClick } ) => {
70
+ const styles = useStyles ( )
71
+
72
+ let iconComponent
73
+
74
+ if ( typeof icon !== "undefined" ) {
75
+ iconComponent = < img src = { icon } width = { "128px" } height = { "128px" } />
76
+ } else {
77
+ iconComponent = (
78
+ < Box width = { "128px" } height = { "128px" } style = { { display : "flex" , justifyContent : "center" , alignItems : "center" } } >
79
+ < Circle />
80
+ </ Box >
81
+ )
82
+ }
83
+
12
84
return (
13
85
< Box
14
86
css = { {
@@ -18,12 +90,14 @@ export const ProjectIcon: React.FC<ProjectIconProps> = ({ title, icon, onClick }
18
90
flexDirection : "column" ,
19
91
justifyContent : "center" ,
20
92
alignItems : "center" ,
21
- border : "1px solid red" ,
93
+ border : "1px solid black" ,
94
+ borderRadius : "4px" ,
22
95
} }
96
+ className = { styles . container }
23
97
onClick = { onClick }
24
98
>
25
- < img src = { icon } width = { "128px" } height = { "128px" } />
26
- < Typography > { title } </ Typography >
99
+ { iconComponent }
100
+ < ProjectName > { title } </ ProjectName >
27
101
</ Box >
28
102
)
29
103
}
0 commit comments