diff --git a/docs/angular/injection-tokens.md b/docs/angular/injection-tokens.md new file mode 100644 index 00000000000..c7c775fd69c --- /dev/null +++ b/docs/angular/injection-tokens.md @@ -0,0 +1,177 @@ +--- +title: Angular Injection Tokens +sidebar_label: Injection Tokens +--- + + + Angular Injection Tokens | Access Ionic Elements via Dependency Injection + + + +Ionic provides Angular injection tokens that allow you to access Ionic elements through Angular's dependency injection system. This provides a more Angular-idiomatic way to interact with Ionic components programmatically. + +## Benefits + +Using injection tokens provides several advantages: + +- **Type Safety**: Full TypeScript support with proper typing for the modal element +- **Angular Integration**: Works seamlessly with Angular's dependency injection system +- **Simplified Code**: Eliminates the need for `ViewChild` queries or manual element references +- **Better Testing**: Easier to mock and test components that use injection tokens + +## IonModalToken + +The `IonModalToken` injection token allows you to inject a reference to the current modal element directly into your Angular components. This is particularly useful when you need to programmatically control modal behavior, listen to modal events, or access modal properties. + +Starting in `@ionic/angular` v8.7.0, you can use this injection token to streamline modal interactions in your Angular applications. + +### Basic Usage + +To use the `IonModalToken`, inject it into your component's constructor: + +```tsx +import { Component, inject } from '@angular/core'; +import { IonButton, IonContent, IonHeader, IonModalToken, IonTitle, IonToolbar } from '@ionic/angular/standalone'; + +@Component({ + selector: 'app-modal', + template: ` + + + Modal Content + + + +

This is modal content

+ Close Modal +
+ `, + imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonButton], +}) +export class ModalComponent { + private modalToken = inject(IonModalToken); + + closeModal() { + this.modalToken.dismiss(); + } +} +``` + +### Listening to Modal Events + +You can use the injected modal reference to listen to modal lifecycle events: + +```tsx +import { Component, inject, OnInit } from '@angular/core'; +import { IonButton, IonContent, IonHeader, IonModalToken, IonTitle, IonToolbar } from '@ionic/angular/standalone'; + +@Component({ + selector: 'app-modal', + template: ` + + + Modal with Events + + + +

Check the console for modal events

+ Close +
+ `, + imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonButton], +}) +export class ModalComponent implements OnInit { + private modalToken = inject(IonModalToken); + + ngOnInit() { + this.modalToken.addEventListener('ionModalWillDismiss', (event) => { + console.log('Modal will dismiss:', event.detail); + }); + + this.modalToken.addEventListener('ionModalDidDismiss', (event) => { + console.log('Modal did dismiss:', event.detail); + }); + } + + closeModal() { + this.modalToken.dismiss({ result: 'closed by button' }); + } +} +``` + +### Accessing Modal Properties + +The injected modal reference provides access to all modal properties and methods: + +```tsx +import { Component, inject, OnInit } from '@angular/core'; +import { IonButton, IonContent, IonHeader, IonModalToken, IonTitle, IonToolbar } from '@ionic/angular/standalone'; + +@Component({ + selector: 'app-modal', + template: ` + + + Modal Properties + + + +

Modal ID: {{ modalId }}

+ Toggle Backdrop Dismiss: {{ backdropDismiss }} +
+ `, + imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonButton], +}) +export class ModalComponent implements OnInit { + private modalToken = inject(IonModalToken); + + modalId = ''; + backdropDismiss = true; + + ngOnInit() { + this.modalId = this.modalToken.id || 'No ID'; + this.backdropDismiss = this.modalToken.backdropDismiss; + } + + toggleBackdropDismiss() { + this.backdropDismiss = !this.backdropDismiss; + this.modalToken.backdropDismiss = this.backdropDismiss; + } +} +``` + +### Opening a Modal with Injection Token Content + +When opening a modal that uses the injection token, you can pass the component directly to the modal controller: + +```tsx +import { Component, inject } from '@angular/core'; +import { IonContent, IonButton, ModalController } from '@ionic/angular/standalone'; +import { ModalComponent } from './modal.component'; + +@Component({ + selector: 'app-home', + template: ` + + Open Modal + + `, +}) +export class HomePage { + private modalController = inject(ModalController); + + async openModal() { + const myModal = await this.modalController.create({ + component: ModalComponent, + componentProps: { + // Any props you want to pass to the modal content + }, + }); + + await myModal.present(); + } +} +``` diff --git a/docs/api/reorder-group.md b/docs/api/reorder-group.md index c3c6c4e9508..2d1d7f73fd3 100644 --- a/docs/api/reorder-group.md +++ b/docs/api/reorder-group.md @@ -16,27 +16,71 @@ import Slots from '@ionic-internal/component-api/v8/reorder-group/slots.md'; import EncapsulationPill from '@components/page/api/EncapsulationPill'; -The reorder group is a container for items using the [reorder](./reorder) component. When the user drags an item and drops it in a new position, the `ionItemReorder` event is dispatched. A handler for this event should be implemented that calls the `complete` method. +The reorder group is a container for items using the [reorder](./reorder) component. When the user drags an item and drops it, the `ionReorderEnd` event is dispatched. A handler for this event should be implemented that calls the `complete` method. -The `detail` property of the `ionItemReorder` event includes all of the relevant information about the reorder operation, including the `from` and `to` indexes. In the context of reordering, an item moves `from` an index `to` a new index. For example usage of the reorder group, see the [reorder](./reorder) documentation. +The `detail` property of the `ionReorderEnd` event includes all of the relevant information about the reorder operation, including the `from` and `to` indexes. In the context of reordering, an item moves `from` an index `to` an index. For example usage of the reorder group, see the [reorder](./reorder) documentation. ## Interfaces -### ItemReorderEventDetail +### ReorderMoveEventDetail ```typescript -interface ItemReorderEventDetail { +interface ReorderMoveEventDetail { + from: number; + to: number; +} +``` + +### ReorderEndEventDetail + +```typescript +interface ReorderEndEventDetail { from: number; to: number; complete: (data?: boolean | any[]) => any; } ``` -### ItemReorderCustomEvent +### ReorderMoveCustomEvent + +While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with Ionic events emitted from this component. + +```typescript +interface ReorderMoveCustomEvent extends CustomEvent { + detail: ReorderMoveEventDetail; + target: HTMLIonReorderGroupElement; +} + +``` + +### ReorderEndCustomEvent While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with Ionic events emitted from this component. +```typescript +interface ReorderEndCustomEvent extends CustomEvent { + detail: ReorderEndEventDetail; + target: HTMLIonReorderGroupElement; +} +``` + +### ItemReorderEventDetail (deprecated) + +**_Deprecated_** — Use the `ionReorderEnd` event with `ReorderEndEventDetail` instead. + +```typescript +interface ItemReorderEventDetail { + from: number; + to: number; + complete: (data?: boolean | any[]) => any; +} +``` + +### ItemReorderCustomEvent (deprecated) + +**_Deprecated_** — Use the `ionReorderEnd` event with `ReorderEndCustomEvent` instead. + ```typescript interface ItemReorderCustomEvent extends CustomEvent { detail: ItemReorderEventDetail; diff --git a/docs/api/reorder.md b/docs/api/reorder.md index ad07a4290ea..5f771c9badf 100644 --- a/docs/api/reorder.md +++ b/docs/api/reorder.md @@ -20,7 +20,7 @@ import EncapsulationPill from '@components/page/api/EncapsulationPill'; Reorder is a component that allows an item to be dragged to change its order within a group of items. It must be used within a [reorder group](./reorder-group) to provide a visual drag and drop interface. -The reorder is the anchor used to drag and drop the items. Once the reorder is complete, the `ionItemReorder` event will be dispatched from the reorder group and the `complete` method needs to be called. +The reorder is the anchor used to drag and drop the items. Once the reorder is complete, the `ionReorderEnd` event will be dispatched from the reorder group and the `complete` method needs to be called. ## Basic Usage @@ -73,6 +73,29 @@ import UpdatingData from '@site/static/usage/v8/reorder/updating-data/index.md'; +## Event Handling + +### Using `ionReorderStart` and `ionReorderEnd` + +The `ionReorderStart` event is emitted when the user begins a reorder gesture. This event fires when the user taps and holds an item, before any movement occurs. This is useful for preparing the UI for the reorder operation, such as hiding certain elements or updating the visual state of items. For example, icons in list items can be hidden while they are being dragged and shown again when the reorder is complete. + +The `ionReorderEnd` event is emitted when the user completes the reorder gesture. This occurs when the user releases the item they are dragging, for example by lifting their finger on a touch screen or releasing the mouse button. The event includes the `from` and `to` indices of the item, as well as the `complete` method that should be called to finalize the reorder operation. The `from` index will always be the position of the item when the gesture started, while the `to` index will be its final position. This event will fire even if no items have changed position, in which case the `from` and `to` indices will be the same. + +import ReorderStartEndEvents from '@site/static/usage/v8/reorder/reorder-start-end-events/index.md'; + + + +### Using `ionReorderMove` + +The `ionReorderMove` event is emitted continuously during the reorder gesture as the user drags an item. The event includes the `from` and `to` indices of the item. Unlike `ionReorderEnd`, the `from` index in this event represents the last known position of the item (which updates as the item moves), while the `to` index represents its current position. If the item has not changed position since the last event, the `from` and `to` indices will be the same. This event is useful for tracking position changes during the drag operation. For example, the ranking or numbering of items can be updated in real-time as they are being dragged to maintain a logical ascending order. + +:::warning +Do not call the `complete` method during the `ionReorderMove` event as it can break the gesture. +::: + +import ReorderMoveEvent from '@site/static/usage/v8/reorder/reorder-move-event/index.md'; + + ## Usage with Virtual Scroll diff --git a/docs/layout/css-utilities.md b/docs/layout/css-utilities.md index 29ad62298b4..3bafb37362a 100644 --- a/docs/layout/css-utilities.md +++ b/docs/layout/css-utilities.md @@ -12,13 +12,13 @@ title: CSS Utilities Ionic Framework provides a set of CSS utility classes that can be used on any element in order to modify the text, element placement or adjust the padding and margin. -:::note +:::important If your app was not started using an available Ionic Framework starter, the stylesheets listed in the [optional section of the global stylesheets](global-stylesheets.md#optional) will need to be included in order for these styles to work. ::: ## Text Modification -### Text Alignment +### Text Align ```html @@ -76,7 +76,7 @@ If your app was not started using an available Ionic Framework starter, the styl | `.ion-text-wrap` | `white-space: normal` | Sequences of whitespace are collapsed. Newline characters in the source are handled as other whitespace. Breaks lines as necessary to fill line boxes. | | `.ion-text-nowrap` | `white-space: nowrap` | Collapses whitespace as for `normal`, but suppresses line breaks (text wrapping) within text. | -### Text Transformation +### Text Transform ```html @@ -125,9 +125,9 @@ The table below shows the default behavior, where `{modifier}` is any of the fol ## Element Placement -### Float Elements +### Float -The float CSS property specifies that an element should be placed along the left or right side of its container, where text and inline elements will wrap around it. This way, the element is taken from the normal flow of the web page, though still remaining a part of the flow, contrary to absolute positioning. +The [float](https://developer.mozilla.org/en-US/docs/Web/CSS/float) CSS property specifies that an element should be placed along the left or right side of its container, where text and inline elements will wrap around it. This way, the element is taken from the normal flow of the web page, though still remaining a part of the flow, contrary to absolute positioning. ```html @@ -188,45 +188,59 @@ The table below shows the default behavior, where `{modifier}` is any of the fol ## Element Display -The display CSS property determines if an element should be visible or not. The element will still be in the DOM, but not rendered, if it is hidden. +### Display -```html - - - -
-

hidden

- You can't see me. -
-
- -
-

not-hidden

- You can see me! -
-
-
-
-``` +The [display](https://developer.mozilla.org/en-US/docs/Web/CSS/display) CSS property sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex. It can also be used to completely hide an element from the layout. + +Ionic provides the following utility classes for `display`: + +| Class | Style Rule | Description | +| --------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| `.ion-display-none` | `display: none` | Turns off the display of an element so that it has no effect on layout (the document is rendered as though the element did not exist). | +| `.ion-display-inline` | `display: inline` | The element behaves as an inline element that does not create line breaks before or after itself. | +| `.ion-display-inline-block` | `display: inline-block` | The element behaves as a block element that flows with surrounding content as if it were a single inline box. | +| `.ion-display-block` | `display: block` | The element behaves as a block element, creating line breaks both before and after itself when in the normal flow. | +| `.ion-display-flex` | `display: flex` | The element behaves like a block element and lays out its content according to the flexbox model. | +| `.ion-display-inline-flex` | `display: inline-flex` | The element behaves like an inline element and lays out its content according to the flexbox model. | +| `.ion-display-grid` | `display: grid` | The element behaves like a block element and lays out its content according to the grid model. | +| `.ion-display-inline-grid` | `display: inline-grid` | The element behaves like an inline element and lays out its content according to the grid model. | +| `.ion-display-table` | `display: table` | The element behaves like an HTML `` element. It defines a block-level box. | +| `.ion-display-table-cell` | `display: table-cell` | The element behaves like an HTML `` element. | + +### Responsive Display Classes + +All of the display classes listed above have additional classes to modify the display based on the screen size. Instead of `display-` in each class, use `display-{breakpoint}-` to only use the class on specific screen sizes, where `{breakpoint}` is one of the breakpoint names listed in [Ionic Breakpoints](#ionic-breakpoints). -| Class | Style Rule | Description | -| ----------- | --------------- | --------------------------- | -| `.ion-hide` | `display: none` | The element will be hidden. | +The table below shows the default behavior, where `{modifier}` is any of the following: `none`, `inline`, `inline-block`, `block`, `flex`, `inline-flex`, `grid`, `inline-grid`, `table`, `table-cell`, `table-row`, as they are described above. -### Responsive Display Attributes +| Class | Description | +| ---------------------------- | ------------------------------------------------------------- | +| `.ion-display-{modifier}` | Applies the modifier to the element on all screen sizes. | +| `.ion-display-sm-{modifier}` | Applies the modifier to the element when `min-width: 576px`. | +| `.ion-display-md-{modifier}` | Applies the modifier to the element when `min-width: 768px`. | +| `.ion-display-lg-{modifier}` | Applies the modifier to the element when `min-width: 992px`. | +| `.ion-display-xl-{modifier}` | Applies the modifier to the element when `min-width: 1200px`. | -There are also additional classes to modify the visibility based on the screen size. Instead of just `.ion-hide` for all screen sizes, use `.ion-hide-{breakpoint}-{dir}` to only use the class on specific screen sizes, where `{breakpoint}` is one of the breakpoint names listed in [Ionic Breakpoints](#ionic-breakpoints), and `{dir}` is whether the element should be hidden on all screen sizes above (`up`) or below (`down`) the specified breakpoint. +### Deprecated Classes + +:::warning Deprecation Notice + +The following classes are deprecated and will be removed in the next major release. Use the recommended `.ion-display-*` classes instead. + +::: -| Class | Description | -| -------------------- | ---------------------------------------------------------------------------------------------------- | -| `.ion-hide-sm-{dir}` | Applies the modifier to the element when `min-width: 576px` (`up`) or `max-width: 576px` (`down`). | -| `.ion-hide-md-{dir}` | Applies the modifier to the element when `min-width: 768px` (`up`) or `max-width: 768px` (`down`). | -| `.ion-hide-lg-{dir}` | Applies the modifier to the element when `min-width: 992px` (`up`) or `max-width: 992px` (`down`). | -| `.ion-hide-xl-{dir}` | Applies the modifier to the element when `min-width: 1200px` (`up`) or `max-width: 1200px` (`down`). | +| Class | Description | +| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `.ion-hide` | Applies `display: none` to the element on all screen sizes.
**Deprecated** — Use the `ion-display-none` class instead. | +| `.ion-hide-sm-{dir}` | Applies the modifier to the element when `min-width: 576px` (`up`) or `max-width: 576px` (`down`).
**Deprecated** — Use the `ion-display-sm-{modifier}` classes instead. | +| `.ion-hide-md-{dir}` | Applies the modifier to the element when `min-width: 768px` (`up`) or `max-width: 768px` (`down`).
**Deprecated** — Use the `ion-display-md-{modifier}` classes instead. | +| `.ion-hide-lg-{dir}` | Applies the modifier to the element when `min-width: 992px` (`up`) or `max-width: 992px` (`down`).
**Deprecated** — Use the `ion-display-lg-{modifier}` classes instead. | +| `.ion-hide-xl-{dir}` | Applies the modifier to the element when `min-width: 1200px` (`up`) or `max-width: 1200px` (`down`).
**Deprecated** — Use the `ion-display-xl-{modifier}` classes instead. | ## Content Space -### Element Padding +### Padding The padding class sets the padding area of an element. The padding area is the space between the content of the element and its border. @@ -276,7 +290,7 @@ The default amount of `padding` to be applied is `16px` and is set by the `--ion | `.ion-padding-horizontal` | `padding: 0 16px` | Applies padding to the left and right. | | `.ion-no-padding` | `padding: 0` | Applies no padding to all sides. | -### Element Margin +### Margin The margin area extends the border area with an empty area used to separate the element from its neighbors. @@ -326,146 +340,54 @@ The default amount of `margin` to be applied is `16px` and is set by the `--ion- | `.ion-margin-horizontal` | `margin: 0 16px` | Applies margin to the left and right. | | `.ion-no-margin` | `margin: 0` | Applies no margin to all sides. | -## Flex Properties +## Flex Container Properties + +Flexbox properties are divided into two categories: **container properties** that control the layout of all flex items, and **item properties** that control individual flex items. See [Flex Item Properties](#flex-item-properties) for item-level alignment. -### Flex Container Properties +### Align Items -```html - - - -
1 of 2
-
- -
2 of 2
-
-
+The [align-items](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) CSS property sets the [align-self](#align-self) value on all direct children as a group. In flexbox, it controls the alignment of items on the cross axis. In grid layout, it controls the alignment of items on the block axis within their grid areas. - - -
1 of 2
-
- -
2 of 2
-
-
+ - - -
1 of 2
-
- -
2 of 2
-
-
+Ionic provides the following utility classes for `align-items`: - - -
1 of 2
-
- -
2 of 2
-
-
+| Class | Style Rule | Description | +| --------------------------- | ------------------------- | ---------------------------------------------------- | +| `.ion-align-items-start` | `align-items: flex-start` | Items are packed toward the start on the cross axis. | +| `.ion-align-items-end` | `align-items: flex-end` | Items are packed toward the end on the cross axis. | +| `.ion-align-items-center` | `align-items: center` | Items are centered along the cross axis. | +| `.ion-align-items-baseline` | `align-items: baseline` | Items are aligned so that their baselines align. | +| `.ion-align-items-stretch` | `align-items: stretch` | Items are stretched to fill the container. | - - -
1 of 2
-
- -
2 of 2
-
-
+### Align Content - - -
1 of 2
-
- -
2 of 2
-
-
-
+The [align-content](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) CSS property sets the distribution of space between and around content items along a flexbox's cross axis, or a grid or block-level element's block axis. - - - -
1 of 4
-
- -
2 of 4
-
- -
3 of 4
-
- -
4 of 4 # # #
-
-
+This property has no effect on single line flex containers (i.e., ones with `flex-wrap: nowrap`). - - -
1 of 4
-
- -
2 of 4
-
- -
3 of 4
-
- -
4 of 4 # # #
-
-
+ - - -
1 of 4
-
- -
2 of 4
-
- -
3 of 4
-
- -
4 of 4 # # #
-
-
+Ionic provides the following utility classes for `align-content`: - - -
1 of 4
-
- -
2 of 4
-
- -
3 of 4
-
- -
4 of 4 # # #
-
-
+| Class | Style Rule | Description | +| ---------------------------- | ------------------------------ | ---------------------------------------------------------- | +| `.ion-align-content-start` | `align-content: flex-start` | Lines are packed toward the start of the cross axis. | +| `.ion-align-content-end` | `align-content: flex-end` | Lines are packed toward the end of the cross axis. | +| `.ion-align-content-center` | `align-content: center` | Lines are centered along the cross axis. | +| `.ion-align-content-stretch` | `align-content: stretch` | Lines are stretched to fill the container. | +| `.ion-align-content-between` | `align-content: space-between` | Lines are evenly distributed on the cross axis. | +| `.ion-align-content-around` | `align-content: space-around` | Lines are evenly distributed with equal space around them. | - - -
1 of 4
-
- -
2 of 4
-
- -
3 of 4
-
- -
4 of 4 # # #
-
-
-
-``` +### Justify Content + +The [justify-content](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) CSS property defines how the browser distributes space between and around content items along the main axis of a flex container and the inline axis of grid and multi-column containers. + + + +Ionic provides the following utility classes for `justify-content`: | Class | Style Rule | Description | | ------------------------------ | -------------------------------- | --------------------------------------------------------------------------- | @@ -475,35 +397,77 @@ The default amount of `margin` to be applied is `16px` and is set by the `--ion- | `.ion-justify-content-around` | `justify-content: space-around` | Items are evenly distributed on the main axis with equal space around them. | | `.ion-justify-content-between` | `justify-content: space-between` | Items are evenly distributed on the main axis. | | `.ion-justify-content-evenly` | `justify-content: space-evenly` | Items are distributed so that the spacing between any two items is equal. | -| `.ion-align-items-start` | `align-items: flex-start` | Items are packed toward the start on the cross axis. | -| `.ion-align-items-end` | `align-items: flex-end` | Items are packed toward the end on the cross axis. | -| `.ion-align-items-center` | `align-items: center` | Items are centered along the cross axis. | -| `.ion-align-items-baseline` | `align-items: baseline` | Items are aligned so that their baselines align. | -| `.ion-align-items-stretch` | `align-items: stretch` | Items are stretched to fill the container. | -| `.ion-nowrap` | `flex-wrap: nowrap` | Items will all be on one line. | -| `.ion-wrap` | `flex-wrap: wrap` | Items will wrap onto multiple lines, from top to bottom. | -| `.ion-wrap-reverse` | `flex-wrap: wrap-reverse` | Items will wrap onto multiple lines, from bottom to top. | -### Flex Item Properties +### Flex Direction -```html - - - -
1 of 4
-
- -
2 of 4
-
- -
3 of 4
-
- -
4 of 4 # # #
-
-
-
-``` +The [flex-direction](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) CSS property sets how flex items are placed in the flex container defining the main axis and the direction (normal or reversed). + + + +Ionic provides the following utility classes for `flex-direction`: + +| Class | Style Rule | Description | +| -------------------------- | -------------------------------- | ----------------------------------------------------------------- | +| `.ion-flex-row` | `flex-direction: row` | Items are placed in the same direction as the text direction. | +| `.ion-flex-row-reverse` | `flex-direction: row-reverse` | Items are placed in the opposite direction as the text direction. | +| `.ion-flex-column` | `flex-direction: column` | Items are placed vertically. | +| `.ion-flex-column-reverse` | `flex-direction: column-reverse` | Items are placed vertically in reverse order. | + +### Flex Wrap + +The [flex-wrap](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap) CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. If wrapping is allowed, it sets the direction that lines are stacked. + + + +Ionic provides the following utility classes for `flex-wrap`: + +| Class | Style Rule | Description | +| ------------------------ | ------------------------- | -------------------------------------------------------- | +| `.ion-flex-nowrap` | `flex-wrap: nowrap` | Items will all be on one line. | +| `.ion-flex-wrap` | `flex-wrap: wrap` | Items will wrap onto multiple lines, from top to bottom. | +| `.ion-flex-wrap-reverse` | `flex-wrap: wrap-reverse` | Items will wrap onto multiple lines, from bottom to top. | + +### Responsive Flex Container Classes + +All of the flex container classes listed above have additional classes to modify the properties based on the screen size. Instead of the base class name, use `{property}-{breakpoint}-{modifier}` to only use the class on specific screen sizes, where `{breakpoint}` is one of the breakpoint names listed in [Ionic Breakpoints](#ionic-breakpoints). + +The table below shows the default behavior, where `{property}` is one of the following: `justify-content`, `align-content`, `align-items`, `flex`, or `flex-wrap`, and `{modifier}` is the corresponding value as described above. + +| Class | Description | +| ------------------------------- | ------------------------------------------------------------- | +| `.ion-{property}-{modifier}` | Applies the modifier to the element on all screen sizes. | +| `.ion-{property}-sm-{modifier}` | Applies the modifier to the element when `min-width: 576px`. | +| `.ion-{property}-md-{modifier}` | Applies the modifier to the element when `min-width: 768px`. | +| `.ion-{property}-lg-{modifier}` | Applies the modifier to the element when `min-width: 992px`. | +| `.ion-{property}-xl-{modifier}` | Applies the modifier to the element when `min-width: 1200px`. | + +### Deprecated Classes + +:::warning Deprecation Notice + +The following classes are deprecated and will be removed in the next major release. Use the recommended `.ion-flex-*` classes instead. + +::: + +| Class | Description | +| ------------------- | -------------------------------------------------------------------------------------------------------------------- | +| `.ion-nowrap` | Items will all be on one line.
**Deprecated** — Use `.ion-flex-nowrap` instead. | +| `.ion-wrap` | Items will wrap onto multiple lines, from top to bottom.
**Deprecated** — Use `.ion-flex-wrap` instead. | +| `.ion-wrap-reverse` | Items will wrap onto multiple lines, from bottom to top.
**Deprecated** — Use `.ion-flex-wrap-reverse` instead. | + +## Flex Item Properties + +Flex item properties control how individual flex items behave within their flex container. See also: [Flex Container Properties](#flex-container-properties) for container-level alignment. + +### Align Self + +The [align-self](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) CSS property overrides a grid or flex item's align-items value. In grid, it aligns the item inside the grid area. In flexbox, it aligns the item on the cross axis. + +The property doesn't apply to block-level boxes, or to table cells. If a flexbox item's cross-axis margin is `auto`, then `align-self` is ignored. + + + +Ionic provides the following utility classes for `align-self`: | Class | Style Rule | Description | | -------------------------- | ------------------------ | ---------------------------------------------------------------------- | @@ -514,9 +478,90 @@ The default amount of `margin` to be applied is `16px` and is set by the `--ion- | `.ion-align-self-stretch` | `align-self: stretch` | Item is stretched to fill the container. | | `.ion-align-self-auto` | `align-self: auto` | Item is positioned according to the parent's `align-items` value. | +### Flex + +The [flex](https://developer.mozilla.org/en-US/docs/Web/CSS/flex) CSS property is a shorthand property for `flex-grow`, `flex-shrink` and `flex-basis`. It sets how a flex item will grow or shrink to fit the space available in its flex container. + + + +Ionic provides the following utility classes for `flex`: + +| Class | Style Rule | Description | +| ------------------- | --------------- | ----------------------------------------------------------- | +| `.ion-flex-1` | `flex: 1` | Item grows and shrinks equally with other flex items. | +| `.ion-flex-auto` | `flex: auto` | Item grows and shrinks based on its content size. | +| `.ion-flex-initial` | `flex: initial` | Item shrinks to its minimum content size but does not grow. | +| `.ion-flex-none` | `flex: none` | Item does not grow or shrink. | + +### Flex Grow + +The [flex-grow](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-grow) CSS property sets the flex grow factor, which specifies how much of the flex container's positive free space, if any, should be assigned to the flex item's main size. + + + +Ionic provides the following utility classes for `flex-grow`: + +| Class | Style Rule | Description | +| ------------------ | -------------- | -------------------------------------------------- | +| `.ion-flex-grow-0` | `flex-grow: 0` | Item does not grow beyond its content size. | +| `.ion-flex-grow-1` | `flex-grow: 1` | Item grows to fill available space proportionally. | + +### Flex Shrink + +The [flex-shrink](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-shrink) CSS property sets the flex shrink factor of a flex item. If the size of all flex items is larger than the flex container, the flex items can shrink to fit according to their `flex-shrink` value. Each flex line's negative free space is distributed between the line's flex items that have a `flex-shrink` value greater than `0`. + + + +Ionic provides the following utility classes for `flex-shrink`: + +| Class | Style Rule | Description | +| -------------------- | ---------------- | -------------------------------------------------------- | +| `.ion-flex-shrink-0` | `flex-shrink: 0` | Item does not shrink below its content size. | +| `.ion-flex-shrink-1` | `flex-shrink: 1` | Item shrinks proportionally when container is too small. | + +### Order + +The [order](https://developer.mozilla.org/en-US/docs/Web/CSS/order) CSS property sets the order to lay out an item in a flex or grid container. Items in a container are sorted by ascending `order` value and then by their source code order. Items not given an explicit `order` value are assigned the default value of `0`. + + + +Ionic provides the following utility classes for `order`: + +| Class | Style Rule | Description | +| ------------------ | ----------- | ----------------------------------------- | +| `.ion-order-first` | `order: -1` | Item appears first in the flex container. | +| `.ion-order-0` | `order: 0` | Item appears in its natural order. | +| `.ion-order-1` | `order: 1` | Item appears after items with order 0. | +| `.ion-order-2` | `order: 2` | Item appears after items with order 1. | +| `.ion-order-3` | `order: 3` | Item appears after items with order 2. | +| `.ion-order-4` | `order: 4` | Item appears after items with order 3. | +| `.ion-order-5` | `order: 5` | Item appears after items with order 4. | +| `.ion-order-6` | `order: 6` | Item appears after items with order 5. | +| `.ion-order-7` | `order: 7` | Item appears after items with order 6. | +| `.ion-order-8` | `order: 8` | Item appears after items with order 7. | +| `.ion-order-9` | `order: 9` | Item appears after items with order 8. | +| `.ion-order-10` | `order: 10` | Item appears after items with order 9. | +| `.ion-order-11` | `order: 11` | Item appears after items with order 10. | +| `.ion-order-12` | `order: 12` | Item appears after items with order 11. | +| `.ion-order-last` | `order: 13` | Item appears last in the flex container. | + +### Responsive Flex Item Classes + +All of the flex item classes listed above have additional classes to modify the properties based on the screen size. Instead of the base class name, use `{property}-{breakpoint}-{modifier}` to only use the class on specific screen sizes, where `{breakpoint}` is one of the breakpoint names listed in [Ionic Breakpoints](#ionic-breakpoints). + +The table below shows the default behavior, where `{property}` is one of the following: `align-self`, `flex`, `flex-grow`, `flex-shrink`, or `order`, and `{modifier}` is the corresponding value as described above. + +| Class | Description | +| ------------------------------- | ------------------------------------------------------------- | +| `.ion-{property}-{modifier}` | Applies the modifier to the element on all screen sizes. | +| `.ion-{property}-sm-{modifier}` | Applies the modifier to the element when `min-width: 576px`. | +| `.ion-{property}-md-{modifier}` | Applies the modifier to the element when `min-width: 768px`. | +| `.ion-{property}-lg-{modifier}` | Applies the modifier to the element when `min-width: 992px`. | +| `.ion-{property}-xl-{modifier}` | Applies the modifier to the element when `min-width: 1200px`. | + ## Border Display -The border display CSS property determines if the border should be visible or not. The property can be applied to the ion-header and the ion-footer. +The `.ion-no-border` utility class can be used to remove borders from Ionic components. This class can be applied to the `ion-header` and `ion-footer` components. ```html diff --git a/plugins/docusaurus-plugin-ionic-component-api/index.js b/plugins/docusaurus-plugin-ionic-component-api/index.js index d3b3d2d7255..90e59ee09f3 100644 --- a/plugins/docusaurus-plugin-ionic-component-api/index.js +++ b/plugins/docusaurus-plugin-ionic-component-api/index.js @@ -145,7 +145,7 @@ ${properties .map((prop) => { const isDeprecated = prop.deprecation !== undefined; - const docs = isDeprecated ? `${prop.docs}\n_Deprecated_ ${prop.deprecation}` : prop.docs; + const docs = isDeprecated ? `${prop.docs}\n\n**_Deprecated_** — ${prop.deprecation}` : prop.docs; return ` ### ${prop.name} ${isDeprecated ? '(deprecated)' : ''} @@ -170,7 +170,15 @@ function renderEvents({ events }) { return ` | Name | Description | Bubbles | | --- | --- | --- | -${events.map((event) => `| \`${event.event}\` | ${formatMultiline(event.docs)} | \`${event.bubbles}\` |`).join('\n')}`; +${events + .map((event) => { + const isDeprecated = event.deprecation !== undefined; + const docs = isDeprecated ? `${event.docs}\n\n**_Deprecated_** — ${event.deprecation}` : event.docs; + return `| \`${event.event}\` ${isDeprecated ? '**(deprecated)**' : ''} | ${formatMultiline(docs)} | \`${ + event.bubbles + }\` |`; + }) + .join('\n')}`; } /** diff --git a/sidebars.js b/sidebars.js index 115eca21382..b3c15b05f58 100644 --- a/sidebars.js +++ b/sidebars.js @@ -85,6 +85,7 @@ module.exports = { }, 'angular/lifecycle', 'angular/navigation', + 'angular/injection-tokens', 'angular/virtual-scroll', 'angular/slides', 'angular/platform', diff --git a/static/demos/api/reorder/index.html b/static/demos/api/reorder/index.html index 695a50c2701..3903da1eb7d 100644 --- a/static/demos/api/reorder/index.html +++ b/static/demos/api/reorder/index.html @@ -99,7 +99,7 @@ function toggleReorder() { const reorderGroup = document.getElementById('reorder'); reorderGroup.disabled = !reorderGroup.disabled; - reorderGroup.addEventListener('ionItemReorder', ({ detail }) => { + reorderGroup.addEventListener('ionReorderEnd', ({ detail }) => { detail.complete(true); }); } diff --git a/static/img/layout/align-content.png b/static/img/layout/align-content.png new file mode 100644 index 00000000000..265c7c7bf3d Binary files /dev/null and b/static/img/layout/align-content.png differ diff --git a/static/img/layout/align-items.png b/static/img/layout/align-items.png new file mode 100644 index 00000000000..d5c40e22e35 Binary files /dev/null and b/static/img/layout/align-items.png differ diff --git a/static/img/layout/align-self.png b/static/img/layout/align-self.png new file mode 100644 index 00000000000..11fcbd371c2 Binary files /dev/null and b/static/img/layout/align-self.png differ diff --git a/static/img/layout/flex-direction.png b/static/img/layout/flex-direction.png new file mode 100644 index 00000000000..dd5691f0fc1 Binary files /dev/null and b/static/img/layout/flex-direction.png differ diff --git a/static/img/layout/flex-grow.png b/static/img/layout/flex-grow.png new file mode 100644 index 00000000000..a029e415dfb Binary files /dev/null and b/static/img/layout/flex-grow.png differ diff --git a/static/img/layout/flex-shrink.png b/static/img/layout/flex-shrink.png new file mode 100644 index 00000000000..4c5d58c54da Binary files /dev/null and b/static/img/layout/flex-shrink.png differ diff --git a/static/img/layout/flex-wrap.png b/static/img/layout/flex-wrap.png new file mode 100644 index 00000000000..300c417c1be Binary files /dev/null and b/static/img/layout/flex-wrap.png differ diff --git a/static/img/layout/flex.png b/static/img/layout/flex.png new file mode 100644 index 00000000000..f2648ac05da Binary files /dev/null and b/static/img/layout/flex.png differ diff --git a/static/img/layout/justify-content.png b/static/img/layout/justify-content.png new file mode 100644 index 00000000000..1b2641086a0 Binary files /dev/null and b/static/img/layout/justify-content.png differ diff --git a/static/img/layout/order.png b/static/img/layout/order.png new file mode 100644 index 00000000000..875e6e799b9 Binary files /dev/null and b/static/img/layout/order.png differ diff --git a/static/usage/v8/datetime/highlightedDates/array/angular/example_component_ts.md b/static/usage/v8/datetime/highlightedDates/array/angular/example_component_ts.md index 1382b5db0e9..ca7f322c840 100644 --- a/static/usage/v8/datetime/highlightedDates/array/angular/example_component_ts.md +++ b/static/usage/v8/datetime/highlightedDates/array/angular/example_component_ts.md @@ -14,21 +14,25 @@ export class ExampleComponent { date: '2023-01-05', textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }, { date: '2023-01-10', textColor: '#09721b', backgroundColor: '#c8e5d0', + border: '1px solid #4caf50', }, { date: '2023-01-20', - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }, { date: '2023-01-23', textColor: 'rgb(68, 10, 184)', backgroundColor: 'rgb(211, 200, 229)', + border: '1px solid rgb(103, 58, 183)', }, ]; } diff --git a/static/usage/v8/datetime/highlightedDates/array/demo.html b/static/usage/v8/datetime/highlightedDates/array/demo.html index 1e8545bf042..9f27a6f29c8 100644 --- a/static/usage/v8/datetime/highlightedDates/array/demo.html +++ b/static/usage/v8/datetime/highlightedDates/array/demo.html @@ -31,21 +31,25 @@ date: '2023-01-05', textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }, { date: '2023-01-10', textColor: '#09721b', backgroundColor: '#c8e5d0', + border: '1px solid #4caf50', }, { date: '2023-01-20', - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }, { date: '2023-01-23', textColor: 'rgb(68, 10, 184)', backgroundColor: 'rgb(211, 200, 229)', + border: '1px solid rgb(103, 58, 183)', }, ]; diff --git a/static/usage/v8/datetime/highlightedDates/array/javascript.md b/static/usage/v8/datetime/highlightedDates/array/javascript.md index a27ff554ee2..9eae9580daf 100644 --- a/static/usage/v8/datetime/highlightedDates/array/javascript.md +++ b/static/usage/v8/datetime/highlightedDates/array/javascript.md @@ -8,21 +8,25 @@ date: '2023-01-05', textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }, { date: '2023-01-10', textColor: '#09721b', backgroundColor: '#c8e5d0', + border: '1px solid #4caf50', }, { date: '2023-01-20', - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }, { date: '2023-01-23', textColor: 'rgb(68, 10, 184)', backgroundColor: 'rgb(211, 200, 229)', + border: '1px solid rgb(103, 58, 183)', }, ]; diff --git a/static/usage/v8/datetime/highlightedDates/array/react.md b/static/usage/v8/datetime/highlightedDates/array/react.md index 4d8d9258f63..f49daad4da2 100644 --- a/static/usage/v8/datetime/highlightedDates/array/react.md +++ b/static/usage/v8/datetime/highlightedDates/array/react.md @@ -11,21 +11,25 @@ function Example() { date: '2023-01-05', textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }, { date: '2023-01-10', textColor: '#09721b', backgroundColor: '#c8e5d0', + border: '1px solid #4caf50', }, { date: '2023-01-20', - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }, { date: '2023-01-23', textColor: 'rgb(68, 10, 184)', backgroundColor: 'rgb(211, 200, 229)', + border: '1px solid rgb(103, 58, 183)', }, ]} > diff --git a/static/usage/v8/datetime/highlightedDates/array/vue.md b/static/usage/v8/datetime/highlightedDates/array/vue.md index 408f58f2833..40cc4316e6d 100644 --- a/static/usage/v8/datetime/highlightedDates/array/vue.md +++ b/static/usage/v8/datetime/highlightedDates/array/vue.md @@ -15,21 +15,25 @@ date: '2023-01-05', textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }, { date: '2023-01-10', textColor: '#09721b', backgroundColor: '#c8e5d0', + border: '1px solid #4caf50', }, { date: '2023-01-20', - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }, { date: '2023-01-23', textColor: 'rgb(68, 10, 184)', backgroundColor: 'rgb(211, 200, 229)', + border: '1px solid rgb(103, 58, 183)', }, ]; diff --git a/static/usage/v8/datetime/highlightedDates/callback/angular/example_component_ts.md b/static/usage/v8/datetime/highlightedDates/callback/angular/example_component_ts.md index b877e31c7e5..159d9f8700a 100644 --- a/static/usage/v8/datetime/highlightedDates/callback/angular/example_component_ts.md +++ b/static/usage/v8/datetime/highlightedDates/callback/angular/example_component_ts.md @@ -17,13 +17,15 @@ export class ExampleComponent { return { textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }; } if (utcDay % 3 === 0) { return { - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }; } diff --git a/static/usage/v8/datetime/highlightedDates/callback/demo.html b/static/usage/v8/datetime/highlightedDates/callback/demo.html index 855b797ed2d..447b01e38f5 100644 --- a/static/usage/v8/datetime/highlightedDates/callback/demo.html +++ b/static/usage/v8/datetime/highlightedDates/callback/demo.html @@ -34,13 +34,15 @@ return { textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }; } if (utcDay % 3 === 0) { return { - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }; } diff --git a/static/usage/v8/datetime/highlightedDates/callback/javascript.md b/static/usage/v8/datetime/highlightedDates/callback/javascript.md index 9041810960b..e7774445358 100644 --- a/static/usage/v8/datetime/highlightedDates/callback/javascript.md +++ b/static/usage/v8/datetime/highlightedDates/callback/javascript.md @@ -11,13 +11,15 @@ return { textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }; } if (utcDay % 3 === 0) { return { - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }; } diff --git a/static/usage/v8/datetime/highlightedDates/callback/react.md b/static/usage/v8/datetime/highlightedDates/callback/react.md index 6543a1366ca..b730427ea96 100644 --- a/static/usage/v8/datetime/highlightedDates/callback/react.md +++ b/static/usage/v8/datetime/highlightedDates/callback/react.md @@ -13,13 +13,15 @@ function Example() { return { textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }; } if (utcDay % 3 === 0) { return { - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }; } diff --git a/static/usage/v8/datetime/highlightedDates/callback/vue.md b/static/usage/v8/datetime/highlightedDates/callback/vue.md index e916b2cef1b..5288fefea8e 100644 --- a/static/usage/v8/datetime/highlightedDates/callback/vue.md +++ b/static/usage/v8/datetime/highlightedDates/callback/vue.md @@ -18,13 +18,15 @@ return { textColor: '#800080', backgroundColor: '#ffc0cb', + border: '1px solid #e91e63', }; } if (utcDay % 3 === 0) { return { - textColor: 'var(--ion-color-secondary-contrast)', - backgroundColor: 'var(--ion-color-secondary)', + textColor: 'var(--ion-color-secondary)', + backgroundColor: 'rgb(var(--ion-color-secondary-rgb), 0.18)', + border: '1px solid var(--ion-color-secondary-shade)', }; } diff --git a/static/usage/v8/reorder/basic/angular/example_component_html.md b/static/usage/v8/reorder/basic/angular/example_component_html.md index 60795eaa3ff..8b1294bd101 100644 --- a/static/usage/v8/reorder/basic/angular/example_component_html.md +++ b/static/usage/v8/reorder/basic/angular/example_component_html.md @@ -2,7 +2,7 @@ - + Item 1 diff --git a/static/usage/v8/reorder/basic/angular/example_component_ts.md b/static/usage/v8/reorder/basic/angular/example_component_ts.md index 541fd9c6df3..5553891178a 100644 --- a/static/usage/v8/reorder/basic/angular/example_component_ts.md +++ b/static/usage/v8/reorder/basic/angular/example_component_ts.md @@ -1,12 +1,12 @@ ```ts import { Component } from '@angular/core'; import { - ItemReorderEventDetail, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, + ReorderEndCustomEvent, } from '@ionic/angular/standalone'; @Component({ @@ -16,14 +16,14 @@ import { imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup], }) export class ExampleComponent { - handleReorder(event: CustomEvent) { + handleReorderEnd(event: ReorderEndCustomEvent) { // The `from` and `to` properties contain the index of the item // when the drag started and ended, respectively console.log('Dragged from index', event.detail.from, 'to', event.detail.to); // Finish the reorder and position the item in the DOM based on // where the gesture ended. This method can also be called directly - // by the reorder group + // by the reorder group. event.detail.complete(); } } diff --git a/static/usage/v8/reorder/basic/demo.html b/static/usage/v8/reorder/basic/demo.html index f9afb7d750a..7b8abca0b96 100644 --- a/static/usage/v8/reorder/basic/demo.html +++ b/static/usage/v8/reorder/basic/demo.html @@ -11,7 +11,7 @@ @@ -56,14 +56,14 @@ diff --git a/static/usage/v8/reorder/basic/javascript.md b/static/usage/v8/reorder/basic/javascript.md index fe805d10fc6..4b07e8ad210 100644 --- a/static/usage/v8/reorder/basic/javascript.md +++ b/static/usage/v8/reorder/basic/javascript.md @@ -32,14 +32,14 @@ diff --git a/static/usage/v8/reorder/basic/react.md b/static/usage/v8/reorder/basic/react.md index abe3b187294..397ebc395d7 100644 --- a/static/usage/v8/reorder/basic/react.md +++ b/static/usage/v8/reorder/basic/react.md @@ -1,23 +1,23 @@ ```tsx import React from 'react'; -import { IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ItemReorderEventDetail } from '@ionic/react'; +import { IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ReorderEndCustomEvent } from '@ionic/react'; function Example() { - function handleReorder(event: CustomEvent) { + function handleReorderEnd(event: ReorderEndCustomEvent) { // The `from` and `to` properties contain the index of the item // when the drag started and ended, respectively console.log('Dragged from index', event.detail.from, 'to', event.detail.to); // Finish the reorder and position the item in the DOM based on // where the gesture ended. This method can also be called directly - // by the reorder group + // by the reorder group. event.detail.complete(); } return ( {/* The reorder gesture is disabled by default, enable it to drag and drop items */} - + Item 1 diff --git a/static/usage/v8/reorder/basic/vue.md b/static/usage/v8/reorder/basic/vue.md index 0ac2374089f..285a1c347be 100644 --- a/static/usage/v8/reorder/basic/vue.md +++ b/static/usage/v8/reorder/basic/vue.md @@ -2,7 +2,7 @@ diff --git a/static/usage/v8/reorder/custom-icon/angular/example_component_html.md b/static/usage/v8/reorder/custom-icon/angular/example_component_html.md index 6d1fb8960bd..cc6692c862d 100644 --- a/static/usage/v8/reorder/custom-icon/angular/example_component_html.md +++ b/static/usage/v8/reorder/custom-icon/angular/example_component_html.md @@ -2,7 +2,7 @@ - + Item 1 diff --git a/static/usage/v8/reorder/custom-icon/angular/example_component_ts.md b/static/usage/v8/reorder/custom-icon/angular/example_component_ts.md index e9bdafd6df8..4d0472c0bd3 100644 --- a/static/usage/v8/reorder/custom-icon/angular/example_component_ts.md +++ b/static/usage/v8/reorder/custom-icon/angular/example_component_ts.md @@ -1,13 +1,13 @@ ```ts import { Component } from '@angular/core'; import { - ItemReorderEventDetail, IonIcon, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, + ReorderEndCustomEvent, } from '@ionic/angular/standalone'; import { addIcons } from 'ionicons'; @@ -29,14 +29,14 @@ export class ExampleComponent { addIcons({ pizza }); } - handleReorder(event: CustomEvent) { + handleReorderEnd(event: ReorderEndCustomEvent) { // The `from` and `to` properties contain the index of the item // when the drag started and ended, respectively console.log('Dragged from index', event.detail.from, 'to', event.detail.to); // Finish the reorder and position the item in the DOM based on // where the gesture ended. This method can also be called directly - // by the reorder group + // by the reorder group. event.detail.complete(); } } diff --git a/static/usage/v8/reorder/custom-icon/demo.html b/static/usage/v8/reorder/custom-icon/demo.html index ab2c55b9423..b089815bd07 100644 --- a/static/usage/v8/reorder/custom-icon/demo.html +++ b/static/usage/v8/reorder/custom-icon/demo.html @@ -11,7 +11,7 @@ @@ -66,14 +66,14 @@ diff --git a/static/usage/v8/reorder/custom-icon/javascript.md b/static/usage/v8/reorder/custom-icon/javascript.md index d7aa87d8f64..8535da7544a 100644 --- a/static/usage/v8/reorder/custom-icon/javascript.md +++ b/static/usage/v8/reorder/custom-icon/javascript.md @@ -42,14 +42,14 @@ diff --git a/static/usage/v8/reorder/custom-icon/javascript/index_html.md b/static/usage/v8/reorder/custom-icon/javascript/index_html.md index d7aa87d8f64..8535da7544a 100644 --- a/static/usage/v8/reorder/custom-icon/javascript/index_html.md +++ b/static/usage/v8/reorder/custom-icon/javascript/index_html.md @@ -42,14 +42,14 @@ diff --git a/static/usage/v8/reorder/custom-icon/react.md b/static/usage/v8/reorder/custom-icon/react.md index 9103db6029d..f5fe620035b 100644 --- a/static/usage/v8/reorder/custom-icon/react.md +++ b/static/usage/v8/reorder/custom-icon/react.md @@ -1,24 +1,24 @@ ```tsx import React from 'react'; -import { IonIcon, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ItemReorderEventDetail } from '@ionic/react'; +import { IonIcon, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ReorderEndCustomEvent } from '@ionic/react'; import { pizza } from 'ionicons/icons'; function Example() { - function handleReorder(event: CustomEvent) { + function handleReorderEnd(event: ReorderEndCustomEvent) { // The `from` and `to` properties contain the index of the item // when the drag started and ended, respectively console.log('Dragged from index', event.detail.from, 'to', event.detail.to); // Finish the reorder and position the item in the DOM based on // where the gesture ended. This method can also be called directly - // by the reorder group + // by the reorder group. event.detail.complete(); } return ( {/* The reorder gesture is disabled by default, enable it to drag and drop items */} - + Item 1 diff --git a/static/usage/v8/reorder/custom-icon/vue.md b/static/usage/v8/reorder/custom-icon/vue.md index 87d77e33048..eec6b5222a9 100644 --- a/static/usage/v8/reorder/custom-icon/vue.md +++ b/static/usage/v8/reorder/custom-icon/vue.md @@ -2,7 +2,7 @@ diff --git a/static/usage/v8/reorder/custom-scroll-target/angular/example_component_html.md b/static/usage/v8/reorder/custom-scroll-target/angular/example_component_html.md index 2296a5506c4..73fc3967021 100644 --- a/static/usage/v8/reorder/custom-scroll-target/angular/example_component_html.md +++ b/static/usage/v8/reorder/custom-scroll-target/angular/example_component_html.md @@ -4,7 +4,7 @@ - + Item 1 diff --git a/static/usage/v8/reorder/custom-scroll-target/angular/example_component_ts.md b/static/usage/v8/reorder/custom-scroll-target/angular/example_component_ts.md index bdd83c0417f..84dedb755b1 100644 --- a/static/usage/v8/reorder/custom-scroll-target/angular/example_component_ts.md +++ b/static/usage/v8/reorder/custom-scroll-target/angular/example_component_ts.md @@ -1,7 +1,7 @@ ```ts import { Component } from '@angular/core'; import { - ItemReorderEventDetail, + ReorderEndCustomEvent, IonContent, IonItem, IonLabel, @@ -17,14 +17,14 @@ import { imports: [IonContent, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup], }) export class ExampleComponent { - handleReorder(event: CustomEvent) { + handleReorderEnd(event: ReorderEndCustomEvent) { // The `from` and `to` properties contain the index of the item // when the drag started and ended, respectively console.log('Dragged from index', event.detail.from, 'to', event.detail.to); // Finish the reorder and position the item in the DOM based on // where the gesture ended. This method can also be called directly - // by the reorder group + // by the reorder group. event.detail.complete(); } } diff --git a/static/usage/v8/reorder/custom-scroll-target/demo.html b/static/usage/v8/reorder/custom-scroll-target/demo.html index 760fb525d79..fb66a69e0ce 100644 --- a/static/usage/v8/reorder/custom-scroll-target/demo.html +++ b/static/usage/v8/reorder/custom-scroll-target/demo.html @@ -10,16 +10,17 @@ + + + + + +
+ + + + +
+
+
+ + + + diff --git a/static/usage/v8/reorder/reorder-move-event/index.md b/static/usage/v8/reorder/reorder-move-event/index.md new file mode 100644 index 00000000000..be938ff393c --- /dev/null +++ b/static/usage/v8/reorder/reorder-move-event/index.md @@ -0,0 +1,26 @@ +import Playground from '@site/src/components/global/Playground'; + +import javascript from './javascript.md'; +import react from './react.md'; +import vue from './vue.md'; + +import angular_example_component_ts from './angular/example_component_ts.md'; +import angular_example_component_html from './angular/example_component_html.md'; + + diff --git a/static/usage/v8/reorder/reorder-move-event/javascript.md b/static/usage/v8/reorder/reorder-move-event/javascript.md new file mode 100644 index 00000000000..e559409668b --- /dev/null +++ b/static/usage/v8/reorder/reorder-move-event/javascript.md @@ -0,0 +1,89 @@ +```html + + + + + + +``` diff --git a/static/usage/v8/reorder/reorder-move-event/react.md b/static/usage/v8/reorder/reorder-move-event/react.md new file mode 100644 index 00000000000..39a0680728d --- /dev/null +++ b/static/usage/v8/reorder/reorder-move-event/react.md @@ -0,0 +1,92 @@ +```tsx +import React, { useState } from 'react'; +import { + IonItem, + IonLabel, + IonList, + IonReorder, + IonReorderGroup, + ReorderEndCustomEvent, + ReorderMoveCustomEvent, +} from '@ionic/react'; + +function Example() { + const [items, setItems] = useState([ + 'Buy groceries', + 'Call the bank', + 'Finish project report', + 'Book flight tickets', + 'Read a book', + ]); + + function handleReorderMove(event: ReorderMoveCustomEvent) { + const from = event.detail.from; + const to = event.detail.to; + + if (from !== to) { + console.log('Dragged from index', from, 'to', to); + } + + // Get all items and sort by their current id (item-1, item-2, ...) + const itemElements = Array.from(document.querySelectorAll('ion-item')).sort((a, b) => { + const aNum = parseInt(a.id.replace('item-', ''), 10); + const bNum = parseInt(b.id.replace('item-', ''), 10); + return aNum - bNum; + }); + + // Dragging down: shift up items between from+1 and to, set dragged to to+1 + if (from < to) { + for (let i = from; i <= to; i++) { + const item = itemElements[i]; + const itemNum = item.querySelector('b'); + if (i === from) { + // Dragged item + itemNum!.textContent = String(to + 1); + item.id = `item-${to + 1}`; + } else { + // Items shift up + itemNum!.textContent = String(i); + item.id = `item-${i}`; + } + } + // Dragging up: shift down items between to and from-1, set dragged to to+1 + } else if (from > to) { + for (let i = to; i <= from; i++) { + const item = itemElements[i]; + const itemNum = item.querySelector('b'); + if (i === from) { + // Dragged item + itemNum!.textContent = String(to + 1); + item.id = `item-${to + 1}`; + } else { + // Items shift down + itemNum!.textContent = String(i + 2); + item.id = `item-${i + 2}`; + } + } + } + } + + function handleReorderEnd(event: ReorderEndCustomEvent) { + // Finish the reorder and update the items data + setItems(event.detail.complete(items)); + } + + return ( + + {/* The reorder gesture is disabled by default, enable it to drag and drop items */} + + {items.map((item, index) => ( + + {index + 1} + {item} + + + ))} + + + ); +} + +export default Example; +``` diff --git a/static/usage/v8/reorder/reorder-move-event/vue.md b/static/usage/v8/reorder/reorder-move-event/vue.md new file mode 100644 index 00000000000..cd3518e5aac --- /dev/null +++ b/static/usage/v8/reorder/reorder-move-event/vue.md @@ -0,0 +1,81 @@ +```html + + + +``` diff --git a/static/usage/v8/reorder/reorder-start-end-events/angular/example_component_html.md b/static/usage/v8/reorder/reorder-start-end-events/angular/example_component_html.md new file mode 100644 index 00000000000..7b9be3a150c --- /dev/null +++ b/static/usage/v8/reorder/reorder-start-end-events/angular/example_component_html.md @@ -0,0 +1,19 @@ +```html + + + + + @for (item of items; track item; let i = $index) { + + {{ item.label }} + + + + } + + +``` diff --git a/static/usage/v8/reorder/reorder-start-end-events/angular/example_component_ts.md b/static/usage/v8/reorder/reorder-start-end-events/angular/example_component_ts.md new file mode 100644 index 00000000000..ec4ccbdb946 --- /dev/null +++ b/static/usage/v8/reorder/reorder-start-end-events/angular/example_component_ts.md @@ -0,0 +1,62 @@ +```ts +import { Component, ViewChildren, QueryList, ElementRef } from '@angular/core'; +import { + ReorderEndCustomEvent, + IonItem, + IonLabel, + IonList, + IonReorder, + IonReorderGroup, + IonIcon, +} from '@ionic/angular/standalone'; +import { addIcons } from 'ionicons'; +import { caretDown, ellipse, warning } from 'ionicons/icons'; + +@Component({ + selector: 'app-example', + templateUrl: 'example.component.html', + styleUrls: ['example.component.css'], + imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, IonIcon], +}) +export class ExampleComponent { + items = [ + { label: 'Buy groceries', icon: 'warning', color: 'warning' }, + { label: 'Call the bank', icon: 'warning', color: 'warning' }, + { label: 'Finish project report', icon: 'ellipse', color: 'light' }, + { label: 'Book flight tickets', icon: 'ellipse', color: 'light' }, + { label: 'Read a book', icon: 'caret-down', color: 'secondary' }, + ]; + + @ViewChildren('icon', { read: ElementRef }) icons!: QueryList>; + + constructor() { + /** + * Any icons you want to use in your application + * can be registered in app.component.ts and then + * referenced by name anywhere in your application. + */ + addIcons({ caretDown, ellipse, warning }); + } + + handleReorderStart() { + console.log('Reorder started'); + + // Hide the icons when the reorder starts + this.icons.forEach((icon) => { + icon.nativeElement.style.opacity = '0'; + }); + } + + handleReorderEnd(event: ReorderEndCustomEvent) { + console.log('Dragged from index', event.detail.from, 'to', event.detail.to); + + // Show the icons again + this.icons.forEach((icon) => { + icon.nativeElement.style.opacity = '1'; + }); + + // Finish the reorder and update the items data + this.items = event.detail.complete(this.items); + } +} +``` diff --git a/static/usage/v8/reorder/reorder-start-end-events/demo.html b/static/usage/v8/reorder/reorder-start-end-events/demo.html new file mode 100644 index 00000000000..72e214b83fe --- /dev/null +++ b/static/usage/v8/reorder/reorder-start-end-events/demo.html @@ -0,0 +1,82 @@ + + + + + + Reorder + + + + + + + + + + + +
+ + + + + Buy groceries + + + + + Call the bank + + + + + Finish project report + + + + + Book flight tickets + + + + + Read a book + + + + + +
+
+
+ + + + diff --git a/static/usage/v8/reorder/reorder-start-end-events/index.md b/static/usage/v8/reorder/reorder-start-end-events/index.md new file mode 100644 index 00000000000..5e7d48127d1 --- /dev/null +++ b/static/usage/v8/reorder/reorder-start-end-events/index.md @@ -0,0 +1,33 @@ +import Playground from '@site/src/components/global/Playground'; + +import javascript_index_html from './javascript/index_html.md'; +import javascript_index_ts from './javascript/index_ts.md'; + +import react from './react.md'; +import vue from './vue.md'; + +import angular_example_component_html from './angular/example_component_html.md'; +import angular_example_component_ts from './angular/example_component_ts.md'; + + diff --git a/static/usage/v8/reorder/reorder-start-end-events/javascript/index_html.md b/static/usage/v8/reorder/reorder-start-end-events/javascript/index_html.md new file mode 100644 index 00000000000..a98397de9e1 --- /dev/null +++ b/static/usage/v8/reorder/reorder-start-end-events/javascript/index_html.md @@ -0,0 +1,57 @@ +```html + + + + + Buy groceries + + + + + Call the bank + + + + + Finish project report + + + + + Book flight tickets + + + + + Read a book + + + + + + + +``` diff --git a/static/usage/v8/reorder/reorder-start-end-events/javascript/index_ts.md b/static/usage/v8/reorder/reorder-start-end-events/javascript/index_ts.md new file mode 100644 index 00000000000..c9e03106886 --- /dev/null +++ b/static/usage/v8/reorder/reorder-start-end-events/javascript/index_ts.md @@ -0,0 +1,47 @@ +```ts +import { defineCustomElements } from '@ionic/core/loader'; + +import { addIcons } from 'ionicons'; +import { caretDown, ellipse, warning } from 'ionicons/icons'; + +/* Core CSS required for Ionic components to work properly */ +import '@ionic/core/css/core.css'; + +/* Basic CSS for apps built with Ionic */ +import '@ionic/core/css/normalize.css'; +import '@ionic/core/css/structure.css'; +import '@ionic/core/css/typography.css'; + +/* Optional CSS utils that can be commented out */ +import '@ionic/core/css/padding.css'; +import '@ionic/core/css/float-elements.css'; +import '@ionic/core/css/text-alignment.css'; +import '@ionic/core/css/text-transformation.css'; +import '@ionic/core/css/flex-utils.css'; +import '@ionic/core/css/display.css'; + +/** + * Ionic Dark Palette + * ----------------------------------------------------- + * For more information, please see: + * https://ionicframework.com/docs/theming/dark-mode + */ + +// import '@ionic/core/css/palettes/dark.always.css'; +// import '@ionic/core/css/palettes/dark.class.css'; +import '@ionic/core/css/palettes/dark.system.css'; + +/* Theme variables */ +import './theme/variables.css'; + +/** + * On Ionicons 7.2+ these icons get mapped + * to "caret-down", "ellipse", "warning" keys. + * Alternatively, developers can do: + * addIcons({ 'caret-down': caretDown, + * "ellipse": ellipse, "warning": warning }); + */ +addIcons({ caretDown, ellipse, warning }); + +defineCustomElements(); +``` diff --git a/static/usage/v8/reorder/reorder-start-end-events/react.md b/static/usage/v8/reorder/reorder-start-end-events/react.md new file mode 100644 index 00000000000..c70462d5b32 --- /dev/null +++ b/static/usage/v8/reorder/reorder-start-end-events/react.md @@ -0,0 +1,67 @@ +```tsx +import React, { useRef, useState } from 'react'; +import { IonIcon, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ReorderEndCustomEvent } from '@ionic/react'; +import { caretDown, ellipse, warning } from 'ionicons/icons'; + +interface TodoItem { + label: string; + icon: string; + color: string; +} + +function Example() { + const [items, setItems] = useState([ + { label: 'Buy groceries', icon: warning, color: 'warning' }, + { label: 'Call the bank', icon: warning, color: 'warning' }, + { label: 'Finish project report', icon: ellipse, color: 'light' }, + { label: 'Book flight tickets', icon: ellipse, color: 'light' }, + { label: 'Read a book', icon: caretDown, color: 'secondary' }, + ]); + const iconsRef = useRef<(HTMLIonIconElement | null)[]>([]); + + function handleReorderStart() { + console.log('Reorder started'); + + // Hide the icons when the reorder starts + iconsRef.current.forEach((icon) => { + if (icon) icon.style.opacity = '0'; + }); + } + + function handleReorderEnd(event: ReorderEndCustomEvent) { + console.log('Dragged from index', event.detail.from, 'to', event.detail.to); + + // Show the icons again + iconsRef.current.forEach((icon) => { + if (icon) icon.style.opacity = '1'; + }); + + // Finish the reorder and update the items data + setItems(event.detail.complete(items)); + } + + return ( + + {/* The reorder gesture is disabled by default, enable it to drag and drop items */} + + {items.map((item: TodoItem, i: number) => ( + + {item.label} + { + iconsRef.current[i] = el; + }} + /> + + + ))} + + + ); +} + +export default Example; +``` diff --git a/static/usage/v8/reorder/reorder-start-end-events/vue.md b/static/usage/v8/reorder/reorder-start-end-events/vue.md new file mode 100644 index 00000000000..0648e09bddc --- /dev/null +++ b/static/usage/v8/reorder/reorder-start-end-events/vue.md @@ -0,0 +1,59 @@ +```html + + + +``` diff --git a/static/usage/v8/reorder/toggling-disabled/angular/example_component_html.md b/static/usage/v8/reorder/toggling-disabled/angular/example_component_html.md index aca04f1ee5a..dbfe175895b 100644 --- a/static/usage/v8/reorder/toggling-disabled/angular/example_component_html.md +++ b/static/usage/v8/reorder/toggling-disabled/angular/example_component_html.md @@ -1,7 +1,7 @@ ```html - + Item 1 diff --git a/static/usage/v8/reorder/toggling-disabled/angular/example_component_ts.md b/static/usage/v8/reorder/toggling-disabled/angular/example_component_ts.md index 496e59f15e1..1e1448b61a0 100644 --- a/static/usage/v8/reorder/toggling-disabled/angular/example_component_ts.md +++ b/static/usage/v8/reorder/toggling-disabled/angular/example_component_ts.md @@ -1,13 +1,13 @@ ```ts import { Component } from '@angular/core'; import { - ItemReorderEventDetail, IonButton, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, + ReorderEndCustomEvent, } from '@ionic/angular/standalone'; @Component({ @@ -19,14 +19,14 @@ import { export class ExampleComponent { public isDisabled = true; - handleReorder(event: CustomEvent) { + handleReorderEnd(event: ReorderEndCustomEvent) { // The `from` and `to` properties contain the index of the item // when the drag started and ended, respectively console.log('Dragged from index', event.detail.from, 'to', event.detail.to); // Finish the reorder and position the item in the DOM based on // where the gesture ended. This method can also be called directly - // by the reorder group + // by the reorder group. event.detail.complete(); } diff --git a/static/usage/v8/reorder/toggling-disabled/demo.html b/static/usage/v8/reorder/toggling-disabled/demo.html index 46481ab3dc0..4b5dc99e6e8 100644 --- a/static/usage/v8/reorder/toggling-disabled/demo.html +++ b/static/usage/v8/reorder/toggling-disabled/demo.html @@ -16,7 +16,7 @@ } ion-list { - width: 100%; + width: 300px; } @@ -63,14 +63,14 @@ diff --git a/static/usage/v8/reorder/updating-data/angular/example_component_html.md b/static/usage/v8/reorder/updating-data/angular/example_component_html.md index 873daed0e90..6326a17c949 100644 --- a/static/usage/v8/reorder/updating-data/angular/example_component_html.md +++ b/static/usage/v8/reorder/updating-data/angular/example_component_html.md @@ -2,7 +2,7 @@ - + @for (item of items; track item) { Item {{ item }} diff --git a/static/usage/v8/reorder/updating-data/angular/example_component_ts.md b/static/usage/v8/reorder/updating-data/angular/example_component_ts.md index f70f2bed206..d476b6fdfa0 100644 --- a/static/usage/v8/reorder/updating-data/angular/example_component_ts.md +++ b/static/usage/v8/reorder/updating-data/angular/example_component_ts.md @@ -1,12 +1,12 @@ ```ts import { Component } from '@angular/core'; import { - ItemReorderEventDetail, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, + ReorderEndCustomEvent, } from '@ionic/angular/standalone'; @Component({ @@ -18,7 +18,7 @@ import { export class ExampleComponent { items = [1, 2, 3, 4, 5]; - handleReorder(event: CustomEvent) { + handleReorderEnd(event: ReorderEndCustomEvent) { // Before complete is called with the items they will remain in the // order before the drag console.log('Before complete', this.items); diff --git a/static/usage/v8/reorder/updating-data/demo.html b/static/usage/v8/reorder/updating-data/demo.html index 8f0ca1b7cda..a01deb9600c 100644 --- a/static/usage/v8/reorder/updating-data/demo.html +++ b/static/usage/v8/reorder/updating-data/demo.html @@ -11,7 +11,7 @@ @@ -34,7 +34,7 @@ let items = [1, 2, 3, 4, 5]; reorderItems(items); - reorderGroup.addEventListener('ionItemReorder', ({ detail }) => { + reorderGroup.addEventListener('ionReorderEnd', ({ detail }) => { // Before complete is called with the items they will remain in the // order before the drag console.log('Before complete', items); diff --git a/static/usage/v8/reorder/updating-data/javascript.md b/static/usage/v8/reorder/updating-data/javascript.md index 901bf08a970..28ef0989eea 100644 --- a/static/usage/v8/reorder/updating-data/javascript.md +++ b/static/usage/v8/reorder/updating-data/javascript.md @@ -10,7 +10,7 @@ let items = [1, 2, 3, 4, 5]; reorderItems(items); - reorderGroup.addEventListener('ionItemReorder', ({ detail }) => { + reorderGroup.addEventListener('ionReorderEnd', ({ detail }) => { // Before complete is called with the items they will remain in the // order before the drag console.log('Before complete', items); diff --git a/static/usage/v8/reorder/updating-data/react.md b/static/usage/v8/reorder/updating-data/react.md index acbf422d017..36b9049e56a 100644 --- a/static/usage/v8/reorder/updating-data/react.md +++ b/static/usage/v8/reorder/updating-data/react.md @@ -1,11 +1,11 @@ ```tsx import React, { useState } from 'react'; -import { IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ItemReorderEventDetail } from '@ionic/react'; +import { IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ReorderEndCustomEvent } from '@ionic/react'; function Example() { const [items, setItems] = useState([1, 2, 3, 4, 5]); - function handleReorder(event: CustomEvent) { + function handleReorderEnd(event: ReorderEndCustomEvent) { // Before complete is called with the items they will remain in the // order before the drag console.log('Before complete', items); @@ -22,7 +22,7 @@ function Example() { return ( {/* The reorder gesture is disabled by default, enable it to drag and drop items */} - + {items.map((item) => ( Item {item} diff --git a/static/usage/v8/reorder/updating-data/vue.md b/static/usage/v8/reorder/updating-data/vue.md index 024caf38347..188df041bc2 100644 --- a/static/usage/v8/reorder/updating-data/vue.md +++ b/static/usage/v8/reorder/updating-data/vue.md @@ -2,7 +2,7 @@ diff --git a/static/usage/v8/reorder/wrapper/angular/example_component_html.md b/static/usage/v8/reorder/wrapper/angular/example_component_html.md index cf856309098..5abb818e8b3 100644 --- a/static/usage/v8/reorder/wrapper/angular/example_component_html.md +++ b/static/usage/v8/reorder/wrapper/angular/example_component_html.md @@ -2,7 +2,7 @@ - + Item 1 diff --git a/static/usage/v8/reorder/wrapper/angular/example_component_ts.md b/static/usage/v8/reorder/wrapper/angular/example_component_ts.md index 541fd9c6df3..5553891178a 100644 --- a/static/usage/v8/reorder/wrapper/angular/example_component_ts.md +++ b/static/usage/v8/reorder/wrapper/angular/example_component_ts.md @@ -1,12 +1,12 @@ ```ts import { Component } from '@angular/core'; import { - ItemReorderEventDetail, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, + ReorderEndCustomEvent, } from '@ionic/angular/standalone'; @Component({ @@ -16,14 +16,14 @@ import { imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup], }) export class ExampleComponent { - handleReorder(event: CustomEvent) { + handleReorderEnd(event: ReorderEndCustomEvent) { // The `from` and `to` properties contain the index of the item // when the drag started and ended, respectively console.log('Dragged from index', event.detail.from, 'to', event.detail.to); // Finish the reorder and position the item in the DOM based on // where the gesture ended. This method can also be called directly - // by the reorder group + // by the reorder group. event.detail.complete(); } } diff --git a/static/usage/v8/reorder/wrapper/demo.html b/static/usage/v8/reorder/wrapper/demo.html index 1322a6ee6fd..e4520630556 100644 --- a/static/usage/v8/reorder/wrapper/demo.html +++ b/static/usage/v8/reorder/wrapper/demo.html @@ -11,7 +11,7 @@ @@ -61,14 +61,14 @@ diff --git a/static/usage/v8/reorder/wrapper/javascript.md b/static/usage/v8/reorder/wrapper/javascript.md index e4e024ee2d4..3cd52cb1e8c 100644 --- a/static/usage/v8/reorder/wrapper/javascript.md +++ b/static/usage/v8/reorder/wrapper/javascript.md @@ -37,14 +37,14 @@ diff --git a/static/usage/v8/reorder/wrapper/react.md b/static/usage/v8/reorder/wrapper/react.md index f70ba499316..50210964586 100644 --- a/static/usage/v8/reorder/wrapper/react.md +++ b/static/usage/v8/reorder/wrapper/react.md @@ -1,23 +1,23 @@ ```tsx import React from 'react'; -import { IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ItemReorderEventDetail } from '@ionic/react'; +import { IonItem, IonLabel, IonList, IonReorder, IonReorderGroup, ReorderEndCustomEvent } from '@ionic/react'; function Example() { - function handleReorder(event: CustomEvent) { + function handleReorderEnd(event: ReorderEndCustomEvent) { // The `from` and `to` properties contain the index of the item // when the drag started and ended, respectively console.log('Dragged from index', event.detail.from, 'to', event.detail.to); // Finish the reorder and position the item in the DOM based on // where the gesture ended. This method can also be called directly - // by the reorder group + // by the reorder group. event.detail.complete(); } return ( {/* The reorder gesture is disabled by default, enable it to drag and drop items */} - + Item 1 diff --git a/static/usage/v8/reorder/wrapper/vue.md b/static/usage/v8/reorder/wrapper/vue.md index fd157186093..1b114e575de 100644 --- a/static/usage/v8/reorder/wrapper/vue.md +++ b/static/usage/v8/reorder/wrapper/vue.md @@ -2,7 +2,7 @@ diff --git a/versioned_docs/version-v5/layout/css-utilities.md b/versioned_docs/version-v5/layout/css-utilities.md index c2dfe9934d4..e81b9503249 100644 --- a/versioned_docs/version-v5/layout/css-utilities.md +++ b/versioned_docs/version-v5/layout/css-utilities.md @@ -6,13 +6,13 @@ title: CSS Utilities Ionic Framework provides a set of CSS utility classes that can be used on any element in order to modify the text, element placement or adjust the padding and margin. -:::note +:::important If your app was not started using an available Ionic Framework starter, the stylesheets listed in the [optional section of the global stylesheets](global-stylesheets.md#optional) will need to be included in order for these styles to work. ::: ## Text Modification -### Text Alignment +### Text Align ```html @@ -70,7 +70,7 @@ If your app was not started using an available Ionic Framework starter, the styl | `.ion-text-wrap` | `white-space: normal` | Sequences of whitespace are collapsed. Newline characters in the source are handled as other whitespace. Breaks lines as necessary to fill line boxes. | | `.ion-text-nowrap` | `white-space: nowrap` | Collapses whitespace as for `normal`, but suppresses line breaks (text wrapping) within text. | -### Text Transformation +### Text Transform ```html @@ -121,7 +121,7 @@ The table below shows the default behavior, where `{modifier}` is any of the fol ### Float Elements -The float CSS property specifies that an element should be placed along the left or right side of its container, where text and inline elements will wrap around it. This way, the element is taken from the normal flow of the web page, though still remaining a part of the flow, contrary to absolute positioning. +The [float](https://developer.mozilla.org/en-US/docs/Web/CSS/float) CSS property specifies that an element should be placed along the left or right side of its container, where text and inline elements will wrap around it. This way, the element is taken from the normal flow of the web page, though still remaining a part of the flow, contrary to absolute positioning. ```html @@ -165,7 +165,7 @@ The table below shows the default behavior, where `{modifier}` is any of the fol ## Element Display -The display CSS property determines if an element should be visible or not. The element will still be in the DOM, but not rendered, if it is hidden. +The [display](https://developer.mozilla.org/en-US/docs/Web/CSS/display) CSS property sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex. It can also be used to completely hide an element from the layout. ```html @@ -190,7 +190,7 @@ The display CSS property determines if an element should be visible or not. The | ----------- | --------------- | --------------------------- | | `.ion-hide` | `display: none` | The element will be hidden. | -### Responsive Display Attributes +### Responsive Display Classes There are also additional classes to modify the visibility based on the screen size. Instead of just `.ion-hide` for all screen sizes, use `.ion-hide-{breakpoint}-{dir}` to only use the class on specific screen sizes, where `{breakpoint}` is one of the breakpoint names listed in [Ionic Breakpoints](#ionic-breakpoints), and `{dir}` is whether the element should be hidden on all screen sizes above (`up`) or below (`down`) the specified breakpoint. @@ -203,7 +203,7 @@ There are also additional classes to modify the visibility based on the screen s ## Content Space -### Element Padding +### Padding The padding class sets the padding area of an element. The padding area is the space between the content of the element and its border. @@ -253,7 +253,7 @@ The default amount of `padding` to be applied is `16px` and is set by the `--ion | `.ion-padding-horizontal` | `padding: 0 16px` | Applies padding to the left and right. | | `.ion-no-padding` | `padding: 0` | Applies no padding to all sides. | -### Element Margin +### Margin The margin area extends the border area with an empty area used to separate the element from its neighbors. @@ -493,7 +493,7 @@ The default amount of `margin` to be applied is `16px` and is set by the `--ion- ## Border Display -The border display CSS property determines if the border should be visible or not. The property can be applied to the ion-header and the ion-footer. +The `.ion-no-border` utility class can be used to remove borders from Ionic components. This class can be applied to the `ion-header` and `ion-footer` components. ```html diff --git a/versioned_docs/version-v6/layout/css-utilities.md b/versioned_docs/version-v6/layout/css-utilities.md index f743f94a139..20e40f101cc 100644 --- a/versioned_docs/version-v6/layout/css-utilities.md +++ b/versioned_docs/version-v6/layout/css-utilities.md @@ -12,13 +12,13 @@ title: CSS Utilities Ionic Framework provides a set of CSS utility classes that can be used on any element in order to modify the text, element placement or adjust the padding and margin. -:::note +:::important If your app was not started using an available Ionic Framework starter, the stylesheets listed in the [optional section of the global stylesheets](global-stylesheets.md#optional) will need to be included in order for these styles to work. ::: ## Text Modification -### Text Alignment +### Text Align ```html @@ -76,7 +76,7 @@ If your app was not started using an available Ionic Framework starter, the styl | `.ion-text-wrap` | `white-space: normal` | Sequences of whitespace are collapsed. Newline characters in the source are handled as other whitespace. Breaks lines as necessary to fill line boxes. | | `.ion-text-nowrap` | `white-space: nowrap` | Collapses whitespace as for `normal`, but suppresses line breaks (text wrapping) within text. | -### Text Transformation +### Text Transform ```html @@ -127,7 +127,7 @@ The table below shows the default behavior, where `{modifier}` is any of the fol ### Float Elements -The float CSS property specifies that an element should be placed along the left or right side of its container, where text and inline elements will wrap around it. This way, the element is taken from the normal flow of the web page, though still remaining a part of the flow, contrary to absolute positioning. +The [float](https://developer.mozilla.org/en-US/docs/Web/CSS/float) CSS property specifies that an element should be placed along the left or right side of its container, where text and inline elements will wrap around it. This way, the element is taken from the normal flow of the web page, though still remaining a part of the flow, contrary to absolute positioning. ```html @@ -171,7 +171,7 @@ The table below shows the default behavior, where `{modifier}` is any of the fol ## Element Display -The display CSS property determines if an element should be visible or not. The element will still be in the DOM, but not rendered, if it is hidden. +The [display](https://developer.mozilla.org/en-US/docs/Web/CSS/display) CSS property sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex. It can also be used to completely hide an element from the layout. ```html @@ -196,7 +196,7 @@ The display CSS property determines if an element should be visible or not. The | ----------- | --------------- | --------------------------- | | `.ion-hide` | `display: none` | The element will be hidden. | -### Responsive Display Attributes +### Responsive Display Classes There are also additional classes to modify the visibility based on the screen size. Instead of just `.ion-hide` for all screen sizes, use `.ion-hide-{breakpoint}-{dir}` to only use the class on specific screen sizes, where `{breakpoint}` is one of the breakpoint names listed in [Ionic Breakpoints](#ionic-breakpoints), and `{dir}` is whether the element should be hidden on all screen sizes above (`up`) or below (`down`) the specified breakpoint. @@ -209,7 +209,7 @@ There are also additional classes to modify the visibility based on the screen s ## Content Space -### Element Padding +### Padding The padding class sets the padding area of an element. The padding area is the space between the content of the element and its border. @@ -259,7 +259,7 @@ The default amount of `padding` to be applied is `16px` and is set by the `--ion | `.ion-padding-horizontal` | `padding: 0 16px` | Applies padding to the left and right. | | `.ion-no-padding` | `padding: 0` | Applies no padding to all sides. | -### Element Margin +### Margin The margin area extends the border area with an empty area used to separate the element from its neighbors. @@ -499,7 +499,7 @@ The default amount of `margin` to be applied is `16px` and is set by the `--ion- ## Border Display -The border display CSS property determines if the border should be visible or not. The property can be applied to the ion-header and the ion-footer. +The `.ion-no-border` utility class can be used to remove borders from Ionic components. This class can be applied to the `ion-header` and `ion-footer` components. ```html diff --git a/versioned_docs/version-v7/layout/css-utilities.md b/versioned_docs/version-v7/layout/css-utilities.md index 05bb0a88aaa..21bf56b8d4c 100644 --- a/versioned_docs/version-v7/layout/css-utilities.md +++ b/versioned_docs/version-v7/layout/css-utilities.md @@ -14,13 +14,13 @@ inlineHtmlPreviews: true Ionic Framework provides a set of CSS utility classes that can be used on any element in order to modify the text, element placement or adjust the padding and margin. -:::note +:::important If your app was not started using an available Ionic Framework starter, the stylesheets listed in the [optional section of the global stylesheets](global-stylesheets.md#optional) will need to be included in order for these styles to work. ::: ## Text Modification -### Text Alignment +### Text Align ```html @@ -78,7 +78,7 @@ If your app was not started using an available Ionic Framework starter, the styl | `.ion-text-wrap` | `white-space: normal` | Sequences of whitespace are collapsed. Newline characters in the source are handled as other whitespace. Breaks lines as necessary to fill line boxes. | | `.ion-text-nowrap` | `white-space: nowrap` | Collapses whitespace as for `normal`, but suppresses line breaks (text wrapping) within text. | -### Text Transformation +### Text Transform ```html @@ -129,7 +129,7 @@ The table below shows the default behavior, where `{modifier}` is any of the fol ### Float Elements -The float CSS property specifies that an element should be placed along the left or right side of its container, where text and inline elements will wrap around it. This way, the element is taken from the normal flow of the web page, though still remaining a part of the flow, contrary to absolute positioning. +The [float](https://developer.mozilla.org/en-US/docs/Web/CSS/float) CSS property specifies that an element should be placed along the left or right side of its container, where text and inline elements will wrap around it. This way, the element is taken from the normal flow of the web page, though still remaining a part of the flow, contrary to absolute positioning. ```html @@ -190,7 +190,7 @@ The table below shows the default behavior, where `{modifier}` is any of the fol ## Element Display -The display CSS property determines if an element should be visible or not. The element will still be in the DOM, but not rendered, if it is hidden. +The [display](https://developer.mozilla.org/en-US/docs/Web/CSS/display) CSS property sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex. It can also be used to completely hide an element from the layout. ```html @@ -215,7 +215,7 @@ The display CSS property determines if an element should be visible or not. The | ----------- | --------------- | --------------------------- | | `.ion-hide` | `display: none` | The element will be hidden. | -### Responsive Display Attributes +### Responsive Display Classes There are also additional classes to modify the visibility based on the screen size. Instead of just `.ion-hide` for all screen sizes, use `.ion-hide-{breakpoint}-{dir}` to only use the class on specific screen sizes, where `{breakpoint}` is one of the breakpoint names listed in [Ionic Breakpoints](#ionic-breakpoints), and `{dir}` is whether the element should be hidden on all screen sizes above (`up`) or below (`down`) the specified breakpoint. @@ -228,7 +228,7 @@ There are also additional classes to modify the visibility based on the screen s ## Content Space -### Element Padding +### Padding The padding class sets the padding area of an element. The padding area is the space between the content of the element and its border. @@ -278,7 +278,7 @@ The default amount of `padding` to be applied is `16px` and is set by the `--ion | `.ion-padding-horizontal` | `padding: 0 16px` | Applies padding to the left and right. | | `.ion-no-padding` | `padding: 0` | Applies no padding to all sides. | -### Element Margin +### Margin The margin area extends the border area with an empty area used to separate the element from its neighbors. @@ -518,7 +518,7 @@ The default amount of `margin` to be applied is `16px` and is set by the `--ion- ## Border Display -The border display CSS property determines if the border should be visible or not. The property can be applied to the ion-header and the ion-footer. +The `.ion-no-border` utility class can be used to remove borders from Ionic components. This class can be applied to the `ion-header` and `ion-footer` components. ```html
` element. | +| `.ion-display-table-row` | `display: table-row` | The element behaves like an HTML `