-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/switch #29
Merged
Merged
Feat/switch #29
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eed2197
feat(ui-kit): switch 컴포넌트 추가
Junkim93 e83846e
feat(ui-kit): label 추가
Junkim93 11b8e67
feat(ui-kit): inline 케이스 추가 및 스타일 일부 수정
Junkim93 a943bce
feat(ui-kit): 컴포넌트 수정에 따른 스토리 수정
Junkim93 4d368c8
Merge branch 'alpha' into feat/switch
Junkim93 9e16c2a
feat(ui-kit): Switch transform 퍼센트 값으로 변경
Junkim93 8089323
Merge branch 'alpha' into feat/switch
Junkim93 286c927
feat(ui-kit): 스위치 슬라이더 x축 이동 롤백
Junkim93 e4891dc
Merge branch 'alpha' into feat/switch
Junkim93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { forwardRef } from 'react'; | ||
import { Ref } from 'react'; | ||
import { CombineElementProps } from 'src/types/utils'; | ||
import clxs from 'classnames'; | ||
import { generateID } from 'src/utils/generateID'; | ||
import { Text } from '..'; | ||
|
||
interface SwitchBaseProps { | ||
label?: string; | ||
display?: 'block' | 'inline'; | ||
} | ||
type SwitchProps = Omit<CombineElementProps<'input', SwitchBaseProps>, 'type'>; | ||
|
||
const Switch = ( | ||
{ label, display = 'block', style, ...props }: SwitchProps, | ||
ref: Ref<HTMLInputElement> | ||
) => { | ||
const id = generateID('switch'); | ||
|
||
return ( | ||
<label | ||
role="switch" | ||
className={clxs('lubycon-switch', `lubycon-switch--display-${display}`)} | ||
style={style} | ||
> | ||
<input className="lubycon-switch--input" ref={ref} type="checkbox" {...props} id={id} /> | ||
<span className="lubycon-switch--slider" /> | ||
{label ? <Text as="span">{label}</Text> : null} | ||
</label> | ||
); | ||
}; | ||
|
||
export default forwardRef(Switch) as typeof Switch; |
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,46 @@ | ||
.lubycon-switch { | ||
border-radius: 31.5px; | ||
display: flex; | ||
align-items: center; | ||
position: relative; | ||
cursor: pointer; | ||
|
||
&--input { | ||
display: none; | ||
} | ||
|
||
&--slider { | ||
position: relative; | ||
width: 40px; | ||
height: 21px; | ||
margin-right: 8px; | ||
border-radius: 31.5px; | ||
background-color: map-get($colors, 'gray40'); | ||
transition: background-color 0.3s; | ||
|
||
&::before { | ||
content: ''; | ||
position: absolute; | ||
width: 15px; | ||
height: 15px; | ||
left: 3.31px; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
background-color: #ffffff; | ||
border-radius: 50%; | ||
transition: transform 0.3s; | ||
} | ||
} | ||
|
||
&--input:checked + &--slider { | ||
background-color: map-get($colors, 'green50'); | ||
} | ||
|
||
&--input:checked + &--slider::before { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 나중에 스위치도 사이즈 요소가 추가될 수 있을 것 같은데, X측도 |
||
transform: translate(18.38px, -50%); | ||
} | ||
|
||
&--display-inline { | ||
display: inline-flex; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
@import './Row'; | ||
@import './Column'; | ||
@import './Checkbox'; | ||
@import './Switch'; |
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,32 @@ | ||
import React from 'react'; | ||
import { Meta } from '@storybook/react/types-6-0'; | ||
import Text from 'components/Text'; | ||
import Switch from 'components/Switch'; | ||
import { colors } from '../constants/colors'; | ||
|
||
export default { | ||
title: 'Lubycon UI Kit/Switch', | ||
} as Meta; | ||
|
||
export const Default = () => { | ||
return ( | ||
<div> | ||
<Text as="h2" typography="h2" style={{ color: colors.gray100 }}> | ||
스위치 | ||
</Text> | ||
<div style={{ padding: 0 }}> | ||
<Switch label={'Off'} style={{ marginBottom: '23.17px' }} /> | ||
<Switch defaultChecked={true} label={'On'} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export const Inline = () => { | ||
return ( | ||
<div> | ||
<Switch display="inline" label="Off" style={{ marginRight: '20px' }} /> | ||
<Switch defaultChecked={true} display="inline" label="On" /> | ||
</div> | ||
); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 애니메이션 디테일 👍👍👍