Repository navigation
Achievements /achievements page
#45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mirzattar
wants to merge
5
commits into
main
Choose a base branch
from
achievements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1fbc110
feat: add achievements page
vincentiusGian eb84582
style: align achievements page padding with members
outrowed b014720
style: fix achievements carousel arrow overlap and mobile sizing
outrowed 0effb7f
style: replace achievements color literals with tokens and fix icon c…
outrowed 7a7881b
refactor: build achievement member list without innerHTML
outrowed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| --- | ||
| import type { LatestAchievement } from "@/data/achievements"; | ||
| import styles from "./LatestAchievements.module.css"; | ||
|
|
||
| interface Props { | ||
| achievements: LatestAchievement[]; | ||
| } | ||
|
|
||
| const { achievements } = Astro.props; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| --- | ||
|
|
||
| <section class={styles.latest_section} aria-label="Latest Achievements"> | ||
| <h1 class={styles.heading}>LATEST ACHIEVEMENTS</h1> | ||
|
|
||
| <!-- Carousel Bar with Arrows & Floating Center Card --> | ||
| <div class={styles.carousel_bar} data-achievement-carousel> | ||
| <button | ||
| type="button" | ||
| class={styles.nav_button} | ||
| data-prev | ||
| aria-label="Previous achievement" | ||
| > | ||
| <svg class={styles.nav_icon} viewBox="0 0 24 24"> | ||
| <path d="M16 4L6 12L16 20Z"></path> | ||
| </svg> | ||
| </button> | ||
|
|
||
| <div class={styles.cards_viewport} data-viewport> | ||
| { | ||
| achievements.map((item, idx) => ( | ||
| <div | ||
| class={styles.slide_card} | ||
| data-slide | ||
| data-index={idx} | ||
| data-active={idx === 0 ? "true" : undefined} | ||
| role="group" | ||
| aria-roledescription="slide" | ||
| aria-label={`${item.title} - ${item.award}`} | ||
| > | ||
| <img | ||
| src={item.image} | ||
| alt={item.title} | ||
| class={styles.card_image} | ||
| loading={idx === 0 ? "eager" : "lazy"} | ||
| /> | ||
| {item.showOverlay !== false && ( | ||
| <div class={styles.card_overlay}> | ||
| <span class={styles.card_award}>{item.award}</span> | ||
| <span class={styles.card_title}>{item.title}</span> | ||
| </div> | ||
| )} | ||
| </div> | ||
| )) | ||
| } | ||
| </div> | ||
|
|
||
| <button | ||
| type="button" | ||
| class={styles.nav_button} | ||
| data-next | ||
| aria-label="Next achievement" | ||
| > | ||
| <svg class={styles.nav_icon} viewBox="0 0 24 24"> | ||
| <path d="M8 4L18 12L8 20Z"></path> | ||
| </svg> | ||
| </button> | ||
| </div> | ||
|
|
||
| <!-- Active Slide Details (Team list + Description) --> | ||
| <div class={styles.details_row} data-details-container> | ||
| <div class={styles.team_col}> | ||
| <h2 class={styles.team_name} data-team-name> | ||
| {achievements[0]?.teamName} | ||
| </h2> | ||
| <ol class={styles.member_list} data-member-list> | ||
| { | ||
| achievements[0]?.members.map((member) => ( | ||
| <li class={styles.member_item}>{member}</li> | ||
| )) | ||
| } | ||
| </ol> | ||
| </div> | ||
|
|
||
| <div class={styles.desc_col}> | ||
| <p class={styles.description_text} data-description> | ||
| {achievements[0]?.description} | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </section> | ||
|
|
||
| <!-- Data for dynamic client switching --> | ||
| <script | ||
| define:vars={{ | ||
| achievementsData: achievements, | ||
| memberItemClass: styles.member_item, | ||
| }} | ||
| > | ||
| function initLatestCarousel() { | ||
| const container = document.querySelector("[data-achievement-carousel]"); | ||
| if (!container) return; | ||
|
|
||
| const slides = container.querySelectorAll("[data-slide]"); | ||
| const prevBtn = container.querySelector("[data-prev]"); | ||
| const nextBtn = container.querySelector("[data-next]"); | ||
| const teamNameEl = document.querySelector("[data-team-name]"); | ||
| const memberListEl = document.querySelector("[data-member-list]"); | ||
| const descEl = document.querySelector("[data-description]"); | ||
|
|
||
| let currentIndex = 0; | ||
| const total = slides.length; | ||
| if (total <= 1) { | ||
| if (prevBtn) prevBtn.style.display = "none"; | ||
| if (nextBtn) nextBtn.style.display = "none"; | ||
| return; | ||
| } | ||
|
|
||
| function updateSlide(newIndex) { | ||
| currentIndex = (newIndex + total) % total; | ||
|
|
||
| slides.forEach((slide, idx) => { | ||
| if (idx === currentIndex) { | ||
| slide.dataset.active = "true"; | ||
| } else { | ||
| delete slide.dataset.active; | ||
| } | ||
| }); | ||
|
|
||
| const activeData = achievementsData[currentIndex]; | ||
| if (activeData) { | ||
| if (teamNameEl) teamNameEl.textContent = activeData.teamName; | ||
| if (descEl) descEl.textContent = activeData.description; | ||
| if (memberListEl) { | ||
| memberListEl.replaceChildren( | ||
| ...activeData.members.map((member) => { | ||
| const item = document.createElement("li"); | ||
| item.className = memberItemClass; | ||
| item.textContent = member; | ||
| return item; | ||
| }), | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| prevBtn?.addEventListener("click", () => updateSlide(currentIndex - 1)); | ||
| nextBtn?.addEventListener("click", () => updateSlide(currentIndex + 1)); | ||
|
|
||
| // Keyboard navigation | ||
| container.addEventListener("keydown", (e) => { | ||
| if (e.key === "ArrowLeft") updateSlide(currentIndex - 1); | ||
| if (e.key === "ArrowRight") updateSlide(currentIndex + 1); | ||
| }); | ||
| } | ||
|
|
||
| if (document.readyState === "loading") { | ||
| document.addEventListener("DOMContentLoaded", initLatestCarousel); | ||
| } else { | ||
| initLatestCarousel(); | ||
| } | ||
| </script> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is unused.