Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .storybook/preview-body.html
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>
2 changes: 1 addition & 1 deletion src/components/Badge/Badge.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type IconType =
export type IconType =
| 'dairyFree'
| 'lactoOvo'
| 'lactoOvoVegetarian'
Expand Down
7 changes: 7 additions & 0 deletions src/components/BadgeList/BadgeList.styled.tsx
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;
`;
5 changes: 5 additions & 0 deletions src/components/BadgeList/BadgeList.types.ts
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[];
}
8 changes: 4 additions & 4 deletions src/components/Header/Header.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import styled from '@emotion/styled';
import { IconButton } from 'components';
import { StyledHeaderProps } from './Header.types';

export const headerHeight = 70;
import { HEADER_HEIGHT } from 'styles/GlobalStyle';
import { pxToRem } from 'utils';

export const StyledHeader = styled.header<StyledHeaderProps>`
background-color: ${({ theme }) => theme.color.white};
box-shadow: 0 4px 10px rgba(0 0 0 / 10%);
padding: 0 10px 0 20px;
position: fixed;
top: 0;
${({ $hide }) => $hide && `top: ${-1 * headerHeight}px;`}
${({ $hide }) => $hide && `top: ${-1 * HEADER_HEIGHT}px;`}
left: 0;
right: 0;
transition: top 0.2s ease-in-out;
Expand All @@ -23,7 +23,7 @@ export const StyledDiv = styled.div`
align-items: center;
max-width: 1500px;
margin: 0 auto;
height: ${headerHeight}px;
height: ${pxToRem(HEADER_HEIGHT)};
`;

export const StyledIconButton = styled(IconButton)`
Expand Down
9 changes: 5 additions & 4 deletions src/components/Layout/Layout.styled.tsx
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;
}
`;
2 changes: 1 addition & 1 deletion src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Header } from '..';
import { Header } from 'components';
import { StyledMain } from './Layout.styled';
import { LayoutProps } from './Layout.types';

Expand Down
27 changes: 27 additions & 0 deletions src/components/Toast/Toast.stories.tsx
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',
};
18 changes: 18 additions & 0 deletions src/components/Toast/Toast.styled.tsx
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;
`;
7 changes: 7 additions & 0 deletions src/components/Toast/Toast.tsx
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) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 갖다 쓸 수 있는 토스트 컴포넌트를 만들어주셔서 감사합니다.

Copy link
Member

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를 호출만 하면 됩니당

return createPortal(<StyledP>{message}</StyledP>, document.getElementById('toast')!);
};
3 changes: 3 additions & 0 deletions src/components/Toast/Toast.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface ToastProps {
message: string;
}
1 change: 1 addition & 0 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function Document() {
<div id="loading-start" aria-live="assertive"></div>
<div id="loading-end" aria-live="assertive"></div>
<div id="dialog"></div>
<div id="toast"></div>
<NextScript />
</body>
</Html>
Expand Down
2 changes: 2 additions & 0 deletions src/styles/GlobalStyle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { css, Global } from '@emotion/react';
import emotionNormalize from 'emotion-normalize';

export const HEADER_HEIGHT = 70;

export const GlobalStyle = () => (
<Global
styles={css`
Expand Down
2 changes: 2 additions & 0 deletions src/utils/misc.ts
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());