-
Notifications
You must be signed in to change notification settings - Fork 7
Toast, BadgeList 컴포넌트 추가 #65
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
6 commits
Select commit
Hold shift + click to select a range
b9ef53e
feat: Add util function (excludeTags, camelCase) - Issue #16
hhhyyo df41805
chore: Modify layout styling - Issue #16
hhhyyo 1875744
feat: Add BadgeListPorps type - Issue #16
hhhyyo 0ca07c4
feat: Apply emotion to BadgeList - Issue #16
hhhyyo 07d0478
feat: Create Toast component - Issue #16
hhhyyo bca6f49
Merge branch 'feature/migration-detail' into develop
hhhyyo 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| <div id="__next"></div> | ||
| <div id="loading-start" aria-live="assertive"></div> | ||
| <div id="loading-end" aria-live="assertive"></div> | ||
| <div id="dialog"></div> | ||
| <div id="dialog"></div> | ||
| <div id="toast"></div> |
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| type IconType = | ||
| export type IconType = | ||
| | 'dairyFree' | ||
| | 'lactoOvo' | ||
| | 'lactoOvoVegetarian' | ||
|
|
||
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,7 @@ | ||
| import styled from '@emotion/styled'; | ||
|
|
||
| export const StyledUl = styled.ul` | ||
| display: flex; | ||
| gap: 10px; | ||
| flex-wrap: wrap; | ||
| `; |
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 @@ | ||
| import { IconType } from 'components/Badge/Badge.types'; | ||
|
|
||
| export interface BadgeListProps { | ||
| tags: IconType[]; | ||
| } |
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 |
|---|---|---|
| @@ -1,15 +1,16 @@ | ||
| import styled from '@emotion/styled'; | ||
| import { headerHeight } from 'components/Header/Header.styled'; | ||
| import { media, pxToRem } from 'utils'; | ||
| import { HEADER_HEIGHT } from 'styles/GlobalStyle'; | ||
| import { pxToRem, media } from 'utils'; | ||
|
|
||
| export const StyledMain = styled.main` | ||
| margin-top: ${headerHeight}px; | ||
| margin: ${pxToRem(HEADER_HEIGHT)} auto 0; | ||
|
|
||
| ${media.mobile} { | ||
| padding: ${pxToRem(10)}; | ||
| min-width: 320px; | ||
| } | ||
|
|
||
| ${media.desktop} { | ||
| max-width: 1500px; | ||
| margin: ${headerHeight}px auto 0; | ||
| } | ||
| `; |
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,27 @@ | ||
| import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
| import { Toast } from './Toast'; | ||
|
|
||
| export default { | ||
| title: 'Toast', | ||
| component: Toast, | ||
| args: { | ||
| message: 'message', | ||
| }, | ||
| } as ComponentMeta<typeof Toast>; | ||
|
|
||
| const Template: ComponentStory<typeof Toast> = (args) => <Toast {...args} />; | ||
|
|
||
| export const Default = Template.bind({}); | ||
|
|
||
| export const LongMessage = Template.bind({}); | ||
|
|
||
| LongMessage.args = { | ||
| message: | ||
| 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', | ||
| }; | ||
|
|
||
| export const Copied = Template.bind({}); | ||
|
|
||
| Copied.args = { | ||
| message: 'Copied', | ||
| }; |
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,18 @@ | ||
| import { css } from '@emotion/react'; | ||
| import styled from '@emotion/styled'; | ||
|
|
||
| export const StyledP = styled.p` | ||
| background: rgba(36, 36, 36, 0.8); | ||
| backdrop-filter: blur(2px); | ||
| color: ${({ theme }) => theme.color.white}; | ||
| width: fit-content; | ||
| padding: 10px 30px; | ||
| border-radius: 15px; | ||
| position: fixed; | ||
| bottom: 20px; | ||
| left: 50%; | ||
| transform: translateX(-50%); | ||
| max-width: 80%; | ||
| word-break: break-all; | ||
| text-align: center; | ||
| `; |
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,7 @@ | ||
| import { createPortal } from 'react-dom'; | ||
| import { StyledP } from './Toast.styled'; | ||
| import { ToastProps } from './Toast.types'; | ||
|
|
||
| export const Toast = ({ message }: ToastProps) => { | ||
| return createPortal(<StyledP>{message}</StyledP>, document.getElementById('toast')!); | ||
| }; | ||
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,3 @@ | ||
| export interface ToastProps { | ||
| message: string; | ||
| } |
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
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 |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| export const excludeTags = (content: string) => content.replace(/<[^>]*>/g, ''); | ||
|
|
||
| export const camelCase = (data: string) => data.replace(/\s\w/g, (match) => match.toUpperCase().trim()); |
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.
저도 갖다 쓸 수 있는 토스트 컴포넌트를 만들어주셔서 감사합니다.
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.
효원님 제가 Toast 쓰는 useToast 훅 만들었는데 detail페이지에서 가져다 쓰셔도 좋을 것 같아요.
곧 푸시할게요
useToast에 duration을 ms 단위로 전달하면 showToast라는 boolean 상태랑 displayToast라는 함수를 객체로 반환하는데
{ showToast && } 로 렌더링 리턴하고 이벤트 발생 시 displayToast를 호출만 하면 됩니당