Skip to content

Commit

Permalink
I put the name of the background photo location to be searched in the…
Browse files Browse the repository at this point in the history
… input
  • Loading branch information
aline-borges committed Sep 8, 2020
1 parent 5c77edf commit f3a88d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
8 changes: 3 additions & 5 deletions src/app/components/form/form.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container" id="home-page" (load)="changeBackgroundImage()">
<div class="container" id="home-page">
<app-header></app-header>
<div class="page-content">
<div class="search-content">
Expand All @@ -11,7 +11,7 @@ <h1 class="page-title">
<i class="fas fa-map-marker-alt"></i>
<input
id="searchInput"
(keyup)="getLocation($event)"
(change)="getLocation($event)"
(keyup.enter)="getHotels()"
class="search-input"
placeholder="Vai pra onde?"
Expand All @@ -23,12 +23,10 @@ <h1 class="page-title">
Pesquisar
<i class="fas fa-search"></i>
</button>

<button class="button" (click)="changeBackgroundImage()">Mudar</button>
</div>
</div>
<footer>
<button class="background-place" (click)="sendLocationToInput()" id="place-name"></button>
<button class="background-place" value="{{ this.name }}" (click)="sendLocationToInput()" id="place-name">{{ this.name }}</button>
</footer>
</div>
</div>
Expand Down
36 changes: 20 additions & 16 deletions src/app/components/form/form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class FormComponent implements OnInit {
hotels: Array<any>
types: Array<any>
location: string
name: string
stars: string
pagination: any
currentPage: number
Expand All @@ -24,8 +25,12 @@ export class FormComponent implements OnInit {
this.currentPage = 1;
}

getLocation(evento: KeyboardEvent){
this.location = (<HTMLInputElement>evento.target).value;
getLocation(evento: KeyboardEvent, value: null){
if(value !== null) {
this.location = value;
}

this.location = document.getElementById('searchInput').value;
}

getHotels(page = 1) {
Expand Down Expand Up @@ -83,37 +88,37 @@ export class FormComponent implements OnInit {
changeBackgroundImage() {

const fernandoDeNoronha = {
name: 'Fernando De Noronha - PE',
name: 'Fernando De Noronha',
url: '../../../assets/images/fernando-de-noronha.png',
};

const portoSeguro = {
name: 'Porto Seguro - BA',
name: 'Porto Seguro',
url: '../../../assets/images/porto-seguro.png',
};

const arraialDoCabo = {
name: 'Arraial Do Cabo - RJ',
name: 'Arraial Do Cabo',
url: '../../../assets/images/arraial-do-cabo.png',
};

const vancouver = {
name: 'Vancouver - Canada',
name: 'Vancouver',
url: '../../../assets/images/vancouver.png',
};

const santorini = {
name: 'Santorini - Grecia',
name: 'Santorini',
url: '../../../assets/images/santorini.png',
};

const bali = {
name: 'Bali - Indonesia',
name: 'Bali',
url: '../../../assets/images/bali.png',
};

const kyoto = {
name: 'Kioto - Japão',
name: 'Kioto',
url: '../../../assets/images/kyoto.png',
};

Expand All @@ -123,7 +128,7 @@ export class FormComponent implements OnInit {
};

const bonito = {
name: 'Bonito - MS',
name: 'Bonito',
url: '../../../assets/images/bonito.jpg',
};

Expand All @@ -136,18 +141,17 @@ export class FormComponent implements OnInit {
const bgImgName = images[randomNumber].name;

const home = document.getElementById('home-page');
const name = document.getElementById('place-name');
this.name = document.getElementById('place-name').innerHTML;

return home.style.backgroundImage = bgImg, name.innerHTML = bgImgName;
return home.style.backgroundImage = bgImg, this.name = bgImgName;
}

sendLocationToInput() {
const name = document.getElementById('place-name').innerHTML;
const name = document.getElementById('place-name').value;
let input = document.getElementById('searchInput');
input.value = name;

console.log(typeof input.value)

return input.value = name.toString();
return this.getLocation(null, name);
}

backToTop() {
Expand Down
Binary file modified src/assets/images/bonito.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f3a88d8

Please sign in to comment.