PHP Classes

File: assets/js/pages/homePage.js

Recommend this page to a friend!
  Classes of Rodrigo Faustino   Simple SPA   assets/js/pages/homePage.js   Download  
File: assets/js/pages/homePage.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Simple SPA
Demonstrates single page applications
Author: By
Last change:
Date: 6 months ago
Size: 1,475 bytes
 

Contents

Class file image Download
import Component from '../component/Component.js'; import FetchData from '../lib/FetchData.js'; import CardComponent from '../card/CardComponent.js'; import FullContent from './FullContent.js'; import Modal from '../modal/Modal.js'; class HomePage extends Component { constructor() { super(); this.title = 'Home - Meu SPA'; this.description = 'Bem-vindo à página inicial do nosso Single Page Application.'; this.keywords = 'home,spa,single page application,principal'; //this.postsUrl = 'assets/js/json/posts.json'; this.postsUrl = 'back/fetch_posts.php'; } async render() { const fetchData = new FetchData(this.postsUrl); const posts = await fetchData.getJson(); this.posts = posts; this.modal = new Modal(''); this.handleCardClick = (post) => { const fullContentComponent = new FullContent(post); this.modal.updateContent(fullContentComponent.render()); this.modal.open(); }; this.cardComponent = new CardComponent(posts, this.handleCardClick); return ` <div> ${this.modal.render()} <div class="w3-center"> ${this.cardComponent.render()} </div> </div> `; } async afterRender() { this.modal.afterRender(); this.cardComponent.afterRender(); } } export default HomePage;