GithubHelp home page GithubHelp logo

kiichi / riotjs4-examples Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 3.0 2.07 MB

Riot 4 Sample Project: Riot + Axios + Akita + Navigo + Bootstrap

Home Page: https://kiichi.github.io/riotjs4-examples/

HTML 45.96% JavaScript 54.04%
riotjs boilerplate sample-app examples akita navigo navigojs axios bootstrap4 es6

riotjs4-examples's Introduction

Riot 4 Examples

This is a sample project using Riot 4 which you need only browser to compile. I use all range of frameworks depend on my purpose. For most of my internal company projects don't require heavy lifting frameworks with Node to transpile; such as, Vue, Angular, or React. Having said that, I cannot go back too basic, e.g. only jQuery, in order to avoid chaotic situation in the future.

The best part of Riot is that it compiles on the browser, and it supports all modern component based UI mechanism with reasonable learning curve. This is very useful for me because I have to split tasks with other team members in different skill levels.

"Understand and stay way of cargo cult" - Julio Biason .Net 4.0 - Things I Learnt The Hard Way (in 30 Years of Software Development)

Demo

Demo Site - Type any username and password to login

Stack

  1. Bootstrap 4 and SB Admin 2 - CSS Template and Design
  2. Riot 4 - Componet based UI Library
  3. Akita 4 - State Management CDN
  4. Axios 0.19.0 - HTTP
  5. Navigo 6 - Routing

I carefully selected other components to fit Riot's theme ... minimalistic but mature enough. They are not random gathering from github.

Running

you can use any http server on your machine. Clone this repo then

npm i -g live-server

Then

live-server

or for python user

python3 -m http.server

Implementation

You can login using any credentials (type anyting in username and password). All dummy data files are located under /api/ folder.

I saved external libraries under /vendor/. This is because I hate some minor update of those libraries break the current setup; however, most of case, you don't have to save those files, just directly link to from the CDN (even simpler).

I was also playing around with Akita since I was watching this from last year as replacement of redux. Using Akita, I implemented a breadcrumb which you can push some items, and pop when you go back. Try to click "Friends" section of details page.

sample.png (600ร—312)

Those files are pre-compiled production files, please ignore them:

  • js/app.js
  • index-prod.html

For more details, please see the next section.

Self Compiler Button (Compile Me!)

You might be wondering "Compile Me!" button at the bottom right corner. This is a conventional button to export single script file which contains pre-compileed riot tags, and clean up index.html script tag in your browser without need of command line tools.

For production deployment, I copy all assets without tags, and I deploy only index.html and app.js. Most of case, I simply deploy app.js unless I change css or images.

You can see the production version in js/app.js and index-prod.html.

Total duration load is 220ms (18 requests), and this is good improvement compare to development version, 550ms (29 requests). Please note that this feature is still experimental. Remove <compile-me> tag if you don't need.

compile-me.png

<compile-me></compile-me>

or you can specify parameters

<compile-me title="Developer Tools" entry-tag="tags/app.html" dist-path="js/app.js" version="1.0.0"></compile-me>

Attributes:

  • title= ... - You can specify the title of this button (Default "Compile Me!")
  • entry-tag=... - pass the entry tag name. (Default "app.html")
  • dist-path=... - specify target file path (Default "js/app.js")
  • version=... - specify version number if you need to embed something in comment line. (Default generated time epoch)

Known issue

Note: somehow left side of this statement below returns null if subscribe contains this.update inside. it works if it assigns it to a temp variable, then attach it to the state in separate line. See onMounted event in each component

const sub = this.query.select('list').subscribe(list => {
    this.update({list:list})
});
this.state.subscription = sub;

Reference

General References

My Riot4 Examples

  • Parent / Child - Using "is" syntac, created a simple nested tags. It's Base component and dynamically switching inner components.

Variations

Other Riot4 projects

Other interesting stuff

riotjs4-examples's People

Contributors

kiichi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.