diff --git a/electron/renderer/components/grid/grid-item.tsx b/electron/renderer/components/grid/grid-item.tsx index c43dfd69..59b1c17d 100644 --- a/electron/renderer/components/grid/grid-item.tsx +++ b/electron/renderer/components/grid/grid-item.tsx @@ -24,6 +24,7 @@ import { useCallback, useMemo, useRef } from 'react'; export interface GridItemMetadata { itemId: string; + title: string; isFocused: boolean; x: number; y: number; @@ -105,13 +106,14 @@ export const GridItem: React.FC = ( const getItemMetadata = useCallback(() => { return { itemId, + title: titleBarText, isFocused, x: x.get(), y: y.get(), width: width.get(), height: height.get(), }; - }, [itemId, isFocused, x, y, width, height]); + }, [itemId, titleBarText, isFocused, x, y, width, height]); // Handle when the user clicks the close button in the title bar. const onCloseClick = useCallback(() => { diff --git a/electron/renderer/pages/grid.tsx b/electron/renderer/pages/grid.tsx index 3416755f..d677f385 100644 --- a/electron/renderer/pages/grid.tsx +++ b/electron/renderer/pages/grid.tsx @@ -356,6 +356,238 @@ const GridPage: React.FC = (): ReactNode => { const [gridWidthRef, { width: gridWidth }] = useMeasure(); const gridHeight = windowSize.height - bottomBarSize.height - 40; + // TODO read layout from storage to detmine the items to show on the grid + // TODO when a user adds an item, we subscribe to that event/callback and update the injected list + // TODO when a user removes an item, we subscribe to that event/callback and update the injected list + // In short, the Grid cmp should not determine what items it has, it receives the items and shows them + const gridItems = [ + { + itemId: 'room', + title: 'Room', + content: ( + + ), + }, + { + itemId: 'experience', + title: 'Experience', + content: ( + + ), + }, + // { + // itemId: 'percWindow', + // title: 'Spells', + // content: ( + // + // ), + // }, + // { + // itemId: 'inv', + // title: 'Inventory', + // content: ( + // + // ), + // }, + // { + // itemId: 'familiar', + // title: 'Familiar', + // content: ( + // + // ), + // }, + // { + // itemId: 'thoughts', + // title: 'Thoughts', + // content: ( + // + // ), + // }, + // { + // itemId: 'combat', + // title: 'Combat', + // content: ( + // + // ), + // }, + // { + // itemId: 'assess', + // title: 'Assess', + // content: ( + // + // ), + // }, + // { + // itemId: 'logons', + // title: 'Arrivals', + // content: ( + // + // ), + // }, + // { + // itemId: 'death', + // title: 'Deaths', + // content: ( + // + // ), + // }, + // { + // itemId: 'atmospherics', + // title: 'Atmospherics', + // content: ( + // + // ), + // }, + // { + // itemId: 'chatter', + // title: 'Chatter', + // content: ( + // + // ), + // }, + // { + // itemId: 'conversation', + // title: 'Conversation', + // content: ( + // + // ), + // }, + // { + // itemId: 'whispers', + // title: 'Whispers', + // content: ( + // + // ), + // }, + // { + // itemId: 'talk', + // title: 'Talk', + // content: ( + // + // ), + // }, + // { + // itemId: 'ooc', + // title: 'OOC', + // content: ( + // + // ), + // }, + // { + // itemId: 'group', + // title: 'Group', + // content: ( + // + // ), + // }, + { + itemId: 'main', + title: 'Main', + content: ( + + ), + }, + ]; + + /* + interface GridItemStreamConfig { + itemId: string; // 'room' + title: string; // 'Room' + whenVisibleStreamToItemIds: string[]; // ['room'], always streams to itself, may also stream elsewhere + whenHiddenStreamToItemIds: string[]; // ['main'], default streams nowhere else, may also stream elsewhere + } + + // when loading the layout... + // drop from layout any item without a config anymore + configItemIds = gridItemStreamConfigs.map((config) => config.itemId) + layout.items = layout.items.filter((item) => configItemIds.includes(item.itemId)) + + layoutItemIds = layout.items.map((item) => item.itemId) + itemIdToStreamIdsMap = { + // for each gridItemStreamConfig in gridItemStreamConfigs + // if layoutItemIds.includes(gridItemStreamConfig.itemId) + // for each itemId in gridItemStreamConfig.whenVisibleStreamToItemIds + // itemIdToStreamIdsMap[itemId].push(gridItemStreamConfig.itemId) + // else + // for each itemId in gridItemStreamConfig.whenHiddenStreamToItemIds + // itemIdToStreamIdsMap[itemId].push(gridItemStreamConfig.itemId) + } + + for each item in layout.items // Array + { + metadata: { + ...item, // itemId, title, isFocused, x, y, width, height + title: gridItemStreamConfigs[item.itemId].title, // 'Inventory' + }, + content: ( + + ), + } + + + { + itemId: 'room', + title: 'Room', + content: ( + + ), + }, + */ + return ( {
- ), - }, - { - itemId: 'experience', - title: 'Experience', - content: ( - - ), - }, - // { - // itemId: 'percWindow', - // title: 'Spells', - // content: ( - // - // ), - // }, - // { - // itemId: 'inv', - // title: 'Inventory', - // content: ( - // - // ), - // }, - // { - // itemId: 'familiar', - // title: 'Familiar', - // content: ( - // - // ), - // }, - // { - // itemId: 'thoughts', - // title: 'Thoughts', - // content: ( - // - // ), - // }, - // { - // itemId: 'combat', - // title: 'Combat', - // content: ( - // - // ), - // }, - // { - // itemId: 'assess', - // title: 'Assess', - // content: ( - // - // ), - // }, - // { - // itemId: 'logons', - // title: 'Arrivals', - // content: ( - // - // ), - // }, - // { - // itemId: 'death', - // title: 'Deaths', - // content: ( - // - // ), - // }, - // { - // itemId: 'atmospherics', - // title: 'Atmospherics', - // content: ( - // - // ), - // }, - // { - // itemId: 'chatter', - // title: 'Chatter', - // content: ( - // - // ), - // }, - // { - // itemId: 'conversation', - // title: 'Conversation', - // content: ( - // - // ), - // }, - // { - // itemId: 'whispers', - // title: 'Whispers', - // content: ( - // - // ), - // }, - // { - // itemId: 'talk', - // title: 'Talk', - // content: ( - // - // ), - // }, - // { - // itemId: 'ooc', - // title: 'OOC', - // content: ( - // - // ), - // }, - // { - // itemId: 'group', - // title: 'Group', - // content: ( - // - // ), - // }, - { - itemId: 'main', - title: 'Main', - content: ( - - ), - }, - ]} />