-
Notifications
You must be signed in to change notification settings - Fork 9
Uds 2036 - update multiple card render for unity-react-core cards #1577
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
base: dev
Are you sure you want to change the base?
Changes from all commits
a514e93
a0d63e6
5853528
555aca0
ca052d2
60ca49f
778091a
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 |
|---|---|---|
|
|
@@ -46,7 +46,69 @@ export const Card = ({ | |
| tags, | ||
| showBorders = true, | ||
| cardLink, | ||
| cards = [], | ||
| columns = "0", | ||
|
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. I think we are moving towards responsive design, and we should not allow columns to be a property. Columns should be responsive and allow the card to adjust between the min and max widths provided by the brand team. |
||
| layout = "auto" | ||
|
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. Does 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. I see we already have horizontal prop. these props are getting confusing |
||
| }) => { | ||
| // If multiple cards are provided, render them in a card container | ||
| if (cards.length > 1) { | ||
| const getColumnClass = () => { | ||
| switch (columns) { | ||
| case "2": | ||
| return ""; | ||
| case "3": | ||
| return "three-columns"; | ||
| case "4": | ||
| return "four-columns"; | ||
| default: | ||
| return ""; | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className={classNames("uds-card-arrangement", { | ||
| "uds-card-arrangement-vertical": layout === "vertical", | ||
| "auto-arrangement": layout !== "vertical" | ||
| }) | ||
| }> | ||
| <div | ||
| className={classNames( | ||
| "uds-card-arrangement-card-container", | ||
| getColumnClass() | ||
| )} | ||
| > | ||
| {cards.map((card, index) => ( | ||
| <BaseCard | ||
| key={index} | ||
| type={card.type || type} | ||
| width={card.width || width} | ||
| horizontal={ | ||
| card.horizontal !== undefined ? card.horizontal : horizontal | ||
| } | ||
| image={card.image} | ||
| imageAltText={card.imageAltText} | ||
| title={card.title} | ||
| icon={card.icon} | ||
| body={card.body} | ||
| eventFormat={card.eventFormat || eventFormat} | ||
| eventLocation={card.eventLocation} | ||
| eventTime={card.eventTime} | ||
| buttons={card.buttons} | ||
| linkLabel={card.linkLabel} | ||
| linkUrl={card.linkUrl} | ||
| tags={card.tags} | ||
| showBorders={ | ||
| card.showBorders !== undefined ? card.showBorders : showBorders | ||
| } | ||
| cardLink={card.cardLink} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| // Single card - render as before | ||
| return ( | ||
| <BaseCard | ||
| type={type} | ||
|
|
@@ -86,7 +148,7 @@ Card.propTypes = { | |
| /** | ||
| * Card title | ||
| */ | ||
| title: PropTypes.string.isRequired, | ||
| title: PropTypes.string, | ||
| /** | ||
| React Font Awesome icon prefix and name string to be rendered in button label. Ex: ['fab', 'drupal'] | ||
| */ | ||
|
|
@@ -152,6 +214,57 @@ Card.propTypes = { | |
| * Card link | ||
| */ | ||
| cardLink: PropTypes.string, | ||
| /** | ||
| * Array of card objects for rendering multiple cards | ||
| */ | ||
| cards: PropTypes.arrayOf( | ||
|
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. Cards has same structure as BaseCard, might need to rearrange the file, but can we reuse the prop structure cards: PropTypes.arrayOf(PropTypes.shape(BaseCard.propTypes)) |
||
| PropTypes.shape({ | ||
| type: PropTypes.oneOf(["default", "degree", "event", "news", "story"]), | ||
| width: PropTypes.oneOf(["25%", "50%", "75%", "100%"]), | ||
| horizontal: PropTypes.bool, | ||
| title: PropTypes.string.isRequired, | ||
| icon: PropTypes.arrayOf(PropTypes.string), | ||
| body: PropTypes.string, | ||
| eventFormat: PropTypes.oneOf(["stack", "inline"]), | ||
| eventLocation: PropTypes.string, | ||
| eventTime: PropTypes.string, | ||
| image: PropTypes.string, | ||
| imageAltText: PropTypes.string, | ||
| buttons: PropTypes.arrayOf( | ||
| PropTypes.shape({ | ||
| ariaLabel: PropTypes.string, | ||
| color: PropTypes.oneOf(["gold", "maroon", "gray", "dark"]), | ||
| icon: PropTypes.arrayOf(PropTypes.string), | ||
| href: PropTypes.string, | ||
| label: PropTypes.string, | ||
| onClick: PropTypes.func, | ||
| size: PropTypes.oneOf(["default", "small", "xsmall"]), | ||
| target: PropTypes.oneOf(["_blank", "_self", "_top", "_parent"]), | ||
| }) | ||
| ), | ||
| linkLabel: PropTypes.string, | ||
| linkUrl: PropTypes.string, | ||
| tags: PropTypes.arrayOf( | ||
| PropTypes.shape({ | ||
| ariaLabel: PropTypes.string, | ||
| color: PropTypes.oneOf(["white", "gray", "dark"]), | ||
| href: PropTypes.string, | ||
| label: PropTypes.string, | ||
| onClick: PropTypes.func, | ||
| }) | ||
| ), | ||
| showBorders: PropTypes.bool, | ||
| cardLink: PropTypes.string, | ||
| }) | ||
| ), | ||
| /** | ||
| * Number of columns for multiple cards layout (0, 2, 3, or 4) | ||
| */ | ||
| columns: PropTypes.oneOf(["0", "2", "3", "4"]), | ||
| /** | ||
| * Vertical or normal layout | ||
| */ | ||
| layout: PropTypes.oneOf(["vertical", "auto"]) | ||
| }; | ||
|
|
||
| /* | ||
|
|
||
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.
Card feels like it is doing too much. Should we have a card-arrangement component that takes an array of 1 or more cards?
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.
I am ok with this temporarily if we have to keep it for WS2 purposes, but think it will cause issue down the line since it is a strange pattern