Skip to content

docs(vue): update all script syntax to use setup #4242

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

Open
wants to merge 4 commits into
base: main
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 1 addition & 8 deletions _templates/playground/new/vue.md.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@ to: "<%= `static/usage/v${version}/${name}/${path}/vue.md` %>"
<<%= component %>></<%= component %>>
</template>

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

export default defineComponent({
components: {
<%= pascalComponent %>,
},
});
</script>
<% if (css){ -%>

Expand Down
2 changes: 0 additions & 2 deletions src/components/global/Playground/stackblitz.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ const openVueEditor = async (code: string, options?: EditorOptions) => {
options?.includeIonContent ? 'vue/App.withContent.vue' : 'vue/App.vue',
'vue/tsconfig.json',
'vue/tsconfig.node.json',
'vue/env.d.ts',
],
options.version
);
Expand All @@ -251,7 +250,6 @@ const openVueEditor = async (code: string, options?: EditorOptions) => {
'src/App.vue': defaultFiles[6],
'src/components/Example.vue': code,
[mainTs]: defaultFiles[5],
'src/env.d.ts': defaultFiles[9],
'src/theme/variables.css': defaultFiles[3],
'index.html': defaultFiles[2],
'vite.config.ts': defaultFiles[4],
Expand Down
14 changes: 3 additions & 11 deletions static/code/stackblitz/v8/vue/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
</ion-app>
</template>

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

import { defineComponent } from 'vue';

import Example from './components/Example.vue';

export default defineComponent({
name: 'App',
components: { IonApp, Example },
});
<script setup lang="ts">
import { IonApp } from '@ionic/vue';
import Example from './components/Example.vue';
</script>
14 changes: 3 additions & 11 deletions static/code/stackblitz/v8/vue/App.withContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
</ion-app>
</template>

<script lang="ts">
import { IonApp, IonContent } from '@ionic/vue';

import { defineComponent } from 'vue';

import Example from './components/Example.vue';

export default defineComponent({
name: 'App',
components: { IonApp, IonContent, Example },
});
<script setup lang="ts">
import { IonApp, IonContent } from '@ionic/vue';
import Example from './components/Example.vue';
</script>
8 changes: 0 additions & 8 deletions static/code/stackblitz/v8/vue/env.d.ts

This file was deleted.

13 changes: 2 additions & 11 deletions static/usage/v8/accordion/accessibility/animations/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@
</ion-accordion-group>
</template>

<script lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel, AccordionGroupCustomEvent } from '@ionic/vue';
import { defineComponent, ref } from 'vue';
export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
<script setup lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
</script>
```
12 changes: 1 addition & 11 deletions static/usage/v8/accordion/basic/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@
</ion-accordion-group>
</template>

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

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
</script>
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,8 @@
</ion-accordion-group>
</template>

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

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
</script>

<style scoped>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@
</ion-accordion-group>
</template>

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

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
</script>
```
15 changes: 1 addition & 14 deletions static/usage/v8/accordion/customization/icons/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,8 @@
</ion-accordion-group>
</template>

<script lang="ts">
<script setup lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
import { caretDownCircle } from 'ionicons/icons';
import { defineComponent } from 'vue';

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
setup() {
return { caretDownCircle };
},
});
</script>
```
15 changes: 1 addition & 14 deletions static/usage/v8/accordion/customization/theming/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,9 @@
</ion-accordion-group>
</template>

<script lang="ts">
<script setup lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
import { caretDownCircle } from 'ionicons/icons';
import { defineComponent } from 'vue';

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
setup() {
return { caretDownCircle };
},
});
</script>

<style>
Expand Down
13 changes: 2 additions & 11 deletions static/usage/v8/accordion/disable/group/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@
</ion-accordion-group>
</template>

<script lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel, AccordionGroupCustomEvent } from '@ionic/vue';
import { defineComponent, ref } from 'vue';
export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
<script setup lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
</script>
```
13 changes: 2 additions & 11 deletions static/usage/v8/accordion/disable/individual/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@
</ion-accordion-group>
</template>

<script lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel, AccordionGroupCustomEvent } from '@ionic/vue';
import { defineComponent, ref } from 'vue';
export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
<script setup lang="ts">
import { IonAccordion, IonAccordionGroup, IonItem, IonLabel } from '@ionic/vue';
</script>
```
33 changes: 9 additions & 24 deletions static/usage/v8/accordion/listen-changes/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,17 @@
</ion-accordion-group>
</template>

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

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
setup() {
const values = ['first', 'second', 'third'];
const accordionGroupChange = (event: AccordionGroupCustomEvent) => {
const collapsedItems = values.filter((value) => value !== event.detail.value);
const selectedValue = event.detail.value;
const values = ['first', 'second', 'third'];
const accordionGroupChange = (event: AccordionGroupCustomEvent) => {
const collapsedItems = values.filter((value) => value !== event.detail.value);
const selectedValue = event.detail.value;

console.log(
`Expanded: ${selectedValue === undefined ? 'None' : event.detail.value} | Collapsed: ${collapsedItems.join(
', '
)}`
);
};

return { accordionGroupChange };
},
});
console.log(
`Expanded: ${selectedValue === undefined ? 'None' : event.detail.value} | Collapsed: ${collapsedItems.join(', ')}`
);
};
</script>
```
12 changes: 1 addition & 11 deletions static/usage/v8/accordion/multiple/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@
</ion-accordion-group>
</template>

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

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
</script>
```
12 changes: 1 addition & 11 deletions static/usage/v8/accordion/readonly/group/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@
</ion-accordion-group>
</template>

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

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
</script>
```
12 changes: 1 addition & 11 deletions static/usage/v8/accordion/readonly/individual/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@
</ion-accordion-group>
</template>

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

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonItem,
IonLabel,
},
});
</script>
```
40 changes: 14 additions & 26 deletions static/usage/v8/accordion/toggle/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,23 @@
<ion-button @click="toggleAccordion()">Toggle Second Accordion</ion-button>
</template>

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

export default defineComponent({
components: {
IonAccordion,
IonAccordionGroup,
IonButton,
IonItem,
IonLabel,
},
setup() {
const accordionGroup = ref(null);
const toggleAccordion = () => {
if (!accordionGroup.value) {
return;
}
const nativeEl = accordionGroup.value.$el;
const accordionGroup = ref(null);

if (nativeEl.value === 'second') {
nativeEl.value = undefined;
} else {
nativeEl.value = 'second';
}
};
const toggleAccordion = () => {
if (!accordionGroup.value) {
return;
}
const nativeEl = accordionGroup.value.$el;

return { accordionGroup, toggleAccordion };
},
});
if (nativeEl.value === 'second') {
nativeEl.value = undefined;
} else {
nativeEl.value = 'second';
}
};
</script>
```
Loading
Loading