@thangdevalone/meet-layout-grid-core 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @thangdevalone/meet-layout-grid-core
2
2
 
3
- Grid calculation logic for meet-layout-grid. No dependencies, works with any framework.
3
+ Framework-agnostic grid calculation engine for meet-layout-grid. Zero dependencies.
4
+
5
+ > For full documentation, examples, and API reference, see the [main README](https://github.com/thangdevalone/meet-layout-grid#readme).
4
6
 
5
7
  ## Installation
6
8
 
@@ -11,79 +13,55 @@ npm install @thangdevalone/meet-layout-grid-core
11
13
  ## Usage
12
14
 
13
15
  ```typescript
14
- import { createMeetGrid, createGrid } from '@thangdevalone/meet-layout-grid-core'
15
-
16
- // Simple grid
17
- const grid = createGrid({
18
- dimensions: { width: 800, height: 600 },
19
- count: 6,
20
- aspectRatio: '16:9',
21
- gap: 8,
22
- })
23
-
24
- console.log(`Item size: ${grid.width}x${grid.height}`)
25
- console.log(`Grid: ${grid.cols} cols, ${grid.rows} rows`)
26
-
27
- for (let i = 0; i < 6; i++) {
28
- const { top, left } = grid.getPosition(i)
29
- console.log(`Item ${i}: top=${top}, left=${left}`)
30
- }
16
+ import { createMeetGrid } from '@thangdevalone/meet-layout-grid-core'
31
17
 
32
- // Meet-style grid with layout modes
33
- const meetGrid = createMeetGrid({
18
+ const grid = createMeetGrid({
34
19
  dimensions: { width: 800, height: 600 },
35
20
  count: 6,
36
21
  aspectRatio: '16:9',
37
22
  gap: 8,
38
- layoutMode: 'sidebar', // 'gallery' | 'spotlight' | 'sidebar'
39
- sidebarPosition: 'bottom', // 'left' | 'right' | 'top' | 'bottom'
23
+ layoutMode: 'gallery',
40
24
  pinnedIndex: 0,
25
+ othersPosition: 'bottom',
41
26
  })
42
27
 
43
28
  for (let i = 0; i < 6; i++) {
44
- const { width, height } = meetGrid.getItemDimensions(i)
45
- const isMain = meetGrid.isMainItem(i)
46
- console.log(`Item ${i}: ${width}x${height}, main: ${isMain}`)
29
+ const { top, left } = grid.getPosition(i)
30
+ const { width, height } = grid.getItemDimensions(i)
31
+ const isMain = grid.isMainItem(i)
32
+ console.log(`Item ${i}: ${width}x${height} at (${left}, ${top}), main: ${isMain}`)
47
33
  }
48
34
  ```
49
35
 
50
- ## API
51
-
52
- ### `createGrid(options)`
53
-
54
- Basic responsive grid.
55
-
56
- **Options:**
57
- - `dimensions: { width, height }` Container size
58
- - `count: number` Number of items
59
- - `aspectRatio: string` e.g. `"16:9"`
60
- - `gap: number` Gap between items (px)
61
-
62
- **Returns:**
63
- - `width`, `height` — Item size
64
- - `rows`, `cols` — Grid shape
65
- - `getPosition(index): { top, left }`
66
-
67
- ### `createMeetGrid(options)`
68
-
69
- Meet-style grid with layout modes.
70
-
71
- **Extra options:**
72
- - `layoutMode: 'gallery' | 'spotlight' | 'sidebar'`
73
- - `pinnedIndex?: number` — Main participant (enables pin mode in gallery, or main tile in sidebar)
74
- - `sidebarPosition?: 'left' | 'right' | 'top' | 'bottom'`
75
- - `sidebarRatio?: number` 0–1
76
-
77
- **Extra returns:**
78
- - `layoutMode`
79
- - `getItemDimensions(index): { width, height }`
80
- - `isMainItem(index): boolean`
81
-
82
- ## Layout modes
83
-
84
- - **gallery** — Same-size tiles in a grid (use `pinnedIndex` for pin mode)
85
- - **spotlight** — One participant only
86
- - **sidebar** — Main area + thumbnail strip (use `sidebarPosition: 'bottom'` for speaker-like layout)
36
+ ## Exports
37
+
38
+ ### Functions
39
+
40
+ | Function | Description |
41
+ | ------------------------------- | -------------------------------------------- |
42
+ | `createMeetGrid(options)` | Full meet-style grid with layout modes |
43
+ | `createGrid(options)` | Basic responsive grid (no layout modes) |
44
+ | `getAspectRatio(ratio)` | Parse aspect ratio string to numeric value |
45
+ | `getGridItemDimensions(…)` | Get dimensions for a specific grid item |
46
+ | `createGridItemPositioner(…)` | Create a reusable position calculator |
47
+ | `getSpringConfig(preset)` | Get spring animation config from preset name |
48
+ | `calculateContentDimensions(…)` | Calculate content size within a cell |
49
+
50
+ ### Types
51
+
52
+ | Type | Description |
53
+ | ------------------- | ------------------------------------------ |
54
+ | `MeetGridOptions` | Options for `createMeetGrid` |
55
+ | `MeetGridResult` | Return type of `createMeetGrid` |
56
+ | `GridOptions` | Options for `createGrid` |
57
+ | `GridResult` | Return type of `createGrid` |
58
+ | `GridDimensions` | `{ width, height }` |
59
+ | `Position` | `{ top, left }` |
60
+ | `LayoutMode` | `'gallery' \| 'spotlight'` |
61
+ | `ItemAspectRatio` | `string \| 'auto'` |
62
+ | `ContentDimensions` | `{ width, height, offsetTop, offsetLeft }` |
63
+ | `PaginationInfo` | Pagination state details |
64
+ | `SpringPreset` | Animation preset names |
87
65
 
88
66
  ## License
89
67