From 09c4b4be9ec33bac7d814dbeb28095a7a7add835 Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Mon, 13 Mar 2017 11:24:41 +0100 Subject: java : vaadin : add theme support --- .../main/WebContent/VAADIN/themes/mytheme/icons/home.png | Bin 0 -> 1783 bytes .../main/WebContent/VAADIN/themes/mytheme/mytheme.scss | 15 +++++++++++++++ .../main/WebContent/VAADIN/themes/mytheme/styles.scss | 4 ++++ java/vaadin/src/main/java/ch/asynk/HelloWorld.java | 11 +++++++---- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/home.png create mode 100644 java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss create mode 100644 java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/styles.scss (limited to 'java/vaadin/src/main') diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/home.png b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/home.png new file mode 100644 index 0000000..7362322 Binary files /dev/null and b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/home.png differ diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss new file mode 100644 index 0000000..f1c36c3 --- /dev/null +++ b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss @@ -0,0 +1,15 @@ + +@import "../valo/valo.scss"; + +@mixin mytheme { + @include valo; + + .v-app { + background-color: #e6e6e9; + } + .v-button { + color: #ff6660; + background-image: none; + background-color: #eee666; + } +} diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/styles.scss b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/styles.scss new file mode 100644 index 0000000..447ce98 --- /dev/null +++ b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/styles.scss @@ -0,0 +1,4 @@ +@import "mytheme.scss"; +.mytheme { + @include mytheme; +} diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java b/java/vaadin/src/main/java/ch/asynk/HelloWorld.java index e811599..f15bddd 100644 --- a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java +++ b/java/vaadin/src/main/java/ch/asynk/HelloWorld.java @@ -3,6 +3,7 @@ package ch.asynk; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Title; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.ThemeResource; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -15,7 +16,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Title("Hello!!") -@Theme("valo") +@Theme("mytheme") public class HelloWorld extends UI { private static final long serialVersionUID = 511085335415683713L; @@ -28,8 +29,9 @@ public class HelloWorld extends UI VerticalLayout content = new VerticalLayout(); setContent(content); - content.addComponent(new Label("Hello World!")); - content.addComponent(new Button("Push Me!", new ClickListener() { + content.addComponent(new Label("Hello World using mytheme")); + Button btn = new Button("Push Me!", new ThemeResource("icons/home.png")); + btn.addClickListener(new ClickListener() { private static final long serialVersionUID = 5808429544582385114L; @Override public void buttonClick(ClickEvent event) { @@ -42,6 +44,7 @@ public class HelloWorld extends UI logger.warn("warn"); logger.error("error"); } - })); + }); + content.addComponent(btn); } } -- cgit v1.2.3