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

feat(ui5-product-switch): initial implementation #971

Merged
merged 39 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1119212
feat(ui5-productswitch): initial implementation
nnaydenow Nov 5, 2019
6c175d9
feat(ui5-productswitch): initial implementation fixes
nnaydenow Nov 6, 2019
1795514
Merge remote-tracking branch 'upstream/master'
nnaydenow Nov 18, 2019
0438511
feat(ui5-productswitch): ui5-button internal usage
nnaydenow Nov 18, 2019
59bd32c
feat(ui5-product-switch): stand alone component
nnaydenow Nov 20, 2019
90399b5
feat(ui5-product-switch): stand alone component fixes
nnaydenow Nov 20, 2019
427486d
feat(ui5-product-switch): stand alone component review fixes
nnaydenow Nov 20, 2019
bed648c
feat(ui5-product-switch): stand alone component review fixes 2
nnaydenow Nov 20, 2019
ece646d
feat(ui5-product-switch): docu improvement
nnaydenow Nov 21, 2019
bd4b7ef
feat(ui5-icon): change src property to name (#928)
fifoosid Nov 18, 2019
ace1ac4
feat(ui5-multicombobox): introduce open property and openChange event…
niyap Nov 18, 2019
58c1269
feat(ui5-multicombobox): implement ACC support (#937)
ivoplashkov Nov 18, 2019
e7a1db1
refactor: move icons to a separate package (#943)
vladitasev Nov 18, 2019
d8fc72c
feat(ui5-multicombobox): introduce required property (#935)
ivoplashkov Nov 18, 2019
939f7bf
chore: translation delivery (#951)
Nov 20, 2019
a344b9e
docs: update Configuration.md (#952)
ilhan007 Nov 21, 2019
6f684bd
refactor: centralize build logic in a tools package (#948)
vladitasev Nov 21, 2019
9e824d0
chore: remove mannualy written icon lit template (#950)
ilhan007 Nov 21, 2019
2ec4fdd
refactor(ui5-icon): ensure SVG not gaining focus on tab in IE (#945)
ilhan007 Nov 21, 2019
a1e6bfb
refactor(ui5-switch): subscribe event handlers within HBS template (#…
ignipae Nov 21, 2019
50700d0
refactor(ui5-checkbox): subscribe event handlers within HBS template …
ignipae Nov 21, 2019
597d93d
refactor(ui5-textarea): subscribe event handlers within HBS template
ignipae Nov 22, 2019
7f52ece
refactor: make the start task self-sufficient (#956)
vladitasev Nov 22, 2019
366e965
chore: change binaries permissions (#958)
ilhan007 Nov 22, 2019
33eafe9
refactor(ui5-shellbar): optimize coPilot SVG (#960)
ilhan007 Nov 25, 2019
1f385b1
feat(ui5-productswitch): initial implementation
nnaydenow Nov 5, 2019
c73e1d5
feat(ui5-productswitch): initial implementation fixes
nnaydenow Nov 6, 2019
004fae3
feat(ui5-productswitch): ui5-button internal usage
nnaydenow Nov 18, 2019
f506311
feat(ui5-product-switch): stand alone component
nnaydenow Nov 20, 2019
cffff2d
feat(ui5-product-switch): stand alone component fixes
nnaydenow Nov 20, 2019
6332306
feat(ui5-product-switch): stand alone component review fixes
nnaydenow Nov 20, 2019
0196282
feat(ui5-product-switch): stand alone component review fixes 2
nnaydenow Nov 20, 2019
1d1541c
feat(ui5-product-switch): docu improvement
nnaydenow Nov 21, 2019
970bc11
Merge branch 'master' of github.com:nnaydenow/ui5-webcomponents
nnaydenow Nov 25, 2019
f8479ae
feat(ui5-product-switch): stand alone component fixes
nnaydenow Nov 25, 2019
629a7af
feat(ui5-product-switch): initial implementation fixes
nnaydenow Nov 25, 2019
2846f99
Merge remote-tracking branch 'origin/master' into HEAD
nnaydenow Nov 25, 2019
9194cc5
Resolve merge conflicts
nnaydenow Nov 25, 2019
a55da70
feat(ui5-product-switch): default cursor is changed
nnaydenow Nov 25, 2019
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
2 changes: 2 additions & 0 deletions packages/fiori/bundle.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ import "./dist/json-imports/LocaleData.js" // same as above
import "./dist/features/CoPilotAnimation.js";

// FIORI components
import ProductSwitch from "./dist/ProductSwitch.js";
import ProductSwitchItem from "./dist/ProductSwitchItem.js";
import ShellBar from "./dist/ShellBar.js";
import ShellBarItem from "./dist/ShellBarItem.js";
3 changes: 3 additions & 0 deletions packages/fiori/src/ProductSwitch.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="ui5-product-switch-root" @focusin={{_onfocusin}}>
<slot></slot>
</div>
126 changes: 126 additions & 0 deletions packages/fiori/src/ProductSwitch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation.js";
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import ProductSwitchTemplate from "./generated/templates/ProductSwitchTemplate.lit.js";

// Styles
import ProductSwitchCss from "./generated/themes/ProductSwitch.css.js";


const metadata = {
tag: "ui5-product-switch",
properties: {
/**
* Indicates how many columns are displayed.
* @private
*/
desktopColumns: {
type: Integer,
},
},
slots: {
/**
* Defines the items of the <code>ui5-product-switch</code>.
*
* @type {HTMLElement[]}
* @slot
* @public
*/
"default": {
propertyName: "items",
type: HTMLElement,
},
},
};

/**
* @class
* <h3 class="comment-api-title">Overview</h3>
*
* The <code>ui5-product-switch</code> is a Fiori specific web component that is used in <code>ui5-shellbar</code> and allows the user easy switching between products.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ui5-product-switch is an SAP Fiori specific web component that is used in ui5-shellbar and allows the user to easily switch between products.

* <br><br>
* <h3>ES6 Module Import</h3>
* <code>import "@ui5/webcomponents-fiori/dist/ProductSwitch.js";</code>
*
* @constructor
* @author SAP SE
* @alias sap.ui.webcomponents.fiori.ProductSwitch
* @extends sap.ui.webcomponents.base.UI5Element
* @tagname ui5-product-switch
* @appenddocs ProductSwitchItem
* @public
* @since 1.0.0-rc.5
*/
class ProductSwitch extends UI5Element {
constructor() {
super();

this.initItemNavigation();
}

initItemNavigation() {
this._itemNavigation = new ItemNavigation(this, { rowSize: 4 });
this._itemNavigation.getItemsCallback = () => this.items;
}

static get metadata() {
return metadata;
}

static get render() {
return litRender;
}

static get styles() {
return ProductSwitchCss;
}

static get template() {
return ProductSwitchTemplate;
}

static get ROW_MIN_WIDTH() {
return {
ONE_COLUMN: 600,
THREE_COLUMN: 900,
};
}

onEnterDOM() {
this._handleResizeBound = this._handleResize.bind(this);

ResizeHandler.register(document.body, this._handleResizeBound);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why on the body?

}

onExitDOM() {
ResizeHandler.deregister(document.body, this._handleResizeBound);
}

onBeforeRendering() {
this.desktopColumns = this.items.length > 6 ? 4 : 3;
}

_handleResize() {
const documentWidth = document.body.clientWidth;

if (documentWidth <= this.constructor.ROW_MIN_WIDTH.ONE_COLUMN) {
this._itemNavigation.rowSize = 1;
} else if (documentWidth <= this.constructor.ROW_MIN_WIDTH.THREE_COLUMN || this.items.length <= 6) {
this._itemNavigation.rowSize = 3;
} else {
this._itemNavigation.rowSize = 4;
}
}

_onfocusin(event) {
const target = event.target;

this._itemNavigation.update(target);
}
}

ProductSwitch.define();

export default ProductSwitch;
43 changes: 43 additions & 0 deletions packages/fiori/src/ProductSwitchItem.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{#if targetSrc}}
<a class="ui5-product-switch-item-root"
data-sap-focus-ref
@focusout="{{_onfocusout}}"
@focusin="{{_onfocusin}}"
@mousedown="{{_onmousedown}}"
@keydown="{{_onkeydown}}"
@keyup="{{_onkeyup}}"
tabindex={{_tabIndex}}
href="{{targetSrc}}"
target="{{target}}">
{{> item}}
</a>
{{else}}
<div
class="ui5-product-switch-item-root"
data-sap-focus-ref
@focusout="{{_onfocusout}}"
@focusin="{{_onfocusin}}"
@mousedown="{{_onmousedown}}"
@keydown="{{_onkeydown}}"
@keyup="{{_onkeyup}}"
tabindex={{_tabIndex}}>
{{> item}}
</div>
{{/if}}

{{#*inline "item"}}
{{#if icon}}
<ui5-icon
class="ui5-product-switch-item-icon"
name="{{icon}}"
></ui5-icon>
{{/if}}
<span class="ui5-product-switch-item-text-content">
{{#if heading}}
<span class="ui5-product-switch-item-heading">{{heading}}</span>
{{/if}}
{{#if subtitle}}
<span class="ui5-product-switch-item-subtitle">{{subtitle}}</span>
{{/if}}
</span>
{{/inline}}
201 changes: 201 additions & 0 deletions packages/fiori/src/ProductSwitchItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/events/PseudoEvents.js";
import ProductSwitchItemTemplate from "./generated/templates/ProductSwitchItemTemplate.lit.js";

// Styles
import ProductSwitchItemCss from "./generated/themes/ProductSwitchItem.css.js";


const metadata = {
tag: "ui5-product-switch-item",
properties: {
/**
* Defines the title of the <code>ui5-product-switch-item</code>.
* @type {string}
* @defaultvalue ""
* @public
*/
heading: {
type: String,
},
/**
* Defines the subtitle of the <code>ui5-product-switch-item</code>.
* @type {string}
* @defaultvalue ""
* @public
*/
subtitle: {
type: String,
},
/**
* Defines the icon to be displayed as a graphical element within the <code>ui5-product-switch-item</code>.
* <br><br>
* Example:
* <br>
* <pre>ui5-product-switch-item icon="palette"</pre>
*
* See all the available icons in the <ui5-link target="_blank" href="https://openui5.hana.ondemand.com/test-resources/sap/m/demokit/iconExplorer/webapp/index.html" class="api-table-content-cell-link">Icon Explorer</ui5-link>.
*
* @type {string}
* @defaultvalue ""
* @public
*/
icon: {
type: String,
},
/**
* Specifies a target where the <code>targetSrc</code> content must be open.
* Options are the standard values for window.open() supported by browsers: _self, _top, _blank, _parent, _search. Alternatively, a frame name can be entered.
* @type {string}
* @defaultvalue "_self"
* @public
*/
target: {
type: String,
defaultValue: "_self",
},
/**
* Defines the <code>ui5-product-switch-item</code> target URI. Supports standard hyperlink behavior.
* @type {string}
* @defaultvalue ""
* @public
*/
targetSrc: {
type: String,
},
/**
* Used to switch the active state (pressed or not) of the <code>ui5-product-switch-item</code>.
* @private
*/
active: {
type: Boolean,
},
/**
* Indicates whether the element is focused.
* @private
*/
focused: {
type: Boolean,
},
_tabIndex: {
type: String,
defaultValue: "-1",
noAttribute: true,
},
},
slots: {
//
},
events: {
/**
* Fired when the <code>ui5-product-switch-item</code> is activated either with a
* click/tap or by using the Enter or Space key.
*
* @event
* @public
*/
click: {},
_focused: {},
},
};

/**
* @class
* <h3 class="comment-api-title">Overview</h3>
* The <code>ui5-product-switch-item</code> represents the items displayed in the <code>ui5-product-switch</code> web component
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a full stop at the end

* <b>Note:</b> <code>ui5-product-switch-item</code> is not supported when used outside of <code>ui5-product-switch</code>.
* <br><br>
* <h3>ES6 Module Import</h3>
* <code>import "@ui5/webcomponents-fiori/dist/ProductSwitchItem.js";</code>
*
* @constructor
* @author SAP SE
* @alias sap.ui.webcomponents.fiori.ProductSwitchItem
* @extends sap.ui.webcomponents.base.UI5Element
* @tagname ui5-product-switch-item
* @public
* @since 1.0.0-rc.5
*/
class ProductSwitchItem extends UI5Element {
constructor() {
super();

this._deactivate = () => {
if (this.active) {
this.active = false;
}
};
}

static get metadata() {
return metadata;
}

static get render() {
return litRender;
}

static get styles() {
return ProductSwitchItemCss;
}

static get template() {
return ProductSwitchItemTemplate;
}

onEnterDOM() {
document.addEventListener("mouseup", this._deactivate);
}

onExitDOM() {
document.removeEventListener("mouseup", this._deactivate);
}

_onmousedown() {
this.active = true;
}

_onkeydown(event) {
if (isSpace(event) || isEnter(event)) {
this.active = true;
}

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

if (isEnter(event)) {
this._fireItemClick();
}
}

_onkeyup(event) {
if (isSpace(event) || isEnter(event)) {
this.active = false;
}

if (isSpace(event)) {
this._fireItemClick();
}
}

_onfocusout() {
this.active = false;
this.focused = false;
}

_onfocusin(event) {
this.focused = true;

this.fireEvent("_focused", event);
}

_fireItemClick() {
this.fireEvent("click", { item: this });
}
}

ProductSwitchItem.define();

export default ProductSwitchItem;
Loading