-
Notifications
You must be signed in to change notification settings - Fork 273
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
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 6c175d9
feat(ui5-productswitch): initial implementation fixes
nnaydenow 1795514
Merge remote-tracking branch 'upstream/master'
nnaydenow 0438511
feat(ui5-productswitch): ui5-button internal usage
nnaydenow 59bd32c
feat(ui5-product-switch): stand alone component
nnaydenow 90399b5
feat(ui5-product-switch): stand alone component fixes
nnaydenow 427486d
feat(ui5-product-switch): stand alone component review fixes
nnaydenow bed648c
feat(ui5-product-switch): stand alone component review fixes 2
nnaydenow ece646d
feat(ui5-product-switch): docu improvement
nnaydenow bd4b7ef
feat(ui5-icon): change src property to name (#928)
fifoosid ace1ac4
feat(ui5-multicombobox): introduce open property and openChange event…
niyap 58c1269
feat(ui5-multicombobox): implement ACC support (#937)
ivoplashkov e7a1db1
refactor: move icons to a separate package (#943)
vladitasev d8fc72c
feat(ui5-multicombobox): introduce required property (#935)
ivoplashkov 939f7bf
chore: translation delivery (#951)
a344b9e
docs: update Configuration.md (#952)
ilhan007 6f684bd
refactor: centralize build logic in a tools package (#948)
vladitasev 9e824d0
chore: remove mannualy written icon lit template (#950)
ilhan007 2ec4fdd
refactor(ui5-icon): ensure SVG not gaining focus on tab in IE (#945)
ilhan007 a1e6bfb
refactor(ui5-switch): subscribe event handlers within HBS template (#…
ignipae 50700d0
refactor(ui5-checkbox): subscribe event handlers within HBS template …
ignipae 597d93d
refactor(ui5-textarea): subscribe event handlers within HBS template
ignipae 7f52ece
refactor: make the start task self-sufficient (#956)
vladitasev 366e965
chore: change binaries permissions (#958)
ilhan007 33eafe9
refactor(ui5-shellbar): optimize coPilot SVG (#960)
ilhan007 1f385b1
feat(ui5-productswitch): initial implementation
nnaydenow c73e1d5
feat(ui5-productswitch): initial implementation fixes
nnaydenow 004fae3
feat(ui5-productswitch): ui5-button internal usage
nnaydenow f506311
feat(ui5-product-switch): stand alone component
nnaydenow cffff2d
feat(ui5-product-switch): stand alone component fixes
nnaydenow 6332306
feat(ui5-product-switch): stand alone component review fixes
nnaydenow 0196282
feat(ui5-product-switch): stand alone component review fixes 2
nnaydenow 1d1541c
feat(ui5-product-switch): docu improvement
nnaydenow 970bc11
Merge branch 'master' of github.com:nnaydenow/ui5-webcomponents
nnaydenow f8479ae
feat(ui5-product-switch): stand alone component fixes
nnaydenow 629a7af
feat(ui5-product-switch): initial implementation fixes
nnaydenow 2846f99
Merge remote-tracking branch 'origin/master' into HEAD
nnaydenow 9194cc5
Resolve merge conflicts
nnaydenow a55da70
feat(ui5-product-switch): default cursor is changed
nnaydenow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
* <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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 inui5-shellbar
and allows the user to easily switch between products.