Skip to content

Commit

Permalink
Merge pull request #60 from anishkn04/sfd-2024
Browse files Browse the repository at this point in the history
refactor: Use a constant base URL instead of whole
  • Loading branch information
SatyaRajAwasth1 authored Oct 3, 2024
2 parents d2202b3 + 9bb2a4a commit 7765eaf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
10 changes: 6 additions & 4 deletions js/activities.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const baseActivitiesURL = "https://raw.githubusercontent.com/noskofficial/sfd-resources/refs/heads/main/nosk-sfd-2024"

document.addEventListener("DOMContentLoaded", async () => {
const clkContainer = document.getElementById("clickables");
const colorForTitles = ["#E4554E", "#000000", "#009042", "#FFCD29"];
Expand All @@ -17,24 +19,24 @@ document.addEventListener("DOMContentLoaded", async () => {
cCard += clickGen(activity, colorForTitles[i], colorForButtons[i]);
i++;
});
} catch {
console.error();
} catch(error) {
console.error(error);
}
document.getElementById("unclickables").innerHTML = ucCard;
document.getElementById("clickables").innerHTML = cCard;
});

const unclickGen = (activity) => {
return `<div class='bg-white rounded-2xl w-full p-5 pt-8 border-[0.2px] border-[#787676] transition-all drop-shadow-lg hover:drop-shadow-2xl cursor-default flex flex-col gap-4 items-center h-full ${activity.title == "Cake Cutting" ? " sm:hidden lg:flex " : ""}'>
<img src="${activity.image}" alt="${activity.title}" class="h-20 w-20">
<img src="${baseActivitiesURL+activity.image}" alt="${activity.title}" class="h-20 w-20">
<div class="font-bold text-xl md:text-2xl text-center">${activity.title}</div>
<div class="font-light text-sm md:text-base text-center">${activity.description}</div>
</div>`;
};
const clickGen = (activity, titleColor, buttonColor) => {
return `<div class='bg-white rounded-2xl w-full p-5 flex flex-col gap-4 drop-shadow-lg transition-all hover:drop-shadow-2xl cursor-default border-[0.2px] border-[#787676] items-center h-full ${activity.title == "Cake Cutting" ? " sm:hidden lg:flex " : ""}'>
<div class="flex w-full items-center">
<img src="${activity.image}" alt="${activity.title}" class="h-20 w-20">
<img src="${baseActivitiesURL+activity.image}" alt="${activity.title}" class="h-20 w-20">
<div class="font-bold text-xl md:text-2xl flex-1 text-center" style="color: ${titleColor}">${activity.title}</div>
</div>
<div class="font-light text-sm md:text-base flex-1 text-center">${activity.description}</div>
Expand Down
4 changes: 3 additions & 1 deletion js/gallery.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const baseGalleryURL = "https://raw.githubusercontent.com/noskofficial/sfd-resources/refs/heads/main/nosk-sfd-2024"

// Fetch the gallery data from the JSON file and insert it into the HTML
fetch(
"https://raw.githubusercontent.com/noskofficial/sfd-resources/refs/heads/main/nosk-sfd-2024/data/gallery.json",
Expand All @@ -16,7 +18,7 @@ fetch(
);

galleryItem.innerHTML = `
<img class="w-full h-64 object-cover" src="${item.image}" alt="${item.description}">
<img class="w-full h-64 object-cover" src="${baseGalleryURL+item.image}" alt="${item.description}">
<div class="p-4">
<p class="font-semibold text-lg mb-2">${item.description}</p>
</div>
Expand Down
3 changes: 2 additions & 1 deletion js/members.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const baseMembersURL = "https://raw.githubusercontent.com/noskofficial/sfd-resources/refs/heads/main/nosk-sfd-2024"
// Function to create cards
function createCard(member) {
return `
<div id="members-card" class="relative w-72 rounded-3xl shadow-lg overflow-hidden">
<!-- Background Image -->
<img id="profile" src="${member.image}" alt="${member.name}" class="w-full rounded-3xl h-96 object-cover border-8 border-white">
<img id="profile" src="${baseMembersURL+member.image}" alt="${member.name}" class="w-full rounded-3xl h-96 object-cover border-8 border-white">
<!-- Overlay with text -->
<div class="absolute text-center bottom-0 left-0 w-full bg-black bg-opacity-60 text-white p-4">
Expand Down
4 changes: 3 additions & 1 deletion js/partners.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const basePartnersURL = "https://raw.githubusercontent.com/noskofficial/sfd-resources/refs/heads/main/nosk-sfd-2024"

async function partnersLoader() {
const res = await fetch(
"https://raw.githubusercontent.com/noskofficial/sfd-resources/refs/heads/main/nosk-sfd-2024/data/sponsors.json",
Expand Down Expand Up @@ -43,7 +45,7 @@ async function partnersLoader() {
<div class="sponsor-image max-w-full max-h-full min-h-36 my-auto flex items-center justify-center">
<a href="${link}">
<img
src="${image}"
src="${basePartnersURL+image}"
alt="${name}"
class="max-w-full max-h-full min-w-48 object-cover"
/>
Expand Down
4 changes: 3 additions & 1 deletion js/sponsors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const baseSponsorsURL = "https://raw.githubusercontent.com/noskofficial/sfd-resources/refs/heads/main/nosk-sfd-2024"

document.addEventListener("DOMContentLoaded", async () => {
let spCards = "";

Expand All @@ -9,7 +11,7 @@ document.addEventListener("DOMContentLoaded", async () => {
const sponsorCount = data.length;
data.forEach((sponsor) => {
spCards += `<a target="_blank" href="${sponsor.link}" class="w-full h-full has-tooltip min-h-48 bg-white drop-shadow-lg hover:drop-shadow-2xl border-[0.2px] border-[#787676] p-8 flex justify-center items-center rounded-lg ">
<abbr title="${sponsor.name}"><img src="${sponsor.image}" alt="${sponsor.name}" class="max-w-full max-h-full object-contain"></abbr>
<abbr title="${sponsor.name}"><img src="${baseSponsorsURL+sponsor.image}" alt="${sponsor.name}" class="max-w-full max-h-full object-contain"></abbr>
</a>`;
});

Expand Down

0 comments on commit 7765eaf

Please sign in to comment.