Search in sources :

Example 6 with Icon

use of com.vaadin.flow.component.icon.Icon in project flow-components by vaadin.

the class IconView method createClickableIconsView.

private void createClickableIconsView() {
    Div message = new Div();
    Icon logoV = new Icon(VaadinIcon.VAADIN_V);
    logoV.getStyle().set("cursor", "pointer");
    logoV.addClickListener(event -> message.setText("The VAADIN_V icon was clicked!"));
    Icon logoH = new Icon(VaadinIcon.VAADIN_H);
    logoH.getStyle().set("cursor", "pointer");
    logoH.addClickListener(event -> message.setText("The VAADIN_H icon was clicked!"));
    addCard("Clickable icons", new HorizontalLayout(logoV, logoH), message);
    logoV.setId("clickable-v-icon");
    logoH.setId("clickable-h-icon");
    message.setId("clickable-message");
}
Also used : Div(com.vaadin.flow.component.html.Div) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 7 with Icon

use of com.vaadin.flow.component.icon.Icon in project flow-components by vaadin.

the class ButtonTest method textIconAndEventCtor.

@Test
public void textIconAndEventCtor() {
    Icon icon = new Icon();
    button = new Button("foo", icon, event -> {
    });
    Assert.assertEquals("foo", button.getText());
    Assert.assertEquals(icon, button.getIcon());
}
Also used : Text(com.vaadin.flow.component.Text) StateNode(com.vaadin.flow.internal.StateNode) ButtonVariant(com.vaadin.flow.component.button.ButtonVariant) Set(java.util.Set) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HashMap(java.util.HashMap) Test(org.junit.Test) Serializable(java.io.Serializable) Button(com.vaadin.flow.component.button.Button) Element(com.vaadin.flow.dom.Element) Assert(org.junit.Assert) Icon(com.vaadin.flow.component.icon.Icon) ElementAttributeMap(com.vaadin.flow.internal.nodefeature.ElementAttributeMap) Button(com.vaadin.flow.component.button.Button) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) Test(org.junit.Test)

Example 8 with Icon

use of com.vaadin.flow.component.icon.Icon in project flow-components by vaadin.

the class ButtonTest method setText.

@Test
public void setText() {
    button = new Button("foo", new Icon());
    button.setText(null);
    Assert.assertEquals("", button.getText());
    button.setText("bar");
    Assert.assertEquals("bar", button.getText());
    button.setText("");
    Assert.assertEquals("", button.getText());
}
Also used : Button(com.vaadin.flow.component.button.Button) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) Test(org.junit.Test)

Example 9 with Icon

use of com.vaadin.flow.component.icon.Icon in project flow-components by vaadin.

the class ButtonTest method updatingThemeAttribute.

@Test
public void updatingThemeAttribute() {
    button = new Button();
    assertButtonHasNoThemeAttribute();
    button.setIcon(new Icon());
    assertButtonHasThemeAttribute(THEME_ATTRIBUTE_ICON);
    button.setText("foo");
    assertButtonHasNoThemeAttribute();
    button.setIcon(null);
    assertButtonHasNoThemeAttribute();
    button = new Button("foo", new Icon());
    assertButtonHasNoThemeAttribute();
    button.setText("");
    assertButtonHasThemeAttribute(THEME_ATTRIBUTE_ICON);
    button = new Button("foo", new Icon());
    button.setText(null);
    assertButtonHasThemeAttribute(THEME_ATTRIBUTE_ICON);
    // don't override explicitly set theme-attribute
    button = new Button();
    button.getElement().setAttribute(THEME_ATTRIBUTE, THEME_ATTRIBUTE_PRIMARY);
    assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
    button.setIcon(new Icon());
    assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
    button.setText("foo");
    assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
    button.setIcon(null);
    assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
    button.setText(null);
    assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
}
Also used : Button(com.vaadin.flow.component.button.Button) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) Test(org.junit.Test)

Example 10 with Icon

use of com.vaadin.flow.component.icon.Icon in project flow-components by vaadin.

the class ButtonTest method setText_slotAttributeIsPreserved.

@Test
public void setText_slotAttributeIsPreserved() {
    button = new Button();
    button.setText("foo");
    Icon icon = new Icon(VaadinIcon.BULLSEYE);
    icon.getElement().setAttribute("slot", "prefix");
    button.setIcon(icon);
    button.setText("bar");
    Assert.assertEquals("prefix", icon.getElement().getAttribute("slot"));
}
Also used : Button(com.vaadin.flow.component.button.Button) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) Test(org.junit.Test)

Aggregations

Icon (com.vaadin.flow.component.icon.Icon)110 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)94 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)46 Button (com.vaadin.flow.component.button.Button)39 Span (com.vaadin.flow.component.html.Span)21 Div (com.vaadin.flow.component.html.Div)19 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)18 Tab (com.vaadin.flow.component.tabs.Tab)16 Text (com.vaadin.flow.component.Text)15 Test (org.junit.Test)12 EnhancedButton (org.komunumo.ui.component.EnhancedButton)12 Grid (com.vaadin.flow.component.grid.Grid)10 RouterLink (com.vaadin.flow.router.RouterLink)9 Notification (com.vaadin.flow.component.notification.Notification)8 Component (com.vaadin.flow.component.Component)7 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)7 Anchor (com.vaadin.flow.component.html.Anchor)7 TextField (com.vaadin.flow.component.textfield.TextField)7 UI (com.vaadin.flow.component.UI)6 StreamResource (com.vaadin.flow.server.StreamResource)6