File tree Expand file tree Collapse file tree 4 files changed +98
-4
lines changed
Expand file tree Collapse file tree 4 files changed +98
-4
lines changed Original file line number Diff line number Diff line change 1+ import styled from "@emotion/styled" ;
2+ import { useEffect , useState } from "react" ;
3+ import SponsorExample from "../../../assets/sponsorExample.svg?react" ;
4+
5+ interface Sponsor {
6+ id : number ;
7+ name : string ;
8+ Logo : React . ComponentType ;
9+ }
10+
11+ export default function Sponsor ( ) {
12+ const [ sponsors , setSponsors ] = useState < Sponsor [ ] > ( [ ] ) ;
13+
14+ // 16개의 임시 스폰서 데이터 생성
15+ useEffect ( ( ) => {
16+ const fetchSponsors = ( ) => {
17+ const dummySponsors = Array ( 16 )
18+ . fill ( null )
19+ . map ( ( _ , index ) => ( {
20+ id : index + 1 ,
21+ name : `후원사 ${ index + 1 } ` ,
22+ Logo : SponsorExample ,
23+ } ) ) ;
24+
25+ setSponsors ( dummySponsors ) ;
26+ } ;
27+
28+ fetchSponsors ( ) ;
29+ } , [ ] ) ;
30+
31+ return (
32+ < SponsorContainer >
33+ < SponsorTitle > 후원사 목록</ SponsorTitle >
34+ < SponsorGrid >
35+ { sponsors . map ( ( sponsor ) => (
36+ < SponsorItem key = { sponsor . id } >
37+ < sponsor . Logo />
38+ </ SponsorItem >
39+ ) ) }
40+ </ SponsorGrid >
41+ </ SponsorContainer >
42+ ) ;
43+ }
44+
45+ const SponsorContainer = styled . div `
46+ width: 1067px;
47+ margin: 0 auto;
48+ margin-bottom: 140px;
49+ ` ;
50+
51+ const SponsorTitle = styled . h5 `
52+ font-weight: 600;
53+ font-size: 37px;
54+ text-align: center;
55+ margin: 0;
56+ ` ;
57+
58+ const SponsorGrid = styled . div `
59+ margin-top: 101px;
60+ display: grid;
61+ grid-template-columns: repeat(4, 1fr);
62+ column-gap: 35px;
63+ row-gap: 75px;
64+ justify-items: center;
65+ ` ;
66+
67+ const SponsorItem = styled . div `
68+ width: 240px;
69+ height: 75px;
70+ display: flex;
71+ align-items: center;
72+ justify-content: center;
73+ ` ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { Outlet } from "react-router-dom";
33
44import Footer from "./Footer" ;
55import Header from "./Header" ;
6+ import Sponsor from "./Sponsor" ;
67
78export default function MainLayout ( ) {
89 return (
@@ -11,6 +12,7 @@ export default function MainLayout() {
1112 < MainContent >
1213 < Outlet />
1314 </ MainContent >
15+ < Sponsor />
1416 < Footer />
1517 </ LayoutContainer >
1618 ) ;
Original file line number Diff line number Diff line change @@ -23,17 +23,27 @@ const TabList: { [key in SelectedTabType]: React.ReactNode } = {
2323} ;
2424
2525export const Test : React . FC = ( ) => {
26- const [ selectedTab , setSelectedTab ] = React . useState < SelectedTabType > ( getTabFromLocalStorage ( ) ) ;
27- const selectTab = ( tab : SelectedTabType ) => setSelectedTab ( setTabToLocalStorage ( tab ) ) ;
26+ const [ selectedTab , setSelectedTab ] = React . useState < SelectedTabType > (
27+ getTabFromLocalStorage ( )
28+ ) ;
29+ const selectTab = ( tab : SelectedTabType ) =>
30+ setSelectedTab ( setTabToLocalStorage ( tab ) ) ;
2831 const TabButton : React . FC < { tab : SelectedTabType } > = ( { tab } ) => (
29- < Button variant = { selectedTab === tab ? "contained" : "outlined" } onClick = { ( ) => selectTab ( tab ) } >
32+ < Button
33+ variant = { selectedTab === tab ? "contained" : "outlined" }
34+ onClick = { ( ) => selectTab ( tab ) }
35+ >
3036 { tab } Test
3137 </ Button >
3238 ) ;
3339
3440 return (
3541 < Stack >
36- < Stack direction = "row" spacing = { 2 } sx = { { width : "100%" , justifyContent : "center" } } >
42+ < Stack
43+ direction = "row"
44+ spacing = { 2 }
45+ sx = { { width : "100%" , justifyContent : "center" } }
46+ >
3747 { Object . keys ( TabList ) . map ( ( tab ) => (
3848 < TabButton key = { tab } tab = { tab as SelectedTabType } />
3949 ) ) }
You can’t perform that action at this time.
0 commit comments