use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.
the class AdvancedFormsViewImpl method initSuggestBoxExample.
@SampleMethod
private void initSuggestBoxExample() {
LocalSuggestBoxStore<String> localStore = LocalSuggestBoxStore.<String>create().addSuggestion(SuggestItem.create("Schroeder Coleman")).addSuggestion(SuggestItem.create("Renee Mcintyre")).addSuggestion(SuggestItem.create("Casey Garza"));
TextBox friendNameBox = TextBox.create("Your friend name").setHelperText("Add friend name as suggestion");
KeyboardEvents.listenOnKeyDown(friendNameBox).onEnter(evt -> {
localStore.addSuggestion(SuggestItem.create(friendNameBox.getValue()));
friendNameBox.clear();
});
suggestBoxCard.setBodyPaddingTop("40px").appendChild(Row.create().appendChild(Column.span6().appendChild(BlockHeader.create("Local suggest store")))).appendChild(Row.create().appendChild(Column.span4().appendChild(friendNameBox)).appendChild(Column.span2().appendChild(Button.createPrimary(Icons.ALL.add()).setContent("ADD FRIEND").addClickListener(evt -> {
localStore.addSuggestion(SuggestItem.create(friendNameBox.getValue()));
friendNameBox.clear();
})))).appendChild(Row.create().appendChild(Column.span12().appendChild(SuggestBox.create("Your friends", localStore).setHelperText("Type any letter and see suggestions"))));
SuggestBoxStore<String> dynamicStore = new SuggestBoxStore<String>() {
@Override
public void filter(String searchValue, SuggestionsHandler<String> suggestionsHandler) {
DomGlobal.fetch("https://restcountries.com/v2/all?fields=name").then(Response::text).then(json -> {
List<SuggestItem<String>> suggestItems = new ArrayList<>();
JsArray<JsPropertyMap<String>> randomNames = Js.cast(Global.JSON.parse(json));
for (int i = 0; i < randomNames.length; i++) {
JsPropertyMap<String> nameProperties = randomNames.getAt(i);
if (nameProperties.get("name").toLowerCase().contains(searchValue.toLowerCase())) {
SuggestItem suggestItem = SuggestItem.create(nameProperties.get("name"));
suggestItems.add(suggestItem);
}
}
suggestionsHandler.onSuggestionsReady(suggestItems);
return null;
});
}
@Override
public void find(String searchValue, Consumer<SuggestItem<String>> handler) {
DomGlobal.fetch("https://restcountries.com/v2/all?fields=name").then(Response::text).then(json -> {
JsArray<JsPropertyMap<String>> randomNames = Js.cast(Global.JSON.parse(json));
for (int i = 0; i < randomNames.length; i++) {
JsPropertyMap<String> nameProperties = randomNames.getAt(i);
if (nameProperties.get("name").equals(searchValue)) {
SuggestItem suggestItem = SuggestItem.create(nameProperties.get("name"));
handler.accept(suggestItem);
return null;
}
}
return null;
});
}
};
suggestBoxCard.appendChild(Row.create().appendChild(Column.span12().appendChild(BlockHeader.create("Dynamic suggest store")))).appendChild(Row.create().appendChild(Column.span12().appendChild(SuggestBox.create("Country", dynamicStore))));
}
use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.
the class LabelsViewImpl method initLabels.
@SampleMethod
private void initLabels() {
Column column = Column.span(1, 2, 6, 12);
element.appendChild(Card.create("LABELS").appendChild(Row.create().addColumn(column.copy().appendChild(Label.createDefault("DEFAULT").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createPrimary("PRIMARY").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createSuccess("SUCCESS").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createInfo("INFO").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createWarning("WARNING").style().setMargin("10px"))).addColumn(column.copy().appendChild(Label.createDanger("DANGER").style().setMargin("10px")))).appendChild(Elements.hr()).appendChild(Elements.h(1).style("text-align: left;").textContent("Example heading ").add(Label.createDanger("New"))).appendChild(Elements.h(2).textContent("Example heading ").add(Label.createWarning("New"))).appendChild(Elements.h(3).textContent("Example heading ").add(Label.createInfo("New"))).appendChild(Elements.h(4).textContent("Example heading ").add(Label.createSuccess("New"))).appendChild(Elements.h(5).textContent("Example heading ").add(Label.createPrimary("New"))).appendChild(Elements.h(6).textContent("Example heading ").add(Label.createDefault("New"))).element());
}
use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.
the class FormsValidationsViewImpl method initIcons.
@SampleMethod
private void initIcons() {
Icon cancel = Icons.ALL.cancel();
TextBox username = TextBox.create("Username").addLeftAddOn(Icons.ALL.account_circle()).addRightAddOn(cancel);
cancel.addClickListener(evt -> username.clear()).style().setCursor("pointer");
HTMLElement showIcon = Icons.ALL.remove_red_eye().clickable().style().setCursor("pointer").element();
TextBox password = TextBox.password("Password").addLeftAddOn(Icons.ALL.https().element()).addRightAddOn(showIcon);
showIcon.addEventListener("mousedown", evt -> password.getInputElement().element().type = "text");
showIcon.addEventListener("mouseup", evt -> password.getInputElement().element().type = "password");
Icon info = Icons.ALL.info();
Tooltip.create(info, "All system pages will be shown in the selected language");
iconsCard.appendChild(username).appendChild(password).appendChild(TextArea.create("Description").addLeftAddOn(Icons.ALL.description())).appendChild(Select.<String>create("Language").addLeftAddOn(Icons.ALL.language()).addRightAddOn(info).appendChild(SelectOption.create("english", "English")).appendChild(SelectOption.create("france", "France")).appendChild(SelectOption.create("arabic", "Arabic")));
}
use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.
the class LoadersViewImpl method sample.
@SampleMethod
private void sample() {
Card card = Card.create("Loaders", "loader sample");
Button button = Button.createDefault("CLICK ME").addClickListener(evt -> {
Loader loader = Loader.create(card.element(), LoaderEffect.PULSE).setLoadingText("Loading ...").start();
new Timer() {
@Override
public void run() {
loader.stop();
}
}.schedule(7000);
});
card.appendChild(TextNode.of(SAMPLE_CONTENT)).appendChild(Elements.br()).appendChild(Elements.br()).appendChild(Elements.div().attr("style", "text-align: center").add(button));
}
use of org.dominokit.domino.SampleMethod in project domino-ui-demo by DominoKit.
the class WavesViewImpl method sample.
@SampleMethod
private void sample() {
HTMLElement element = div().element();
WavesSupport.addFor(element).setWaveColor(WaveColor.YELLOW).applyWaveStyle(WaveStyle.CIRCLE);
}
Aggregations