Skip to content

Commit

Permalink
refactor: 프로젝트 폴더, 파일구조 변경 (멘토링 참고)
Browse files Browse the repository at this point in the history
  • Loading branch information
cksrlcks committed Nov 28, 2024
1 parent 0b874d0 commit defb4b6
Show file tree
Hide file tree
Showing 111 changed files with 235 additions and 405 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styles from "./styles.module.scss";
import styles from "./Error.module.scss";

export default function Error({ error }) {
export function Error({ error }) {
if (!error) {
return null;
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styles from "./styles.module.scss";
import styles from "./FieldItem.module.scss";

export default function FieldItem({ children }) {
export function FieldItem({ children }) {
return <div className={styles["form-item"]}>{children}</div>;
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Alert from "@components/Alert";
import LoadingSpinner from "@components/LoadingSpinner";
import { Alert, LoadingSpinner } from "@components/ui";

export default function ProductForm({ isLoading, error, onSubmit, children }) {
export function Form({ isLoading, error, onSubmit, children }) {
return (
<>
{isLoading && <LoadingSpinner />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import useSingleFile from "@hooks/useSingleFile";
import Preview from "../Preview";
import Error from "../Error";
import { Preview, Error } from "@components/Field";
import iconPlus from "@assets/img/icon/icon_plus.svg";
import styles from "./styles.module.scss";
import styles from "./ImageUpload.module.scss";

const LIMIT_SIZE_MB = 2;

export default function ImageUpload({
export function ImageUpload({
error,
value,
id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useState } from "react";
import clsx from "clsx";
import Error from "../Error";
import { Error } from "@components/Field";
import iconViewOn from "@assets/img/icon/icon_view_on.svg";
import iconViewOff from "@assets/img/icon/icon_view_off.svg";
import styles from "./styles.module.scss";
import styles from "./Input.module.scss";

export default function Input({ type = "text", error, value, ...props }) {
export function Input({ type = "text", error, value, ...props }) {
const [currentType, setCurrentType] = useState(type);
const valid = value && !error;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from "react";
import clsx from "clsx";
import Error from "../Error";
import { Error } from "@components/Field";

export default function NumberInput({
export function NumberInput({
type = "number",
error,
value,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import clearIcon from "@assets/img/icon/icon_clear.svg";
import styles from "./styles.module.scss";
import styles from "./Preview.module.scss";

export default function Preview({ src, onRemove }) {
export function Preview({ src, onRemove }) {
return (
<figure className={styles.cover}>
<button type="button" className={styles.button} onClick={onRemove}>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { useRef } from "react";
import clsx from "clsx";
import Tags from "@components/Tags";
import Error from "../Error";
import { Tags } from "@components/ui";
import { Error } from "@components/Field";

export default function TagsInput({
error,
value,
id,
name,
onChange,
placeholder,
}) {
export function TagsInput({ error, value, id, name, onChange, placeholder }) {
const inputRef = useRef(null);
const valid = value.length && !error;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import clsx from "clsx";
import Error from "../Error";
import { Error } from "@components/Field";

export default function Textarea({ error, value, ...props }) {
export function Textarea({ error, value, ...props }) {
const valid = value && !error;

return (
Expand Down
5 changes: 0 additions & 5 deletions src/components/Field/Textarea/styles.module.scss

This file was deleted.

9 changes: 9 additions & 0 deletions src/components/Field/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from "./Form";
export * from "./Error";
export * from "./FieldItem";
export * from "./Input";
export * from "./Textarea";
export * from "./TagsInput";
export * from "./ImageUpload";
export * from "./NumberInput";
export * from "./Preview";
17 changes: 0 additions & 17 deletions src/components/Field/index.jsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Link } from "react-router-dom";
import styles from "./styles.module.scss";
import styles from "./Footer.module.scss";

import facebookIcon from "@assets/img/icon/icon_facebook.svg";
import twitterIcon from "@assets/img/icon/icon_twitter.svg";
import youtubeIcon from "@assets/img/icon/icon_youtube.svg";
import instagramIcon from "@assets/img/icon/icon_instagram.svg";

export default function Footer() {
export function Footer() {
return (
<footer className={styles.footer}>
<div className={styles.inner}>
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/components/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Footer";
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Logo from "./Logo";
import Nav from "./Nav";
import Util from "./Util";
import styles from "./styles.module.scss";
import { Logo, Nav, Util } from "@components/Header";
import styles from "./Header.module.scss";

export default function Header({ showNav = false }) {
export function Header({ showNav = false }) {
return (
<header className={styles.header}>
<nav className={styles.nav}>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Link } from "react-router-dom";
import logoPC from "@assets/img/common/logo_full.svg";
import logoMobile from "@assets/img/common/logo_text.svg";
import styles from "./styles.module.scss";
import styles from "./Logo.module.scss";

export default function Logo() {
export function Logo() {
return (
<h1 className={styles.logo}>
<Link to="/">
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NavLink, useLocation } from "react-router-dom";
import clsx from "clsx";
import styles from "./styles.module.scss";
import styles from "./Nav.module.scss";

const MENU = [
{
Expand All @@ -19,7 +19,7 @@ function isInclude(path, list = []) {
return list.includes(path);
}

export default function Nav() {
export function Nav() {
const { pathname } = useLocation();

return (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Dropdown from "@components/Dropdown";
import Avatar from "@components/Avatar";
import { Dropdown, Avatar } from "@components/ui";

export default function Profile({ user, onLogout }) {
export function Profile({ user, onLogout }) {
function handleLogout() {
if (confirm("정말로 로그아웃 하시겠습니까?")) {
onLogout();
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useAuth } from "@context/AuthContext";
import Button from "@components/Button";
import Profile from "@components/Header/Profile";
import styles from "./styles.module.scss";
import { Button } from "@components/ui";
import { Profile } from "@components/Header";
import styles from "./Util.module.scss";

export default function Util() {
export function Util() {
const {
auth: { user },
handleLogout,
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./Header";
export * from "./Logo";
export * from "./Nav";
export * from "./Profile";
export * from "./Util";
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Outlet } from "react-router-dom";
import Header from "../Header";
import Footer from "../Footer";
import styles from "./styles.module.scss";
import { Header } from "@components/Header";
import { Footer } from "@components/Footer";
import styles from "./Layout.module.scss";

export default function Layout({ hasNav = false, hasFooter = false }) {
export function Layout({ hasNav = false, hasFooter = false }) {
return (
<>
<Header showNav={hasNav} />
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/components/Layout/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Layout";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LoadingSpinner from "@components/LoadingSpinner";
import Message from "./Message";
import { LoadingSpinner } from "@components/ui";
import { Message } from "@components/List";

export default function List({
export function List({
items,
renderItem,
isLoading,
Expand Down
5 changes: 5 additions & 0 deletions src/components/List/Message.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styles from "./Message.module.scss";

export function Message({ children }) {
return <div className={styles.message}>{children}</div>;
}
File renamed without changes.
5 changes: 0 additions & 5 deletions src/components/List/Message/index.jsx

This file was deleted.

2 changes: 2 additions & 0 deletions src/components/List/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./List";
export * from "./Message";
5 changes: 5 additions & 0 deletions src/components/Page/PageWrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styles from "./PageWrapper.module.scss";

export function PageWrapper({ children }) {
return <div className={styles.container}>{children}</div>;
}
File renamed without changes.
1 change: 1 addition & 0 deletions src/components/Page/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./PageWrapper";
5 changes: 0 additions & 5 deletions src/components/PageContainer/index.jsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import clsx from "clsx";
import arrowLeft from "@assets/img/icon/icon_arrow_left.svg";
import arrowRight from "@assets/img/icon/icon_arrow_right.svg";
import styles from "./styles.module.scss";
import styles from "./Pagination.module.scss";

export default function Pagination({
export function Pagination({
page,
pageNumbers,
isPrevDisabled,
Expand Down
1 change: 1 addition & 0 deletions src/components/Pagination/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Pagination";
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { cloneElement, useEffect, useRef, useState } from "react";
import searchIcon from "@assets/img/icon/icon_search.svg";
import styles from "./styles.module.scss";
import styles from "./Recent.module.scss";

export default function Recent({
export function Recent({
title,
data,
onItemClick,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useRef } from "react";
import searchIcon from "@assets/img/icon/icon_search.svg";
import clearIcon from "@assets/img/icon/icon_clear.svg";
import styles from "./styles.module.scss";
import styles from "./Search.module.scss";

export default function Search({
export function Search({
value,
onChange,
onSubmit,
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/components/Search/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./Search";
export * from "./Recent";
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styles from "./styles.module.scss";
import styles from "./Section.module.scss";

function Section({ children }) {
export function Section({ children }) {
return <section className={styles.section}>{children}</section>;
}

Expand All @@ -19,5 +19,3 @@ function Content({ children }) {

Section.Header = Header;
Section.Content = Content;

export default Section;
File renamed without changes.
1 change: 1 addition & 0 deletions src/components/Section/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Section";
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import clsx from "clsx";
import iconError from "@assets/img/icon/icon_error.svg";
import iconWarn from "@assets/img/icon/icon_warn.svg";
import styles from "./styles.module.scss";
import clsx from "clsx";
import styles from "./Alert.module.scss";

const iconImg = {
warn: { src: iconWarn, alt: "경고" },
error: { src: iconError, alt: "에러" },
};

export default function Alert({ mode = "error", children }) {
export function Alert({ mode = "error", children }) {
return (
<div className={clsx(styles.alert, styles[mode])}>
<img src={iconImg[mode].src} alt={iconImg[mode].alt} />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import defaultAvatar from "@assets/img/icon/icon_avatar.svg";
import styles from "./styles.module.scss";
import styles from "./Avatar.module.scss";

export default function Avatar({ nickname, img }) {
export function Avatar({ nickname, img }) {
const avatarImg = img || defaultAvatar;

function handleError(e) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Link } from "react-router-dom";
import clsx from "clsx";
import styles from "./styles.module.scss";
import styles from "./Button.module.scss";

export default function Button({ to, className, children, size, ...props }) {
export function Button({ to, className, children, size, ...props }) {
const css = clsx(styles.btn, size && styles[`btn-${size}`], className);
const Component = to ? Link : "button";
const ComponentProps = {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/components/Chip/index.jsx → src/components/ui/Chip.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import clearIcon from "@assets/img/icon/icon_clear.svg";
import styles from "./styles.module.scss";
import styles from "./Chip.module.scss";

export default function Chip({ removable, text, onClick }) {
export function Chip({ removable, text, onClick }) {
return (
<div className={styles.chip}>
{text}
Expand Down
File renamed without changes.
Loading

0 comments on commit defb4b6

Please sign in to comment.