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

refactor(ui5-popover, ui5-dialog): clean styles #673

Merged
merged 3 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions packages/main/src/Dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{>include "./Popup.hbs"}}

<span class="{{classes.frame}}">
<span class="ui5-popup-frame">
<span id="{{_id}}-firstfe" tabindex="0"></span>
<div style="{{zindex}}" class="{{classes.dialogParent}}">
<div tabindex="-1" aria-labelledby="{{headerId}}" role="dialog" class="{{classes.main}}">
<div style="{{zindex}}" class="ui5-dialog-root-parent {{classes.dialogParent}}">
<div tabindex="-1" aria-labelledby="{{headerId}}" role="dialog" class="ui5-popup-root ui5-dialog-root">
{{> header}}
<section class="ui5-dialog-wrapper-section">
<div class="ui5-popup-wrapper-content">
<div class="ui5-popup-wrapper-scroll">
<section class="ui5-dialog-section">
<div class="ui5-popup-content">
<div class="ui5-popup-scroll">
<slot></slot>
</div>
</div>
Expand Down
24 changes: 7 additions & 17 deletions packages/main/src/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Dialog extends Popup {
* @public
*/
open() {
if (this._isOpen) {
if (this.opened) {
return;
}

Expand All @@ -96,15 +96,15 @@ class Dialog extends Popup {

this.storeCurrentFocus();

this._isOpen = true;
this.opened = true;
}

/**
* Closes the <code>ui5-dialog</code>.
* @public
*/
close() {
if (!this._isOpen) {
if (!this.opened) {
return;
}

Expand All @@ -113,7 +113,7 @@ class Dialog extends Popup {
return;
}

this._isOpen = false;
this.opened = false;

this.resetFocus();

Expand All @@ -122,23 +122,13 @@ class Dialog extends Popup {

get classes() {
return {
frame: {
"ui5-popup-wrapper-frame": true,
"ui5-popup-wrapper-frame--open": this._isOpen,
},
dialogParent: {
"ui5-dialog-wrapper-parent": true,
"ui5-dialog-wrapper--stretched": this.stretch,
"ui5-phone": isPhone(),
},
main: {
"ui5-popup-wrapper": true,
"ui5-dialog-wrapper": true,
},
blockLayer: {
sapUiBLy: true,
"ui5-popup-wrapper-blockLayer": true,
"ui5-popup-wrapper-blockLayer--hidden": this._hideBlockLayer,
"ui5-popup-BLy": true,
"ui5-popup-blockLayer": true,
"ui5-popup-blockLayer--hidden": this._hideBlockLayer,
},
};
}
Expand Down
10 changes: 5 additions & 5 deletions packages/main/src/Popover.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{{>include "./Popup.hbs"}}

<span class="{{classes.frame}}" @focusin="{{onfocusin}}">
<span class="ui5-popup-frame" @focusin="{{onfocusin}}">
<span id="{{_id}}-firstfe" tabindex="0" @focusin={{focusHelper.forwardToLast}}></span>
<div style="{{styles.main}}" role="dialog" aria-labelledby="{{headerId}}" tabindex="-1" class="{{classes.main}}">
<div style="{{styles.main}}" role="dialog" aria-labelledby="{{headerId}}" tabindex="-1" class="ui5-popup-root ui5-popover-root">
{{> header}}
<div id="{{_id}}-content" role="application" style="{{styles.content}}" class="ui5-popup-wrapper-content">
<div class="ui5-popup-wrapper-scroll">
<div id="{{_id}}-content" role="application" style="{{styles.content}}" class="ui5-popup-content">
<div class="ui5-popup-scroll">
<slot></slot>
</div>
</div>
{{> footer}}
<span id="{{_id}}-arrow" style="{{styles.arrow}}" class="{{classes.arrow}}"></span>
<span id="{{_id}}-arrow" style="{{styles.arrow}}" class="ui5-popover-arr"></span>
</div>
<span id="{{_id}}-lastfe" tabindex="0" @focusin={{focusHelper.forwardToFirst}}></span>
<div tabindex="0" id="{{_id}}-blocklayer" style="{{styles.blockLayer}}" class="{{classes.blockLayer}}"></div>
Expand Down
42 changes: 12 additions & 30 deletions packages/main/src/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class Popover extends Popup {
let maxContentHeight = Math.round(maxHeight);

if (this.hasHeader) {
const headerDomRef = this.getPopupDomRef().querySelector(".ui5-popup-wrapper-header");
const headerDomRef = this.getPopupDomRef().querySelector(".ui5-popup-header");
if (headerDomRef) {
maxContentHeight = Math.round(maxHeight - headerDomRef.offsetHeight);
}
Expand Down Expand Up @@ -502,7 +502,7 @@ class Popover extends Popup {
* @public
*/
openBy(element) {
if (this._isOpen) {
if (this.opened) {
return;
}

Expand All @@ -523,16 +523,16 @@ class Popover extends Popup {

this.setLocation(targetRect, popoverSize);

this._isOpen = true;
this.opened = true;

setTimeout(_ => {
if (this._isOpen) {
if (this.opened) {
this._dockInterval = setInterval(this.checkDocking.bind(this), dockInterval);
}
}, 0);

setTimeout(_ => {
if (this._isOpen) {
if (this.opened) {
document.addEventListener("mousedown", this._documentMouseDownHandler, true);
document.addEventListener("touchstart", this._documentMouseDownHandler, true);
}
Expand All @@ -544,7 +544,7 @@ class Popover extends Popup {
* @public
*/
close() {
if (!this._isOpen) {
if (!this.opened) {
return;
}

Expand All @@ -553,7 +553,7 @@ class Popover extends Popup {
return;
}

this._isOpen = false;
this.opened = false;

clearInterval(this._dockInterval);

Expand All @@ -569,8 +569,8 @@ class Popover extends Popup {
}

getPopoverSize() {
const popoverFrameDomRef = this.shadowRoot.querySelector(".ui5-popup-wrapper-frame"); // this.getDomRef();
const popoverDomRef = popoverFrameDomRef.querySelector(".ui5-popover-wrapper");
const popoverFrameDomRef = this.shadowRoot.querySelector(".ui5-popup-frame"); // this.getDomRef();
const popoverDomRef = popoverFrameDomRef.querySelector(".ui5-popover-root");

popoverFrameDomRef.style.visibility = "hidden";
popoverFrameDomRef.style.display = "block";
Expand All @@ -596,29 +596,11 @@ class Popover extends Popup {
}

get classes() {
const placementType = this._actualPlacementType;

return {
frame: {
"ui5-popup-wrapper-frame": true,
"ui5-popup-wrapper-frame--open": this._isOpen,
},
main: {
"ui5-popup-wrapper": true,
"ui5-popover-wrapper": true,
},
blockLayer: {
sapUiBLy: true,
"ui5-popup-wrapper-blockLayer": true,
"ui5-popup-wrapper-blockLayer--hidden": !this.modal || this._hideBlockLayer,
},
arrow: {
"ui5-popover-wrapper-arr": true,
"ui5-popover-wrapper-arr--hidden": this.noArrow,
"ui5-popover-wrapper-arrLeft": placementType === PopoverPlacementType.Right,
"ui5-popover-wrapper-arrRight": placementType === PopoverPlacementType.Left,
"ui5-popover-wrapper-arrUp": placementType === PopoverPlacementType.Bottom,
"ui5-popover-wrapper-arrDown": placementType === PopoverPlacementType.Top,
"ui5-popup-BLy": true,
"ui5-popup-blockLayer": true,
"ui5-popup-blockLayer--hidden": !this.modal || this._hideBlockLayer,
},
};
}
Expand Down
6 changes: 3 additions & 3 deletions packages/main/src/Popup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{{#if hasHeader}}
<header>
{{#if header.length}}
<div role="{{role}}" class="ui5-popup-wrapper-header">
<div role="{{role}}" class="ui5-popup-header">
<slot name="header"></slot>
</div>
{{else}}
<h2 role="{{role}}" class="ui5-popup-wrapper-header ui5-popup-wrapper-headerText">{{headerText}}</h2>
<h2 role="{{role}}" class="ui5-popup-header ui5-popup-headerText">{{headerText}}</h2>
{{/if}}
</header>
{{/if}}
Expand All @@ -15,7 +15,7 @@
{{#*inline "footer"}}
{{#if hasFooter}}
<footer>
<div class="ui5-popup-wrapper-footer">
<div class="ui5-popup-footer">
<slot name="footer"></slot>
</div>
</footer>
Expand Down
17 changes: 11 additions & 6 deletions packages/main/src/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ const metadata = {
type: String,
},

_isOpen: {
/**
* Indicates if the elements is on focus
* @private
*/
opened: {
type: Boolean,
},

_zIndex: {
type: Integer,
},
Expand Down Expand Up @@ -143,7 +148,7 @@ function createBLyBackStyle() {
const bodyStyleSheet = document.createElement("style");
bodyStyleSheet.type = "text/css";
bodyStyleSheet.innerHTML = `
.sapUiBLyBack {
.ui5-popup-BLy--back {
width: 100%;
height: 100%;
position: fixed;
Expand Down Expand Up @@ -190,11 +195,11 @@ function updateBodyScrolling(hasModal) {

function addBodyStyles() {
document.body.style.top = `-${window.pageYOffset}px`;
document.body.classList.add("sapUiBLyBack");
document.body.classList.add("ui5-popup-BLy--back");
}

function removeBodyStyles() {
document.body.classList.remove("sapUiBLyBack");
document.body.classList.remove("ui5-popup-BLy--back");
window.scrollTo(0, -parseFloat(document.body.style.top));
document.body.style.top = "";
}
Expand Down Expand Up @@ -271,7 +276,7 @@ class Popup extends UI5Element {

getPopupDomRef() {
const domRef = this.getDomRef();
return domRef && domRef.querySelector(".ui5-popup-wrapper");
return domRef && domRef.querySelector(".ui5-popup-root");
}

hitTest(_event) {
Expand Down Expand Up @@ -334,7 +339,7 @@ class Popup extends UI5Element {
}

onAfterRendering() {
if (!this._isOpen) {
if (!this.opened) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Select extends UI5Element {
get _isPickerOpen() {
const popover = this.shadowRoot.querySelector("#ui5-select--popover");

return popover && popover._isOpen;
return popover && popover.opened;
}

_togglePopover() {
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/features/InputSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Suggestions {

isOpened() {
const popover = this._getPopover();
return !!(popover && popover._isOpen);
return !!(popover && popover.opened);
}

_handleItemNavigation(forward) {
Expand Down Expand Up @@ -239,7 +239,7 @@ class Suggestions {
_getScrollContainer() {
if (!this._scrollContainer) {
const popover = this._getPopover();
this._scrollContainer = popover.getDomRef().querySelector(".ui5-popup-wrapper-content");
this._scrollContainer = popover.getDomRef().querySelector(".ui5-popup-content");
}

return this._scrollContainer;
Expand Down
37 changes: 29 additions & 8 deletions packages/main/src/themes/Dialog.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.ui5-dialog-wrapper-parent {
.ui5-dialog-root-parent {
position: fixed;
left: 0;
right: 0;
Expand All @@ -10,34 +10,55 @@
overflow: hidden;
}

.ui5-dialog-wrapper--stretched .ui5-dialog-wrapper {
:host([stretch]) .ui5-dialog-root {
width: 90%;
height: 93%;
min-width: 0;
min-height: 0;
}

.ui5-phone.ui5-dialog-wrapper-parent.ui5-dialog-wrapper--stretched .ui5-dialog-wrapper {
:host([stretch]) .ui5-phone.ui5-dialog-root-parent .ui5-dialog-root {
width: 100%;
height: 100%;
box-shadow: none;
border-radius: 0;
}


.ui5-dialog-wrapper {
.ui5-dialog-root {
display: flex;
flex-direction: column;
overflow: hidden;
}

.ui5-dialog-wrapper header,
.ui5-dialog-wrapper footer {
.ui5-dialog-root header,
.ui5-dialog-root footer {
flex-shrink: 0;
}

.ui5-dialog-wrapper-section {
.ui5-dialog-section {
overflow: hidden;
flex: 1 1 auto;
display: flex;
}

/*
* IE pair of styles
* to be removed later on
*/
ui5-dialog[stretch] .ui5-dialog-root {
width: 90%;
height: 93%;
min-width: 0;
min-height: 0;
}

ui5-dialog[stretch] .ui5-phone.ui5-dialog-root-parent .ui5-dialog-root {
width: 100%;
height: 100%;
box-shadow: none;
border-radius: 0;
}

ui5-dialog[opened] .ui5-popup-frame {
display: inline;
}
Loading