use of com.vaadin.flow.dom.Style in project flow by vaadin.
the class BasicComponentView method onShow.
@Override
protected void onShow() {
getElement().getStyle().set("margin", "1em");
getElement().setAttribute("id", "root");
Text text = new Text(TEXT);
Input input = new Input();
input.setPlaceholder("Synchronized on change event");
NativeButton button = new NativeButton(BUTTON_TEXT, e -> {
Div greeting = new Div();
greeting.addClassName("thankYou");
String buttonText = e.getSource().getElement().getText();
greeting.setText("Thank you for clicking \"" + buttonText + "\" at (" + e.getClientX() + "," + e.getClientY() + ")! The field value is " + input.getValue());
greeting.addClickListener(e2 -> remove(greeting));
add(greeting);
});
Div helloWorld = new Div();
helloWorld.setText(DIV_TEXT);
helloWorld.addClassName("hello");
helloWorld.setId("hello-world");
helloWorld.addClickListener(e -> {
helloWorld.setText("Stop touching me!");
helloWorld.getElement().getClassList().clear();
});
Style s = helloWorld.getElement().getStyle();
s.set("color", "red");
s.set("fontWeight", "bold");
add(text, helloWorld, button, input);
}
use of com.vaadin.flow.dom.Style in project flow by vaadin.
the class StyleAttributeHandler method setAttribute.
@Override
public void setAttribute(Element element, String attributeValue) {
Style style = element.getStyle();
style.clear();
parseStyles(attributeValue).forEach(style::set);
}
use of com.vaadin.flow.dom.Style in project flow by vaadin.
the class ElementTest method getMultipleStylesAsAttribute.
@Test
public void getMultipleStylesAsAttribute() {
Element e = ElementFactory.createDiv();
Style s = e.getStyle();
s.set("border", "1px solid black");
s.set("margin", "1em");
Assert.assertTrue(e.hasAttribute("style"));
assertEqualsOne(new String[] { "border:1px solid black;margin:1em", "margin:1em;border:1px solid black" }, e.getAttribute("style"));
}
use of com.vaadin.flow.dom.Style in project flow by vaadin.
the class ElementTest method customPropertyStyle.
@Test
public void customPropertyStyle() {
Element element = ElementFactory.createDiv();
Style style = element.getStyle();
style.set("--some-variable", "foo");
Assert.assertEquals("foo", style.get("--some-variable"));
}
use of com.vaadin.flow.dom.Style in project flow by vaadin.
the class ElementTest method removeSingleStyle.
@Test
public void removeSingleStyle() {
Element e = ElementFactory.createDiv();
Style s = e.getStyle();
s.set("foo", "bar");
s.remove("foo");
Assert.assertEquals(null, s.get("foo"));
}
Aggregations