Skip to content

Commit

Permalink
fix: add missing focused label styles and visual test
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed May 24, 2019
1 parent 7c02ece commit 6de4908
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/visual/default.html
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8">

<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../iron-test-helpers/mock-interactions.js"></script>
<script>
const theme = window.location.search.replace(/.*theme=(\w+).*/, '$1') || 'lumo';
document.write(`<link rel="import" href="../../theme/${theme}/vaadin-checkbox.html">`);
Expand Down Expand Up @@ -46,18 +47,28 @@
<vaadin-checkbox value="2">2</vaadin-checkbox>
</vaadin-checkbox-group>
</div>

<div id="validation-tests">
<vaadin-checkbox-group required error-message="Please choose a number" label="Choose a number" id="validation-checkbox-group">
<vaadin-checkbox value="1">1</vaadin-checkbox>
<vaadin-checkbox value="2">2</vaadin-checkbox>
</vaadin-checkbox-group>
</div>

<div id="focus-tests">
<vaadin-checkbox-group label="Focused">
<vaadin-checkbox id="focus-checkbox" value="1">1</vaadin-checkbox>
<vaadin-checkbox value="2">2</vaadin-checkbox>
</vaadin-checkbox-group>
</div>

<script>
window.addEventListener('WebComponentsReady', () => {
const checkboxGroup = document.getElementById('validation-checkbox-group');
checkboxGroup.validate();

MockInteractions.keyDownOn(document.body, 9);
document.getElementById('focus-checkbox').dispatchEvent(new CustomEvent('focusin', {composed: true, bubbles: true}));
});
</script>

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions test/visual/test.js
Expand Up @@ -52,6 +52,13 @@ gemini.suite('vaadin-checkbox', function(rootSuite) {
.setCaptureElements('#validation-tests')
.capture('error');
});

gemini.suite(`focus-tests-${theme}`, function(suite) {
suite
.setUrl(`default.html?theme=${theme}`)
.setCaptureElements('#focus-tests')
.capture('focus');
});
});

});
16 changes: 16 additions & 0 deletions theme/lumo/vaadin-checkbox-group-styles.html
@@ -1,3 +1,4 @@
<link rel="import" href="../../../vaadin-lumo-styles/color.html">
<link rel="import" href="../../../vaadin-lumo-styles/mixins/required-field.html">

<dom-module id="lumo-checkbox-group" theme-for="vaadin-checkbox-group">
Expand Down Expand Up @@ -33,6 +34,21 @@
color: var(--lumo-disabled-text-color);
-webkit-text-fill-color: var(--lumo-disabled-text-color);
}

:host([focused]:not([disabled])) [part="label"] {
color: var(--lumo-primary-text-color);
}

:host(:hover:not([disabled]):not([focused])) [part="label"] {
color: var(--lumo-body-text-color);
}

/* Touch device adjustment */
@media (pointer: coarse) {
:host(:hover:not([disabled]):not([focused])) [part="label"] {
color: var(--lumo-secondary-text-color);
}
}
</style>
</template>
</dom-module>
5 changes: 5 additions & 0 deletions theme/material/vaadin-checkbox-group-styles.html
@@ -1,3 +1,4 @@
<link rel="import" href="../../../vaadin-material-styles/color.html">
<link rel="import" href="../../../vaadin-material-styles/mixins/required-field.html">

<dom-module id="material-checkbox-group" theme-for="vaadin-checkbox-group">
Expand Down Expand Up @@ -43,6 +44,10 @@
color: var(--material-disabled-text-color);
-webkit-text-fill-color: var(--material-disabled-text-color);
}

:host([focused]:not([invalid])) [part="label"] {
color: var(--material-primary-text-color);
}
</style>
</template>
</dom-module>

0 comments on commit 6de4908

Please sign in to comment.