import { Component, Input, OnInit } from '@angular/core'

import { HelperService }               from '@k-services/svc.helper'

@Component({
    moduleId: module.id+ '',
    selector: 'fold-out-container',
    templateUrl: './template.fold-out-container.pug',
    styleUrls: ['./structure.fold-out-container.scss','./visual.fold-out-container.scss']
})

export class FoldOutContainerComponent {

    // Variables ----
    isOpen: boolean = false

    @Input('type') type: string;
    @Input('title') title: string;
    @Input('content') content: any;

    constructor(
        private _helper: HelperService
    ) {  }



    // Lifecycle hooks ----
    ngOnInit() {

        // If type is description, open it from the beginning 

        if(this.type == 'description') {
            this.isOpen = true
        }
    }


    // Functions ----

    /**
     * opens and closes fold out
     */
    open():void {
        if(!this.isOpen) {
            this.isOpen = true
        } else {
            this.isOpen = false
        }
    }


}