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: footer, icon-link-list, icon-link #105

Merged
merged 2 commits into from
Jul 9, 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
63 changes: 0 additions & 63 deletions components/footer-icon.js

This file was deleted.

7 changes: 3 additions & 4 deletions components/footer-link-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,19 @@ class FooterLinks extends HTMLElement {
row-gap: 10px;

font-size: 16px;
color: white;
color: var(--bg-100);
}

@media only screen and (min-width: 768px) {
ul {
flex-direction: row;
align-items: center;
column-gap: 20px;

color: white;
}
}

@media only screen and (min-width: 1024px) {
ul {
color: var(--text-900);
column-gap: 80px;
}
}
Expand Down Expand Up @@ -95,6 +92,8 @@ class FooterLink extends HTMLElement {
padding: 0;
margin: 0;
list-style-type: none;
color: var(--bg-100);
font-size: 16px;
}
`;
}
Expand Down
90 changes: 90 additions & 0 deletions components/footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { css, html } from "../html-css-utils.js";

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

this.render();
}

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

createCss() {
return css`
:host {
display: block;
height: 400px;
color: white;
background-color: var(--text-900);
padding: 80px 27px;

@media only screen and (min-width: 768px) {
padding: 180px 76px 100px 76px;
}

@media only screen and (min-width: 1550px) {
display: flex;
justify-content: center;
}
}

footer {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
max-width: 1550px;

@media only screen and (min-width: 1550px) {
flex: 1;
}
}

section {
display: flex;
flex-direction: column;
row-gap: 40px;

@media only screen and (min-width: 768px) {
flex-direction: row;
justify-content: space-between;
}
}

p {
border-top: 1px solid rgba(253, 253, 255, 0.75);
font-size: 14px;
color: var(--bg-100);
opacity: 0.75;

margin-top: 26px;
padding-top: 20px;

@media only screen and (min-width: 768px) {
margin-top: 50px;
padding-top: 20px;
}

@media only screen and (min-width: 1024px) {
padding-top: 48px;
}
}
`;
}

createHtml() {
return html`<footer>
<section>
<slot name="footer-link-list"></slot>
<slot name="icon-link-list"></slot>
</section>

<p>© 2024 Dale Study. All rights reserved.</p>
</footer>`;
}
}

customElements.define("ds-footer", Footer);
114 changes: 114 additions & 0 deletions components/icon-link-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { css, html } from "../html-css-utils.js";

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

this.validateAttributes();
this.render();
}

validateAttributes() {
const attributes = ["href", "icon-src", "icon-alt"];

for (let i = 0; i < attributes.length; i++) {
if (!this.hasAttribute(attributes[i])) {
throw new Error(`The "${attributes[i]}" attribute is required.`);
}
}

const iconSrc = this.getAttribute("icon-src");
const validExtensions = [".svg", ".png", ".jpg", ".jpeg"];
const extension = iconSrc.slice(iconSrc.lastIndexOf(".")).toLowerCase();

if (!validExtensions.includes(extension)) {
throw new Error(
`The "icon-src" attribute must end with one of the following extensions: ${validExtensions.join(
", "
)}.`
);
}
}

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

createCss() {
const width = this.getAttribute("width");
const height = this.getAttribute("height");

return css`
a {
display: block;
}

img {
${width ? `width: ${width};` : ""}
${height ? `height: ${height};` : ""}
}
Comment on lines +47 to +50
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

`;
}

createHtml() {
const href = this.getAttribute("href");
const iconSrc = this.getAttribute("icon-src");
const iconAlt = this.getAttribute("icon-alt");

return html`
<a href="${href}" target="_blank">
<img src="${iconSrc}" alt="${iconAlt}" />
</a>
`;
}
}

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

this.render();
this.validateAttributes();
}

validateAttributes() {
const slot = this.shadowRoot.querySelector("slot");
const nodes = slot.assignedNodes();

nodes.forEach((node) => {
if (
node.nodeType === Node.ELEMENT_NODE &&
node.tagName.toLowerCase() !== "ds-icon-link"
) {
throw new Error(
"The children of ds-icon-link-list must be ds-icon-link."
);
}
});
}

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

createCss() {
return css`
section {
display: flex;
align-items: center;
column-gap: 40px;
}
`;
}

createHtml() {
return html`<section>
<slot></slot>
</section>`;
}
}

customElements.define("ds-icon-link", IconLink);
customElements.define("ds-icon-link-list", IconLinkList);
Binary file added images/blog-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/github-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/linked-in-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/youtube-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 35 additions & 51 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -394,56 +394,40 @@
</div>
</div>

<footer>
<div
style="
border-bottom: 0.1rem solid #d3d3d3;
padding-bottom: 5rem;
padding-top: 18rem;
"
>
<ds-footer-link-list>
<!-- TODO: add real links -->
<ds-footer-link href="#faq">FAQ</ds-footer-link>
<ds-footer-link href="#discover">Discover</ds-footer-link>
<ds-footer-link href="#explore">Explore</ds-footer-link>
<ds-footer-link href="#books">Books</ds-footer-link>
</ds-footer-link-list>

<div style="display: flex; gap: 40px">
<ds-footer-icon
href="https://github.com/DaleSeo"
width="24px"
height="24px"
iconSrc="images/icon-blogger.svg"
iconAlt="blogger-icon"
></ds-footer-icon>
<ds-footer-icon
href="https://www.linkedin.com/in/daleseo/"
width="24px"
height="24px"
iconSrc="images/icon-linkedin.svg"
iconAlt="linkedin-icon"
></ds-footer-icon>
<ds-footer-icon
href="https://github.com/DaleSeo"
width="24px"
height="24px"
iconSrc="images/icon-github.svg"
iconAlt="github-icon"
></ds-footer-icon>
<ds-footer-icon
href="https://www.youtube.com/@DaleSeo"
width="24px"
height="24px"
iconSrc="images/icon-youtube.svg"
iconAlt="youtube-icon"
></ds-footer-icon>
</div>
</div>
<div style="margin-top: 5rem; font-size: 1.4rem; font-weight: regular">
<p>© 2024 Dale Study. All rights reserved.</p>
</div>
</footer>
<ds-footer>
<ds-footer-link-list slot="footer-link-list">
<!-- TODO: add real links -->
<ds-footer-link href="#faq">FAQ</ds-footer-link>
<ds-footer-link href="#discover">Discover</ds-footer-link>
<ds-footer-link href="#explore">Explore</ds-footer-link>
<ds-footer-link href="#books">Books</ds-footer-link>
</ds-footer-link-list>

<ds-icon-link-list slot="icon-link-list">
<ds-icon-link
href="https://www.algodale.com/"
icon-src="images/blog-icon.png"
icon-alt="알고달레 블로그 아이콘"
></ds-icon-link>

<ds-icon-link
href="https://www.linkedin.com/in/daleseo/"
icon-src="images/linked-in-icon.png"
icon-alt="Dale Seo (달레)의 링크드인 아이콘"
></ds-icon-link>

<ds-icon-link
href="https://github.com/DaleStudy/leetcode-study"
icon-src="images/github-icon.png"
icon-alt="달레 알고리즘 스터디 깃허브 레포지토리 아이콘"
></ds-icon-link>

<ds-icon-link
href="https://www.youtube.com/@DaleSeo"
icon-src="images/youtube-icon.png"
icon-alt="Dale Seo (달레)의 유튜브 아이콘"
></ds-icon-link>
</ds-icon-link-list>
</ds-footer>
</body>
</html>
Loading