-
Notifications
You must be signed in to change notification settings - Fork 583
Expand file tree
/
Copy pathGroup.tsx
More file actions
34 lines (31 loc) · 931 Bytes
/
Group.tsx
File metadata and controls
34 lines (31 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React, { isValidElement } from "react";
import type { SkiaProps } from "../processors";
import type { GroupProps } from "../../dom/types";
import type { ChildrenProps } from "../../dom/types/Common";
export interface PublicGroupProps extends Omit<GroupProps, "layer"> {
layer?: GroupProps["layer"] | ChildrenProps["children"];
}
export const Group = ({
layer,
backdropFilter,
saveLayerFlags,
...props
}: SkiaProps<PublicGroupProps>) => {
if (isValidElement(layer) && typeof layer === "object") {
return (
// keep the saveLayerFlags on whichever node triggers saveLayer
<skLayer backdropFilter={backdropFilter} saveLayerFlags={saveLayerFlags}>
{layer}
<skGroup {...props} />
</skLayer>
);
}
return (
<skGroup
layer={layer as GroupProps["layer"]}
backdropFilter={backdropFilter}
saveLayerFlags={saveLayerFlags}
{...props}
/>
);
};