Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ <h1>SocialRepo</h1>
<section id="home">
<ul id="socialLinks">
</ul>
<div id="copyConfirm" class="copy-confirm">
<span class="copy-text"></span>
</div>
</section>
<section id="info" class="hidden">
<div id="heading">
Expand Down
69 changes: 65 additions & 4 deletions src/code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function getSocialLinks() {
.then(jsonData => {
Object.keys(jsonData).slice(1).forEach(key => {
socialLinks[key] = jsonData[key];
createSocialLink(key, jsonData[key]);
createSocialLink(key);
});
return socialLinks;
})
Expand All @@ -78,6 +78,15 @@ const socialLinks = getSocialLinks();
// ============== Home ==============
function showCopyMessage(key) {
console.log(`Copied ${key} to clipboard!`);
const copyConfirm = document.getElementById('copyConfirm');
const copyText = copyConfirm.querySelector('.copy-text');
copyText.textContent = `✅${key} profile copied.`;
copyConfirm.style.display = 'flex';

setTimeout(() => {
copyConfirm.style.display = 'none';
}, 3000);

};

function createImage(key) {
Expand All @@ -89,13 +98,31 @@ function createImage(key) {
}

const socialLinksContainer = document.getElementById("socialLinks");
function createSocialLink(key, value) {
function createSocialLink(key) {
const li = document.createElement("li");
// Here this will be a div which will come over the top of the icon and it will show the name of the app
const div = document.createElement("div")
const img = createImage(key);
div.classList.add('div-hover-effect')
//^ making the string short if it overflows (based upon its length)
if (key.length>8){
div.textContent = `${key.substr(0,8)+"..."}`
}else{
div.textContent = key
}
li.addEventListener("mouseenter",()=>{
img.style.display = 'none'
div.style.display = 'flex'
})
li.addEventListener('mouseleave',()=>{
img.style.display = 'block'
div.style.display = 'none'
})
img.onload = () => {
li.appendChild(div)
li.appendChild(img);
li.addEventListener("click", () => {
navigator.clipboard.writeText(value); // Copy the value to clipboard
navigator.clipboard.writeText(socialLinks[key]); // Copy the value to clipboard
showCopyMessage(key);
});
socialLinksContainer.appendChild(li);
Expand Down Expand Up @@ -504,4 +531,38 @@ function addDnDHandlers(elem) {
const saveBtn = document.getElementById("save-btn");
saveBtn.addEventListener("click", () => {
const links = Array.from(document.querySelectorAll(".link-box input"));
});
});

function addLinkBoxOnSave() {
const linkInputBox = document.querySelectorAll(".link-box input");
if (linkInputBox) {
linkInputBox.forEach((linkInput) => {
let inputURL = linkInput.value;
if (isValidURL(inputURL)) {
//if the link box already exists in home then update the existing one, else create a new box
const res = getSocialName(inputURL);
const key = res.key;
const value = inputURL;
let linkExists = false;
const homeSocials = document.querySelectorAll(".social-logo");
homeSocials.forEach((social) => {
if (key == social.alt) {
socialLinks[key] = value;
console.log(socialLinks);
linkExists = true;
return;
}
});
//else create a link box on home page
if (!linkExists) {
socialLinks[key] = value;
createSocialLink(key);
}
//if not a valid URL
} else {
console.log("invalid URL");
}
});
}
}
saveBtn.addEventListener("click", addLinkBoxOnSave);
58 changes: 47 additions & 11 deletions src/code/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
box-sizing: border-box;
/* font-family: "Source Sans 3", sans-serif; */
font-family: "Raleway", sans-serif;
transition: all 300ms ease;
transition: all 400ms ease;
list-style-type: none;
}

:root {
--primary-color: #7029ff;
--secondary-color: #b58fff;
--accent-color: #d0beff;
--text-color: #eeeeee;
--primary-color: #a47df2;
--secondary-color: #c3b0e8;
--accent-color: #ab98d8;
--text-color: #faf1f1;
--text-color-2: #242327;
}

body {
width: 500px;
height: 450px;
width: 600px;
height: 600px;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
scroll-behavior: smooth;
Expand Down Expand Up @@ -77,8 +77,8 @@ nav li button {
}

nav li button:active {
transform: scale(0.9);
transition-duration: 100ms;
transform: scale(0.7);
transition-duration: 120ms;
}

#info-btn {
Expand Down Expand Up @@ -184,6 +184,21 @@ p {
height: 100%;
}

.div-hover-effect{
/* position: absolute;
top: 105%; */
display: none;
justify-content: center;
align-items: center;
height: inherit;
width: inherit;
border-radius: inherit;
font-size: 11px;
font-weight: 700;
color: white;
background-color: transparent;
overflow: hidden;
}
/* ============== Info Panel ============== */

#info {
Expand Down Expand Up @@ -312,7 +327,7 @@ table td {

#images {
display: flex;
gap: 1.5rem;
gap: 1.7rem;
}

#images img {
Expand Down Expand Up @@ -345,7 +360,7 @@ table td {
font-size: 0.9rem;
outline: none;
border: none;
background-color: var(--accent-color);
background-color: white;
color: var(--primary-color);
font-weight: 600;
text-align: center;
Expand Down Expand Up @@ -542,3 +557,24 @@ table td {
transform: scale(0.9);
transition-duration: 100ms;
}

.copy-confirm {
display: none;
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background-color: var(--primary-color);
color: var(--text-color);
padding: 0.5rem 1rem;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
font-size: 1rem;
display: flex;
align-items: center;
gap: 0.5rem;
}

.copy-confirm .check {
font-size: 1.2rem;
}