import { h, HarmajaOutput } from "harmaja" import * as _ from "lodash" import * as L from "lonna" import { Color, isShapedItem, Item, NoteShape, ShapedItem } from "../../../../common/src/domain" import { ShapeDiamondIcon, ShapeRectIcon, ShapeRoundIcon, ShapeSquareIcon } from "../../components/Icons" import { black, selectedColor } from "../../components/UIColors" import { SubmenuProps } from "./ContextMenuView" const shapes = { square: ShapeSquareIcon, round: ShapeRoundIcon, rect: ShapeRectIcon, diamond: ShapeDiamondIcon, } type ShapeIcon = (c: Color, f?: Color) => HarmajaOutput type ShapeIconAndId = { id: NoteShape; svg: ShapeIcon } const shapeSymbols: ShapeIconAndId[] = Object.entries(shapes).map(([id, svg]) => ({ id: id as NoteShape, svg })) export function getShapeIcon(item: Item): ShapeIcon { return shapes[isShapedItem(item) ? item.shape || "square" : "square"] } export function shapesSubMenu({ board, focusedItems, dispatch }: SubmenuProps) { const shapedItems = L.view(focusedItems, (items) => items.items.filter(isShapedItem)) const anyShaped = L.view(shapedItems, (items) => items.length > 0) const currentShape = L.view(shapedItems, (items) => _.uniq(items.map((item) => item.shape)).length > 1 ? undefined : items[0]?.shape, ) return L.view(anyShaped, (anyShaped) => { return !anyShaped ? [] : [