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/BAR-199] 컨벤션에 맞춰서 폴더 구조 수정 #34

Merged
merged 3 commits into from
Jan 13, 2024
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
9 changes: 6 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
],
"unused-imports/no-unused-imports": "error",
"no-else-return": ["error", { "allowElseIf": false }],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-imports": [
"error",
{ "fixStyle": "inline-type-imports" }
],
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/naming-convention": [
"error",
Expand All @@ -48,9 +51,9 @@
"warn",
{
"groups": [
["^next", "^react", "^@\\w", "^\\w"],
["^next", "^react", "^@tanstack", "^@vanilla", "^\\w"],
["^\\u0000"],
["^@/"],
["^~", "^@"],
["^\\."]
]
}
Expand Down
2 changes: 2 additions & 0 deletions .storybook/preview-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div id="modal-root" />
<div id="tooltip-root" />
9 changes: 5 additions & 4 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { AppProps } from 'next/app';
import Layout from '@components/Layout/Layout';

import '@styles/global.css';

import Layout from '@components/Layout';
import Modal from '@components/Modal';
import TanstackQueryProvider from '@components/Providers/TanstackQueryProvider';
import Toast from '@components/Toast/Toast';
import Toast from '@components/Toast';
import { pretendard } from '@styles/font';

import '@styles/global.css';

const App = ({ Component, pageProps }: AppProps) => {
return (
<main className={pretendard.className}>
Expand Down
3 changes: 2 additions & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Head, Html, Main, NextScript } from 'next/document';
import { PORTAL_ID } from '@constants/portalId';

import { PORTAL_ID } from '@constants/portal';

const Document = () => {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BADGE_TYPE } from '@constants/badge';
import type { Meta, StoryObj } from '@storybook/react';

import Badge from './Badge';
import { BADGE_TYPE } from './constants';
import Badge from '.';

const meta: Meta<typeof Badge> = {
title: 'Components/Badge',
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/components/Badge/style.css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { recipe } from '@vanilla-extract/recipes';

import { sprinkles } from '@styles/sprinkles.css';
import { COLORS } from '@styles/tokens';
import { recipe } from '@vanilla-extract/recipes';

export const badge = recipe({
base: [
Expand Down
3 changes: 2 additions & 1 deletion src/components/Button/style.css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { recipe } from '@vanilla-extract/recipes';

import { sprinkles } from '@styles/sprinkles.css';
import { COLORS } from '@styles/tokens';
import { recipe } from '@vanilla-extract/recipes';

export const button = recipe({
variants: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { iconFactory, type Icons } from '../constants/icon';
import { iconFactory, type Icons } from '../../constants/icon';

interface IconProps {
icon: Icons;
Expand Down
5 changes: 3 additions & 2 deletions src/components/Input/WriteInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ChangeEvent, HTMLAttributes, KeyboardEvent } from 'react';
import { useMemo, useRef, useState } from 'react';
import { assignInlineVars } from '@vanilla-extract/dynamic';

import Icon from '@components/Icon';
import { MAIN_INPUT_MAX_LENGTH } from '@constants/config';
import type { UseInputReturn } from '@hooks/useInput';
import { COLORS } from '@styles/tokens';
import { assignInlineVars } from '@vanilla-extract/dynamic';

import Icon from '../../SvgIcon';
import * as style from './style.css';

interface WriteInputProps extends HTMLAttributes<HTMLTextAreaElement> {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Input/WriteInput/style.css.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { COLORS } from '@styles/tokens';
import { createVar, style } from '@vanilla-extract/css';
import { recipe } from '@vanilla-extract/recipes';

import { COLORS } from '@styles/tokens';

export const conatiner = style({
display: 'flex',
justifyContent: 'space-between',
Expand Down
File renamed without changes.
9 changes: 1 addition & 8 deletions src/components/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { useModalStore } from '@stores/modalStore';
import { useModalStore } from '@stores/modal';
import type { Meta, StoryObj } from '@storybook/react';

import Modal from '.';

const meta: Meta<typeof Modal> = {
title: 'Components/Modal',
component: Modal,
decorators: [
(Story) => (
<div style={{ height: '500px' }}>
<Story />
</div>
),
],
};

export default meta;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { PropsWithChildren } from 'react';
import { PORTAL_ID } from '@constants/portalId';

import Portal from '../Portal';
import * as styles from './style.css';
import { PORTAL_ID } from '@constants/portal';

import Portal from '../../Portal';
import * as styles from '../style.css';

const ModalContainer = ({ children }: PropsWithChildren<unknown>) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useModalStore } from '@stores/modalStore';
import { useModalStore } from '@stores/modal';

import DeleteArticle from './components/DeleteArticle';
import DeleteArticle from './modals/DeleteArticle';

const Modal = () => {
const { type } = useModalStore();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useModalStore } from '@stores/modalStore';
import { COLORS } from '@styles/tokens';
import { assignInlineVars } from '@vanilla-extract/dynamic';

import ModalContainer from '../ModalContainer';
import { useModalStore } from '@stores/modal';
import { COLORS } from '@styles/tokens';

import ModalContainer from '../components/ModalContainer';
import * as styles from '../style.css';

const DeleteArticle = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Modal/style.css.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createVar, style } from '@vanilla-extract/css';

import { sprinkles } from '@styles/sprinkles.css';
import { COLORS } from '@styles/tokens';
import { middleLayer, positionCenter, topLayer } from '@styles/utils.css';
import { createVar, style } from '@vanilla-extract/css';

export const modalStyle = style([
positionCenter,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Portal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ReactNode } from 'react';
import ReactDOM from 'react-dom';
import type { PORTAL_ID } from '@constants/portalId';

import type { PORTAL_ID } from '@constants/portal';

interface PortalProps {
children: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/Tabs.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { StoryObj } from '@storybook/react';
import { type Meta } from '@storybook/react';

import Tabs from './Tabs';
import Tabs from '.';

const COMPONENT_DESCRIPTION = `
- \`<Tabs />\`: 모든 컴포넌트에 대한 컨텍스트와 상태를 제공합니다.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PropsWithChildren } from 'react';

import { useTabsContext } from '../../hooks/useTabsContext';
import { useTabsContext } from '../../../hooks/useTabsContext';

interface TabsContentProps {
value: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PropsWithChildren } from 'react';

import * as styles from './style.css';
import * as styles from '../style.css';

const TabsList = ({ children }: PropsWithChildren) => {
return <ul className={styles.tabsList}>{children}</ul>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PropsWithChildren } from 'react';

import { useTabsContext } from '../../hooks/useTabsContext';
import * as styles from './style.css';
import { useTabsContext } from '../../../hooks/useTabsContext';
import * as styles from '../style.css';

interface TabsTriggerProps {
value: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createContext, type PropsWithChildren, useState } from 'react';

import TabsContent from './TabsContent';
import TabsList from './TabsList';
import TabsTrigger from './TabsTrigger';
import TabsContent from './components/TabsContent';
import TabsList from './components/TabsList';
import TabsTrigger from './components/TabsTrigger';

interface TabsContextProps {
selectedTab: string;
Expand Down
5 changes: 3 additions & 2 deletions src/components/Tabs/style.css.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { COLORS } from '@styles/tokens';
import * as utils from '@styles/utils.css';
import { style } from '@vanilla-extract/css';
import { recipe } from '@vanilla-extract/recipes';

import { COLORS } from '@styles/tokens';
import * as utils from '@styles/utils.css';

export const tabsList = style([
utils.flexCenter,
{
Expand Down
7 changes: 4 additions & 3 deletions src/components/Toast/Toast.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useEffect } from 'react';
import { TOAST_DURATION_TIME } from '@models/toastModel';
import { useToastStore } from '@stores/toastStore';

import { TOAST_DURATION_TIME } from '@constants/toast';
import { useToastStore } from '@stores/toast';
import type { Meta, StoryObj } from '@storybook/react';

import Toast from './Toast';
import Toast from '.';

const meta: Meta<typeof Toast> = {
title: 'Toast',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect } from 'react';
import { useToastStore } from '@stores/toastStore';

import { useToastStore } from '@stores/toast';

import * as styles from './style.css';

Expand Down
3 changes: 2 additions & 1 deletion src/components/Toast/style.css.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { recipe } from '@vanilla-extract/recipes';

import { sprinkles } from '@styles/sprinkles.css';
import { COLORS } from '@styles/tokens';
import { modalLayer } from '@styles/utils.css';
import { recipe } from '@vanilla-extract/recipes';

export const toast = recipe({
base: [
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tooltip/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';

import Tooltip from './Tooltip';
import Tooltip from '.';

const COMPONENT_DESCRIPTION = `
- \`<Tooltip />\`: 모든 컴포넌트에 대한 컨텍스트와 상태를 제공합니다.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { PropsWithChildren } from 'react';
import { PORTAL_ID } from '@constants/portalId';
import { useTooltipContext } from '@hooks/useTooltipContext';
import { assignInlineVars } from '@vanilla-extract/dynamic';
import clsx from 'clsx';

import Portal from '../Portal';
import * as styles from './style.css';
import { PORTAL_ID } from '@constants/portal';
import { useTooltipContext } from '@hooks/useTooltipContext';

import Portal from '../../Portal';
import * as styles from '../style.css';

const ARROW_STYLE = {
top: styles.bottomArrow,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { type PropsWithChildren } from 'react';

import { useTooltipContext } from '@hooks/useTooltipContext';

import * as styles from './style.css';
import * as styles from '../style.css';

const TooltipTrigger = ({ children }: PropsWithChildren) => {
const { tooltipRef, onOpenTooltip, onCloseTooltip } = useTooltipContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { PropsWithChildren, Ref } from 'react';
import { createContext, useEffect, useRef, useState } from 'react';

import { getPosition } from '@utils/getPosition';

import TooltipContent from './TooltipContent';
import TooltipTrigger from './TooltipTrigger';
import TooltipContent from './components/TooltipContent';
import TooltipTrigger from './components/TooltipTrigger';

const INIT_POSITION = { top: 0, left: 0 };

Expand Down
5 changes: 3 additions & 2 deletions src/components/Tooltip/style.css.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { sprinkles } from '@styles/sprinkles.css';
import { COLORS, Z_INDEX } from '@styles/tokens';
import { createVar, style } from '@vanilla-extract/css';
import { recipe } from '@vanilla-extract/recipes';

import { sprinkles } from '@styles/sprinkles.css';
import { COLORS, Z_INDEX } from '@styles/tokens';

export const trigger = style({
width: 'fit-content',
height: 'fit-content',
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/constants/toast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const TOAST_DURATION_TIME = {
SHOW: 3500,
ACTION: 5000,
} as const;
2 changes: 1 addition & 1 deletion src/hooks/useTabsContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext } from 'react';

import { TabsContext } from '../components/Tabs/Tabs';
import { TabsContext } from '../components/Tabs';

export const useTabsContext = () => {
const ctx = useContext(TabsContext);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTooltipContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext } from 'react';

import { TooltipContext } from '../components/Tooltip/Tooltip';
import { TooltipContext } from '../components/Tooltip';

export const useTooltipContext = () => {
const ctx = useContext(TooltipContext);
Expand Down
5 changes: 1 addition & 4 deletions src/models/toastModel.ts → src/models/toast.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export const TOAST_DURATION_TIME = {
SHOW: 3500,
ACTION: 5000,
} as const;
import type { TOAST_DURATION_TIME } from '@constants/toast';

export type ToastDurationTime =
(typeof TOAST_DURATION_TIME)[keyof typeof TOAST_DURATION_TIME];
File renamed without changes.
7 changes: 3 additions & 4 deletions src/stores/toastStore.ts → src/stores/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { createStore } from 'zustand';
import { shallow } from 'zustand/shallow';
import { useStoreWithEqualityFn as useStore } from 'zustand/traditional';

import {
TOAST_DURATION_TIME,
type ToastDurationTime,
} from '../models/toastModel';
import { TOAST_DURATION_TIME } from '@constants/toast';

import { type ToastDurationTime } from '../models/toast';

interface ToastData {
message: string;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getPosition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TooltipShape } from '../components/Tooltip/Tooltip';
import type { TooltipShape } from '../components/Tooltip';

const TOOLTIP_MARGIN = {
MINIMAL: 8,
Expand Down