-
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
Component System: Add Elevation Component #28593
Conversation
Size Change: +1.48 kB (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
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.
LGTM. I'd prefer if we used more specific tests than snapshots for some of those. One last thing is that we need to add the component to packages/components/tsconfig.json
test( 'should render isInteractive', () => { | ||
const { container } = render( <Elevation isInteractive /> ); | ||
|
||
expect( container.firstChild ).toMatchSnapshot(); |
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.
More snapshot tests 😱
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 know :(. Both Elevation
and Surface
are basically PURE css things.
This raises an interesting question. How should we handle unit testing for these low level primitives that are mostly CSS things?
It could get very verbose to check for individual css props 🤔 - for example, complex box shadows.
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 honestly have no idea. Checking for those things seems just as brittle as a snapshot test.
8f7a1c5
to
8bbda0c
Compare
@sarayourfriend Thank you for your help with this one! Do you think we're 👍 now? |
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.
Awesome work! Thanks @ItsJonQ and @sarayourfriend!
The only thing I didn't understand is how focus
and isInteractive
props work. I see Storybook has knobs for those props, but it doesn't seem like I can focus on the element.
function Elevation( props, forwardedRef ) { | ||
const otherProps = useElevation( props ); | ||
|
||
return <View aria-hidden { ...otherProps } ref={ forwardedRef } />; |
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.
Does this component accept a children prop? Is it possible that someone uses this component like this by mistake?
<Elevation>
<p>Paragraph</p>
<button>Button</button>
</Elevation>
If that's the case, I would whether not accept a children prop or warn against it. If there's a use case for children prop, I would use role="presentation"
instead of aria-hidden
(the difference is that aria-hidden
will disable the whole subtree, whereas role="presentation"
will only disable that element).
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.
Ooo! Thanks for the feedback. Elevation
actually shouldn't accept children
😱 .
(@sarayourfriend how would we adjust the types for that? I think this may be one of the few new components that don't accept children
)
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.
Oh, interesting. I'll do some tinkering.
@diegohaz Thank you for the review! We'll update the To clarify with Let's pretend we want to add We could do something like this: <LinkCard>
...
<Elevation focus={10} />
</LinkCard> The styles are written in a way where once the They apply when the direct parent element is engaged with, rather than the Hope this helps 🙏 P.S. I don't blame you for not getting it. I needed to poke at the story to remember why I set it up this way. After I did, I feel like it makes sense, and I can understand the use case. |
@ItsJonQ That makes sense. I imagined something like that. Do you think we can have a story for that too? |
|
@diegohaz Focus story has been pushed |
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.
Looks good to me! Thanks! ❤️
@diegohaz Amazing!! Thank you 🙇 |
This update adds a new Elevation component for the new Component System.
This is a brand new primitive component.
@wordpress/components
previously didn't have aElevation
component, so we didn't need to "adapt" it.This component renders shadows using the elevation/shadow values from the new Style System.
How has this been tested?
Tested locally in Storybook and in Jest.
Checklist: