Skip to content

feat: Update card icon components for responsive design - #102

Merged
toto04 merged 4 commits into
mainfrom
bianca/materials
Apr 22, 2026
Merged

feat: Update card icon components for responsive design#102
toto04 merged 4 commits into
mainfrom
bianca/materials

Conversation

@BIA3IA

@BIA3IA BIA3IA commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Enhance card icon components to support responsive sizes and improve layout for mobile devices. Adjustments include new size definitions and layout optimizations for better usability across different screen sizes.

@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The card icon component library is refactored to support responsive sizing via breakpoint-aware configuration. The CardSize type is expanded from three to four values, new responsive types enable breakpoint-based overrides, a classes.ts module centralizes size class mappings, and utility functions resolve classes across breakpoints instead of using fixed logic.

Changes

Cohort / File(s) Summary
Type System Expansion
src/components/card-icon/types.ts
Added xs to CardSize enum. Introduced CardBreakpoint, SizeClassMap, ResponsiveCardSizeConfig, and ResponsiveCardSize types to enable responsive sizing configs with base and optional breakpoint overrides. Simplified CardIconProps to single interface with optional description field.
Class Mappings & Utilities
src/components/card-icon/classes.ts, src/components/card-icon/utils.ts
New classes.ts exports size class mappings (ICON_SIZE_CLASSES, CARD_PADDING_*, CONTENT_GAP_CLASSES, TITLE_SIZE_CLASSES). Updated getIconSizeClasses, getCardPaddingClasses, and getContentGapClasses to accept ResponsiveCardSize. Added getTitleSizeClasses function to resolve title sizing classes across breakpoints.
Component Props Updates
src/components/card-icon/basic-card-media.tsx, src/components/card-icon/description-card-media.tsx, src/components/card-icon/index.tsx
Updated BasicCardMedia and DescriptionCardMedia to accept ResponsiveCardSize instead of CardSize. Modified CardIcon to apply dynamic title sizing via getTitleSizeClasses(size) instead of fixed "typo-headline-medium" class.
Consumer Implementation
src/components/home/materials.tsx
Updated Materials component with adjusted grid spacing, refined featured cards grid layout, changed quick-links grid to grid-cols-3 base with responsive gap, shifted header alignment from left-aligned xl behavior to centered sm behavior, and updated quick links data to use responsive size config ({ base: "xs", sm: "sm" }).

Sequence Diagram

sequenceDiagram
    participant Component as CardIcon Component
    participant Utility as Utility Function<br/>(getIconSizeClasses)
    participant ClassMap as Class Mappings<br/>(ICON_SIZE_CLASSES)
    participant DOM as Rendered Output

    Component->>Utility: ResponsiveCardSize<br/>(plain or config)
    Utility->>Utility: Resolve breakpoints<br/>(base, sm, md, lg)
    Utility->>ClassMap: Lookup classes<br/>for each breakpoint
    ClassMap-->>Utility: Return CSS classes
    Utility->>Utility: Prefix & concatenate<br/>classes by breakpoint
    Utility-->>Component: Responsive class string
    Component->>DOM: Apply classes<br/>with breakpoint variants
Loading

Possibly Related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating card icon components to support responsive design, which aligns with the primary objectives of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@BIA3IA BIA3IA changed the title Update card icon components for responsive design feat: Update card icon components for responsive design Apr 22, 2026
@BIA3IA
BIA3IA marked this pull request as ready for review April 22, 2026 20:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
src/components/home/materials.tsx (1)

52-64: ⚠️ Potential issue | 🟡 Minor

Inconsistent Italian accents in user-facing copy.

The mobile paragraph correctly uses "più" (line 58), but the desktop paragraph and the button say "piu" / "cio" without accents (lines 53, 55, 62). Please normalize all occurrences to "più" and "ciò" for consistency and proper Italian orthography.

✏️ Proposed fix
-        <p className="typo-body-large hidden max-w-lg sm:block">
-          Il piu grande archivio didattico creato dagli studenti per gli studenti del Politecnico di Milano. Cerca tra
-          migliaia di appunti, dispense, temi d'esame e molto altro. Carica i tuoi file per far crescere la community e
-          trova tutto cio che ti serve, organizzato per corso di studi.
-        </p>
+        <p className="typo-body-large hidden max-w-lg sm:block">
+          Il più grande archivio didattico creato dagli studenti per gli studenti del Politecnico di Milano. Cerca tra
+          migliaia di appunti, dispense, temi d'esame e molto altro. Carica i tuoi file per far crescere la community e
+          trova tutto ciò che ti serve, organizzato per corso di studi.
+        </p>
@@
         <Button variant="primary" size="lg" className="w-fit">
-          Scopri di piu
+          Scopri di più
           <FiArrowUpRight />
         </Button>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/home/materials.tsx` around lines 52 - 64, Update the
user-facing Italian strings in this component to use proper accents: in the
desktop paragraph text (the <p> with className "typo-body-large hidden max-w-lg
sm:block") change "piu" to "più" and "cio" to "ciò" so the sentence reads "Il
più grande... trova tutto ciò che ti serve"; also update the Button label (the
Button with variant="primary" size="lg") from "Scopri di piu" to "Scopri di
più". Ensure only the string literals are modified; do not change element
structure or classes.
🧹 Nitpick comments (2)
src/components/card-icon/types.ts (1)

3-28: LGTM — clean, well-typed responsive sizing model.

The expanded CardSize, new ResponsiveCardSizeConfig/ResponsiveCardSize, and the simplification to description?: string align cleanly with the existing component logic (which already guards on Boolean(description)) and with the consumer usage in materials.tsx.

One tiny note: CardBreakpoint and CardSize share the "sm" | "md" | "lg" tokens but semantically differ (breakpoint vs. size). Consider a short doc comment on each to avoid confusion for future readers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/card-icon/types.ts` around lines 3 - 28, Add short doc
comments above the CardSize and CardBreakpoint type aliases to clarify their
semantic difference (CardSize represents visual size tokens "xs" | "sm" | "md" |
"lg", while CardBreakpoint represents responsive breakpoints "base" | "sm" |
"md" | "lg"); update nearby types (ResponsiveCardSizeConfig and
ResponsiveCardSize) if needed to reference these comments so future readers
won't confuse size tokens with breakpoint tokens.
src/components/card-icon/utils.ts (1)

20-44: LGTM — responsive class resolver is correct and mobile-first aligned.

Mobile-first prefix logic (empty base, sm: / md: / lg: overrides) and the filter(Boolean) for skipped breakpoints look right. Minor: when a breakpoint override maps to the same class as a lower breakpoint (e.g., { base: "md", lg: "md" }"p-8 lg:p-8"), you emit redundant tokens. Could de-dupe by tracking the last emitted value, but not important as long as it stays internal.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/card-icon/utils.ts` around lines 20 - 44, The responsive
resolver may emit duplicate tokens for repeated sizes (e.g., prefixClasses
output like "p-8 lg:p-8"); update resolveResponsiveClasses to de-duplicate
consecutive emitted class groups by tracking the last non-empty emitted string
and only push a new prefixed group when it differs from the last; use the
existing BREAKPOINTS and BREAKPOINT_PREFIX lookup and reuse prefixClasses(name,
classes) to build the group, comparing against the last emitted value before
adding, and keep existing behavior when size is a string (classesBySize[size]).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/card-icon/classes.ts`:
- Around line 17-22: The CARD_PADDING_WITH_DESCRIPTION map currently uses "p-8"
for all breakpoints; decide whether that's intentional or a bug and implement
the appropriate fix: if it's intentional, update getCardPaddingClasses to detect
when all SizeClassMap entries are identical and emit a single class (e.g.,
"p-8") instead of repeating "p-8 sm:p-8 md:p-8 lg:p-8"; if it's not intentional,
correct CARD_PADDING_WITH_DESCRIPTION to the proper per-size values (matching
design spec or aligning with CARD_PADDING_WITHOUT_DESCRIPTION) so
getCardPaddingClasses continues to output distinct responsive classes. Reference
CARD_PADDING_WITH_DESCRIPTION and getCardPaddingClasses to locate the change.

---

Outside diff comments:
In `@src/components/home/materials.tsx`:
- Around line 52-64: Update the user-facing Italian strings in this component to
use proper accents: in the desktop paragraph text (the <p> with className
"typo-body-large hidden max-w-lg sm:block") change "piu" to "più" and "cio" to
"ciò" so the sentence reads "Il più grande... trova tutto ciò che ti serve";
also update the Button label (the Button with variant="primary" size="lg") from
"Scopri di piu" to "Scopri di più". Ensure only the string literals are
modified; do not change element structure or classes.

---

Nitpick comments:
In `@src/components/card-icon/types.ts`:
- Around line 3-28: Add short doc comments above the CardSize and CardBreakpoint
type aliases to clarify their semantic difference (CardSize represents visual
size tokens "xs" | "sm" | "md" | "lg", while CardBreakpoint represents
responsive breakpoints "base" | "sm" | "md" | "lg"); update nearby types
(ResponsiveCardSizeConfig and ResponsiveCardSize) if needed to reference these
comments so future readers won't confuse size tokens with breakpoint tokens.

In `@src/components/card-icon/utils.ts`:
- Around line 20-44: The responsive resolver may emit duplicate tokens for
repeated sizes (e.g., prefixClasses output like "p-8 lg:p-8"); update
resolveResponsiveClasses to de-duplicate consecutive emitted class groups by
tracking the last non-empty emitted string and only push a new prefixed group
when it differs from the last; use the existing BREAKPOINTS and
BREAKPOINT_PREFIX lookup and reuse prefixClasses(name, classes) to build the
group, comparing against the last emitted value before adding, and keep existing
behavior when size is a string (classesBySize[size]).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 965c177f-fb62-4046-a950-d3b73a3923ed

📥 Commits

Reviewing files that changed from the base of the PR and between 998b219 and 56c175e.

📒 Files selected for processing (7)
  • src/components/card-icon/basic-card-media.tsx
  • src/components/card-icon/classes.ts
  • src/components/card-icon/description-card-media.tsx
  • src/components/card-icon/index.tsx
  • src/components/card-icon/types.ts
  • src/components/card-icon/utils.ts
  • src/components/home/materials.tsx

Comment thread src/components/card-icon/classes.ts
@toto04
toto04 merged commit 3665328 into main Apr 22, 2026
2 checks passed
@toto04
toto04 deleted the bianca/materials branch April 22, 2026 21:07
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