Skip to content

Commit

Permalink
Merge pull request #19959 from storybookjs/tom/sb-773-docs2-toolbar-i…
Browse files Browse the repository at this point in the history
…tems-changed-in-docs-mode

Return to filtering toolbars in docs mode, but don't filter menu
  • Loading branch information
tmeasday authored Dec 2, 2022
2 parents c244467 + e095a5b commit 2d4150c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
22 changes: 1 addition & 21 deletions code/ui/blocks/src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import type { FC, MouseEvent } from 'react';
import React, { Fragment } from 'react';
import { styled } from '@storybook/theming';
import {
FlexBar,
Icons,
IconButton,
IconButtonSkeleton,
getStoryHref,
} from '@storybook/components';
import { FlexBar, Icons, IconButton, IconButtonSkeleton } from '@storybook/components';

interface ZoomProps {
zoom: (val: number) => void;
Expand Down Expand Up @@ -64,17 +58,6 @@ const Zoom: FC<ZoomProps> = ({ zoom, resetZoom }) => (
</>
);

const Eject: FC<EjectProps> = ({ baseUrl, storyId }) => (
<IconButton
key="opener"
href={getStoryHref(baseUrl, storyId)}
target="_blank"
title="Open canvas in new tab"
>
<Icons icon="share" />
</IconButton>
);

const Bar = styled(FlexBar)({
position: 'absolute',
left: 0,
Expand All @@ -99,8 +82,5 @@ export const Toolbar: FC<ToolbarProps> = ({
<Zoom {...{ zoom, resetZoom }} />
)}
</Fragment>
<Fragment key="right">
{storyId && (isLoading ? <IconButtonSkeleton /> : <Eject {...{ storyId, baseUrl }} />)}
</Fragment>
</Bar>
);
2 changes: 1 addition & 1 deletion code/ui/manager/src/components/preview/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const useTools = (
);

return useMemo(() => {
return entry?.type === 'story'
return ['story', 'docs'].includes(entry?.type)
? filterTools(tools, toolsExtra, tabs, {
viewMode,
entry,
Expand Down
2 changes: 1 addition & 1 deletion code/ui/manager/src/components/preview/tools/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const menuMapper = ({ api, state }: Combo) => ({
export const menuTool: Addon = {
title: 'menu',
id: 'menu',
match: ({ viewMode }) => viewMode === 'story',
match: ({ viewMode }) => ['story', 'docs'].includes(viewMode),
render: () => (
<Consumer filter={menuMapper}>
{({ isVisible, toggle, singleStory }) =>
Expand Down

0 comments on commit 2d4150c

Please sign in to comment.