Skip to content
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

Add "Area" component #305

Open
kettanaito opened this issue Mar 19, 2020 · 1 comment
Open

Add "Area" component #305

kettanaito opened this issue Mar 19, 2020 · 1 comment
Labels
Milestone

Comments

@kettanaito
Copy link
Owner

kettanaito commented Mar 19, 2020

What:

I suggest to introduce an Area component to Atomic Layout.

Why:

Area component would act similarly to Box, but is designed to be used as a direct child of the templateless Composition. Area would accommodate the CSS Grid-related props (column, rowEnd, etc.).

I find this useful for scenarios when I need to align direct Composition children (i.e. specify a child's grid-column) without having to convert the Composition to use template/areas.

Usage example:

import { Composition, Area } from 'atomic-layout'

const Example = () => {
  return (
    <Composition templateCols="1fr 250px">
      <Area columnStart={2}>Content</Area>
    </Composition>
  )
}

Together with the polymorphic as prop the Area component may be used as an augment component that provides grid-related styles to any direct children.

@kettanaito kettanaito added this to the 1.0 milestone Apr 1, 2020
@kettanaito
Copy link
Owner Author

kettanaito commented Apr 9, 2020

The Composition component assigns the area prop directly to the Box:

const createAreaComponent = (areaName: string): AreaComponent => (
props: BoxProps,
) => {
return <Box area={areaName} {...props} />
}

However, that area prop is not listed as the one Box can accept in the GenericProps interface:

export interface GenericProps {

The props signature of the Box component can accept the area prop just fine due to the key signature on the `BoxProps:

export interface BoxProps extends GenericProps {
[propName: string]: any
flex?: boolean
inline?: boolean
}

Also, one thing to keep in mind: Areas rendered this way will not support conditional rendering based on their presence in the areas/template props. At least, with the current setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant