-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add filter by criteria and by characteristics
- Loading branch information
1 parent
875ab8f
commit bc02be6
Showing
11 changed files
with
519 additions
and
45 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 |
---|---|---|
@@ -1,5 +1,67 @@ | ||
<template> | ||
<div data-test="pokemon-moves"></div> | ||
<h2> | ||
{{ moveLengthLabel }} | ||
</h2> | ||
<div class="pokemon-moves" data-test="pokemon-moves"> | ||
|
||
<div class="pokemon-move" :class="move.type" v-for="(move, i) of moves" :key="i"> | ||
<ion-icon :src="move.icon"></ion-icon> | ||
<div> | ||
{{ move.move }} | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
</script> | ||
import { pokemonTypeIcon } from '@/constants/types-icons'; | ||
import { Pokemon } from '@/models/pokemon.model'; | ||
import { computed } from 'vue'; | ||
const props = defineProps<{ pokemon: Pokemon }>() | ||
const moves = computed(() => { | ||
const typesLength = props.pokemon.types.length; | ||
return props.pokemon.moves.map((move, i) => ({ | ||
move, | ||
icon: pokemonTypeIcon(props.pokemon.types[i % typesLength]), | ||
type: props.pokemon.types[i % typesLength] | ||
})) | ||
}) | ||
const moveLengthLabel = computed(() => { | ||
const movesLegth = props.pokemon.moves.length | ||
return movesLegth == 1 | ||
? "1 move" | ||
: `${movesLegth} moves` | ||
}) | ||
</script> | ||
<style scoped> | ||
.pokemon-moves { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 30px; | ||
margin-top: 15px; | ||
} | ||
.pokemon-move ion-icon { | ||
border-radius: 100%; | ||
background: white; | ||
margin-top: 7px; | ||
font-size: 15px; | ||
padding: 5px; | ||
} | ||
.pokemon-move div { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
padding: 0px 10px; | ||
white-space: nowrap; | ||
} | ||
.pokemon-move { | ||
height: 64px; | ||
width: 100px; | ||
border-radius: 4px; | ||
text-align: center; | ||
color: var(--neutral-50); | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
} | ||
</style> |
This file contains 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 |
---|---|---|
@@ -1,25 +1,119 @@ | ||
<template> | ||
<ion-modal ref="modal" trigger="open-modal"> | ||
<ion-page> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"> | ||
<ion-button @click="cancel()">Cancel</ion-button> | ||
</ion-buttons> | ||
<ion-title>Welcome</ion-title> | ||
<ion-buttons slot="end"> | ||
<ion-button :strong="true" @click="confirm()">Confirm</ion-button> | ||
<ion-button @click="closeModal"> | ||
<ion-icon class="primary" :icon="close"></ion-icon> | ||
</ion-button> | ||
</ion-buttons> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content class="ion-padding"> | ||
<ion-item> | ||
<ion-label position="stacked">Enter your name</ion-label> | ||
<ion-input ref="input" type="text" placeholder="Your name"></ion-input> | ||
<ion-select v-model="filters.moves" placeholder="Select movement number"> | ||
<ion-select-option v-for="(move, i) of props.moves " :value="move" :key="i"> | ||
{{ move }} | ||
</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
<ion-item> | ||
<ion-select v-model="filters.experience" placeholder="Select experience level"> | ||
<ion-select-option v-for="(experience, i) of props.experiences " :value="experience" :key="i"> | ||
{{ experience }} | ||
</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
<ion-item> | ||
<ion-select :value="filters.types" placeholder="Pokemon type" :multiple="true" @ion-change="changes"> | ||
<ion-select-option v-for="(type, i) of props.types" :value="type" :key="i"> | ||
{{ type }} | ||
</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
</ion-content> | ||
</ion-modal> | ||
<ion-footer> | ||
<ion-button @click="closeModal" color="medium" class="cancel">cancel</ion-button> | ||
<ion-button @click="submitModal">confirm</ion-button> | ||
</ion-footer> | ||
</ion-page> | ||
</template> | ||
<script setup lang="ts"> | ||
const cancel = () => {return 5} | ||
const confirm = () => {return 7} | ||
import { IonFooter, IonIcon, IonSelect, IonSelectOption, IonPage, IonHeader, IonToolbar, IonButtons, IonButton, IonContent, IonItem, modalController } from '@ionic/vue'; | ||
import { close } from 'ionicons/icons'; | ||
import { onMounted, reactive, ref } from 'vue'; | ||
const moves = ref() | ||
const props = defineProps<{ | ||
filters: { | ||
types: string[], | ||
experience: number, | ||
moves: number | ||
}, | ||
moves: number[], | ||
types: string[], | ||
experiences: number[] | ||
}>() | ||
const filters = reactive(Object.assign({}, props.filters)) | ||
const changes = (event: CustomEvent) => { | ||
filters.types = event.detail.value | ||
} | ||
onMounted(() => { | ||
console.log(props) | ||
modalController.getTop | ||
moves.value = "oranges" | ||
}) | ||
const closeModal = () => { | ||
modalController.dismiss() | ||
} | ||
const submitModal = () => { | ||
modalController.dismiss(filters) | ||
} | ||
</script> | ||
<style scoped> | ||
ion-page { | ||
--ion-background-color: var(--neutral-50) | ||
} | ||
ion-header { | ||
background-color: var(--neutral-50); | ||
} | ||
ion-footer { | ||
display: flex; | ||
background-color: var(--neutral-50); | ||
} | ||
ion-button { | ||
flex: 1 | ||
} | ||
ion-header::after { | ||
display: none; | ||
} | ||
.cancel { | ||
--background-color: red; | ||
} | ||
ion-toolbar { | ||
--ion-toolbar-background: var(--neutral-50); | ||
} | ||
ion-item { | ||
--ion-background-color: var(--neutral-100); | ||
--ion-background-color: var(--neutral-100); | ||
--border-radius: 8px 8px 0 0; | ||
margin-bottom: 24px; | ||
} | ||
ion-select { | ||
--placeholder-color: var(--neutral-500); | ||
--placeholder-opacity: 1; | ||
width: 100%; | ||
}</style> |
This file contains 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 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
Oops, something went wrong.