Skip to content

Commit

Permalink
created slide show
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Macri <[email protected]>
  • Loading branch information
Giuseppe Macri committed Aug 29, 2023
1 parent d48e65a commit 3d5edaf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
14 changes: 11 additions & 3 deletions website/src/components/common/swipeable.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ import React, {PureComponent} from 'react';
import styled from 'styled-components';
import SwipeableViews from 'react-swipeable-views';

const Container = styled.div`
display: flex;
flex-direction: column;
gap: 72px;
`;

const PaginationContainer = styled.div`
display: flex;
justify-content: center;
Expand Down Expand Up @@ -58,12 +64,14 @@ export default class Swipeable extends PureComponent {
render() {
const {children, onChange, selectedIndex} = this.props;
return (
<div>
<Container>
<SwipeableViews enableMouseEvents index={selectedIndex} onChange={onChange}>
{children}
</SwipeableViews>
<Pagination items={children} selectedIndex={selectedIndex} onChange={onChange} />
</div>
<div>
<Pagination items={children} selectedIndex={selectedIndex} onChange={onChange} />
</div>
</Container>
);
}
}
21 changes: 16 additions & 5 deletions website/src/components/studio.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import React, {useCallback, useState} from 'react';
import styled from 'styled-components';
import Swipeable from './common/swipeable';

const Flex = styled.div`
display: flex;
Expand All @@ -13,6 +14,9 @@ const StudioContainer = styled(Flex)`

const Section = styled(Flex)`
gap: 56px;
width: 100%;
justify-content: center;
justify-items: center;
`;

const MapCard = styled(Flex)`
Expand Down Expand Up @@ -138,7 +142,7 @@ const SECTIONS = [
const CardSection = ({cards}) => (
<Section>
{cards.map(card => (
<MapCard>
<MapCard key={card.imageUrl}>
<MapCardImage src={card.imageUrl} alt={card.title} />
<MapCardBody>
<MapCardIcon src={card.icon} alt={card.title} />
Expand All @@ -151,11 +155,18 @@ const CardSection = ({cards}) => (
);

const Studio = () => {
const [selectedIndex, setSelectedIndex] = useState(0);
const onChange = useCallback(index => {
setSelectedIndex(index);
}, []);

return (
<StudioContainer>
{SECTIONS.slice(0, 1).map((cards, index) => (
<CardSection key={index} cards={cards} />
))}
<Swipeable onChange={onChange} selectedIndex={selectedIndex}>
{SECTIONS.map((cards, index) => (
<CardSection key={index} cards={cards} />
))}
</Swipeable>
</StudioContainer>
);
};
Expand Down

0 comments on commit 3d5edaf

Please sign in to comment.