import { Component , OnInit , AfterViewInit } from '@angular/core' ; import { DomSanitizer } from '@angular/platform-browser' ; import { Router , NavigationEnd } from '@angular/router' ; import { SeoService } from '../../services/seo' ; import { StateService } from '../../services/state' ; import { toAbsoluteUrl , toRouterLink , routifyLinks } from '../../utils/urls' ; import { content , images , title } from '../../../../config/code-gov-config.json' ; interface AboutItem { title : string ; description : string ; link : string ; image : string ; } interface Link { view_project : string ; go_to_repo : string ; } interface FeaturedProject { short_name : string ; verbose_name : string ; author : string ; description : string ; image : string ; links : Link [ ] ; } @ Component ( { selector : 'home' , styles : [ require ( './home.style.scss' ) ] , template : require ( './home.template.html' ) } ) export class HomeComponent implements OnInit , AfterViewInit { private backgroundImage = this . sanitizer . bypassSecurityTrustStyle ( `url('${ images . background }')` ) ; private content = content ; private featured : FeaturedProject [ ] ; private aboutItems : AboutItem [ ] ; constructor ( public stateService , private sanitizer , private seoService , private router ) { this . stateService . set ( 'section' , 'home' ) ; this . seoService . setTitle ( title , false ) ; this . seoService . setMetaDescription ( 'Code.gov is a platform designed to improve access to the federal government’s ' + 'custom-developed software.' ) ; this . aboutItems = content . home . about . map ( aboutItem => { aboutItem . image = toAbsoluteUrl ( aboutItem . image ) ; return aboutItem ; } ) ; this . featured = content . home . featured . map ( featuredProject => { featuredProject . image = toAbsoluteUrl ( featuredProject . image ) ; featuredProject . links = routifyLinks ( featuredProject . links ) ; return featuredProject ; } ) ; } ngOnInit ( ) { window . scrollTo ( 0 , 0 ) ; } ngAfterViewInit ( ) { window . scrollTo ( 0 , 0 ) ; } scrollToAbout ( ) { let top = document . getElementById ( 'banner-home' ) . clientHeight ; let offset = document . querySelector ( 'header nav.main' ) . clientHeight ; let buffer = 35 ; window . scrollTo ( { top : top - offset , behavior : 'smooth' } ) ; } }