From d20bf9cdc762ea9ce6bebf4601ee5cd74f5bb829 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 28 Nov 2017 20:43:20 -0600 Subject: [PATCH] chore(item-sliding): move item-options, item-option to separate directories --- packages/core/src/components.d.ts | 4 +- .../item-option.tsx | 8 +- .../core/src/components/item-option/readme.md | 58 ++++++++ .../item-options.tsx | 21 --- .../src/components/item-options/readme.md | 57 +++++++ .../components/item-sliding/item-sliding.tsx | 103 +------------ .../src/components/item-sliding/readme.md | 139 +++++++++++++----- packages/core/src/index.d.ts | 2 +- 8 files changed, 226 insertions(+), 166 deletions(-) rename packages/core/src/components/{item-sliding => item-option}/item-option.tsx (85%) create mode 100644 packages/core/src/components/item-option/readme.md rename packages/core/src/components/{item-sliding => item-options}/item-options.tsx (57%) create mode 100644 packages/core/src/components/item-options/readme.md diff --git a/packages/core/src/components.d.ts b/packages/core/src/components.d.ts index 3ae09208a4..599ac1c9df 100644 --- a/packages/core/src/components.d.ts +++ b/packages/core/src/components.d.ts @@ -1252,7 +1252,7 @@ declare global { import { ItemOption as IonItemOption -} from './components/item-sliding/item-option'; +} from './components/item-option/item-option'; declare global { interface HTMLIonItemOptionElement extends IonItemOption, HTMLElement { @@ -1286,7 +1286,7 @@ declare global { import { ItemOptions as IonItemOptions -} from './components/item-sliding/item-options'; +} from './components/item-options/item-options'; declare global { interface HTMLIonItemOptionsElement extends IonItemOptions, HTMLElement { diff --git a/packages/core/src/components/item-sliding/item-option.tsx b/packages/core/src/components/item-option/item-option.tsx similarity index 85% rename from packages/core/src/components/item-sliding/item-option.tsx rename to packages/core/src/components/item-option/item-option.tsx index 5218c8d321..65b589d260 100644 --- a/packages/core/src/components/item-sliding/item-option.tsx +++ b/packages/core/src/components/item-option/item-option.tsx @@ -1,12 +1,6 @@ import { Component, Prop } from '@stencil/core'; -/** - * @name ItemOption - * @description - * The option button for an `ion-item-sliding`. Must be placed inside of an ``. - * You can combine the `(ionSwipe)` event and the `expandable` directive to create a full swipe - * action for the item. - */ + @Component({ tag: 'ion-item-option', host: { diff --git a/packages/core/src/components/item-option/readme.md b/packages/core/src/components/item-option/readme.md new file mode 100644 index 0000000000..4c6cff7de8 --- /dev/null +++ b/packages/core/src/components/item-option/readme.md @@ -0,0 +1,58 @@ +# ion-item-option + +The option button for an `ion-item-sliding`. Must be placed inside of an ``. +You can combine the `(ionSwipe)` event and the `expandable` directive to create a full swipe +action for the item. + + + + + +## Properties + +#### color + +string + + +#### disabled + +boolean + + +#### href + +string + + +#### mode + +any + + +## Attributes + +#### color + +string + + +#### disabled + +boolean + + +#### href + +string + + +#### mode + +any + + + +---------------------------------------------- + +*Built by [StencilJS](https://stenciljs.com/)* diff --git a/packages/core/src/components/item-sliding/item-options.tsx b/packages/core/src/components/item-options/item-options.tsx similarity index 57% rename from packages/core/src/components/item-sliding/item-options.tsx rename to packages/core/src/components/item-options/item-options.tsx index caf9e2b431..4f27596ccc 100644 --- a/packages/core/src/components/item-sliding/item-options.tsx +++ b/packages/core/src/components/item-options/item-options.tsx @@ -2,27 +2,6 @@ import { Component, Element, Event, EventEmitter, Method, Prop } from '@stencil/ import { Side, isRightSide } from '../../utils/helpers'; -/** - * @name ItemOptions - * @description - * The option buttons for an `ion-item-sliding`. These buttons can be placed either on the left or right side. - * You can combine the `(ionSwipe)` event plus the `expandable` directive to create a full swipe action for the item. - * - * @usage - * - * ```html - * - * - * Item 1 - * - * - * - * - * - * - * - *``` - */ @Component({ tag: 'ion-item-options' }) diff --git a/packages/core/src/components/item-options/readme.md b/packages/core/src/components/item-options/readme.md new file mode 100644 index 0000000000..0efda93da1 --- /dev/null +++ b/packages/core/src/components/item-options/readme.md @@ -0,0 +1,57 @@ +# ion-item-options + +The option buttons for an `ion-item-sliding`. These buttons can be placed either on the left or right side. +You can combine the `(ionSwipe)` event plus the `expandable` directive to create a full swipe action for the item. + + +```html + + + Item 1 + + + + + + + +``` + + + + + +## Properties + +#### side + +any + + +## Attributes + +#### side + +any + + +## Events + +#### ionSwipe + + +## Methods + +#### fireSwipeEvent() + + +#### isRightSide() + + +#### width() + + + +---------------------------------------------- + +*Built by [StencilJS](https://stenciljs.com/)* diff --git a/packages/core/src/components/item-sliding/item-sliding.tsx b/packages/core/src/components/item-sliding/item-sliding.tsx index 538cf87a29..fe8cd08843 100644 --- a/packages/core/src/components/item-sliding/item-sliding.tsx +++ b/packages/core/src/components/item-sliding/item-sliding.tsx @@ -2,7 +2,7 @@ import { Component, Element, Event, EventEmitter, Method, State } from '@stencil import { GestureDetail } from '../../index'; import { swipeShouldReset } from '../../utils/helpers'; -import { ItemOptions } from './item-options'; +import { ItemOptions } from '../item-options/item-options'; const SWIPE_MARGIN = 30; @@ -26,107 +26,6 @@ export const enum SlidingState { } -/** - * @name ItemSliding - * @description - * A sliding item is a list item that can be swiped to reveal buttons. It requires - * an [Item](../Item) component as a child and a [List](../../list/List) component as - * a parent. All buttons to reveal can be placed in the `` element. - * - * @usage - * ```html - * - * - * - * Item - * - * - * Favorite - * Share - * - * - * - * Unread - * - * - * - * ``` - * - * ### Swipe Direction - * By default, the buttons are revealed when the sliding item is swiped from right to left, - * so the buttons are placed in the right side. But it's also possible to reveal them - * in the right side (sliding from left to right) by setting the `side` attribute - * on the `ion-item-options` element. Up to 2 `ion-item-options` can used at the same time - * in order to reveal two different sets of buttons depending the swipping direction. - * - * ```html - * - * - * - * Archive - * - * - * - * - * - * - * Archive - * - * - * ``` - * - * ### Listening for events (ionDrag) and (ionSwipe) - * It's possible to know the current relative position of the sliding item by subscribing - * to the (ionDrag)` event. - * - * ```html - * - * Item - * - * Favorite - * - * - * ``` - * - * ### Button Layout - * If an icon is placed with text in the option button, by default it will - * display the icon on top of the text. This can be changed to display the icon - * to the left of the text by setting `icon-start` as an attribute on the - * `` element. - * - * ```html - * - * - * - * Archive - * - * - * - * ``` - * - * ### Expandable Options - * - * Options can be expanded to take up the full width of the item if you swipe past - * a certain point. This can be combined with the `ionSwipe` event to call methods - * on the class. - * - * ```html - * - * - * Item - * - * Delete - * - * - * ``` - * - * We can call `delete` by either clicking the button, or by doing a full swipe on the item. - * - * @demo /docs/demos/src/item-sliding/ - * @see {@link /docs/components#lists List Component Docs} - * @see {@link ../Item Item API Docs} - * @see {@link ../../list/List List API Docs} - */ @Component({ tag: 'ion-item-sliding', styleUrls: { diff --git a/packages/core/src/components/item-sliding/readme.md b/packages/core/src/components/item-sliding/readme.md index e50de5cbd5..f13f0dbbdd 100644 --- a/packages/core/src/components/item-sliding/readme.md +++ b/packages/core/src/components/item-sliding/readme.md @@ -1,52 +1,125 @@ -# ion-item-option +# ion-item-sliding + +A sliding item is a list item that can be swiped to reveal buttons. It requires +an [Item](../Item) component as a child and a [List](../../list/List) component as +a parent. All buttons to reveal can be placed in the `` element. + +@usage +```html + + + + Item + + + Favorite + Share + + + + Unread + + + +``` + + +### Swipe Direction + +By default, the buttons are revealed when the sliding item is swiped from right to left, +so the buttons are placed in the right side. But it's also possible to reveal them +in the right side (sliding from left to right) by setting the `side` attribute +on the `ion-item-options` element. Up to 2 `ion-item-options` can used at the same time +in order to reveal two different sets of buttons depending the swipping direction. + +```html + + + + Archive + + + + + + + Archive + + +``` + + +### Listening for events (ionDrag) and (ionSwipe) +It's possible to know the current relative position of the sliding item by subscribing +to the (ionDrag)` event. + +```html + + Item + + Favorite + + +``` + + +### Button Layout +If an icon is placed with text in the option button, by default it will +display the icon on top of the text. This can be changed to display the icon +to the left of the text by setting `icon-start` as an attribute on the +`` element. + +```html + + + + Archive + + + +``` + + +### Expandable Options + +Options can be expanded to take up the full width of the item if you swipe past +a certain point. This can be combined with the `ionSwipe` event to call methods +on the class. + +```html + + + Item + + Delete + + +``` + +We can call `delete` by either clicking the button, or by doing a full swipe on the item. -## Properties +## Events -#### color - -string +#### ionDrag -#### disabled +## Methods -boolean +#### close() -#### href - -string +#### closeOpened() -#### mode - -any +#### getOpenAmount() -## Attributes - -#### color - -string - - -#### disabled - -boolean - - -#### href - -string - - -#### mode - -any +#### getSlidingPercent() diff --git a/packages/core/src/index.d.ts b/packages/core/src/index.d.ts index 63ed3bc266..12fe24a629 100644 --- a/packages/core/src/index.d.ts +++ b/packages/core/src/index.d.ts @@ -53,7 +53,7 @@ export { InfiniteScrollContent } from './components/infinite-scroll/infinite-scr export { Input } from './components/input/input'; export { Item } from './components/item/item'; export { ItemDivider } from './components/item-divider/item-divider'; -export { ItemOption } from './components/item-sliding/item-option'; +export { ItemOption } from './components/item-option/item-option'; export { ItemSliding } from './components/item-sliding/item-sliding'; export { KeyboardController } from './components/keyboard-controller/keyboard-controller'; export * from './components/keyboard-controller/keys';