Giter Site home page Giter Site logo

Comments (3)

diegohaz avatar diegohaz commented on April 30, 2024

Hi, @mrtnbroder. Thank you for the words.

The components directory is scalable for sure. Actually, Atomic Design itself is scalable. From Pattern Lab, which this boilerplate is based on:

Pattern Lab is designed to be flexible with regards to naming and structure. There's really no One Right Way to do this, and we think that's just fine. Name things as you please, and we'll leave the hair-splitting out of things.

For example, I've added a themes folder to the structure. In this great article, @yejodido introduces ecosystems and environments.

That said, you could add a modals folder to the structure. But I think your suggestion is better, I would name it contents though. I'm doing something similar on Icon.

This is something worth discussing and it would be nice if other people could add their thoughts. In the end, though, you should do what better addresses your use case.

cc/ @bradfrost

from arc.

jlmitch5 avatar jlmitch5 commented on April 30, 2024

It seems to me like the <Modal /> component should probably not be concerned with the content inside of it...it should just be concerned with things like opening/closing and the consistent interface elements that all modals share (the close button in the top right corner, the background overlay behind the modal, etc.)

This makes me think that it might it could be a good case for a template? with a definition that looks something like:

const Modal = ({ children }) => (
  <div style={overlay}>
    <div style={modal}>
      <div style={modaBody}>
        {children}
      </div>
    </div>
  </div>
)

There is a possible issue here though. Modals are more complicated than just rendering a dom string. They require internal state ("is the modal open or closed"), and also may need to interact with the larger environment ("open a modal if the API returns an error", "all modals need to be closed if the user's login session has timed out").

Curious what y'all think about this idea.

from arc.

diegohaz avatar diegohaz commented on April 30, 2024

It seems to me like the component should probably not be concerned with the content inside of it

I agree. What I did was creating a Modal molecule and some more specific modal organisms like ConfirmModal and LoginModal.

"open a modal if the API returns an error", "all modals need to be closed if the user's login session has timed out

To achieve that, we need to make the modal(s) state global. I wrote a implementation of this on the redux branch inspired by this answer from @gaearon on SO.

Basically, we have a modal store, the components and the respective containers to connect them to the store.

The usage would be something like this:

<Button onClick={() => props.dispatch(modalShow('confirm'))}>
  Delete
</Button>
<ConfirmModal name="confirm" onConfirm={() => props.dispatch(somethingDelete())}>
  Are you sure?
</ConfirmModal>

An example is the UserButton component and the UserButton container that opens the LoginModal.

from arc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.