forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CarouselRatio.js
66 lines (64 loc) · 1.69 KB
/
CarouselRatio.js
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
import * as React from 'react';
import AspectRatio from '@mui/joy/AspectRatio';
import Box from '@mui/joy/Box';
import Typography from '@mui/joy/Typography';
import Card from '@mui/joy/Card';
const data = [
{
src: 'https://images.unsplash.com/photo-1502657877623-f66bf489d236',
title: 'Night view',
description: '4.21M views',
},
{
src: 'https://images.unsplash.com/photo-1527549993586-dff825b37782',
title: 'Lake view',
description: '4.74M views',
},
{
src: 'https://images.unsplash.com/photo-1532614338840-ab30cf10ed36',
title: 'Mountain view',
description: '3.98M views',
},
];
export default function CarouselRatio() {
return (
<Box
sx={{
display: 'flex',
gap: 1,
py: 1,
overflow: 'auto',
width: 343,
scrollSnapType: 'x mandatory',
'& > *': {
scrollSnapAlign: 'center',
},
'::-webkit-scrollbar': { display: 'none' },
}}
>
{data.map((item) => (
<Card
row
key={item.title}
variant="outlined"
sx={{
gap: 2,
'--Card-padding': (theme) => theme.spacing(2),
}}
>
<AspectRatio ratio="1" sx={{ minWidth: 60 }}>
<img
src={`${item.src}?h=120&fit=crop&auto=format`}
srcSet={`${item.src}?h=120&fit=crop&auto=format&dpr=2 2x`}
alt={item.title}
/>
</AspectRatio>
<Box sx={{ whiteSpace: 'nowrap' }}>
<Typography fontWeight="md">{item.title}</Typography>
<Typography level="body2">{item.description}</Typography>
</Box>
</Card>
))}
</Box>
);
}