Skip to content

Commit 27c6cba

Browse files
authored
Merge pull request #157 from sipe-team/feat/5th-recruit
fix: 후원사 소개 section card 스타일 변경 및 관련 이미지 컴포넌트 추가
2 parents 69eb13f + d668fa6 commit 27c6cba

File tree

5 files changed

+111
-23
lines changed

5 files changed

+111
-23
lines changed

src/components/atoms/ContentWithTitle/index.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
import { color, Flex, Typography } from '@sipe-team/side';
2+
import clsx from 'clsx';
23

34
import styles from './index.module.scss';
45

56
type ContentWithTitleProps = {
67
title: string;
78
children: React.ReactNode | React.ReactNode[];
9+
className?: string;
10+
style?: React.CSSProperties;
11+
titleColor?: string;
12+
titleSize?: 36 | 12 | 14 | 16 | 18 | 20 | 24 | 28 | 32 | 48;
813
};
914

10-
function ContentWithTitle({ title, children }: ContentWithTitleProps) {
15+
function ContentWithTitle({
16+
title,
17+
children,
18+
className,
19+
style,
20+
titleColor,
21+
titleSize = 36,
22+
}: ContentWithTitleProps) {
1123
return (
12-
<Flex align="center" className={styles.wrapper} direction="column">
13-
<Typography color={color.white} className={styles.title} size={36}>
24+
<Flex
25+
align="center"
26+
className={clsx(styles.wrapper, className)}
27+
direction="column"
28+
style={style}
29+
>
30+
<Typography
31+
color={titleColor || color.white}
32+
className={styles.title}
33+
size={titleSize}
34+
>
1435
{title}
1536
</Typography>
1637
{children}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use client';
2+
3+
import { useState } from 'react';
4+
5+
import Image from 'next/image';
6+
7+
import clsx from 'clsx';
8+
9+
import styles from './index.module.scss';
10+
11+
interface SponsorImageProps {
12+
src: string;
13+
alt: string;
14+
}
15+
16+
function SponsorImage({ src, alt }: SponsorImageProps) {
17+
const [hasError, setHasError] = useState(false);
18+
19+
const handleError = () => {
20+
setHasError(true);
21+
};
22+
23+
const imageProperties = hasError
24+
? {
25+
src: '/assets/empty_image.png',
26+
alt: 'Image not available',
27+
fill: true,
28+
className: styles.fallbackImage,
29+
}
30+
: {
31+
src,
32+
alt,
33+
width: 0,
34+
height: 0,
35+
onError: handleError,
36+
className: styles.sponsorImage,
37+
};
38+
39+
return (
40+
<div className={clsx(styles.imageWrapper, hasError && styles.errorWrapper)}>
41+
<Image {...imageProperties} />
42+
</div>
43+
);
44+
}
45+
46+
export default SponsorImage;
Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
11
.imageList {
2-
width: 100%;
3-
height: 100%;
4-
justify-content: center;
5-
align-items: center;
62
gap: 16px;
73
display: grid;
8-
align-self: stretch;
94
place-items: center;
105
grid-template-columns: repeat(1, 1fr);
116

7+
@include tablet {
8+
gap: 16px;
9+
grid-template-columns: repeat(2, 1fr);
10+
}
11+
1212
@include desktop {
1313
gap: 32px;
1414
grid-template-columns: repeat(3, 1fr);
1515
}
16+
17+
.imageWrapper {
18+
position: relative;
19+
width: 331px;
20+
height: 158px;
21+
background-color: white;
22+
border-radius: 12px;
23+
padding: 10px;
24+
display: flex;
25+
justify-content: center;
26+
align-items: center;
27+
28+
&.errorWrapper {
29+
background-color: #2d3748; // empty_image.png 배경색과 매칭
30+
}
31+
}
32+
33+
.sponsorImage {
34+
width: auto;
35+
height: auto;
36+
max-width: 100%;
37+
max-height: 100%;
38+
}
39+
40+
.fallbackImage {
41+
object-fit: contain;
42+
}
1643
}

src/components/organisms/about/SponsorSection/index.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import ContentWithTitle from '@/components/atoms/ContentWithTitle';
2-
import Image from '@/components/molecules/Image';
32
import { getAbout } from '@/db';
43
import { getEntries } from '@/libs/utils';
54

5+
import SponsorImage from './SponsorImage';
6+
67
import styles from './index.module.scss';
78

89
function Sponsor() {
@@ -14,14 +15,7 @@ function Sponsor() {
1415
<ContentWithTitle title="후원사 소개">
1516
<div className={styles.imageList}>
1617
{sponsors.map(([key, sponsor]) => (
17-
<Image
18-
objectFit="contain"
19-
src={sponsor.link}
20-
key={key}
21-
alt={sponsor.name}
22-
width={320}
23-
height={180}
24-
/>
18+
<SponsorImage key={key} src={sponsor.link} alt={sponsor.name} />
2519
))}
2620
</div>
2721
</ContentWithTitle>

src/components/pages/Activity/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ function Activity({ activityData, currentTab }: Props) {
2424
<Button
2525
className={styles.periodButton}
2626
buttonType="chip"
27-
active={currentTab === 'post'}
28-
href="/activity?tab=post"
27+
active={currentTab === 'video'}
28+
href="/activity?tab=video"
2929
>
30-
블로그
30+
발표 영상
3131
</Button>
3232
<Button
3333
className={styles.periodButton}
3434
buttonType="chip"
35-
active={currentTab === 'video'}
36-
href="/activity?tab=video"
35+
active={currentTab === 'post'}
36+
href="/activity?tab=post"
3737
>
38-
발표 영상
38+
블로그
3939
</Button>
4040
</div>
4141
<div className={styles.wrapper}>

0 commit comments

Comments
 (0)