import windowIcon from "raw-loader!../../icons/window-maximize-solid.svg";
export const ContainerBlock = (bm, category, label, type) => {
  bm.add(type, {
    label,
    category: category,
    content: {
      type: type,
      classes: ["container"],
    },
    render: ({ model, className }) => `
    <div class="drapcode-compo-seventeen ${className}-label ${className}__drapcode-wrap">
    <div class="drap-on-six">${windowIcon}</div>
    <div class="drapcode-compo-qustion ${className}__info">
      <a
        target="_blank"
        href="https://academy.drapcode.com/docs/app-builder/layout-component-container"
        draggable="false"
      >
        <i class="bem-Svg ${className}__info-fa fa fa-info-circle" title="Check how to use ${label}?"></i>
      </a>
    </div>
    <div class="drapcode-com-one">${model.get("label")}</div>
  </div>
  `,
  });
};

export default (dc, label, type) => {
  const defaultType = dc.getType("default");
  const defaultModel = defaultType.model;
  const defaultView = defaultType.view;
  dc.addType(type, {
    model: defaultModel.extend(
      {
        defaults: {
          ...defaultModel.prototype.defaults,
          "custom-name": label,
          tagName: "div",
          droppable: true,
          resizable: true,
          traits: [
            {
              type: "class_select",
              options: [
                { value: "container", name: "Fixed (fixed with of n pixels)" },
                {
                  value: "container-fluid",
                  name: "Fluid (100% width of parent element)",
                },
              ],
              label: "Width",
            },
          ].concat(defaultModel.prototype.defaults.traits),
        },
      },
      {
        isComponent(el) {
          if (
            el &&
            el.classList &&
            (el.classList.contains("container") ||
              el.classList.contains("container-fluid"))
          ) {
            return { type };
          }
        },
      }
    ),
    view: defaultView,
  });
};
