-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add CardIcon component #50
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
23019ac
feat: add CardIcon component and new image assets
BIA3IA d861532
Refactor CardIcon component to support new SchoolCard and MaterialCar…
BIA3IA 530f126
feat: refactor CardIcon component to support gradient icons and share…
BIA3IA 2079dfb
feat: replace lucide-react icons with react-icons in various components
BIA3IA 90e23bb
Merge commit 'ae1e1847382841a5638f57dc6a590878f3097da6' into bianca/c…
BIA3IA d982d58
fix: correct className syntax in Select component for better styling
BIA3IA d9756fe
Update src/app/page.tsx
BIA3IA cb8dead
fix: remove unnecessary className from Button component in Hero
BIA3IA 5f07d48
refactor: restructure layout in Home component for improved readability
BIA3IA c7c27d5
fix: add dynamic padding classes to CardIcon component based on size …
BIA3IA ff20196
refactor: simplify GradientIcon component by removing unnecessary pro…
BIA3IA 55b0546
fix: formatting
BIA3IA 5104faf
refactor: split card-icon into one component per file
toto04 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,5 +1,61 @@ | ||
| import { FiBook, FiBookOpen, FiClipboard, FiFileText, FiPenTool, FiTriangle, FiUploadCloud } from "react-icons/fi" | ||
| import { CardIcon } from "@/components/card-icon" | ||
| import { Hero } from "@/components/home/hero" | ||
|
|
||
| const schoolCards = [ | ||
| { title: "Scuola di Architettura", icon: FiTriangle, size: "md" }, | ||
| { title: "Scuola di Design", icon: FiPenTool, size: "md" }, | ||
| { title: "Scuola di Ingegneria", icon: FiBookOpen, size: "md" }, | ||
| ] as const | ||
|
|
||
| const materialCards = [ | ||
| { | ||
| title: "Carica", | ||
| description: | ||
| "Hai appunti, dispense o temi d'esame che vuoi condividere? Caricali qui! Il tuo contributo è prezioso per aiutare migliaia di colleghi con materiale aggiornato!", | ||
| icon: FiUploadCloud, | ||
| size: "lg", | ||
| }, | ||
| { | ||
| title: "Visualizza", | ||
| description: | ||
| "Cerca ciò che ti serve per il tuo prossimo esame. Naviga tra i corsi di studio e trova facilmente appunti, esercizi e dispense condivisi da altri studenti come te.", | ||
| icon: FiBookOpen, | ||
| size: "lg", | ||
| }, | ||
| ] as const | ||
|
|
||
| const otherCards = [ | ||
| { title: "Dispense", icon: FiBook, size: "sm" }, | ||
| { title: "Appunti", icon: FiFileText, size: "sm" }, | ||
| { title: "Esami", icon: FiClipboard, size: "sm" }, | ||
| ] as const | ||
|
|
||
| export default function Home() { | ||
| return <Hero /> | ||
| return ( | ||
| <main className="w-full"> | ||
| <Hero /> | ||
| <div className="mx-auto flex max-w-6xl flex-col gap-12"> | ||
| <section> | ||
| <div className="grid gap-6 sm:grid-cols-2 md:grid-cols-3"> | ||
| {schoolCards.map((card) => ( | ||
| <CardIcon key={card.title} {...card} href="#" hoverEffect /> | ||
| ))} | ||
| </div> | ||
| </section> | ||
| <section className="flex max-w-4xl flex-col gap-6"> | ||
| <div className="grid gap-32 sm:grid-cols-2"> | ||
| {materialCards.map((card) => ( | ||
| <CardIcon key={card.title} {...card} href="#" /> | ||
| ))} | ||
| </div> | ||
| <div className="grid gap-16 sm:grid-cols-3"> | ||
| {otherCards.map((card) => ( | ||
| <CardIcon key={card.title} {...card} href="#" /> | ||
| ))} | ||
| </div> | ||
| </section> | ||
| </div> | ||
| </main> | ||
| ) | ||
| } | ||
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,7 @@ | ||
| import { GradientIcon, type GradientIconType } from "../gradient-icon" | ||
| import type { CardSize } from "./types" | ||
| import { getIconSizeClasses } from "./utils" | ||
|
|
||
| export function BasicCardMedia({ icon: Icon, size }: { icon: GradientIconType; size: CardSize }) { | ||
| return <GradientIcon icon={Icon} className={getIconSizeClasses(size)} /> | ||
| } |
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,12 @@ | ||
| import { cn } from "@/lib/utils" | ||
| import { GradientIcon, type GradientIconType } from "../gradient-icon" | ||
| import type { CardSize } from "./types" | ||
| import { getIconSizeClasses } from "./utils" | ||
|
|
||
| export function DescriptionCardMedia({ icon: Icon, size }: { icon: GradientIconType; size: CardSize }) { | ||
| return ( | ||
| <div className={cn("relative", getIconSizeClasses(size))}> | ||
| <GradientIcon icon={Icon} className="h-full w-full" /> | ||
| </div> | ||
| ) | ||
| } |
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,15 @@ | ||
| import { Shape } from "@/components/shapes" | ||
|
|
||
| export function CardHoverBackground() { | ||
| return ( | ||
| <div className="pointer-events-none absolute inset-0 z-0 overflow-hidden opacity-0 transition-opacity duration-300 group-hover/card:opacity-100"> | ||
| <Shape variant="big-teal" className="-top-16 -right-20 absolute h-40 w-40" /> | ||
| <Shape variant="big-teal" className="-bottom-21 -left-2 absolute h-70 w-70" /> | ||
| <div className="-top-36 -left-32 absolute h-168 w-2xl"> | ||
| <div className="-rotate-70 relative h-full w-full origin-center"> | ||
|
toto04 marked this conversation as resolved.
|
||
| <Shape variant="looper" className="absolute inset-0 h-full w-full object-contain" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
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,61 @@ | ||
| import { Glass } from "@/components/glass" | ||
| import { cn } from "@/lib/utils" | ||
| import { BasicCardMedia } from "./basic-card-media" | ||
| import { DescriptionCardMedia } from "./description-card-media" | ||
| import { CardHoverBackground } from "./hover-background" | ||
| import type { CardIconProps } from "./types" | ||
| import { getCardPaddingClasses, getContentGapClasses } from "./utils" | ||
|
|
||
| export function CardIcon(props: CardIconProps) { | ||
| const { title, icon, size = "md", href, hoverEffect = false, className } = props | ||
| const description = "description" in props ? props.description : undefined | ||
| const Root = href ? "a" : "div" | ||
| const isDescriptionCard = Boolean(description) | ||
|
|
||
| return ( | ||
| <Glass | ||
| className={cn( | ||
| "w-full overflow-hidden rounded-rectangles border-white/50 bg-background-blur p-0 text-card-foreground", | ||
| className | ||
| )} | ||
| > | ||
| <Root | ||
| href={href} | ||
| className={cn( | ||
| "group/card relative flex h-full flex-col text-left", | ||
| getCardPaddingClasses(size, isDescriptionCard) | ||
| )} | ||
| > | ||
| {hoverEffect && <CardHoverBackground />} | ||
|
|
||
| <div | ||
| className={cn( | ||
| "relative z-10 flex h-full flex-1 flex-col", | ||
| getContentGapClasses(size), | ||
| isDescriptionCard ? "justify-between" : "items-center justify-center text-center" | ||
| )} | ||
| > | ||
| <div className="flex justify-center"> | ||
| {isDescriptionCard ? ( | ||
| <DescriptionCardMedia icon={icon} size={size} /> | ||
| ) : ( | ||
| <BasicCardMedia icon={icon} size={size} /> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className={cn("flex flex-col", isDescriptionCard ? "gap-2 text-left" : "items-center text-center")}> | ||
| <h3 | ||
| className={cn( | ||
| "typo-headline-medium bg-linear-to-b from-blue-secondary to-blue-primary bg-clip-text text-transparent", | ||
| isDescriptionCard ? "text-left" : "text-center" | ||
| )} | ||
| > | ||
| {title} | ||
| </h3> | ||
| {description && <p className="typo-body-medium max-w-sm text-left text-text-primary">{description}</p>} | ||
| </div> | ||
| </div> | ||
| </Root> | ||
| </Glass> | ||
| ) | ||
| } |
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,18 @@ | ||
| import type { GradientIconType } from "@/components/gradient-icon" | ||
|
|
||
| export type CardSize = "sm" | "md" | "lg" | ||
|
|
||
| export type SharedCardProps = { | ||
| title: string | ||
| icon: GradientIconType | ||
| size?: CardSize | ||
| href?: string | ||
| hoverEffect?: boolean | ||
| className?: string | ||
| } | ||
|
|
||
| export type CardWithDescriptionProps = SharedCardProps & { | ||
| description: string | ||
| } | ||
|
|
||
| export type CardIconProps = SharedCardProps | CardWithDescriptionProps |
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,17 @@ | ||
| import type { CardSize } from "./types" | ||
|
|
||
| export function getIconSizeClasses(size: CardSize) { | ||
| if (size === "sm") return "h-14 w-14" | ||
| if (size === "lg") return "h-44 w-44" | ||
| return "h-32 w-32" | ||
| } | ||
|
|
||
| export function getCardPaddingClasses(size: CardSize, hasDescription: boolean) { | ||
| if (!hasDescription && size === "sm") return "px-8 py-4" | ||
| return "p-8" | ||
| } | ||
|
|
||
| export function getContentGapClasses(size: CardSize) { | ||
| if (size === "sm") return "gap-2" | ||
| return "gap-6" | ||
| } |
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,29 @@ | ||
| import { type FunctionComponent, type SVGProps, useId } from "react" | ||
|
|
||
| export type GradientIconType = FunctionComponent<SVGProps<SVGSVGElement>> | ||
|
|
||
| type GradientIconProps = { | ||
| icon: GradientIconType | ||
| className: string | ||
| } | ||
|
|
||
| export function GradientIcon({ icon: Icon, className }: GradientIconProps) { | ||
| const iconId = useId().replaceAll(":", "") | ||
| const gradientId = `icon-gradient-${iconId}` | ||
| const maskId = `icon-mask-${iconId}` | ||
|
|
||
| return ( | ||
| <svg className={className} viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> | ||
| <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="16" height="16"> | ||
| <Icon className={className} stroke="white" fill="none" /> | ||
| </mask> | ||
| </defs> | ||
| <rect x="0" y="0" width="16" height="16" fill={`url(#${gradientId})`} mask={`url(#${maskId})`} /> | ||
| </svg> | ||
| ) | ||
| } |
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
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
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 |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| "use client" | ||
| import { MoonIcon, SunIcon } from "lucide-react" | ||
| import { useTheme } from "next-themes" | ||
| import { FiMoon, FiSun } from "react-icons/fi" | ||
|
|
||
| export function ThemeButton() { | ||
| const { resolvedTheme, setTheme } = useTheme() | ||
| return ( | ||
| // TODO: enable when dark mode design is ready | ||
| <button type="button" disabled={true} onClick={() => setTheme(resolvedTheme === "light" ? "dark" : "light")}> | ||
| <SunIcon className="block h-6 w-6 dark:hidden" /> | ||
| <MoonIcon className="hidden h-6 w-6 dark:block" /> | ||
| <FiSun className="block h-6 w-6 dark:hidden" /> | ||
| <FiMoon className="hidden h-6 w-6 dark:block" /> | ||
| </button> | ||
| ) | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.