-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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};` : ""} | ||
} | ||
`; | ||
} | ||
|
||
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); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍