-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Update card icon components for responsive design #102
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
4 commits
Select commit
Hold shift + click to select a range
eff95a8
refactor: restructure Hero component layout to follow figma design
BIA3IA 653652d
feat: update card icon components to use responsive sizes and improve…
BIA3IA 417e7fb
feat: add responsive size classes and utility functions for CardIcon …
BIA3IA 56c175e
fix: adjust padding in Materials component section for consistency
BIA3IA 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { GradientIcon, type GradientIconType } from "../gradient-icon" | ||
| import type { CardSize } from "./types" | ||
| import type { ResponsiveCardSize } from "./types" | ||
| import { getIconSizeClasses } from "./utils" | ||
|
|
||
| export function BasicCardMedia({ icon: Icon, size }: { icon: GradientIconType; size: CardSize }) { | ||
| export function BasicCardMedia({ icon: Icon, size }: { icon: GradientIconType; size: ResponsiveCardSize }) { | ||
| 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,36 @@ | ||
| import type { SizeClassMap } from "./types" | ||
|
|
||
| export const ICON_SIZE_CLASSES: SizeClassMap = { | ||
| xs: "h-10 w-10", | ||
| sm: "h-14 w-14", | ||
| md: "h-32 w-32", | ||
| lg: "h-44 w-44", | ||
| } | ||
|
|
||
| export const CARD_PADDING_WITHOUT_DESCRIPTION: SizeClassMap = { | ||
| xs: "p-3", | ||
| sm: "px-8 py-4", | ||
| md: "p-8", | ||
| lg: "p-8", | ||
| } | ||
|
|
||
| export const CARD_PADDING_WITH_DESCRIPTION: SizeClassMap = { | ||
| xs: "p-8", | ||
| sm: "p-8", | ||
| md: "p-8", | ||
| lg: "p-8", | ||
| } | ||
|
|
||
| export const CONTENT_GAP_CLASSES: SizeClassMap = { | ||
| xs: "gap-2", | ||
| sm: "gap-2", | ||
| md: "gap-6", | ||
| lg: "gap-6", | ||
| } | ||
|
|
||
| export const TITLE_SIZE_CLASSES: SizeClassMap = { | ||
| xs: "typo-label-large", | ||
| sm: "typo-headline-medium", | ||
| md: "typo-headline-medium", | ||
| lg: "typo-headline-medium", | ||
| } | ||
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,18 +1,28 @@ | ||
| import type { GradientIconType } from "@/components/gradient-icon" | ||
|
|
||
| export type CardSize = "sm" | "md" | "lg" | ||
| export type CardSize = "xs" | "sm" | "md" | "lg" | ||
| export type CardBreakpoint = "base" | "sm" | "md" | "lg" | ||
|
|
||
| export type SizeClassMap = Record<CardSize, string> | ||
|
|
||
| export type ResponsiveCardSizeConfig = { | ||
| base: CardSize | ||
| sm?: CardSize | ||
| md?: CardSize | ||
| lg?: CardSize | ||
| } | ||
|
|
||
| export type ResponsiveCardSize = CardSize | ResponsiveCardSizeConfig | ||
|
|
||
| export type SharedCardProps = { | ||
| title: string | ||
| icon: GradientIconType | ||
| size?: CardSize | ||
| size?: ResponsiveCardSize | ||
| href?: string | ||
| hoverEffect?: boolean | ||
| className?: string | ||
| } | ||
|
|
||
| export type CardWithDescriptionProps = SharedCardProps & { | ||
| description: string | ||
| export type CardIconProps = 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 |
|---|---|---|
| @@ -1,17 +1,63 @@ | ||
| import type { CardSize } from "./types" | ||
| import { | ||
| CARD_PADDING_WITH_DESCRIPTION, | ||
| CARD_PADDING_WITHOUT_DESCRIPTION, | ||
| CONTENT_GAP_CLASSES, | ||
| ICON_SIZE_CLASSES, | ||
| TITLE_SIZE_CLASSES, | ||
| } from "./classes" | ||
|
|
||
| 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" | ||
| import type { CardBreakpoint, ResponsiveCardSize, SizeClassMap } from "./types" | ||
|
|
||
| const BREAKPOINTS: CardBreakpoint[] = ["base", "sm", "md", "lg"] | ||
|
|
||
| const BREAKPOINT_PREFIX: Record<CardBreakpoint, string> = { | ||
| base: "", | ||
| sm: "sm:", | ||
| md: "md:", | ||
| lg: "lg:", | ||
| } | ||
|
|
||
| function prefixClasses(prefix: string, value: string): string { | ||
| return value | ||
| .split(" ") | ||
| .filter(Boolean) | ||
| .map((token) => `${prefix}${token}`) | ||
| .join(" ") | ||
| } | ||
|
|
||
| function resolveResponsiveClasses(size: ResponsiveCardSize, classesBySize: SizeClassMap): string { | ||
| if (typeof size === "string") { | ||
| return classesBySize[size] | ||
| } | ||
|
|
||
| return BREAKPOINTS.map((breakpoint) => { | ||
| const currentSize = size[breakpoint] | ||
|
|
||
| if (!currentSize) { | ||
| return "" | ||
| } | ||
|
|
||
| return prefixClasses(BREAKPOINT_PREFIX[breakpoint], classesBySize[currentSize]) | ||
| }) | ||
| .filter(Boolean) | ||
| .join(" ") | ||
| } | ||
|
|
||
| export function getIconSizeClasses(size: ResponsiveCardSize) { | ||
| return resolveResponsiveClasses(size, ICON_SIZE_CLASSES) | ||
| } | ||
|
|
||
| export function getCardPaddingClasses(size: ResponsiveCardSize, hasDescription: boolean) { | ||
| return resolveResponsiveClasses( | ||
| size, | ||
| hasDescription ? CARD_PADDING_WITH_DESCRIPTION : CARD_PADDING_WITHOUT_DESCRIPTION | ||
| ) | ||
| } | ||
|
|
||
| export function getCardPaddingClasses(size: CardSize, hasDescription: boolean) { | ||
| if (!hasDescription && size === "sm") return "px-8 py-4" | ||
| return "p-8" | ||
| export function getContentGapClasses(size: ResponsiveCardSize) { | ||
| return resolveResponsiveClasses(size, CONTENT_GAP_CLASSES) | ||
| } | ||
|
|
||
| export function getContentGapClasses(size: CardSize) { | ||
| if (size === "sm") return "gap-2" | ||
| return "gap-6" | ||
| export function getTitleSizeClasses(size: ResponsiveCardSize) { | ||
| return resolveResponsiveClasses(size, TITLE_SIZE_CLASSES) | ||
| } |
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.
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.