-
Notifications
You must be signed in to change notification settings - Fork 100
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
fix(Hidden): Add Hidden component #103
Conversation
d393a76
to
657168f
Compare
label: 'Hidden on mobile', | ||
render: () => ( | ||
<Hidden component="span" hideFor="mobile"> | ||
<Text baseline={false}>Hidden on mobile</Text> |
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.
The baseline={false}
is not really required, it's best to try and keep these docs code blocks as lean as possible.
lib/components/Hidden/Hidden.tsx
Outdated
return ( | ||
<Box | ||
display={[ | ||
hideFor === 'mobile' ? 'none' : 'inline', |
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.
Whats the reason for falling back to inline
on mobile?
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.
so children is the one decide the display style display: xxx
, if falling back to block
, children couldn't override it? thoughts?
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.
We had to pass something there and inline
is something. If the child is block it will still behave as expected.
Better ideas gratefully accepted 😅
Just pushed an update that adds support for print/screen hiding, which necessitated a change in the API towards boolean props, since you can mix and match. For example: <Hidden desktop print>...</Hidden> |
)} | ||
/> | ||
</button> | ||
<Hidden print> |
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.
Dogfooding straight away 👍 🐶 🥘
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, trying to make this more of a habit.
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. I was a bit surprised by the pivot back to boolean props but the mix and match use case seems persuasive.
lib/components/Hidden/Hidden.tsx
Outdated
screen?: boolean; | ||
print?: boolean; | ||
inline?: boolean; | ||
component?: ReactType; |
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.
As discussed maybe remove the component option for 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.
Done 👍
Example usage
Hidden on mobile:
Hidden on desktop:
Hidden inline:
Hidden on print:
Hidden on screen: