add icons functionality
This commit is contained in:
32
assets/css/icon.css
Normal file
32
assets/css/icon.css
Normal 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
BIN
assets/images/cashapp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
BIN
assets/images/discord.ico
Normal file
BIN
assets/images/discord.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 279 KiB |
BIN
assets/images/tiktok.jpg
Normal file
BIN
assets/images/tiktok.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
BIN
assets/images/tiktok.png
Normal file
BIN
assets/images/tiktok.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 298 KiB |
35
assets/js/icon.js
Normal file
35
assets/js/icon.js
Normal 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);
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user