Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-label): fix width for italic labels #1625

Merged
merged 5 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 18 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,18 @@
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 {
fifoosid marked this conversation as resolved.
Show resolved Hide resolved
margin-right: 0;
Copy link
Member

@ilhan007 ilhan007 May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The margins here and below are still 2px, let's change them to 0.125rem

margin-left: 2px;
}

:host([required][show-colon]) [dir="rtl"] .ui5-label-required-colon:after {
margin-right: 2px;
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