Skip to content

Commit

Permalink
chore: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Oct 26, 2023
1 parent ec985e3 commit c8c02fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/core/components/ComponentList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ const getClassNameItem = getClassNameFactory("ComponentListItem", styles);
const ComponentListItem = ({
component,
index,
id,
}: {
component: string;
index: number;
id: string;
}) => {
return (
<div className={getClassNameItem()}>
<Draggable
key={component}
id={component}
id={id}
index={index}
showShadow
disableAnimations
Expand Down Expand Up @@ -102,6 +104,7 @@ const ComponentList = ({
key={componentKey}
component={componentKey}
index={i}
id={componentKey}
/>
);
})}
Expand Down
4 changes: 3 additions & 1 deletion packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ export function Puck({
droppedItem.source.droppableId.startsWith("component-list") &&
droppedItem.destination
) {
const [_, componentId] = droppedItem.draggableId.split("::");

dispatch({
type: "insert",
componentType: droppedItem.draggableId,
componentType: componentId || droppedItem.draggableId,
destinationIndex: droppedItem.destination!.index,
destinationZone: droppedItem.destination.droppableId,
});
Expand Down
10 changes: 8 additions & 2 deletions packages/core/lib/use-component-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const useComponentList = (config: Config, ui: UiState) => {
const [componentList, setComponentList] = useState<ReactNode[]>();

useEffect(() => {
if (ui.componentList) {
if (Object.keys(ui.componentList).length > 0) {
const matchedComponents: string[] = [];

let _componentList: ReactNode[];
Expand All @@ -31,6 +31,7 @@ export const useComponentList = (config: Config, ui: UiState) => {
key={componentName}
component={componentName as string}
index={i}
id={`${categoryKey}::${componentName}`}
/>
);
})}
Expand All @@ -49,13 +50,18 @@ export const useComponentList = (config: Config, ui: UiState) => {
ui.componentList.other?.visible !== false
) {
_componentList.push(
<ComponentList id="other" key="other" title={"Other"}>
<ComponentList
id="other"
key="other"
title={ui.componentList.other?.title || "Other"}
>
{remainingComponents.map((componentName, i) => {
return (
<ComponentList.Item
key={componentName}
component={componentName as string}
index={i}
id={`other::${componentName}`}
/>
);
})}
Expand Down

0 comments on commit c8c02fd

Please sign in to comment.