Skip to content

Commit 27d80aa

Browse files
javier-godoypaodb
authored andcommitted
fix(demo): improve dark theme support in demos
1 parent fae6110 commit 27d80aa

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1919
<drivers.dir>${project.basedir}/drivers</drivers.dir>
2020
<jetty.version>11.0.12</jetty.version>
21-
<flowingcode.commons.demo.version>4.0.0</flowingcode.commons.demo.version>
21+
<flowingcode.commons.demo.version>4.2.0-SNAPSHOT</flowingcode.commons.demo.version>
2222
<frontend.hotdeploy>true</frontend.hotdeploy>
2323
</properties>
2424

src/test/java/com/flowingcode/vaadin/addons/extendedlogin/ExtendedLoginOverlayDemo.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@
2020
package com.flowingcode.vaadin.addons.extendedlogin;
2121

2222
import com.flowingcode.vaadin.addons.demo.DemoSource;
23-
import com.vaadin.flow.component.dependency.CssImport;
23+
import com.flowingcode.vaadin.addons.demo.ThemeChangeObserver;
2424
import com.vaadin.flow.component.html.Div;
2525
import com.vaadin.flow.component.html.IFrame;
2626
import com.vaadin.flow.router.PageTitle;
@@ -31,13 +31,22 @@
3131
@PageTitle("Extended Login Overlay Demo")
3232
@SuppressWarnings("serial")
3333
@Route(value = "extended-login/login-overlay-demo", layout = ExtendedLoginDemoView.class)
34-
public class ExtendedLoginOverlayDemo extends Div {
34+
public class ExtendedLoginOverlayDemo extends Div implements ThemeChangeObserver {
35+
36+
private final IFrame iframe;
3537

3638
public ExtendedLoginOverlayDemo() {
3739
setClassName("wrap-iframe");
38-
IFrame iframe = new IFrame("/extended-login/login-overlay");
40+
iframe = new IFrame("/extended-login/login-overlay");
3941
iframe.setSizeFull();
4042
iframe.getElement().setAttribute("frameBorder", "0");
4143
add(iframe);
4244
}
45+
46+
@Override
47+
public void onThemeChange(String themeName) {
48+
iframe.getElement().executeJs(
49+
"this.contentWindow.document.querySelector('html').setAttribute('theme', $0)", themeName);
50+
}
51+
4352
}

src/test/java/com/flowingcode/vaadin/addons/extendedlogin/LoginLayoutDemo.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@
2020
package com.flowingcode.vaadin.addons.extendedlogin;
2121

2222
import com.flowingcode.vaadin.addons.demo.DemoSource;
23-
import com.vaadin.flow.component.dependency.CssImport;
23+
import com.flowingcode.vaadin.addons.demo.ThemeChangeObserver;
2424
import com.vaadin.flow.component.html.Div;
2525
import com.vaadin.flow.component.html.IFrame;
2626
import com.vaadin.flow.router.PageTitle;
@@ -31,14 +31,23 @@
3131
@PageTitle("Login Layout Demo")
3232
@SuppressWarnings("serial")
3333
@Route(value = "extended-login/login-layout-demo", layout = ExtendedLoginDemoView.class)
34-
public class LoginLayoutDemo extends Div {
34+
public class LoginLayoutDemo extends Div implements ThemeChangeObserver {
35+
36+
private IFrame iframe;
3537

3638
public LoginLayoutDemo() {
3739
setClassName("wrap-iframe");
38-
IFrame iframe = new IFrame("/extended-login/login-layout");
40+
iframe = new IFrame("/extended-login/login-layout");
3941
iframe.setClassName("frame");
4042
iframe.setSizeFull();
4143
iframe.getElement().setAttribute("frameBorder", "0");
4244
add(iframe);
4345
}
46+
47+
@Override
48+
public void onThemeChange(String themeName) {
49+
iframe.getElement().executeJs(
50+
"this.contentWindow.document.querySelector('html').setAttribute('theme', $0)", themeName);
51+
}
52+
4453
}

0 commit comments

Comments
 (0)