|
| 1 | +import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js"; |
| 2 | +import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js"; |
| 3 | +import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js"; |
| 4 | +import PageBackgroundDesign from "./types/PageBackgroundDesign.js"; |
| 5 | + |
| 6 | +// Template |
| 7 | +import PageTemplate from "./generated/templates/PageTemplate.lit.js"; |
| 8 | + |
| 9 | +// Styles |
| 10 | +import PageCss from "./generated/themes/Page.css.js"; |
| 11 | + |
| 12 | + |
| 13 | +/** |
| 14 | + * @public |
| 15 | + */ |
| 16 | +const metadata = { |
| 17 | + tag: "ui5-page", |
| 18 | + managedSlots: true, |
| 19 | + languageAware: true, |
| 20 | + properties: /** @lends sap.ui.webcomponents.fiori.Page.prototype */ { |
| 21 | + |
| 22 | + /** |
| 23 | + * Defines the background color of the <code>ui5-page</code>. |
| 24 | + * <br><br> |
| 25 | + * <b>Note:</b> When a ui5-list is placed inside the page, we recommend using “List” to ensure better color contrast. |
| 26 | + * <br><br> |
| 27 | + * Available options are: |
| 28 | + * <ul> |
| 29 | + * <li><code>List</code></li> |
| 30 | + * <li><code>Solid</code></li> |
| 31 | + * <li><code>Standard</code></li> (default) |
| 32 | + * <li><code>Transparent</code></li> |
| 33 | + * <ul> |
| 34 | + * @type {PageBackgroundDesign} |
| 35 | + * @defaultvalue "Standard" |
| 36 | + * @public |
| 37 | + */ |
| 38 | + backgroundDesign: { |
| 39 | + type: String, |
| 40 | + defaultValue: PageBackgroundDesign.Standard, |
| 41 | + }, |
| 42 | + |
| 43 | + /** |
| 44 | + * Disables vertical scrolling of page content. |
| 45 | + * If set to true, there will be no vertical scrolling at all. |
| 46 | + * |
| 47 | + * @type {Boolean} |
| 48 | + * @defaultvalue false |
| 49 | + * @public |
| 50 | + */ |
| 51 | + disableScrolling: { |
| 52 | + type: Boolean, |
| 53 | + }, |
| 54 | + |
| 55 | + /** |
| 56 | + * Defines if the footer should float over the content. |
| 57 | + * <br><br> |
| 58 | + * <b>Note:</b> When set to true the footer floats over the content with a slight offset from the bottom, otherwise it is fixed at the very bottom of the page. |
| 59 | + * @type {Boolean} |
| 60 | + * @defaultvalue true |
| 61 | + * @public |
| 62 | + */ |
| 63 | + floatingFooter: { |
| 64 | + type: Boolean, |
| 65 | + }, |
| 66 | + |
| 67 | + /** |
| 68 | + * Defines the footer visibility. |
| 69 | + * |
| 70 | + * @type {Boolean} |
| 71 | + * @defaultvalue false |
| 72 | + * @public |
| 73 | + */ |
| 74 | + hideFooter: { |
| 75 | + type: Boolean, |
| 76 | + }, |
| 77 | + }, |
| 78 | + |
| 79 | + slots: /** @lends sap.ui.webcomponents.fiori.Page.prototype */ { |
| 80 | + |
| 81 | + /** |
| 82 | + * Defines the header HTML Element. |
| 83 | + * |
| 84 | + * @type {HTMLElement[]} |
| 85 | + * @slot |
| 86 | + * @public |
| 87 | + */ |
| 88 | + header: { |
| 89 | + type: HTMLElement, |
| 90 | + }, |
| 91 | + |
| 92 | + /** |
| 93 | + * Defines the content HTML Element. |
| 94 | + * |
| 95 | + * @type {HTMLElement[]} |
| 96 | + * @slot |
| 97 | + * @public |
| 98 | + */ |
| 99 | + "default": { |
| 100 | + propertyName: "content", |
| 101 | + type: HTMLElement, |
| 102 | + }, |
| 103 | + |
| 104 | + /** |
| 105 | + * Defines the footer HTML Element. |
| 106 | + * |
| 107 | + * @type {HTMLElement[]} |
| 108 | + * @slot |
| 109 | + * @public |
| 110 | + */ |
| 111 | + footer: { |
| 112 | + type: HTMLElement, |
| 113 | + }, |
| 114 | + }, |
| 115 | + events: /** @lends sap.ui.webcomponents.fiori.Page.prototype */ { |
| 116 | + }, |
| 117 | +}; |
| 118 | + |
| 119 | +/** |
| 120 | + * @class |
| 121 | + * |
| 122 | + * <h3 class="comment-api-title">Overview</h3> |
| 123 | + * |
| 124 | + * The <code>ui5-page</code> is a container control that holds one whole screen of an application. |
| 125 | + * The page has three distinct areas that can hold content - a header, content area and a footer. |
| 126 | + * <h3>Structure</h3> |
| 127 | + * <h4>Header</h4> |
| 128 | + * The top most area of the page is occupied by the header. The standard header includes a navigation button and a title. |
| 129 | + * <h4>Content</h4> |
| 130 | + * The content occupies the main part of the page. Only the content area is scrollable by default. |
| 131 | + * This can be prevented by setting <code>enableScrolling</code> to <code>false</code>. |
| 132 | + * <h4>Footer</h4> |
| 133 | + * The footer is optional and occupies the fixed bottom part of the page. Alternatively, the footer can be floating above the bottom part of the content. |
| 134 | + * This is enabled with the <code>floatingFooter</code> property. |
| 135 | + * |
| 136 | + * |
| 137 | + * <h3>ES6 Module Import</h3> |
| 138 | + * |
| 139 | + * <code>import @ui5/webcomponents-fiori/dist/Page.js";</code> |
| 140 | + * |
| 141 | + * @constructor |
| 142 | + * @author SAP SE |
| 143 | + * @alias sap.ui.webcomponents.fiori.Page |
| 144 | + * @extends UI5Element |
| 145 | + * @tagname ui5-page |
| 146 | + * @since 1.0.0-rc.12 |
| 147 | + * @public |
| 148 | + */ |
| 149 | +class Page extends UI5Element { |
| 150 | + constructor() { |
| 151 | + super(); |
| 152 | + this.i18nBundle = getI18nBundle("@ui5/webcomponents"); |
| 153 | + } |
| 154 | + |
| 155 | + static get metadata() { |
| 156 | + return metadata; |
| 157 | + } |
| 158 | + |
| 159 | + static get render() { |
| 160 | + return litRender; |
| 161 | + } |
| 162 | + |
| 163 | + static get styles() { |
| 164 | + return PageCss; |
| 165 | + } |
| 166 | + |
| 167 | + static get template() { |
| 168 | + return PageTemplate; |
| 169 | + } |
| 170 | + |
| 171 | + static async onDefine() { |
| 172 | + await fetchI18nBundle("@ui5/webcomponents"); |
| 173 | + } |
| 174 | + |
| 175 | + get _contentBottom() { |
| 176 | + return !this.floatingFooter && !this.hideFooter ? "2.75rem" : "0"; |
| 177 | + } |
| 178 | + |
| 179 | + get _contentPaddingBottom() { |
| 180 | + return this.floatingFooter && !this.hideFooter ? "3.5rem" : "0"; |
| 181 | + } |
| 182 | + |
| 183 | + get styles() { |
| 184 | + return { |
| 185 | + content: { |
| 186 | + "padding-bottom": this.footer.length && this._contentPaddingBottom, |
| 187 | + "bottom": this.footer.length && this._contentBottom, |
| 188 | + }, |
| 189 | + }; |
| 190 | + } |
| 191 | +} |
| 192 | + |
| 193 | +Page.define(); |
| 194 | + |
| 195 | +export default Page; |
0 commit comments