-
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
Showing
12 changed files
with
253 additions
and
55 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
12 changes: 12 additions & 0 deletions
12
src/components/HistorySlideButton/HistorySlideButton.css.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,12 @@ | ||
import { style, styleVariants } from '@vanilla-extract/css'; | ||
|
||
export const buttonStyle = style({}); | ||
|
||
export const iconVariants = styleVariants({ | ||
PREV: [{}], | ||
NEXT: [ | ||
{ | ||
transform: 'rotate(180deg)', | ||
}, | ||
], | ||
}); |
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,26 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import CommonIcon from '@/composable/Icon/CommonIcon'; | ||
import useOceanSwiperButton from '../../hook/useOceanSwiperButton'; | ||
import { iconVariants } from './HistorySlideButton.css'; | ||
|
||
interface Props { | ||
direction: ButtonDirection; | ||
} | ||
|
||
const HistorySlideButton = ({ direction }: Props) => { | ||
const { handleClick } = useOceanSwiperButton(direction); | ||
return ( | ||
<button type="button" onClick={handleClick}> | ||
<CommonIcon | ||
className={iconVariants[direction]} | ||
variant="LEFT_ARROW_SECONDARY_VARIANT" | ||
width={24} | ||
height={24} | ||
/> | ||
</button> | ||
); | ||
}; | ||
|
||
export default HistorySlideButton; |
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,62 @@ | ||
'use client'; | ||
|
||
import 'swiper/css'; | ||
|
||
import React from 'react'; | ||
import HistoryCard from '../Card/History/HistoryCard'; | ||
import HistorySlideButton from '../HistorySlideButton/HistorySlideButton'; | ||
import HistoryTab from '../HistoryTab/HistoryTab'; | ||
import OceanSwiper from '../OceanSwiper/OceanSwiper'; | ||
|
||
const HistorySwiper = () => { | ||
const mock1 = ['a', 'b', 'c']; | ||
const mock2 = ['d', 'e', 'f']; | ||
const mock3 = ['g', 'h', 'i']; | ||
|
||
return ( | ||
<OceanSwiper> | ||
<OceanSwiper.Top className=""> | ||
<HistorySlideButton direction="PREV" /> | ||
<HistoryTab /> | ||
<HistorySlideButton direction="NEXT" /> | ||
</OceanSwiper.Top> | ||
<OceanSwiper.Main hiddenNavigation> | ||
<OceanSwiper.Slide> | ||
{mock1.map((id) => { | ||
return ( | ||
<HistoryCard key={id} visible_status="VISIBLE" sizeToken="LARGE"> | ||
<HistoryCard.Company companyName="회사명" /> | ||
<HistoryCard.Position positionName="직책명" /> | ||
<HistoryCard.Period period="기간" /> | ||
</HistoryCard> | ||
); | ||
})} | ||
</OceanSwiper.Slide> | ||
<OceanSwiper.Slide> | ||
{mock2.map((id) => { | ||
return ( | ||
<HistoryCard key={id} visible_status="VISIBLE" sizeToken="LARGE"> | ||
<HistoryCard.Company companyName="회사명" /> | ||
<HistoryCard.Position positionName="직책명" /> | ||
<HistoryCard.Period period="기간" /> | ||
</HistoryCard> | ||
); | ||
})} | ||
</OceanSwiper.Slide> | ||
<OceanSwiper.Slide> | ||
{mock3.map((id) => { | ||
return ( | ||
<HistoryCard key={id} visible_status="VISIBLE" sizeToken="LARGE"> | ||
<HistoryCard.Company companyName="회사명" /> | ||
<HistoryCard.Position positionName="직책명" /> | ||
<HistoryCard.Period period="기간" /> | ||
</HistoryCard> | ||
); | ||
})} | ||
</OceanSwiper.Slide> | ||
</OceanSwiper.Main> | ||
</OceanSwiper> | ||
); | ||
}; | ||
|
||
export default HistorySwiper; |
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,10 @@ | ||
import React from 'react'; | ||
import { useOceanSwiperIndex } from '@/hook/useOceanSwiperIndex'; | ||
|
||
const HistoryTab = () => { | ||
const { readIndex } = useOceanSwiperIndex(); | ||
|
||
return <div>{readIndex}</div>; | ||
}; | ||
|
||
export default HistoryTab; |
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,20 @@ | ||
import { createStaticContext } from '@/utils/context/StaticContext'; | ||
|
||
export interface ContextDispatchOceanSwiperProps {} | ||
|
||
interface ContextOceanSwiper { | ||
buttonRefs: { | ||
prev: HTMLButtonElement | null; | ||
next: HTMLButtonElement | null; | ||
}; | ||
} | ||
|
||
export const ContextDispatchOceanSwiper = | ||
createStaticContext<ContextDispatchOceanSwiperProps>({}); | ||
|
||
export const ContextValueOceanSwiper = createStaticContext<ContextOceanSwiper>({ | ||
buttonRefs: { | ||
prev: null, | ||
next: null, | ||
}, | ||
}); |
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 was deleted.
Oops, something went wrong.
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,3 @@ | ||
export const customEvents = { | ||
SWIPER_REAL_INDEX_CHANGE: 'SWIPER_REAL_INDEX_CHANGE', | ||
} as const; |
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,21 @@ | ||
import React, { useEffect } from 'react'; | ||
|
||
const useEventListener = <T extends Event>( | ||
target: EventTarget, | ||
event: string, | ||
callback: (event: T) => void, | ||
options?: boolean | AddEventListenerOptions, | ||
) => { | ||
const eventListener: EventListener = (event: Event) => { | ||
return callback(event as T); | ||
}; | ||
|
||
useEffect(() => { | ||
target.addEventListener(event, eventListener, options); | ||
return () => { | ||
target.removeEventListener(event, eventListener, options); | ||
}; | ||
}, []); | ||
}; | ||
|
||
export default useEventListener; |
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,18 @@ | ||
import { getStaticContext } from '@/utils/context/StaticContext'; | ||
import { ContextValueOceanSwiper } from '../components/OceanSwiper/OceanSwiper.context'; | ||
|
||
const useOceanSwiperButton = (direction: ButtonDirection) => { | ||
const { buttonRefs } = getStaticContext(ContextValueOceanSwiper); | ||
|
||
const handleClick = () => { | ||
if (direction === 'PREV') { | ||
buttonRefs.prev?.click(); | ||
} else { | ||
buttonRefs.next?.click(); | ||
} | ||
}; | ||
|
||
return { handleClick }; | ||
}; | ||
|
||
export default useOceanSwiperButton; |
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,18 @@ | ||
import { useState } from 'react'; | ||
import Swiper from 'swiper'; | ||
import { customEvents } from '@/const/customEvents'; | ||
import useEventListener from './useEventListener'; | ||
|
||
export const useOceanSwiperIndex = () => { | ||
const [readIndex, setIndex] = useState(0); | ||
|
||
useEventListener<CustomEvent<Swiper>>( | ||
window, | ||
customEvents.SWIPER_REAL_INDEX_CHANGE, | ||
(e) => { | ||
setIndex(e.detail.realIndex); | ||
}, | ||
); | ||
|
||
return { readIndex }; | ||
}; |