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 : implemented header component #32

Merged
merged 4 commits into from
Jun 14, 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
68 changes: 68 additions & 0 deletions components/header.js
Copy link
Contributor

Choose a reason for hiding this comment

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

이렇게 자바스크립트 파일 하나로 뽑아내니, 생각했던 것보다 더 심플하고 좋은데요? At least, for me lol

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import "./link-button/link-button.js";

const template = document.createElement("template");
template.innerHTML = `
<style>
:host {
position: fixed;
top: 0;
left: 0;
padding: 20px 0;
width: 100%;
border-bottom: 1px solid #D3D3D3;
background-color: rgba(255, 255, 255, 0.8);
}

header {
width: 80%;
margin: 0 auto;
justify-content: space-between;
display: flex;
align-items: center;
}

.buttons-container {
display: flex;
}

a {
display: flex;
gap: 10px;
align-items: center;
text-decoration: none;
}

a img {
width: 45px;
height: 22.5px;
}

a span {
font-size: 20px;
font-weight: 500;
color: black;
}
</style>
<header>
<a href="/">
<img src="images/logo.png" alt="logo" />
<span>달레 스터디</span>
</a>

<div class="buttons-container">
<link-button href="#join-instruction-container" size="large" variant="primary">참여방법 안내</link-button>
<link-button href="https://discord.gg/43UkheRV" size="large" variant="secondary">디스코드 참여하기</link-button>
</div>
</header>
`;

class HeaderComponent extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
}

customElements.define("header-component", HeaderComponent);

11 changes: 1 addition & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,7 @@
</head>

<body>
<header>
<div>
<img src="images/logo.png" alt="#" />
<span>달레 스터디</span>
</div>
<div>
<link-button size="small" variant="ghost" href="#join-instruction-container">참여방법 안내</link-button>
<link-button size="small" variant="secondary" href="https://discord.gg/43UkheRV">디스코드 참여하기</link-button>
</div>
</header>
<header-component></header-component>

<div id="intro-container">
<div class="hero">
Expand Down
2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "./components/divider/divider.js";
import "./components/footer-link/footer-link.js";
import "./components/header.js"
import "./components/hero/hero.js";
import "./components/link-button/link-button.js";
import "./components/seo-meta-tag/seo-meta-tag.js";