-
Notifications
You must be signed in to change notification settings - Fork 4
feat(ui): Bottom Sheet #284
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
10802da
docs: add toss/react
bbfb603
chore: change eslint extraneous rule, off
a783475
feat: context for bottom sheet open state control
4173c38
feat: bottom sheet composite components
2fe9bac
chore: export bottom sheet ui
d2778d1
feat: add storybook and example
a3fbe95
chore: 오타 수정
816dfc2
feat: displayName 추가 및 overflow hidden 시 shift 방지 로직 추가
dc2efe3
feat: storybook 개선
8a8093e
chore: resolve deps
3e8f831
chore: bottom sheet changeset
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 hidden or 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,5 @@ | ||
| --- | ||
| '@sopt-makers/ui': minor | ||
| --- | ||
|
|
||
| bottom sheet component |
This file contains hidden or 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 hidden or 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,155 @@ | ||
| import { | ||
| BottomSheetActionButton, | ||
| BottomSheetBody, | ||
| BottomSheetContent, | ||
| BottomSheetRoot, | ||
| BottomSheetTrigger, | ||
| } from '@sopt-makers/ui'; | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| type SampleProps = { | ||
| open?: boolean; | ||
| onOpenChange?: (open: boolean) => void; | ||
| defaultOpen?: boolean; | ||
| title?: string; | ||
| backIcon?: boolean; | ||
| }; | ||
|
|
||
| const meta: Meta<SampleProps> = { | ||
| title: 'Components/BottomSheet', | ||
| tags: ['autodocs'], | ||
| parameters: { | ||
| docs: { | ||
| codePanel: true, | ||
| }, | ||
| }, | ||
| args: { | ||
| defaultOpen: false, | ||
| title: 'Title', | ||
| backIcon: false, | ||
| }, | ||
| argTypes: { | ||
| open: { type: 'boolean', control: { type: 'boolean' }, description: '`boolean`' }, | ||
| onOpenChange: { | ||
| type: 'function', | ||
| control: { type: 'function' }, | ||
| description: '`(open:boolean) => void`', | ||
| }, | ||
| defaultOpen: { | ||
| type: 'boolean', | ||
| control: { type: 'boolean' }, | ||
| description: '`boolean`', | ||
| }, | ||
| title: { type: 'string', control: { type: 'string' }, description: '`string`' }, | ||
| backIcon: { type: 'boolean', control: { type: 'boolean' }, description: '`boolean`' }, | ||
| }, | ||
| }; | ||
| export default meta; | ||
|
|
||
| export const BottomSheetDefault: StoryObj<SampleProps> = { | ||
| name: 'BottomSheet - Default', | ||
| render: (args) => { | ||
| return ( | ||
| <BottomSheetRoot open={args.open} onOpenChange={args.onOpenChange} defaultOpen={args.defaultOpen}> | ||
| <BottomSheetTrigger> | ||
| <button>열기</button> | ||
| </BottomSheetTrigger> | ||
| <BottomSheetContent title={args.title} backIcon={args.backIcon}> | ||
| <BottomSheetBody> | ||
| <p style={{ color: 'white' }}> | ||
| 커뮤니티 이용규칙은 누구나 기분 좋게 참여할 수 있는 커뮤니티를 만들기 위해 제정되었습니다. 서비스 내의 | ||
| 모든 커뮤니티는 커뮤니티 이용규칙에 의해 운영되므로, 이용자는 커뮤니티 이용 전 반드시 모든 내용을 | ||
| 숙지하여야 합니다. 방송통신심의위원회의 정보통신에 관한 심의규정, 현행 법률, 서비스 이용약관 및 커뮤니티 | ||
| 이용규칙을 위반하거나, 사회 통념 및 관련 법령을 기준으로 타 이용자에게 악영향을 끼치는 경우, 게시물이 | ||
| 삭제되고 서비스 이용이 일정 기간 제한될 수 있습니다. | ||
| </p> | ||
| </BottomSheetBody> | ||
| </BottomSheetContent> | ||
| </BottomSheetRoot> | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| export const BottomSheetBackIcon: StoryObj<SampleProps> = { | ||
| name: 'BottomSheet - Back Icon', | ||
| render: (args) => ( | ||
| <BottomSheetRoot open={args.open} onOpenChange={args.onOpenChange} defaultOpen={args.defaultOpen}> | ||
| <BottomSheetTrigger> | ||
| <button>열기</button> | ||
| </BottomSheetTrigger> | ||
| <BottomSheetContent title={args.title} backIcon={args.backIcon}> | ||
| <BottomSheetBody> | ||
| <p style={{ color: 'white' }}> | ||
| 커뮤니티 이용규칙은 누구나 기분 좋게 참여할 수 있는 커뮤니티를 만들기 위해 제정되었습니다. 서비스 내의 모든 | ||
| 커뮤니티는 커뮤니티 이용규칙에 의해 운영되므로, 이용자는 커뮤니티 이용 전 반드시 모든 내용을 숙지하여야 | ||
| 합니다. 방송통신심의위원회의 정보통신에 관한 심의규정, 현행 법률, 서비스 이용약관 및 커뮤니티 이용규칙을 | ||
| 위반하거나, 사회 통념 및 관련 법령을 기준으로 타 이용자에게 악영향을 끼치는 경우, 게시물이 삭제되고 서비스 | ||
| 이용이 일정 기간 제한될 수 있습니다. | ||
| </p> | ||
| </BottomSheetBody> | ||
| </BottomSheetContent> | ||
| </BottomSheetRoot> | ||
| ), | ||
| args: { | ||
| backIcon: true, | ||
| }, | ||
| }; | ||
|
|
||
| export const BottomSheetWithActionButton: StoryObj<SampleProps> = { | ||
| name: 'BottomSheet - Action Button', | ||
| render: (args) => ( | ||
| <BottomSheetRoot open={args.open} onOpenChange={args.onOpenChange} defaultOpen={args.defaultOpen}> | ||
| <BottomSheetTrigger> | ||
| <button>열기</button> | ||
| </BottomSheetTrigger> | ||
| <BottomSheetContent title={args.title} backIcon={args.backIcon}> | ||
| <BottomSheetBody> | ||
| <p style={{ color: 'white' }}> | ||
| 커뮤니티 이용규칙은 누구나 기분 좋게 참여할 수 있는 커뮤니티를 만들기 위해 제정되었습니다. 서비스 내의 모든 | ||
| 커뮤니티는 커뮤니티 이용규칙에 의해 운영되므로, 이용자는 커뮤니티 이용 전 반드시 모든 내용을 숙지하여야 | ||
| 합니다. 방송통신심의위원회의 정보통신에 관한 심의규정, 현행 법률, 서비스 이용약관 및 커뮤니티 이용규칙을 | ||
| 위반하거나, 사회 통념 및 관련 법령을 기준으로 타 이용자에게 악영향을 끼치는 경우, 게시물이 삭제되고 서비스 | ||
| 이용이 일정 기간 제한될 수 있습니다. | ||
| </p> | ||
| </BottomSheetBody> | ||
| <BottomSheetActionButton>Button</BottomSheetActionButton> | ||
| </BottomSheetContent> | ||
| </BottomSheetRoot> | ||
| ), | ||
| }; | ||
|
|
||
| export const BottomSheetBodyScrolled: StoryObj<SampleProps> = { | ||
| name: 'BottomSheet - Body Scrolled', | ||
| render: (args) => ( | ||
| <BottomSheetRoot open={args.open} onOpenChange={args.onOpenChange} defaultOpen={args.defaultOpen}> | ||
| <BottomSheetTrigger> | ||
| <button>열기</button> | ||
| </BottomSheetTrigger> | ||
| <BottomSheetContent title={args.title} backIcon={args.backIcon}> | ||
| <BottomSheetBody> | ||
| <p style={{ color: 'white' }}> | ||
| 커뮤니티 이용규칙은 누구나 기분 좋게 참여할 수 있는 커뮤니티를 만들기 위해 제정되었습니다. 서비스 내의 모든 | ||
| 커뮤니티는 커뮤니티 이용규칙에 의해 운영되므로, 이용자는 커뮤니티 이용 전 반드시 모든 내용을 숙지하여야 | ||
| 합니다. 방송통신심의위원회의 정보통신에 관한 심의규정, 현행 법률, 서비스 이용약관 및 커뮤니티 이용규칙을 | ||
| 위반하거나, 사회 통념 및 관련 법령을 기준으로 타 이용자에게 악영향을 끼치는 경우, 게시물이 삭제되고 서비스 | ||
| 이용이 일정 기간 제한될 수 있습니다. 커뮤니티 이용규칙은 누구나 기분 좋게 참여할 수 있는 커뮤니티를 만들기 | ||
| 위해 제정되었습니다. 서비스 내의 모든 커뮤니티는 커뮤니티 이용규칙에 의해 운영되므로, 이용자는 커뮤니티 이용 | ||
| 전 반드시 모든 내용을 숙지하여야 합니다. 방송통신심의위원회의 정보통신에 관한 심의규정, 현행 법률, 서비스 | ||
| 이용약관 및 커뮤니티 이용규칙을 위반하거나, 사회 통념 및 관련 법령을 기준으로 타 이용자에게 악영향을 끼치는 | ||
| 경우, 게시물이 삭제되고 서비스 이용이 일정 기간 제한될 수 있습니다. 커뮤니티 이용규칙은 누구나 기분 좋게 | ||
| 참여할 수 있는 커뮤니티를 만들기 위해 제정되었습니다. 서비스 내의 모든 커뮤니티는 커뮤니티 이용규칙에 의해 | ||
| 운영되므로, 이용자는 커뮤니티 이용 전 반드시 모든 내용을 숙지하여야 합니다. 방송통신심의위원회의 정보통신에 | ||
| 관한 심의규정, 현행 법률, 서비스 이용약관 및 커뮤니티 이용규칙을 위반하거나, 사회 통념 및 관련 법령을 | ||
| 기준으로 타 이용자에게 악영향을 끼치는 경우, 게시물이 삭제되고 서비스 이용이 일정 기간 제한될 수 있습니다. | ||
| 커뮤니티 이용규칙은 누구나 기분 좋게 참여할 수 있는 커뮤니티를 만들기 위해 제정되었습니다. 서비스 내의 모든 | ||
| 커뮤니티는 커뮤니티 이용규칙에 의해 운영되므로, 이용자는 커뮤니티 이용 전 반드시 모든 내용을 숙지하여야 | ||
| 합니다. 방송통신심의위원회의 정보통신에 관한 심의규정, 현행 법률, 서비스 이용약관 및 커뮤니티 이용규칙을 | ||
| 위반하거나, 사회 통념 및 관련 법령을 기준으로 타 이용자에게 악영향을 끼치는 경우, 게시물이 삭제되고 서비스 | ||
| 이용이 일정 기간 제한될 수 있습니다. | ||
| </p> | ||
| </BottomSheetBody> | ||
| <BottomSheetActionButton>Button</BottomSheetActionButton> | ||
| </BottomSheetContent> | ||
| </BottomSheetRoot> | ||
| ), | ||
| }; |
This file contains hidden or 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 hidden or 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 @@ | ||
| import { createContext, PropsWithChildren, useContext } from 'react'; | ||
|
|
||
| interface ContextProps { | ||
| open: boolean; | ||
| onOpenChange: (open: boolean) => void; | ||
| } | ||
|
|
||
| export const BottomSheetContext = createContext<ContextProps | null>(null); | ||
|
|
||
| export function BottomSheetProvider({ open, onOpenChange, children }: PropsWithChildren<ContextProps>) { | ||
| return ( | ||
| <BottomSheetContext.Provider | ||
| value={{ | ||
| open, | ||
| onOpenChange, | ||
| }} | ||
| > | ||
| {children} | ||
| </BottomSheetContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| export function useBottomSheetContext() { | ||
| const context = useContext(BottomSheetContext); | ||
|
|
||
| if (context === null) { | ||
| throw new Error('this hook must be used within a BottomSheetProvider'); | ||
| } | ||
|
|
||
| return context; | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.