https://github.com/openmole/scaladget
Scala lib for generating javascript widgets
https://github.com/openmole/scaladget
Last synced: about 2 months ago
JSON representation
Scala lib for generating javascript widgets
- Host: GitHub
- URL: https://github.com/openmole/scaladget
- Owner: openmole
- License: agpl-3.0
- Created: 2014-06-11T15:16:38.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-10-14T14:56:52.000Z (over 1 year ago)
- Last Synced: 2025-05-20T14:08:19.712Z (about 1 year ago)
- Language: CSS
- Size: 1.48 MB
- Stars: 46
- Watchers: 8
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
scaladget
=========
Scaladget provides a scala facades of some famous javascript libraries. It relies on the [scala-js](http://www.scala-js.org/) project. Among them:
* [Bootstrap-native.js](https://thednp.github.io/bootstrap.native/)
* [Sortable.js](http://rubaxa.github.io/Sortable/)
* [Ace Editor](http://ace.c9.io)
* [Bootstrap-slider](http://seiyria.com/bootstrap-slider/)
* [Lunr](https://lunrjs.com/)
## Usage ##
Just add this to your dependencies:
```sh
libraryDependencies += "org.openmole.scaladget" %%% "bootstrapnative" % scaladgetVersion
libraryDependencies += "org.openmole.scaladget" %%% "ace" % scaladgetVersion
libraryDependencies += "org.openmole.scaladget" %%% "bootstrapslider" % scaladgetVersion
libraryDependencies += "org.openmole.scaladget" %%% "lunr" % scaladgetVersion
```
Current version : see release tags section
All the facades are intensively used in the [OpenMOLE project](https://github.com/openmole/openmole).
## Bootstrap-native library ##
[Demo](http://zebulon.iscpif.fr/~leclaire/scaladget/)
The boostrap-native facade (based on [https://thednp.github.io/bootstrap.native/](http://zebulon.iscpif.fr/~leclaire/scaladget/)) renders transparent the use of buttons, forms, modals, tables, collapsers, selectors etc...
Imports:
```scala
import scaladget.bootstrapnative.bsn._
```
Here is an example of bootstrap modal dialog creation in full scala:
```scala
import scalatags.JsDom.tags
// Create the Modal dialog
val modalDialog: ModalDialog =
ModalDialog(
onopen = ()=> println("OPEN"),
onclose = ()=> println("CLOSE")
)
// Append header, body, footer elements
modalDialog header div("Header")
modalDialog footer buttonGroup()(
ModalDialog.closeButton(modalDialog, btn_info, "OK"),
ModalDialog.closeButton(modalDialog, btn_default, "Cancel")
)
// Build the dialog and the modal dialog
tags.span(
modalDialog.dialog,
button("Modal !", onclick := {() => modalDialog.show}, btn_primary, marginLeft := 5),
tags.span(glyph_settings, paddingLeft := 5, pointer, onclick := {()=> modalDialog.show})
```

And here an example for a dynamic collapser:
```scala
buttonIcon("Trigger !", btn_primary).expandOnclick(panel("My text in detail")(width := 400))
```


Find more examples on the: [API Demo](http://zebulon.iscpif.fr/~leclaire/scaladget/)
Here is an example of scaladget intensive use in the [OpenMOLE project](https://github.com/openmole/openmole/blob/master/openmole/gui/client/org.openmole.gui.client.core/src/main/scala/org/openmole/gui/client/core/ScriptClient.scala)
## Bootstrap-slider library ##
See rendering in the [API Demo](http://zebulon.iscpif.fr/~leclaire/scaladget/)

## SVG rendering ##
A SVG API for rendering typed path in SVG is provided. it is compatible with [scalatags](https://github.com/lihaoyi/scalatags).
See a simple example [here](http://zebulon.iscpif.fr/~leclaire/scaladget/svg.html)

An example using the scaladget SVG tool and reactive library [Laminar](https://laminar.dev/) can be found in this [demo](http://zebulon.iscpif.fr/~leclaire/scaladget/flowchart.html).
It reproduces this [D3 flowchart](http://bl.ocks.org/cjrd/6863459).
