Skip to content

Commit

Permalink
Merge pull request #18 from RishavOsaurus/main
Browse files Browse the repository at this point in the history
fix: Bug Fixes and Styles Changes
  • Loading branch information
SatyaRajAwasth1 authored Oct 23, 2024
2 parents 0ba3e5d + 4df2451 commit 165827d
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 16 deletions.
41 changes: 30 additions & 11 deletions src/components/shared/LeftSidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,46 @@ const yearsRange = Array.from({ length: currentYear - startYear + 1 }, (_, i) =>
const toggleBtn = document.getElementById('toggleBtn');
const closeBtn = document.getElementById('closeBtn');

function updateCloseBtnVisibility() {
if (screen.width > 1080) {
if (closeBtn) closeBtn.classList.add('hidden');
} else {
if (closeBtn) closeBtn.classList.remove('hidden');
}
}

// Initial check
updateCloseBtnVisibility();

// Add resize event listener
window.addEventListener('resize', updateCloseBtnVisibility);


function toggleSidebar() {
console.log("opening sidebar")
const isHidden = sidebar.classList.toggle('-translate-x-full');
backdrop.classList.toggle('hidden', isHidden);
if (!isHidden) {
document.body.style.overflow = 'hidden'; // Disable scrolling
} else {
document.body.style.overflow = ''; // Enable scrolling
if (sidebar) {
const isHidden = sidebar.classList.toggle('-translate-x-full');
if (backdrop) {
backdrop.classList.toggle('hidden', isHidden);
}
if (!isHidden) {
document.body.style.overflow = 'hidden'; // Disable scrolling
} else {
document.body.style.overflow = ''; // Enable scrolling
}
}
}

function closeSidebar() {
console.log("closing sidebar")
sidebar.classList.add('-translate-x-full');
backdrop.classList.add('hidden');
if (sidebar) sidebar.classList.add('-translate-x-full');
if (backdrop) backdrop.classList.add('hidden');
document.body.style.overflow = ''; // Enable scrolling
}

toggleBtn.addEventListener('click', toggleSidebar);
closeBtn.addEventListener('click', closeSidebar);
backdrop.addEventListener('click', closeSidebar);
if (toggleBtn) toggleBtn.addEventListener('click', toggleSidebar);
if (closeBtn) closeBtn.addEventListener('click', closeSidebar);
if (backdrop) backdrop.addEventListener('click', closeSidebar);
});
</script>

Expand Down
25 changes: 25 additions & 0 deletions src/content/profiles/2022/rishav-chapagain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Rishav Chapagain
program: BE Software
batch: '2022'
image:
url: https://avatars.githubusercontent.com/u/113815102?v=4
alt: Rishav Chapagain
tags:
- Backend
- Open Source Contributor
- Writer
history:
- year: '2022'
position: 'Student'
company: 'NCIT'
description: 'Learining Everything tech has to offer'

social:
linkedin: 'https://www.linkedin.com/in/rishav-chapagain'
github: 'https://github.com/rishavosaurus'
twitter: 'https://twitter.com/nerdishav'
slogan: Grades in the mud!
---

I like to read,write and do everything that does not involve conversing or talking with another individual.
4 changes: 3 additions & 1 deletion src/pages/profiles/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ const similarProfiles = allProfiles.filter((p) => p.slug !== entry.slug).slice(0
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
{similarProfiles.map((profile) => (
<div class="p-4 bg-gray-700 rounded-lg shadow-md flex flex-col items-center">
<img src={profile.data.image.url} alt={profile.data.image.alt} class="w-24 h-24 rounded-full mb-2" />
<a href={`/profiles/${profile.slug}`} style="cursor: pointer;" target="_blank" class="flex flex-col gap-1 w-full items-center justify-center">
<img src={profile.data.image.url} alt={profile.data.image.alt} class="w-24 h-24 rounded-full" />
<h3 class="font-bold text-center text-white">{profile.data.name}</h3>
<p class="text-gray-300">{profile.data.program} ({profile.data.batch})</p>
<a href={`/profiles/${profile.slug}`} class="text-blue-400 mt-2">View Profile</a>
</a>
</div>
))}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/profiles/[faculty].astro
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const { profiles } = Astro.props;
<p class="mt-4 text-center text-lg">
Don’t see the profile you were looking for?
<a
style="margin-left: 1rem;"
href="/add-profile"
class="mt-4 inline-block border border-green-500 hover:bg-green-500 text-white py-2 px-4 transition-all duration-300 rounded"
>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/profiles/[year].astro
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ const { profiles } = Astro.props;
))}
</div>
<p class="mt-4 text-center text-lg">
Dont see the profile you were looking for?
Don't see the profile you were looking for?
<a
style="margin-left: 1rem;"
href="/add-profile"
class="mt-4 inline-block border border-green-500 hover:bg-green-500 text-white py-2 px-4 transition-all duration-300 rounded"
>
Expand Down
9 changes: 6 additions & 3 deletions src/pages/profiles/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { getCollection } from "astro:content";
import TwoColLayout from "../../layout/TwoColLayout.astro";
import ProfileCard from "../../layout/AlumniCardLayout.astro";
const allProfiles = await getCollection("profiles");
import type { CollectionEntry } from "astro:content";
const allProfiles: CollectionEntry<"profiles">[] = await getCollection("profiles");
// A map to hold data in map with year/batch as key and set of profiles in alphabetical order as value
const batchMap = allProfiles.reduce((map, profile) => {
Expand All @@ -21,8 +23,9 @@ const batchMap = allProfiles.reduce((map, profile) => {
// Convert each set to an array and sort by name
for (const [batch, profilesSet] of batchMap.entries()) {
const profilesArray = Array.from(profilesSet);
profilesArray.sort((a: CollectionEntry<"profiles">, b: CollectionEntry<"profiles">) => a.data.name.localeCompare(b.data.name));
profilesArray.sort((a, b) => a.data.name.localeCompare(b.data.name));
profilesArray.sort((a: CollectionEntry<"profiles">, b: CollectionEntry<"profiles">) => a.data.name.localeCompare(b.data.name));
// Replace the set with the sorted array in the map
batchMap.set(batch, profilesArray);
Expand Down Expand Up @@ -62,7 +65,7 @@ const sortedYears = Array.from(batchMap.keys()).sort();
href="/"
class="border border-blue-500 hover:bg-blue-500 text-white py-3 px-6 transition-all duration-300"
>
Get Back to Home
Home
</a>
</div>
</section>
Expand Down

0 comments on commit 165827d

Please sign in to comment.