add icons functionality

This commit is contained in:
2025-12-03 10:56:56 -06:00
parent 6a2b7d7743
commit e292a0352d
8 changed files with 84 additions and 4 deletions

32
assets/css/icon.css Normal file
View File

@@ -0,0 +1,32 @@
main {
display: grid;
grid-template-columns: repeat( auto-fit, minmax(256px, 1fr) );
overflow-x: hidden;
gap: 32px;
}
/* @media screen and (min-width: ){
} */
Icon {
display: flex;
padding: 32px;
text-align: end;
justify-content: space-between;
align-items: center;
outline: 1px solid black;
}
Icon:hover {
cursor: pointer;
}
Icon img {
width: 8rem;
height: 8rem;
}

BIN
assets/images/cashapp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
assets/images/discord.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

BIN
assets/images/tiktok.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
assets/images/tiktok.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

35
assets/js/icon.js Normal file
View File

@@ -0,0 +1,35 @@
const main = document.querySelector("main");
const icons = main.querySelectorAll("Icon");
icons.forEach((icon) => {
let iconImage = icon.getAttribute("image");
let link = icon.getAttribute("href");
let title = icon.getAttribute("title");
console.log(iconImage, link, title);
if (iconImage) {
let imageElement = document.createElement("img");
imageElement.src = iconImage;
imageElement.height = 64;
imageElement.width = 64;
icon.appendChild(imageElement);
}
if (link) {
icon.addEventListener('click', (e) => {
window.open(link, "_blank");
});
}
if (title) {
let titleElement = document.createElement("span");
titleElement.textContent = title;
icon.appendChild(titleElement);
}
});

View File

@@ -5,12 +5,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Links are pretty cool</title>
<link rel="stylesheet" href="assets/css/global.css">
<link rel="stylesheet" href="assets/css/icon.css">
<script src="assets/js/global.js" defer></script>
<script src="assets/js/icon.js" defer></script>
</head>
<body>
<main>
<Icon href="https://lunarware.tech" image="/favicon.ico" title="Website"></Icon>
<Icon href="https://git.lunarware.tech/lucielle" image="https://git.lunarware.tech/assets/img/favicon.png" title="Gitea"></Icon>
<Icon href="#" image="assets/images/discord.ico" title="Discord"></Icon>
<Icon href="https://www.tiktok.com/@lucielle.0x22" image="assets/images/tiktok.png" title="TikTok"></Icon>
<Icon href="https://cash.app/$LuciEll00" image="assets/images/cashapp.png" title="Cashapp"></Icon>
</main>
</body>
</html>

View File

@@ -1,16 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Projects 'n' stuff</title>
<link rel="stylesheet" href="assets/css/global.css">
<link rel="stylesheet" href="assets/css/icon.css">
<script src="assets/js/global.js" defer></script>
<script src="assets/js/icon.js" defer></script>
</head>
<body>
<main>
<Icon href="https://git.lunarware.tech/lucielle/website" image="/favicon.ico" title="Website"></Icon>
</main>
</body>
</html>