|
| 1 | +import type { ReactNode } from 'react'; |
| 2 | +import type { GameItemInfo } from './game.types.js'; |
| 3 | + |
| 4 | +export interface GridItemContent extends GridItemInfo { |
| 5 | + /** |
| 6 | + * The content to display in the grid item. |
| 7 | + */ |
| 8 | + content: ReactNode; |
| 9 | +} |
| 10 | + |
| 11 | +/** |
| 12 | + * The information shared between the grid item and the grid. |
| 13 | + * For example, to notify when the item's layout or position changes. |
| 14 | + */ |
| 15 | +export interface GridItemInfo { |
| 16 | + itemId: string; |
| 17 | + itemTitle: string; |
| 18 | + isFocused: boolean; |
| 19 | + layout: GridItemLayout; |
| 20 | +} |
| 21 | + |
| 22 | +export interface GridItemConfig { |
| 23 | + /** |
| 24 | + * Info about the game stream that this grid item is for. |
| 25 | + */ |
| 26 | + gameItemInfo: GameItemInfo; |
| 27 | + /** |
| 28 | + * When this item is visible (i.e. added to the grid layout) |
| 29 | + * then these are the grid item ids where to stream this item's content. |
| 30 | + * Usually, this is the item's own id. |
| 31 | + */ |
| 32 | + whenVisibleStreamToItemIds: Array<string>; |
| 33 | + /** |
| 34 | + * When this item is hidden (i.e. removed from the grid layout) |
| 35 | + * then these are the grid item ids where to stream this item's content. |
| 36 | + * Usually, the fallback is the main grid item or empty array. |
| 37 | + */ |
| 38 | + whenHiddenStreamToItemIds: Array<string>; |
| 39 | +} |
| 40 | + |
| 41 | +/** |
| 42 | + * The dimension for the grid where the item may be dragged and resized. |
| 43 | + */ |
| 44 | +export interface GridItemBoundary { |
| 45 | + /** |
| 46 | + * The max height of the grid in pixels. |
| 47 | + */ |
| 48 | + height: number; |
| 49 | + /** |
| 50 | + * The max width of the grid in pixels. |
| 51 | + */ |
| 52 | + width: number; |
| 53 | +} |
| 54 | + |
| 55 | +/** |
| 56 | + * The positional layout for the grid item. |
| 57 | + */ |
| 58 | +export interface GridItemLayout { |
| 59 | + /** |
| 60 | + * The x coordinate for the grid item. |
| 61 | + * The leftmost edge of the grid item. |
| 62 | + */ |
| 63 | + x: number; |
| 64 | + /** |
| 65 | + * The y coordinate for the grid item. |
| 66 | + * The topmost edge of the grid item. |
| 67 | + */ |
| 68 | + y: number; |
| 69 | + /** |
| 70 | + * The width dimension for the grid item. |
| 71 | + * The horizontal length of the grid item. |
| 72 | + * Rightmost edge is `x + width`. |
| 73 | + */ |
| 74 | + width: number; |
| 75 | + /** |
| 76 | + * The height dimension for the grid item. |
| 77 | + * The vertical length of the grid item. |
| 78 | + * Bottommost edge is `y + height`. |
| 79 | + */ |
| 80 | + height: number; |
| 81 | +} |
0 commit comments