Skip to main content

module salix::util::WithPopups

rascal-0.40.17
salix-core-0.2.7

Usage

import salix::util::WithPopups;

Source code

http://github.com/usethesource/salix-core/src/main/rascal/salix/util/WithPopups.rsc

Dependencies

import salix::App;
import salix::HTML;
import salix::Core;
import salix::Index;
import salix::Node;
import salix::demo::basic::Counter;
import Node;
import List;

alias Popups

lrel[str selector, Popup popup]

Mapping CSS selectors to Popup values

data Popup

data Popup  
= popup(str text, Placement placement = \auto()
, list[Modifier] modifiers = []
, Strategy strategy = fixed())
;

A Popup has a literal text``, a placementdefaulting toauto()and placementstrategydefaulting tofixed(). In the future we want to support arbitrary HTML in text`.

data Placement

data Placement  
= \auto()
| \auto-start()
| \auto-end()
| \top()
| \top-start()
| \top-end()
| \bottom()
| \bottom-start()
| \bottom-end()
| \right()
| \right-start()
| \right-end()
| \left()
| \left-start()
| \left-end()
;

Data type encoding PopperJS positions of the tooltip. (see here https://popper.js.org/docs/v2/constructors/).

data Strategy

data Strategy  
= absolute()
| fixed()
;

function withPopupsWeb

App[&T] withPopupsWeb(Popups popups, &T appModel, void(&T) appView, str title
, str extraCss=DEFAULT_CSS, list[str] css=[], list[str] scripts=[])

Run a Salix app view function appView on a model value appModel and decorate the resulting page with popups/tooltips according popups, which is a list relation mapping CSS selectors (strings) to Popup values (see above). This function is primarily intended for creating explanatory screenshots for documentation or slide decks. The resulting page view is not interactive anymore; events are simply ignored.

function withPopups

SalixApp[&T] withPopups(Popups popups, &T appModel, void(&T) appView, str title
, str extraCss=DEFAULT_CSS, list[str] css=[], list[str] scripts=[], str id = "root")

function withPopupView

void withPopupView(Popups popups, &T model, void(&T) appView, str css)

function testWithCounter

App[Model] testWithCounter()