Search in sources :

Example 6 with Style

use of com.vaadin.flow.dom.Style in project flow by vaadin.

the class ElementTest method styleGetNamesDashAndCamelCase.

@Test
public void styleGetNamesDashAndCamelCase() {
    Element element = ElementFactory.createDiv();
    Style style = element.getStyle();
    style.set("borderColor", "blue");
    style.set("border-foo", "bar");
    List<String> styles = style.getNames().collect(Collectors.toList());
    Assert.assertEquals(2, styles.size());
    Assert.assertTrue(styles.contains("border-color"));
    Assert.assertTrue(styles.contains("border-foo"));
}
Also used : Element(com.vaadin.flow.dom.Element) Style(com.vaadin.flow.dom.Style) Test(org.junit.Test)

Example 7 with Style

use of com.vaadin.flow.dom.Style in project flow by vaadin.

the class ElementTest method getUnsetStyle.

@Test
public void getUnsetStyle() {
    Element e = ElementFactory.createDiv();
    Style s = e.getStyle();
    Assert.assertNull(s.get("foo"));
}
Also used : Element(com.vaadin.flow.dom.Element) Style(com.vaadin.flow.dom.Style) Test(org.junit.Test)

Example 8 with Style

use of com.vaadin.flow.dom.Style in project flow by vaadin.

the class ElementTest method replaceStyle.

@Test
public void replaceStyle() {
    Element e = ElementFactory.createDiv();
    Style s = e.getStyle();
    s.set("foo", "bar");
    s.set("foo", "baz");
    Assert.assertEquals("baz", s.get("foo"));
}
Also used : Element(com.vaadin.flow.dom.Element) Style(com.vaadin.flow.dom.Style) Test(org.junit.Test)

Example 9 with Style

use of com.vaadin.flow.dom.Style in project flow by vaadin.

the class ElementTest method useCustomPropertyStyle.

@Test
public void useCustomPropertyStyle() {
    Element element = ElementFactory.createDiv();
    Style style = element.getStyle();
    style.set("color", "var(--some-var)");
    Assert.assertEquals("var(--some-var)", style.get("color"));
}
Also used : Element(com.vaadin.flow.dom.Element) Style(com.vaadin.flow.dom.Style) Test(org.junit.Test)

Example 10 with Style

use of com.vaadin.flow.dom.Style in project flow by vaadin.

the class ElementTest method setStyle.

public void setStyle() {
    Element e = ElementFactory.createDiv();
    Style s = e.getStyle();
    s.set("foo", "bar");
    Assert.assertEquals("bar", s.get("foo"));
}
Also used : Element(com.vaadin.flow.dom.Element) Style(com.vaadin.flow.dom.Style)

Aggregations

Style (com.vaadin.flow.dom.Style)22 Element (com.vaadin.flow.dom.Element)20 Test (org.junit.Test)17 Text (com.vaadin.flow.component.Text)1 Div (com.vaadin.flow.component.html.Div)1 Input (com.vaadin.flow.component.html.Input)1 NativeButton (com.vaadin.flow.component.html.NativeButton)1 ElementFactory (com.vaadin.flow.dom.ElementFactory)1 StateNode (com.vaadin.flow.internal.StateNode)1 ElementStylePropertyMap (com.vaadin.flow.internal.nodefeature.ElementStylePropertyMap)1 Route (com.vaadin.flow.router.Route)1 Registration (com.vaadin.flow.shared.Registration)1 ViewTestLayout (com.vaadin.flow.uitest.servlet.ViewTestLayout)1 JsonObject (elemental.json.JsonObject)1 Set (java.util.Set)1