Skip to content

Commit

Permalink
Merge pull request #15 from bhyun-kim/main
Browse files Browse the repository at this point in the history
feat: Create Text Link Component in Footer
  • Loading branch information
bhyun-kim authored Jun 8, 2024
2 parents f5ecd92 + 1b21c2f commit 89434e8
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
15 changes: 15 additions & 0 deletions components/footer-link/footer-link.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.footer-link {
list-style-type: none;
padding: 0;
}
.footer-link li {
display: inline;
margin: 0 10px;
}
.footer-link a {
text-decoration: none;
color: #007bff;
}
.footer-link a:hover {
text-decoration: underline;
}
38 changes: 38 additions & 0 deletions components/footer-link/footer-link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const template = document.createElement("template");
template.innerHTML = `
<link rel="stylesheet" href="./components/footer-link/footer-link.css">
<ul class="footer-link">
<li>
<a id="link" href="#"><slot></slot></a>
</li>
</ul>
`;

class FooterLink extends HTMLElement {
constructor() {
super();
const shadow = this.attachShadow({ mode: "open" });
shadow.appendChild(template.content.cloneNode(true));
}

static get observedAttributes() {
return ["href"];
}

constructor() {
this.linkElement = shadow.getElementById("link");
this.updateLink(this.getAttribute("href"));
}

attributeChangedCallback(name, oldValue, newValue) {
if (name === "href") {
this.updateLinkHref(newValue);
}
}

updateLink(href) {
this.linkElement.setAttribute("href", href);
}
}

window.customElements.define("footer-link", FooterLink);
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
/>
<script src="https://code.iconify.design/iconify-icon/2.1.0/iconify-icon.min.js"></script>
<script src="./main.js" async defer type="module"></script>
</head>
<body>

<style>
html {
Expand Down Expand Up @@ -494,7 +496,7 @@
padding-top: 18rem;
"
>
<span>FAQ</span>
<footer-link href="/faq">FAQ</footer-link>
<div style="display: flex">
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./components/divider/divider.js";
import "./components/footer-link/footer-link.js";
import "./components/hero/hero.js";
import "./components/seo-meta-tag/seo-meta-tag.js";
12 changes: 12 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
* {
font-family: "Noto Sans KR", sans-serif;
}

footer {
background-color: #efefef;
padding-bottom: 10rem;
padding-right: 10rem;
padding-left: 10rem;
}
footer > div {
display: flex;
justify-content: space-between;
font-size: 1.6rem;
}

0 comments on commit 89434e8

Please sign in to comment.