├── README.md ├── assets ├── images │ ├── aboutImage.png │ ├── banner.png │ ├── bannerImage.png │ ├── cardControler.png │ ├── cardCrown.png │ ├── cardSword.png │ ├── communityImage.png │ ├── communityImageMobile.png │ ├── favicon.svg │ ├── iconBrowser.png │ ├── iconDrop.png │ ├── iconWindows.png │ ├── logo.svg │ ├── menuIcon.svg │ ├── slide1.png │ ├── slide2.png │ ├── slide3.png │ └── video.gif └── style │ └── style.css ├── games.html ├── index.html └── script.js /README.md: -------------------------------------------------------------------------------- 1 |

FreePlay

2 |

3 | Tecnologias   |    4 | Sobre   |    5 | Layout   |    6 | Funcionalidades 7 |

8 |

9 | FreePlay é um ótimo site para encontrar jogos novos, divertidos e gratuitos para jogar com seus amigos. 10 |

11 |

12 | 13 |

14 | 15 | ## Tecnologias 🚀 16 | Esse projeto foi desenvolvido com as seguintes tecnologias: 17 | - HTML 18 | - CSS 19 | - Javascript 20 | - [Free-To-Play API](https://www.freetogame.com/api-doc) 21 | 22 | ## Sobre 📖 23 | 24 | 25 | ### Descrição 26 | FreePlay é uma coleção de jogos gratuitos para que você não perca tempo escolhendo o que vai jogar. Esta coleção foi feita especialmente para você, assim você pode se divertir sem pagar um único centavo! 27 | 28 | 29 | ### Objetivo 30 | Práticar principais recursos de HTML, CSS e Javascript. Entre eles: 31 | 32 | - Requisição e manipulação de API 33 | - DOM 34 | - Responsividade 35 | - Métodos de array 36 | 37 | ## Layout 🔖 38 | No link abaixo você encontra o layout do projeto: 39 | - [Layout](https://www.figma.com/file/WJfDg7Z2sUwTWkuUxMDuvy/FreePlay?node-id=0%3A1) 40 | 41 | ## Funcionalidades 🛠✨ 42 | - Pesquisar jogos; 43 | - Filtrar jogos por categoria e plataforma; 44 | 45 | ## 📫 Como contribuir 46 | 47 | Para contribuir com FreePlay, siga estas etapas: 48 | 1. Bifurque este repositório. 49 | 2. Crie um branch: `git checkout -b `. 50 | 3. Faça suas alterações e confirme-as: `git commit -m ''` 51 | 4. Envie para o branch original: `git push origin / ` 52 | 5. Crie a solicitação de pull. 53 | Como alternativa, consulte a documentação do GitHub em [como criar uma solicitação pull](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request). 54 | --- 55 | Feito com ♥ by [David Augusto](https://github.com/DavidAugustoo) -------------------------------------------------------------------------------- /assets/images/aboutImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/aboutImage.png -------------------------------------------------------------------------------- /assets/images/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/banner.png -------------------------------------------------------------------------------- /assets/images/bannerImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/bannerImage.png -------------------------------------------------------------------------------- /assets/images/cardControler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/cardControler.png -------------------------------------------------------------------------------- /assets/images/cardCrown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/cardCrown.png -------------------------------------------------------------------------------- /assets/images/cardSword.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/cardSword.png -------------------------------------------------------------------------------- /assets/images/communityImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/communityImage.png -------------------------------------------------------------------------------- /assets/images/communityImageMobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/communityImageMobile.png -------------------------------------------------------------------------------- /assets/images/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /assets/images/iconBrowser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/iconBrowser.png -------------------------------------------------------------------------------- /assets/images/iconDrop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/iconDrop.png -------------------------------------------------------------------------------- /assets/images/iconWindows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/iconWindows.png -------------------------------------------------------------------------------- /assets/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /assets/images/menuIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /assets/images/slide1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/slide1.png -------------------------------------------------------------------------------- /assets/images/slide2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/slide2.png -------------------------------------------------------------------------------- /assets/images/slide3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/slide3.png -------------------------------------------------------------------------------- /assets/images/video.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidAugustoo/FreePlay/c0f60bee54ae8b9ff11448c06571a0ca569d5c1f/assets/images/video.gif -------------------------------------------------------------------------------- /assets/style/style.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap'); 2 | 3 | :root { 4 | --background-color: #171B1F; 5 | --primary-color: #1991EB; 6 | --secondary-color: #FFF; 7 | --terciary-color: #8d8d8d; 8 | } 9 | 10 | * { 11 | margin: 0px; 12 | padding: 0px; 13 | box-sizing: border-box; 14 | } 15 | 16 | html { 17 | font-size: 16px; 18 | scroll-behavior: smooth; 19 | } 20 | 21 | body { 22 | background-color: var(--background-color); 23 | font-family: 'Poppins', sans-serif; 24 | color: var(--secondary-color); 25 | overflow-x: hidden; 26 | } 27 | 28 | ::-webkit-scrollbar-track { 29 | background-color: transparent; 30 | } 31 | ::-webkit-scrollbar { 32 | width: 6px; 33 | background: transparent; 34 | } 35 | ::-webkit-scrollbar-thumb { 36 | background: transparent; 37 | } 38 | 39 | .container { 40 | max-width: 1200px; 41 | margin: 0 auto; 42 | padding: 0px 20px; 43 | overflow-x: hidden; 44 | } 45 | 46 | .container-games { 47 | padding: 0px 9%; 48 | } 49 | 50 | ul { 51 | list-style: none; 52 | } 53 | 54 | a { 55 | text-decoration: none; 56 | color: var(--secondary-color); 57 | } 58 | 59 | p { 60 | font-size: 1rem; 61 | color: var(--terciary-color); 62 | } 63 | 64 | .small-text { 65 | font-size: 0.9rem; 66 | } 67 | 68 | h1 { 69 | font-size: 3.3rem; 70 | } 71 | 72 | h2 { 73 | font-size: 2.3rem; 74 | } 75 | 76 | h3 { 77 | font-size: 1.1rem; 78 | } 79 | 80 | h5 { 81 | font-size: 1rem; 82 | font-weight: 600; 83 | } 84 | 85 | span { 86 | color: var(--primary-color); 87 | } 88 | 89 | .buttom { 90 | display: flex; 91 | width: 190px; 92 | height: 50px; 93 | align-items: center; 94 | justify-content: center; 95 | background-color: var(--primary-color); 96 | border-radius: 10px; 97 | font-weight: 600; 98 | transition: all .3s; 99 | } 100 | 101 | .buttom:hover { 102 | background-color: #579fd6; 103 | } 104 | 105 | [data-anime] { 106 | opacity: 0; 107 | transition: .4s; 108 | } 109 | 110 | [data-anime="left"] { 111 | transform: translate3d(-50px, 0, 0); 112 | } 113 | 114 | [data-anime="right"] { 115 | transform: translate3d(100px, 0, 0); 116 | } 117 | 118 | [data-anime].animate { 119 | opacity: 1; 120 | transform: translate3d(0px, 0px, 0px); 121 | } 122 | 123 | /* header */ 124 | 125 | .background-banner { 126 | width: 100vw; 127 | background-image: url('/assets/images/banner.png'); 128 | background-position: center; 129 | background-size: cover; 130 | } 131 | 132 | .header-area { 133 | display: flex; 134 | align-items: center; 135 | justify-content: space-between; 136 | padding: 40px 0px; 137 | } 138 | 139 | .menu { 140 | display: flex; 141 | gap: 70px; 142 | } 143 | 144 | .menu--item { 145 | font-weight: 600; 146 | cursor: pointer; 147 | border-bottom: 3px solid transparent; 148 | transition: all .30s; 149 | } 150 | 151 | .menu--item:hover { 152 | border-bottom: 3px solid #1991EB; 153 | } 154 | 155 | .menu-mobile--icon { 156 | display: none; 157 | cursor: pointer; 158 | } 159 | 160 | .menu-mobile { 161 | display: none; 162 | } 163 | 164 | /* banner */ 165 | 166 | .banner { 167 | display: flex; 168 | } 169 | 170 | .banner-desc { 171 | display: flex; 172 | align-items: center; 173 | flex: 1; 174 | } 175 | 176 | .banner-text{ 177 | display: flex; 178 | flex-direction: column; 179 | gap: 30px; 180 | } 181 | 182 | .banner-image { 183 | flex: 1; 184 | } 185 | 186 | .banner-image img { 187 | width: 100%; 188 | } 189 | 190 | /* carousel */ 191 | 192 | .carousel { 193 | overflow: hidden; 194 | } 195 | 196 | .carousel-area { 197 | display: flex; 198 | transition: all ease .3s; 199 | overflow-x: hidden; 200 | } 201 | 202 | .carousel--item { 203 | display: flex; 204 | align-items: center; 205 | background-position: center; 206 | background-size: cover; 207 | width: 100vw; 208 | height: 70vh; 209 | padding: 0px 3%; 210 | transition: all ease .3s; 211 | overflow-x: hidden; 212 | } 213 | 214 | .carousel--desc { 215 | display: flex; 216 | flex-direction: column; 217 | gap: 20px; 218 | } 219 | 220 | .carousel--text { 221 | max-width: 520px; 222 | } 223 | 224 | .carousel--tag { 225 | display: flex; 226 | justify-content: center; 227 | align-items: center; 228 | border-radius: 10px; 229 | width: 70px; 230 | height: 25px; 231 | padding: 20px 30px; 232 | background-color: rgba(248, 248, 248, 0.3); 233 | 234 | } 235 | 236 | .carousel-controls { 237 | display: flex; 238 | gap: 10px; 239 | } 240 | 241 | .carousel--control { 242 | display: flex; 243 | justify-content: center; 244 | align-items: center; 245 | font-size: 1.5rem; 246 | width: 50px; 247 | height: 50px; 248 | background-color: rgba(248, 248, 248, 0.3); 249 | border-radius: 100%; 250 | cursor: pointer; 251 | } 252 | 253 | /* info */ 254 | 255 | #info { 256 | margin-top: 150px; 257 | } 258 | 259 | .info-cards { 260 | display: grid; 261 | grid-template-columns: repeat(3,1fr); 262 | gap: 40px; 263 | } 264 | 265 | .card-item { 266 | display: flex; 267 | align-items: center; 268 | background-color: #252B33; 269 | border-radius: 10px; 270 | padding: 30px; 271 | gap: 30px; 272 | 273 | } 274 | 275 | .card--image { 276 | display: flex; 277 | align-items: center; 278 | justify-content: center; 279 | width: 50px; 280 | height: 50px; 281 | } 282 | 283 | .card--desc { 284 | flex: 1; 285 | color: white; 286 | } 287 | 288 | /* about */ 289 | 290 | #about { 291 | display: flex; 292 | margin-top: 150px; 293 | } 294 | 295 | .about--image { 296 | display: flex; 297 | justify-content: start; 298 | flex: 1; 299 | } 300 | 301 | .about--image img{ 302 | width: 100%; 303 | } 304 | 305 | .about--desc { 306 | display: flex; 307 | flex-direction: column; 308 | justify-content: center; 309 | align-items: flex-start; 310 | flex: 1; 311 | } 312 | 313 | .about--text { 314 | display: flex; 315 | flex-direction: column; 316 | gap: 25px; 317 | max-width: 500px; 318 | } 319 | 320 | /* community */ 321 | 322 | #community { 323 | margin-top: 100px; 324 | width: 100%; 325 | } 326 | 327 | .community--image { 328 | width: 100%; 329 | } 330 | 331 | .community--image--mobile { 332 | display: none; 333 | } 334 | 335 | /* footer */ 336 | 337 | #footer { 338 | margin-top: 100px; 339 | padding: 50px 0px 20px 0px; 340 | width: 100vw; 341 | background-color: #252B33; 342 | } 343 | 344 | .footer--area { 345 | display: flex; 346 | } 347 | 348 | .footer--logo { 349 | flex: 1; 350 | } 351 | 352 | .footer--links { 353 | display: flex; 354 | gap: 100px; 355 | } 356 | 357 | .footer--link { 358 | display: flex; 359 | flex-direction: column; 360 | gap: 10px; 361 | } 362 | 363 | .autor { 364 | margin-top: 70px; 365 | width: 100%; 366 | text-align: center; 367 | } 368 | 369 | /* games */ 370 | 371 | .games { 372 | margin-top: 70px; 373 | } 374 | 375 | .modal { 376 | display: none; 377 | } 378 | 379 | .game-area { 380 | display: grid; 381 | grid-template-columns: repeat(4, 1fr); 382 | row-gap: 40px; 383 | column-gap: 20px; 384 | margin: 70px 0px; 385 | transition: all ease 1s; 386 | } 387 | 388 | .game--warning { 389 | display: none; 390 | text-align: center; 391 | } 392 | 393 | .game-card { 394 | display: flex; 395 | flex-direction: column; 396 | justify-content: space-between; 397 | gap: 10px; 398 | } 399 | 400 | .game--image { 401 | width: auto; 402 | } 403 | 404 | .game--image img { 405 | width: 100%; 406 | } 407 | 408 | .game--desc { 409 | display: flex; 410 | flex-direction: column; 411 | justify-content: space-between; 412 | gap: 15px; 413 | } 414 | 415 | .tags-area { 416 | display: flex; 417 | align-items: cente; 418 | justify-content: space-between; 419 | } 420 | 421 | .tag--genre { 422 | display: flex; 423 | justify-content: center; 424 | align-items: center; 425 | border-radius: 10px; 426 | background-color: #252B33; 427 | width: 100px; 428 | height: 35px; 429 | font-size: 0.9rem; 430 | } 431 | 432 | .filters-dropdown--area { 433 | display: flex; 434 | gap: 10px; 435 | } 436 | 437 | .filter-area { 438 | display: flex; 439 | justify-content: center; 440 | align-items: center; 441 | gap: 20px; 442 | } 443 | 444 | .filter-platform, 445 | .filter-genre { 446 | position: relative; 447 | } 448 | 449 | .filter-desc--platform, 450 | .filter-desc--genre { 451 | display: flex; 452 | gap: 10px; 453 | } 454 | 455 | .currentSelected--platform, 456 | .currentSelected--genre { 457 | color: white; 458 | cursor: pointer; 459 | text-transform: capitalize; 460 | } 461 | 462 | .filter-options--platform, 463 | .filter-options--genre { 464 | background-color: #252B33; 465 | padding: 20px; 466 | border-radius: 10px; 467 | position: absolute; 468 | right: 0; 469 | margin-top: 5px; 470 | display: flex; 471 | flex-direction: column; 472 | gap: 10px; 473 | } 474 | 475 | .filter-options--platform.closed, 476 | .filter-options--genre.closed { 477 | display: none; 478 | } 479 | 480 | .dropdown--filter { 481 | cursor: pointer; 482 | } 483 | 484 | .filter--item--platform, 485 | .filter--item--genre { 486 | cursor: pointer; 487 | text-transform: capitalize; 488 | } 489 | 490 | .search-game { 491 | display: block; 492 | max-width: 700px; 493 | height: 50px; 494 | width: 100%; 495 | border-radius: 10px; 496 | padding: 0px 20px; 497 | background-color: #252B33; 498 | border: 0; 499 | font-size: 1.1rem; 500 | color: white; 501 | } 502 | 503 | .search-game:focus { 504 | outline: none; 505 | } 506 | 507 | 508 | 509 | @media (max-width: 850px) { 510 | 511 | html { 512 | font-size: 13px; 513 | } 514 | 515 | .container { 516 | max-width: 1200px; 517 | margin: 0 auto; 518 | padding: 0px 60px; 519 | } 520 | 521 | .info-cards { 522 | grid-template-columns: repeat(1, 1fr); 523 | } 524 | } 525 | 526 | @media (max-width: 850px) { 527 | 528 | .menu-desktop { 529 | display: none; 530 | } 531 | 532 | .menu { 533 | display: none; 534 | } 535 | 536 | .menu-mobile.closed { 537 | display: none; 538 | } 539 | 540 | .menu-mobile.open { 541 | display: block; 542 | } 543 | 544 | 545 | .menu-mobile--icon { 546 | display: block; 547 | } 548 | 549 | .menu-mobile--item { 550 | padding: 15px; 551 | text-transform: uppercase; 552 | font-size: 1.2rem; 553 | } 554 | 555 | .menu-mobile--item:hover { 556 | background-color: #1991EB; 557 | } 558 | 559 | .banner { 560 | margin-top: 70px; 561 | } 562 | 563 | .banner-image { 564 | display: none; 565 | } 566 | 567 | .container { 568 | max-width: 1200px; 569 | margin: 0 auto; 570 | padding: 0px 30px; 571 | } 572 | 573 | #about { 574 | flex-direction: column; 575 | gap: 50px; 576 | } 577 | 578 | .community--image { 579 | display: none; 580 | } 581 | 582 | .community--image--mobile { 583 | display: block; 584 | width: 100%; 585 | } 586 | 587 | .footer--area { 588 | flex-direction: column; 589 | align-items: center; 590 | gap: 40px; 591 | } 592 | 593 | .footer--links { 594 | gap: 50px; 595 | } 596 | 597 | .game-area { 598 | grid-template-columns: repeat(3, 1fr); 599 | } 600 | 601 | .filter-area { 602 | flex-direction: column; 603 | } 604 | 605 | } 606 | 607 | @media (max-width: 425px) { 608 | 609 | .game-area { 610 | grid-template-columns: repeat(1, 1fr); 611 | } 612 | } -------------------------------------------------------------------------------- /games.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | FreePlay 10 | 11 | 12 |
13 |
14 |
15 | 18 | 21 | 29 |
30 | 38 |
39 |
40 | 41 | 102 | 103 |
104 |
105 | 122 | 123 |
124 | 125 |
126 |
127 |
128 |

Plataforma:

Todos

129 |
130 |
    131 |
  • Todos

  • 132 |
  • Windows

  • 133 |
  • Navegador

  • 134 |
135 |
136 | 137 |
138 |
139 |

Gênero:

Todos

140 |
141 |
    142 |
  • Todos

  • 143 |
  • mmorpg

  • 144 |
  • shooter

  • 145 |
  • strategy

  • 146 |
  • racing

  • 147 |
  • sports

  • 148 |
  • survival

  • 149 |
150 |
151 |
152 | 153 |
154 | 155 |
156 | 157 |
158 |
159 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | FreePlay 10 | 11 | 12 |
13 |
14 | 40 | 41 | 52 |
53 |
54 | 55 |
56 |
57 |
58 |
59 |
60 | 61 |
62 | 63 |
64 |
JOGOS GRATUITOS
65 |

Melhores jogos gratuitos para jogar com seus amigos

66 |
67 |
68 |
69 |
70 | 71 |
72 | 73 |
74 |
DIVERSAS CATEGORIAS
75 |

Reunimos diferentes categorias de jogos

76 |
77 |
78 |
79 |
80 | 81 |
82 | 83 |
84 |
POPULARES DO MOMENTO
85 |

Encontre os jogos mais jogados do momento

86 |
87 |
88 |
89 |
90 | 91 |
92 |
93 | 94 |
95 |
96 |
97 |

O melhor lugar para encontrar jogos gratuitos!

98 |

FreePlay é uma coleção de jogos gratuitos para que você não perca tempo escolhendo o que vai jogar. Esta coleção foi feita especialmente para você, assim você pode se divertir sem pagar um único centavo!

99 | Explorar Jogos 100 |
101 |
102 |
103 | 104 |
105 | 106 | 107 |
108 |
109 | 110 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /script.js: -------------------------------------------------------------------------------- 1 | const s = (el) => document.querySelector(el); 2 | const sa = (el) => document.querySelectorAll(el); 3 | 4 | 5 | // animatios 6 | 7 | let target = document.querySelectorAll('[data-anime]'); 8 | 9 | window.addEventListener('scroll', () => { 10 | let windowTop = window.scrollY + ((window.innerHeight * 3) / 4); 11 | 12 | target.forEach(element => { 13 | if((windowTop) > element.offsetTop) { 14 | element.classList.add('animate'); 15 | } else { 16 | element.classList.remove('animate'); 17 | } 18 | }); 19 | }); 20 | 21 | // menu mobile 22 | 23 | let menuMobileIcon = s('.menu-mobile--icon'); 24 | let menuMobile = s('.menu-mobile'); 25 | 26 | menuMobileIcon.addEventListener('click', () => { 27 | if(menuMobile.classList.contains('closed')) { 28 | menuMobile.classList.remove('closed'); 29 | menuMobile.classList.add('open'); 30 | } else { 31 | menuMobile.classList.remove('open'); 32 | menuMobile.classList.add('closed'); 33 | } 34 | }); 35 | 36 | // carousel 37 | 38 | let currentSlide = 0; 39 | 40 | function goNext() { 41 | currentSlide++; 42 | if(currentSlide > 2) { 43 | currentSlide = 0; 44 | } 45 | 46 | updateMargin(); 47 | } 48 | 49 | function goBack() { 50 | currentSlide--; 51 | if(currentSlide < 2) { 52 | currentSlide = 0; 53 | } 54 | 55 | updateMargin(); 56 | } 57 | 58 | function updateMargin() { 59 | let slideritemWidth = s('.carousel--item').clientWidth; 60 | let newMargin = (currentSlide * slideritemWidth); 61 | s('.carousel--item').style.marginLeft = `-${newMargin}px` 62 | } 63 | 64 | // games 65 | let plataform = '?platform=all'; 66 | let category = ''; 67 | let url = `https://free-to-play-games-database.p.rapidapi.com/api/games${plataform}${category}&sort-by=popularity`; 68 | console.log(url); 69 | let page = 0; 70 | let inputFilter = document.querySelector('.search-game'); 71 | 72 | async function getGames() { 73 | 74 | let response = await fetch(url, { 75 | "method": "GET", 76 | "headers": { 77 | "x-rapidapi-host": "free-to-play-games-database.p.rapidapi.com", 78 | "x-rapidapi-key": "03fb1e4f2dmsh6bb237e14e40631p173a3ajsnf3d499c72407" 79 | }}); 80 | 81 | return response.json(); 82 | } 83 | 84 | async function addGamesIntoDom() { 85 | 86 | let json = await getGames(); 87 | 88 | console.log(json) 89 | 90 | json.map((item) => { 91 | let gameCard = s('.modal .game-card').cloneNode(true); 92 | 93 | gameCard.querySelector('.game--image img').src = item.thumbnail; 94 | gameCard.querySelector('.game--title').innerHTML = `${item.title.substring(0,25)}`; 95 | gameCard.querySelector('.game--resume').innerHTML = `${item.short_description.substring(0,55)}...`; 96 | gameCard.querySelector('.tag--genre').innerHTML = item.genre; 97 | gameCard.querySelector('.tag--platform img').src = WhatThisPlataform(item.platform); 98 | gameCard.querySelector('.game-card--link').href = item.game_url; 99 | 100 | s('.game-area').append(gameCard); 101 | }); 102 | } 103 | 104 | function WhatThisPlataform(platform) { 105 | if(platform == "PC (Windows)") { 106 | return '/assets/images/iconWindows.png'; 107 | } else { 108 | return '/assets/images/iconBrowser.png'; 109 | } 110 | } 111 | 112 | addGamesIntoDom(); 113 | 114 | inputFilter.addEventListener('input', event => { 115 | let inputValue = event.target.value.toLowerCase(); 116 | let games = document.querySelectorAll('.game-card'); 117 | let warning = document.querySelector('.game--warning'); 118 | 119 | games.forEach((game) => { 120 | let gameTitle = game.querySelector('.game--title').textContent.toLowerCase(); 121 | 122 | if(gameTitle.includes(inputValue)) { 123 | game.style.display = 'flex'; 124 | } else { 125 | game.style.display = 'none'; 126 | } 127 | 128 | }); 129 | 130 | }); 131 | 132 | // filter 133 | 134 | let filterOptionsPlatform = s('.filter-options--platform'); 135 | let filterOptionsGenre = s('.filter-options--genre') 136 | 137 | s('.filter-desc--platform').addEventListener('click', () => { 138 | if (filterOptionsPlatform.classList.contains('closed')) { 139 | filterOptionsPlatform.classList.remove('closed'); 140 | } else { 141 | filterOptionsPlatform.classList.add('closed'); 142 | } 143 | 144 | }); 145 | 146 | s('.filter-desc--genre').addEventListener('click', () => { 147 | if (filterOptionsGenre.classList.contains('closed')) { 148 | filterOptionsGenre.classList.remove('closed'); 149 | } else { 150 | filterOptionsGenre.classList.add('closed'); 151 | } 152 | 153 | }); 154 | 155 | sa('.filter--item--platform').forEach((option) => { 156 | option.addEventListener('click', (el) => { 157 | s('.filter--item--platform.selected').classList.remove('selected'); 158 | option.classList.add('selected'); 159 | 160 | let platformSelected = s('.filter--item--platform.selected').getAttribute('data-key'); 161 | s('.currentSelected--platform').innerHTML = s('.filter--item--platform.selected').getAttribute('data-name'); 162 | 163 | filterPlataform(platformSelected); 164 | filterOptionsPlatform.classList.add('closed'); 165 | }); 166 | }); 167 | 168 | sa('.filter--item--genre').forEach((option) => { 169 | option.addEventListener('click', (el) => { 170 | s('.filter--item--genre.selected').classList.remove('selected'); 171 | option.classList.add('selected'); 172 | 173 | let genreSelected = s('.filter--item--genre.selected').getAttribute('data-key'); 174 | s('.currentSelected--genre').innerHTML = genreSelected; 175 | 176 | filterGenre(genreSelected); 177 | filterOptionsGenre.classList.add('closed'); 178 | }); 179 | }); 180 | 181 | function filterPlataform(platformSelected) { 182 | 183 | plataform = `?platform=${platformSelected}`; 184 | 185 | url = `https://free-to-play-games-database.p.rapidapi.com/api/games${plataform}${category}&sort-by=popularity`; 186 | s('.game-area').innerHTML = ''; 187 | getGames(); 188 | addGamesIntoDom(); 189 | } 190 | 191 | function filterGenre(genreSelected) { 192 | 193 | if(genreSelected == 'todos') { 194 | category = ''; 195 | } else { 196 | category = `&category=${genreSelected}`; 197 | } 198 | 199 | 200 | url = `https://free-to-play-games-database.p.rapidapi.com/api/games${plataform}${category}&sort-by=popularity`; 201 | 202 | getGames(); 203 | s('.game-area').innerHTML = ''; 204 | addGamesIntoDom(); 205 | } 206 | 207 | 208 | --------------------------------------------------------------------------------