Skip to content

Commit

Permalink
Merge pull request #13 from junction-asia-2023/feat/home
Browse files Browse the repository at this point in the history
feat(home): Add Active
  • Loading branch information
1ilsang committed Aug 19, 2023
2 parents 16a48cb + 350b128 commit 3466017
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 36 deletions.
14 changes: 14 additions & 0 deletions public/svg/active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/svg/right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

43 changes: 9 additions & 34 deletions src/features/home/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
import { useLayoutEffect, useState } from 'react';
import { useAtom } from 'jotai';

import reactLogo from '../../assets/react.svg';

import viteLogo from '/vite.svg';

import { titleAtom } from '../shared/layout/atom';
import useHomeContainer from './hooks/useHomeContainer';
import Profile from './components/Profile';
import './home.scss';
import Active from './components/Active';
import GrayBar from './components/GrayBar';

const HomeContainer = () => {
const [count, setCount] = useState(0);
const [, setTitle] = useAtom(titleAtom);

useLayoutEffect(() => {
setTitle({ title: 'CardMe' });
}, []);
useHomeContainer();

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<Profile />
<GrayBar />
<Active />
</>
);
};
Expand Down
29 changes: 29 additions & 0 deletions src/features/home/components/Active.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { FunctionComponent } from 'react';
import { useNavigate } from 'react-router-dom';

import activeLogo from '/svg/active.svg';
import rightIcon from '/svg/right.svg';

import { URL } from '../../shared/constants/url';

const Active: FunctionComponent = () => {
const navigate = useNavigate();
const handleActiveClick = () => navigate(URL.setting);

return (
<section className="active-box" onClick={handleActiveClick}>
<div className="icon-box">
<img className="icon" src={activeLogo} alt="active icon" />
</div>
<div className="content">
<div className="title">Active</div>
<div className="description">Expressing myself</div>
</div>
<div className="next">
<img className="next-icon" src={rightIcon} alt="next" />
</div>
</section>
);
};

export default Active;
5 changes: 5 additions & 0 deletions src/features/home/components/GrayBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const GrayBar = () => {
return <div className="gray-bar" />;
};

export default GrayBar;
37 changes: 37 additions & 0 deletions src/features/home/components/Profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useAtom } from 'jotai';
import { FunctionComponent } from 'react';

import { userAtom } from '../../login/atom';

const Profile: FunctionComponent = () => {
const [{ email, profileImage, department, name, position }] =
useAtom(userAtom);

return (
<section className="profile-box">
<div className="image-box">
<img className="image" src={profileImage} alt="profile" />
</div>
<div className="list-box">
<div className="list">
<div className="name">Name</div>
<div className="description">{name}</div>
</div>
<div className="list">
<div className="name">Department</div>
<div className="description">{department}</div>
</div>
<div className="list">
<div className="name">Email</div>
<div className="description">{email}</div>
</div>
<div className="list">
<div className="name">Position</div>
<div className="description">{position}</div>
</div>
</div>
</section>
);
};

export default Profile;
75 changes: 75 additions & 0 deletions src/features/home/home.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@import '../shared/style/color';

.profile-box {
display: flex;
flex-direction: column;

padding: 24px 16px 16px 16px;
gap: 24px;

.image-box {
display: flex;
justify-content: center;

.image {
width: 100px;
height: 100px;
}
}

.list-box {
display: flex;
flex-direction: column;

gap: 16px;

.list {
display: flex;
height: 24px;
gap: 16px;

.name {
width: 100px;
}
.description {
color: $description-sub;
}
}
}
}
.gray-bar {
height: 12px;
background-color: $other-area-color;
}
.active-box {
display: flex;
align-items: center;
justify-content: space-between;

cursor: pointer;

height: 72px;
padding: 8px 16px;
gap: 16px;

.icon-box {
width: 36px;
height: 36px;
}

.content {
// width: 260px;
width: 100%;
padding: 0px 12px;

.title {
font-weight: 500;
line-height: 24px;
}

.description {
color: $description-sub;
font-size: 14px;
}
}
}
14 changes: 14 additions & 0 deletions src/features/home/hooks/useHomeContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useAtom } from 'jotai';
import { useLayoutEffect } from 'react';

import { titleAtom } from '../../shared/layout/atom';

const useHomeContainer = () => {
const [, setTitle] = useAtom(titleAtom);

useLayoutEffect(() => {
setTitle({ title: 'CardMe' });
}, []);
};

export default useHomeContainer;
5 changes: 4 additions & 1 deletion src/features/login/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { DummyUser } from './type';

export const DUMMY_USER: DummyUser = {
name: 'Sangchul',
profileImage: 'https://avatars.githubusercontent.com/u/23524849?v=4',
email: '[email protected]',
companyNo: 'JS1234',
password: 'just',
department: 'dev1',
department: 'Social Dev1',
position: 'Software Engineer',
};
3 changes: 3 additions & 0 deletions src/features/login/type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export type User = {
name?: string;
profileImage?: string;
email?: string;
companyNo?: string;
department?: string;
position?: string;
};
export type DummyUser = User & { password?: string };

Expand Down
1 change: 1 addition & 0 deletions src/features/shared/constants/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum URL {
home = '/',
login = '/login',
setting = '/setting',
}
2 changes: 2 additions & 0 deletions src/features/shared/style/_color.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ $container-color: #ffffff;

$button-background-color: #191919;
$button-text-color: #ffffff;

$description-sub: #7878B8;

0 comments on commit 3466017

Please sign in to comment.