Comments (3)
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.
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.
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)
- Running from dist HOT 1
- A lot of packages is out of date HOT 2
- Arc ssr (server side) CSS can not loaded. HOT 1
- r
- Error with import components HOT 6
- Looking for a Typescript version of components/index.js HOT 1
- Question about how 'components' is exported in the example project HOT 1
- GraphQl Branch HOT 3
- Updating to webpack 4
- Updating the SSR version to webpack 4 : new webpack config HOT 1
- Implement React Portals HOT 4
- Non root path build
- crashes on heroku, but not locally.
- injectGlobal is not supported
- `process.env` Object in config.js empty on Browser
- change crlf to lf
- Molecule inside molecule
- Discussion: are people still using Atomic design in 2021? HOT 2
- eslint bug
- Mui
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arc.