Skip to main content

Navigator

<Navigator /> component is a canvas widget to display a minimap of the diagram contents.

Result
Loading...
Live Editor
function Example() {
  const {defaultLayout} = Reactodia.useWorker(Layouts);

  const {onMount} = Reactodia.useLoadedWorkspace(async ({context, signal}) => {
    const {model, view, performLayout} = context;

    const alice = model.createElement('urn:example:Alice');
    const bob = model.createElement('urn:example:Bob');
    bob.setData({...bob.data, types: ['urn:example:Balloon']});
    model.createLinks({
      sourceId: alice.iri,
      targetId: bob.iri,
      linkTypeId: 'urn:example:knows',
      properties: {},
    });

    await performLayout({signal});
  }, []);

  return (
    <div className='reactodia-live-editor'>
      <Reactodia.Workspace ref={onMount}
        defaultLayout={defaultLayout}>
        <Reactodia.DefaultWorkspace
          menu={null}
          search={null}
          actions={null}
          navigator={{
            expanded: true,
            viewportFill: 'lightgreen',
            viewportStroke: {color: 'green'},
          }}
          canvas={{
            elementTemplateResolver: types =>
              types.includes('urn:example:Balloon')
                ? Reactodia.RoundTemplate : undefined,
          }}
        />
      </Reactodia.Workspace>
    </div>
  );
}

Styles

The component look can be customized using the following CSS properties (see design system for more information):

PropertyDescription
--reactodia-navigator-background-fillBackground color on the minimap outside the scrollable pane area.
--reactodia-navigator-scrollable-pane-fillBackground color on the minimap for the scrollable pane area.
--reactodia-navigator-viewport-fillBackground color on the minimap for the viewport area.
--reactodia-navigator-viewport-stroke-colorStroke color for the viewport area border.
--reactodia-navigator-viewport-stroke-widthStroke width for the viewport area border.
--reactodia-navigator-viewport-stroke-dashStroke dash for the viewport area border.
--reactodia-navigator-overflow-stroke-colorStroke color for the viewport area overflow border (displayed when the viewport is cutoff at the minimap border).
--reactodia-navigator-overflow-stroke-widthStroke width for the viewport area overflow border (displayed when the viewport is cutoff at the minimap border).
--reactodia-navigator-overflow-stroke-dashStroke dash for the viewport area overflow border (displayed when the viewport is cutoff at the minimap border).