From 4eb495cac3f006b9f1aa525f04025401734a3550 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sauli=20T=C3=A4hk=C3=A4p=C3=A4=C3=A4?= Date: Sat, 20 Dec 2014 23:53:54 +0200 Subject: [PATCH] Add opacity filter for disabled menubar item. (#15381) Change-Id: I457becda9b8741b0b0f85d8985581a2039fa7304 --- .../VAADIN/themes/base/menubar/menubar.scss | 3 +- .../themes/base/DisabledMenuBarItem.java | 29 +++++++++++++++ .../themes/base/DisabledMenuBarItemTest.java | 36 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/themes/base/DisabledMenuBarItem.java create mode 100644 uitest/src/com/vaadin/tests/themes/base/DisabledMenuBarItemTest.java diff --git a/WebContent/VAADIN/themes/base/menubar/menubar.scss b/WebContent/VAADIN/themes/base/menubar/menubar.scss index b5f0752c9b..5ffac6de09 100644 --- a/WebContent/VAADIN/themes/base/menubar/menubar.scss +++ b/WebContent/VAADIN/themes/base/menubar/menubar.scss @@ -54,7 +54,8 @@ .#{$primaryStyleName} span.#{$primaryStyleName}-menuitem-disabled:hover, .#{$primaryStyleName} span.#{$primaryStyleName}-menuitem-disabled:focus, .#{$primaryStyleName} span.#{$primaryStyleName}-menuitem-disabled:active { - color: #999; + opacity: .5; + filter: alpha(opacity=50); } .#{$primaryStyleName}-more-menuitem { /* Arial has the most coverage for geometric entity characters */ diff --git a/uitest/src/com/vaadin/tests/themes/base/DisabledMenuBarItem.java b/uitest/src/com/vaadin/tests/themes/base/DisabledMenuBarItem.java new file mode 100644 index 0000000000..825f267ad3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/base/DisabledMenuBarItem.java @@ -0,0 +1,29 @@ +package com.vaadin.tests.themes.base; + +import com.vaadin.server.ThemeResource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.MenuBar; + +public class DisabledMenuBarItem extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + MenuBar menubar = new MenuBar(); + + MenuBar.MenuItem item = menubar.addItem("Item", null); + item.setEnabled(false); + item.setIcon(new ThemeResource("just_a_placeholder.png")); + + addComponent(menubar); + } + + @Override + protected String getTestDescription() { + return "Image icon should be greyed out."; + } + + @Override + protected Integer getTicketNumber() { + return 15381; + } +} diff --git a/uitest/src/com/vaadin/tests/themes/base/DisabledMenuBarItemTest.java b/uitest/src/com/vaadin/tests/themes/base/DisabledMenuBarItemTest.java new file mode 100644 index 0000000000..0a10a7f38b --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/base/DisabledMenuBarItemTest.java @@ -0,0 +1,36 @@ +package com.vaadin.tests.themes.base; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class DisabledMenuBarItemTest extends MultiBrowserTest { + + @Test + public void disabledMenuItemShouldHaveOpacity() { + openTestURL(); + + WebElement element = driver.findElement(By + .className("v-menubar-menuitem-disabled")); + + assertThat(element.getCssValue("opacity"), is("0.5")); + + if (browserIsIE8or9()) { + assertThat(element.getCssValue("filter"), is("alpha(opacity=50)")); + + } + } + + private boolean browserIsIE8or9() { + return Browser.IE8.getDesiredCapabilities().equals( + getDesiredCapabilities()) + || Browser.IE9.getDesiredCapabilities().equals( + getDesiredCapabilities()); + } +} \ No newline at end of file -- 2.39.5