Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
lenincompres committed Nov 23, 2024
1 parent aec2263 commit fbf33df
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 269 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="DOM.js"></script>
<script src="lib/DOM.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-9S3H2NXER5"></script>
<script>
Expand Down
5 changes: 5 additions & 0 deletions src/Copy.js → lib/Copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#key;
#indexMap = {};
#KEY = {};
#at = {};

/**
* Creates an instance of a copy.
Expand Down Expand Up @@ -63,6 +64,7 @@
if (this.#map[key]) return console.error(`Key "${key}" already exists in copy.`);
this.#map[key] = val;
this.#KEY[key] = key;
this.#at[key] = this.get(key);
return this.get(key);
}

Expand Down Expand Up @@ -207,6 +209,9 @@
static get KEY() {
return Copy.getDefaultInstance().#KEY;
}
static get at() {
return Copy.getDefaultInstance().#at;
}
static add = (...args) => Copy.getDefaultInstance().add(...args);
static get = (...args) => Copy.getDefaultInstance().get(...args);
static next = () => Copy.getDefaultInstance().next();
Expand Down
File renamed without changes.
File renamed without changes.
21 changes: 10 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as STYLE from "./src/style.js";
import Pager from "./src/Pager.js";
import Copy from "./src/Copy.js";
import SOCIAL_LINKS from "./src/social.js";
import Pager from "./lib/Pager.js";
import Copy from "./lib/Copy.js";
import SOCIAL_LINKS from "./src/pages/data/social.js";
import CardScroll from "./src/CardScroll.js";
import news from "./src/news.js";
import news from "./src/pages/data/news.js";
import bioPage from "./src/pages/bio.js";
import projectsPage from "./src/pages/projects.js";
import contactPage from "./src/pages/contact.js";
Expand All @@ -14,12 +14,11 @@ binderSet({
isWide: false,
})

function resized(e) {
function checkViewport(e) {
isMobile = window.innerWidth < 780;
isWide = window.innerWidth > 1050;
};


Copy.add({
storyteller: {
en: "storyteller",
Expand All @@ -44,7 +43,7 @@ Copy.add({
contact: {
es: "contacto",
en: "contact",
}
},
});

let newsScroll = new CardScroll(news);
Expand Down Expand Up @@ -161,7 +160,7 @@ DOM.set({
},
tagline: {
margin: "0 .6em",
text: Copy.get('storyteller') + ' · inventor · ' + Copy.get('educator'),
text: Copy.at.storyteller + ' · inventor · ' + Copy.at.educator,
},
menu: {
display: _isMobile.as("block", "none"),
Expand Down Expand Up @@ -211,7 +210,7 @@ DOM.set({
bind: [_hoverPage, Pager._key],
as: (over, current) => current === name ? STYLE.SHADOW.INSET : over === name ? STYLE.SHADOW.HIGHLIGHT : STYLE.SHADOW.NORMAL,
},
text: Copy.get(name),
text: Copy.at[name],
onclick: e => Pager.key = name,
mouseover: e => hoverPage = name,
mouseout: e => hoverPage = false,
Expand Down Expand Up @@ -245,6 +244,6 @@ DOM.set({
},
},
},
onload: resized,
onresize: resized,
onload: checkViewport,
onresize: checkViewport,
});
12 changes: 5 additions & 7 deletions src/pages/bio.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/pages/contact.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SOCIAL_LINKS from "../social.js";
import SOCIAL_LINKS from "./data/social.js";
import * as STYLE from "../style.js";

const contactPage = {
Expand Down
76 changes: 35 additions & 41 deletions src/news.js → src/pages/data/news.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,50 @@
import Copy from "./Copy.js";
import Copy from "../../../lib/Copy.js";

let news = [];
const newsies = [{
src: "assets/poster.jpg",
alt: Copy.text({
es: "desCONCIERTO de Jalogüín",
en: "A Halloween disCONCERT",
}),
url: "https://www.google.com/maps/place/Ca%C3%B1ave/@40.8644495,-73.9289111,15z/data=!4m6!3m5!1s0x89c2f559184229cb:0x994c7ec6855fdb5!8m2!3d40.8644495!4d-73.9289111!16s%2Fg%2F11g0hldvl4?entry=ttu&g_ep=EgoyMDI0MTAyMC4xIKXMDSoASAFQAw%3D%3D",
desc: Copy.text({
es: `Lenino sale de su madriguera a cantarle cuentos a las brujas, ogros, duendes y hadas que se manifiesten la noche del **3 de Noviembre** en [Cañave]({href}).`,
en: `Lenino comes out of his burrow to sing stories to the witches, ogres, goblins and fairies that appear on the night of **November 3** at [Cañave]({href}).`,
}),
}, {
title: Copy.text({
es: "¡Nuevo website!",
en: "New website!",
}),
src: "https://i.etsystatic.com/52679041/r/il/c0dc16/6069187861/il_794xN.6069187861_a4dz.jpg",
title: Copy.text({
es: "Nuevo website y turotial",
en: "New website and tutorial",
}),
url: "https://jackrabbits.lenino.net/",
desc: Copy.text({
es: `**Jack Rabbits** tiene un nuevo [website y video tutorial]({href}). También puedes comprar una copia limitada en introductoria del juego.`,
en: `**Jack Rabbits** has a new [website and video tutorial]({href}). You can also buy a limited copy of the game there.`,
}),
}];

const addNews = (src, alt, href, desc = "", title = "") => news.push({
export default newsies.map(n => ({
h2: {
fontFamily: "title",
textAlign: "center",
text: title,
text: n.title,
},
a: {
href: href,
href: n.href,
target: "_blank",
img: {
width: "100%",
alt: alt,
src: src,
alt: n.alt,
src: n.src,
},
},
div: {
marginBottom: "1em",
markdown: desc.replace('{href}', href),
markdown: n.desc.replace('{href}', n.href),
}
});

addNews(
"assets/poster.jpg",
Copy.text({
es: "desCONCIERTO de Jalogüín",
en: "A Halloween disCONCERT",
}),
"https://www.google.com/maps/place/Ca%C3%B1ave/@40.8644495,-73.9289111,15z/data=!4m6!3m5!1s0x89c2f559184229cb:0x994c7ec6855fdb5!8m2!3d40.8644495!4d-73.9289111!16s%2Fg%2F11g0hldvl4?entry=ttu&g_ep=EgoyMDI0MTAyMC4xIKXMDSoASAFQAw%3D%3D",
Copy.text({
es: `Lenino sale de su madriguera a cantarle cuentos a las brujas, ogros, duendes y hadas que se manifiesten la noche del **3 de Noviembre** en [Cañave]({href}).`,
en: `Lenino comes out of his burrow to sing stories to the witches, ogres, goblins and fairies that appear on the night of **November 3** at [Cañave]({href}).`,
}),
);

addNews(
"https://i.etsystatic.com/52679041/r/il/c0dc16/6069187861/il_794xN.6069187861_a4dz.jpg",
Copy.text({
es: "Nuevo website y turotial",
en: "New website and tutorial",
}),
"https://jackrabbits.lenino.net/",
Copy.text({
es: `**Jack Rabbits** tiene un nuevo [website y video tutorial]({href}). También puedes comprar una copia limitada en introductoria del juego.`,
en: `**Jack Rabbits** has a new [website and video tutorial]({href}). You can also buy a limited copy of the game there.`,
}),
Copy.text({
es: "¡Nuevo website!",
en: "New website!",
}),
);

export default news;
}));
Loading

0 comments on commit fbf33df

Please sign in to comment.