Adding Redux To AtlasParcel Boilerplate

in #utopian-io6 years ago (edited)

AtlasParcel is a starter application to empower developers to start a single page application powered by React, Atlaskit, Parcel, and (now) Redux.

AtlasParcel with Redux

About The Project

Setting up a new single page application with React can be a pain. AtlasParcel is the pain killer in this regard. You can set up and deploy a new project in minutes thanks to Parcel and Atlaskit.

This boilerplate should make it quite easy to build something based on top of it. It has a great developer experience with zero configuration needed. Thank you, Parcel.

A developer can see changes instantaneously in the browser. After you have started your project with yarn start, a development server will be started which picks up any saved changes and displays the updated application in your browser; without the need to reload. Hot-reloading is a huge time saver.

Some of the application's UI state has been already wired up to Redux. Mainly to show how it is done. A good application structure for managing state can be seen in the state folder.

It is also easy to build the project with just one command: yarn build. If you have Netlify installed you can even deploy it with one command: netlify deploy

Technology Stack

New Features

  • React Router 4
  • Redux integration of react router
  • Redux integration of UI state

Roadmap

  • Update to use React Router 4
  • Add Redux for state management

This project is now considered feature complete. It has everything to get a fresh app up and running quickly.

Getting Started

Building your project on top of this starter is straightforward. Just clone the starter in a folder with your project's name. Then remove the Git history to be able to initialize your own Git repository. Then install the dependencies with yarn. When the installation has finished, you can run the new app with yarn start. These are the steps in more detail:

git clone https://github.com/cutemachine/atlasparcel.git YOUR_PROJECT
cd YOUR_PROJECT
rm -rf .git
git init
git add .
git commit -m 'Initial version of YOUR_PROJECT'
yarn
yarn start

Using Redux

Redux has been added to the AtlasParcel starter. So a developer can just use it without the need for any further work. Even the React Router has been wired to the Redux store. So it is easy to react to state changes regarding routes.

Using Redux and adding own state slices to handle the application's needs might be harder. So I would like to give a walkthrough of the folder structure.

This is the file structure for handling the application state:

src/state
src/state/ui
src/state/ui/actions.js
src/state/ui/operations.js
src/state/ui/reducers.js
src/state/ui/selectors.js
src/state/ui/types.js
src/state/rootReducer.js
src/state/store.js

If you want to add a new state slice to your application you would copy the state/ui folder with its contents to a new folder and name it appropriately.

Let's suppose you want to manage the state of a shopping cart, you would copy state/ui to state/cart.

Then in the root reducer src/state/rootReducer.js you would add the state slice like so:

import uiReducer, { uiSelectors } from './ui'
import cartReducer, { cartSelectors } from './cart'

// …

const rootReducer = combineReducers({
  router: routerReducer,
  ui: uiReducer,
  cart: cartReducer
})

// …

Now you can make changes to the cart state slice by adjusting the files in src/state/cart/. The rest of the files are just normal Redux stuff. You can learn more about using Redux on the excellent Redux docs.

Repository Changes For Adding Redux

The branch for adding the Redux store can be reviewd on GitHub.
The branch has been merged into master.

Demo

Check out the updated live demo of AtlasParcel with Redux integration.

How To Contribute

Do you want to contribute to this project? Great. You can contact me through my Github profile page or just send a pull request.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Jo, is there I a slider component like I use here? https://we-resist-bot.herokuapp.com/@r351574nc3/preferences

I'm trying to rebuild that page and add sliders. I'm not sure if I need to build my own slider component or if there is one available already.

I had no luck opening the link, but are you looking for a component like this?

Oh, well done, this time including redux!
I've never worked with Atlaskit, I'm going to check this out and report back to you. What is your experience so far with it? Is it as usable as semantic-ui-react? :) But in general I really like the style of the Atlassian Components, have worked at while with Jira on a daily basis.

I'm impressed! I need to use them in some project in the future. Unbelievable detailed components with lots of variations. Especially the great datepicker, this is always a pain point for web applications. :)

​Happy to hear. Let me know if you have questions using AtlasParcel; I'm happy to help.

Hey Felix (correct?), thank you for the kind words.

Well, I never worked professionally with any of the two UI libraries. I want to build a new site for the Steem blockchain and was undecided what to use for the UI React components. So I decided to create these starters to be able to make a more informed decision.

To be honest, the plan did not work out because there is not a clear winner.

I love that Atlaskit is using styled-components under the hood.

Semantic UI has a great variety of components, but I despise working with SASS. SASS was a great tool, but it is less useful now that we are in the component age.

Having written this reply to you, I think I will use Atlaskit. So, thanks for asking :)

PS: You should write some more posts here on Steemit. I feel the urge to upvote some articles from your blog ​:)

I want to build a new site for the Steem blockchain..

Your goal is something like https://busy.org ? That would be very ambitious! I like to hear more regarding this. :)

You are totally right, I need to write new articles about javascript! I'm currently thinking about how to help the community to publish more javascript related articles. Because in comparison to other languages there are very less js related posts per day. :(

Yes, I would love to read more JavaScript related articles here.

I agree, building something like Busy would be too ambitious and it would not make sense. Busy is excellent. I would rather contribute to the code than to build a competing product.

The site I want to build is more like a swiss army knife for the Steem blockchain. A site where one can find good content and users; make delegations; track rewards and similar features.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thank you for the review, Vladimir.

Hey @cutemachine I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x


Exclusive 30 days free upvotes to your every new post. No need to send any kinds of steem or sbd its full free service. we have paid service too so please check them too. Active the free upvote service and learn more about it here : http://www.upperwhale.ga

Please, do not spam the comments section. You are not helping the Steemit platform by doing this.

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 59893.00
ETH 2414.92
USDT 1.00
SBD 2.43