Skip to content

Commit dcf8000

Browse files
authored
docs(groups.md): minor fixes (#97)
1 parent df6ed69 commit dcf8000

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

docs/blocks/groups.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ There are two ways to work with groups:
1111
Use this when you want groups to update automatically based on block properties. For example, you can group blocks by their color or type.
1212

1313
```typescript
14-
import { Graph, GroupsList } from '@gravity-ui/graph';
14+
import { BlockGroups, Graph, Group } from '@gravity-ui/graph';
15+
16+
const MyGroup = Group.define({
17+
style: {
18+
background: 'rgba(0, 200, 200, 0.2)',
19+
border: 'rgba(200, 200, 0, 0.2)',
20+
},
21+
});
1522

1623
// Make groups automatically
17-
const AutoGroups = GroupsList.withBlockGrouping({
24+
const AutoGroups = BlockGroups.withBlockGrouping({
1825
// Put blocks in groups
1926
groupingFn: (blocks) => {
2027
const groups = {};
@@ -29,9 +36,7 @@ const AutoGroups = GroupsList.withBlockGrouping({
2936
mapToGroups: (groupId, { rect }) => ({
3037
id: groupId,
3138
rect,
32-
style: {
33-
background: "rgba(0, 100, 200, 0.1)"
34-
}
39+
component: MyGroup,
3540
})
3641
});
3742

@@ -44,16 +49,16 @@ graph.addLayer(AutoGroups, {
4449

4550
### 2. Manual Groups
4651

47-
Use direct `GroupsList` methods when you need manual control over groups. This approach is useful when:
52+
Use direct `BlockGroups` methods when you need manual control over groups. This approach is useful when:
4853
- Groups are created/updated based on user actions
4954
- You need custom group management logic
5055
- Groups are independent of block properties
5156

5257
```typescript
53-
import { Graph, GroupsList } from '@gravity-ui/graph';
58+
import { Graph, BlockGroups } from '@gravity-ui/graph';
5459

5560
// Add groups to graph
56-
const groups = graph.addLayer(GroupsList, {
61+
const groups = graph.addLayer(BlockGroups, {
5762
draggable: true,
5863
});
5964

@@ -82,10 +87,10 @@ groups.updateGroups([
8287
### Creating a Group
8388

8489
```typescript
85-
import { Graph, GroupsList } from '@gravity-ui/graph';
90+
import { Graph, BlockGroups } from '@gravity-ui/graph';
8691

8792
// Add fixed area groups to graph
88-
const areas = graph.addLayer(GroupsList, {
93+
const areas = graph.addLayer(BlockGroups, {
8994
draggable: false, // areas cannot be moved
9095
});
9196

@@ -146,7 +151,7 @@ You can control how groups work:
146151

147152
## API Reference
148153

149-
### GroupsList Methods
154+
### BlockGroups Methods
150155
```typescript
151156
// Create or replace all groups
152157
setGroups(groups: TGroup[]): void;
@@ -175,10 +180,10 @@ updateGroups(groups: TGroup[]): void;
175180

176181
### Custom Group with Extended Properties
177182

178-
You can create your own group type with additional properties. The key is to pass your custom group component to `GroupsList`. Here's a complete example:
183+
You can create your own group type with additional properties. The key is to pass your custom group component to `BlockGroups`. Here's a complete example:
179184

180185
```typescript
181-
import { Graph, GroupsList, Group } from '@gravity-ui/graph';
186+
import { Graph, BlockGroups, Group } from '@gravity-ui/graph';
182187

183188
// 1. Define extended group type
184189
interface ExtendedTGroup extends TGroup {
@@ -211,7 +216,7 @@ class CustomGroup extends Group<ExtendedTGroup> {
211216
}
212217

213218
// 3. Create groups with extended properties
214-
const groups = graph.addLayer(GroupsList, {
219+
const groups = graph.addLayer(BlockGroups, {
215220
draggable: false,
216221
groupComponent: CustomGroup, // Use our custom component
217222
});

0 commit comments

Comments
 (0)