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(vue): streamline usage examples with script setup syntax #2956

Merged
merged 25 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8a59938
chore(docs): streamline demo using script setup syntax
treighmawaka May 10, 2023
348b893
chore(docs): streamline demo using script setup syntax
treighmawaka May 10, 2023
a475b88
chore(docs): streamline demo using script setup syntax
treighmawaka May 10, 2023
3d34995
chore(docs): streamline demo using script setup syntax
treighmawaka May 10, 2023
2dc86ec
docs(alert): streamline vue usage example
treighmawaka May 10, 2023
91f33ac
docs(alert): streamline vue usage example
treighmawaka May 10, 2023
d7923c7
docs(alert): streamline vue usage example
treighmawaka May 10, 2023
6334fb4
docs(alert): streamline vue usage example
treighmawaka May 10, 2023
68d56df
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
7c3b6d1
docs(alert): streamline vue usage example
treighmawaka May 10, 2023
69f3632
docs(alert): streamline vue usage example
treighmawaka May 10, 2023
2930d51
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
575e3f6
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
466ffac
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
9ed57c3
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
56f2536
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
f61fcc8
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
a238e2d
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
75fc055
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
4a7fb42
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
efa1461
docs(modal): streamline vue usage example
treighmawaka May 10, 2023
057b9fb
docs(): streamline vue usage example
treighmawaka May 10, 2023
140ad6a
Merge remote-tracking branch 'origin/main'
mapsandapps Aug 4, 2023
215bfcc
Fix functionality of a couple playgrounds
mapsandapps Aug 4, 2023
7a33db8
Lint
mapsandapps Aug 4, 2023
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
54 changes: 21 additions & 33 deletions static/usage/v7/alert/buttons/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,32 @@
<p>{{ roleMessage }}</p>
</template>

<script lang="ts">
<script lang="ts" setup>
import { ref } from 'vue';
import { IonAlert, IonButton } from '@ionic/vue';

export default {
components: { IonAlert, IonButton },
setup() {
const handlerMessage = ref('');
const roleMessage = ref('');
const handlerMessage = ref('');
const roleMessage = ref('');

const alertButtons = [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
handlerMessage.value = 'Alert canceled';
},
},
{
text: 'OK',
role: 'confirm',
handler: () => {
handlerMessage.value = 'Alert confirmed';
},
},
];

const setResult = (ev: CustomEvent) => {
roleMessage.value = `Dismissed with role: ${ev.detail.role}`;
};

return {
handlerMessage,
roleMessage,
alertButtons,
setResult,
};
const alertButtons = [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
handlerMessage.value = 'Alert canceled';
},
},
{
text: 'OK',
role: 'confirm',
handler: () => {
handlerMessage.value = 'Alert confirmed';
},
},
];

const setResult = (ev: CustomEvent) => {
roleMessage.value = `Dismissed with role: ${ev.detail.role}`;
};
</script>
```
27 changes: 10 additions & 17 deletions static/usage/v7/alert/customization/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@
<ion-alert trigger="present-alert" class="custom-alert" header="Are you sure?" :buttons="alertButtons"></ion-alert>
</template>

<script lang="ts">
<script lang="ts" setup>
import { IonAlert, IonButton } from '@ionic/vue';

export default {
components: { IonAlert, IonButton },
setup() {
const alertButtons = [
{
text: 'No',
cssClass: 'alert-button-cancel',
},
{
text: 'Yes',
cssClass: 'alert-button-confirm',
},
];

return { alertButtons };
const alertButtons = [
{
text: 'No',
cssClass: 'alert-button-cancel',
},
};
{
text: 'Yes',
cssClass: 'alert-button-confirm',
},
];
</script>

<style>
Expand Down
43 changes: 18 additions & 25 deletions static/usage/v7/alert/inputs/radios/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,26 @@
></ion-alert>
</template>

<script lang="ts">
<script lang="ts" setup>
import { IonAlert, IonButton } from '@ionic/vue';

export default {
components: { IonAlert, IonButton },
setup() {
const alertButtons = ['OK'];
const alertInputs = [
{
label: 'Red',
type: 'radio',
value: 'red',
},
{
label: 'Blue',
type: 'radio',
value: 'blue',
},
{
label: 'Green',
type: 'radio',
value: 'green',
},
];

return { alertButtons, alertInputs };
const alertButtons = ['OK'];
const alertInputs = [
{
label: 'Red',
type: 'radio',
value: 'red',
},
{
label: 'Blue',
type: 'radio',
value: 'blue',
},
{
label: 'Green',
type: 'radio',
value: 'green',
},
};
];
</script>
```
51 changes: 22 additions & 29 deletions static/usage/v7/alert/inputs/text-inputs/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,30 @@
></ion-alert>
</template>

<script lang="ts">
<script lang="ts" setup>
import { IonAlert, IonButton } from '@ionic/vue';

export default {
components: { IonAlert, IonButton },
setup() {
const alertButtons = ['OK'];
const alertInputs = [
{
placeholder: 'Name',
},
{
placeholder: 'Nickname (max 8 characters)',
attributes: {
maxlength: 8,
},
},
{
type: 'number',
placeholder: 'Age',
min: 1,
max: 100,
},
{
type: 'textarea',
placeholder: 'A little about yourself',
},
];

return { alertButtons, alertInputs };
const alertButtons = ['OK'];
const alertInputs = [
{
placeholder: 'Name',
},
{
placeholder: 'Nickname (max 8 characters)',
attributes: {
maxlength: 8,
},
},
{
type: 'number',
placeholder: 'Age',
min: 1,
max: 100,
},
{
type: 'textarea',
placeholder: 'A little about yourself',
},
};
];
</script>
```
25 changes: 9 additions & 16 deletions static/usage/v7/alert/presenting/controller/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,18 @@
<ion-button @click="presentAlert">Click Me</ion-button>
</template>

<script lang="ts">
<script lang="ts" setup>
import { IonButton, alertController } from '@ionic/vue';

export default {
components: { IonButton },
setup() {
const presentAlert = async () => {
const alert = await alertController.create({
header: 'Alert',
subHeader: 'Important message',
message: 'This is an alert!',
buttons: ['OK'],
});
const presentAlert = async () => {
const alert = await alertController.create({
header: 'Alert',
subHeader: 'Important message',
message: 'This is an alert!',
buttons: ['OK'],
});

await alert.present();
};

return { presentAlert };
},
await alert.present();
};
</script>
```
17 changes: 5 additions & 12 deletions static/usage/v7/alert/presenting/isOpen/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,15 @@
></ion-alert>
</template>

<script lang="ts">
<script lang="ts" setup>
import { ref } from 'vue';
import { IonAlert, IonButton } from '@ionic/vue';

export default {
components: { IonAlert, IonButton },
setup() {
const isOpen = ref(false);
const alertButtons = ['OK'];
const isOpen = ref(false);
const alertButtons = ['OK'];

const setOpen = (state: boolean) => {
isOpen.value = state;
};

return { isOpen, alertButtons, setOpen };
},
const setOpen = (state: boolean) => {
isOpen.value = state;
};
</script>
```
11 changes: 2 additions & 9 deletions static/usage/v7/alert/presenting/trigger/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@
></ion-alert>
</template>

<script lang="ts">
<script lang="ts" setup>
import { IonAlert, IonButton } from '@ionic/vue';

export default {
components: { IonAlert, IonButton },
setup() {
const alertButtons = ['OK'];

return { alertButtons };
},
};
const alertButtons = ['OK'];
</script>
```
14 changes: 4 additions & 10 deletions static/usage/v7/input/counter/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@
></ion-input>
</template>

<script lang="ts">
<script lang="ts" setup>
import { IonInput } from '@ionic/vue';
import { defineComponent } from 'vue';

export default defineComponent({
components: { IonInput },
methods: {
customFormatter(inputLength, maxLength) {
return `${maxLength - inputLength} characters remaining`;
},
},
});
const customFormatter = (inputLength, maxLength) => {
return `${maxLength - inputLength} characters remaining`;
};
</script>
```
34 changes: 14 additions & 20 deletions static/usage/v7/modal/controller/vue/example_vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,25 @@
</ion-page>
</template>

<script lang="ts">
<script lang="ts" setup>
import { IonButton, IonContent, IonPage, IonHeader, IonToolbar, IonTitle, modalController } from '@ionic/vue';
import Modal from './Modal.vue';
import { ref } from 'vue';

export default {
components: { IonButton, IonContent, IonPage, IonHeader, IonToolbar, IonTitle },
data() {
return {
message: 'This modal example uses the modalController to present and dismiss modals.',
};
},
methods: {
async openModal() {
const modal = await modalController.create({
component: Modal,
});
modal.present();
const message = ref('This modal example uses the modalController to present and dismiss modals.');

const { data, role } = await modal.onWillDismiss();
const openModal = async () => {
const modal = await modalController.create({
component: Modal,
});

if (role === 'confirm') {
this.message = `Hello, ${data}!`;
}
},
},
modal.present();

const { data, role } = await modal.onWillDismiss();

if (role === 'confirm') {
message.value = `Hello, ${data}!`;
}
};
</script>
```
19 changes: 5 additions & 14 deletions static/usage/v7/modal/controller/vue/modal_vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ion-content>
</template>

<script lang="ts">
<script lang="ts" setup>
import {
IonContent,
IonHeader,
Expand All @@ -30,19 +30,10 @@
IonInput,
modalController,
} from '@ionic/vue';
import { defineComponent } from 'vue';
import { defineComponent, ref } from 'vue';
const name = ref();

export default defineComponent({
name: 'Modal',
components: { IonContent, IonHeader, IonTitle, IonToolbar, IonButtons, IonButton, IonItem, IonInput },
methods: {
cancel() {
return modalController.dismiss(null, 'cancel');
},
confirm() {
return modalController.dismiss(this.name, 'confirm');
},
},
});
const cancel = () => modalController.dismiss(null, 'cancel');
const confirm = () => modalController.dismiss(name.value, 'confirm');
</script>
```
Loading