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

tab 컴포넌트 #13

Closed
wants to merge 14 commits into from
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"sb:ds": "pnpm --filter design-system storybook"
},
"dependencies": {
"@emotion/css": "^11.11.2",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"next": "14.1.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"start": "next start",
"preview": "next preview",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
"build-storybook": "storybook build",
"lint:eslint": "eslint 'src/**/*.{js,ts,tsx}'",
"lint:styles": "stylelint 'src/**/*.{js,jsx,ts,tsx,css,scss}'"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.2.25",
Expand Down
6 changes: 3 additions & 3 deletions packages/design-system/src/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Input from './input';

export default { Input };
export { Input } from './input';
export { Select } from './select';
export { Checkbox } from './checkbox';
export { Tab } from './tab';
export { Tooltip } from './tooltip';
4 changes: 1 addition & 3 deletions packages/design-system/src/components/input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface IInputProps extends InputHTMLAttributes<HTMLInputElement> {
onClick: () => void;
}

const Input: React.FC<IInputProps> = React.forwardRef(
export const Input: React.FC<IInputProps> = React.forwardRef(
(
{ inputType = 'text', disabled, value, onChange, onClick, ...rest },
ref: React.Ref<HTMLInputElement>,
Expand All @@ -28,5 +28,3 @@ const Input: React.FC<IInputProps> = React.forwardRef(
);
},
);

export default Input;
28 changes: 28 additions & 0 deletions packages/design-system/src/components/tab/TabLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use client';

import styled from '@emotion/styled';

export const TabLayout = styled.div`
display: flex;
gap: 10px;
`;
interface TabListProps {
active: boolean;
}

export const TabList = styled.div<TabListProps>`
padding: 10px 20px;
border: 1px solid transparent;
border-radius: 5px;

background-color: ${(props) => (props.active ? '#0056b3' : '#007bff')};

color: #fff;
font-size: 16px;

cursor: pointer;

&:hover {
background-color: #0056b3;
}
`;
43 changes: 43 additions & 0 deletions packages/design-system/src/components/tab/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import { TabLayout, TabList } from './TabLayout';

interface TabProps {
list: Array<{
value: string;
label: string;
}>;
ysnarmi marked this conversation as resolved.
Show resolved Hide resolved
selectedValue: string;
onChange: () => void;
}

// TODO : 삭제 필요 (TeamType/categories)
enum TeamType {
PREPARE_TEAM = 'PREPARE_TEAM',
MISSIONARY_TEAM = 'MISSIONARY_TEAM',
}

export const Tab = ({ list, selectedValue, onChange }: TabProps) => {
const categories = [
{
value: TeamType.PREPARE_TEAM,
label: '준비팀',
},
{
value: TeamType.MISSIONARY_TEAM,
label: '선교팀',
},
];
ysnarmi marked this conversation as resolved.
Show resolved Hide resolved

return (
<TabLayout>
{categories.map((category) => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

props의 List에서 가져오는 것이 어떨까요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

props에서 가져올 예정이고, 이해를 위한 리스트를 작성한 거에용

Copy link
Collaborator

Choose a reason for hiding this comment

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

예시나 목 데이터같은 경우에는 컴포넌트 내부가 아니라, storybook에서 만들어도 좋을 것 같아요!

<TabList
key={category.value}
active={category.value === TeamType.PREPARE_TEAM}
>
{category.label}
</TabList>
))}
</TabLayout>
);
};
39 changes: 39 additions & 0 deletions packages/design-system/src/components/tooltip/TooltipLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use client';

import styled from '@emotion/styled';

export const TooltipLayout = styled.div`
position: relative;
display: inline-block;
`;

// 툴팁 스타일
export const TooltipText = styled.span`
position: absolute;
bottom: 150%;
left: 50%;
z-index: 1;

width: 120px;
margin-left: -60px;
padding: 5px;
border-radius: 6px;

background-color: #000;

color: #fff;
text-align: center;

opacity: 0.1;
visibility: hidden;

transition: opacity 0.3s;
`;

// 툴팁을 나타내는 이벤트 핸들러
export const TooltipTrigger = styled.span`
&:hover + ${TooltipText} {
opacity: 1;
visibility: visible;
}
`;
18 changes: 18 additions & 0 deletions packages/design-system/src/components/tooltip/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import type { ReactNode } from 'react';

import { TooltipLayout, TooltipTrigger, TooltipText } from './TooltipLayout';

interface TooltipProps {
text: string;
children: ReactNode;
}

export const Tooltip = ({ children, text }: TooltipProps) => {
return (
<TooltipLayout>
<TooltipTrigger>{children}</TooltipTrigger>
<TooltipText>{text}</TooltipText>
</TooltipLayout>
);
};
13 changes: 12 additions & 1 deletion packages/missionary-admin/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
import { Input } from '@samilhero/design-system/src/components/index';
import { Tab } from '@samilhero/design-system/src/components/tab';
import { Tooltip } from '@samilhero/design-system/src/components';

export default function Home() {
return <main>선교 상륙 작전1</main>;
return (
<main>
선교 상륙 작전1
<Input />
<Tab />
<Tooltip text={'ddd'}>툴탑</Tooltip>
</main>
);
}
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading