Skip to content

Commit 14a48d1

Browse files
authored
fix(ui5-label): fix width for italic labels (#1625)
1 parent 0cef140 commit 14a48d1

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

packages/main/src/Label.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<label
22
class="ui5-label-root"
3+
dir="{{rtl}}"
34
@click={{_onclick}}
45
for="{{for}}"
56
>

packages/main/src/Label.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3+
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
34

45
// Template
56
import LabelTemplate from "./generated/templates/LabelTemplate.lit.js";
@@ -130,6 +131,10 @@ class Label extends UI5Element {
130131
elementToFocus.focus();
131132
}
132133
}
134+
135+
get rtl() {
136+
return getRTL() ? "rtl" : undefined;
137+
}
133138
}
134139

135140
Label.define();

packages/main/src/themes/Label.css

+17-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
overflow: hidden;
2121
}
2222

23+
bdi{
24+
content: "";
25+
padding-right: 0.15625rem;
26+
}
27+
2328
:host(:not([wrap])) .ui5-label-text-wrapper {
2429
text-overflow: ellipsis;
2530
overflow: hidden;
@@ -29,7 +34,7 @@
2934
}
3035

3136
:host(:not([wrap])[required][show-colon]) .ui5-label-text-wrapper {
32-
max-width: calc(100% - 0.725rem);
37+
max-width: calc(100% - .85rem);
3338
}
3439

3540
:host(:not([wrap])[required]) .ui5-label-text-wrapper {
@@ -50,6 +55,17 @@
5055
font-size: 1.25rem;
5156
font-weight: bold;
5257
position: relative;
58+
font-style: normal;
5359
vertical-align: middle;
5460
line-height: 0;
61+
}
62+
63+
:host([required][show-colon]) .ui5-label-required-colon:after {
64+
margin-right: 0;
65+
margin-left: .125rem;
66+
}
67+
68+
:host([required][show-colon]) [dir="rtl"] .ui5-label-required-colon:after {
69+
margin-right: .125rem;
70+
margin-left: 0;
5571
}

packages/main/test/pages/Label.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta charset="utf-8">
77

8-
<title>Playground</title>
8+
<title>Label</title>
99
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
1010
<meta http-equiv="X-UA-Compatible" content="IE=edge">
1111
<meta charset="utf-8">
@@ -81,35 +81,35 @@ <h2>Test show-colon not forcing truncation</h2>
8181
<h2>label + input</h2>
8282
<div style="display: flex; align-items: center">
8383
<ui5-label id="label-for-ui5-input" for="form-ui5-input" style="width: 100px" required>Reprehenderit amet cillum tempor ex eu dolor adipisicing reprehenderit pariatur</ui5-label>
84-
<ui5-input style="width: 320px; margin-left: 16px;" id="form-ui5-input"></ui5-input>
84+
<ui5-input style="width: 320px; margin: 0 16px;" id="form-ui5-input"></ui5-input>
8585
</div>
8686

8787
<br>
8888

8989
<div style="display: flex; align-items: center">
9090
<ui5-label id="label-for-native-input" for="native-input" style="width: 100px" show-colon wrap required>Reprehenderit amet cillum tempor ex eu dolor adipisicing reprehenderit pariatur</ui5-label>
91-
<input style="width: 320px; margin-left: 16px;" id="native-input"></input>
91+
<input style="width: 320px; margin: 0 16px;" id="native-input"></input>
9292
</div>
9393

9494
<br>
9595

9696
<div style="display: flex; align-items: center">
9797
<ui5-label id="label-for-ui5-textarea" for="ui5-textarea" style="width: 100px" show-colon>Reprehenderit amet cillum tempor ex eu dolor adipisicing reprehenderit pariatur</ui5-label>
98-
<ui5-textarea style="width: 320px; margin-left: 16px;" id="ui5-textarea"></ui5-textarea>
98+
<ui5-textarea style="width: 320px; margin: 0 16px;" id="ui5-textarea"></ui5-textarea>
9999
</div>
100100

101101
<br>
102102

103103
<div style="display: flex; align-items: center">
104104
<ui5-label id="label-for-native-textarea" for="native-textarea" style="width: 100px" required>Reprehenderit amet cillum tempor ex eu dolor adipisicing reprehenderit pariatur</ui5-label>
105-
<textarea style="width: 320px; margin-left: 16px;" id="native-textarea"></textarea>
105+
<textarea style="width: 320px; margin: 0 16px;" id="native-textarea"></textarea>
106106
</div>
107107

108108
<br>
109109

110110
<div style="display: flex; align-items: center">
111111
<ui5-label id="label-for-ui5-datepicker" for="ui5-datepicker" style="width: 100px" show-colon required>Reprehenderit amet cillum tempor ex eu dolor adipisicing reprehenderit pariatur</ui5-label>
112-
<ui5-datepicker style="width: 320px; margin-left: 16px;" id="ui5-datepicker"></ui5-datepicker>
112+
<ui5-datepicker style="width: 320px; margin: 0 16px;" id="ui5-datepicker"></ui5-datepicker>
113113
</div>
114114
</section>
115115
</body>

0 commit comments

Comments
 (0)