From 6fbd708ae0ed8129dad23d9a3c214115b15f037e Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 27 Mar 2018 16:23:39 -0400 Subject: [PATCH] refactor(list): rename methods and update docs --- core/src/components.d.ts | 16 +++++++++---- .../components/item-sliding/item-sliding.tsx | 6 ++--- core/src/components/list/list.tsx | 23 ++++++++++++------- core/src/components/list/readme.md | 15 ++++++++++-- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 2a704be06a..4df7052b6a 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -2778,11 +2778,17 @@ declare global { declare global { interface HTMLIonListElement extends HTMLStencilElement { /** - * Close the sliding items. Items can also be closed from the [Item Sliding](../../item-sliding/ItemSliding). + * Close the sliding items. Items can also be closed from the [Item Sliding](../../item-sliding/ItemSliding). Returns a boolean value of whether it closed an item or not. */ 'closeSlidingItems': () => boolean; - 'getOpenedItem': () => ItemSliding; - 'setOpenedItem': (itemSliding: ItemSliding) => void; + /** + * Get the [Item Sliding](../../item-sliding/ItemSliding) that is currently opene. + */ + 'getOpenItem': () => ItemSliding; + /** + * Set an [Item Sliding](../../item-sliding/ItemSliding) as the open item. + */ + 'setOpenItem': (itemSliding: ItemSliding) => void; } var HTMLIonListElement: { prototype: HTMLIonListElement; @@ -2996,7 +3002,7 @@ declare global { declare global { interface HTMLIonMenuButtonElement extends HTMLStencilElement { /** - * Automatically hides the content when the corresponding menu is not active + * Automatically hides the menu button when the corresponding menu is not active */ 'autoHide': boolean; /** @@ -3022,7 +3028,7 @@ declare global { namespace JSXElements { export interface IonMenuButtonAttributes extends HTMLAttributes { /** - * Automatically hides the content when the corresponding menu is not active + * Automatically hides the menu button when the corresponding menu is not active */ 'autoHide'?: boolean; /** diff --git a/core/src/components/item-sliding/item-sliding.tsx b/core/src/components/item-sliding/item-sliding.tsx index 64d6cfc908..e7f8465edd 100644 --- a/core/src/components/item-sliding/item-sliding.tsx +++ b/core/src/components/item-sliding/item-sliding.tsx @@ -130,7 +130,7 @@ export class ItemSliding { } private canStart(): boolean { - const selected = this.list && this.list.getOpenedItem(); + const selected = this.list && this.list.getOpenItem(); if (selected && selected !== this) { this.closeOpened(); return false; @@ -139,7 +139,7 @@ export class ItemSliding { } private onDragStart() { - this.list && this.list.setOpenedItem(this); + this.list && this.list.setOpenItem(this); if (this.tmr) { clearTimeout(this.tmr); @@ -243,7 +243,7 @@ export class ItemSliding { this.state = SlidingState.Disabled; this.tmr = null; }, 600); - this.list && this.list.setOpenedItem(null); + this.list && this.list.setOpenItem(null); style.transform = ''; return; } diff --git a/core/src/components/list/list.tsx b/core/src/components/list/list.tsx index 84f3451993..aa66250af6 100644 --- a/core/src/components/list/list.tsx +++ b/core/src/components/list/list.tsx @@ -14,26 +14,33 @@ import { ItemSliding } from '../item-sliding/item-sliding'; } }) export class List { - private openedItem: ItemSliding|null; + private openItem: ItemSliding | null; + /** + * Get the [Item Sliding](../../item-sliding/ItemSliding) that is currently opene. + */ @Method() - getOpenedItem() { - return this.openedItem; + getOpenItem() { + return this.openItem; } + /** + * Set an [Item Sliding](../../item-sliding/ItemSliding) as the open item. + */ @Method() - setOpenedItem(itemSliding: ItemSliding|null) { - this.openedItem = itemSliding; + setOpenItem(itemSliding: ItemSliding | null) { + this.openItem = itemSliding; } /** * Close the sliding items. Items can also be closed from the [Item Sliding](../../item-sliding/ItemSliding). + * Returns a boolean value of whether it closed an item or not. */ @Method() closeSlidingItems(): boolean { - if (this.openedItem) { - this.openedItem.close(); - this.openedItem = null; + if (this.openItem) { + this.openItem.close(); + this.openItem = null; return true; } return false; diff --git a/core/src/components/list/readme.md b/core/src/components/list/readme.md index a287c459b3..de98a93a72 100644 --- a/core/src/components/list/readme.md +++ b/core/src/components/list/readme.md @@ -1,5 +1,11 @@ # ion-list +Lists are made up of multiple rows of items which can contain text, buttons, toggles, +icons, thumbnails, and much more. Lists generally contain items with similar +data content, such as images and text. + +Lists support several interactions including swiping items to reveal options, dragging to +reorder items within the list, and deleting items. @@ -10,12 +16,17 @@ #### closeSlidingItems() Close the sliding items. Items can also be closed from the [Item Sliding](../../item-sliding/ItemSliding). +Returns a boolean value of whether it closed an item or not. -#### getOpenedItem() +#### getOpenItem() + +Get the [Item Sliding](../../item-sliding/ItemSliding) that is currently opene. -#### setOpenedItem() +#### setOpenItem() + +Set an [Item Sliding](../../item-sliding/ItemSliding) as the open item.