Git Product home page Git Product logo

react-ultimate's Introduction

React Ultimate

This repo is not maintained. Check Unredux where our recent React experiments occur.


Tired of React Starters reexplaining another helloworld?

Dreamed of something closer to the industry?

Welcome to React Ultimate then.

alt tag

This project aims to provide basic solutions for typical web app tasks. Bundling, indexing, pagination, filtering, sorting, CRUD, forms, authorization, tests, lints, live reloads,np isomorphic app, code sharing between server and browser... We're going to solve all such common tasks in a simplified, yet valueable form to provide a starting point for your next project.

Not everything of that is already here or has desired quality, but we're approaching. We're interested in the architecture that may be ported to different frameworks and even languages. React is not a final answer. Reactivity probably is.

Install

  1. Download and unzip repo
  2. Go to unzipped folder
  3. Install static server with $ npm install http-server -g
  4. Install packages with $ npm install

Note: Windows users should have Bash shell installed (instructions).

Dev Run

  1. Check dev.env and load it into SHELL via $ . dev.env
  2. Run Webpack-Server via $ npm run webpack-server (terminal #1)
  3. Run Nodemon with $ npm start (terminal #2)
  4. See localhost:8080 (or with other port you've set in dev.env)

Prod run

  1. Create prod.env (see sample.env) and load it into SHELL via $ . prod.env
  2. Run Webpack via $ npm run webpack (terminal #1)
  3. Run Node with $ npm run node (terminal #2)
  4. See http://yoursite.com:8080 (or with other port you've set in prod.env)

Lint

  1. Run $ npm run eslint -s

Test

  1. Run all tests with $ . .conf-test ; npm mocha -s
  2. Run specific tests with $ . .conf-test ; npm test -- --grep "api/robots POST" -s (-- is an NPM syntax to pass arguments)

Notes

All React starters / tutorials suffer from being oversimplified. They don't show any architecture (the most complex part), only a basic file layouts at their best. TodoApps have similar issues: very specific, single page only, unrealistic models (one field), no backend, no validation, no users, etc. We want to approach this differently – provide application which is closer to production (not saying enterprise) level.

Absolute imports

One of the most annoying NodeJS limitation is the absence of absolute imports. By "absolute" we mean imports relative to the project root or some top-level folder.

Your imports look like import "foo" for libraries but turn into import "../../../../foo"; mess for app code. It's a well known problem because such statements are very hard to read and support. They tend to break every time you move files between folder.

Fortunately absolute imports can be emulated with some amount of twist. The requirement here is to keep IDE navigation and autocompletion features working. Script bin/install add symlinks for every project entry point like frontend or backend in node_modules. Browserify requires to keep package.json for every such entrypoint but Webpack is free of this limitation.

This project is 100% relative-imports free.

Flux vs Baobab

We don't use Flux. Check this and this for a shallow answer to why. See #98 for additional insides.

Immutable

We experimented with most popular libs: ImmutableJS, Mori and Seamless-Immutable. We tried our best, but the resulting code was really messy and bug-prone all the time. So we decided to switch to Ramda which is API incompatible with all of the above. It does not enforce immutability, but encourage it, having zero mutable operations in toolkit.

URL-bound vs URL-unbound components

All stateful components can be divided to URL-bound and URL-unbound. By definition, state of URL-bound components can be changed through URL. It allows to bookmark and share page link and reproduce expectable state by just entring page.

There is no namespacing in URL (we could add one, but URL is rather short for that sort of things, and we want to keep JSON API format in client for simplicity) that's why the possible number of URL-bound components is limited to one per page.

Another tradeoff is that new URL means ReactRouter.run is triggered which means redraw of the Root component which hurts rendering performance ().

To sum up: make primary (content) components either URL-bound or URL-unbound depending on your business priorities. Secondary components will always be URL-unbound.

Links

Wiki contains more information about this project.

Cycle-Ultimate is a newer version of this project built with CycleJS.

react-ultimate's People

Contributors

enalmada avatar ivan-kleshnin avatar mateus1165 avatar rudzainy avatar scabbiaza avatar tacone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-ultimate's Issues

Data fetching

Data fetching can't be implemented within single component which already renders something due to limitations of React hooks. The seemingly standard approach today is to extract data fetching into parent component.

It's very tedious to wrap every component with data-source component manually, but with some toolkit it may be quite easy.

Here is two libraries I found:

https://github.com/ericclemmons/react-resolver
https://github.com/andreypopp/react-async

Second is not yet realeased but I will track it's progress.

Watch for images folder doesn't work

This issue is related to the pathes, look at this commit:
df8f558

After I change path
Gulp.watch("./frontend/images/**/*", ["dist-images"]);
to
Gulp.watch("frontend/images/**/*", ["dist-images"]);

it started working fine, for all cases.

I also added clear task for images, otherwise public/images will contain a lot of unuseful files after some time.

Freeze Bug

Something is wrong with the last version. Check pagination freezes.
Need to discover the cause of this.

CRUD

  • Create / Add
  • Retrieve / Detail
  • Update / Edit
  • Delete / Remove

We use names that are on the right side.
Create should be called Add (because it's more neutral).
DeleteRemove and so on...

Webpack

I was wrong. It's just awesome. I'm going to rewrite everything on it.

Add bower

You said you added this, but I don't see bower.json. How you did install vendors? Manually?

Remove browserify / watchify from gulp

Will require 1-2 additional $ npm run browserify / watchify terminal windows (may use bash script or another npm command to replace those with single dev command?!).
Should simplify gulpfile.js. Should fasten build process.
May resolve problem with missing file changes (which are still occur).

Implement Flow typechecking

As TypeScript is fundamentally incompatible with ES6 and Babel does not support it – it's not suitable for us. I'm going to check Flow. There will be a problems with IDEs, but let's try.

what about this " var " code is "let "???

i clone this repo with "git clone " , when i open gulp file.js , there is

// DEFAULTS ========================================================================================
let exitOnError = false;
process.env.NODE_CONFIG_DIR = process.env.NODE_CONFIG_DIR || "./shared/config";

// IMPORTS =========================================================================================
let ChildProcess = require("child_process");
let Config = require("config");
let Gulp = require("gulp");
let gulpUtil = require("gulp-util");
let runSequence = require("run-sequence");
let jshintStylish = require("jshint-stylish");
let gulpJshint = require("gulp-jshint");
let gulpCached = require("gulp-cached");
let gulpSourcemaps = require("gulp-sourcemaps");
let gulpLess = require("gulp-less");
let gulpConcat = require("gulp-concat");
let gulpRename = require("gulp-rename");
var gulpUglify = require("gulp-uglify");
let gulp6to5 = require("gulp-6to5");
let gulpPlumber = require("gulp-plumber");
let vinylSource = require("vinyl-source-stream");
let vinylBuffer = require("vinyl-buffer");

why ??

and, i find all js missing "var " but " let " there .

Consider Reflux replacement

I'm getting tired of Reflux. They seems to be really lost in what they do. Actions are flawed.

Candidates to watch and replace:
Flummox
Minimal Flux
Rx-Flux
ThunderCats (remix of the prev one)

Both are better then Reflux. I like API of the second one more, but it doesn't support async actions at this moment. It's better to wait a bit and see what will happen next.

Index

  • Basic
  • Filters
  • Sorts
  • Pagination
  • Animation (keep scroll position)
  • Perpage switcher

Warnings in `npm install`

npm WARN package.json Dependency 'glob' exists in both dependencies and devDependencies, using 'glob@^5.0.5' from dependencies
npm WARN package.json Dependency 'gulp-jshint' exists in both dependencies and devDependencies, using 'gulp-jshint@^1.10.0' from dependencies
npm WARN package.json Dependency 'mkdirp' exists in both dependencies and devDependencies, using 'mkdirp@^0.5.0' from dependencies
npm WARN package.json Dependency 'watchify' exists in both dependencies and devDependencies, using 'watchify@^3.1.2' from dependencies

What is vendors.js?

I thought it will contain outer libs like bootstrap and jquery.
But it doesn't.

It contains this:

"frontendVendors": [
    "axios",
    "babel/polyfill",
    "baobab",
    "classnames",
    "node-uuid",
    "util-inspect",
    "immutable",
    "joi",
    "lodash.sortby",
    "lodash.isobject",
    "lodash.isplainobject",
    "lodash.isarray",
    "lodash.isempty",
    "lodash.debounce",
    "lodash.throttle",
    "lodash.result",
    "lodash.merge",
    "lodash.flatten",
    "react",
    "react/addons",
    "react/lib/ReactLink",
    "react-router",
    "react-document-title"
  ],

I don't understand why?

Shouldn't app.js contain react, lodash etc? Is't not duplication?
And current vendors.js is 5M!

Universal components

Extract URL-bound vs URL-unbound specifics from simple component to model components.

More tests

JS bites without static typechecking. Really hope that Flow will help.

Get rid of Joi

We don't want to use 2 validation libraries. Both Joi and Hapi frustrate me a lot.
Usage of Joi on frontend is painful: very big, not frontend-friendly. Official answer is "It was not designed for frontend", but I personally don't see why validation should be backend-only. It's one of the few truly environment-agnostic things. Joi for backend is kinda ok, but still: no changelogs, esoteric error formats, arrogant devs... Time to find something better. Will obsolete #13

Twitter API loader component

Create interface component to load Twitter Frame in timeline

Three basic ways to do this:

  1. Load twitter in new page (with reloading or in new tab).
  2. Open twitter frame above or below the timeline.
  3. Load it in popup.

First way is the simplest but with no usability – we are losing timeline data at least.
Second way is straightforward too, but with good animation between timeline and twitter it can be the solution.
Third way is iffy. From one this term popup has huge negative content, from other side looking on big web applications we can see it's still alive.

Devices support

It's better to get the answer on this question at the beginning. I suppose twitto should work on all modern browsers and modern devices: desktop, laptop, phones.
Key word is "modern" here. Old devices with old browser could not support all javascript that will be necessary for this web app.

Exploring twitter

Can we have one solution for all devices? (ok, for all "modern" devices).
Let's look at the twitter. They have desktop version, and versions for iOS and Android as well.
They also have http://mobile.twitter.com that is work differently on different devices: it looks pretty modern on iPad4, but old on old samsung with android.

Desktop and mobile applications are almost free in their choices.
Mobile version on iPad use ajax, animation etc.
Mobile version on old devices is very limited: any action requires page reloading.

So the answer is – if you want to have "all" devices support, you'll better to start gathering developers from different platforms.

I suppose we are going to create web application in browser. Let's call it "site", to be simple.

Choosing terms: popup, modal, dialog ...

There is a lot of confusions in this terms, because libs and frameworks use their differently.

Bootstrap has modal:
http://getbootstrap.com/javascript/#modals

It often contains header, content and footer, and fills part of the screen with current page content fading.

Google calls it dialog:
https://www.google.com/design/spec/components/dialogs.html

Dialogs inform users about critical information, require users to make decisions, or encapsulate multiple tasks within a discrete process. Use dialogs sparingly because they are interruptive in nature—their sudden appearance forces users to stop their current task and refocus on the dialog content.

Use fullscreen mode or not, it depends from how much information contains the dialog component.

jQuery Mobile has dialog and page elements:
http://demos.jquerymobile.com/1.4.5/transitions/

Dialog is more like confirmation with minimum information in content, similar to modal in bootstrap. Page is similar to fullscreen mode dialog in google guidelines.

I prefer to use jQuery terms.

About transitions

So back to our twitter frame component and third way: Load it in popup.
Because we are going to use Bootstrap framework we can use modal component.
It's simple, quick solution and it has good support:
http://getbootstrap.com/getting-started/#support

But what alternatives do we have?

jQuery Mobile
jQuery Mobile is a HTML5-based user interface system designed to make responsive web sites and apps that are accessible on all smartphone, tablet and desktop devices.

I love this demo:
http://demos.jquerymobile.com/1.4.5/transitions/

To have ability to chose between dialogs and pages and different animation would be great benefit for the project. And they have awesome devices support:
http://jquerymobile.com/gbs/1.4/

But when we will look closer, we will see they still have issues with transitions on some devices.
So if they have, any other will have it.

Can we close the eyes on it? Maybe we could, but developers do not recommend to use Bootstrap and jQuery Mobile together 😕 :
http://stackoverflow.com/questions/18636919/can-i-use-bootstrap-3-together-with-jquery-mobile

But maybe we can take only this transition.js from JQM?
Did you work with jQuery UI before? It's f**king mess from js and css classes. So leave this idea.

Looking on jQuery Mobile alternatives like http://www.sencha.com/, http://goratchet.com/, http://app-framework-software.intel.com/, you will see - they are frameworks for mobile application only.

Effeckt.css
https://github.com/h5bp/Effeckt.css

This lib has 9000 stars on github and it says:
Designing and developing UIs for the mobile web is tricky, but it's extremely difficult to do that while delivering something that performs at 60fps. The best opportunities to getting jank-free transitions on phones/tablets are CSS transition and keyframe animation based, especially tapping into hardware-accelerated transforms and opacity changes.

Yes, let's stick with pure css! I believe in it.

But why demo doesn't work on my mobile devices?
http://h5bp.github.io/Effeckt.css/

Both Chrome and Safari are stucking by trying page load effect. I updated OS version – didn't help.
In Samsung with Android this page even did not load properly.

Codrops
Article from 2013:
http://tympanus.net/Development/PageTransitions/

Looks cool on iPad, doesn't work on Samsung Android, works on Mac Chrome, IE supports only from version 10. WTF?

Summary

I strongly recommend to stick with the bootstrap's modal and do not f**k the brain.
It will not support in old browsers, but we decided we will not support it.

Later I will try to add page effect as in JQM with simplest animation (fade, slide, etc)

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.