-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eca17e
commit 78cf5a4
Showing
9 changed files
with
152 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
apps/ziine/src/views/magazine-list-page/magazine-list-page.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { cva } from '@/styled-system/css'; | ||
|
||
export const listItemStyle = cva({ | ||
base: {}, | ||
variants: { | ||
active: { | ||
true: { | ||
minWidth: '256px', | ||
maxWidth: '256px', | ||
}, | ||
false: { | ||
minWidth: '240px', | ||
maxWidth: '240px', | ||
}, | ||
}, | ||
}, | ||
}); |
60 changes: 49 additions & 11 deletions
60
apps/ziine/src/views/magazine-list-page/magazine-list-page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,57 @@ | ||
import { getMagazineList } from '@/entities/magazine/apis/apis'; | ||
'use client'; | ||
|
||
import { useSuspenseMagazineList } from '@/entities/magazine/apis/queries'; | ||
import { MagazineCard } from '@/entities/magazine/components/magazine-card'; | ||
import { css } from '@/styled-system/css'; | ||
import { Swiper, SwiperSlide } from 'swiper/react'; | ||
|
||
import 'swiper/css'; | ||
import 'swiper/css/pagination'; | ||
import { useState } from 'react'; | ||
import { Tag } from '@ziine/design'; | ||
import { listItemStyle } from './magazine-list-page.styles'; | ||
|
||
export const MagazineListPage = () => { | ||
const { | ||
data: { magazines }, | ||
} = useSuspenseMagazineList(); | ||
|
||
export const MagazineListPage = async () => { | ||
const data = await getMagazineList(); | ||
const [activeIndex, setActiveIndex] = useState(0); | ||
|
||
return ( | ||
<div className={css({ margin: '24px 0', gap: '16px', display: 'flex' })}> | ||
{data.magazines.map((magazine) => ( | ||
<MagazineCard | ||
key={magazine.id} | ||
{...magazine} | ||
className={css({ minWidth: '256px', maxWidth: '256px', height: 'fit-content' })} | ||
/> | ||
))} | ||
<div | ||
className={css({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
margin: '24px 0', | ||
width: '100%', | ||
})} | ||
> | ||
<Swiper | ||
spaceBetween={16} | ||
slidesPerView={3} | ||
centeredSlides={true} | ||
pagination={{ clickable: true, type: 'fraction' }} | ||
observer={true} | ||
observeParents={true} | ||
updateOnWindowResize={true} | ||
className={css({ | ||
marginBottom: '48px', | ||
width: '100%', | ||
height: '100%', | ||
})} | ||
onSlideChange={({ activeIndex }) => { | ||
setActiveIndex(activeIndex); | ||
}} | ||
> | ||
{magazines.map((magazine, idx) => ( | ||
<SwiperSlide key={magazine.id} className={listItemStyle({ active: activeIndex === idx })}> | ||
<MagazineCard {...magazine} /> | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
<Tag variant='orangeOutlined'>{`${activeIndex + 1}/${magazines.length}`}</Tag> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.