layer.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import { inject, injectable } from 'inversify';
  3. import { Layer } from '@flowgram.ai/core';
  4. import { domUtils } from '@flowgram.ai/utils';
  5. import { MinimapLayerOptions } from './type';
  6. import { FlowMinimapService } from './service';
  7. import { MinimapRender } from './component';
  8. @injectable()
  9. export class FlowMinimapLayer extends Layer<MinimapLayerOptions> {
  10. public static type = 'FlowMinimapLayer';
  11. @inject(FlowMinimapService) private readonly service: FlowMinimapService;
  12. public readonly node: HTMLElement;
  13. private readonly className = 'gedit-minimap-layer gedit-playground-layer';
  14. constructor() {
  15. super();
  16. this.node = domUtils.createDivWithClass(this.className);
  17. this.node.style.zIndex = '9999';
  18. }
  19. public render(): JSX.Element {
  20. if (this.options.disableLayer) {
  21. return <></>;
  22. }
  23. return (
  24. <MinimapRender
  25. service={this.service}
  26. panelStyles={this.options.panelStyles}
  27. containerStyles={this.options.containerStyles}
  28. inactiveStyle={this.options.inactiveStyle}
  29. />
  30. );
  31. }
  32. }