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-messagestrip): Close button now has the correct design #2029

Merged
merged 4 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
22 changes: 9 additions & 13 deletions packages/main/src/MessageStrip.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="{{classes.main}}"
<div class="{{classes.root}}"
id="{{_id}}"
role="alert"
dir="{{effectiveDir}}"
Expand All @@ -16,19 +16,15 @@
{{/unless}}

<span class="ui5-hidden-text">{{hiddenText}}</span>
<span class="{{classes.label}}"><slot></slot></span>
<span class="ui5-messagestrip-text"><slot></slot></span>

{{#unless noCloseButton}}
<button
class="ui5-messagestrip-close-icon-wrapper"
title="{{_closeButtonText}}"
@click={{_closeClick}}
>
<ui5-icon
class="ui5-messagestrip-close-icon"
name="decline"
>
</ui5-icon>
</button>
<ui5-button
icon="decline"
design="Transparent"
class="ui5-messagestrip-close-button"
title="{{_closeButtonText}}"
@click={{_closeClick}}
></ui5-button>
{{/unless}}
</div>
45 changes: 13 additions & 32 deletions packages/main/src/MessageStrip.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import { isEnter, isSpace } from "@ui5/webcomponents-base/src/Keys.js";
import "@ui5/webcomponents-icons/dist/icons/decline.js";
import "@ui5/webcomponents-icons/dist/icons/message-information.js";
import "@ui5/webcomponents-icons/dist/icons/message-success.js";
Expand All @@ -10,6 +9,7 @@ import "@ui5/webcomponents-icons/dist/icons/message-warning.js";
import MessageStripType from "./types/MessageStripType.js";
import MessageStripTemplate from "./generated/templates/MessageStripTemplate.lit.js";
import Icon from "./Icon.js";
import Button from "./Button.js";
import { MESSAGE_STRIP_CLOSE_BUTTON } from "./generated/i18n/i18n-defaults.js";

// Styles
Expand Down Expand Up @@ -153,42 +153,27 @@ class MessageStrip extends UI5Element {

constructor() {
super();

this.i18nBundle = getI18nBundle("@ui5/webcomponents");
}

_closeClick() {
this.fireEvent("close", {});
}

_closeKeyDown(event) {
if (isEnter(event)) {
this.fireEvent("close");
}

if (isSpace(event)) {
event.preventDefault();
}
}

_closeKeyUp(event) {
if (isSpace(event)) {
this.fireEvent("close");
}
}

static async onDefine() {
await fetchI18nBundle("@ui5/webcomponents");

await Icon.define();
await Promise.all([
fetchI18nBundle("@ui5/webcomponents"),
Icon.define(),
Button.define(),
]);
}

static typeClassesMappings() {
return {
"Information": "ui5-messagestrip--info",
"Positive": "ui5-messagestrip--positive",
"Negative": "ui5-messagestrip--negative",
"Warning": "ui5-messagestrip--warning",
"Information": "ui5-messagestrip-root--info",
"Positive": "ui5-messagestrip-root--positive",
"Negative": "ui5-messagestrip-root--negative",
"Warning": "ui5-messagestrip-root--warning",
};
}

Expand All @@ -211,14 +196,10 @@ class MessageStrip extends UI5Element {

get classes() {
return {
label: {
"ui5-messagestrip-text": true,
"ui5-messagestripNoCloseButton": this.noCloseButton,
},
main: {
root: {
"ui5-messagestrip-root": true,
"ui5-messagestrip-icon--hidden": this.noIcon,
"ui5-messagestrip-close-icon--hidden": this.noCloseButton,
"ui5-messagestrip-root-no-icon": this.noIcon,
"ui5-messagestrip-root-no-close-button": this.noCloseButton,
[this.typeClasses]: true,
},
};
Expand Down
125 changes: 40 additions & 85 deletions packages/main/src/themes/MessageStrip.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
width: 100%;
}

/** Root classes **/
.ui5-messagestrip-root {
width: 100%;
height: 100%;
Expand All @@ -14,124 +15,78 @@
border-width: var(--_ui5_messagestrip_border_width);
border-style: solid;
box-sizing: border-box;
padding: 0.4375rem 2rem 0.4375rem 2.5rem;
position: relative;
}

.ui5-messagestrip-root .ui5-messagestrip-icon-wrapper {
position: absolute;
top: var(--_ui5_messagestrip_icon_top);
left: 0.75rem;
box-sizing: border-box;
.ui5-messagestrip-root-no-icon {
padding: var(--_ui5_messagestrip_padding_no_icon);
}

.ui5-messagestrip-root .ui5-messagestrip-text {
width: 100%;
color: var(--sapTextColor);
line-height: 1.2;
}

.ui5-messagestrip-icon--hidden {
padding: 0.4375rem 2rem 0.4375rem 1rem;
}

.ui5-messagestrip-close-icon--hidden {
.ui5-messagestrip-root-no-close-button {
padding-right: 1rem;
}

.ui5-messagestrip-text {
font-family: var(--sapFontFamily);
font-size: var(--sapFontSize);
}

.ui5-messagestrip--info {
.ui5-messagestrip-root--info {
background-color: var(--sapInformationBackground);
border-color: var(--sapInformationBorderColor);
color: var(--sapTextColor);
}

.ui5-messagestrip--info .ui5-messagestrip-icon {
.ui5-messagestrip-root--info .ui5-messagestrip-icon {
color: var(--sapInformativeElementColor);
}

.ui5-messagestrip--positive {
.ui5-messagestrip-root--positive {
background-color: var(--sapSuccessBackground);
border-color: var(--sapSuccessBorderColor);
}

.ui5-messagestrip--positive .ui5-messagestrip-icon {
.ui5-messagestrip-root--positive .ui5-messagestrip-icon {
color: var(--sapPositiveElementColor);
}

.ui5-messagestrip--negative {
.ui5-messagestrip-root--negative {
background-color: var(--sapErrorBackground);
border-color: var(--sapErrorBorderColor);
}

.ui5-messagestrip--negative .ui5-messagestrip-icon {
.ui5-messagestrip-root--negative .ui5-messagestrip-icon {
color: var(--sapNegativeElementColor);
}

.ui5-messagestrip--warning {
.ui5-messagestrip-root--warning {
background-color: var(--sapWarningBackground);
border-color: var(--sapWarningBorderColor);
}

.ui5-messagestrip--warning .ui5-messagestrip-icon {
.ui5-messagestrip-root--warning .ui5-messagestrip-icon {
color: var(--sapCriticalElementColor);
}

.ui5-messagestrip-close-icon-wrapper {
display: flex;
justify-content: center;
align-items: center;
width: var(--_ui5_messagestrip_close_button_size);
height: var(--_ui5_messagestrip_close_button_size);
border-radius: 0.25rem;
background: transparent;
color: var(--sapTextColor);
cursor: pointer;
/** Icon wrapper **/
.ui5-messagestrip-icon-wrapper {
position: absolute;
right: 0.125rem;
top: 0.125rem;
outline: none;
border: var(--_ui5_messagestrip_close_button_border);
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}

.ui5-messagestrip-close-icon-wrapper:hover {
background-color: var(--sapButton_Lite_Hover_Background);
}

.ui5-messagestrip-close-icon-wrapper:active {
background-color: var(--sapButton_Active_Background);
color: var(--sapButton_Active_TextColor);
}

.ui5-messagestrip-close-icon {
width: 0.75rem;
height: 0.75rem;
pointer-events: none;
}

.ui5-messagestrip-close-icon-wrapper:active .ui5-messagestrip-close-icon {
color: currentColor;
}

.ui5-messagestrip-close-icon-wrapper:focus {
outline-offset: var(--_ui5_messagestrip_focus_offset);
outline: var(--_ui5_messagestrip_focus_width) dotted var(--sapContent_FocusColor);
top: var(--_ui5_messagestrip_icon_top);
left: 0.75rem;
box-sizing: border-box;
}

.ui5-messagestrip-close-icon-wrapper:active:focus {
outline: var(--_ui5_messagestrip_focus_width) dotted var(--sapContent_ContrastFocusColor);
/** Text **/
.ui5-messagestrip-text {
width: 100%;
color: var(--sapTextColor);
line-height: 1.2;
font-family: var(--sapFontFamily);
font-size: var(--sapFontSize);
}

/* FF renders outine around element content, causing double outline - around the button and the icon */
.ui5-messagestrip-close-icon-wrapper::-moz-focus-inner {
border: none;
/** Close button **/
.ui5-messagestrip-close-button {
width: var(--_ui5_messagestrip_close_button_size);
height: var(--_ui5_messagestrip_close_button_size);
position: absolute;
right: 0.125rem;
top: 0.125rem;
}

/* RTL */
Expand All @@ -140,22 +95,22 @@
padding-left: 2rem;
}

[dir="rtl"] .ui5-messagestrip-icon-wrapper {
right: 0.75rem;
left: 0;
}

[dir="rtl"] .ui5-messagestrip-icon--hidden {
[dir="rtl"] .ui5-messagestrip-root-no-icon {
padding-right: 1rem;
padding-left: 2rem;
}

[dir="rtl"] .ui5-messagestrip-close-icon--hidden {
[dir="rtl"] .ui5-messagestrip-root-no-close-button {
padding-left: 1rem;
padding-right: 0;
}

[dir="rtl"] .ui5-messagestrip-close-icon-wrapper {
[dir="rtl"] .ui5-messagestrip-icon-wrapper {
right: 0.75rem;
left: 0;
}

[dir="rtl"] .ui5-messagestrip-close-button {
left: 0.125rem;
right: auto;
}
}
5 changes: 3 additions & 2 deletions packages/main/src/themes/base/MessageStrip-parameters.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
--_ui5_messagestrip_button_border_style: none;
--_ui5_messagestrip_button_border_color: transparent;
--_ui5_messagestrip_button_border_radius: 0;
--_ui5_messagestrip_padding: 0.125rem .125rem;
--_ui5_messagestrip_padding: 0.4375rem 2.5rem 0.4375rem 2.5rem;
--_ui5_messagestrip_padding_no_icon: 0.4375rem 2.5rem 0.4375rem 1rem;
--_ui5_messagestrip_button_height: 1.625rem;
--_ui5_messagestrip_border_width: 1px;
--_ui5_messagestrip_close_button_border: none;
--_ui5_messagestrip_close_button_size: 1.625rem;
--_ui5_messagestrip_icon_top: 0.4375rem;
--_ui5_messagestrip_focus_width: 1px;
--_ui5_messagestrip_focus_offset: -2px;
}
}
2 changes: 1 addition & 1 deletion packages/main/test/specs/MessageStrip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("MessageStrip general interaction", () => {

it("tests close event", () => {

const closeButton = browser.$("#messageStrip").shadow$(".ui5-messagestrip-close-icon-wrapper");
const closeButton = browser.$("#messageStrip").shadow$(".ui5-messagestrip-close-button");
const input = browser.$("#inputField");

closeButton.click();
Expand Down