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-flexlible-column-layout): Custom layouts configuration #1987

Merged
merged 2 commits into from
Jul 29, 2020
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
20 changes: 18 additions & 2 deletions packages/fiori/src/FlexibleColumnLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ const metadata = {
type: Integer,
defaultValue: 0,
},

/**
* Allows the user to replace the whole layouts configuration
*
* @type {Object}
* @private
* @sap-restricted
*/
_layoutsConfiguration: {
type: Object,
defaultValue: undefined,
},
},
slots: /** @lends sap.ui.webcomponents.fiori.FlexibleColumnLayout.prototype */ {
/**
Expand Down Expand Up @@ -383,7 +395,7 @@ class FlexibleColumnLayout extends UI5Element {
}

nextColumnLayout(layout) {
return getLayoutsByMedia()[this.media][layout].layout;
return this._effectiveLayoutsByMedia[this.media][layout].layout;
}

calcVisibleColumns(colLayot) {
Expand Down Expand Up @@ -559,7 +571,7 @@ class FlexibleColumnLayout extends UI5Element {
}

get effectiveArrowsInfo() {
return getLayoutsByMedia()[this.media][this.layout].arrows;
return this._effectiveLayoutsByMedia[this.media][this.layout].arrows;
}

get media() {
Expand Down Expand Up @@ -601,6 +613,10 @@ class FlexibleColumnLayout extends UI5Element {
get accEndColumnText() {
return this.i18nBundle.getText(FCL_END_COLUMN_TXT);
}

get _effectiveLayoutsByMedia() {
return this._layoutsConfiguration || getLayoutsByMedia();
}
}

FlexibleColumnLayout.define();
Expand Down
328 changes: 328 additions & 0 deletions packages/fiori/test/pages/FCLCustom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="utf-8">

<title>Flexible Column Layout</title>

<script>delete Document.prototype.adoptedStyleSheets</script>
<script src="../../webcomponentsjs/webcomponents-loader.js"></script>
<script src="../../resources/bundle.esm.js" type="module"></script>
<script nomodule src="../../resources/bundle.es5.js"></script>

<style>
html, body {
padding: 0;
margin: 0;
}

.sectionTitle, ui5-input, .testButton {
margin-left: 1rem;
}

.col {
height: 100%;
}

.colHeader {
display: flex;
align-items: center;
justify-content: space-between;
height: 2.75rem;
padding: 0.25rem 1rem 0.25rem 1rem;
background: var(--sapList_Background);
box-sizing: border-box;
}

.colSubHeader {
display: flex;
align-items: center;
box-sizing: border-box;
}

.productInfo {
display:flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
}
</style>
</head>

<body style="background-color: var(--sapBackgroundColor);">

<ui5-flexible-column-layout id="fcl3" layout="ThreeColumnsMidExpanded">
<!-- start column -->
<div style="box-sizing: border-box;" slot="startColumn">
<div style="padding: 1rem">
<ui5-title>Column 1</ui5-title>
</div>
<ui5-list>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
</ui5-list>
</div>

<!-- mid column -->
<div style="box-sizing: border-box;" slot="midColumn">
<div style="padding: 1rem">
<ui5-title>Column 2</ui5-title>
</div>
<ui5-list>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
</ui5-list>
</div>

<!-- end column -->
<div style="box-sizing: border-box;" slot="endColumn">
<div style="padding: 1rem">
<ui5-title>Column 3</ui5-title>
</div>

<ui5-list>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
<ui5-li>Hello worild!</ui5-li>
</ui5-list>
</div>
</ui5-flexible-column-layout>

<script>
var fcl = document.getElementById("fcl3");
fcl._layoutsConfiguration = {
desktop: {
"OneColumn": {
layout: ["100%", 0, 0],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"TwoColumnsStartExpanded": {
layout: ["90%", "10%", 0],
arrows: [
{ visible: true, dir: "mirror" },
{ visible: false, dir: null },
],
},
"TwoColumnsMidExpanded": {
layout: ["10%", "90%", 0],
arrows: [
{ visible: true, dir: null },
{ visible: false, dir: null },
],
},
"ThreeColumnsStartExpanded": {
layout: ["15%", "70%", "15%"],
arrows: [
{ visible: true, dir: null },
{ visible: true, dir: null },
],
},
"ThreeColumnsMidExpanded": {
layout: ["15%", "70%", "15%"],
arrows: [
{ visible: true, dir: null },
{ visible: true, dir: null },
],
},
"ThreeColumnsEndExpanded": {
layout: ["15%", "15%", "70%"],
arrows: [
{ visible: false, dir: null, separator: true },
{ visible: true, dir: "mirror" },
],
},
"ThreeColumnsStartExpandedEndHidden": {
layout: ["90%", "10%", 0],
arrows: [
{ visible: true, dir: "mirror" },
{ visible: false, dir: null },
],
},
"ThreeColumnsMidExpandedEndHidden": {
layout: ["10%", "90%", 0],
arrows: [
{ visible: true, dir: null },
{ visible: true, dir: null },
],
},
"MidColumnFullScreen": {
layout: [0, "100%", 0],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"EndColumnFullScreen": {
layout: [0, 0, "100%"],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
},
tablet: {
"OneColumn": {
layout: ["100%", 0, 0],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"TwoColumnsStartExpanded": {
layout: ["90%", "10%", 0],
arrows: [
{ visible: true, dir: "mirror" },
{ visible: false, dir: null },
],
},
"TwoColumnsMidExpanded": {
layout: ["10%", "90%", 0],
arrows: [
{ visible: true, dir: null },
{ visible: false, dir: null },
],
},
"ThreeColumnsStartExpanded": {
layout: ["90%", "10%", 0],
arrows: [
{ visible: true, dir: "mirror" },
{ visible: false, dir: null },
],
},
"ThreeColumnsMidExpanded": {
layout: [0, "90%", "10%"],
arrows: [
{ visible: true, dir: null },
{ visible: true, dir: null },
],
},
"ThreeColumnsEndExpanded": {
layout: [0, "10%", "90%"],
arrows: [
{ visible: false, dir: null },
{ visible: true, dir: "mirror" },
],
},
"ThreeColumnsStartExpandedEndHidden": {
layout: ["90%", "10%", 0],
arrows: [
{ visible: true, dir: "mirror" },
{ visible: false, dir: null },
],
},
"ThreeColumnsMidExpandedEndHidden": {
layout: ["10%", "90%", 0],
arrows: [
{ visible: true, dir: null },
{ visible: true, dir: null },
],
},
"MidColumnFullScreen": {
layout: [0, "100%", 0],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"EndColumnFullScreen": {
layout: [0, 0, "100%"],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
},
phone: {
"OneColumn": {
layout: ["100%", 0, 0],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"TwoColumnsStartExpanded": {
layout: [0, "100%", 0],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"TwoColumnsMidExpanded": {
layout: [0, "100%", 0],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"ThreeColumnsStartExpanded": {
layout: [0, 0, "100%"],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"ThreeColumnsMidExpanded": {
layout: [0, 0, "100%"],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"ThreeColumnsEndExpanded": {
layout: [0, 0, "100%"],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"ThreeColumnsStartExpandedEndHidden": {
layout: [0, 0, "100%"],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"ThreeColumnsMidExpandedEndHidden": {
layout: [0, 0, "100%"],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"MidColumnFullScreen": {
layout: [0, "100%", 0],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
"EndColumnFullScreen": {
layout: [0, 0, "100%"],
arrows: [
{ visible: false, dir: null },
{ visible: false, dir: null },
],
},
},
};
</script>

</body>
</html>