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

[김법균] Week14 #458

Merged
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4ff3eac
feat: Create Button Component
bk-git-hub May 8, 2024
afc85a4
style: Fix incorrect syntax in css
bk-git-hub May 8, 2024
51cd32b
feat: Add Header component
bk-git-hub May 8, 2024
4b13e67
feat: Render Header component as common component
bk-git-hub May 8, 2024
80657d1
chore: Remove initial codes in Home Component
bk-git-hub May 8, 2024
5a20445
chore: Change Logo image to Link Component
bk-git-hub May 8, 2024
71fc42e
style: Apply reset.css in _app.tsx
bk-git-hub May 8, 2024
c06e1ef
style: Initialize global.css
bk-git-hub May 8, 2024
7450edd
feat: Add Footer Component
bk-git-hub May 8, 2024
d494e1c
feat: Add main heading to homepage
bk-git-hub May 9, 2024
6524c10
feat: Add AddlinkButton in homepage
bk-git-hub May 9, 2024
2e998f1
feat: Add main example page image in homepage
bk-git-hub May 9, 2024
df4176b
feat: Add feature cards in homepage
bk-git-hub May 9, 2024
9543365
style: Adjust Sign in button style
bk-git-hub May 9, 2024
d85cd76
feat: Add link feature using useRouter from homepage to signup page
bk-git-hub May 9, 2024
54a6d86
feat: Add optional rendering of header and footer in app.tsx
bk-git-hub May 9, 2024
38f02df
style: Add global color variable and font
bk-git-hub May 9, 2024
0ef3b30
feat: Add header for sign up page
bk-git-hub May 9, 2024
abf2956
refactor: Extract authHeader from authPage into a seperate component
bk-git-hub May 9, 2024
235a8a2
feat: Add sign up form in sign up page
bk-git-hub May 9, 2024
9c7af94
feat: Add social link bar in sign up page
bk-git-hub May 9, 2024
0a80ad0
feat: Add routing feature to AuthHeader component
bk-git-hub May 9, 2024
c661db3
refactor: Change SignUpForm stylesheet to AuthForm
bk-git-hub May 9, 2024
25948dd
feat: Create sign in page
bk-git-hub May 9, 2024
572c3a1
feat: Add type prop for Button component
bk-git-hub May 9, 2024
ea1481f
install libraries..
bk-git-hub May 11, 2024
ff659cd
feat: Add disable feature in Button component
bk-git-hub May 11, 2024
be585da
refactor: Refactor sign in form using react-hook-form
bk-git-hub May 11, 2024
7adf8d7
refactor: Use react-hook-form to handle sign up form
bk-git-hub May 11, 2024
bb1eb95
chore: Remove AuthInput component
bk-git-hub May 13, 2024
318d23e
intall axios
bk-git-hub May 13, 2024
ae1190f
feat: Create axios instance
bk-git-hub May 13, 2024
ebec153
feat: Create ShowTextToggle component
bk-git-hub May 13, 2024
92f5aea
feat: Add toggle button and error trigger to sign up page
bk-git-hub May 13, 2024
c55266b
feat: Add password toggle feature to sign in page
bk-git-hub May 13, 2024
a21a6b4
feat: Trigger validation at onBlur
bk-git-hub May 13, 2024
006447c
chore: Change button type to 'button'
bk-git-hub May 13, 2024
13d1c7a
chore: Fix base url
bk-git-hub May 13, 2024
8ca6d8d
feat: Add api request to onSubmit function and handle request
bk-git-hub May 13, 2024
db72aea
chore: Remove console.log in onSubmit
bk-git-hub May 13, 2024
1702d39
feat: Create Account Component for header display
bk-git-hub May 13, 2024
bbc6fc3
feat: Use context api to share userInfo state
bk-git-hub May 13, 2024
70edc32
feat: Add sign in feature and move to folder page and update userInfo
bk-git-hub May 13, 2024
24f16bb
feat: Create folder page
bk-git-hub May 13, 2024
4e99ba4
feat: Add sign up api feature to sign up page
bk-git-hub May 13, 2024
facb247
feat: Add routing to folder page when userInfo exists
bk-git-hub May 13, 2024
12e3cb5
feat: Add temporary loading feature for header(needs to be fixed)
bk-git-hub May 16, 2024
84fe27d
feat: Add SearchBar Component
bk-git-hub May 16, 2024
43417d3
feat: Add FolderToolBar Component
bk-git-hub May 16, 2024
fd4f1bb
feat: Add LinkCard & Link
bk-git-hub May 16, 2024
50cef44
feat: Add Modal feature in folder page
bk-git-hub May 16, 2024
4df5259
style: Add hover style to toggle button
bk-git-hub May 16, 2024
1cdb459
fix: Fix image error in share modal
bk-git-hub May 16, 2024
1d56499
fix: Change eslintrc and add script for Kakao Talk share
bk-git-hub May 17, 2024
23340a5
chore: Change share url to local host for feature test
bk-git-hub May 17, 2024
4df9304
feat: Create SharedPage component
bk-git-hub May 17, 2024
b740fc5
Merge branch 'part3-김법균' into part3-김법균
bk-git-hub May 24, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bk-git-hub

이걸로 설정해보는건 어떤가요? 공식문서에서도 recommend 하고있는 strict 형태여서 제안드립니다
https://nextjs.org/docs/app/building-your-application/configuring/eslint

image

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "next/core-web-vitals"
"extends": "next"
}
22 changes: 22 additions & 0 deletions components/Account/Account.module.scss
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bk-git-hub

역시 말씀드리지만, javascript project convention에 따라 파일명을 제작하는게 좋겠어요
https://google.github.io/styleguide/jsguide.html#file-name

파일 이름의 경우, lowercase와 underscore의 조합으로만 작성을 하고, 리액트 프로젝트 컨벤션에 따라 콤포넌트만 PascalCase 또는 snake-case로 작성을 하는건 어떨까요?

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.account {
display: flex;
align-items: center;
gap: 6px;
}
.userProfileImg {
width: 28px;
aspect-ratio: 1/1;
border-radius: 50%;
}

.userEmail {
width: fit-content;
font-size: 14px;
@media (max-width: 767px) {
position: absolute;
width: 1px;
height: 1px;
clip: rect(0 0 0 0);
overflow: hidden;
}
}
20 changes: 20 additions & 0 deletions components/Account/Account.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import styles from './Account.module.scss';

interface AccountProps {
profileImgSource?: string;
userEmail: string;
Comment on lines +4 to +5
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bk-git-hub

prop으로 전달받는 요소의 경우, 우리 프로젝트에서 전반적으로 사용되는 유저 데이터가 존재하나요?
그렇다면 유저 데이터에 대한 타입을 선언해서 그냥 유저 정보를 다 받아오도록 하는게 더 좋지 않을까 생각이 되어요.

type User = {
  profileImgSrc?: string
  email: string
  name: string
  ...
}

interface AccountProps {
  user: User
}

}

const Account = ({ profileImgSource, userEmail }: AccountProps) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bk-git-hub

account라기 보단 user-profile이라는 콤포넌트가 더 적합한 이름으로 보이는데 어떻게 생각하시나요?

return (
<div className={styles.account}>
<img
src={profileImgSource}
alt='User Profile'
className={styles.userProfileImg}
/>
<span className={styles.userEmail}>{userEmail}</span>
</div>
);
};
export default Account;
27 changes: 27 additions & 0 deletions components/AuthHeader/AuthHeader.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.authPageHeader {
display: flex;
flex-direction: column;
gap: 16px;
align-items: center;
}

.logo {
position: relative;
width: 218px;
height: 38px;
}

.membershipPromptBar {
display: flex;
gap: 8px;
font-family: inherit;
}

.membershipPromptText {
font-family: inherit;
}

.membershipPromptLink {
text-decoration: underline;
color: var(--Linkbrary-primary-color);
}
26 changes: 26 additions & 0 deletions components/AuthHeader/AuthHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Link from 'next/link';
import Image from 'next/image';
import styles from './AuthHeader.module.css';

interface AuthHeaderProps {
text: string;
linkText: string;
link: string;
}

export default function AuthHeader({ text, linkText, link }: AuthHeaderProps) {
return (
<div className={styles.authPageHeader}>
<Link href={'/'} className={styles.logo}>
<Image src={'/assets/images/logo.svg'} fill alt='Linkbrary' />
</Link>

<div className={styles.membershipPromptBar}>
<span className={styles.membershipPromptText}>{text}</span>
<Link href={link} className={styles.membershipPromptLink}>
{linkText}
</Link>
</div>
</div>
);
}
25 changes: 25 additions & 0 deletions components/Button/Button.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.btn {
background-image: linear-gradient(to right, #6d6afe, #6de3fe);
padding: 10px 16px;
border-radius: 8px;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.125em;
font-weight: 600;
color: #f5f5f5;
text-decoration-line: none;
flex-shrink: 0;
font-family: Pretendard;
}

.btn:hover {
cursor: pointer;
}

@media (max-width: 767px) {
.btn {
padding: 10px 16px;
font-size: 14px;
}
}
30 changes: 30 additions & 0 deletions components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import styles from './Button.module.css';

interface ButtonProps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bk-git-hub

button element가 기본적으로 받아올 수 있는 요소들이 존재할텐데요
그걸 받아올 수 있도록 react진영에서 button element에 대한 타입을 사전에 정의해놓았습니다.
Button Props에 위에 설명한 버튼 타입을 상속받아 확장하도록 하는게 좋겠어요

children?: React.ReactNode;
onClick?: () => void;
className?: string;
type?: 'button' | 'submit' | 'reset' | undefined;
disabled?: boolean;
}

const Button = ({
children,
onClick,
className,
type = 'button',
disabled = false,
}: ButtonProps) => {
return (
<button
onClick={onClick}
className={`${className} ${styles.btn}`}
type={type}
disabled={disabled}
>
{disabled ? '처리중' : children}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bk-git-hub

그리고 여기서 처리중임을 꽂아주기보다
상단에서 이 버튼 콤포넌트가 보여주어야 하는 요소를 관리하도록 하는게 더 재활용성이 높을거에요
이를 콤포지션 패턴이라 하구요
https://medium.com/@guilherme.pomp/creating-react-components-with-the-composition-pattern-f59c895f27bc

그렇다면 다음과 같은 형태로 동적으로 값들이 할당되도록 할 수 있겠죠

<Button disabled={isLoggingIn}>로그인 {isLoggingIn && <Icons.spinner />}</Button>

</button>
);
};

export default Button;
116 changes: 116 additions & 0 deletions components/FolderToolBar/FolderToolBar.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
.folderToolBarContainer {
display: flex;
flex-direction: column;
gap: 24px;
width: 1060px;

.folderToolButtons {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;

.folderNameButtons {
display: flex;
flex-wrap: wrap;
width: 80%;
gap: 8px;
}
}

.folderNameDisplay {
font-size: 24px;
letter-spacing: -0.2px;
font-weight: 600;
}

.folderNameBar {
display: flex;
justify-content: space-between;
align-items: center;

.utilButtons {
display: flex;
gap: 12px;
}
}

@media (max-width: 1124px) {
width: 706px;
}

@media (max-width: 767px) {
width: 325px;

.folderNameBar {
flex-direction: column;
align-items: flex-start;
gap: 12px;
}
}
}

.folderNameButton {
background-color: #fff;
border: 1px solid #6d6afe;
padding: 8px 12px;
border-radius: 5px;
height: 36px;

&:hover {
background-color: #e7effb;
}
}

.focusedButton {
background-color: #6d6afe;
color: #fff;
&:hover {
background-color: #6d6afe;
}
}

.utilButton {
position: relative;
display: flex;
gap: 4px;
color: #9fa6b2;
font-size: 14px;
font-weight: 600;
}
.utilButtonIcon {
position: relative;
width: 18px;
height: 18px;
}

.folderAddButton {
display: flex;
font-weight: 500;
gap: 4px;
color: #6d6afe;

.addIconWhite {
display: none;
}

@media (max-width: 767px) {
position: fixed;
bottom: 101px;
padding: 8px 24px;
left: 50%;
transform: translateX(-50%);
border-radius: 20px;
background-color: #6d6afe;
color: #fff;
z-index: 1;

.addIcon {
display: none;
}

.addIconWhite {
display: block;
}
}
}
87 changes: 87 additions & 0 deletions components/FolderToolBar/FolderToolBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import FolderToolBarButton from './FolderToolBarButton';
import styles from './FolderToolBar.module.scss';
import UtilButton from './UtilButton';
import { UTIL_BUTTONS_PROPS } from './constants';
import { FolderObj } from '@/utils/interfaces';

const addIcon = '/assets/images/add_icon.svg';
const addIconWhite = '/assets/images/add_icon_white.svg';
interface FolderToolBarProps {
folders?: FolderObj[];
currentFolderId?: number;
folderNameOnClick: (id: number) => void;
onFolderNameChangeClick: () => void;
onFolderAddClick: () => void;
onFolderDeleteClick: () => void;
onShare: () => void;
}

export default function FolderToolBar({
folders,
currentFolderId,
folderNameOnClick,
onFolderAddClick,
onFolderNameChangeClick,
onFolderDeleteClick,
onShare,
}: FolderToolBarProps) {
const currentFolder = folders?.find(
(folder) => folder.id === currentFolderId
);
const currentFolderName = currentFolder?.name;
UTIL_BUTTONS_PROPS.share.onClick = onShare;
UTIL_BUTTONS_PROPS.changeName.onClick = onFolderNameChangeClick;
UTIL_BUTTONS_PROPS.delete.onClick = onFolderDeleteClick;

return (
<div className={styles.folderToolBarContainer}>
<div className={styles.folderToolButtons}>
<ul className={styles.folderNameButtons}>
{folders?.map((item) => (
<li key={item.id}>
<FolderToolBarButton
onClick={folderNameOnClick}
id={item.id}
isFocused={item.id === currentFolderId}
>
{item.name}
</FolderToolBarButton>
</li>
))}
</ul>

<button className={styles.folderAddButton} onClick={onFolderAddClick}>
<span>폴더 추가</span>
<img
src={addIcon}
alt='폴더 추가 아이콘'
className={styles.addIcon}
/>
<img
src={addIconWhite}
alt='폴더 추가 아이콘'
className={styles.addIconWhite}
/>
</button>
</div>
<div className={styles.folderNameBar}>
<span className={styles.folderNameDisplay}>{currentFolderName}</span>
<ul className={styles.utilButtons}>
{Object.entries(UTIL_BUTTONS_PROPS).map(([key, btn]) => (
<li key={btn.id}>
{currentFolderId !== -1 && (
<UtilButton
imgSrc={btn.imgSrc}
alt={btn.alt}
onClick={btn.onClick}
>
{btn.btnText}
</UtilButton>
)}
</li>
))}
</ul>
</div>
</div>
);
}
29 changes: 29 additions & 0 deletions components/FolderToolBar/FolderToolBarButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import styles from './FolderToolBar.module.scss';

interface FolderToolBarButtonProps {
id: number;
children: React.ReactNode;
onClick: (id: number) => void;
isFocused: boolean;
}

export default function FolderToolBarButton({
id,
children,
onClick,
isFocused,
}: FolderToolBarButtonProps) {
const handleClick = () => {
onClick(id);
};
return (
<button
onClick={handleClick}
className={`${styles.folderNameButton} ${
isFocused && styles.focusedButton
}`}
>
{children}
</button>
);
}
Loading