pariveda-accelerators / react-toolkit

Component library and other helpful tooling when building an application using React
MIT License
1 stars 1 forks source link

Box must support all props `Flex`, `Block`, etc support #34

Open zakbutcher opened 4 years ago

zakbutcher commented 4 years ago

Box currently doesn't support additional properties defined by Flex. We need to figure out a scalable component architecture that supports component hierarchies.

Approach 1

<Flex /> === <Box d="flex" />
<Flex direction="column" /> === <Box d="flex" direction="column" />

Approach 2

const Box = ({d, ...restProps}) => {
  if (d === 'flex') {
    return <Flex {...restProps} />
  }
}

Others?

zakbutcher commented 4 years ago

This is also related to #32

zakbutcher commented 4 years ago

Expanding on the question:

Does Box need to support all Flex, Block properties or can it be a "style" component? 🤔

Material UI uses an overlay to convey state. If Box is an accessible wrapper extended by Flex, Block, etc then all layout components are accessible. Furthermore, if Box is only intended to provide accessibility & baseline configuration support for layouts, then it can be reused as an accessible wrapper for any component built using a <div> as the root element.

Box would then be responsible for indicating UI state transitions (e.g. hover, pressed, focused, etc) as well as supporting keyboard, mouse, or other input-device accessibility.