Helpful guidance and tips for building front-end components atomically.
Created by Brad Frost, Atomic Design is a system for building and maintaining reusable components (we will refer to them as elements to avoid confusion with the larger Capital Framework Components) for a web platform. By creating simple elements, and combining them to build larger and more complex elements, we can ensure a consistent design throughout our projects.
An atomic element is any self contained code pattern that follows the Atomic Design principles. The types of elements are atoms, molecules, organisms, and templates.
- The base unit
- Think buttons, input fields, and other HTML tags
- Abstract and not too useful on their own
- It can do something
- A series of atoms combined to serve a purpose
- Self contained chunks with different functionalities to form a distinct section
- Think headers, comments section, etc
Types of pages that have a particular layout. The primary ones are Landing, Sublanding, Browse, Learn, and Document Detail. They are differentiated primarily by their major layout features, such as whether or not they have a hero, whether the sidebar is on the right or left, etc. Each template allows certain atoms, molecules, and organisms to be included in its major sections.
- If it can't stand on it's own. For example a paragraph or list item have minimal styles added to them and can live on their own so they wouldn't be elements. A button is more complex (comparatively) and so it should become an element.
- If it's not a utility. Utilities are adjustments and helpers, they don't need to become elements.
- If it's not a layout helper. Layout helpers are specifically used to lay out the structure of a page and are never concerned with the content within them.
Both prefixing and organizing elements by their type is the easiest way to keep them organized. All element classes should be prefixed by the first letter of its type (ex .m-pagination) and placed in a corresponding directory (ex. /src/molecules/pagination.less). To save yourself the trouble of moving things multiple times, we have found it easiest to break up an element in its top level stylesheet, then move each class block to its appropriate sub-directory.
- Follow the installation instructions.
- Click around to ensure the local server is rendering the sandbox correctly.
- Stop the server with
ctrl+c.
- From the root of
capital-framework
npm run cf-link
To add your Component to this command, edit the script in package.json
2. In a new tab, navigate to the root of the Sandbox
cd capital-framework-sandbox
3. Run the same command from the root of the Sandbox repo
npm run cf-link
Again, to add your Component to this command, edit the script in this repo’s package.json
4. Run the build command
npm run build
5. Start the server and check out the changes
npm start
When you’re done working on or reviewing a Component, run npm unlink component-name && npm install component-name
- Checkout the v4 prerelease branch of Capital Framework
cd capital-framework
git checkout prerelease-ver-4- Create a new branch for your Capital Framework Component
git checkout -b atomic/pagination- Save your changes
- In the Sandbox create a new preview branch, build the assets, start the server, and adjust markup as needed
cd capital-framework-sandbox
git checkout -b cf-pagination-example
npm run build
npm start- When you save changes in Capital Framework, the Sandbox will re-build the files (may still need a manual page refresh) as long as the server is running.
Feel free to start a conversation in the Capital Framework repo or in the Atomic Design chat channel.