-
Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(toast): add playgrounds #2516
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7e58d81
docs(toast): remove phone demo, inline TOC, and usage
1d01bd0
docs(toast): add playgrounds
f5de766
docs(toast): make styling example more realistic
260a942
docs(toast): add headers to toast demos
dd0e189
Update static/usage/toast/presenting/controller/vue.md
averyjohnston 3e5eae1
Merge branch 'FW-1258' of https://github.com/ionic-team/ionic-docs in…
c03922e
Update static/usage/toast/icon/react.md
averyjohnston c8e0edc
docs(toast): use controller for JS examples
38ac4f2
Merge branch 'FW-1258' of https://github.com/ionic-team/ionic-docs in…
928dc66
docs(toast): rename styling to theming
866c811
fix(): fix broken link
7736be5
docs(toast): make theming text easier to read
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,5 @@ | ||
```html | ||
<ion-button (click)="presentToast()">Click Me</ion-button> | ||
<p>{{ handlerMessage }}</p> | ||
<p>{{ roleMessage }}</p> | ||
``` |
This file contains hidden or 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,39 @@ | ||
```ts | ||
import { Component } from '@angular/core'; | ||
import { ToastController } from '@ionic/angular'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: 'example.component.html', | ||
}) | ||
export class ExampleComponent { | ||
handlerMessage = ''; | ||
roleMessage = ''; | ||
|
||
constructor(private toastController: ToastController) {} | ||
|
||
async presentToast() { | ||
const toast = await this.toastController.create({ | ||
message: 'Hello World!', | ||
duration: 3000, | ||
buttons: [ | ||
{ | ||
text: 'More Info', | ||
role: 'info', | ||
handler: () => { this.handlerMessage = 'More Info clicked'; } | ||
}, | ||
{ | ||
text: 'Dismiss', | ||
role: 'cancel', | ||
handler: () => { this.handlerMessage = 'Dismiss clicked'; } | ||
} | ||
] | ||
}); | ||
|
||
await toast.present(); | ||
|
||
const { role } = await toast.onDidDismiss(); | ||
this.roleMessage = `Dismissed with role: ${role}`; | ||
} | ||
} | ||
``` |
This file contains hidden or 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 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Toast</title> | ||
<link rel="stylesheet" href="../../common.css" /> | ||
<script src="../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@6/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@6/css/ionic.bundle.css" /> | ||
|
||
<style> | ||
.container { | ||
flex-direction: column; | ||
} | ||
|
||
.container p { | ||
margin-bottom: 0; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>Toast</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content> | ||
<div class="container"> | ||
<ion-button onclick="presentToast()">Click Me</ion-button> | ||
<p id="handlerResult"></p> | ||
<p id="roleResult"></p> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
|
||
<script type="module"> | ||
import { toastController } from 'https://cdn.jsdelivr.net/npm/@ionic/core@6/dist/ionic/index.esm.js'; | ||
window.toastController = toastController; | ||
</script> | ||
|
||
<script> | ||
const handlerOutput = document.querySelector('#handlerResult'); | ||
const roleOutput = document.querySelector('#roleResult'); | ||
|
||
async function presentToast() { | ||
const toast = await toastController.create({ | ||
message: 'Hello World!', | ||
duration: 3000, | ||
buttons: [ | ||
{ | ||
text: 'More Info', | ||
role: 'info', | ||
handler: () => { handlerOutput.innerText = 'More Info clicked'; } | ||
}, | ||
{ | ||
text: 'Dismiss', | ||
role: 'cancel', | ||
handler: () => { handlerOutput.innerText = 'Dismiss clicked'; } | ||
} | ||
] | ||
}); | ||
|
||
await toast.present(); | ||
|
||
const { role } = await toast.onDidDismiss(); | ||
roleOutput.innerText = `Dismissed with role: ${role}`; | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains hidden or 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,24 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript from './javascript.md'; | ||
import react from './react.md'; | ||
import vue from './vue.md'; | ||
|
||
import angularHTML from './angular/angular_html.md'; | ||
import angularTS from './angular/angular_ts.md'; | ||
|
||
<Playground | ||
devicePreview | ||
code={{ | ||
javascript, | ||
react, | ||
vue, | ||
angular: { | ||
files: { | ||
'src/app/example.component.html': angularHTML, | ||
'src/app/example.component.ts': angularTS, | ||
}, | ||
}, | ||
}} | ||
src="usage/toast/buttons/demo.html" | ||
/> |
This file contains hidden or 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,34 @@ | ||
```html | ||
<ion-button onclick="presentToast()">Click Me</ion-button> | ||
<p id="handlerResult"></p> | ||
<p id="roleResult"></p> | ||
|
||
<script> | ||
const handlerOutput = document.querySelector('#handlerResult'); | ||
const roleOutput = document.querySelector('#roleResult'); | ||
|
||
async function presentToast() { | ||
const toast = await toastController.create({ | ||
message: 'Hello World!', | ||
duration: 3000, | ||
buttons: [ | ||
{ | ||
text: 'More Info', | ||
role: 'info', | ||
handler: () => { handlerOutput.innerText = 'More Info clicked'; } | ||
}, | ||
{ | ||
text: 'Dismiss', | ||
role: 'cancel', | ||
handler: () => { handlerOutput.innerText = 'Dismiss clicked'; } | ||
} | ||
] | ||
}); | ||
|
||
await toast.present(); | ||
|
||
const { role } = await toast.onDidDismiss(); | ||
roleOutput.innerText = `Dismissed with role: ${role}`; | ||
} | ||
</script> | ||
``` |
This file contains hidden or 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,41 @@ | ||
```tsx | ||
import React, { useState } from 'react'; | ||
import { IonButton, useIonToast } from '@ionic/react'; | ||
|
||
function Example() { | ||
const [presentToast] = useIonToast(); | ||
const [handlerMessage, setHandlerMessage] = useState(''); | ||
const [roleMessage, setRoleMessage] = useState(''); | ||
|
||
return ( | ||
<> | ||
<IonButton | ||
onClick={() => { | ||
presentToast({ | ||
message: 'Hello World!', | ||
duration: 3000, | ||
onDidDismiss: (e: CustomEvent) => setRoleMessage(`Dismissed with role: ${e.detail.role}`), | ||
buttons: [ | ||
{ | ||
text: 'More Info', | ||
role: 'info', | ||
handler: () => { setHandlerMessage('More Info clicked'); } | ||
}, | ||
{ | ||
text: 'Dismiss', | ||
role: 'cancel', | ||
handler: () => { setHandlerMessage('Dismiss clicked'); } | ||
} | ||
] | ||
}) | ||
}} | ||
> | ||
Click Me | ||
</IonButton> | ||
<p>{handlerMessage}</p> | ||
<p>{roleMessage}</p> | ||
</> | ||
); | ||
} | ||
export default Example; | ||
``` |
This file contains hidden or 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,46 @@ | ||
```html | ||
<template> | ||
<ion-button @click="presentToast">Click Me</ion-button> | ||
<p>{{ handlerMessage }}</p> | ||
<p>{{ roleMessage }}</p> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { IonButton, toastController } from '@ionic/vue'; | ||
|
||
export default { | ||
components: { IonButton }, | ||
data() { | ||
return { | ||
handlerMessage: '', | ||
roleMessage: '', | ||
}; | ||
}, | ||
methods: { | ||
async presentToast() { | ||
const toast = await toastController.create({ | ||
message: 'Hello World!', | ||
duration: 3000, | ||
buttons: [ | ||
{ | ||
text: 'More Info', | ||
role: 'info', | ||
handler: () => { this.handlerMessage = 'More Info clicked'; } | ||
}, | ||
{ | ||
text: 'Dismiss', | ||
role: 'cancel', | ||
handler: () => { this.handlerMessage = 'Dismiss clicked'; } | ||
} | ||
] | ||
}); | ||
|
||
await toast.present(); | ||
|
||
const { role } = await toast.onDidDismiss(); | ||
this.roleMessage = `Dismissed with role: ${role}`; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
``` |
This file contains hidden or 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,3 @@ | ||
```html | ||
<ion-button (click)="presentToast()">Click Me</ion-button> | ||
``` |
This file contains hidden or 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,22 @@ | ||
```ts | ||
import { Component } from '@angular/core'; | ||
import { ToastController } from '@ionic/angular'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: 'example.component.html', | ||
}) | ||
export class ExampleComponent { | ||
constructor(private toastController: ToastController) {} | ||
|
||
async presentToast() { | ||
const toast = await this.toastController.create({ | ||
message: 'Hello World!', | ||
duration: 1500, | ||
icon: 'globe' | ||
}); | ||
|
||
await toast.present(); | ||
} | ||
} | ||
``` |
This file contains hidden or 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,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Toast</title> | ||
<link rel="stylesheet" href="../../common.css" /> | ||
<script src="../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@6/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@6/css/ionic.bundle.css" /> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>Toast</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content> | ||
<div class="container"> | ||
<ion-button onclick="presentToast()">Click Me</ion-button> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
|
||
<script type="module"> | ||
import { toastController } from 'https://cdn.jsdelivr.net/npm/@ionic/core@6/dist/ionic/index.esm.js'; | ||
window.toastController = toastController; | ||
</script> | ||
|
||
<script> | ||
async function presentToast() { | ||
const toast = await this.toastController.create({ | ||
message: 'Hello World!', | ||
duration: 1500, | ||
icon: 'globe' | ||
}); | ||
|
||
await toast.present(); | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains hidden or 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,24 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript from './javascript.md'; | ||
import react from './react.md'; | ||
import vue from './vue.md'; | ||
|
||
import angularHTML from './angular/angular_html.md'; | ||
import angularTS from './angular/angular_ts.md'; | ||
|
||
<Playground | ||
devicePreview | ||
code={{ | ||
javascript, | ||
react, | ||
vue, | ||
angular: { | ||
files: { | ||
'src/app/example.component.html': angularHTML, | ||
'src/app/example.component.ts': angularTS, | ||
}, | ||
}, | ||
}} | ||
src="usage/toast/icon/demo.html" | ||
/> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.