import windowIcon from "raw-loader!../../icons/window-maximize-solid.svg";
export const RowBlock = (bm, category, label, type) => {
  bm.add(type, {
    label,
    category: category,
    content: {
      type: type,
      classes: ["row"],
    },
    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-row-column-break#row"
          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: Object.assign({}, defaultModel.prototype.defaults, {
          "custom-name": label,
          tagName: "div",
          draggable:
            ".container, .container-fluid, .data-group, .data-list, .jumbotron, form, form *",
          resizable: 1,
          droppable: true,
          traits: [
            {
              type: "class_select",
              options: [
                { value: "", name: "Yes" },
                { value: "no-gutters", name: "No" },
              ],
              label: "Gutters?",
            },
          ].concat(defaultModel.prototype.defaults.traits),
        }),
      },
      {
        isComponent(el) {
          if (el && el.classList && el.classList.contains("row")) {
            return { type };
          }
        },
      }
    ),
    view: defaultView,
  });
};
