Code Monkey home page Code Monkey logo

ui-code-challenge's Introduction

UI Code Challenge

An [email protected] ES6 starter app

What is this?

This repo was originally created as a code challenge for a job interview. It also serves as a boilerplate project for Angular 1.5 in ECMAScript 2015 (ES6). It uses Gulp to orchestrate builds, incorporating Webpack behind the scenes. No, this is not an oxymoron. Gulp and Webpack are better together (and Webpack is a thousand times faster than Browserify)!

But I digress. Let's build this thing.

Dependencies

  • Node v6.x or later (We are using ES6 after all)

Installation

git clone https://github.com/alfonsogoberjr/ui-code-challenge.git
cd ui-code-challenge && npm install

And start with

npm start

Navigate to http://localhost:5000 and you will be redirected to /menu.

This is a fictional bakery

/menu is the only route included - but you can add more by following the example of client/js/src/components/menu. Just duplicate that folder and change the names and references. Don't forget to import any new components into client/js/src/main.js also.

The bakery menu was specified by the challenge - and it's a great way to demonstrate Angular in action with ES6 on both client and server. You could also empty out the client/ folder entirely and add your own structure for React or choo - whatever floats your boat.

As a side note: Daria is my aunt's name. She always made great cookies. It's also the name of a really cool show from the 90's.

Customization

A few noteworthy files and directories come to mind:

  • .env will set your environment variables without needing to export. It's optional, but handy for development. Remember not to commit this file if you add any sensitive data like API keys, client secrets, etc. And do not use it in production!
  • server/index.js contains the server-side app configuration. It uses a handy little module called paquet, which I also wrote. All it does is bootstrap a Koa app behind the scenes with some nice-to-have-but-annoying-to-write defaults. Routes and middleware are contained in server/routes.js and server/middleware.js, respectively. Remember that Koa only accepts generators as middleware!
  • client/js/src contains all of the Angular source code. Import/export files using ES6 import and export. This is handy because normally you need to include 3rd-party dependencies (like lodash, for example) via clumsily creating new services and grabbing the libs from the window object. No longer, friend. Your FE deps are free at last, and you didn't even need Bower (everything is loaded directly from node_modules). Yay modularity! Everything is compiled by Webpack into client/js/bundle.min.js.
  • client/styles/src contains the SASS files, per challenge requirements. These are also compiled into CSS automatically by Webpack and added to client/js/bundle.min.js.

Notes

  • The challenge said I could use server-side filtering, but I opted instead for client-side filtering of the inventory. With a large-enough payload, pagination and server-side (query-string) filtering would undoubtedly be necessary.
  • I added an extra property type on the inventory data in order to facilitate the filtering UI.
  • You can filter multiple types at once by clicking multiple boxes in the menu. They're toggle buttons, so clicking them again will remove them from the filter mechanism.
  • Style elements are not directly handled by gulp, because (as mentioned earlier) Webpack is just so much faster than any alternatives. Gulp, however, still makes sense as a task runner, and Webpack is just one of the tasks it runs.
  • Gulp also runs apiDoc to automatically generate docs from the source comments in server/routes.js. You can see the docs at http://localhost:5000/docs.
  • There is built-in auto-reload functionality that I developed myself; instead of using WebSockets it establishes a simple chunked HTTP response which, when broken, triggers a refresh. When you save a file, it triggers Nodemon (via gulp task) to restart, which disconnects the server and triggers a browser refresh. It also means that the page will reload every so often during development; usually around every few minutes or so.

ui-code-challenge's People

Watchers

 avatar  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.