-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
[react] Create Hidden component #146
Conversation
const hiddenAtomics = generateAtomics(({ theme }) => { | ||
const conditions = {}; | ||
|
||
for (let i = 0; i < theme.breakpoints.keys.length; i += 1) { | ||
const breakpoint = theme.breakpoints.keys[i]; | ||
conditions[`${theme.breakpoints.keys[i]}Only`] = theme.breakpoints.only(breakpoint); | ||
conditions[`${theme.breakpoints.keys[i]}Up`] = theme.breakpoints.up(breakpoint); | ||
conditions[`${theme.breakpoints.keys[i]}Down`] = theme.breakpoints.down(breakpoint); | ||
} | ||
|
||
return { | ||
conditions, | ||
properties: { | ||
display: ['none'], | ||
}, | ||
}; | ||
}); |
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.
Gist of the logic.
@@ -6,5 +6,4 @@ export { generateAtomics, atomics } from './generateAtomics'; | |||
export { default as css } from './css'; | |||
export { default as createUseThemeProps } from './createUseThemeProps'; | |||
export { default as internal_createExtendSxProp } from './createExtendSxProp'; | |||
export { default as Box } from './Box'; |
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.
@brijeshb42 I have to remove this, otherwise the test fail due to "Cannot find a module ./Box". I believe that Box should be imported from @pigment-css/react/Box
right?
Summary
With a flip perspective, I am able to create the Hidden with the same API using the existing
generateAtomics
fn.Instead of declaring
xs, … xl
as conditions, I use the prop namexsUp, xsDown, xsOnly, … xlUp, xlDown, xlOnly
as conditions.In the component, it reads the runtime theme to find the breakpoint keys and compose the
display
atomic object:Test
See
packages/pigment-css-react/tests/generateAtomics.test.js