SCSS μμ± λ§λ¬΄λ¦¬
populate μ€μ²© μ¬μ© / formμ font-awesome μμ΄μ½ λ£κΈ° / shared.scss μμ± / μ΄λ―Έμ§ λΉμ¨μ λ§μΆ° μνμΌλ‘ μλ₯΄κΈ° / νλ‘ν μ΄λ―Έμ§κ° μλ κ²½μ° / ν μ€νΈ μμ§ μ€μ μ λ ¬
μ 체 μ½λλ κΉνλΈμ μ¬λ¦Ό
μ¬κΈ°μλ μ΄λ €μ λ λΆλΆλ€λ§ λ°λ‘ μ 리
User objectμ videos νλμ _id κ°μ μ€μ Video objectλ€λ‘ λ°κΎΈλ©΄μ κ·Έ Video objectμ owner νλμ _id κ°λ μ€μ User objectλ‘ λ°κΎΌλ€.
// videoController.js
export const see = async (req, res) => {
const { id } = req.params;
const videos = await User.find(id).populate({
path: "videos",
populate: {
path: "owner",
model: "User",
},
});
};
input(value="search now", type="submit")
μ μμ νκ³ λμ μ button
μ μΆκ°νλ€.
κ·Έ ν position relativeμ absoluteλ₯Ό μ΄μ©ν΄ μμΉλ₯Ό μ‘μλ€.
//- search.pug
form(method="GET").search-form
input(name="keyword", placeholder="Search by keywords", required, autofocus)
button
i.fas.fa-search
// search.scss
.search-form {
position: relative;
button {
position: absolute;
right: 5px;
top: 7px;
font-size: $font-regular;
background-color: transparent;
color: $bg;
border-style: none;
}
}
[CSS] ν μ€νΈ μΈλ‘ μ€μ μ λ ¬ 4κ°μ§ μ°Έκ³
li {
margin-left: 44px;
text-transform: uppercase;
font-weight: bold;
display: table;
a {
display: table-cell;
vertical-align: middle;
}
}
.container {
display: flex;
flex-direction: column;
margin: 40px auto;
padding: 40px;
max-width: 400px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.4);
hr {
width: 90%;
border: 1px solid rgba(255, 255, 255, 0.4);
}
}
.video-mixin__container {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 20px;
margin: 80px 0;
}
.empty-message {
font-size: $font-regular;
}
.auth-switch {
margin: 20px 0;
font-size: $font-small;
text-align: center;
a {
text-decoration: underline;
transition: all 300ms;
}
a:hover {
color: $red;
}
}
.profile-outer-box {
width: 60px;
.profile-inner-box {
padding-top: 100%;
overflow: hidden;
position: relative;
border-radius: 50%;
.profile-img {
width: 100%;
height: 100%;
object-fit: cover;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
}
[TIL] 210925 δΈ λΉμ¨ μ μ§νλ λ°μν μ΄λ―Έμ§ λ§λ€κΈ°λ₯Ό μ°Έκ³ ν΄μ μμ νλ€.
κ·Έλ°λ° μμμ μ 리νλ λλ‘ μμ±νλκΉ μ΄λ―Έμ§μ ν¬κΈ°κ° μ΄λ»λ μκ΄μμ΄ μ€μμμ 무쑰건 (80x80)pxμ μλΌλ΄μ μ΄λ―Έμ§μ μΌλΆλΆλ§ 보μ¬μ£Όλ λ¬Έμ κ° μμλ€.
λ΄κ° μνλ 건 μ΄λ―Έμ§μ μ€μμμ λ¨Όμ 짧μ λ³μ κΈ°μ€μΌλ‘ μ μ¬κ°νμΌλ‘ μλ₯Έ νμ
(80x80)pxμ μνμ λ§μΆ°μ 보μ¬μ£Όλ κ²μ΄μλ€.
widthμ heightλ₯Ό λͺ¨λ 100%λ‘ μ§μ ν ν object-fit: cover
μ μ΄μ©ν΄ μ΄λ―Έμ§μ ν λ³μ΄ λ€λ₯Έ λ³μ λΉν΄ μ¬νκ² κΈΈμ΄λ μμ λ± λ§κ² μμΉνλλ‘ νλ€.
λ€λ§ μ΄ λ°©λ²μ μΈ λλ§λ€ λ μ’μ λ°©λ²μ΄ μμκΉ κ³ λ―Όλλ€. divλ₯Ό μ΄λ κ² μ€λ³΅ν΄μ μ°λ κ² μ΅μ μ μλ ν λ°.
.profile-outer-box {
width: 60px;
.profile-inner-box {
padding-top: 100%;
overflow: hidden;
position: relative;
border-radius: 50%;
.profile-img {
width: 100%; // μΆκ° β
height: 100%; // μΆκ° β
object-fit: cover; // μΆκ° β
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
}
μ²μ ν¨μ€μλλ₯Ό μ΄μ©ν΄ κ°μ
νλ©΄ νλ‘ν μ΄λ―Έμ§κ° μλ€.
μ΄ κ²½μ°μ headerμ νλ‘ν μ΄λ―Έμ§λ₯Ό μ΄λͺ¨μ§λ‘ λ체νλ€.
νλ‘ν νμΈ νμ΄μ§λ κ°μ λ°©λ²μΌλ‘ μμ νλ€.
a νκ·Έλ₯Ό ν λ²λ§ μ°λλ‘ μμ νκ³ μΆμμΌλ 5) λλ¬Έμ κ·Έλ κ² ν μκ° μλ€.
if loggedInUser.avatarUrl === undefined
a(href=`/users/${loggedInUser._id}`)
span π
else
div.profile-outer-box
div.profile-inner-box
a(href=`/users/${loggedInUser._id}`)
img(src="/" + loggedInUser.avatarUrl).profile-img