-
Notifications
You must be signed in to change notification settings - Fork 30
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
Create A Lightbox
Component
#12700
Create A Lightbox
Component
#12700
Conversation
Combines the web and apps lightbox setup into a single component. This puts the logic in a single place, hopefully making it easier to find and understand. For apps, this also means the component is now referenced once at the `ArticlePage` level, rather than separately in each layout file. This reduces repetition and matches the way it's handled for web.
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
Size Change: 0 B Total Size: 927 kB ℹ️ View Unchanged
|
switch (renderingTarget) { | ||
case 'Web': | ||
if ( | ||
switches.lightbox === undefined || |
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 this check needed?
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 lightbox
switch has three possible values: undefined
, true
or false
. The first condition handles undefined
. If it evaluates to false
then the type is narrowed to boolean
, which the second condition handles.
Technically you could rely on JavaScript's coercion behaviour to combine this into a single condition, which would implicitly convert undefined
to false
, but I prefer to handle these checks separately as I think it's clearer.
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.
Nice refactor 👍
Seen on PROD (merged by @JamieB-gu 8 minutes and 49 seconds ago) Please check your changes! |
Combines the web and apps lightbox setup into a single component. This puts the logic in a single place, hopefully making it easier to find and understand.
For apps, this also means the component is now referenced once at the
ArticlePage
level, rather than separately in each layout file. This reduces repetition and matches the way it's handled for web.