Skip to content

Commit 2790d27

Browse files
authored
Merge pull request #57 from prgrms-web-devcourse-final-project/feat/cocktailPage#17
[feat] StarBg컴포넌트
2 parents 2afeb7a + 06d7dd7 commit 2790d27

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

src/app/recipe/[id]/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import StarBg from '@/shared/components/starBg/StarBg';
2+
3+
function page() {
4+
return (
5+
<div className="w-full">
6+
<StarBg className="h-200 lg:h-202" />
7+
</div>
8+
);
9+
}
10+
export default page;
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Star from '@/shared/assets/images/star_bg.webp';
21
import Image, { StaticImageData } from 'next/image';
2+
import StarBg from '../starBg/StarBg';
33

44
interface Props {
55
src: StaticImageData;
@@ -9,12 +9,7 @@ interface Props {
99

1010
function PageHeader({ src, title, description }: Props) {
1111
return (
12-
<div
13-
className="h-40 w-full bg-repeat o-cover relative md:h-65 lg:h-80"
14-
style={{
15-
backgroundImage: `url(${Star.src})`,
16-
}}
17-
>
12+
<StarBg className="relative h-40 md:h-65 lg:h-80">
1813
<div className="absolute bottom-0 left-1/2 -translate-x-1/2">
1914
<Image src={src} alt="" width={src.width} height={src.height} />
2015
<div className="text-center text-nowrap font-serif font-bold flex flex-col absolute left-1/2 -translate-x-1/2 bottom-4 md:bottom-9 lg:bottom-[55px]">
@@ -26,7 +21,7 @@ function PageHeader({ src, title, description }: Props) {
2621
</p>
2722
</div>
2823
</div>
29-
</div>
24+
</StarBg>
3025
);
3126
}
3227
export default PageHeader;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Star from '@/shared/assets/images/star_bg.webp';
2+
3+
interface Props {
4+
className: string;
5+
children?: React.ReactNode;
6+
}
7+
8+
function StarBg({ className, children }: Props) {
9+
return (
10+
<div
11+
className={`w-full bg-repeat ${className}`}
12+
style={{
13+
backgroundImage: `url(${Star.src})`,
14+
}}
15+
>
16+
{children}
17+
</div>
18+
);
19+
}
20+
export default StarBg;

0 commit comments

Comments
 (0)