11import React , { ReactNode } from "react"
2- import styled from "@emotion/styled"
2+ import {
3+ Box ,
4+ Flex ,
5+ Text ,
6+ Heading ,
7+ BoxProps ,
8+ LinkBox ,
9+ LinkOverlay ,
10+ Image ,
11+ useColorModeValue ,
12+ } from "@chakra-ui/react"
313import { GatsbyImage , IGatsbyImageData } from "gatsby-plugin-image"
414
515import Link from "./Link"
616
7- const Content = styled . div `
8- padding: 1.5rem;
9- `
10-
11- const Description = styled . p `
12- opacity: 0.8;
13- margin-bottom: 0rem;
14- `
15-
16- const ChildrenContainer = styled . div `
17- margin-top: 2rem;
18- `
19-
20- const ImageWrapper = styled . div < {
21- isRight : boolean | undefined
22- isBottom : boolean | undefined
23- } > `
24- display: flex;
25- flex-direction: row;
26- justify-content: ${ ( props ) => ( props . isRight ? `flex-end` : `center` ) } ;
27- align-items: ${ ( props ) => ( props . isBottom ? `flex-end` : `center` ) } ;
28- background: ${ ( props ) => props . theme . colors . cardGradient } ;
29- box-shadow: inset 0px -1px 0px rgba(0, 0, 0, 0.1);
30- min-height: 260px;
31- `
32-
33- const Title = styled . h3 `
34- margin-top: 0.5rem;
35- margin-bottom: 1rem;
36- `
37-
38- const Image = styled ( GatsbyImage ) `
39- width: 100%;
40- height: 100%;
41- min-width: 100px;
42- min-height: 100px;
43- max-width: 372px;
44- max-height: 257px;
45- @media (max-width: ${ ( props ) => props . theme . breakpoints . s } ) {
46- max-width: 311px;
47- }
48- `
49-
50- const Card = styled ( Link ) `
51- text-decoration: none;
52- flex: 1 1 372px;
53- color: ${ ( props ) => props . theme . colors . text } ;
54- box-shadow: 0px 14px 66px rgba(0, 0, 0, 0.07),
55- 0px 10px 17px rgba(0, 0, 0, 0.03), 0px 4px 7px rgba(0, 0, 0, 0.05);
56- margin: 1rem;
17+ const linkBoxFocusStyles : BoxProps = {
18+ borderRadius : "base" ,
19+ boxShadow : "0px 8px 17px rgba(0, 0, 0, 0.15)" ,
20+ bg : "tableBackgroundHover" ,
21+ transition : "transform 0.1s" ,
22+ transform : "scale(1.02)" ,
23+ }
5724
58- &:hover,
59- &:focus {
60- text-decoration: none;
61- border-radius: 4px;
62- box-shadow: 0px 8px 17px rgba(0, 0, 0, 0.15);
63- background: ${ ( props ) => props . theme . colors . tableBackgroundHover } ;
64- transition: transform 0.1s;
65- transform: scale(1.02);
66- }
67- `
25+ const linkFocusStyles : BoxProps = {
26+ textDecoration : "none" ,
27+ }
6828
6929export interface IProps {
7030 children ?: React . ReactNode
@@ -90,25 +50,81 @@ const ActionCard: React.FC<IProps> = ({
9050 isBottom = true ,
9151} ) => {
9252 const isImageURL = typeof image === "string"
53+ const descriptionColor = useColorModeValue ( "blackAlpha.700" , "whiteAlpha.800" )
9354
9455 return (
95- < Card to = { to } className = { className } hideArrow = { true } >
96- < ImageWrapper
97- isRight = { isRight }
98- isBottom = { isBottom }
56+ < LinkBox
57+ boxShadow = "
58+ 0px 14px 66px rgba(0, 0, 0, 0.07),
59+ 0px 10px 17px rgba(0, 0, 0, 0.03), 0px 4px 7px rgba(0, 0, 0, 0.05)"
60+ color = "text"
61+ flex = "1 1 372px"
62+ _hover = { linkBoxFocusStyles }
63+ _focus = { linkBoxFocusStyles }
64+ className = { className }
65+ m = { 4 }
66+ >
67+ < Flex
68+ minH = "260px"
69+ bg = "cardGradient"
70+ direction = "row"
71+ justify = { isRight ? "flex-end" : "center" }
72+ align = { isBottom ? "flex-end" : "center" }
9973 className = "action-card-image-wrapper"
74+ boxShadow = "inset 0px -1px 0px rgba(0, 0, 0, 0.1)"
10075 >
101- { ! isImageURL && < Image image = { image } alt = { alt || "" } /> }
76+ { ! isImageURL && (
77+ < Image
78+ alt = { alt || "" }
79+ as = { GatsbyImage }
80+ maxH = "257px"
81+ maxW = { { base : "311px" , sm : "372px" } }
82+ minW = "100px"
83+ minH = "100px"
84+ image = { image }
85+ sizes = "full"
86+ />
87+ ) }
10288 { isImageURL && (
103- < img src = { image } alt = { alt } className = "action-card-image" />
89+ < Image
90+ alt = { alt || "" }
91+ maxH = "257px"
92+ maxW = { { base : "311px" , sm : "372px" } }
93+ minW = "100px"
94+ minH = "100px"
95+ src = { image }
96+ sizes = "full"
97+ className = "action-card-image"
98+ />
10499 ) }
105- </ ImageWrapper >
106- < Content className = "action-card-content" >
107- < Title > { title } </ Title >
108- < Description > { description } </ Description >
109- { children && < ChildrenContainer > { children } </ ChildrenContainer > }
110- </ Content >
111- </ Card >
100+ </ Flex >
101+ < Box p = { 6 } className = "action-card-content" >
102+ < Heading
103+ as = "h3"
104+ fontSize = "2xl"
105+ mt = { 2 }
106+ mb = { 4 }
107+ fontWeight = { 600 }
108+ lineHeight = { 1.4 }
109+ >
110+ < LinkOverlay
111+ as = { Link }
112+ color = "text"
113+ hideArrow
114+ textDecoration = "none"
115+ to = { to }
116+ _hover = { linkFocusStyles }
117+ _focus = { linkFocusStyles }
118+ >
119+ { title }
120+ </ LinkOverlay >
121+ </ Heading >
122+ < Text mb = { 0 } color = { descriptionColor } >
123+ { description }
124+ </ Text >
125+ { children && < Box mt = { 8 } > { children } </ Box > }
126+ </ Box >
127+ </ LinkBox >
112128 )
113129}
114130
0 commit comments