-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
style : css 살짝 고치기
- Loading branch information
Showing
9 changed files
with
159 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import heart from "./heart.png"; | ||
|
||
import Header from "../header/Header"; | ||
|
||
import styles from "./searchboard.module.css"; | ||
|
||
export default function SearchBoard() { | ||
const navigate = useNavigate(); | ||
const [data, setData] = useState([]); | ||
|
||
useEffect(() => { | ||
// API 호출 | ||
fetch("https://api.zionhann.shop/app/makeup/posts/images") | ||
.then((response) => response.json()) | ||
.then((data) => setData(data.data)); | ||
}, []); | ||
|
||
const handleContainerClick = (num) => { | ||
navigate("/post/" + num); | ||
}; | ||
|
||
const truncate = (str, n) => { | ||
return str?.length > n ? str.substr(0, n - 1) + "..." : str; | ||
}; | ||
|
||
if (data.length === 0) return <>loading...</>; | ||
|
||
return ( | ||
<div className={styles.searchboard}> | ||
<Header></Header> | ||
<div className={styles.container}> | ||
{[...Array(4)].map((_, colIndex) => ( | ||
<div key={colIndex}> | ||
{[...Array(4)].map((_, rowIndex) => { | ||
const itemIndex = rowIndex * 4 + colIndex; | ||
const item = data[itemIndex]; | ||
if (!item) return null; | ||
return ( | ||
<div className={styles.bottom}> | ||
<div | ||
key={item.photo_id} | ||
className={styles.rect} | ||
onClick={() => handleContainerClick(item.photo_id)} | ||
style={{ backgroundImage: `url(${item.imageUrl})` }} | ||
> | ||
<div className={styles.hoverText}> | ||
{truncate(item.text, 12)} | ||
</div> | ||
|
||
<img | ||
src={heart} | ||
alt="heartimg" | ||
className={styles.heart} | ||
></img> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
.searchboard .container { | ||
display: flex; | ||
justify-content: center; | ||
white-space: pre-line; | ||
margin-bottom: 111px; | ||
background-color: #efc4b8; | ||
padding-top: 127px; | ||
padding-bottom: 127px; | ||
} | ||
|
||
.bottom > .rect { | ||
width: 220px; | ||
height: 220px; | ||
margin-left: 8px; | ||
margin-top: 8px; | ||
display: flex; | ||
background-size: cover; | ||
background-repeat: no-repeat; | ||
position: relative; | ||
} | ||
|
||
.rect:hover .hoverText { | ||
display: flex; | ||
margin-top: 234px; | ||
margin-left: 5px; | ||
font-family: "Pretendard-Regular"; | ||
font-weight: 400; | ||
font-size: 12px; | ||
} | ||
|
||
.hoverText { | ||
display: none; | ||
} | ||
|
||
.bottom { | ||
width: 236px; | ||
height: 267px; | ||
border-color: white; | ||
border-style: solid; | ||
border-radius: 5px; | ||
background-color: white; | ||
box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.15); | ||
margin-bottom: 29px; | ||
margin-right: 25px; | ||
} | ||
|
||
.bottom:hover { | ||
box-shadow: 0px 0px 25px rgba(255, 135, 159, 0.4); | ||
} | ||
|
||
.heart { | ||
position: absolute; | ||
width: 24px; | ||
height: 19px; | ||
margin-top: 234px; | ||
left: 195px; | ||
} | ||
|
||
.title { | ||
font-family: "Pretendard-Regular"; | ||
font-size: 30px; | ||
font-weight: bold; | ||
padding-top: 146px; | ||
padding-bottom: 30px; | ||
padding-left: 241px; | ||
} |