Skip to content

Commit

Permalink
feat: add RTL specific styles (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Mar 18, 2020
1 parent f31e4ca commit a35cd90
Show file tree
Hide file tree
Showing 36 changed files with 114 additions and 21 deletions.
12 changes: 6 additions & 6 deletions bower.json
Expand Up @@ -35,13 +35,13 @@
"iron-resizable-behavior": "^2.0.0",
"polymer": "^2.0.0",
"vaadin-control-state-mixin": "vaadin/vaadin-control-state-mixin#^2.1.1",
"vaadin-overlay": "vaadin/vaadin-overlay#^3.2.0",
"vaadin-text-field": "vaadin/vaadin-text-field#^2.4.3",
"vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.3.2",
"vaadin-overlay": "vaadin/vaadin-overlay#^3.4.0",
"vaadin-text-field": "vaadin/vaadin-text-field#^2.6.0-alpha3",
"vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.5.2",
"vaadin-lumo-styles": "vaadin/vaadin-lumo-styles#^1.1.1",
"vaadin-material-styles": "vaadin/vaadin-material-styles#^1.1.2",
"vaadin-item": "vaadin/vaadin-item#^2.1.0",
"vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.0.0"
"vaadin-item": "vaadin/vaadin-item#^2.2.0-alpha1",
"vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.3.0"
},
"devDependencies": {
"iron-form": "^2.0.0",
Expand All @@ -50,7 +50,7 @@
"paper-input": "^2.0.0",
"vaadin-button": "vaadin/vaadin-button#^2.1.0",
"web-component-tester": "^6.1.5",
"vaadin-demo-helpers": "vaadin/vaadin-demo-helpers#^3.0.0",
"vaadin-demo-helpers": "vaadin/vaadin-demo-helpers#^3.1.0-alpha1",
"vaadin-dialog": "^2.2.1"
},
"resolutions": {
Expand Down
3 changes: 2 additions & 1 deletion src/vaadin-combo-box-item.html
Expand Up @@ -5,6 +5,7 @@
-->
<link rel="import" href="../../polymer/polymer-element.html">
<link rel="import" href="../../vaadin-themable-mixin/vaadin-themable-mixin.html">
<link rel="import" href="../../vaadin-element-mixin/vaadin-dir-mixin.html">

<dom-module id="vaadin-combo-box-item">
<template>
Expand Down Expand Up @@ -47,7 +48,7 @@
* @mixes Vaadin.ThemableMixin
* @private
*/
class ComboBoxItemElement extends Vaadin.ThemableMixin(Polymer.Element) {
class ComboBoxItemElement extends Vaadin.ThemableMixin(Vaadin.DirMixin(Polymer.Element)) {
static get is() {
return 'vaadin-combo-box-item';
}
Expand Down
27 changes: 27 additions & 0 deletions test/visual/default-rtl.html
@@ -0,0 +1,27 @@
<!DOCTYPE html>

<head lang="en">
<meta charset="UTF-8">

<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script>
const theme = window.location.search.replace(/.*theme=(\w+).*/, '$1') || 'lumo';
document.write(`<link rel="import" href="../../theme/${theme}/vaadin-combo-box.html">`);
document.documentElement.setAttribute('dir', 'rtl');
</script>
</head>

<body>

<div id="default-rtl-tests" style="padding: 10px;">
Plain
<vaadin-combo-box></vaadin-combo-box>

<br>Label
<vaadin-combo-box label="Element"></vaadin-combo-box>

<br>Value
<vaadin-combo-box value="Carbon" items='["Carbon"]'></vaadin-combo-box>
</div>

</body>
8 changes: 6 additions & 2 deletions test/visual/dropdown.html
Expand Up @@ -5,9 +5,13 @@

<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script>
const dir = window.location.search.replace(/.*dir=(\w+).*/, '$1') || 'ltr';
document.documentElement.setAttribute('dir', dir);

const theme = window.location.search.replace(/.*theme=(\w+).*/, '$1') || 'lumo';
document.write(`<link rel="import" href="../../theme/${theme}/vaadin-combo-box.html">`);
</script>

<dom-module id="text-field-styles" theme-for="vaadin-text-field">
<template>
<style>
Expand All @@ -23,8 +27,8 @@
<body>

<div id="dropdown-tests" style="padding: 10px; min-height: 300px;">
Plain template
<vaadin-combo-box id="plain" item-label-path="name" item-value-path="symbol"></vaadin-combo-box>
Selected item
<vaadin-combo-box id="selected" value="He" item-label-path="name" item-value-path="symbol"></vaadin-combo-box>

<br> Item template
<vaadin-combo-box id="template" item-label-path="name" item-value-path="symbol">
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.
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.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
39 changes: 27 additions & 12 deletions test/visual/test.js
Expand Up @@ -15,6 +15,13 @@ gemini.suite('vaadin-combo-box', function(rootSuite) {
.after(goToAboutBlank);

['lumo', 'material'].forEach(theme => {
gemini.suite(`default-rtl-tests-${theme}`, function(suite) {
suite
.setUrl(`default-rtl.html?theme=${theme}`)
.setCaptureElements('#default-rtl-tests')
.capture('default');
});

gemini.suite(`default-tests-${theme}`, function(suite) {
suite
.setUrl(`default.html?theme=${theme}`)
Expand All @@ -36,20 +43,28 @@ gemini.suite('vaadin-combo-box', function(rootSuite) {
.capture('default');
});

gemini.suite(`dropdown-${theme}`, function(suite) {
suite
.setUrl(`dropdown.html?theme=${theme}`)
.setCaptureElements('#dropdown-tests')
.capture('default', function(actions) {
actions.executeJS(function(window) {
window.document.querySelector('#plain').open();
['ltr', 'rtl'].forEach(dir => {
gemini.suite(`dropdown-${theme}-${dir}-selected`, function(suite) {
suite
.setUrl(`dropdown.html?theme=${theme}&dir=${dir}`)
.setCaptureElements('#dropdown-tests')
.capture('default', function(actions) {
actions.executeJS(function(window) {
window.document.querySelector('#selected').open();
});
});
})
.capture('template', function(actions) {
actions.executeJS(function(window) {
window.document.querySelector('#template').open();
});

gemini.suite(`dropdown-${theme}-${dir}-template`, function(suite) {
suite
.setUrl(`dropdown.html?theme=${theme}&dir=${dir}`)
.setCaptureElements('#dropdown-tests')
.capture('template', function(actions) {
actions.executeJS(function(window) {
window.document.querySelector('#template').open();
});
});
});
});
});
});

Expand Down
10 changes: 10 additions & 0 deletions theme/lumo/vaadin-combo-box-dropdown-styles.html
Expand Up @@ -84,6 +84,16 @@
transform: rotate(360deg);
}
}

/* RTL specific styles */

:host([loading][dir="rtl"]) [part~="loader"] {
left: auto;
margin-left: 0;
margin-right: auto;
margin-inline-start: 0;
margin-inline-end: auto;
}
</style>
</template>
</dom-module>
6 changes: 6 additions & 0 deletions theme/lumo/vaadin-combo-box-item-styles.html
Expand Up @@ -42,6 +42,12 @@
box-shadow: none;
}
}

/* RTL specific styles */
:host([dir="rtl"]) {
padding-right: calc(var(--lumo-border-radius) / 4);
padding-left: calc(var(--lumo-space-l) + var(--lumo-border-radius) / 4);
}
</style>
</template>
</dom-module>
30 changes: 30 additions & 0 deletions theme/material/vaadin-combo-box-dropdown-styles.html
Expand Up @@ -90,6 +90,36 @@
background-size: 300% 100%;
}
}

/* RTL specific styles */

@keyframes material-combo-box-loader-progress-rtl {
0% {
background-position: 100% 0;
background-size: 300% 100%;
}

33% {
background-position: 200% 0;
background-size: 400% 100%;
}

67% {
background-position: 300% 0;
background-size: 250% 100%;
}

100% {
background-position: 400% 0;
background-size: 300% 100%;
}
}

:host([loading][dir="rtl"]) [part="loader"] {
animation:
3s linear infinite material-combo-box-loader-progress-rtl,
.3s .1s both material-combo-box-loader-fade-in;
}
</style>
</template>
</dom-module>

0 comments on commit a35cd90

Please sign in to comment.