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

refactor(playgrounds): use Vue's script setup syntax #3328

Draft
wants to merge 58 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
71ddb11
accordion
mapsandapps Sep 1, 2023
e139adf
action-sheet
mapsandapps Sep 1, 2023
f7d213c
Update playground template
mapsandapps Sep 7, 2023
4367cfa
backdrop
mapsandapps Dec 14, 2023
3a6db20
badge
mapsandapps Dec 14, 2023
3f52485
breadcrumbs
mapsandapps Dec 14, 2023
6669972
button
mapsandapps Dec 14, 2023
4b14c62
buttons
mapsandapps Dec 14, 2023
ac9c1d9
card
mapsandapps Dec 14, 2023
4674420
checkbox
mapsandapps Dec 14, 2023
0e91ee3
chip
mapsandapps Dec 14, 2023
5be175e
content
mapsandapps Dec 14, 2023
7b5a625
datetime
mapsandapps Dec 14, 2023
ae73d34
fab
mapsandapps Dec 14, 2023
ac34cd2
footer
mapsandapps Dec 14, 2023
c1e79b7
grid
mapsandapps Dec 14, 2023
b59188f
header
mapsandapps Dec 14, 2023
e2216af
icon
mapsandapps Dec 14, 2023
0c959ed
img
mapsandapps Dec 14, 2023
bc71b76
infinite-scroll
mapsandapps Dec 14, 2023
0e75efe
input
mapsandapps Dec 14, 2023
11004f4
item
mapsandapps Dec 15, 2023
00ca0cb
item-divider
mapsandapps Dec 15, 2023
c0dad46
item-group
mapsandapps Dec 15, 2023
7cb8ef8
label
mapsandapps Dec 15, 2023
78d5eec
list
mapsandapps Dec 15, 2023
980f6c5
list-header
mapsandapps Dec 15, 2023
f630b75
loading
mapsandapps Dec 15, 2023
ab31953
menu
mapsandapps Dec 15, 2023
037efca
nav: nav-link
mapsandapps Dec 15, 2023
ae5b161
note
mapsandapps Dec 15, 2023
e551846
picker
mapsandapps Dec 15, 2023
311bf82
popover
mapsandapps Dec 15, 2023
72bc39c
radio
mapsandapps Dec 15, 2023
ca8646a
range
mapsandapps Dec 15, 2023
b817e5d
refresher
mapsandapps Dec 15, 2023
d60f494
reorder
mapsandapps Dec 15, 2023
385f4b5
ripple-effect
mapsandapps Dec 15, 2023
2b91117
searchbar
mapsandapps Dec 15, 2023
df2e759
segment
mapsandapps Dec 15, 2023
d45f6ae
segment-button
mapsandapps Dec 15, 2023
c37baab
select
mapsandapps Dec 15, 2023
585691c
skeleton-text
mapsandapps Dec 15, 2023
73d1a51
spinner
mapsandapps Dec 15, 2023
b20a8a7
split-pane
mapsandapps Dec 15, 2023
369506e
tabs
mapsandapps Dec 15, 2023
6ccfaad
text
mapsandapps Dec 15, 2023
27b4b12
textarea
mapsandapps Dec 15, 2023
d2f334a
thumbnail
mapsandapps Dec 15, 2023
9f74da6
title
mapsandapps Dec 15, 2023
0dcb673
toast
mapsandapps Dec 15, 2023
cfcc61c
toggle
mapsandapps Dec 15, 2023
559b5ea
toolbar
mapsandapps Dec 15, 2023
811936f
refactor: `<ion-avatar />`
icarusgk Sep 15, 2023
22c2363
refactor: `<ion-back-button />`
icarusgk Sep 16, 2023
c0f1a98
lint
mapsandapps Dec 15, 2023
d0aeb8f
modal
mapsandapps Dec 15, 2023
faed9d1
progress-bar
mapsandapps Dec 15, 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
Prev Previous commit
Next Next commit
input
mapsandapps committed Dec 14, 2023

Verified

This commit was signed with the committer’s verified signature.
mapsandapps Shawn Taylor
commit 0e75efe89749bba2f14293d8f245cb0f4cd34da2
7 changes: 1 addition & 6 deletions static/usage/v7/input/basic/vue.md
Original file line number Diff line number Diff line change
@@ -23,12 +23,7 @@
</ion-list>
</template>

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

export default defineComponent({
components: { IonInput, IonItem, IonList },
});
</script>
```
7 changes: 1 addition & 6 deletions static/usage/v7/input/clear/vue.md
Original file line number Diff line number Diff line change
@@ -34,12 +34,7 @@
</ion-list>
</template>

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

export default defineComponent({
components: { IonInput, IonItem, IonList },
});
</script>
```
7 changes: 1 addition & 6 deletions static/usage/v7/input/fill/vue.md
Original file line number Diff line number Diff line change
@@ -7,12 +7,7 @@
<ion-input label="Outline input" label-placement="floating" fill="outline" placeholder="Enter text"></ion-input>
</template>

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

export default defineComponent({
components: { IonInput },
});
</script>
```
43 changes: 18 additions & 25 deletions static/usage/v7/input/filtering/vue.md
Original file line number Diff line number Diff line change
@@ -12,35 +12,28 @@
</ion-list>
</template>

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

export default defineComponent({
components: { IonInput, IonItem, IonList },
setup() {
const ionInputEl = ref();
const inputModel = ref('');
const onInput = (ev) => {
const value = ev.target!.value;
const ionInputEl = ref();
const inputModel = ref('');
const onInput = (ev) => {
const value = ev.target!.value;

// Removes non alphanumeric characters
const filteredValue = value.replace(/[^a-zA-Z0-9]+/g, '');
// Removes non alphanumeric characters
const filteredValue = value.replace(/[^a-zA-Z0-9]+/g, '');

/**
* Update both the state variable and
* the component to keep them in sync.
*/
inputModel.value = filteredValue;
/**
* Update both the state variable and
* the component to keep them in sync.
*/
inputModel.value = filteredValue;

const inputCmp = ionInputEl.value;
if (inputCmp !== undefined) {
inputCmp.$el.value = filteredValue;
}
};

return { ionInputEl, inputModel, onInput };
},
});
const inputCmp = ionInputEl.value;
if (inputCmp !== undefined) {
inputCmp.$el.value = filteredValue;
}
};
</script>
```
55 changes: 25 additions & 30 deletions static/usage/v7/input/helper-error/vue.md
Original file line number Diff line number Diff line change
@@ -13,36 +13,31 @@
></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: {
validateEmail(email) {
return email.match(
/^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
);
},

validate(ev) {
const value = ev.target.value;

this.$refs.input.$el.classList.remove('ion-valid');
this.$refs.input.$el.classList.remove('ion-invalid');

if (value === '') return;

this.validateEmail(value)
? this.$refs.input.$el.classList.add('ion-valid')
: this.$refs.input.$el.classList.add('ion-invalid');
},

markTouched() {
this.$refs.input.$el.classList.add('ion-touched');
},
},
});
import { ref } from 'vue';

const input = ref(null);

function validateEmail(email) {
return email.match(
/^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
);
}

function validate(ev) {
const value = ev.target.value;

input.value.$el.classList.remove('ion-valid');
input.value.$el.classList.remove('ion-invalid');

if (value === '') return;

validateEmail(value) ? input.value.$el.classList.add('ion-valid') : input.value.$el.classList.add('ion-invalid');
}

function markTouched() {
input.value.$el.classList.add('ion-touched');
}
</script>
```
7 changes: 1 addition & 6 deletions static/usage/v7/input/label-placement/vue.md
Original file line number Diff line number Diff line change
@@ -19,12 +19,7 @@
</ion-list>
</template>

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

export default defineComponent({
components: { IonInput, IonItem, IonList },
});
</script>
```
7 changes: 1 addition & 6 deletions static/usage/v7/input/label-slot/vue.md
Original file line number Diff line number Diff line change
@@ -9,12 +9,7 @@
</ion-list>
</template>

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

export default defineComponent({
components: { IonInput, IonItem, IonList, IonText },
});
</script>
```
7 changes: 1 addition & 6 deletions static/usage/v7/input/no-visible-label/vue.md
Original file line number Diff line number Diff line change
@@ -7,12 +7,7 @@
</ion-list>
</template>

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

export default defineComponent({
components: { IonInput, IonItem, IonList },
});
</script>
```
16 changes: 1 addition & 15 deletions static/usage/v7/input/start-end-slots/vue.md
Original file line number Diff line number Diff line change
@@ -12,22 +12,8 @@
</ion-list>
</template>

<script lang="ts">
<script lang="ts" setup>
import { IonButton, IonIcon, IonInput, IonItem, IonList } from '@ionic/vue';
import { eye, lockClosed } from 'ionicons/icons';
import { defineComponent } from 'vue';

export default defineComponent({
components: {
IonButton,
IonIcon,
IonInput,
IonItem,
IonList,
},
setup() {
return { eye, lockClosed };
},
});
</script>
```
7 changes: 1 addition & 6 deletions static/usage/v7/input/theming/colors/vue.md
Original file line number Diff line number Diff line change
@@ -11,12 +11,7 @@
<ion-input aria-label="Dark input" color="dark" placeholder="Dark input"></ion-input>
</template>

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

export default defineComponent({
components: { IonInput },
});
</script>
```
7 changes: 1 addition & 6 deletions static/usage/v7/input/theming/css-properties/vue.md
Original file line number Diff line number Diff line change
@@ -10,13 +10,8 @@
></ion-input>
</template>

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

export default defineComponent({
components: { IonInput },
});
</script>

<style>
7 changes: 1 addition & 6 deletions static/usage/v7/input/types/vue.md
Original file line number Diff line number Diff line change
@@ -23,12 +23,7 @@
</ion-list>
</template>

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

export default defineComponent({
components: { IonInput, IonItem, IonList },
});
</script>
```