Skip to content

Commit

Permalink
Revert "feat(component): replaced -> component (#15084)"
Browse files Browse the repository at this point in the history
This reverts commit e73113f.
  • Loading branch information
alisonjoseph authored Nov 14, 2023
1 parent 0b006d6 commit f68b621
Showing 1 changed file with 8 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,7 @@ import React from 'react';
import { CARBON_SIDENAV_ITEMS } from './_utils';
import { usePrefix } from '../../internal/usePrefix';

interface SideNavItemsProps {
/**
* Provide a single icon as the child to `SideNavIcon` to render in the
* container
*/
children: React.ReactNode;

/**
* Provide an optional class to be applied to the containing node
*/
className?: string;

/**
* Property to indicate if the side nav container is open (or not). Use to
* keep local state and styling in step with the SideNav expansion state.
*/
isSideNavExpanded?: boolean;
}

const SideNavItems: React.FC<SideNavItemsProps> = ({
const SideNavItems = ({
className: customClassName,
children,
isSideNavExpanded,
Expand All @@ -40,16 +21,13 @@ const SideNavItems: React.FC<SideNavItemsProps> = ({
const childrenWithExpandedState = React.Children.map(children, (child) => {
if (React.isValidElement(child)) {
// avoid spreading `isSideNavExpanded` to non-Carbon UI Shell children
const childType = child.type as React.ComponentType;
if (childType && childType.displayName) {
return React.cloneElement(child, {
...(CARBON_SIDENAV_ITEMS.includes(childType.displayName)
? {
isSideNavExpanded,
}
: {}),
});
}
return React.cloneElement(child, {
...(CARBON_SIDENAV_ITEMS.includes(child.type?.displayName)
? {
isSideNavExpanded,
}
: {}),
});
}
});
return <ul className={className}>{childrenWithExpandedState}</ul>;
Expand Down

0 comments on commit f68b621

Please sign in to comment.