-
Notifications
You must be signed in to change notification settings - Fork 71
Make a HOC version #9
Comments
I've certainly been thinking about this. I was thinking more of having an API that looks something like this, but maybe there's good reason not to go with this approach: <Box
Component={Paper}
{...boxProps}
{...paperProps} /> The Box component would pass styles based on its props, then render Paper. Curious what you think |
I think it's a matter of taste. I prefer seeing a component's own props attached to its tag. So I don't have a definitive answer for this, but I'm also curious of reading others opinions. |
I'm with @jgoux. I'd prefer seeing my props on the component tag. |
I'm not opposed to the nested component approach. One thing that feels odd to me is that the jsx looks like two elements, but it's only generating one. Maybe that's an okay trade off in this situation. |
We could also use a simple function: import { AppBar, Paper } from "material-ui"
import { Box, Flex, box, flex } from "reflexbox"
const view = (props) =>
<Flex auto column>
<AppBar />
<Flex auto>
{box({ auto: true })(
<Paper>Left</Paper>
)}
{box({ auto: true })(
<Paper>Right</Paper>
)}
</Flex>
</Flex> With the partial application, you can even prepare common patterns : import { AppBar, Paper } from "material-ui"
import { Box, Flex, box, flex } from "reflexbox"
const CustomBox = box({ auto: true })
const view = (props) =>
<Flex auto column>
<AppBar />
<Flex auto>
{CustomBox(
<Paper>Left</Paper>
)}
{CustomBox(
<Paper>Right</Paper>
)}
</Flex>
</Flex> |
The latest version |
Congrats for the release ! 馃憤 |
Hello,
I really like the API you built for this library. 馃憤
What would be the scenario when you want to integrate with custom/third-party components ?
For example, imagine I want to create a layout using multiple Paper from material-ui.
To make the
Paper
a flex element, I'd have to modify itsstyle
property (this is what I do at the moment), but I could do better and encapsulate all the "position/layout" logic inside HOC components which would apply the flexbox styles to their children, taking the API you provide :I used
Boxed
andFlexed
but the name/API could be anything.What do you think ? 馃槃
The text was updated successfully, but these errors were encountered: