Skip to content

Latest commit

 

History

History

plugin-merkur

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@ima/plugin-merkur

The @ima/plugin-merkur is for easy integration merkur widget to ima application.

Instalace

npm install @ima/plugin-merkur --save
// /app/build.js

var vendors = {
    common: [
      '@ima/plugin-merkur'
    ]
};

Usage

// /app/page/home/HomeController
import { AbstractController } from '@ima/core';
import { MerkurResource } from '@ima/plugin-merkur';

class HomeController extends AbstractController {
  /** @type {import('@ima/core').Dependencies} */
  static get $dependencies() {
    return [MerkurResource];
  }

  constructor(merkurResource) {
    super();

    this._merkurResource = merkurResource;
  }

  load() {
    const data = {
      containerSelector: '.widget__container',
      // When using merkur slot
      slot: {
        headline: {
          containerSelector: '.widget__headline-slot'
        }
      }
    };

    const widgetProperties = this._merkurResource
      .get('http://localhost:4444/widget', data)
      .then((response) => response.body);


    return {
      widgetProperties
    }
  }
}

// /app/page/home/HomeView
import React from 'react';
import { MerkurWidget } from '@merkur/integration-react';

class HomeView extends React.Component {
  render() {
    const { widgetProperties } = this.props;

    return (
      <div>
        <MerkurWidget widgetProperties={widgetProperties}>
          <div>Loading phrase</div>
        </MerkurWidget>
      </div>
    );
  }
}