Skip to content

feat: add CardIcon component#50

Open
BIA3IA wants to merge 12 commits intomainfrom
bianca/card-icon
Open

feat: add CardIcon component#50
BIA3IA wants to merge 12 commits intomainfrom
bianca/card-icon

Conversation

@BIA3IA
Copy link
Copy Markdown
Contributor

@BIA3IA BIA3IA commented Mar 20, 2026

Closes #47

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 138068a8-8b03-4a51-9b37-43d1913b7c32

📥 Commits

Reviewing files that changed from the base of the PR and between c7c27d5 and 55b0546.

📒 Files selected for processing (2)
  • src/components/card-icon.tsx
  • src/components/gradient-icon.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/gradient-icon.tsx
  • src/components/card-icon.tsx

Walkthrough

Replaced lucide-react with react-icons; added GradientIcon and CardIcon components; expanded Home to render Hero plus three mapped card sections (schoolCards, materialCards, otherCards) using CardIcon; updated multiple components to use react-icons/fi and adjusted select class selectors.

Changes

Cohort / File(s) Summary
Dependency Migration
package.json
Removed lucide-react and added react-icons (dependency change only).
Home page & data
src/app/page.tsx
Replaced return <Hero /> with a <main> layout; added schoolCards, materialCards, otherCards arrays and dynamically render CardIcon components; hoverEffect enabled for school cards.
New UI components
src/components/card-icon.tsx, src/components/gradient-icon.tsx
Added CardIcon (anchor/div root by href, sizes sm
Icon library updates (components)
src/components/header.tsx, src/components/home/hero.tsx, src/components/theme-button.tsx
Replaced lucide-react imports/usages with react-icons/fi equivalents (Globe/Search/Navigation/UserPlus/Sun/Moon); one Hero button size/icon adjusted.
Icon typing & UI updates
src/components/ui/buttonWithIcon.tsx
Changed ButtonWithIcon prop type from LucideIcon to IconType (react-icons).
Select component adjustments
src/components/ui/select.tsx
Replaced chevron icons with FiChevronDown/FiChevronUp; updated Tailwind/Radix attribute selectors and CSS variable notations in class strings (data- placeholder/disabled/highlighted selectors and var() notations).

Possibly related PRs

  • feat: add Hero component #42 — Earlier Home changes that introduced a standalone Hero and initial page layout; directly related to the Home expansions and reuse of Hero in this PR.
🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Includes out-of-scope changes: migrated from lucide-react to react-icons across multiple files, modified Tailwind/Radix selectors in select.tsx, and changed button sizes, extending beyond the CardIcon component objective. Separate the icon library migration and component refactoring into distinct PRs to keep changes focused on CardIcon implementation as specified in issue #47.
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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add CardIcon component' directly aligns with the main change—adding a new CardIcon component exported from src/components/card-icon.tsx.
Linked Issues check ✅ Passed The PR successfully implements the CardIcon component from issue #47, rendering cards with prominent icons and supporting content, matching the visual design shown in the issue.

✏️ 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 added 5 commits March 24, 2026 21:41
…d variants; streamline media handling and hover effects. Update Hero component for improved heading structure.
…d props

- Introduced GradientIcon component for rendering icons with gradient effects.
- Updated CardIcon to use shared props for different card types, including size and description.
- Simplified media rendering logic for cards, separating basic and description card media.
- Enhanced styling and layout for better responsiveness and visual consistency.
@BIA3IA BIA3IA marked this pull request as ready for review March 26, 2026 11:26
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: 2

🧹 Nitpick comments (3)
src/components/gradient-icon.tsx (2)

53-57: Hardcoded mask/rect dimensions may not work for all icon sets.

The mask and rect are hardcoded to 24x24, which matches Feather icons (Fi*) with viewBox="0 0 24 24". However, other react-icons sets use different viewBox dimensions (e.g., Heroicons v2 uses 0 0 24 24 but Heroicons v1 uses 0 0 20 20).

Consider dynamically reading the icon's viewBox attribute to ensure compatibility if different icon sets are used in the future.

💡 Potential improvement to extract viewBox dimensions
 export function GradientIcon({ title, icon: Icon, className }: GradientIconProps) {
   const iconId = useId().replaceAll(":", "")
   const gradientId = `icon-gradient-${iconId}`
   const maskId = `icon-mask-${iconId}`
   const svg = Icon({ className, "aria-label": title }) as ReactElement<SVGProps<SVGSVGElement>>
   const children = svg.props.children
+  const viewBox = svg.props.viewBox ?? "0 0 24 24"
+  const [, , width, height] = viewBox.split(" ")

   return cloneElement(svg, {
     ...svg.props,
     stroke: undefined,
     fill: "none",
     children: (
       <>
         <defs>
           <linearGradient id={gradientId} x1="0%" x2="0%" y1="0%" y2="100%">
             <stop offset="0%" stopColor="var(--color-blue-secondary)" />
             <stop offset="100%" stopColor="var(--color-blue-primary)" />
           </linearGradient>
-          <mask id={maskId} maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
+          <mask id={maskId} maskUnits="userSpaceOnUse" x="0" y="0" width={width} height={height}>
             {maskChildren(children)}
           </mask>
         </defs>
-        <rect x="0" y="0" width="24" height="24" fill={`url(#${gradientId})`} mask={`url(#${maskId})`} />
+        <rect x="0" y="0" width={width} height={height} fill={`url(#${gradientId})`} mask={`url(#${maskId})`} />
       </>
     ),
   })
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/gradient-icon.tsx` around lines 53 - 57, The mask and rect
dimensions are hardcoded to 24x24; update the GradientIcon component to derive
dimensions from the icon's viewBox instead of fixed values: read the viewBox
string from the incoming svg/children (e.g., children.props?.viewBox or the
top-level <svg> element), parse the four numbers (minX, minY, width, height) and
use those values for the mask attributes and rect (x, y, width, height) rather
than 0/0/24/24; keep a sensible fallback (24,24) if viewBox is missing and
ensure existing symbols maskId, gradientId and maskChildren(children) are used
unchanged.

12-16: Use IconType from react-icons for consistency with buttonWithIcon.tsx.

GradientIconType (FunctionComponent<SVGProps<SVGSVGElement>>) and react-icons IconType ((props: IconBaseProps) => React.ReactNode) have different type signatures. While both work in practice due to compatible prop shapes and JSX returns, using IconType would align this component with buttonWithIcon.tsx and leverage react-icons' type definitions directly (react-icons ^5.6.0 is already a dependency).

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

In `@src/components/gradient-icon.tsx` around lines 12 - 16, Replace the custom
GradientIconType with react-icons' IconType to match buttonWithIcon.tsx and
reuse the library's types: update the exported GradientIconType declaration to
use IconType from 'react-icons', import IconType at the top, and keep
GradientIconProps (title, icon) but type icon as IconType instead of
FunctionComponent<SVGProps<SVGSVGElement>> so the component signature aligns
with react-icons' IconType.
src/components/card-icon.tsx (1)

74-74: Minor: Avoid passing href to non-anchor elements.

When Root is "div", passing href={href} results in href={undefined} on a div element. While harmless, it's cleaner to conditionally spread the prop.

♻️ Cleaner conditional prop spreading
-      <Root href={href} className="group/card relative flex h-full flex-col p-8 text-left">
+      <Root {...(href && { href })} className="group/card relative flex h-full flex-col p-8 text-left">
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/card-icon.tsx` at line 74, The Root element is receiving href
even when it renders as a non-anchor (e.g., "div"), producing unnecessary
href={undefined}; update the JSX where Root is used (the Root component) to only
spread href when appropriate — e.g., conditionally include {...(href && { href
})} or check the tag type (Root === "a") before passing href — so that href is
not passed to non-anchor elements; keep the existing className and props intact
while making this conditional spread.
🤖 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/app/page.tsx`:
- Around line 28-32: The card titles in the otherCards constant include
leading/trailing spaces; remove those extra spaces in the otherCards entries
(e.g., change "   Dispense   " to "Dispense") and handle any visual spacing via
styling on the CardIcon/Card or CardIcon component (add Tailwind/CSS
padding/margin in the CardIcon render or its parent) rather than embedding
whitespace in the data; also scan for any code that relies on those padded
strings and update it to use the trimmed titles or to apply padding via
className on CardIcon.

In `@src/components/home/hero.tsx`:
- Around line 26-29: Remove the nonexistent className="icon-lg" from the Button
and add explicit sizing on the FiNavigation icon similar to FiSearch;
specifically, update the Button usage (component Button, props variant="primary"
and size="lg") to drop className="icon-lg" and give the FiNavigation element an
explicit size class (e.g., the same h-5 w-5 used for FiSearch) so the SVG
renders at the intended size.

---

Nitpick comments:
In `@src/components/card-icon.tsx`:
- Line 74: The Root element is receiving href even when it renders as a
non-anchor (e.g., "div"), producing unnecessary href={undefined}; update the JSX
where Root is used (the Root component) to only spread href when appropriate —
e.g., conditionally include {...(href && { href })} or check the tag type (Root
=== "a") before passing href — so that href is not passed to non-anchor
elements; keep the existing className and props intact while making this
conditional spread.

In `@src/components/gradient-icon.tsx`:
- Around line 53-57: The mask and rect dimensions are hardcoded to 24x24; update
the GradientIcon component to derive dimensions from the icon's viewBox instead
of fixed values: read the viewBox string from the incoming svg/children (e.g.,
children.props?.viewBox or the top-level <svg> element), parse the four numbers
(minX, minY, width, height) and use those values for the mask attributes and
rect (x, y, width, height) rather than 0/0/24/24; keep a sensible fallback
(24,24) if viewBox is missing and ensure existing symbols maskId, gradientId and
maskChildren(children) are used unchanged.
- Around line 12-16: Replace the custom GradientIconType with react-icons'
IconType to match buttonWithIcon.tsx and reuse the library's types: update the
exported GradientIconType declaration to use IconType from 'react-icons', import
IconType at the top, and keep GradientIconProps (title, icon) but type icon as
IconType instead of FunctionComponent<SVGProps<SVGSVGElement>> so the component
signature aligns with react-icons' IconType.
🪄 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: 7df2307c-020a-4fc9-b853-2bf6b2864bf0

📥 Commits

Reviewing files that changed from the base of the PR and between ae1e184 and d982d58.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • package.json
  • src/app/page.tsx
  • src/components/card-icon.tsx
  • src/components/gradient-icon.tsx
  • src/components/header.tsx
  • src/components/home/hero.tsx
  • src/components/theme-button.tsx
  • src/components/ui/buttonWithIcon.tsx
  • src/components/ui/select.tsx

@BIA3IA BIA3IA requested a review from viganogabriele March 26, 2026 15:27
Copy link
Copy Markdown
Contributor

@toto04 toto04 left a comment

Choose a reason for hiding this comment

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

Ok fighissimo, togliere lucide penso sia ok, al massimo lo rimettiamo se si spacca qualcosa ahah
Ti ho lasciato un paio di commentini e poi possiamo approvare

@BIA3IA BIA3IA requested a review from toto04 March 31, 2026 07:55
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.

CardIcon

2 participants