Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-docs: Fix ArgsTable sorting when using of={Component} #14669

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions addons/docs/src/blocks/ArgsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ export const StoryTable: FC<

export const ComponentsTable: FC<ComponentsProps> = (props) => {
const context = useContext(DocsContext);
const { components, include, exclude } = props;
const { components, include, exclude, sort } = props;

const tabs = addComponentTabs({}, components, context, include, exclude);
return <TabbedArgsTable tabs={tabs} />;
return <TabbedArgsTable tabs={tabs} sort={sort} />;
};

export const ArgsTable: FC<ArgsTableProps> = (props) => {
Expand All @@ -222,7 +222,8 @@ export const ArgsTable: FC<ArgsTableProps> = (props) => {
} catch (err) {
mainProps = { error: err.message };
}
return <PureArgsTable {...mainProps} />;

return <PureArgsTable {...mainProps} sort={sort} />;
}

if (components) {
Expand Down
2 changes: 1 addition & 1 deletion examples/cra-ts-kitchen-sink/src/stories/PropsSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';

export const PropsSort = () => <div>PropsSort!</div>;
PropsSort.propTypes = {
foo: PropTypes.string,
foo: PropTypes.string.isRequired,
middleWithDefaultValue: PropTypes.string,
bar: PropTypes.string,
endWithDefaultValue: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { PropsSort } from './PropsSort';
import { ArgsTable, Meta } from '@storybook/addon-docs/blocks';
import { SortType } from "@storybook/components";

<Meta title="PropsSort" />
<Meta
title="PropsSort"
/>

<ArgsTable of={PropsSort} />
<ArgsTable of={PropsSort} exclude={['foo']} />
<ArgsTable of={PropsSort} sort="alpha" />
<ArgsTable of={PropsSort} sort="requiredFirst" />