import {IContent} from '../interfaces/components/IContent';
import {IBox} from '../interfaces/components/IBox';

export class Content implements IContent {

    protected container:HTMLElement;

    protected boxes:IBox[];

    protected boxCreator:()=>IBox;

    public setBoxCreator(callback:()=>IBox)
    {
        this.boxCreator = callback;
    }

    public init(container:HTMLElement)
    {
        this.container = container;
        this.boxes = [];
        let boxElements = this.container.querySelectorAll('.js-box');
        boxElements.forEach((el:HTMLElement, i:number)=>{
            let boxComponent = this.boxCreator();
            boxComponent.init(el);
            this.boxes.push(boxComponent);
        });
    }

}