Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: (#17): Change scroll to carousel #25

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions src/views/MarketplaceV2/components/Featured/Cards.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
import React from 'react'
import { Grid } from '@mui/material'
import Carousel from 'react-multi-carousel'
import 'react-multi-carousel/lib/styles.css'
import styled from 'styled-components'
import Card from '../Card'
import './style.css'

const Cards = (props) => {
const { items } = props

return (
<Grid
className="scrollable-container"
container
wrap="nowrap"
mt={5}
pb={5}
columnSpacing={{ xs: 2 }}
sx={{
overflowX: 'scroll',
overflowY: 'hidden',
overflow: 'auto',
}}
<Carousel
responsive={responsive}
infinite
showDots
autoPlay
removeArrowOnDeviceType={['tablet', 'mobile']}
containerClass="carousel-container"
dotListClass="custom-dot-list-style"
>
{items.map((item, ind) => {
const id = ind + 1
return (
<Grid key={id} item alignItems="center" xs={12}>
<StyledDiv>
<Card {...item} />
</StyledDiv>
</Grid>
<StyledDiv>
<Card {...item} />
</StyledDiv>
)
})}
</Grid>
</Carousel>
)
}
const responsive = {
desktop: {
breakpoint: { max: 3000, min: 1024 },
items: 3,
slidesToSlide: 3, // optional, default to 1.
},
tablet: {
breakpoint: { max: 1024, min: 464 },
items: 2,
slidesToSlide: 2, // optional, default to 1.
},
mobile: {
breakpoint: { max: 464, min: 0 },
items: 1,
slidesToSlide: 1, // optional, default to 1.
},
}

export default Cards

const StyledDiv = styled.div`
margin: 5vh 0px;
padding: 2vh;
min-width: 220px;
${({ theme }) => `
${theme.mediaQueries.xl} {
Expand Down
9 changes: 9 additions & 0 deletions src/views/MarketplaceV2/components/Featured/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@
width: 24px;
}
}

.custom-dot-list-style .react-multi-carousel-dot button {
background-color: #fff;
border: 1px solid #3898b8;
}

.custom-dot-list-style .react-multi-carousel-dot--active button {
background-color: #4bdefd;
}
Loading