Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sounmind committed Jun 15, 2024
1 parent 4d6e555 commit b72612b
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 144 deletions.
3 changes: 0 additions & 3 deletions components/header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "./link-button/link-button.js";

const template = document.createElement("template");
template.innerHTML = `
<style>
Expand Down Expand Up @@ -65,4 +63,3 @@ class HeaderComponent extends HTMLElement {
}

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

120 changes: 120 additions & 0 deletions components/link-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
const template = document.createElement("template");

template.innerHTML = /*html*/ `
<style>
a {
text-decoration: none;
color: inherit;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border-radius: 5px;
display: inline-block;
margin: 5px;
background-color: #f0f0f0;
}
a:hover {
background-color: #e0e0e0;
}
/* Outline style */
a.outline {
border: 1px solid #000;
}
/* Size variants */
a.small {
padding: 5px 10px;
font-size: 14px;
}
a.big {
padding: 15px 30px;
font-size: 18px;
}
/* Style variants */
a.ghost {
background-color: transparent;
border: none;
color: #000;
}
a.ghost:hover {
background-color: rgba(0, 0, 0, 0.1);
}
/* Combined ghost and outline styles */
a.ghost.outline {
border: 1px solid #000;
}
a.secondary {
background-color: #d9d9d9;
border: 1px solid #d9d9d9;
color: #000;
}
a.secondary:hover {
background-color: #b0b0b0;
border: 1px solid #b0b0b0;
}
</style>
<a href="#">
<slot></slot>
</a>
`;

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

this.attachShadow({
mode: "open",
});
this.shadowRoot.appendChild(template.content.cloneNode(true));

this.validateAttributes();
this.setDefaultAttributes();
this.updateAttributes();
}

validateAttributes() {
if (!this.hasAttribute("href")) {
throw new Error('The "href" attribute is required.');
}
}

setDefaultAttributes() {
if (!this.hasAttribute("size")) {
this.setAttribute("size", "small");
}
if (!this.hasAttribute("variant")) {
this.setAttribute("variant", "ghost");
}
}

updateAttributes() {
const link = this.shadowRoot.querySelector("a");
link.setAttribute("href", this.getAttribute("href"));

// Set target to "_blank" only for external links
if (!this.getAttribute("href").startsWith("#")) {
link.setAttribute("target", "_blank");
}

if (this.hasAttribute("size")) {
link.classList.add(this.getAttribute("size"));
}
if (this.hasAttribute("variant")) {
link.classList.add(this.getAttribute("variant"));
}
if (this.hasAttribute("outline")) {
link.classList.add("outline");
}
}
}

customElements.define("link-button", LinkButton);
58 changes: 0 additions & 58 deletions components/link-button/link-button.css

This file was deleted.

76 changes: 0 additions & 76 deletions components/link-button/link-button.js

This file was deleted.

30 changes: 26 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,23 @@
</head>

<body>
<link-button
size="big"
variant="secondary"
href="https://discord.gg/43UkheRV"
>๋””์Šค์ฝ”๋“œ ์ฐธ์—ฌํ•˜๊ธฐ</link-button
>
<header-component></header-component>

<div id="intro-container">
<div class="hero">
<p>ํ•ด์™ธ์ทจ์—…์„ ์œ„ํ•œ ์ปค๋ฎค๋‹ˆํ‹ฐ ๊ธฐ๋ฐ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์Šคํ„ฐ๋””</p>
<link-button size="big" variant="secondary" href="https://discord.gg/43UkheRV">๋””์Šค์ฝ”๋“œ ์ฐธ์—ฌํ•˜๊ธฐ</link-button>
<p>ํ•ด์™ธ์ทจ์—…์„ ์œ„ํ•œ ์ปค๋ฎค๋‹ˆํ‹ฐ ๊ธฐ๋ฐ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์Šคํ„ฐ๋””</p>
<link-button
size="big"
variant="secondary"
href="https://discord.gg/43UkheRV"
>๋””์Šค์ฝ”๋“œ ์ฐธ์—ฌํ•˜๊ธฐ</link-button
>
</div>

<div class="intro-image">
Expand All @@ -253,14 +264,25 @@
</div>
<div class="hero">
<p>์ง€์—ญ์— ๊ด€๊ณ„์—†์ด ๋‹ค์–‘ํ•œ ์–ธ์–ด๋กœ ์ฐธ์—ฌํ•  ์ˆ˜ ์žˆ์–ด์š”</p>
<link-button size="big" variant="ghost" outline href="#join-instruction-container">์ฐธ์—ฌ๋ฐฉ๋ฒ• ์•ˆ๋‚ด</link-button>
<link-button
size="big"
variant="ghost"
outline
href="#join-instruction-container"
>์ฐธ์—ฌ๋ฐฉ๋ฒ• ์•ˆ๋‚ด</link-button
>
</div>
</div>

<div id="review-container">
<div class="hero">
<p>์ฝ”๋“œ๋ฆฌ๋ทฐ๋ฅผ ํ†ตํ•ด ์ƒˆ๋กœ์šด ๊ด€์ ์„ ๋ฐฐ์šธ ์ˆ˜ ์žˆ์–ด์š”</p>
<link-button size="big" variant="secondary" href="https://discord.gg/43UkheRV">๋””์Šค์ฝ”๋“œ ์ฐธ์—ฌํ•˜๊ธฐ</link-button>
<link-button
size="big"
variant="secondary"
href="https://discord.gg/43UkheRV"
>๋””์Šค์ฝ”๋“œ ์ฐธ์—ฌํ•˜๊ธฐ</link-button
>
</div>
<div class="review-image">
<img src="images/review.png" />
Expand Down
5 changes: 2 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import "./components/divider/divider.js";
import "./components/footer-link/footer-link.js";
import "./components/header.js"
import "./components/header.js";
import "./components/hero/hero.js";
import "./components/link-button/link-button.js";
import "./components/link-button.js";
import "./components/review-item/review-item.js";
import "./components/seo-meta-tag/seo-meta-tag.js";

0 comments on commit b72612b

Please sign in to comment.