Skip to content

Commit

Permalink
feat: add "name" prop to componentItem override
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Jan 22, 2024
1 parent 60198ab commit 45bbceb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Override an individual item within the component list.

```tsx copy
const overrides = {
componentList: ({ children }) => <div>{children}</div>,
componentList: ({ name }) => <div>{name}</div>,
};
```

Expand All @@ -17,7 +17,12 @@ const overrides = {
| Prop | Example | Type |
| ----------------------- | ----------- | --------- |
| [`children`](#children) | `<input />` | ReactNode |
| [`name`](#name) | `"Button"` | ReactNode |

### `children`

The default node for the component item.

### `name`

THe name of the component item.
6 changes: 3 additions & 3 deletions packages/core/components/Drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const DrawerItem = ({
index,
}: {
name: string;
children?: (props: { children: ReactNode }) => ReactElement;
children?: (props: { children: ReactNode; name: string }) => ReactElement;
id?: string;
index: number;
}) => {
Expand All @@ -57,15 +57,15 @@ const DrawerItem = ({
const CustomInner = useMemo(
() =>
children ||
(({ children }: { children: ReactNode }) => (
(({ children, name }: { children: ReactNode; name: string }) => (
<div className={getClassNameItem("default")}>{children}</div>
)),
[children]
);

return (
<DrawerDraggable id={resolvedId} index={index}>
<CustomInner>
<CustomInner name={name}>
<div className={getClassNameItem("draggableWrapper")}>
<div className={getClassNameItem("draggable")}>
<div className={getClassNameItem("name")}>{name}</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/types/Overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type Overrides = OverridesGeneric<{
className?: string;
}>;
components: RenderFunc;
componentItem: RenderFunc;
componentItem: RenderFunc<{ children: ReactNode; name: string }>;
outline: RenderFunc;
puck: RenderFunc;
}>;
Expand Down

0 comments on commit 45bbceb

Please sign in to comment.