1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-19 22:53:03 +05:30

(feat): added socials as search result

This commit is contained in:
2023-11-18 19:40:18 +05:30
parent a36c6ffd29
commit 96ce43b1fe
2 changed files with 48 additions and 17 deletions

View File

@@ -111,8 +111,8 @@ function perform_search(searchInput, searchDef, searchRes) {
resultTags.forEach(tag => {
result[tag] = response.filter(item => item.tag === tag);
});
console.log(result);
inject_search_results(result.project);
inject_search_results(result);
}
},
error: function(error) {
@@ -134,27 +134,50 @@ function fallback_search(searchDef, searchRes) {
function inject_search_results (results) {
searchRes.innerHTML = `<p class="text-xs text-accent_three mt-3 mb-2 mx-1">SEARCH RESULTS</p>`;
results.forEach(function(result) {
let projectsDiv = document.createElement("div");
projectsDiv.className = "group resultitem w-full flex justify-between items-center my-1 p-1 cursor-pointer hover:bg-bg_third transition transform duration-200 rounded-lg";
projectsDiv.setAttribute("onclick", "location.href='" + result.link + "'");
projectsDiv.innerHTML = `
<span class="flex items-center">
<span class="mx-1 px-[0.65rem] py-1 rounded border-[1px] border-accent_secondary_transparent">${result.name.charAt(0).toUpperCase()}</span>
<span class="flex flex-col">
<h6 class="mx-1">${result.name}</h6>
<p class="mx-1 text-xs text-accent_three">${result.description.slice(0, 35) + '...'}</p>
if(typeof(results.project) !== 'undefined') {
results.project.forEach(function(result) {
let projectDiv = document.createElement("div");
projectDiv.className = "group resultitem w-full flex justify-between items-center my-1 p-1 cursor-pointer hover:bg-bg_third transition transform duration-200 rounded-lg";
projectDiv.setAttribute("onclick", "location.href='" + result.link + "'");
projectDiv.innerHTML = `
<span class="flex items-center">
<span class="mx-1 px-[0.65rem] py-1 rounded border-[1px] border-accent_secondary_transparent text-accent_primary">${result.name.charAt(0).toUpperCase()}</span>
<span class="flex flex-col">
<h6 class="mx-1">${result.name}</h6>
<p class="mx-1 text-xs text-accent_three">${result.description.slice(0, 35) + '...'}</p>
</span>
</span>
<span class="flex items-center mr-1">
<span class="px-[1rem] py-[0.05rem] mx-1 text-xs bg-accent_four text-bg_secondary rounded-full group-hover:hidden">${'#' + result.tag}</span>
<i class="fa-solid fa-chevron-right text-accent_three mx-2 hidden group-hover:block"></i>
</span>
`;
searchRes.appendChild(projectDiv);
});
}
if(typeof(results.social) !== 'undefined') {
results.social.forEach(function(result) {
let socialDiv = document.createElement("div");
socialDiv.className = "group resultitem w-full flex justify-between items-center my-1 p-1 cursor-pointer hover:bg-bg_third transition transform duration-200 rounded-lg";
socialDiv.setAttribute("onclick", "window.open('" + result.link + "', '_blank')");
socialDiv.innerHTML = `
<span class="flex items-center">
<i class="text-xl text-accent_primary m-2 ${result.icon}"></i>
<p class="mx-1">${result.platform}</p>
</span>
<span class="flex items-center mr-1">
<span class="px-[1rem] py-[0.05rem] mx-1 text-xs bg-accent_four text-bg_secondary rounded-full group-hover:hidden">${'#' + result.tag}</span>
<i class="fa-solid fa-chevron-right text-accent_three mx-2 hidden group-hover:block"></i>
</span>
`;
searchRes.appendChild(projectsDiv);
});
`;
searchRes.appendChild(socialDiv);
});
}
}
function inject_no_results(results) {

View File

@@ -635,6 +635,14 @@ video {
z-index: 50;
}
.m-1 {
margin: 0.25rem;
}
.m-2 {
margin: 0.5rem;
}
.mx-1 {
margin-left: 0.25rem;
margin-right: 0.25rem;