| 1 |
import Stack from '@elementor/ui/Stack'; |
| 2 |
import Typography from '@elementor/ui/Typography'; |
| 3 |
import Box from '@elementor/ui/Box'; |
| 4 |
import Image from '@elementor/ui/Image'; |
| 5 |
import EyeIcon from '@elementor/icons/EyeIcon'; |
| 6 |
import { __ } from '@wordpress/i18n'; |
| 7 |
import { styled } from '@elementor/ui/styles'; |
| 8 |
|
| 9 |
const Container = styled( Stack )( ( { theme } ) => ( { |
| 10 |
border: `1px solid ${ theme.palette.divider }`, |
| 11 |
borderRadius: theme.shape.borderRadius, |
| 12 |
} ) ); |
| 13 |
|
| 14 |
const Title = styled( Typography )( ( { theme } ) => ( { |
| 15 |
color: theme.palette.text.secondary, |
| 16 |
fontWeight: 500, |
| 17 |
padding: theme.spacing( 1.25 ), |
| 18 |
} ) ); |
| 19 |
|
| 20 |
const ImageContainer = styled( Box )( ( { theme } ) => ( { |
| 21 |
position: 'relative', |
| 22 |
cursor: 'pointer', |
| 23 |
display: 'flex', |
| 24 |
overflow: 'hidden', |
| 25 |
padding: theme.spacing( 1.25 ), |
| 26 |
borderTop: `1px solid ${ theme.palette.divider }`, |
| 27 |
} ) ); |
| 28 |
|
| 29 |
const Overlay = styled( Box )( () => ( { |
| 30 |
position: 'absolute', |
| 31 |
top: 10, |
| 32 |
left: 10, |
| 33 |
width: 'calc(100% - 20px)', |
| 34 |
height: 'calc(100% - 20px)', |
| 35 |
backgroundColor: 'rgba(0, 0, 0, 0.5)', |
| 36 |
color: 'white', |
| 37 |
display: 'flex', |
| 38 |
alignItems: 'center', |
| 39 |
justifyContent: 'center', |
| 40 |
flexDirection: 'column', |
| 41 |
opacity: 0, |
| 42 |
transition: 'opacity 0.3s', |
| 43 |
'&:hover': { |
| 44 |
opacity: 1, |
| 45 |
}, |
| 46 |
} ) ); |
| 47 |
|
| 48 |
export const PreviewWithImage = ( { title, thumbnail, onClick } ) => { |
| 49 |
return ( |
| 50 |
<Container direction="column"> |
| 51 |
<Box sx={ { minHeight: 40 } }> |
| 52 |
<Title variant="body1">{ title }</Title> |
| 53 |
</Box> |
| 54 |
|
| 55 |
<ImageContainer> |
| 56 |
<Image |
| 57 |
src={ thumbnail } |
| 58 |
alt={ title } |
| 59 |
sx={ { |
| 60 |
width: '100%', |
| 61 |
height: 'auto', |
| 62 |
objectFit: 'cover', |
| 63 |
} } /> |
| 64 |
<Overlay |
| 65 |
onClick={ onClick } |
| 66 |
> |
| 67 |
<EyeIcon sx={ { mr: 1 } } /> |
| 68 |
<Typography variant="body2" sx={ { color: 'theme.palette.common.white' } }>{ __( 'View Demo', 'hello-plus' ) }</Typography> |
| 69 |
</Overlay> |
| 70 |
</ImageContainer> |
| 71 |
</Container> |
| 72 |
); |
| 73 |
}; |
| 74 |
|