-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat(contentcard): first implementation #935
Changes from all commits
715d3b6
5b060dc
1f23d20
946c469
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ export enum SDSWarningTypes { | |
TooltipSubtitle = "tooltipSubtitle", | ||
TooltipWidth = "tooltipWidth", | ||
TooltipInvertStyle = "tooltipInvertStyle", | ||
ContentCardActionsOnlyButtons = "contentCardActionsOnlyButtons", | ||
ClickableContentCardNumberOfButtons = "clickableContentCardNumberOfButtons", | ||
} | ||
|
||
export const SDS_WARNINGS = { | ||
|
@@ -58,6 +60,16 @@ export const SDS_WARNINGS = { | |
message: | ||
"Warning: Tooltips using the inverted or sdsStyle prop will be deprecated. Please use hasInvertedStyle instead!", | ||
}, | ||
[SDSWarningTypes.ContentCardActionsOnlyButtons]: { | ||
hasWarned: false, | ||
message: | ||
"Warning: Only SDS buttons could be used within ContentCard Actions component slot!", | ||
}, | ||
[SDSWarningTypes.ClickableContentCardNumberOfButtons]: { | ||
hasWarned: false, | ||
message: | ||
"Warning: Clickable Content Cards can only have one or no buttons!", | ||
}, | ||
Comment on lines
+63
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great warnings! So user friendly ❤️ |
||
}; | ||
|
||
export const showWarningIfFirstOccurence = (warningType: SDSWarningTypes) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { CardProps } from "@mui/material"; | ||
|
||
interface BaseContentCardProps extends CardProps { | ||
sdsType?: "wide" | "narrow"; | ||
overlineText?: string; | ||
titleText?: string; | ||
subtitleText?: string; | ||
metadataText?: string; | ||
boundingBox?: boolean; | ||
decorativeBorder?: boolean; | ||
children?: React.ReactNode; | ||
clickableCard?: boolean; | ||
buttonsPosition?: "left" | "right"; | ||
} | ||
|
||
export interface ImageContentCardProps extends BaseContentCardProps { | ||
visualElementType: "image"; | ||
image?: React.ReactNode; | ||
imagePosition?: "left" | "right"; | ||
imagePadding?: boolean; | ||
imageSize?: number; | ||
icon?: never; | ||
} | ||
|
||
export interface IconContentCardProps extends BaseContentCardProps { | ||
visualElementType: "icon"; | ||
icon?: React.ReactNode; | ||
image?: never; | ||
imageSize?: never; | ||
imagePosition?: never; | ||
imagePadding?: never; | ||
Comment on lines
+28
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious, why the types are Thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It uses the When we set Does that make sense? 🥸 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh!! Thanks so much for the explanation 💡 That totally makes sense now thank you! |
||
} | ||
|
||
export interface NoneContentCardProps extends BaseContentCardProps { | ||
visualElementType: "none"; | ||
icon?: never; | ||
image?: never; | ||
imagePosition?: never; | ||
imagePadding?: never; | ||
imageSize?: never; | ||
} | ||
|
||
export type ContentCardProps = | ||
| ImageContentCardProps | ||
| IconContentCardProps | ||
| NoneContentCardProps; | ||
|
||
export const CONTENT_CARD_DEFAULT_IMAGE_MEDIA_SIZE = 300; | ||
export const CONTENT_CARD_WIDE_TYPE_MIN_WIDTH_LOW_BOUNDARY = 595; | ||
export const CONTENT_CARD_WIDE_TYPE_MIN_WIDTH_HIGH_BOUNDARY = 605; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really cool util function 💡 🔥 !!