Skip to content

Commit

Permalink
fix(ui5-label): fix width for italic labels (#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifoosid committed May 18, 2020
1 parent 0cef140 commit 14a48d1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/main/src/Label.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<label
class="ui5-label-root"
dir="{{rtl}}"
@click={{_onclick}}
for="{{for}}"
>
Expand Down
5 changes: 5 additions & 0 deletions packages/main/src/Label.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";

// Template
import LabelTemplate from "./generated/templates/LabelTemplate.lit.js";
Expand Down Expand Up @@ -130,6 +131,10 @@ class Label extends UI5Element {
elementToFocus.focus();
}
}

get rtl() {
return getRTL() ? "rtl" : undefined;
}
}

Label.define();
Expand Down
18 changes: 17 additions & 1 deletion packages/main/src/themes/Label.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
overflow: hidden;
}

bdi{
content: "";
padding-right: 0.15625rem;
}

:host(:not([wrap])) .ui5-label-text-wrapper {
text-overflow: ellipsis;
overflow: hidden;
Expand All @@ -29,7 +34,7 @@
}

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

:host(:not([wrap])[required]) .ui5-label-text-wrapper {
Expand All @@ -50,6 +55,17 @@
font-size: 1.25rem;
font-weight: bold;
position: relative;
font-style: normal;
vertical-align: middle;
line-height: 0;
}

:host([required][show-colon]) .ui5-label-required-colon:after {
margin-right: 0;
margin-left: .125rem;
}

:host([required][show-colon]) [dir="rtl"] .ui5-label-required-colon:after {
margin-right: .125rem;
margin-left: 0;
}
12 changes: 6 additions & 6 deletions packages/main/test/pages/Label.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">

<title>Playground</title>
<title>Label</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
Expand Down Expand Up @@ -81,35 +81,35 @@ <h2>Test show-colon not forcing truncation</h2>
<h2>label + input</h2>
<div style="display: flex; align-items: center">
<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>
<ui5-input style="width: 320px; margin-left: 16px;" id="form-ui5-input"></ui5-input>
<ui5-input style="width: 320px; margin: 0 16px;" id="form-ui5-input"></ui5-input>
</div>

<br>

<div style="display: flex; align-items: center">
<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>
<input style="width: 320px; margin-left: 16px;" id="native-input"></input>
<input style="width: 320px; margin: 0 16px;" id="native-input"></input>
</div>

<br>

<div style="display: flex; align-items: center">
<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>
<ui5-textarea style="width: 320px; margin-left: 16px;" id="ui5-textarea"></ui5-textarea>
<ui5-textarea style="width: 320px; margin: 0 16px;" id="ui5-textarea"></ui5-textarea>
</div>

<br>

<div style="display: flex; align-items: center">
<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>
<textarea style="width: 320px; margin-left: 16px;" id="native-textarea"></textarea>
<textarea style="width: 320px; margin: 0 16px;" id="native-textarea"></textarea>
</div>

<br>

<div style="display: flex; align-items: center">
<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>
<ui5-datepicker style="width: 320px; margin-left: 16px;" id="ui5-datepicker"></ui5-datepicker>
<ui5-datepicker style="width: 320px; margin: 0 16px;" id="ui5-datepicker"></ui5-datepicker>
</div>
</section>
</body>
Expand Down

0 comments on commit 14a48d1

Please sign in to comment.