Skip to content

Commit

Permalink
feat(ui5-page): implement responsive paddings #3412
Browse files Browse the repository at this point in the history
  • Loading branch information
fifoosid committed Jun 21, 2021
1 parent 76d7d39 commit fa3cdb7
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/fiori/src/Bar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
<div class="ui5-bar-content-container ui5-bar-endcontent-container">
<slot name="endContent"></slot>
</div>
</div>
</div>
32 changes: 31 additions & 1 deletion packages/fiori/src/Page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
import MediaRange from "@ui5/webcomponents-base/dist/MediaRange.js";
import PageBackgroundDesign from "./types/PageBackgroundDesign.js";

// Template
Expand Down Expand Up @@ -74,6 +75,17 @@ const metadata = {
hideFooter: {
type: Boolean,
},

/**
* Defines the current media query size.
*
* @type {string}
* @private
* @since 1.0.0-rc.15
*/
mediaRange: {
type: String,
},
},

slots: /** @lends sap.ui.webcomponents.fiori.Page.prototype */ {
Expand Down Expand Up @@ -172,6 +184,24 @@ class Page extends UI5Element {
await fetchI18nBundle("@ui5/webcomponents");
}

constructor() {
super();

this._updateMediaRange = this.updateMediaRange.bind(this);
}

onEnterDOM() {
ResizeHandler.register(this, this._updateMediaRange);
}

onExitDOM() {
ResizeHandler.deregister(this, this._updateMediaRange);
}

updateMediaRange() {
this.mediaRange = MediaRange.getCurrentRange(MediaRange.RANGESETS.RANGE_4STEPS, this.getDomRef().offsetWidth);
}

get _contentBottom() {
return !this.floatingFooter && !this.hideFooter ? "2.75rem" : "0";
}
Expand Down
47 changes: 40 additions & 7 deletions packages/fiori/src/themes/Page.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,57 @@
}

.ui5-page-footer-root {
width: 100%;
box-sizing: border-box;
position: absolute;
bottom: 0;
left: 0;
z-index: 2;
width: 100%;
}

:host([disable-scrolling]) .ui5-page-content-root {
overflow: hidden;
}

:host([floating-footer]) .ui5-page-footer-root {
left: 0.5rem;
right: 0.5rem;
width: auto;
opacity: 1;
bottom: 0.5rem;
}
/*** Responsive paddings ***/

:host([media-range="S"]) .ui5-page-content-root,
:host([media-range="S"][floating-footer]) .ui5-page-footer-root {
padding: 0 1rem;
}

:host([media-range="S"]) ::slotted([ui5-bar][slot="header"]) {
box-sizing: border-box;
padding: 0 .25rem;
}

:host([media-range="M"]) .ui5-page-content-root,
:host([media-range="L"]) .ui5-page-content-root,
:host([media-range="M"][floating-footer]) .ui5-page-footer-root,
:host([media-range="L"][floating-footer]) .ui5-page-footer-root {
padding: 0 2rem;
}

:host([media-range="M"]) ::slotted([ui5-bar][slot="header"]),
:host([media-range="L"]) ::slotted([ui5-bar][slot="header"]) {
box-sizing: border-box;
padding: 0 1.25rem;
}

:host([media-range="XL"]) .ui5-page-content-root,
:host([media-range="XL"][floating-footer]) .ui5-page-footer-root {
padding: 0 3rem;
}

:host([media-range="XL"]) ::slotted([ui5-bar][slot="header"]) {
box-sizing: border-box;
padding: 0 2.25rem;
}

:host([disable-scrolling]) .ui5-page-content-root {
overflow: hidden;
}

:host([hide-footer]:not([floating-footer])) .ui5-page-footer-root {
display: none;
Expand Down
14 changes: 6 additions & 8 deletions packages/fiori/test/pages/Page.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
</head>

<body style="background-color: var(--sapBackgroundColor);"></body>
<ui5-page id="page" backgroundDesign="List" floating-footer show-footer>
<div slot="header">
<ui5-bar design="Header">
<ui5-button icon="home" title="Go home" slot="startContent"></ui5-button>
<ui5-label slot="middleContent">Title</ui5-label>
<ui5-button icon="action-settings" title="Go to settings" slot="endContent"></ui5-button>
</ui5-bar>
</div>
<ui5-page id="page" background-design="List" floating-footer show-footer>
<ui5-bar design="Header" slot="header">
<ui5-button icon="home" title="Go home" slot="startContent"></ui5-button>
<ui5-label slot="middleContent">Title</ui5-label>
<ui5-button icon="action-settings" title="Go to settings" slot="endContent"></ui5-button>
</ui5-bar>

<div>
<div style="width: 100%;">
Expand Down
23 changes: 15 additions & 8 deletions packages/fiori/test/samples/Page.sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
<section>
<h3>Page with floating footer</h3>
<div class="snippet">
<ui5-page id="page" style="height: 700px; width: 500px" backgroundDesign="List" floating-footer show-footer>
<div slot="header">
<ui5-bar design="Header">
<ui5-button icon="home" title="Go home" slot="startContent"></ui5-button>
<ui5-label slot="middleContent">Title</ui5-label>
<ui5-button icon="action-settings" title="Go to settings" slot="endContent"></ui5-button>
</ui5-bar>
</div>
<ui5-page id="page" style="height: 700px; width: 500px" background-design="List" floating-footer show-footer>
<ui5-bar design="Header" slot="header">
<ui5-button icon="home" title="Go home" slot="startContent"></ui5-button>
<ui5-label slot="middleContent">Title</ui5-label>
<ui5-button icon="action-settings" title="Go to settings" slot="endContent"></ui5-button>
</ui5-bar>

<div>
<p class="content-paragraph">
Expand Down Expand Up @@ -80,6 +78,7 @@ <h3>Page with floating footer</h3>
</ui5-page>
</div>
<pre class="prettyprint lang-html"><xmp>
<<<<<<< HEAD
<ui5-page id="page" backgroundDesign="List" floating-footer show-footer>
<div slot="header">
<ui5-bar design="Header">
Expand All @@ -88,6 +87,14 @@ <h3>Page with floating footer</h3>
<ui5-button icon="action-settings" title="Go to settings" slot="endContent"></ui5-button>
</ui5-bar>
</div>
=======
<ui5-page id="page" background-design="List" floating-footer show-footer>
<ui5-bar design="Header" slot="header">
<ui5-button icon="home" title="Go home" slot="startContent"></ui5-button>
<ui5-label slot="middleContent">Title</ui5-label>
<ui5-button icon="action-settings" title="Go to settings" slot="endContent"></ui5-button>
</ui5-bar>
>>>>>>> b720393d0... feat(ui5-page): implement responsive paddings (#3412)

<div>
<p>
Expand Down

0 comments on commit fa3cdb7

Please sign in to comment.