Home

Awesome

playground-binding.scala

release FOSSA Status build-status quality-gate-status lines-of-code Maintainability technical-debt Scala Steward badge Analytics

StackShare Scala Scala.js Binding.scala

play

My playground I use for playing with fancy and exciting technologies. This one's for scala, scalajs and binding.scala.

Purpose

The purpose of this playground is to explore, study and assess in the first place the binding.scala library, and secondly scalajs.

The showcases are intended to:

You can view and play the showcases here:

<p align="center"> <a href="https://ccamel.github.io/playground-binding.scala/index.html">View !</a> </p>

Showcases

All the showcases come in a SPA (100% clientside application).

The binding.scala route library is used to enable the navigation and maintain the link between URLs and pages to display.

Calc

Purpose

Calc is a very simple and basic calculator.

<p align="center"> <b>Links:</b><br> <a href="https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/calc">Play</a> | <a href="https://scalafiddle.io/sf/hbwbCOe/0">View Scalafiddle</a> <br><br> <kbd><img src="doc/assets/showcase-calc.png"></kbd> </p>

Implementation details

The model is an immutable case class which holds the state of the calculator. The behaviour is implemented by this model as a partial function which accepts tokens (digit, operators).

The gui maintains the whole model in a single bindable variable, and every graphical element of the calculator (buttons, display) needing to be updated upon model change (reactive dom) is bound to that variable.

Led Matrix

Purpose

The idea under this showcase is to build a virtual matrix of cells, each cell having a color and is independently addressable.

<p align="center"> <b>Links:</b><br> <a href="https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/led-matrix">Play</a> | <a href="https://scalafiddle.io/sf/nXYqFFS/6">View Scalafiddle</a> <br><br> <kbd><img src="doc/assets/showcase-led-matrix.png"></kbd> </p>

Details

The view consists in binding each cell to a dom element (actually a span or an SVG rect) in order to render the surface. As the matrix can have a significant number of cells (~2000), it allows to appreciate the performance of the binding.scala library to handle the situation.

Beside this, some (simple) demos have been implemented that play with the virtual screen. Each demo displays a form which allows to set some parameters whose values are taken in real time.

Loan Calculator

Simple loan calculator which determines the monthly payments on a loan.

<p align="center"> <b>Links:</b><br> <a href="https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/loan-calculator">Play</a> | <a href="https://scalafiddle.io/sf/1RxSQj6/1">View Scalafiddle</a> <br><br> <kbd><img src="doc/assets/showcase-loan-calculator.png"></kbd> </p>

Tree View

Example of a simple tree view implementation with dynamic loading of elements.

<p align="center"> <b>Links:</b><br> <a href="https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/tree-view">Play</a> | <a href="https://scalafiddle.io/sf/KEznYyM/2">View Scalafiddle</a> <br><br> <kbd><img src="doc/assets/showcase-tree-view.png"></kbd> </p>

Details

The model is a simple recursive structure built with Vars (mutable and observable sequence of elements).

The view is bound to the model and react by displaying parts of the tree that have changed.

Drag-me

The Drag-me showcase is quite similar to elm drag but with more features.

It allows the user to select, move and resize a simple rectangle form.

<p align="center"> <b>Links:</b><br> <a href="https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/drag-me">Play</a> | <a href="https://scalafiddle.io/sf/obKiF28/8">View Scalafiddle</a> <br><br> <kbd><img src="doc/assets/showcase-drag-me.png"></kbd> </p>

Details

The model is a simple structure holding both the basic geometric properties of the form (position and size) and the current edition mode (none, moving, resizing).

The view is bound to that model and react to reflect the change (selection, coordinates change, width/height change, etc.).

virtual-list

The virtual-list showcase is quite similar to virtual rendering 1000000 items.

The idea is to use a list that represents a subset of a larger set of data. That list is automatically updated on events (mouse move, drag, key up/down...), and the dom elements bound to the list items are refreshed accordingly.

<p align="center"> <b>Links:</b><br> <a href="https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/virtual-list">Play</a> | <a href="https://scalafiddle.io/sf/JuZsaoP/0">View Scalafiddle</a> <br><br> <kbd><img src="doc/assets/showcase-virtual-list.png"></kbd> </p>

SVG-editor

The SVG-editor showcase is an improvement of the Drag-me showcase using full SVG shapes for drawing.

It allows the user to select, move and resize a simple rectangle form (more to come).

<p align="center"> <b>Links:</b><br> <a href="https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/svg-editor">Play</a> | <br><br> <kbd><img src="doc/assets/showcase-svg-editor.png"></kbd> </p>

Building and Running

The build can be launched with:

sbt fastOptJS dist

Then, open ./dist/index.html file in your browser.

Technologies

scala-logo

scalajs-logo

binding.scala-logo

materializecss-logo

fontawesome-logo

License

MIT © Chris Camel

FOSSA Status