import React, { FC } from 'react'; import { Button, Field, HorizontalGroup, InlineField, InlineFieldRow } from '@grafana/ui'; import { StandardEditorProps } from '@grafana/data'; import { PanelOptions } from '../models.gen'; import { useObservable } from 'react-use'; import { Subject } from 'rxjs'; import { CanvasEditorOptions } from './elementEditor'; import { Anchor, Placement } from 'app/features/canvas'; import { NumberInput } from 'app/features/dimensions/editors/NumberInput'; const anchors: Array = ['top', 'left', 'bottom', 'right']; const places: Array = ['top', 'left', 'bottom', 'right', 'width', 'height']; export const PlacementEditor: FC> = ({ item }) => { const settings = item.settings; // Will force a rerender whenever the subject changes useObservable(settings?.scene ? settings.scene.moved : new Subject()); if (!settings) { return
Loading...
; } const element = settings.element; if (!element) { return
???
; } const { placement } = element; return (
{anchors.map((a) => ( ))}
<> {places.map((p) => { const v = placement[p]; if (v == null) { return null; } return ( console.log('TODO, edit!!!', p, v)} /> ); })}
); };