• Stars
    star
    467
  • Rank 93,935 (Top 2 %)
  • Language
    JavaScript
  • Created about 9 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Project boilerplate using React, Redux and Uniloc

Unicorn Standard Starter Kit

This starter kit provides you with the code and conventions you need to get straight into building your React/Redux based app.

Happiness is six lines away

Prerequisites: node.js and git

git clone https://github.com/unicorn-standard/starter-kit.git your-repo-name
cd your-repo-name
npm install
npm start
npm run open # (from a different console window, otherwise open localhost:3000)

Presto, you've got a ready-to-customise application!

Unicorn Standard Starter Kit

Why use Unicorn Standard Starter Kit?

  • Your directory structure is sorted as soon as you git clone
  • ES6 compilation and automatic-reloading development server are configured for you with webpack and Babel
  • Redux is an incredibly simple way of modelling your data, with great community support
  • React is an incredibly simple way of rendering your views, and is maintained by Facebook
  • Simple uniloc-based routing is included - easy to understand, and easy to customize
  • The Pacomo CSS conventions eliminate bugs caused by conflicting styles
  • The actors pattern allows you to easily react to changes on your store without forcing a re-render
  • Your redux store is already configured with navigation, data and view models
  • Comes with views, layouts and reducers for a simple document editor!

Getting Started

Put your name on it

  • Update name, desription and author in package.json
  • Update app title in src/index.html
  • Restart the dev server (make sure to do this after any changes to src/index.html)

Make sure your editor is happy

  • Setup ES6 syntax highlighting on extensions .js and .jsx (see babel-sublime)

Start building

  • Add a route to src/constants/ROUTES.js
  • Add a nav menu item for your route in src/components/ApplicationLayout.jsx
  • Add a component for your route in src/components
  • Add reducers and actions for your component's view model in src/actions and src/reducers/view
  • Add any data models which your component reqiures in src/reducers/data
  • Add a container to map your store's state and dispatch to component props in src/containers
  • Configure your route in src/Application.jsx
  • Bask in the glory of your creation
  • Don't forget to commit your changes and push to Bitbucket or GitHub!

Show your friends

  • Run gulp dist to output a web-ready build of your app to dist

Structure

Entry point

main.js is the entry point to your application. It defines your redux store, handles any actions dispatched to your redux store, handles changes to the browser's current URL, and also makes an initial route change dispatch.

Most of the above will be obvious from a quick read through main.js - if there is one thing which may strike you as "interesting", it'll be the block which handles actors.

Actors

Read the introduction to actors

Each time your store's state changes, a sequence of functions are called on the current state of your store. These functions are called actors.

There is one important exception to this rule: actors will not be called if main.js is currently in the midst of calling the sequence from a previous update. This allows earlier actors in a sequence to dispatch actions to the store, with later actors in the sequence receiving the updated state.

The code which accomplishes this is very small:

let acting = false
store.subscribe(function() {
  // Ensure that any action dispatched by actors do not result in a new
  // actor run, allowing actors to dispatch with impunity.
  if (!acting) {
    acting = true

    for (let actor of actors) {
      actor(store.getState(), store.dispatch.bind(store))
    }

    acting = false
  }
})

The actor is defined in src/actors/index.js. By default, it runs the following sequence:

  • redirector - dispatch a navigation action if the current location should redirect to another location
  • renderer - renders your component with React

Model

Your model (i.e. reducers and actions) is pre-configured with three parts:

Navigation

The navigation state holds the following information:

  • location is the object which your ROUTES constant's lookup function returns for the current URL. With the default uniloc-based ROUTES object, this will have a string name property, and an options object containing any route parameters.
  • transitioning is true if a navigation start action has been dispatched, but the browser hasn't changed URL yet

Data

The data state can be thought of as the database for your application. If your application reads data from a remote server, it should be stored here. Any metadata should also be stored here, including the time it was fetched or its current version number.

View

The view state has a property for each of the view's in your app, holding their current state. For example, form state should be stored in the view models.

Directories

  • src/actions - Redux action creators
  • src/actors - Handle changes to your store's state
  • src/components - React components, stateless where possible
  • src/constants - Define stateless data
  • src/containers - Unstyled "smart" components which take your store's state and dispatch, and possibly navigation location, and pass them to "dumb" components
  • src/reducers - Redux reducers
  • src/static - Files which will be copied across to the root directory on build
  • src/styles - Helpers for stylesheets for individual components
  • src/utils - General code which isn't specific to your application
  • src/validators - Functions which take an object containing user entry and return an object containing any errors

Other directories:

  • build - Intermediate files produced by the development server. Don't touch these.
  • dist - The output of gulp dist, which contains your distribution-ready app.
  • config/environments - The build system will assign one of these to the environment module, depending on the current build environment.

Main application files:

  • src/Application.jsx - Your application's top-level React component
  • src/index.html - The single page for your single page application
  • src/main.js - The application's entry point
  • src/main.less - Global styles for your application

Main build files:

  • gulpfile.babel.js - Build scripts written with gulp
  • webpack.config.js - Webpack configuration

TODO

  • Watch static and index.html for changes and copy them across to build when appropriate

More Repositories

1

create-react-blog

Start and deploy your own statically rendered blog with create-react-app
JavaScript
548
star
2

gulp-rev-replace

Rewrite occurences of filenames which have been renamed by gulp-rev
JavaScript
388
star
3

govern

Component-based state management for JavaScript.
TypeScript
266
star
4

react-pacomo

Automatic Namespacing for your React className props
JavaScript
193
star
5

javascript-cheatsheets

A collection of cheatsheets for JavaScript
HTML
177
star
6

webpack-black-triangle

A minimal webpack/ES6 project template with a spinning black triangle
JavaScript
166
star
7

memamug-client

Memamug helps you remember faces. Written with React, Maxim & Rails.
JavaScript
109
star
8

react-zen

React utilities for working with APIs
TypeScript
108
star
9

uniloc

Universal JavaScript Route Parsing and Generation
JavaScript
95
star
10

raw-react-part-1

Learn Raw React - No JSX, Flux, ES6, Webpack, ...
JavaScript
74
star
11

memamug-server

Memamug helps you remember faces. Written with React, Maxim & Rails
Ruby
68
star
12

use-codemirror

CodeMirror support for React
JavaScript
66
star
13

retil

The React Utility Library
TypeScript
46
star
14

maxim

Maxim provides a simple way to structure JavaScript applications, letting you focus on the parts that matter.
JavaScript
45
star
15

pacomo

A Method For Structuring Stylesheets in React-based Applications
42
star
16

cura-firebase-example

A React/Firebase starter with serverless SSR, routing and styled components.
JavaScript
29
star
17

reactjs.tokyo

Source for reactjs.tokyo. Built with universal-react-scripts and Firebase.
JavaScript
28
star
18

raw-react-part-2

Solution for Learn Raw React: Ridiculously Simple Forms
JavaScript
26
star
19

react-black-triangle

An opiniated React starter kit. Clone, follow the README, and have a working app in under two minutes.
JavaScript
26
star
20

sitepack

A JavaScript tool for building static web sites.
JavaScript
25
star
21

react-cx

Combine styles from CSS Modules with a `cx` prop.
JavaScript
24
star
22

react-base

Higher order component to handle merging callbacks, prefixing classnames and props passthrough.
JavaScript
21
star
23

raw-react-part-3

Learn Raw React - Routing
JavaScript
19
star
24

armo-breadboard

Themeable live coding for React.
JavaScript
16
star
25

popup-trigger

A helper for triggering popups on focus, hover, and selection.
TypeScript
15
star
26

memcord

Memcords let you pass Records as React props without breaking PureComponent.
TypeScript
14
star
27

mdx-loader

Webpack loader for MDX (i.e. JSX-infused Markdown) using mdx-it
JavaScript
14
star
28

react-typescript-firebase-navi

A starter kit to get you started faster than all the other starter kits πŸš…πŸ”₯πŸš€πŸ’
TypeScript
13
star
29

vouch.chat

JavaScript
11
star
30

derby-i18n

i18n support for derby.js
JavaScript
10
star
31

numbat-ui

CSS
10
star
32

use-promised-state

A state hook for React that doesn't whinge if used once used after unmount.
JavaScript
9
star
33

react-controllers

Utilities for creating React controller components
TypeScript
9
star
34

react-c

An implementation of Pacomo, a system to help structure your React stylesheets.
JavaScript
9
star
35

universal-react-app

A server-rendered starter forked from create-react-app
JavaScript
8
star
36

use-sx

Composable styles for React
TypeScript
8
star
37

node-joyo-kanji

A list of the Joyo Kanji packaged for node.js
8
star
38

react-routing-library

Concurrent routing that grows with your app.
TypeScript
7
star
39

firebase-react-demo

A simple demo of adding Firebase Functions/Hosting to a Create React App project
JavaScript
6
star
40

react-elemap

A tool for transforming React elements.
JavaScript
5
star
41

react-armory-helpers

Packages that can used with ES6 `import` within React Armory guides
4
star
42

static-directory-loader

Copy files into your public directory with a webpack import
JavaScript
4
star
43

react-junctions

JavaScript
3
star
44

meteor-yaml

Meteor smart package for YAML parsing/generation
JavaScript
2
star
45

mdx-cra-demo

JavaScript
2
star
46

junctions-react-app

A demo project using Junctions in the structure generated by Create React App
JavaScript
2
star
47

react-base-control

Higher order component to manage control-related events and state.
JavaScript
2
star
48

numbat-ui-example

JavaScript
1
star
49

angular-deputy

Resources with associations, computed values and offline support for AngularJS
CoffeeScript
1
star
50

m-and-c-in-mvc-talk

CSS
1
star
51

now-cura

Now builder for Create Universal React App
TypeScript
1
star
52

junctions-tutorial

Companion repo for the Junctions tutorial
JavaScript
1
star
53

armo

React stuff
JavaScript
1
star
54

vouch-landing

A landing page built in 2 hours with React and Firebase
JavaScript
1
star