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

[FE] issue75: 이미지 에러 및 스터디 상세 페이지 수정 #104

Merged
merged 15 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 frontend/env/.env.dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
API_URL="http://52.79.214.158:8080"
API_URL=""
CLIENT_ID="cb83d95cd5644436b090"
2 changes: 1 addition & 1 deletion frontend/env/.env.local
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
API_URL="http://52.79.214.158:8080"
API_URL=""
CLIENT_ID="cb83d95cd5644436b090"
3 changes: 2 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { LoginContext } from '@context/login/LoginProvider';
import Footer from '@layout/footer/Footer';
import Header from '@layout/header/Header';

import ErrorPage from '@pages/error-page/ErrorPage';
import LoginRedirectPage from '@pages/login-redirect-page/LoginRedirectPage';
import MainPage from '@pages/main-page/MainPage';

Expand Down Expand Up @@ -37,7 +38,7 @@ const App = () => {
<Route path="/" element={<MainPage />} />
<Route path="/study/:studyId" element={<DetailPage />} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<Route path="/study/:studyId" element={<DetailPage />} />
<Route path="ROUTE_PATHS.STUDY_DETAIL" element={<DetailPage />} />

상수로 분리하면 더 좋겠네요

<Route path="/login" element={isLoggedIn ? <Navigate to="/" replace={true} /> : <LoginRedirectPage />} />
<Route path="*" element={<div>에러 페이지</div>} />
<Route path="*" element={<ErrorPage />} />
</Routes>
</main>
<Footer />
Expand Down
Binary file added frontend/src/assets/images/no-image-found.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/sth-went-wrong.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions frontend/src/components/avatar/Avatar.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { SerializedStyles, css } from '@emotion/react';
import styled from '@emotion/styled';

import type { AvatarProps } from '@components/avatar/Avatar';
import Image from '@components/image/Image';

const dynamicSize = {
sm: css`
Expand Down Expand Up @@ -33,7 +34,7 @@ export const Avatar = styled.div`
min-width: 36px;
height: 36px;
border-radius: 50%;
box-shadow: 0px 1px 5px 0px ${theme.colors.secondary.dark};
box-shadow: 0 1px 5px 0 ${theme.colors.secondary.dark};
overflow: hidden;
transition: opacity 0.2s ease;

Expand All @@ -46,7 +47,7 @@ export const Avatar = styled.div`
${dynamicImageContainer}
`;

export const Image = styled.img`
export const AvatarImage = styled(Image)`
width: 100%;
height: 100%;
object-fit: cover;
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/components/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import { MakeOptional } from '@custom-types/index';
import * as S from '@components/avatar/Avatar.style';

export type AvatarProps = {
className?: string;
profileImg: string;
profileAlt: string;
size: 'sm' | 'md' | 'lg';
};

type OptionalAvatarProps = MakeOptional<AvatarProps, 'size'>;

const Avatar: React.FC<OptionalAvatarProps> = ({ className, size = 'sm', profileImg, profileAlt }) => {
const Avatar: React.FC<OptionalAvatarProps> = ({ size = 'sm', profileImg, profileAlt }) => {
return (
<S.Avatar className={className} size={size}>
<S.Image src={profileImg} alt={profileAlt} />
<S.Avatar size={size}>
<S.AvatarImage src={profileImg} alt={profileAlt} />
</S.Avatar>
);
};
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/button/Button.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export const Button = styled.button<ButtonProp>`
${({ fluid }) => css`
width: ${fluid ? '100%' : 'auto'};
padding: 20px 10px;
text-align: center;

text-align: center;
font-size: 24px;
border: none;
border-radius: 10px;
background: #1a237e;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ButtonProp = {
className?: string;
children: string;
fluid: boolean;
onClick: () => void;
onClick: React.MouseEventHandler<HTMLButtonElement>;
};

type OptionalButtonProp = MakeOptional<ButtonProp, 'fluid' | 'onClick'>;
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/components/card/Card.style.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';

import Image from '@components/image/Image';

export const Card = styled.div`
${({ theme }) => css`
display: flex;
flex-direction: column;

width: 100%;
height: 350px;
overflow: hidden;

Expand All @@ -21,14 +22,12 @@ export const Card = styled.div`
`;

export const ImageContainer = styled.div`
width: 100%;

flex-grow: 1;

overflow: hidden;
`;

export const Image = styled.img`
export const CardImage = styled(Image)`
width: 100%;
height: 100%;

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Card: React.FC<CardProps> = ({ thumbnailUrl, thumbnailAlt, title, excerpt,
return (
<S.Card>
<S.ImageContainer>
<S.Image src={thumbnailUrl} alt={thumbnailAlt} />
<S.CardImage src={thumbnailUrl} alt={thumbnailAlt} />
</S.ImageContainer>
<S.Contents>
<S.Title>{title}</S.Title>
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/components/chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ import { MakeOptional } from '@custom-types/index';
import * as S from '@components/chip/Chip.style';

export interface ChipProps {
className?: string;
children: string;
disabled: boolean;
}

export type OptionalChipProps = MakeOptional<ChipProps, 'disabled'>;

const Chip: React.FC<OptionalChipProps> = ({ className, children, disabled = false }) => {
return (
<S.Chip className={className} disabled={disabled}>
{children}
</S.Chip>
);
const Chip: React.FC<OptionalChipProps> = ({ children, disabled = false }) => {
return <S.Chip disabled={disabled}>{children}</S.Chip>;
};

export default Chip;
17 changes: 17 additions & 0 deletions frontend/src/components/image/Image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import notFoundImage from '@assets/images/no-image-found.png';

interface ImageProps {
className?: string;
src: string;
alt: string;
}

const Image: React.FC<ImageProps> = ({ className, src, alt }) => {
const handleImageError = ({ currentTarget }: React.SyntheticEvent<HTMLImageElement>) => {
currentTarget.src = notFoundImage;
};

return <img className={className} src={src} alt={alt} onError={handleImageError} />;
};

export default Image;
9 changes: 2 additions & 7 deletions frontend/src/components/study-chip/StudyChip.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import Chip from '@components/chip/Chip';

type StudyChipProps = {
className?: string;
isOpen: boolean;
};

const StudyChip = ({ className, isOpen }: StudyChipProps) => {
return (
<Chip className={className} disabled={!isOpen}>
{isOpen ? '모집중' : '모집완료'}
</Chip>
);
const StudyChip = ({ isOpen }: StudyChipProps) => {
return <Chip disabled={!isOpen}>{isOpen ? '모집중' : '모집완료'}</Chip>;
};

export default StudyChip;
5 changes: 2 additions & 3 deletions frontend/src/components/tag-chip/TagChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import type { FC } from 'react';
import * as S from '@components/tag-chip/TagChip.style';

export type TagChipProps = {
className?: string;
children: string;
};

const TagChip: FC<TagChipProps> = ({ className, children }) => {
return <S.TagChip className={className}>{children}</S.TagChip>;
const TagChip: FC<TagChipProps> = ({ children }) => {
return <S.TagChip>{children}</S.TagChip>;
};

export default TagChip;
18 changes: 13 additions & 5 deletions frontend/src/custom-types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;

export type StudyStatus = 'open' | 'close';
export type StudyStatus = 'OPEN' | 'CLOSE';

export type Study = {
id: number;
Expand All @@ -10,14 +10,21 @@ export type Study = {
status: StudyStatus;
};

export type Owner = {
id: number;
username: string;
imageUrl: string;
profileUrl: string;
};

export type Member = {
id: number;
username: string;
profileImage: string;
imageUrl: string;
profileUrl: string;
};

export type StudyTag = { id: number; tagName: string };
export type StudyTag = { id: number; name: string };

export type StudyDetail = {
id: number;
Expand All @@ -28,10 +35,11 @@ export type StudyDetail = {
description: string;
currentMemberCount: number;
maxMemberCount: number;
deadline: string;
createdAt: string;
enrollmentEndDate: string;
startDate: string;
endDate: string;
owner: string;
owner: Owner;
members: Array<Member>;
tags: Array<StudyTag>;
} & Study;
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/layout/header/Header.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,9 @@ export const NavButton = styled.button`
& > svg {
fill: ${theme.colors.primary.base};
}

& > span {
color: ${theme.colors.primary.base};
}
`}
`;
4 changes: 3 additions & 1 deletion frontend/src/layout/header/logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import logoImage from '@assets/images/logo.png';

import * as S from '@layout/header/logo/Logo.style';

import Image from '@components/image/Image';

const Logo: React.FC = () => {
return (
<S.Row>
<S.ImageContainer>
<img src={logoImage} alt="모아모아 로고 이미지" />
<Image src={logoImage} alt="모아모아 로고 이미지" />
</S.ImageContainer>
<S.BorderText>MOAMOA</S.BorderText>
</S.Row>
Expand Down
Loading