Skip to content

Commit

Permalink
[FE] 이미지 추가 시, 모달창 최대 크기를 정해야 한다. 디폴트 이미지를 정해야 한다. (#630)
Browse files Browse the repository at this point in the history
* design: 이미지 관련 최대 높이값 수정

* refactor: 이미지 url 없을때 대응
  • Loading branch information
intae92 authored Oct 19, 2022
1 parent dd4a74e commit 21de034
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
3 changes: 3 additions & 0 deletions frontend/src/components/host/SectionDetailModal/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const image = css`
margin-top: 8px;
cursor: pointer;
border-radius: 8px;
height: 240px;
max-height: 240px;
object-fit: cover;
`;

const description = css`
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/components/user/DetailInfoModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ export interface DetailInfoModalProps {
description: string;
}

const getImageUrl = (url: string): string => {
return url === '' ? homeCover_fallback : url;
};

const DetailInfoModal: React.FC<DetailInfoModalProps> = ({ name, imageUrl, description }) => {
return (
<ModalPortal>
<Dimmer>
<div css={styles.container}>
<h1 css={styles.title}>{name}</h1>
<div css={styles.imageWrapper}>
<img css={styles.image} src={getImageUrl(imageUrl)} />
</div>
<div css={styles.imageWrapper}>{imageUrl !== '' && <img css={styles.image} src={imageUrl} />}</div>
<span css={styles.description}>{description}</span>
</div>
</Dimmer>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/user/DetailInfoModal/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import theme from '@/styles/theme';
const container = css`
max-width: 400px;
min-width: 320px;
max-height: 400px;
width: 80%;
background-color: ${theme.colors.white};
display: flex;
Expand All @@ -29,7 +30,8 @@ const imageWrapper = css`

const image = css`
width: 100%;
height: 100%;
height: 240px;
max-height: 240px;
object-fit: cover;
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ interface SectionInfoPreviewProps {
}

const SectionInfoPreview: React.FC<SectionInfoPreviewProps> = ({ imageUrl, onClick }) => {
const isImage = imageUrl !== '';

return (
<div css={styles.wrapper} onClick={onClick}>
<div css={styles.imageWrapper}>
<LazyImage css={styles.image} imageUrl={imageUrl} />
</div>
<div css={styles.imageWrapper(isImage)}>{isImage && <LazyImage css={styles.image} imageUrl={imageUrl} />}</div>
<FaMapMarkedAlt css={styles.icon} size={24} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ const wrapper = css`
cursor: pointer;
`;

const imageWrapper = css`
const imageWrapper = (isImage: boolean) => css`
width: 56px;
height: 40px;
overflow: hidden;
border-radius: 8px;
box-shadow: 2px 2px 4px 0px ${theme.colors.gray500};
background-color: ${!isImage && theme.colors.skyblue200};
`;

const image = css`
Expand Down
11 changes: 1 addition & 10 deletions frontend/src/components/user/SectionCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import useModal from '@/hooks/useModal';

import { ID, SectionType, TaskType } from '@/types';

import homeCover_fallback from '@/assets/homeCover-fallback.png';

import styles from './styles';

type SectionCardProps = {
Expand All @@ -21,10 +19,6 @@ type SectionCardProps = {
flipTaskCheck: any;
};

const getImageUrl = (url: string): string => {
return url === '' ? homeCover_fallback : url;
};

const SectionCard: React.FC<SectionCardProps> = ({
section,
sectionsAllCheckMap,
Expand Down Expand Up @@ -58,10 +52,7 @@ const SectionCard: React.FC<SectionCardProps> = ({
</Button>
)}
{(section.imageUrl || section.description) && (
<SectionInfoPreview
imageUrl={getImageUrl(section.imageUrl)}
onClick={() => onClickSectionDetail(section)}
/>
<SectionInfoPreview imageUrl={section.imageUrl} onClick={() => onClickSectionDetail(section)} />
)}
</div>
</div>
Expand Down

0 comments on commit 21de034

Please sign in to comment.