Skip to content
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
45 changes: 21 additions & 24 deletions src/components/expandGrid/ExpandGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import "./expandGrid.scss"

const ExpandGrid = ({ data }) => {
return (
<div className="container my-3 py-5">
<section className="expandGrid">
<div className="expandGrid-body">
<h2>{data.title}</h2>
<h6 className="px-5">{data.subtitle}</h6>
<AnimatedList items={data.items} />
</div>
</section>
<div className="m-3 mx-5 sm:mx-3 py-5">
<section className="expandGrid">
<div className="expandGrid-body">
<h2>{data.title}</h2>
<h6 className="px-5">{data.subtitle}</h6>
<AnimatedList items={data.items} />
</div>
</section>
</div>

)
}

Expand All @@ -39,11 +38,7 @@ const ListItem = ({ index, onClick, data }) => {
shouldFlip={shouldFlip(index)}
delayUntil={createCardFlipId(index)}
>
<img
alt=""
src={data.image?.url}
className="avatar"
/>
<img alt="" src={data.image?.url} className="avatar" />
</Flipped>
</div>
</Flipped>
Expand All @@ -52,11 +47,9 @@ const ListItem = ({ index, onClick, data }) => {
)
}

const ExpandedListItem = ({ index, onClick, data }) => {
const ExpandedListItem = ({ index, onClick, data, scrollToRef }) => {
const scrollRef = useRef(null)

const scrollToRef = ref => window.scrollTo(0, ref.current.offsetTop - 40)

return (
<Flipped
flipId={createCardFlipId(index)}
Expand All @@ -67,7 +60,6 @@ const ExpandedListItem = ({ index, onClick, data }) => {
el.classList.add("animated-in")
}, 400)
}}
onExit={() => scrollToRef(scrollRef)}
>
<div
ref={scrollRef}
Expand All @@ -83,11 +75,7 @@ const ExpandedListItem = ({ index, onClick, data }) => {
stagger="card-image"
delayUntil={createCardFlipId(index)}
>
<img
alt=""
src={data.image?.url}
className="avatar-expanded"
/>
<img alt="" src={data.image?.url} className="avatar-expanded" />
</Flipped>

<div className="additional-content">
Expand All @@ -104,9 +92,16 @@ const ExpandedListItem = ({ index, onClick, data }) => {

const AnimatedList = ({ items }) => {
const [focused, setFocused] = useState(null)
const scrollRef = useRef(null)
const onClick = index => {
setFocused(focused === index ? null : index)
if (focused !== null) {
scrollToRef(scrollRef)
}
}

const scrollToRef = ref => window.scrollTo(0, ref.current.offsetTop - 40)

return (
<Flipper
flipKey={focused}
Expand All @@ -118,8 +113,9 @@ const AnimatedList = ({ items }) => {
},
}}
decisionData={focused}

>
<ul className="list">
<ul ref={scrollRef} className="list">
{items.map((item, index) => {
return (
<>
Expand All @@ -128,6 +124,7 @@ const AnimatedList = ({ items }) => {
index={focused}
onClick={onClick}
data={item}
scrollToRef={scrollToRef}
/>
) : (
<ListItem
Expand Down
15 changes: 6 additions & 9 deletions src/components/expandGrid/expandGrid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
text-align: center;
line-height: 30px;
font-weight: 400;

}
}

Expand Down Expand Up @@ -75,25 +74,24 @@
}
}
.avatar {
height: 600px;
width: 100%;
aspect-ratio: 1/1;
margin: 0;
border-radius: 8px;

@media screen and (max-width: 1500px) {
height: 400px;
}

&-expanded {
@extend .avatar;
flex-grow: 0;
margin-right: 0;
width: auto;
min-width: 33%;
max-width: 33%;
@media screen and (max-width: 1500px) {
min-width: 50%;
max-width: 50%;
}
}
}


.expandedListItem .description {
display: flex;
flex-direction: column;
Expand All @@ -108,7 +106,6 @@
width: 100%;
margin-top: 2rem;


@media screen and (max-width: 890px) {
margin: 0;
}
Expand Down