feat: Update card icon components for responsive design - #102
Conversation
WalkthroughThe card icon component library is refactored to support responsive sizing via breakpoint-aware configuration. The Changes
Sequence DiagramsequenceDiagram
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
Possibly Related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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 | 🟡 MinorInconsistent 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, newResponsiveCardSizeConfig/ResponsiveCardSize, and the simplification todescription?: stringalign cleanly with the existing component logic (which already guards onBoolean(description)) and with the consumer usage inmaterials.tsx.One tiny note:
CardBreakpointandCardSizeshare 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 thefilter(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
📒 Files selected for processing (7)
src/components/card-icon/basic-card-media.tsxsrc/components/card-icon/classes.tssrc/components/card-icon/description-card-media.tsxsrc/components/card-icon/index.tsxsrc/components/card-icon/types.tssrc/components/card-icon/utils.tssrc/components/home/materials.tsx
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.