Skip to content
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

feature/#13-title #17

Merged
merged 13 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
#6 💄 toast
  • Loading branch information
BonhaengLee committed Dec 31, 2022
commit 5275c239696421eb07eb3d8d3085588b0b6fcb7c
35 changes: 25 additions & 10 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { css } from "@emotion/react";
import { ReactElement } from "react";
import { ReactElement, useEffect } from "react";
import tw from "twin.macro";

import BottomSheet from "../src/components/BottomSheet/BottomSheet";
import Input from "../src/components/Input/Input";
import CommonLayout from "../src/components/Layout/CommonLayout";
import ProjectList from "../src/components/ProjectList/ProjectList";
import LimitedTextarea from "../src/components/Textarea/LimitedTextarea";
import ToastMessage from "../src/components/Toast/ToastMessage";
import Button from "../src/components/Button/Button";
import ButtonArea from "../src/components/Button/ButtonArea";
import PopUp from "../src/components/PopUp/PopUp";
import useDisclosure from "../src/hooks/useDisclosure";
import Toast from "../src/components/Toast/Toast";

function App() {
const projectListData = [
Expand Down Expand Up @@ -80,21 +79,31 @@ function App() {
},
];

// usePopup
const {
isOpen: isOpenPopUp,
onOpen: onOpenPopUp,
onClose: onClosePopUp,
} = useDisclosure();

// useToast
const {
isOpen: isOpenToast,
onOpen: onOpenToast,
onClose: onCloseToast,
} = useDisclosure();
useEffect(() => {
setTimeout(() => {
onCloseToast();
}, 3000);
});

return (
<div>
<ProjectList data={projectListData} />

<div css={[tw`mt-[30px]`, css``]} />
<ToastMessage />

{/* popup */}
<div css={[tw`mt-[30px]`, css``]} />
<div css={[tw`mt-[30px]`]} />
<Button as="button" type="button" onClick={onOpenPopUp}>
<span>[팝업버튼]알림 방식을 선택하세요.</span>
</Button>
Expand All @@ -119,13 +128,19 @@ function App() {
]}
/>

<div css={[tw`mt-[30px]`, css``]} />
<div css={[tw`mt-[30px]`]} />
<Button as="button" type="button" onClick={onOpenToast}>
<span>[토스트버튼]duration:3000</span>
</Button>
<Toast show={isOpenToast} title="본캐 홍길동 어쩌고 저쩌고 했습니다." />

<div css={[tw`mt-[30px]`]} />
<BottomSheet />

<div css={[tw`mt-[30px]`, css``]} />
<div css={[tw`mt-[30px]`]} />
<Input />

<div css={[tw`mt-[30px]`, css``]} />
<div css={[tw`mt-[30px]`]} />
<LimitedTextarea minInput={10} maxInput={1000} />
<ButtonArea>
<Button theme="secondary" as="a" href="www.google.com">
Expand Down
48 changes: 48 additions & 0 deletions src/components/Toast/Toast.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.toast {
position: fixed;
bottom: 24px;
padding: 3px;
overflow-y: auto;
overflow-x: hidden;
display: inline-flex;
flex-wrap: nowrap;
flex-direction: column-reverse;
z-index: 50;

&Inner {
display: flex;
align-items: center;
justify-content: center;
position: relative;
margin-top: 6px;
height: 48px;
width: calc(100vw - 40px);
border-radius: 12px;
overflow: hidden;
opacity: 0.8;
background: #292929;
color: #fff;
&.hide {
display: none;
}
}
&Title {
text-align: center;
}

&.fadeOut {
display: block;
visibility: hidden;
opacity: 0;
-webkit-transition: visibility 1.5s, opacity 1.5s;
-moz-transition: visibility 1.5s, opacity 1.5s;
-ms-transition: visibility 1.5s, opacity 1.5s;
-o-transition: visibility 1.5s, opacity 1.5s;
transition: visibility 1.5s, opacity 1.5s;
-webkit-transition-delay: 3s;
-moz-transition-delay: 3s;
-ms-transition-delay: 3s;
-o-transition-delay: 3s;
transition-delay: 3s;
}
}
20 changes: 20 additions & 0 deletions src/components/Toast/Toast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import clsx from "clsx";

import styles from "./Toast.module.scss";

export interface ToastMessageParams {
show?: boolean;
title?: string;
}

function ToastMessage({ show = false, title }: ToastMessageParams) {
return (
<div className={clsx(styles.toast, show && styles.fadeOut)}>
<div className={clsx(styles.toastInner, !show && styles.hide)}>
<p className={styles.toastTitle}>{title}</p>
</div>
</div>
);
}

export default ToastMessage;
52 changes: 0 additions & 52 deletions src/components/Toast/ToastMessage.tsx

This file was deleted.