Skip to content

Commit

Permalink
Merge pull request #25587 from storybookjs/charles-fix-menu-icon-sidebar
Browse files Browse the repository at this point in the history
UI: Fix menu icon on the sidebar
  • Loading branch information
valentinpalkovic authored Jan 15, 2024
2 parents c356639 + 352c00a commit 06d6098
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions code/ui/manager/src/components/sidebar/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,12 @@ import React, { useMemo, useState } from 'react';
import { styled } from '@storybook/theming';
import { transparentize } from 'polished';
import type { Button, TooltipLinkListLink } from '@storybook/components';
import { WithTooltip, TooltipLinkList, Icons, IconButton } from '@storybook/components';
import { WithTooltip, TooltipLinkList, IconButton } from '@storybook/components';
import { CloseIcon, CogIcon } from '@storybook/icons';
import { useLayout } from '../layout/LayoutProvider';

export type MenuList = ComponentProps<typeof TooltipLinkList>['links'];

const sharedStyles = {
height: 10,
width: 10,
marginLeft: -5,
marginRight: -5,
display: 'block',
};

const Icon = styled(Icons)(sharedStyles, ({ theme }) => ({
color: theme.color.secondary,
}));

export const SidebarIconButton: FC<ComponentProps<typeof Button> & { highlighted: boolean }> =
styled(IconButton)<
ComponentProps<typeof Button> & {
Expand Down Expand Up @@ -64,28 +52,6 @@ const MenuButtonGroup = styled.div({
gap: 4,
});

const Img = styled.img(sharedStyles);
const Placeholder = styled.div(sharedStyles);

export interface ListItemIconProps {
icon?: ComponentProps<typeof Icons>['icon'];
imgSrc?: string;
}

/**
* @deprecated Please use `Icons` from `@storybook/components` instead
* Component will be removed in SB 8.0
*/
export const MenuItemIcon = ({ icon, imgSrc }: ListItemIconProps) => {
if (icon) {
return <Icon icon={icon} />;
}
if (imgSrc) {
return <Img src={imgSrc} alt="image" />;
}
return <Placeholder />;
};

type ClickHandler = TooltipLinkListLink['onClick'];

const SidebarMenuList: FC<{
Expand All @@ -102,7 +68,7 @@ const SidebarMenuList: FC<{
onHide();
}) as ClickHandler,
}));
}, [menu]);
}, [menu, onHide]);
return <TooltipLinkList links={links} />;
};

Expand Down

0 comments on commit 06d6098

Please sign in to comment.