Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement intro section component #95

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Hero extends HTMLElement {
h2 {
font-weight: inherit;
font-size: 30px;
word-break: keep-all;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SamTheKorean 단어 단위의 줄바꿈을 위해 hero 컴포넌트에 이 속성을 추가했어요

}

@media only screen and (min-width: 768px) {
Expand Down
4 changes: 0 additions & 4 deletions components/hero/hero.css

This file was deleted.

17 changes: 0 additions & 17 deletions components/hero/hero.js

This file was deleted.

114 changes: 114 additions & 0 deletions components/intro-section.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { css, html } from "../html-css-utils.js";

class IntroSection extends HTMLElement {
constructor() {
super();

this.render();
}

render() {
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = this.createCss() + this.createHtml();
}

createCss() {
return css`
section {
display: flex;
justify-content: center;
align-items: center;

height: 100vh;
background: linear-gradient(
0deg,
rgba(251, 250, 255, 0) -10%,
rgba(251, 250, 255, 1) 25%
),
linear-gradient(
90deg,
rgba(36, 234, 202, 0.8) 0%,
rgba(132, 109, 233, 0.8) 100%
);
}

.inner-container {
display: flex;
flex-direction: column;
row-gap: 30px;

/* NOTE: Requires accurate policy settings */
margin: 0 7.5%;
}

@media only screen and (min-width: 768px) {
/* NOTE: Requires accurate policy settings */
.inner-container {
row-gap: 50px;
margin: 0 9%;
}
}

@media only screen and (min-width: 1024px) {
.inner-container {
position: relative;
flex-direction: row-reverse;
row-gap: unset;
/* NOTE: Requires accurate policy settings */
margin: 0;
width: 80%;
}
}

article {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
/* NOTE: Requires accurate policy settings */
row-gap: -4.9px;

width: 70%;
}

@media only screen and (min-width: 768px) {
article {
/* NOTE: Requires accurate policy settings */
row-gap: -3.2px;
}
}

@media only screen and (min-width: 1024px) {
article {
row-gap: unset;
width: 40%;
}
}

@media only screen and (min-width: 1024px) {
aside {
width: 60%;
}
}
Comment on lines +74 to +92
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개인적으로는, 미디어쿼리를 아래와 같이 통합하는게 가독성에 더 좋다고 생각하는데, 혹시 각 엘리먼트마다 구분해서 미디어쿼리를 작성하신 이유가 있으실까요?

@media only screen and (min-width: 768px) {
  .inner-container {
    ...
  }
  article {
    ...
  }
}

@media only screen and (min-width: 1024px) {
  .inner-container {
    ...
  }
  article {
    ...
  }
  aside {
    ...
  }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 작성하면 각 엘리먼트, 선택자 별로 어떻게 반응형으로 대응하는지 빠르게 알 수 있는 것을 경험했기 때문에 선호하는 방식이에요.
예를 들어, 미디어쿼리 안에 스타일 코드가 길어질 경우, 특정 엘리먼트에 대한 반응형 스타일을 미디워쿼리 별로 비교하면서 스타일 코드를 작성할 때 매번 스크롤을 많이 이동해야 하는 불편함을 경험했었거든요.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 스타일 코드 양이 많아질수록 dx가 개선될 수 있는 좋은 안이 될 수 있을 것 같네요!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sounmind @yolophg What an interesting conversation!

2024년이니 저 같으면 미디어 쿼리를 선택자 안에 둘 것 같아요! 이 방식이 우리가 실제 스타일 생각하는 방식과 제일 유사히지 않나요?

article {
  ...

  @media only screen and (min-width: 768px) {
    ...
  }

  @media only screen and (min-width: 1024px) {
    ...
  }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이런 문법이 가능했었군요? 몰랐습니다. 이게 가능하다면 제가 가장 선호하는 방식이 되겠네요!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaleSeo 이 스펙에 관련된 문서를 어디서 찾을 수 있을까요??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너무 최신이라 하이라이팅이 못 따라가네요...ㅋㅋㅋ

`;
}

createHtml() {
return html`
<section>
<div class="inner-container">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상위 section 요소에 바로 스타일을 해도 되지 않을까요? 현재 section에 적용되어 있는 스타일은 :host psedo class 선택자로 적용해주고요. 이러한 패턴을 다른 PR에서 본 것 같은데, 불필요한 div 요소를 줄일 수 있어서 좋은 것 같았습니다.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오? 그랬군요. 알아보고 가능하다면 적용해보겠습니다.

<aside>
<slot name="image"></slot>
</aside>

<article>
<slot name="heading"></slot>
<slot name="button"></slot>
</article>
</div>
</section>
`;
}
}

customElements.define("ds-intro-section", IntroSection);
4 changes: 4 additions & 0 deletions global-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ html {
scroll-behavior: smooth;
}

body {
margin: 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 글로벌 스타일 때문에 밑에 섹션들이 모두 숨막히게 붙어버리는 좌우로 붙어버리는 것은 같은데 의도하신 건가요?

Shot 2024-07-03 at 19 35 09@2x

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 의도한 것 맞습니다.
지금 body에 부여된 스타일로는 section 컴포넌트들을 요구사항대로 구현할 수 없었기 때문에...(배경 때문이라도)
일단 초기화 해놓았습니다.
global style 관련해서 오늘 정기미팅 안건에 올려놓았는데요. 이야기해보면 좋겠습니다.

}

a {
text-decoration: none;
color: inherit;
Expand Down
55 changes: 16 additions & 39 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@
<script src="./main.js" async defer type="module"></script>

<style>
body {
width: 80%;
margin-left: auto;
margin-right: auto;
max-width: 130rem;
}

header {
margin: 2rem 0;
border-bottom: 0.1rem solid #d3d3d3;
Expand Down Expand Up @@ -77,22 +70,6 @@
font-weight: medium;
}

#intro-container {
display: flex;
justify-content: space-between;
margin-top: 23.5rem;
padding-bottom: 24rem;
border-bottom: 0.1rem solid #d3d3d3;
}

.intro-image {
width: 55%;
}

.intro-image img {
max-width: 100%;
}

#language-container {
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -145,7 +122,7 @@
/* 'review-card-list' style will be removed when the review card list component is created */
.review-card-list {
display: grid;
grid-template-columns: minmax(306px, 1fr);
grid-template-columns: minmax(306px, 1fr);
gap: 10px;
padding-top: 40px;
place-content: center;
Expand Down Expand Up @@ -233,7 +210,7 @@
font-size: 2.4rem;
font-weight: regular;
}

/* 'review-card-list' style will be removed when the review card list component is created */
/* Medium devices such as tablets (768px and up) */
@media only screen and (min-width: 768px) {
Expand All @@ -254,21 +231,21 @@
<body>
<header-component></header-component>

<div id="intro-container">
<div class="hero">
<ds-hero>해외취업을 위한 커뮤니티 기반 알고리즘 스터디</ds-hero>
<ds-button-link
size="big"
variant="primary"
href="https://discord.gg/43UkheRV"
>디스코드 참여하기</ds-button-link
>
</div>
<ds-intro-section id="intro-section">
<ds-hero slot="heading">
해외취업을 위한 커뮤니티 기반 알고리즘 스터디
</ds-hero>
<ds-button-link
slot="button"
size="big"
variant="primary"
href="https://discord.gg/43UkheRV"
>
디스코드 참여하기
</ds-button-link>

<div class="intro-image">
<ds-image src="images/roadmap.png" alt="roadmap"></ds-image>
</div>
</div>
<ds-image slot="image" src="images/roadmap.png" alt="roadmap"></ds-image>
</ds-intro-section>

<div id="language-container">
<div class="language-image">
Expand Down
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import "./components/button-link.js";
import "./components/footer-link/footer-link.js";
import "./components/footer-icon.js";
import "./components/footer-link/footer-link.js";
import "./components/header.js";
import "./components/hero.js";
import "./components/image.js";
import "./components/intro-section.js";
import "./components/review-item.js";
import "./components/seo-meta-tag/seo-meta-tag.js";