From 4e3474af9ebe632365bc7143191f17575f7e385c Mon Sep 17 00:00:00 2001 From: Sun Zhe <31067185+ZheSun88@users.noreply.github.com> Date: Wed, 18 Jul 2018 15:27:43 +0300 Subject: [PATCH] Add theme variant demo and tests (#77) --- .../flow/component/button/demo/ButtonView.java | 17 +++++++++++++++++ .../flow/component/button/tests/ButtonIT.java | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/src/test/java/com/vaadin/flow/component/button/demo/ButtonView.java b/src/test/java/com/vaadin/flow/component/button/demo/ButtonView.java index dd62c2c..184ce05 100644 --- a/src/test/java/com/vaadin/flow/component/button/demo/ButtonView.java +++ b/src/test/java/com/vaadin/flow/component/button/demo/ButtonView.java @@ -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; @@ -40,6 +42,7 @@ public void initView() { createImageButtonWithAccessibleLabel(); createButtonsWithTabIndex(); createDisabledButton(); + addVariantsFeature(); message = new Div(); message.setId("buttonMessage"); @@ -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