Coder Social home page Coder Social logo

sk-stock-test's Introduction

Stock Katalogue

Example stock application built using React, ES2015/Babel and Webpack.

Installation

Ensure npm is installed. You may also need to install Webpack globally with npm install -g webpack.

Clone the repo and run npm install.

npm build will output the app to /dist.

Run a local server inside /dist to play with the app. I recommend python -m SimpleHTTPServer and visting your localhost on the reported port number.

Development

I haven't bothered with a full tooling setup for this demo. Webpack is used for JSX, Babel and uglify/compress transformation, but I have avoided a full Gulp workflow in favour of minimal npm scripts for autoprefixing, SCSS compilation and file output. See package.json.

Notes

I considered using Flux/Redux architecture for the application but ran with standard props/state to keep things more straightforward. Obviously for scalability purposes I would want to refactor and add a Flux type setup with actions for adding stock etc.

The initial data is passed as a prop to the App component and is then passed down to the StockList - hydration could be performed here, either as a bootstrapped and rendered tag in the HTML payload, or via an XHR request on load.

I relied upon HTML5 native inputs in the AddStockForm component for basic validation and user feedback. I was tempted to build out custom components for a more consistent/richer UX but elected to keep things basic. The date picker UI is decent on Chrome/Webkit but varies wildly in other user agents.

The StockList component is read-only and could easily be extended with edit and delete actions. I relied on componentDidMount() with passed-in key ordering to ensure the list renders properly when performing CSS 'new row added' effects. Need to investigate the peformance implications of key use. I also used the product name as a key which will obviously break if duplicates are involved.

CSS styling has been provided with a basic SCSS file for the entire app. I didn't want to add Bootstrap/Material and bloat things out further. Added classNames to the App subcomponents in order to hook into them. In production I would want to inline the critical styles in the <head> of the page in order to reduce load times.

Speaking of progressive enhancement, an approach I want to explore is rendering a basic HTML 'app shell' from the server, then rendering the React app into its containers once loaded. In this app, the <header> and placeholders for the two main components could have been rendered up-front, with spinners/tombstoning in place. Planning to develop this approach in the future.

Unfortunately I didn't have time to provide unit tests, please forgive me. :)

sk-stock-test's People

Contributors

njmcode avatar njmcode-rehab avatar

Watchers

 avatar  avatar

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.