Feat: Home 컴포넌트 추가

This commit is contained in:
정현조 2024-09-09 15:05:37 +09:00
parent 943b443080
commit ed15f4df4a
2 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,35 @@
import '@/index.css';
import { Meta, StoryObj } from '@storybook/react';
import Home from '.';
import { useState } from 'react';
const HomeWrapper = ({ initialLoggedIn }: { initialLoggedIn: boolean }) => {
const [isLoggedIn, setIsLoggedIn] = useState(initialLoggedIn);
return (
<Home
isLoggedIn={isLoggedIn}
setIsLoggedIn={setIsLoggedIn}
/>
);
};
const meta: Meta<typeof Home> = {
title: 'Components/Home',
component: Home,
parameters: {
layout: 'fullscreen',
},
};
export default meta;
type Story = StoryObj<typeof Home>;
export const GoogleLogin: Story = {
render: () => <HomeWrapper initialLoggedIn={false} />,
};
export const SelectWorkspace: Story = {
render: () => <HomeWrapper initialLoggedIn={true} />,
};

View File

@ -0,0 +1,80 @@
import { useState } from 'react';
import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue, SelectGroup } from '../ui/select';
import GoogleLogo from '@/assets/icons/web_neutral_rd_ctn@1x.png';
interface HomeProps {
isLoggedIn?: boolean;
setIsLoggedIn?: (loggedIn: boolean) => void;
}
export default function Home({ isLoggedIn = false, setIsLoggedIn }: HomeProps) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [selectedWorkspace, setSelectedWorkspace] = useState('');
const workspaces = [
{ id: 1, name: 'Workspace 1' },
{ id: 2, name: 'Workspace 2' },
{ id: 3, name: 'Workspace 3' },
];
const handleGoogleSignIn = () => {
console.log('구글로 계속하기');
if (setIsLoggedIn) {
setIsLoggedIn(true);
}
};
return (
<div className="flex h-full flex-col items-center justify-center bg-gray-50 p-8">
<div className="mb-6 max-w-xl rounded-lg bg-white p-6 shadow-lg">
<h2 className="mb-4 text-2xl font-bold text-gray-900"> </h2>
<p className="mb-4 text-base text-gray-700">
(AI)
. .
</p>
<p className="mb-4 text-base text-gray-700">
.
Auto Labeler를 , .
</p>
<p className="mb-4 text-base text-gray-700">
Auto Labeler는 , .
, .
</p>
<p className="text-base text-gray-700">
.
</p>
</div>
{!isLoggedIn ? (
<button
onClick={handleGoogleSignIn}
className="mb-4 transition hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-gray-300 active:opacity-80"
>
<img
src={GoogleLogo}
alt="Sign in with Google"
className="h-auto w-full"
/>
</button>
) : (
<Select onValueChange={(value) => setSelectedWorkspace(value)}>
<SelectTrigger className="mb-4 w-72">
<SelectValue placeholder="워크스페이스를 선택하세요" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
{workspaces.map((workspace) => (
<SelectItem
key={workspace.id}
value={workspace.name}
>
{workspace.name}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
)}
</div>
);
}