-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(content, fab): fixed slot placement (#3563)
Co-authored-by: Liam DeBeasi <[email protected]>
- Loading branch information
1 parent
680fb37
commit 9d20cab
Showing
9 changed files
with
342 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
static/usage/v8/fab/before-content/angular/example_component_html.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
```html | ||
<ion-content fixed-slot-placement="before"> | ||
<ion-fab horizontal="end" vertical="bottom" slot="fixed"> | ||
<ion-fab-button> | ||
<ion-icon name="add"></ion-icon> | ||
</ion-fab-button> | ||
</ion-fab> | ||
<ion-list> | ||
<ion-item [button]="true" *ngFor="let item of items; let index"> | ||
<ion-avatar slot="start"> | ||
<img [src]="'https://picsum.photos/80/80?random=' + index" alt="avatar" /> | ||
</ion-avatar> | ||
<ion-label>{{ item }}</ion-label> | ||
</ion-item> | ||
</ion-list> | ||
<ion-infinite-scroll (ionInfinite)="onIonInfinite($event)"> | ||
<ion-infinite-scroll-content></ion-infinite-scroll-content> | ||
</ion-infinite-scroll> | ||
</ion-content> | ||
``` |
31 changes: 31 additions & 0 deletions
31
static/usage/v8/fab/before-content/angular/example_component_ts.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
```tsx | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
import { InfiniteScrollCustomEvent } from '@ionic/angular'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: 'example.component.html', | ||
}) | ||
export class ExampleComponent implements OnInit { | ||
items = []; | ||
|
||
ngOnInit() { | ||
this.generateItems(); | ||
} | ||
|
||
private generateItems() { | ||
const count = this.items.length + 1; | ||
for (let i = 0; i < 50; i++) { | ||
this.items.push(`Item ${count + i}`); | ||
} | ||
} | ||
|
||
onIonInfinite(ev) { | ||
this.generateItems(); | ||
setTimeout(() => { | ||
(ev as InfiniteScrollCustomEvent).target.complete(); | ||
}, 500); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Fab</title> | ||
<link rel="stylesheet" href="../../common.css" /> | ||
<script src="../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@next/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@next/css/ionic.bundle.css" /> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-content fixed-slot-placement="before"> | ||
<ion-fab horizontal="end" vertical="bottom" slot="fixed"> | ||
<ion-fab-button> | ||
<ion-icon name="add"></ion-icon> | ||
</ion-fab-button> | ||
</ion-fab> | ||
<ion-list></ion-list> | ||
<ion-infinite-scroll> | ||
<ion-infinite-scroll-content></ion-infinite-scroll-content> | ||
</ion-infinite-scroll> | ||
</ion-content> | ||
</ion-app> | ||
<script> | ||
const infiniteScroll = document.querySelector('ion-infinite-scroll'); | ||
infiniteScroll.addEventListener('ionInfinite', (event) => { | ||
setTimeout(() => { | ||
generateItems(); | ||
event.target.complete(); | ||
}, 500); | ||
}); | ||
|
||
const list = document.querySelector('ion-list'); | ||
|
||
function generateItems() { | ||
const count = list.childElementCount + 1; | ||
const total = count + 50; | ||
for (let i = count; i < total; i++) { | ||
const el = document.createElement('ion-item'); | ||
el.button = true; | ||
|
||
const avatar = document.createElement('ion-avatar'); | ||
avatar.slot = 'start'; | ||
const img = document.createElement('img'); | ||
img.src = `https://picsum.photos/80/80?random=${i}`; | ||
img.alt = 'Avatar'; | ||
|
||
avatar.appendChild(img); | ||
el.appendChild(avatar); | ||
|
||
const text = document.createElement('ion-label'); | ||
text.innerText = `Item ${i}`; | ||
|
||
el.appendChild(text); | ||
|
||
list.appendChild(el); | ||
} | ||
} | ||
|
||
generateItems(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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_html from './angular/example_component_html.md'; | ||
import angular_example_component_ts from './angular/example_component_ts.md'; | ||
|
||
<Playground | ||
version="8" | ||
code={{ | ||
javascript, | ||
react, | ||
vue, | ||
angular: { | ||
files: { | ||
'src/app/example.component.html': angular_example_component_html, | ||
'src/app/example.component.ts': angular_example_component_ts, | ||
}, | ||
}, | ||
}} | ||
src="usage/v8/fab/before-content/demo.html" | ||
size="medium" | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
```html | ||
<ion-content fixed-slot-placement="before"> | ||
<ion-fab horizontal="end" vertical="bottom" slot="fixed"> | ||
<ion-fab-button> | ||
<ion-icon name="add"></ion-icon> | ||
</ion-fab-button> | ||
</ion-fab> | ||
<ion-list></ion-list> | ||
<ion-infinite-scroll> | ||
<ion-infinite-scroll-content></ion-infinite-scroll-content> | ||
</ion-infinite-scroll> | ||
</ion-content> | ||
|
||
<script> | ||
const infiniteScroll = document.querySelector('ion-infinite-scroll'); | ||
infiniteScroll.addEventListener('ionInfinite', (event) => { | ||
setTimeout(() => { | ||
generateItems(); | ||
event.target.complete(); | ||
}, 500); | ||
}); | ||
const list = document.querySelector('ion-list'); | ||
function generateItems() { | ||
const count = list.childElementCount + 1; | ||
const total = count + 50; | ||
for (let i = count; i < total; i++) { | ||
const el = document.createElement('ion-item'); | ||
el.setAttribute('button', ''); | ||
const avatar = document.createElement('ion-avatar'); | ||
avatar.slot = 'start'; | ||
const img = document.createElement('img'); | ||
img.src = `https://picsum.photos/80/80?random=${i}`; | ||
img.alt = 'Avatar'; | ||
avatar.appendChild(img); | ||
el.appendChild(avatar); | ||
const text = document.createElement('ion-label'); | ||
text.innerText = `Item ${i}`; | ||
el.appendChild(text); | ||
list.appendChild(el); | ||
} | ||
} | ||
generateItems(); | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
```tsx | ||
import React, { useState, useEffect } from 'react'; | ||
import { | ||
IonAvatar, | ||
IonContent, | ||
IonFab, | ||
IonFabButton, | ||
IonIcon, | ||
IonInfiniteScroll, | ||
IonInfiniteScrollContent, | ||
IonItem, | ||
IonLabel, | ||
IonList, | ||
} from '@ionic/react'; | ||
|
||
function Example() { | ||
const [items, setItems] = useState<string[]>([]); | ||
|
||
const generateItems = () => { | ||
const newItems = []; | ||
for (let i = 0; i < 50; i++) { | ||
newItems.push(`Item ${1 + items.length + i}`); | ||
} | ||
setItems([...items, ...newItems]); | ||
}; | ||
|
||
useEffect(() => { | ||
generateItems(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return ( | ||
<IonContent fixedSlotPlacement="before"> | ||
<IonFab horizontal="end" vertical="bottom" slot="fixed"> | ||
<IonFabButton> | ||
<IonIcon name="add"></IonIcon> | ||
</IonFabButton> | ||
</IonFab> | ||
<IonList> | ||
{items.map((item, index) => ( | ||
<IonItem key={item} button> | ||
<IonAvatar slot="start"> | ||
<img src={'https://picsum.photos/80/80?random=' + index} alt="avatar" /> | ||
</IonAvatar> | ||
<IonLabel>{item}</IonLabel> | ||
</IonItem> | ||
))} | ||
</IonList> | ||
<IonInfiniteScroll | ||
onIonInfinite={(ev) => { | ||
generateItems(); | ||
setTimeout(() => ev.target.complete(), 500); | ||
}} | ||
> | ||
<IonInfiniteScrollContent></IonInfiniteScrollContent> | ||
</IonInfiniteScroll> | ||
</IonContent> | ||
); | ||
} | ||
export default Example; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
```html | ||
<template> | ||
<ion-content fixed-slot-placement="before"> | ||
<ion-fab horizontal="end" vertical="bottom" slot="fixed"> | ||
<ion-fab-button> | ||
<ion-icon name="add"></ion-icon> | ||
</ion-fab-button> | ||
</ion-fab> | ||
<ion-list> | ||
<ion-item v-for="(item, index) in items" button> | ||
<ion-avatar slot="start"> | ||
<img :src="'https://picsum.photos/80/80?random=' + index" alt="avatar" /> | ||
</ion-avatar> | ||
<ion-label>{{ item }}</ion-label> | ||
</ion-item> | ||
</ion-list> | ||
<ion-infinite-scroll @ionInfinite="ionInfinite"> | ||
<ion-infinite-scroll-content></ion-infinite-scroll-content> | ||
</ion-infinite-scroll> | ||
</ion-content> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { | ||
InfiniteScrollCustomEvent, | ||
IonAvatar, | ||
IonContent, | ||
IonFab, | ||
IonFabButton, | ||
IonIcon, | ||
IonImg, | ||
IonInfiniteScroll, | ||
IonInfiniteScrollContent, | ||
IonItem, | ||
IonLabel, | ||
IonList, | ||
} from '@ionic/vue'; | ||
import { defineComponent, reactive } from 'vue'; | ||
export default defineComponent({ | ||
components: { | ||
IonAvatar, | ||
IonContent, | ||
IonFab, | ||
IonFabButton, | ||
IonIcon, | ||
IonImg, | ||
IonInfiniteScroll, | ||
IonInfiniteScrollContent, | ||
IonItem, | ||
IonLabel, | ||
IonList, | ||
}, | ||
setup() { | ||
const items = reactive([]); | ||
const generateItems = () => { | ||
const count = items.length + 1; | ||
for (let i = 0; i < 50; i++) { | ||
items.push(`Item ${count + i}`); | ||
} | ||
}; | ||
const ionInfinite = (ev: InfiniteScrollCustomEvent) => { | ||
generateItems(); | ||
setTimeout(() => ev.target.complete(), 500); | ||
}; | ||
generateItems(); | ||
return { ionInfinite, items }; | ||
}, | ||
}); | ||
</script> | ||
``` |