mirror of
https://github.com/neosubhamoy/neosubhamoy-portfolio.git
synced 2025-12-20 01:09:35 +05:30
(feat): added socials as search result
This commit is contained in:
@@ -111,8 +111,8 @@ function perform_search(searchInput, searchDef, searchRes) {
|
|||||||
resultTags.forEach(tag => {
|
resultTags.forEach(tag => {
|
||||||
result[tag] = response.filter(item => item.tag === tag);
|
result[tag] = response.filter(item => item.tag === tag);
|
||||||
});
|
});
|
||||||
console.log(result);
|
|
||||||
inject_search_results(result.project);
|
inject_search_results(result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(error) {
|
error: function(error) {
|
||||||
@@ -134,14 +134,15 @@ function fallback_search(searchDef, searchRes) {
|
|||||||
function inject_search_results (results) {
|
function inject_search_results (results) {
|
||||||
searchRes.innerHTML = `<p class="text-xs text-accent_three mt-3 mb-2 mx-1">SEARCH RESULTS</p>`;
|
searchRes.innerHTML = `<p class="text-xs text-accent_three mt-3 mb-2 mx-1">SEARCH RESULTS</p>`;
|
||||||
|
|
||||||
results.forEach(function(result) {
|
if(typeof(results.project) !== 'undefined') {
|
||||||
let projectsDiv = document.createElement("div");
|
results.project.forEach(function(result) {
|
||||||
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";
|
let projectDiv = document.createElement("div");
|
||||||
projectsDiv.setAttribute("onclick", "location.href='" + result.link + "'");
|
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 + "'");
|
||||||
|
|
||||||
projectsDiv.innerHTML = `
|
projectDiv.innerHTML = `
|
||||||
<span class="flex items-center">
|
<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="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">
|
<span class="flex flex-col">
|
||||||
<h6 class="mx-1">${result.name}</h6>
|
<h6 class="mx-1">${result.name}</h6>
|
||||||
<p class="mx-1 text-xs text-accent_three">${result.description.slice(0, 35) + '...'}</p>
|
<p class="mx-1 text-xs text-accent_three">${result.description.slice(0, 35) + '...'}</p>
|
||||||
@@ -153,8 +154,30 @@ function inject_search_results (results) {
|
|||||||
</span>
|
</span>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
searchRes.appendChild(projectsDiv);
|
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(socialDiv);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function inject_no_results(results) {
|
function inject_no_results(results) {
|
||||||
|
|||||||
@@ -635,6 +635,14 @@ video {
|
|||||||
z-index: 50;
|
z-index: 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-1 {
|
||||||
|
margin: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-2 {
|
||||||
|
margin: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.mx-1 {
|
.mx-1 {
|
||||||
margin-left: 0.25rem;
|
margin-left: 0.25rem;
|
||||||
margin-right: 0.25rem;
|
margin-right: 0.25rem;
|
||||||
|
|||||||
Reference in New Issue
Block a user