diff --git a/addons/docs/src/blocks/Anchor.tsx b/addons/docs/src/blocks/Anchor.tsx index 7ed1160cfd74..adabdc7dee72 100644 --- a/addons/docs/src/blocks/Anchor.tsx +++ b/addons/docs/src/blocks/Anchor.tsx @@ -4,8 +4,11 @@ export const anchorBlockIdFromId = (storyId: string) => `anchor--${storyId}`; export interface AnchorProps { storyId: string; + className?: string; } -export const Anchor: FC = ({ storyId, children }) => ( -
{children}
+export const Anchor: FC = ({ storyId, children, className }) => ( +
+ {children} +
); diff --git a/addons/docs/src/blocks/ArgsTable.tsx b/addons/docs/src/blocks/ArgsTable.tsx index 7b70859ffd82..d21dde90cb5a 100644 --- a/addons/docs/src/blocks/ArgsTable.tsx +++ b/addons/docs/src/blocks/ArgsTable.tsx @@ -24,6 +24,7 @@ type PropDescriptor = string[] | RegExp; interface BaseProps { include?: PropDescriptor; exclude?: PropDescriptor; + className?: string; } type OfProps = BaseProps & { @@ -146,7 +147,7 @@ export const StoryTable: FC< parameters: { argTypes }, storyStore, } = context; - const { story, component, subcomponents, showComponent, include, exclude } = props; + const { story, component, subcomponents, showComponent, include, exclude, className } = props; let storyArgTypes; try { let storyId; @@ -195,18 +196,18 @@ export const StoryTable: FC< if (subcomponents) { tabs = addComponentTabs(tabs, subcomponents, context, include, exclude); } - return ; + return ; } catch (err) { - return ; + return ; } }; export const ComponentsTable: FC = (props) => { const context = useContext(DocsContext); - const { components, include, exclude } = props; + const { components, include, exclude, className } = props; const tabs = addComponentTabs({}, components, context, include, exclude); - return ; + return ; }; export const ArgsTable: FC = (props) => { @@ -215,12 +216,19 @@ export const ArgsTable: FC = (props) => { parameters: { subcomponents }, } = context; - const { include, exclude, components } = props as ComponentsProps; + const { include, exclude, components, className } = props as ComponentsProps; const { story } = props as StoryProps; const main = getComponent(props, context); if (story) { - return ; + return ( + + ); } if (!components && !subcomponents) { @@ -230,17 +238,24 @@ export const ArgsTable: FC = (props) => { } catch (err) { mainProps = { error: err.message }; } - return ; + return ; } if (components) { - return ; + return ( + + ); } const mainLabel = getComponentName(main); return ( ); @@ -248,4 +263,5 @@ export const ArgsTable: FC = (props) => { ArgsTable.defaultProps = { story: PRIMARY_STORY, + className: 'sbdocs sbdocs-argsTable', }; diff --git a/addons/docs/src/blocks/Description.tsx b/addons/docs/src/blocks/Description.tsx index f8bf8e711db0..c1faccf190a3 100644 --- a/addons/docs/src/blocks/Description.tsx +++ b/addons/docs/src/blocks/Description.tsx @@ -70,7 +70,9 @@ ${extractComponentDescription(target) || ''} const DescriptionContainer: FunctionComponent = (props) => { const context = useContext(DocsContext); const { markdown } = getDescriptionProps(props, context); - return markdown ? : null; + return markdown ? ( + + ) : null; }; // since we are in the docs blocks, assume default description if for primary component story diff --git a/addons/docs/src/blocks/DocsStory.tsx b/addons/docs/src/blocks/DocsStory.tsx index 4eab78e0d890..43b0efdc8db0 100644 --- a/addons/docs/src/blocks/DocsStory.tsx +++ b/addons/docs/src/blocks/DocsStory.tsx @@ -12,7 +12,7 @@ const warnStoryDescription = deprecate( () => {}, dedent` Deprecated parameter: docs.storyDescription => docs.description.story - + https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#docs-description-parameter ` ); @@ -23,6 +23,7 @@ export const DocsStory: FunctionComponent = ({ expanded = true, withToolbar = false, parameters, + className, }) => { let description = expanded && parameters?.docs?.description?.story; if (!description) { @@ -32,7 +33,7 @@ export const DocsStory: FunctionComponent = ({ const subheading = expanded && name; return ( - + {subheading && {subheading}} {description && } diff --git a/addons/docs/src/blocks/Primary.tsx b/addons/docs/src/blocks/Primary.tsx index 242e17794876..fea9fe95d2ed 100644 --- a/addons/docs/src/blocks/Primary.tsx +++ b/addons/docs/src/blocks/Primary.tsx @@ -14,5 +14,7 @@ export const Primary: FC = ({ name }) => { if (componentStories) { story = name ? componentStories.find((s) => s.name === name) : componentStories[0]; } - return story ? : null; + return story ? ( + + ) : null; }; diff --git a/addons/docs/src/blocks/Stories.tsx b/addons/docs/src/blocks/Stories.tsx index afb7de3e8ad8..5bab73bbd031 100644 --- a/addons/docs/src/blocks/Stories.tsx +++ b/addons/docs/src/blocks/Stories.tsx @@ -23,7 +23,12 @@ export const Stories: FunctionComponent = ({ title, includePrimary return ( <> {title} - {stories.map((story) => story && )} + {stories.map( + (story) => + story && ( + + ) + )} ); }; diff --git a/addons/docs/src/blocks/Subtitle.tsx b/addons/docs/src/blocks/Subtitle.tsx index 3fb44a8af5a6..30e4601c76c3 100644 --- a/addons/docs/src/blocks/Subtitle.tsx +++ b/addons/docs/src/blocks/Subtitle.tsx @@ -13,5 +13,5 @@ export const Subtitle: FunctionComponent = ({ children }) => { if (!text) { text = parameters?.componentSubtitle; } - return text ? {text} : null; + return text ? {text} : null; }; diff --git a/addons/docs/src/blocks/Title.tsx b/addons/docs/src/blocks/Title.tsx index 36f5590c9b98..b44b981d58f7 100644 --- a/addons/docs/src/blocks/Title.tsx +++ b/addons/docs/src/blocks/Title.tsx @@ -17,5 +17,5 @@ export const Title: FunctionComponent = ({ children }) => { if (!text) { text = extractTitle(context); } - return text ? {text} : null; + return text ? {text} : null; }; diff --git a/addons/docs/src/blocks/types.ts b/addons/docs/src/blocks/types.ts index 93eabc67b867..4008a3580cfd 100644 --- a/addons/docs/src/blocks/types.ts +++ b/addons/docs/src/blocks/types.ts @@ -13,4 +13,5 @@ export interface StoryData { export type DocsStoryProps = StoryData & { expanded?: boolean; withToolbar?: boolean; + className?: string; }; diff --git a/lib/components/src/blocks/ArgsTable/ArgsTable.tsx b/lib/components/src/blocks/ArgsTable/ArgsTable.tsx index db4fac5cab3e..d302d472027c 100644 --- a/lib/components/src/blocks/ArgsTable/ArgsTable.tsx +++ b/lib/components/src/blocks/ArgsTable/ArgsTable.tsx @@ -204,6 +204,7 @@ export interface ArgsTableRowProps { export interface ArgsTableErrorProps { error: ArgsTableError; + className?: string; } export type ArgsTableProps = ArgsTableRowProps | ArgsTableErrorProps; @@ -252,10 +253,10 @@ const groupRows = (rows: ArgType) => { * ArgDefs, usually derived from docgen info for the component. */ export const ArgsTable: FC = (props) => { - const { error } = props as ArgsTableErrorProps; + const { error, className } = props as ArgsTableErrorProps; if (error) { return ( - + {error}  Read the docs @@ -274,7 +275,7 @@ export const ArgsTable: FC = (props) => { Object.entries(groups.ungroupedSubsections).length === 0 ) { return ( - + No inputs found for this component.  Read the docs @@ -290,7 +291,7 @@ export const ArgsTable: FC = (props) => { const common = { updateArgs, compact, inAddonPanel }; return ( - + diff --git a/lib/components/src/blocks/ArgsTable/TabbedArgsTable.tsx b/lib/components/src/blocks/ArgsTable/TabbedArgsTable.tsx index 254ddfdb8b25..ca86a44d3e22 100644 --- a/lib/components/src/blocks/ArgsTable/TabbedArgsTable.tsx +++ b/lib/components/src/blocks/ArgsTable/TabbedArgsTable.tsx @@ -4,17 +4,18 @@ import { TabsState } from '../../tabs/tabs'; export interface TabbedArgsTableProps { tabs: Record; + className?: string; } -export const TabbedArgsTable: FC = ({ tabs, ...props }) => { +export const TabbedArgsTable: FC = ({ tabs, className, ...props }) => { const entries = Object.entries(tabs); if (entries.length === 1) { - return ; + return ; } return ( - + {entries.map((entry) => { const [label, table] = entry; const id = `prop_table_div_${label}`; diff --git a/lib/components/src/blocks/Description.tsx b/lib/components/src/blocks/Description.tsx index e3951a538d06..a6bed665a0da 100644 --- a/lib/components/src/blocks/Description.tsx +++ b/lib/components/src/blocks/Description.tsx @@ -5,14 +5,15 @@ import { components } from '../html'; export interface DescriptionProps { markdown: string; + className?: string; } /** * A markdown description for a component, typically used to show the * components docgen docs. */ -export const Description: FunctionComponent = ({ markdown }) => ( - +export const Description: FunctionComponent = ({ markdown, className }) => ( + {markdown} ); diff --git a/lib/components/src/placeholder/placeholder.tsx b/lib/components/src/placeholder/placeholder.tsx index 31e48adebb2b..09cf3a4140ff 100644 --- a/lib/components/src/placeholder/placeholder.tsx +++ b/lib/components/src/placeholder/placeholder.tsx @@ -14,10 +14,19 @@ const Message = styled.div(({ theme }) => ({ fontSize: theme.typography.size.s2 - 1, })); -export const Placeholder: FunctionComponent = ({ children, ...props }) => { +interface PlaceholderProps { + children?: React.ReactNode; + className?: string; +} + +export const Placeholder: FunctionComponent = ({ + children, + className, + ...props +}) => { const [title, desc] = Children.toArray(children); return ( - + {title} {desc && {desc}} diff --git a/lib/components/src/tabs/tabs.tsx b/lib/components/src/tabs/tabs.tsx index 405cafd05343..e5da2c97942f 100644 --- a/lib/components/src/tabs/tabs.tsx +++ b/lib/components/src/tabs/tabs.tsx @@ -150,14 +150,25 @@ export interface TabsProps { backgroundColor?: string; absolute?: boolean; bordered?: boolean; + className?: string; } export const Tabs: FunctionComponent = memo( - ({ children, selected, actions, absolute, bordered, tools, backgroundColor, id: htmlId }) => { + ({ + children, + selected, + actions, + absolute, + bordered, + tools, + backgroundColor, + id: htmlId, + className, + }) => { const list = childrenToList(children, selected); return list.length ? ( - + {list.map(({ title, id, active, color }) => { @@ -188,7 +199,7 @@ export const Tabs: FunctionComponent = memo( ) : ( - + Nothing found ); @@ -212,6 +223,7 @@ export interface TabsStateProps { absolute: boolean; bordered: boolean; backgroundColor: string; + className?: string; } export interface TabsStateState { @@ -225,6 +237,7 @@ export class TabsState extends Component { absolute: false, bordered: false, backgroundColor: '', + className: '', }; constructor(props: TabsStateProps) { @@ -240,10 +253,11 @@ export class TabsState extends Component { }; render() { - const { bordered = false, absolute = false, children, backgroundColor } = this.props; + const { bordered = false, absolute = false, children, backgroundColor, className } = this.props; const { selected } = this.state; return (