feat: Atomic Components for Card refactor#235
Conversation
🟡 Heimdall Review Status
🟡
|
| Code Owner | Status | Calculation | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ui-systems-eng-team |
🟡
0/1
|
Denominator calculation
|
|
|
||
| export type CardRootProps = CardRootBaseProps & PressableProps; | ||
|
|
||
| export const CardRoot = memo( |
There was a problem hiding this comment.
Component that handles the interactive layer of card
There was a problem hiding this comment.
@adrienzheng-cb do you mind adding some js docs to this (and other component s where helpful) to add context around usage?
Additionally, are we expecting customers to ever use this directly or is it for internal use to share behavior between Card components?
There was a problem hiding this comment.
At the moment, I'm planning to just keep it internal along with all of the CardLayout component, only MediaCard, DataCard, MessagingCard, and ContentCard will be exposed. I do see benefit of exposing it if we encourage consumers to assemble their own card tho.
There was a problem hiding this comment.
@adrienzheng-cb got it! In that case let's not export it from the barrel file nor add an exports entry for those modules in the package.json to make it harder for customers to use
4c49779 to
ec9c499
Compare
a6cb94a to
be85bd4
Compare
be85bd4 to
7134a9f
Compare
7134a9f to
830443f
Compare
830443f to
e3d6651
Compare
e3d6651 to
67a0cf5
Compare
67a0cf5 to
634007d
Compare
634007d to
d4869f5
Compare
cb-ekuersch
left a comment
There was a problem hiding this comment.
Few questions I want to get to the bottom of here, but in general the direction looks good!
|
|
||
| import { Pictogram, SpotSquare } from '../illustrations'; | ||
|
|
||
| import { CardRemoteImage } from './CardRemoteImage'; |
| <RemoteImage | ||
| alt={props.alt ?? ''} | ||
| resizeMode="cover" | ||
| source={getSource(props.src)} |
There was a problem hiding this comment.
nit: curious about the addition of these properties
There was a problem hiding this comment.
Because this properties used to be set inside CardRemoteImage which got removed.
resizeMode ensures that the Image always stretch proportionally covers its container entirely no matter what aspect ratio the container is in.
|
|
||
| export type CardRootProps = CardRootBaseProps & PressableProps; | ||
|
|
||
| export const CardRoot = memo( |
There was a problem hiding this comment.
@adrienzheng-cb do you mind adding some js docs to this (and other component s where helpful) to add context around usage?
Additionally, are we expecting customers to ever use this directly or is it for internal use to share behavior between Card components?
| { | ||
| children?: React.ReactNode; | ||
| /** If true, the CardRoot will be rendered as a Pressable component. */ | ||
| renderAsPressable?: boolean; |
There was a problem hiding this comment.
nit: should we just make this implicit with a onPress prop as the previous cards did?
There was a problem hiding this comment.
I know we discussed this like a month ago, i just need a little help remembering the context around the decision
There was a problem hiding this comment.
because the list of props that indicate is interactivity is indefinite, we just want to leave the choice to customer instead of having implicit logic here and there and make assumptions.
| if (renderAsPressable) { | ||
| const { as, ...pressableRestProps } = props; | ||
| return ( | ||
| <Pressable ref={ref} as={as ?? 'button'} {...(pressableRestProps as any)}> |
There was a problem hiding this comment.
nit: is the default as necessary? Pretty sure button is the default for pressable
There was a problem hiding this comment.
should we render the pressable if they pass button as the value for as? onClick will be valid prop at that point
There was a problem hiding this comment.
nice suggestion. I updated logic to the following in followup pr
- if
asisbuttonora, then renderAsPressable istrueby default, otherwisefalse. - removed the default
as, because Pressable by default renders a button.
| } else { | ||
| const { as, ...hstackRestProps } = props; | ||
| return ( | ||
| <HStack ref={ref} as={as ?? 'article'} {...(hstackRestProps as any)}> |
There was a problem hiding this comment.
this has been removed in follow-up. originally using article because semanticaly non-interactive card with a lot of text content should be rendered as an article. Since MediaCard, DataCard, and MessagingCard are intended to be more interactive than static, this is no longer necessary.
What changed? Why?
Root cause (required for bugfixes)
UI changes
Testing
How has it been tested?
Testing instructions
Illustrations/Icons Checklist
Required if this PR changes files under
packages/illustrations/**orpackages/icons/**Change management
type=routine
risk=low
impact=sev5
automerge=false