Skip to content

Leaderboard image optimizations - Media type Badge#1751

Merged
prxt6529 merged 18 commits intomainfrom
leaderboard-image-optimizations
Jan 19, 2026
Merged

Leaderboard image optimizations - Media type Badge#1751
prxt6529 merged 18 commits intomainfrom
leaderboard-image-optimizations

Conversation

@prxt6529
Copy link
Copy Markdown
Collaborator

@prxt6529 prxt6529 commented Jan 19, 2026

Summary by CodeRabbit

  • New Features

    • Media type badges added across the app to indicate image, video, or interactive files.
    • Size options added for drop position and leaderboard displays.
  • Improvements

    • Default images now use higher-resolution scaling for clearer display.
    • File upload accepts more media formats (including GIF and interactive models).
    • Tooltip and keyboard/scroll interaction for media badges improved.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Adds a centralized submission media-type system and helper re-exports; introduces MediaTypeBadge UI and a controlled tooltip hook; bumps default image scale to AUTOx1080; centralizes file-upload MIME lists and validation; wires badges into multiple UI components and expands several component props.

Changes

Cohort / File(s) Summary
Centralized media constants
constants/submission-media.constants.ts, helpers/file.helpers.ts
New module defining submission media types, MIME lists, category styles, and getSubmissionMediaTypeInfo; helpers/file.helpers.ts re-exports getMediaTypeInfo, MediaCategory, and MediaTypeInfo.
MediaTypeBadge + tooltip hook
components/drops/media/MediaTypeBadge.tsx, hooks/useControlledTooltip.ts
New MediaTypeBadge component that derives label/styles from mimeType and renders an SVG + Tooltip; new useControlledTooltip hook to manage controlled open/close, keyboard handlers, and scroll-close behavior.
Image scale bump
components/drops/view/item/content/media/MediaDisplay.tsx, components/drops/view/item/content/media/MediaDisplayImage.tsx, __tests__/components/drops/view/item/content/media/MediaDisplayImage.test.tsx
Default imageScale changed from ImageScale.AUTOx600ImageScale.AUTOx1080; minor import/class ordering tweaks and FallbackImage optimize={false} added; tests updated.
File validation & upload
components/waves/memes/file-upload/utils/fileValidation.ts, components/waves/memes/file-upload/utils/constants.ts, components/waves/memes/file-upload/components/UploadArea.tsx, components/waves/memes/MemesArtSubmissionFile.tsx
Replaced local format/accept constants with centralized SUBMISSION_* lists; validation now uses SUBMISSION_IMAGE_MIME_TYPES / SUBMISSION_INTERACTIVE_MIME_TYPES; inputs now use SUBMISSION_FILE_INPUT_ACCEPT and UI uses SUBMISSION_UI_FORMAT_CATEGORIES.
Badge integration across UI
components/home/carousel/CarouselActiveItemDetails.tsx, components/home/next-mint-leading/LeadingCard.tsx, components/home/next-mint-leading/NextMintCard.tsx, components/memes/drops/MemesLeaderboardDrop.tsx, components/waves/small-leaderboard/WaveSmallLeaderboardItemContent.tsx
Inserted MediaTypeBadge inline with titles/headers and in small leaderboard items (uses first media mime_type, typically size="sm").
Wave drop meta & props
components/waves/drop/WaveDropMetaRow.tsx, components/waves/drop/MemesSingleWaveDropInfoPanel.tsx, components/waves/drop/SingleWaveDropPosition.tsx
WaveDropMetaRow now accepts optional mimeType?: string and renders MediaTypeBadge; MemesSingleWaveDropInfoPanel passes mimeType; SingleWaveDropPosition adds `size?: "sm"
Leaderboard item API expansion
components/waves/leaderboard/gallery/WaveLeaderboardGalleryItem.tsx
WaveLeaderboardGalleryItemProps extended with onDropClick, artFocused?, activeSort?, and animationKey?; component updated to accept/use these props for click routing and rendering/animation.
TheMemes season state refactor
components/the-memes/TheMemes.tsx
Consolidated seasonId state (replaced initialSeasonId/selectedSeason), added handleSeasonChange, switched API/URL usage and effects to seasonId.
Removed local constants
components/waves/memes/file-upload/utils/constants.ts
Removed UI_FORMAT_CATEGORIES and FILE_INPUT_ACCEPT exports in favor of centralized submission constants.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant MediaBadge as MediaTypeBadge
  participant Helper as getMediaTypeInfo
  participant TooltipHook as useControlledTooltip
  participant DOM

  Client->>MediaBadge: render(mimeType, dropId, size)
  MediaBadge->>Helper: getMediaTypeInfo(mimeType)
  Helper-->>MediaBadge: category, label, styles
  MediaBadge->>TooltipHook: initialize triggerProps & isOpen
  Client->>MediaBadge: user hover / focus / key
  MediaBadge->>TooltipHook: triggerProps handlers (onMouseEnter/onKeyDown)
  TooltipHook-->>MediaBadge: setIsOpen(true)
  MediaBadge->>DOM: render Tooltip bound to tooltipId
  DOM->>TooltipHook: scroll event
  TooltipHook-->>MediaBadge: setIsOpen(false)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • #1592 — related interactive/external HTML media support and submission media handling.
  • #1635 — modifies WaveLeaderboardGalleryItem.tsx; overlaps with props/layout changes here.
  • #1695 — updates file-upload constants and accepted MIME lists; directly related to centralized constants changes.

Suggested reviewers

  • ragnep
  • simo6529

Poem

🐰
I nibbled through mime lists, neat and light,
A badge for image, video, interactive bright.
Tooltips that hush when the wind scrolls by,
Scaled pictures taller, now touching the sky.
Hop, click, and behold each media's sprite ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: implementing media type badge UI components and updating image scale optimization defaults from AUTOx600 to AUTOx1080 throughout the leaderboard.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
components/waves/memes/file-upload/utils/fileValidation.ts (1)

31-45: Include GLTF in the user-facing error message.

At Line 44, .gltf uploads are allowed but the message only mentions GLB. This can confuse users who select GLTF files.

🔧 Suggested fix
-      error: `File type not supported. Please upload PNG, JPG, GIF, video, or GLB files.`,
+      error: `File type not supported. Please upload PNG, JPG, GIF, video, or GLB/GLTF files.`,
components/waves/leaderboard/gallery/WaveLeaderboardGalleryItem.tsx (1)

152-160: Unsafe non-null assertions mixed with optional chaining.

Lines 154 and 156 use ! after optional chaining (drop.parts[0]?.media[0]!), which is inconsistent and potentially unsafe. If parts[0] exists but media[0] is undefined, the code will throw.

🐛 Proposed fix with proper null handling
-            <MediaDisplay
-              media_mime_type={
-                drop.parts[0]?.media[0]!.mime_type || "image/jpeg"
-              }
-              media_url={drop.parts[0]?.media[0]!.url!}
+            <MediaDisplay
+              media_mime_type={
+                drop.parts[0]?.media[0]?.mime_type ?? "image/jpeg"
+              }
+              media_url={drop.parts[0]?.media[0]?.url ?? ""}

Alternatively, extract the media access earlier and guard:

const primaryMedia = drop.parts[0]?.media[0];
// Then use primaryMedia?.mime_type and primaryMedia?.url with proper fallbacks
🧹 Nitpick comments (1)
constants/submission-media.constants.ts (1)

36-37: Consider deriving SUBMISSION_FILE_INPUT_ACCEPT from SUBMISSION_MEDIA_TYPES.

The accept string is hardcoded and duplicates information already in SUBMISSION_MEDIA_TYPES. If you add a new media type to the array, this string won't update automatically.

♻️ Suggested refactor
-export const SUBMISSION_FILE_INPUT_ACCEPT =
-  "image/png,image/jpeg,image/jpg,image/gif,video/mp4,video/quicktime,.mov,model/gltf-binary,model/gltf+json,application/octet-stream,.glb,.gltf";
+const FILE_EXTENSIONS = [".mov", ".glb", ".gltf"];
+export const SUBMISSION_FILE_INPUT_ACCEPT = [
+  ...SUBMISSION_MEDIA_MIME_TYPES,
+  "application/octet-stream",
+  ...FILE_EXTENSIONS,
+].join(",");

Signed-off-by: prxt6529 <prxt@6529.io>
@prxt6529 prxt6529 changed the title Leaderboard image optimizations Leaderboard image optimizations - Media type Badge Jan 19, 2026
Signed-off-by: prxt6529 <prxt@6529.io>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@components/home/next-mint-leading/NextMintCard.tsx`:
- Around line 84-96: The title Link inside the flex row (in NextMintCard.tsx,
adjacent to MediaTypeBadge) can overflow because flex children need min-w-0 to
allow line-clamp; update the flex container/Link so the clamped title can shrink
by adding the CSS utility class min-w-0 (and optionally flex-1) to the element
that wraps or is the Link (the element with className "tw-m-0 ...
group-hover:tw-text-white/80") so long titles respect line-clamp and don’t
overflow.
♻️ Duplicate comments (1)
components/home/next-mint-leading/LeadingCard.tsx (1)

88-100: Same flex-row line-clamp concern as NextMintCard.

🧹 Nitpick comments (2)
components/waves/memes/MemesArtSubmissionFile.tsx (1)

40-48: Update component documentation to reflect supported file types.

The file input now accepts additional formats via SUBMISSION_FILE_INPUT_ACCEPT (GIF images and 3D models like GLTF/GLB), but the JSDoc comment on line 44 still states only "images (PNG, JPG) and videos".

Consider updating the documentation to accurately reflect all supported formats.

📝 Suggested documentation update
 /**
  * Memes Art Submission File Component
  *
  * Handles uploading, previewing, and validating artwork files for meme submissions.
- * Supports images (PNG, JPG) and videos with browser compatibility detection.
+ * Supports images (PNG, JPG, GIF), videos (MP4, MOV), and 3D models (GLTF, GLB) 
+ * with browser compatibility detection.
  *
  * This version uses Blob URLs (createObjectURL) to preview any newly selected file,
  * which satisfies a CSP requiring 'blob:' rather than 'data:' for media.
  */

Also applies to: 306-306

components/memes/drops/MemesLeaderboardDrop.tsx (1)

3-3: Guard the badge when there’s no media.

Currently the badge renders even if artworkMedia is undefined, which can show a type indicator alongside a card with no media. Consider rendering only when media exists (as in WaveSmallLeaderboardItemContent).

♻️ Suggested tweak
-                  <div className="tw-flex tw-items-center tw-gap-2">
-                    <MediaTypeBadge
-                      mimeType={artworkMedia?.mime_type}
-                      dropId={drop.id}
-                      size="sm"
-                    />
-                    <MemesLeaderboardDropHeader title={title} />
-                  </div>
+                  <div className="tw-flex tw-items-center tw-gap-2">
+                    {artworkMedia && (
+                      <MediaTypeBadge
+                        mimeType={artworkMedia.mime_type}
+                        dropId={drop.id}
+                        size="sm"
+                      />
+                    )}
+                    <MemesLeaderboardDropHeader title={title} />
+                  </div>

Also applies to: 102-109

Comment thread components/home/next-mint-leading/NextMintCard.tsx Outdated
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@components/drops/media/MediaTypeBadge.tsx`:
- Around line 45-77: The badge never opens because the Tooltip is controlled by
isOpen/setIsOpen but the badge div lacks interaction handlers and keyboard
accessibility; update the badge root (the div using data-tooltip-id/
data-tooltip-content and classes like SIZE_CLASSES[size] and
ICON_SIZE_CLASSES[size]) to add tabIndex={0}, aria-label={mediaInfo.label},
onMouseEnter={() => setIsOpen(true)}, onMouseLeave={() => setIsOpen(false)},
onFocus={() => setIsOpen(true)}, onBlur={() => setIsOpen(false)} and an
onKeyDown handler that opens the tooltip on Enter/Space and closes on Escape
using setIsOpen; keep using tooltipId and useTooltipCloseOnScroll as-is so
scrolling still closes the tooltip.

Comment thread components/drops/media/MediaTypeBadge.tsx
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
Signed-off-by: prxt6529 <prxt@6529.io>
@sonarqubecloud
Copy link
Copy Markdown

@prxt6529 prxt6529 merged commit 04cde34 into main Jan 19, 2026
7 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants