-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
components: Remove @emotion/css
from ItemGroup
#33070
Conversation
Size Change: +860 B (0%) Total Size: 1.05 MB
ℹ️ View Unchanged
|
import { useItem } from './use-item'; | ||
import { ItemView } from './styles'; | ||
|
||
function Item( props: PolymorphicComponentProps< ItemProps, 'div' > ) { |
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.
Is it missing forwardedRef: Ref< any >
?
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.
Whoops, yes it is.
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.
It's really weird that contextConnect
didn't yell about it missing the ref as the first argument to contextConnect
is a function accepting PolymorphicComponentProps and a ref 🤔
role, | ||
size, | ||
spacedAround, | ||
action, |
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.
action
is a valid HTML attribute, and therefore when it is passed down to ItemView
React assigned an invalid value of "true"|"false"
to the action
attribute.
We should rename this property so that it doesn't conflict with any existing HTML attributes, maybe hasAction
?
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.
Yeah, isAction
makes sense to me and follows our boolean naming agreement 🙂
@ciampo I went ahead and renamed all the booleans and moved the default props up out of styles into the component like we did with other components. |
} | ||
`; | ||
|
||
const renderRounded = ( { rounded = false }: ItemGroupProps ) => |
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.
In the original hook, rounded
defaulted to true
const { | ||
isBordered = false, | ||
isSeparated = false, | ||
size: sizeProp, | ||
role = 'list', | ||
...otherProps | ||
} = useContextSystem( props, 'ItemGroup' ); |
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.
Should we move these default prop values to the DEFAULT_PROPS
object?
We could then rewrite this something like:
const { | |
isBordered = false, | |
isSeparated = false, | |
size: sizeProp, | |
role = 'list', | |
...otherProps | |
} = useContextSystem( props, 'ItemGroup' ); | |
const { | |
isBordered, | |
isSeparated, | |
size: sizeProp, | |
role, | |
...otherProps | |
} = useContextSystem( { ...DEFAULT_PROPS, props }, 'ItemGroup' ); |
and then remove spreading DEFAULT_PROPS
directly on <ItemGroupView />
} | ||
|
||
export interface ItemProps { | ||
isAction?: boolean; |
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.
Should we add JSDocs, including specifying the @default
value?
} | ||
`; | ||
|
||
const borderRadius = CONFIG.controlBorderRadius; |
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.
Nit, but should borderRadius
be declared at the top of the file?
css` | ||
border-radius: ${ borderRadius }; | ||
|
||
> *:first-child { |
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.
This rule seems to create a warning in Storybook:
The pseudo class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type"
> *:first-child { | |
> *:first-of-type { |
Description
Part of #30503 (comment)
Also had to make some updates to the storybook story to remove usages of the
css
prop in favor ofstyle
as we've been doing in stories.How has this been tested?
Storybook, everything all the props etc should all work as they worked before.
Types of changes
Non breaking change
Checklist:
*.native.js
files for terms that need renaming or removal).