diff --git a/apps/executeJS/src/features/playground/store.ts b/apps/executeJS/src/features/playground/store.ts index 2959510..4259f28 100644 --- a/apps/executeJS/src/features/playground/store.ts +++ b/apps/executeJS/src/features/playground/store.ts @@ -3,7 +3,7 @@ import { create } from 'zustand'; import { persist, createJSONStorage } from 'zustand/middleware'; import { PLAYGROUND_STORAGE_KEY } from './const'; -interface Tab { +export interface Tab { id: string; playgroundId: Playground['id']; title: string; @@ -30,7 +30,7 @@ interface PlaygroundState { }) => void; } -const INITIAL_TAB_TITLE = '✨New Playground'; +const INITIAL_TAB_TITLE = 'New Tab'; const INITIAL_TAB_ID = 'first-playground-tab'; const INITIAL_PLAYGROUND_ID = 'first-playground'; diff --git a/apps/executeJS/src/features/tab/index.ts b/apps/executeJS/src/features/tab/index.ts new file mode 100644 index 0000000..5ecdd1f --- /dev/null +++ b/apps/executeJS/src/features/tab/index.ts @@ -0,0 +1 @@ +export * from './ui'; diff --git a/apps/executeJS/src/features/tab/ui/index.ts b/apps/executeJS/src/features/tab/ui/index.ts new file mode 100644 index 0000000..bf7c127 --- /dev/null +++ b/apps/executeJS/src/features/tab/ui/index.ts @@ -0,0 +1 @@ +export * from './tab-button'; diff --git a/apps/executeJS/src/features/tab/ui/tab-button.tsx b/apps/executeJS/src/features/tab/ui/tab-button.tsx new file mode 100644 index 0000000..b44b558 --- /dev/null +++ b/apps/executeJS/src/features/tab/ui/tab-button.tsx @@ -0,0 +1,49 @@ +import { Cross2Icon } from '@radix-ui/react-icons'; + +import { Tab } from '@/features/playground'; + +interface TabButtonProps { + tab: Tab; + isActive: boolean; + onActiveTab: (id: Tab['id']) => void; + onCloseTab: (id: Tab['id']) => void; +} + +export const TabButton: React.FC = ({ + tab, + isActive, + onActiveTab, + onCloseTab, +}) => { + const { id, title } = tab; + + return ( +
+
+ + +
+
+ ); +}; diff --git a/apps/executeJS/src/pages/playground/playground-groups.tsx b/apps/executeJS/src/pages/playground/playground-groups.tsx index 465c97b..d4652ce 100644 --- a/apps/executeJS/src/pages/playground/playground-groups.tsx +++ b/apps/executeJS/src/pages/playground/playground-groups.tsx @@ -1,5 +1,6 @@ -import { Cross2Icon, PlusIcon } from '@radix-ui/react-icons'; +import { PlusIcon } from '@radix-ui/react-icons'; +import { TabButton } from '@/features/tab'; import { usePlaygroundStore } from '@/features/playground'; import { PlaygroundWidget } from '@/widgets/playground'; @@ -11,41 +12,18 @@ export const PlaygroundGroups: React.FC = () => {
- {tabs.map(({ id, title }) => { - const active = id === activeTabId; + {tabs.map((tab) => { + const { id } = tab; + const isActive = id === activeTabId; return ( -
- {/* TODO: 탭 최대 너비에 따른 제목 ellipsis 처리 @bori */} - - -
+ tab={tab} + isActive={isActive} + onActiveTab={setActiveTab} + onCloseTab={closeTab} + /> ); })}