Search in sources :

Example 16 with Style

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

the class ElementTest method assertClientStyleKey.

private void assertClientStyleKey(String sentToClient, String setUsingStyleApi) {
    Element element = ElementFactory.createDiv();
    StateNode stateNode = element.getNode();
    ElementStylePropertyMap map = stateNode.getFeature(ElementStylePropertyMap.class);
    Style style = element.getStyle();
    style.set(setUsingStyleApi, "foo");
    Assert.assertEquals("foo", style.get(setUsingStyleApi));
    Assert.assertEquals(sentToClient, map.getPropertyNames().toArray()[0]);
    Assert.assertEquals("foo", map.getProperty(sentToClient));
}
Also used : ElementStylePropertyMap(com.vaadin.flow.internal.nodefeature.ElementStylePropertyMap) Element(com.vaadin.flow.dom.Element) StateNode(com.vaadin.flow.internal.StateNode) Style(com.vaadin.flow.dom.Style)

Example 17 with Style

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

the class ElementTest method getSingleStyleAsAttribute.

@Test
public void getSingleStyleAsAttribute() {
    Element e = ElementFactory.createDiv();
    Style s = e.getStyle();
    s.set("border", "1px solid black");
    Assert.assertTrue(e.hasAttribute("style"));
    Assert.assertEquals("border:1px solid black", e.getAttribute("style"));
}
Also used : Element(com.vaadin.flow.dom.Element) Style(com.vaadin.flow.dom.Style) Test(org.junit.Test)

Example 18 with Style

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

the class ElementTest method dashSeparatedGetStyle.

@Test
public void dashSeparatedGetStyle() {
    Element element = ElementFactory.createDiv();
    Style style = element.getStyle();
    style.set("borderColor", "blue");
    style.set("border-foo", "bar");
    Assert.assertEquals("blue", style.get("border-color"));
    Assert.assertEquals("bar", style.get("border-foo"));
}
Also used : Element(com.vaadin.flow.dom.Element) Style(com.vaadin.flow.dom.Style) Test(org.junit.Test)

Example 19 with Style

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

the class ElementTest method dashSeparatedSetStyle.

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

Example 20 with Style

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

the class ElementTest method removeStyleAttribute.

@Test
public void removeStyleAttribute() {
    Element element = ElementFactory.createDiv();
    Style style = element.getStyle();
    style.set("border", "1px solid green");
    element.removeAttribute("style");
    Assert.assertEquals(0, style.getNames().count());
}
Also used : Element(com.vaadin.flow.dom.Element) Style(com.vaadin.flow.dom.Style) Test(org.junit.Test)

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