Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(reorder): update angular to standalone #3957

Open
wants to merge 5 commits into
base: ROU-11416
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/reorder.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ In order to sort the array upon completion of the reorder, the array should be p

In some cases, it may be necessary for an app to reorder both the array and the DOM nodes on its own. If this is required, `false` should be passed as a parameter to the `complete` method. This will prevent Ionic from reordering any DOM nodes inside of the reorder group.

Regardless of the approach taken, a stable identity should be provided to reorder items if provided in a loop. This means using `trackBy` for Angular, and `key` for React and Vue.
Regardless of the approach taken, a stable identity should be provided to reorder items if provided in a loop. This means using `track` for Angular, and `key` for React and Vue.

import UpdatingData from '@site/static/usage/v8/reorder/updating-data/index.md';

Expand Down
12 changes: 10 additions & 2 deletions static/usage/v7/reorder/basic/angular/example_component_ts.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
handleReorder(ev: CustomEvent<ItemReorderEventDetail>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonIcon,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

import { addIcons } from 'ionicons';
import { pizza } from 'ionicons/icons';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonIcon, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonContent,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['./example.component.css'],
imports: [IonContent, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
handleReorder(ev: CustomEvent<ItemReorderEventDetail>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonButton,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonButton, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
public isDisabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<!-- The reorder gesture is disabled by default, enable it to drag and drop items -->
<!-- Casting $event to $any is a temporary fix for this bug https://github.com/ionic-team/ionic-framework/issues/24245 -->
<ion-reorder-group [disabled]="false" (ionItemReorder)="handleReorder($any($event))">
<ion-item *ngFor="let item of items; trackBy: trackItems">
@for (item of items; track item) {
<ion-item>
<ion-label> Item {{ item }} </ion-label>
<ion-reorder slot="end"></ion-reorder>
</ion-item>
}
</ion-reorder-group>
</ion-list>
```
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
items = [1, 2, 3, 4, 5];
Expand All @@ -23,9 +31,5 @@ export class ExampleComponent {
// After complete is called the items will be in the new order
console.log('After complete', this.items);
}

trackItems(index: number, itemNumber: number) {
return itemNumber;
}
}
```
12 changes: 10 additions & 2 deletions static/usage/v7/reorder/wrapper/angular/example_component_ts.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
handleReorder(ev: CustomEvent<ItemReorderEventDetail>) {
Expand Down
12 changes: 10 additions & 2 deletions static/usage/v8/reorder/basic/angular/example_component_ts.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
handleReorder(ev: CustomEvent<ItemReorderEventDetail>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonIcon,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

import { addIcons } from 'ionicons';
import { pizza } from 'ionicons/icons';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonIcon, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonContent,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['./example.component.css'],
imports: [IonContent, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
handleReorder(ev: CustomEvent<ItemReorderEventDetail>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonButton,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonButton, IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
public isDisabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<!-- The reorder gesture is disabled by default, enable it to drag and drop items -->
<!-- Casting $event to $any is a temporary fix for this bug https://github.com/ionic-team/ionic-framework/issues/24245 -->
<ion-reorder-group [disabled]="false" (ionItemReorder)="handleReorder($any($event))">
<ion-item *ngFor="let item of items; trackBy: trackItems">
@for (item of items; track item) {
<ion-item>
<ion-label> Item {{ item }} </ion-label>
<ion-reorder slot="end"></ion-reorder>
</ion-item>
}
</ion-reorder-group>
</ion-list>
```
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
items = [1, 2, 3, 4, 5];
Expand All @@ -23,9 +31,5 @@ export class ExampleComponent {
// After complete is called the items will be in the new order
console.log('After complete', this.items);
}

trackItems(index: number, itemNumber: number) {
return itemNumber;
}
}
```
12 changes: 10 additions & 2 deletions static/usage/v8/reorder/wrapper/angular/example_component_ts.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
```ts
import { Component } from '@angular/core';

import { ItemReorderEventDetail } from '@ionic/angular';
import {
ItemReorderEventDetail,
IonItem,
IonLabel,
IonList,
IonReorder,
IonReorderGroup,
} from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonItem, IonLabel, IonList, IonReorder, IonReorderGroup],
})
export class ExampleComponent {
handleReorder(ev: CustomEvent<ItemReorderEventDetail>) {
Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-v7/api/reorder.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ In order to sort the array upon completion of the reorder, the array should be p

In some cases, it may be necessary for an app to reorder both the array and the DOM nodes on its own. If this is required, `false` should be passed as a parameter to the `complete` method. This will prevent Ionic from reordering any DOM nodes inside of the reorder group.

Regardless of the approach taken, a stable identity should be provided to reorder items if provided in a loop. This means using `trackBy` for Angular, and `key` for React and Vue.
Regardless of the approach taken, a stable identity should be provided to reorder items if provided in a loop. This means using `track` for Angular, and `key` for React and Vue.

import UpdatingData from '@site/static/usage/v7/reorder/updating-data/index.md';

Expand Down