Skip to content

Commit 71c9caa

Browse files
authored
fix(ui5-token): correct visual in RTL/Compact (#804)
1 parent 3f26f2c commit 71c9caa

File tree

3 files changed

+53
-24
lines changed

3 files changed

+53
-24
lines changed

packages/main/src/Token.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div tabindex="{{_tabIndex}}" @click="{{_select}}" @keydown="{{_keydown}}" class="ui5-token--wrapper">
1+
<div tabindex="{{_tabIndex}}" @click="{{_select}}" @keydown="{{_keydown}}" class="ui5-token--wrapper" dir="{{dir}}">
22
<span class="ui5-token--text"><slot></slot></span>
33

44
{{#unless readonly}}

packages/main/src/Token.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
33
import { getTheme } from "@ui5/webcomponents-base/dist/config/Theme.js";
4+
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
45
import {
56
isBackSpace,
67
isEnter,
@@ -157,6 +158,10 @@ class Token extends UI5Element {
157158
return this.i18nBundle.getText(TOKEN_ARIA_DELETABLE);
158159
}
159160

161+
get dir() {
162+
return getRTL() ? "rtl" : "ltr";
163+
}
164+
160165
get iconURI() {
161166
return getTheme() === "sap_fiori_3" ? "sap-icon://decline" : "sap-icon://sys-cancel";
162167
}

packages/main/src/themes/Token.css

+47-23
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@
1010
box-sizing: border-box;
1111
}
1212

13-
:host([data-ui5-compact-size]) {
14-
font-size: 0.75rem;
15-
height: 1.25rem;
16-
}
17-
18-
:host([data-ui5-compact-size]) .ui5-token--icon {
19-
padding: 0 0.25rem;
20-
width: 0.75rem;
21-
height: 0.75rem;
13+
:host([overflows]) {
14+
visibility: hidden;
2215
}
2316

2417
:host(:not([readonly]):hover) {
@@ -49,26 +42,13 @@
4942
outline: 1px dotted var(--sapUiContentContrastFocusColor);
5043
}
5144

52-
:host([overflows]) {
53-
visibility: hidden;
54-
}
55-
56-
.ui5-token--icon {
57-
padding: 0.25rem 0.5rem;
58-
color: inherit;
59-
cursor: pointer;
60-
width: 1rem;
61-
height: 1rem;
62-
color: var(--_ui5_token_icon_color);
63-
}
64-
6545
.ui5-token--wrapper {
6646
display: flex;
6747
align-items: center;
6848
height: 100%;
6949
width: 100%;
7050
cursor: default;
71-
padding-left: 0.375rem;
51+
padding-left: 0.3125rem;
7252
padding-top: 0.25rem;
7353
padding-bottom: 0.25rem;
7454
box-sizing: border-box;
@@ -85,3 +65,47 @@
8565
.ui5-token--text {
8666
white-space: nowrap;
8767
}
68+
69+
.ui5-token--icon {
70+
padding: 0.25rem 0.5rem;
71+
color: inherit;
72+
cursor: pointer;
73+
width: 1rem;
74+
height: 1rem;
75+
color: var(--_ui5_token_icon_color);
76+
}
77+
78+
/* Compact */
79+
:host([data-ui5-compact-size]) {
80+
font-size: 0.75rem;
81+
height: 1.125rem; /* Note: by design should be 1.25rem, but the token gets cut in Erron/Warning state */
82+
}
83+
84+
:host([data-ui5-compact-size]) .ui5-token--wrapper {
85+
padding-left: 0.25rem;
86+
padding-top: 0.1rem;
87+
padding-bottom: 0.1rem;
88+
}
89+
90+
:host([data-ui5-compact-size]) .ui5-token--icon {
91+
padding: 0.1rem 0.25rem;
92+
width: 0.75rem;
93+
height: 0.75rem;
94+
}
95+
96+
/* RTL */
97+
:host .ui5-token--wrapper[dir="rtl"] {
98+
padding-right: 0.3125rem;
99+
padding-left: 0;
100+
}
101+
102+
:host([readonly]) .ui5-token--wrapper[dir="rtl"] {
103+
padding-right: 0;
104+
padding-left: 0.375rem;
105+
}
106+
107+
/* RTL + Compact */
108+
:host([data-ui5-compact-size]) .ui5-token--wrapper[dir="rtl"] {
109+
padding-right: 0.25rem;
110+
padding-left: 0;
111+
}

0 commit comments

Comments
 (0)