-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathProductPreview.tsx
117 lines (111 loc) · 3.94 KB
/
ProductPreview.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import * as React from 'react';
import { useRecordContext } from 'react-admin';
import { Box, lighten, darken, Typography, useTheme } from '@mui/material';
import { formatNumberAsUSD } from '../formatUtils';
const MarkdownField = React.lazy(() =>
import('@react-admin/ra-markdown').then(module => ({
default: module.MarkdownField,
}))
);
const ProductPreview = (props: any) => {
const record = useRecordContext(props);
const theme = useTheme();
if (!record) return null;
const { image, height, width, price, reference } = record;
return (
<Box
sx={{
display: 'flex',
flexDirection: 'column',
padding: '0 20px',
width: 350,
'& > p': {
fontSize: 12,
color: 'text.primary',
textAlign: 'right',
},
}}
>
<Box padding={2}>
<Box
sx={{
position: 'relative',
width: '100%',
paddingBottom: '82.5%',
background: 'black',
boxShadow: '0 10px 7px -5px rgba(0, 0, 0, 0.3)',
}}
>
<Box
sx={{
position: 'absolute',
background: theme.palette.background.paper,
top: '3.0303%',
bottom: '3.0303%',
left: '2.5%',
right: '2.5%',
boxShadow: '0px 0px 20px 0px rgba(0,0,0,0.5) inset',
}}
>
<Box
sx={{
position: 'absolute',
top: '16.129%',
bottom: '16.129%',
left: '13.158%',
right: '13.158%',
'& img': {
width: '100%',
},
}}
>
<img src={image} alt="" />
</Box>
</Box>
</Box>
</Box>
<Box
sx={{
py: 2,
px: 3,
'& h1': {
fontSize: 18,
color: 'text.primary',
fontWeight: 'normal',
},
'& h2': {
fontSize: 14,
color:
theme.palette.mode === 'light'
? lighten(theme.palette.text.primary, 0.38)
: darken(theme.palette.text.primary, 0.38),
fontWeight: 'normal',
},
'& .MuiFormControl-root': {
margin: 0,
'& > div': {
padding: 0,
},
},
}}
>
<Typography variant="h1">{reference}</Typography>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
}}
>
<Typography variant="caption">
{width} x {height} cm
</Typography>
<Typography variant="caption">
{formatNumberAsUSD(price, 2)}
</Typography>
</Box>
<MarkdownField record={record} label="" source="description" />
</Box>
</Box>
);
};
export default ProductPreview;