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");
}
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());
}
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());
}
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);
}
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"));
}
Aggregations