In our company we are using Atomic Design for our design system (made with React and with Styled Components as our styling solution), in order to break down our UI into atoms, molecules and organisms
I have a doubt regarding when an atom should be classified as an atom or if it should be inside its parent domain.
You can see an example of this type of composition in this Material UI Card example (which does not use atomic design, but you can get the idea anyway).
So, imagine the following example, you have a Card Atom (since it's only a wrapper that returns a styled HTML tag with children):
const Card = ({children}) => <StyledWrapper>{children}</StyledWrapper>
There are also defined some children to go along with the Card
, such as CardHeader
, CardBody
and CardFooter
, all of them optional styled wrappers and they are passed as children if necessary.
So, which would be the right approach in this example?
CardHeader
,CardBody
andCardFooter
should be classified as atoms, outside theCard
domain (meaning it's folder)
-- atoms
-- Card
-- CardHeader
-- CardBody
-- CardFooter
CardHeader
,CardBody
andCardFooter
should be placed inside theCard
domain since they are not reusable (meaning they are designed to be used only with theCard
atom), and should be exported there alongsideCard
, so the only atom in this example would beCard
-- atoms
-- Card
-- CardHeader
-- CardBody
-- CardFooter