Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
Add theme variant demo and tests (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZheSun88 authored and SomeoneToIgnore committed Jul 18, 2018
1 parent 59cf586 commit 4e3474a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.vaadin.flow.component.ClickEvent;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.button.GeneratedVaadinButton;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.icon.Icon;
Expand All @@ -40,6 +42,7 @@ public void initView() {
createImageButtonWithAccessibleLabel();
createButtonsWithTabIndex();
createDisabledButton();
addVariantsFeature();

message = new Div();
message.setId("buttonMessage");
Expand Down Expand Up @@ -143,6 +146,20 @@ private void createDisabledButton() {
button.setId("disabled-button");
}

private void addVariantsFeature() {
// begin-source-example
// source-example-heading: Theme variants usage
Button button = new Button();
button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
// end-source-example

addVariantsDemo(Button::new,
GeneratedVaadinButton::addThemeVariants,
GeneratedVaadinButton::removeThemeVariants,
ButtonVariant::getVariantName, ButtonVariant.LUMO_SMALL,
ButtonVariant.LUMO_PRIMARY);
}

private void showButtonClickedMessage(ClickEvent<Button> evt) {
Button source = evt.getSource();
source.getParent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ private void waitUntilMessageIsChangedForClickedButton(
.equals("Button " + messageString + " was clicked."));
}

@Test
public void assertVariants() {
verifyThemeVariantsBeingToggled();
}

private int getCenterX(WebElement element) {
return element.getLocation().getX() + element.getSize().getWidth() / 2;
}
Expand Down

0 comments on commit 4e3474a

Please sign in to comment.