-
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.
Merge pull request #54 from themoment-team/develop
Release v1.2.1
- Loading branch information
Showing
16 changed files
with
192 additions
and
92 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
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,42 @@ | ||
import { Device } from 'utils'; | ||
import { Direction } from 'utils'; | ||
|
||
import SlideController from '.'; | ||
|
||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
export default { | ||
title: 'SlideController', | ||
component: SlideController, | ||
parameters: { | ||
backgrounds: { | ||
default: 'dark', | ||
}, | ||
}, | ||
} as Meta<typeof SlideController>; | ||
|
||
type Story = StoryObj<typeof SlideController>; | ||
|
||
export const Left: Story = { | ||
args: { | ||
direction: Direction.LEFT, | ||
onClick: () => {}, | ||
view: Device.TABLET, | ||
}, | ||
}; | ||
|
||
export const Right: Story = { | ||
args: { | ||
direction: Direction.RIGHT, | ||
onClick: () => {}, | ||
view: Device.TABLET, | ||
}, | ||
}; | ||
|
||
export const PC: Story = { | ||
args: { | ||
direction: Direction.RIGHT, | ||
onClick: () => {}, | ||
view: Device.PC, | ||
}, | ||
}; |
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,31 @@ | ||
'use client'; | ||
|
||
import { Vector } from 'assets'; | ||
|
||
import * as S from './style'; | ||
|
||
import type { Direction } from 'utils'; | ||
import type { Device } from 'utils'; | ||
|
||
interface Props { | ||
direction: Direction; | ||
onClick: () => void; | ||
view: Device; | ||
} | ||
|
||
const ControllerType = { | ||
left: S.PrevController, | ||
right: S.NextController, | ||
} as const; | ||
|
||
const SlideController: React.FC<Props> = ({ direction, onClick, view }) => { | ||
const Controller = ControllerType[direction]; | ||
|
||
return ( | ||
<Controller type="button" onClick={onClick} view={view}> | ||
<Vector /> | ||
</Controller> | ||
); | ||
}; | ||
|
||
export default SlideController; |
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,27 @@ | ||
import styled from '@emotion/styled'; | ||
import type { Device } from 'utils'; | ||
|
||
enum Margin { | ||
PC = '3.125rem', | ||
TABLET = '1.875rem', | ||
} | ||
|
||
export const Controller = styled.button<{ view: Device }>` | ||
border: none; | ||
z-index: 1; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease-in-out; | ||
background-color: ${({ theme }) => theme.gray[0]}; | ||
`; | ||
|
||
export const PrevController = styled(Controller)` | ||
margin-right: ${({ view }) => Margin[view]}; | ||
`; | ||
|
||
export const NextController = styled(Controller)` | ||
margin-left: ${({ view }) => Margin[view]}; | ||
svg { | ||
transform: matrix(-1, 0, 0, 1, 0, 0); | ||
} | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as useFilterProjects } from './useFilterProjects'; | ||
export { default as useHandleSlide } from './useHandleSlide'; | ||
export { default as useWindowResizeEffect } from './useWindowResizeEffect'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
|
||
const useHandleSlide = (maxIndex: number) => { | ||
const [slideIndex, setSlideIndex] = useState<number>(0); | ||
|
||
const increaseIndex = (index: number) => index + 1; | ||
const decreaseIndex = (index: number) => index - 1; | ||
|
||
const handlePrevSlide = () => { | ||
setSlideIndex(curIndex => | ||
curIndex === 0 ? maxIndex : decreaseIndex(curIndex), | ||
); | ||
}; | ||
|
||
const handleNextSlide = () => { | ||
setSlideIndex(curIndex => | ||
curIndex === maxIndex ? 0 : increaseIndex(curIndex), | ||
); | ||
}; | ||
|
||
return { | ||
slideIndex, | ||
handlePrevSlide, | ||
handleNextSlide, | ||
}; | ||
}; | ||
|
||
export default useHandleSlide; |
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,4 @@ | ||
export enum Device { | ||
PC = 'PC', | ||
TABLET = 'TABLET', | ||
} |
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,4 @@ | ||
export enum Direction { | ||
LEFT = 'left', | ||
RIGHT = 'right', | ||
} |
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 * from './device'; | ||
export * from './direction'; | ||
export * from './windowSize'; |
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,4 @@ | ||
export enum WindowSize { | ||
TABLET_SIZE = 1280, | ||
MOBILE_SIZE = 620, | ||
} |