Fais de ta vie un rêve, et d'un rêve, une réalité.
This commit is contained in:
parent
8662895cff
commit
b26d9f1bf8
107
onzer.riot
107
onzer.riot
@ -1,31 +1,44 @@
|
|||||||
<onzer>
|
<onzer>
|
||||||
<div class="px-12">
|
<div class="px-12">
|
||||||
<div class="flex-row mb-2">
|
<div class="flex-row mb-2">
|
||||||
<input id="album" type="button" onclick={ click } value="Albums" class="mr-2 border-solid bg-emerald-100 border rounded-lg border-emerald-300 h-14 w-40 mt-2"/>
|
<input id="album" type="button" onclick={click} value="Albums"
|
||||||
<input id="artist" type="button" onclick={ click } value="Artists" class="mx-2 border-solid bg-emerald-100 border rounded-lg border-emerald-300 h-14 w-40 mt-2"/>
|
class="mr-4 border-solid border rounded-lg h-20 w-64 mt-2 {album_style}"/>
|
||||||
<input id="song" type="button" onclick={ click } value="Songs" class="ml-2 border-solid bg-emerald-100 border rounded-lg border-emerald-300 h-14 w-40 mt-2"/>
|
<input id="artist" type="button" onclick={click} value="Artists"
|
||||||
|
class="mr-4 border-solid border rounded-lg h-20 w-64 mt-2 {artist_style}"/>
|
||||||
|
<input id="song" type="button" onclick={click} value="Songs"
|
||||||
|
class="mr-4 border-solid border rounded-lg h-20 w-64 mt-2 {song_style}"/>
|
||||||
</div>
|
</div>
|
||||||
<form onsubmit={ add }>
|
<form onsubmit={ add }>
|
||||||
<div class="flex flex-row items-baseline">
|
<div class="flex flex-row items-baseline">
|
||||||
<input class="flex-grow-1 border-solid border bg-emerald-100 w-half rounded-lg border-emerald-300 border h-14 pl-6 grow"
|
<input class="flex-grow-1 border-solid border bg-emerald-100 w-half rounded-lg border-emerald-300 border h-20 pl-6 grow"
|
||||||
placeholder={ this.state.placeholder } onkeyup={ edit } />
|
placeholder={ this.state.placeholder } onkeyup={ edit } />
|
||||||
<input type="button" value="Playlists" class="ml-2 border-solid bg-emerald-300 border rounded-lg border-emerald-600 mb-4 h-14 w-40 mt-2"/>
|
<input type="button" value="Playlists"
|
||||||
|
class="ml-2 border-solid bg-emerald-300 border rounded-lg border-emerald-600 mb-4 h-20 w-48 mt-2"/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap px-12 justify-between mt-8">
|
||||||
|
<div each={ album in state.items.results }
|
||||||
|
class="item mb-4 border border-solid rounded-lg h-64 flex justify-center items-center">
|
||||||
|
<div>
|
||||||
|
<p> { album.name } </p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
onBeforeMount(props){
|
onBeforeMount(props){
|
||||||
this.state.placeholder = 'Rechercher dans les albums';
|
this.state = {
|
||||||
|
placeholder: "Rechercher dans les albums",
|
||||||
|
search: "albums"
|
||||||
|
};
|
||||||
|
|
||||||
this.test();
|
this.paintButton();
|
||||||
|
this.album_style = "isActivate";
|
||||||
console.log(this.state);
|
|
||||||
},
|
},
|
||||||
onMounted(){
|
onMounted(){
|
||||||
document.getElementById("album").style.backgroundColor = "#6EE7B7";
|
|
||||||
document.getElementById("album").style.borderColor = "#059669";
|
|
||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
edit(e) {
|
edit(e) {
|
||||||
@ -33,45 +46,59 @@
|
|||||||
},
|
},
|
||||||
click(e) {
|
click(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.clearButton();
|
this.paintButton();
|
||||||
switch (e.target.attributes.value.value) {
|
const old_search = this.state.search;
|
||||||
case 'Songs':
|
switch(e.target.value){
|
||||||
this.state.placeholder = "Rechercher dans les songs"
|
case "Albums":
|
||||||
document.getElementById("song").style.backgroundColor = "#6EE7B7";
|
this.state.placeholder = "Rechercher dans les albums";
|
||||||
document.getElementById("song").style.borderColor = "#059669";
|
this.album_style = "isActivate";
|
||||||
|
this.state.search = "albums";
|
||||||
break;
|
break;
|
||||||
case 'Artists':
|
case "Artists":
|
||||||
this.state.placeholder = "Rechercher dans les artists";
|
this.state.placeholder = "Rechercher dans les artists";
|
||||||
document.getElementById("artist").style.backgroundColor = "#6EE7B7";
|
this.artist_style = "isActivate";
|
||||||
document.getElementById("artist").style.borderColor = "#059669";
|
this.state.search = "artists";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.state.placeholder = "Rechercher dans les albums";
|
this.placeholder = "Rechercher dans les songs";
|
||||||
document.getElementById("album").style.backgroundColor = "#6EE7B7";
|
this.song_style = "isActivate";
|
||||||
document.getElementById("album").style.borderColor = "#059669";
|
this.state.search = "songs";
|
||||||
|
}
|
||||||
|
if(old_search != this.state.search){this.list();}
|
||||||
|
this.update();
|
||||||
|
},
|
||||||
|
async list(){
|
||||||
|
this.state = {
|
||||||
|
placeholder: "Rechercher dans les songs",
|
||||||
|
items: await this.fetchData()
|
||||||
};
|
};
|
||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
clearButton() {
|
fetchData(){
|
||||||
document.getElementById("song").style.backgroundColor = "#D1FAE5";
|
return fetch("https://dwarves.iut-fbleau.fr/~fauvet/api/"+this.state.search+"").then(response => {
|
||||||
document.getElementById("song").style.borderColor = "#6EE7B7";
|
|
||||||
document.getElementById("album").style.backgroundColor = "#D1FAE5";
|
|
||||||
document.getElementById("album").style.borderColor = "#6EE7B7";
|
|
||||||
document.getElementById("artist").style.backgroundColor = "#D1FAE5";
|
|
||||||
document.getElementById("artist").style.borderColor = "#6EE7B7";
|
|
||||||
},
|
|
||||||
async test(){
|
|
||||||
this.state = {
|
|
||||||
placeholder: "caca",
|
|
||||||
items: await this.fetchSong()
|
|
||||||
};
|
|
||||||
console.log(this.state);
|
|
||||||
},
|
|
||||||
fetchSong(){
|
|
||||||
return fetch("https://dwarves.iut-fbleau.fr/~fauvet/api/songs").then(response => {
|
|
||||||
return response.json();
|
return response.json();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
paintButton(){
|
||||||
|
this.album_style = "isDeactivate";
|
||||||
|
this.artist_style = "isDeactivate";
|
||||||
|
this.song_style = "isDeactivate";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<style>
|
||||||
|
.isActivate{
|
||||||
|
background-color: #6EE7B7;
|
||||||
|
border-color: #059669;
|
||||||
|
}
|
||||||
|
.isDeactivate {
|
||||||
|
background-color: #D1FAE5;
|
||||||
|
border-color: #6EE7B7;
|
||||||
|
}
|
||||||
|
.item {
|
||||||
|
background-color: #ECFDF5;
|
||||||
|
border-color: #6EE7B7;
|
||||||
|
width: 32%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</onzer>
|
</onzer>
|
Loading…
Reference in New Issue
Block a user