all files / addon/components/ el-container.js

0% Statements 0/9
0% Branches 0/8
0% Functions 0/2
0% Lines 0/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                                 
import Component from '@ember/component';
import layout from '../templates/components/el-container';
import {computed, get, set} from "@ember/object";
 
export default Component.extend({
  layout,
  tagName: 'section',
  direction: null,
  classNames: ['el-container'],
  classNameBindings: ['getClassName'],
 
  hasChildToMakeVertical: false,
 
  getClassName: computed('direction', 'hasChildToMakeVertical', function () {
    return  (get(this, 'direction') === 'vertical' || get(this, 'hasChildToMakeVertical')) ? 'is-vertical' : "";
  }),
 
  didRender() {
    const child = this.element.children;
    let foundElements = false;
    for (let i = 0; i < child.length; i++) {
      let c = child[i];
      if(c.dataset.component === 'el-header' || c.dataset.component === 'el-footer' ){
        // set(this, 'hasChildToMakeVertical', true);
        foundElements = true;
        break;
      }
    }
    set(this, 'hasChildToMakeVertical', foundElements);
  }
});