Skip to content
Merged
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ Ionic's documentation is built using [Docusaurus](https://docusaurus.io/). The c
- `components/` - components used across the site
- `global/` - components used globally
- `page/` - components used on a single page or in a limited scope
- `styles/` - global styles and variables
- `components/` - styles split out into the components they target
- `css/` - global styles, refer to its [README](src/css/README.md)
- `theme/` - overrides for the markup Docusaurus's theme renders
- `theme/` - Docusaurus theme components that have been swizzled
- `static/`
- `code/` - StackBlitz project templates used by the playgrounds
Expand Down
8 changes: 4 additions & 4 deletions _templates/playground/new/vue.md.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ to: "<%= `static/usage/v${version}/${name}/${path}/vue.md` %>"
</template>

<script setup lang="ts">
import { <%= pascalComponent %> } from '@ionic/vue';
import { <%= pascalComponent %> } from '@ionic/vue';
</script>
<% if (css){ -%>

<style scoped>
<%= component %> {
/* styles go here */
}
<%= component %> {
/* styles go here */
}
</style>
<% } -%>
```
4 changes: 2 additions & 2 deletions docs/api/item.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export default Example;

In Vue, use the `router-link` attribute on `ion-item`. The `router-direction` and `router-animation` attributes are also available for controlling the transition.

```html
```vue
<template>
<ion-list>
<ion-item router-link="/home">
Expand All @@ -376,7 +376,7 @@ In Vue, use the `router-link` attribute on `ion-item`. The `router-direction` an
</template>

<script setup lang="ts">
import { IonItem, IonLabel, IonList } from '@ionic/vue';
import { IonItem, IonLabel, IonList } from '@ionic/vue';
</script>
```

Expand Down
90 changes: 45 additions & 45 deletions docs/api/route.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const confirmDiscardChanges = async () => {

<TabItem value="vue">

```html
```vue
<template>
<ion-router>
<ion-route url="/home" component="page-home"></ion-route>
Expand All @@ -193,50 +193,50 @@ const confirmDiscardChanges = async () => {
</template>

<script>
import { alertController } from '@ionic/vue';

const isLoggedInGuard = async () => {
const isLoggedIn = await UserData.isLoggedIn(); // Replace this with actual login validation

if (isLoggedIn) {
return true;
} else {
return { redirect: '/login' }; // If a user is not logged in, they will be redirected to the /login page
}
};

const hasUnsavedDataGuard = async () => {
const hasUnsavedData = await checkData(); // Replace this with actual validation

if (hasUnsavedData) {
return await confirmDiscardChanges();
} else {
return true;
}
};

const confirmDiscardChanges = async () => {
const alert = await alertController.create({
header: 'Discard Unsaved Changes?',
message: 'Are you sure you want to leave? Any unsaved changed will be lost.',
buttons: [
{
text: 'Cancel',
role: 'Cancel',
},
{
text: 'Discard',
role: 'destructive',
},
],
});

await alert.present();

const { role } = await alert.onDidDismiss();

return role === 'Cancel' ? false : true;
};
import { alertController } from '@ionic/vue';

const isLoggedInGuard = async () => {
const isLoggedIn = await UserData.isLoggedIn(); // Replace this with actual login validation

if (isLoggedIn) {
return true;
} else {
return { redirect: '/login' }; // If a user is not logged in, they will be redirected to the /login page
}
};

const hasUnsavedDataGuard = async () => {
const hasUnsavedData = await checkData(); // Replace this with actual validation

if (hasUnsavedData) {
return await confirmDiscardChanges();
} else {
return true;
}
};

const confirmDiscardChanges = async () => {
const alert = await alertController.create({
header: 'Discard Unsaved Changes?',
message: 'Are you sure you want to leave? Any unsaved changed will be lost.',
buttons: [
{
text: 'Cancel',
role: 'Cancel',
},
{
text: 'Discard',
role: 'destructive',
},
],
});

await alert.present();

const { role } = await alert.onDidDismiss();

return role === 'Cancel' ? false : true;
};
</script>
```

Expand Down
6 changes: 3 additions & 3 deletions docs/api/tab-bar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const TabBarExample: React.FC = () => (

<TabItem value="vue">

```html
```vue
<template>
<ion-tabs>
<!-- Tab bar -->
Expand All @@ -124,8 +124,8 @@ export const TabBarExample: React.FC = () => (
</template>

<script setup lang="ts">
import { IonIcon, IonTabBar, IonTabButton, IonTabs } from '@ionic/vue';
import { call, person, settings } from 'ionicons/icons';
import { IonIcon, IonTabBar, IonTabButton, IonTabs } from '@ionic/vue';
import { call, person, settings } from 'ionicons/icons';
</script>
```

Expand Down
6 changes: 3 additions & 3 deletions docs/api/tab-button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const TabButtonExample: React.FC = () => (

<TabItem value="vue">

```html
```vue
<template>
<ion-tabs>
<!-- Tab bar -->
Expand Down Expand Up @@ -174,8 +174,8 @@ export const TabButtonExample: React.FC = () => (
</template>

<script setup lang="ts">
import { IonIcon, IonLabel, IonTabBar, IonTabButton, IonTabs } from '@ionic/vue';
import { calendar, informationCircle, map, personCircle } from 'ionicons/icons';
import { IonIcon, IonLabel, IonTabBar, IonTabButton, IonTabs } from '@ionic/vue';
import { calendar, informationCircle, map, personCircle } from 'ionicons/icons';
</script>
```

Expand Down
18 changes: 9 additions & 9 deletions docs/developing/config/_per-component.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,20 @@ createApp(App).use(IonicVue, {

**Recommended**

```html
```vue
<template>
<ion-back-button [text]="backButtonText"></ion-back-button>
<ion-back-button :text="backButtonText"></ion-back-button>
</template>

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

/**
* The back button text can be updated
* anytime the locale changes.
*/
const backButtonText = ref('Go Back');
/**
* The back button text can be updated
* anytime the locale changes.
*/
const backButtonText = ref('Go Back');
</script>
```

Expand Down
36 changes: 18 additions & 18 deletions docs/developing/managing-focus.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,25 @@ export default Home;
</TabItem>
<TabItem value="vue">

```html
```vue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since both of these blocks sit inside the mdx-code-block wrapper, prettier doesn't reach them, so the <script setup> bodies here and in the Overlays sample further down are still indented two spaces. They're the last Vue samples on the site like that, so I think they'll just need unindenting by hand.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 59d585b.

<template>
<ion-page>
<ion-input ref="input" label="setFocus" label-placement="floating"></ion-input>
</ion-page>
</template>

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

const input = ref();
onIonViewDidEnter(() => {
requestAnimationFrame(() => {
// requestAnimationFrame is currently required due to:
// https://github.com/ionic-team/ionic-framework/issues/24434
input.value.$el.setFocus();
});
import { IonInput, IonPage, onIonViewDidEnter } from '@ionic/vue';
import { ref } from 'vue';

const input = ref();
onIonViewDidEnter(() => {
requestAnimationFrame(() => {
// requestAnimationFrame is currently required due to:
// https://github.com/ionic-team/ionic-framework/issues/24434
input.value.$el.setFocus();
});
});
</script>
```

Expand Down Expand Up @@ -215,22 +215,22 @@ export default Home;
</TabItem>
<TabItem value="vue">

```html
```vue
<template>
<ion-modal @didPresent="onDidPresent">
<ion-input ref="input"></ion-input>
</ion-modal>
</template>

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

const input = ref();
const input = ref();

function onDidPresent() {
input.value.$el.setFocus();
}
function onDidPresent() {
input.value.$el.setFocus();
}
</script>
```

Expand Down
4 changes: 2 additions & 2 deletions docs/native-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ export class CameraComponent{
</TabItem>
<TabItem value="vue">

```typescript
```vue

<template>
...
</template>

<script setup lang="typescript">
<script setup lang="ts">
import { ref } from 'vue';
import { Camera, CameraResultType } from '@capacitor/camera';
const imageSrc = ref<string | undefined>('');
Expand Down
12 changes: 6 additions & 6 deletions docs/updating/6-0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Refer to the [Testing section below](#testing) for more information.

**Before**

```html
```vue
<ion-modal
:is-open="modalOpenRef"
@onWillPresent="onModalWillPresentHandler"
Expand All @@ -178,7 +178,7 @@ Refer to the [Testing section below](#testing) for more information.

**After**

```html
```vue
<ion-modal
:is-open="modalOpenRef"
@willPresent="onModalWillPresentHandler"
Expand All @@ -200,26 +200,26 @@ This applies to `ion-action-sheet`, `ion-alert`, `ion-loading`, `ion-modal`, `io

**Before**

```html
```vue
<ion-tabs>
<ion-tab-bar slot="bottom"> ... </ion-tab-bar>
</ion-tabs>

<script setup lang="ts">
import { IonTabs, IonTabBar } from '@ionic/vue';
import { IonTabs, IonTabBar } from '@ionic/vue';
</script>
```

**After**

```html
```vue
<ion-tabs>
<ion-router-outlet></ion-router-outlet>
<ion-tab-bar slot="bottom"> ... </ion-tab-bar>
</ion-tabs>

<script setup lang="ts">
import { IonTabs, IonTabBar, IonRouterOutlet } from '@ionic/vue';
import { IonTabs, IonTabBar, IonRouterOutlet } from '@ionic/vue';
</script>
```

Expand Down
4 changes: 2 additions & 2 deletions docs/vue/navigation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const routes: RouteRecordRaw[] = [

Say we start on the `home` route, and we want to add a button that takes us to the `detail` route. We can do this using the following HTML to navigate to the `detail` route:

```html
```vue
<ion-button router-link="/detail">Go to detail</ion-button>
```

Expand Down Expand Up @@ -128,7 +128,7 @@ The `router-direction` attribute accepts values of `"forward"`, `"back"`, or `"r

The `router-animation` attribute accepts an `AnimationBuilder` function and is used to provide a custom page transition that is only used when clicking the component it is provided on. The `AnimationBuilder` type is a function that returns an Ionic Animation instance. Refer to the [Animations documentation](../utilities/animations.mdx) for more information on using animations in Ionic Vue.

```html
```vue
<ion-button router-link="/page2" router-direction="back" :router-animation="myAnimation">Click Me</ion-button>
```

Expand Down
4 changes: 2 additions & 2 deletions static/usage/v9/accordion/accessibility/animations/vue.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
```html
```vue
<template>
<ion-accordion-group :animated="false">
<ion-accordion value="first">
Expand All @@ -23,6 +23,6 @@
</template>

<script setup lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
</script>
```
4 changes: 2 additions & 2 deletions static/usage/v9/accordion/basic/vue.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
```html
```vue
<template>
<ion-accordion-group>
<ion-accordion value="first">
Expand All @@ -23,6 +23,6 @@
</template>

<script setup lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
</script>
```
Loading
Loading