-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from whitep4nth3r/make-webring-static-new
Make webring static
- Loading branch information
Showing
7 changed files
with
184 additions
and
10 deletions.
There are no files selected for viewing
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,46 @@ | ||
function Webring({ members, prevUrl, nextUrl }) { | ||
return /* html */ ` | ||
<h2 class="tcwr__title">The Claw <span>webring</span></h2> | ||
<div class="tcwr__nav"> | ||
<a href=${prevUrl} class="tcwr__navItem">Previous</a> | ||
<button class="tcwr__navItem--random" data-webring-random>Random</button> | ||
<a href="${nextUrl}" class="tcwr__navItem">Next</a> | ||
</div> | ||
<ul class="tcwr__membersList"> | ||
${members | ||
.map( | ||
(member) => ` | ||
<li class="tcwr__membersListItem"> | ||
<a href="${member.url}" class="tcwr__membersListItemLink"> | ||
${member.name} | ||
</a> | ||
</li>`, | ||
) | ||
.join("")} | ||
</ul> | ||
<a href="https://github.com/whitep4nth3r/the-claw-webring#join-the-claw-webring" class="tcwr__join">Join</a> | ||
<script type="text/json" id="members"> | ||
${JSON.stringify(members)} | ||
</script> | ||
<script type="module"> | ||
function getRandomInt(min, max) { | ||
return Math.round(Math.random() * (max - min) + min); | ||
} | ||
export function getRandomEntry(array) { | ||
return array[getRandomInt(0, array.length - 1)]; | ||
} | ||
const members = JSON.parse(document.getElementById("members").textContent); | ||
const randomButton = document.querySelector("[data-webring-random]"); | ||
randomButton.addEventListener("click", () => { | ||
window.location.href = getRandomEntry(members).url; | ||
}) | ||
</script> | ||
`; | ||
} | ||
|
||
module.exports = Webring; |
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,11 @@ | ||
module.exports = async function () { | ||
const members = await fetch( | ||
"https://the-claw-webring.netlify.app/data/members.json", | ||
).then((res) => res.json()); | ||
|
||
return { | ||
members, | ||
prevUrl: members[members.length - 1].url, // can be static because I know my position in the webring as index 0 | ||
nextUrl: members[1].url, // can be static because I know my position in the webring as index 0 | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
.tcwr__title { | ||
@include font_bold; | ||
color: var(--color-link); | ||
font-size: 1.2rem; | ||
line-height: 1.6; | ||
margin-bottom: 0.5rem; | ||
|
||
span { | ||
font-family: "Atomic Marker"; | ||
color: var(--orange); | ||
} | ||
} | ||
|
||
@keyframes funky { | ||
0% { | ||
filter: saturate(100%); | ||
transform: rotate(-8deg); | ||
} | ||
50% { | ||
filter: saturate(0); | ||
transform: rotate(-2deg); | ||
} | ||
100% { | ||
filter: saturate(100%); | ||
transform: rotate(-8deg); | ||
} | ||
} | ||
|
||
.tcwr__logo { | ||
animation: funky infinite 4s; | ||
max-height: 100%; | ||
margin: auto; | ||
transform: rotate(-8deg); | ||
} | ||
|
||
@media (prefers-reduced-motion: reduce) { | ||
.tcwr__logo { | ||
animation: unset; | ||
} | ||
} | ||
|
||
.tcwr__nav { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 1rem; | ||
margin-top: 0.5rem; | ||
margin-bottom: 1rem; | ||
justify-content: space-around; | ||
} | ||
|
||
.tcwr__navItem { | ||
font-style: italic; | ||
line-height: 1.2; | ||
color: var(--color-fg-copy); | ||
display: block; | ||
font-size: 1rem; | ||
padding: 0.25rem; | ||
border-radius: var(--border-radius-base); | ||
} | ||
|
||
.tcwr__navItem--random { | ||
@include font_bold; | ||
font-style: normal; | ||
color: var(--color-fg-copy); | ||
border-radius: var(--border-radius-base); | ||
background-color: var(--input-bg); | ||
padding: 0.6rem 1rem; | ||
border: var(--input-border); | ||
} | ||
|
||
.tcwr__navItem:focus, | ||
.tcwr__navItem:focus-visible { | ||
@include input_focus; | ||
} | ||
|
||
.tcwr__membersList { | ||
padding-inline-start: 0; | ||
list-style: none; | ||
max-height: 100px; | ||
overflow-y: auto; | ||
} | ||
|
||
.tcwr__membersListItemLink { | ||
color: var(--color-fg-copy); | ||
margin-bottom: 0.25rem; | ||
display: block; | ||
} | ||
|
||
.tcwr__membersListItemLink:focus-visible, | ||
.tcwr__membersListItemLink:focus-visible:focus { | ||
@include input_focus; | ||
} | ||
|
||
.tcwr__join { | ||
background-color: var(--orange); | ||
display: block; | ||
border-width: 0; | ||
border-radius: var(--border-radius-base); | ||
width: 100%; | ||
color: var(--black); | ||
font-family: "Atomic Marker"; | ||
font-size: 1.5rem; | ||
text-align: center; | ||
text-decoration: none; | ||
padding: 0.5rem 1rem; | ||
margin: 1rem auto 0.5rem auto; | ||
} | ||
|
||
.tcwr__join:focus-visible, | ||
.tcwr__join:focus-visible:focus { | ||
@include input_focus; | ||
} |
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 |
---|---|---|
|
@@ -40,3 +40,4 @@ | |
@import "sponsorships"; | ||
@import "stream-package"; | ||
@import "newsletter-signup"; | ||
@import "webring"; |
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