-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6572 from storybooks/add/addon-contexts-tests
Addon-contexts improvements: bug-fixing, testing, typing
- Loading branch information
Showing
27 changed files
with
557 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,36 @@ | ||
import React from 'react'; | ||
import React, { ComponentProps } from 'react'; | ||
import { Icons, IconButton, WithTooltip } from '@storybook/components'; | ||
import { ToolBarMenuOptions } from './ToolBarMenuOptions'; | ||
import { TToolBarMenu } from '../@types'; | ||
import { ContextNode, FCNoChildren } from '../types'; | ||
|
||
export const ToolBarMenu: TToolBarMenu = ({ | ||
type ToolBarMenu = FCNoChildren<{ | ||
icon: ContextNode['icon']; | ||
title: ContextNode['title']; | ||
active: boolean; | ||
expanded: boolean; | ||
setExpanded: (state: boolean) => void; | ||
optionsProps: ComponentProps<typeof ToolBarMenuOptions>; | ||
}>; | ||
|
||
export const ToolBarMenu: ToolBarMenu = ({ | ||
icon, | ||
title, | ||
active, | ||
expanded, | ||
setExpanded, | ||
optionsProps, | ||
}) => ( | ||
<WithTooltip | ||
closeOnClick | ||
trigger="click" | ||
placement="top" | ||
tooltipShown={expanded} | ||
onVisibilityChange={setExpanded} | ||
tooltip={<ToolBarMenuOptions {...optionsProps} />} | ||
> | ||
<IconButton active={active} title={title}> | ||
<Icons icon={icon} /> | ||
</IconButton> | ||
</WithTooltip> | ||
); | ||
}) => | ||
icon ? ( | ||
<WithTooltip | ||
closeOnClick | ||
trigger="click" | ||
placement="top" | ||
tooltipShown={expanded} | ||
onVisibilityChange={setExpanded} | ||
tooltip={<ToolBarMenuOptions {...optionsProps} />} | ||
> | ||
<IconButton active={active} title={title}> | ||
<Icons icon={icon} /> | ||
</IconButton> | ||
</WithTooltip> | ||
) : null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import React from 'react'; | ||
import { createAddonDecorator } from '../index'; | ||
import { createAddonDecorator, Render } from '../index'; | ||
import { addonContextsAPI } from '../api'; | ||
import { Renderer } from '../../@types'; | ||
|
||
/** | ||
* This is the framework specific bindings for React. | ||
* '@storybook/react' expects the returning object from a decorator to be a 'React Element' (vNode). | ||
*/ | ||
export const renderReact: Renderer = (nodes, props, next) => { | ||
export const renderReact: Render<React.ReactElement> = (contextNodes, propsMap, getStoryVNode) => { | ||
const { getRendererFrom } = addonContextsAPI(); | ||
return getRendererFrom(React.createElement)(nodes, props, next); | ||
return getRendererFrom(React.createElement)(contextNodes, propsMap, getStoryVNode); | ||
}; | ||
|
||
export const withContexts = createAddonDecorator(renderReact); |
Oops, something went wrong.