Skip to content

Commit

Permalink
Removed getPrimaryFromResolvedOf function
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilson2k committed Oct 18, 2023
1 parent 393b0db commit d3cabc6
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions code/ui/blocks/src/blocks/Primary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,6 @@ interface PrimaryProps {
of?: Of;
}

const getPrimaryFromResolvedOf = (resolvedOf: ReturnType<typeof useOf>) => {
switch (resolvedOf.type) {
case 'meta': {
return resolvedOf.csfFile.stories[0] || null;
}
case 'component': {
throw new Error(
`Unsupported module type. Primary's \`of\` prop only supports \`meta\`, got: ${
(resolvedOf as any).type
}`
);
}
default: {
throw new Error(
`Unrecognized module type resolved from 'useOf', got: ${(resolvedOf as any).type}`
);
}
}
};

export const Primary: FC<PrimaryProps> = (props) => {
const { name, of } = props;

Expand All @@ -50,7 +30,7 @@ export const Primary: FC<PrimaryProps> = (props) => {
let story;
if (of) {
const resolvedOf = useOf(of || 'meta', ['meta']);
story = getPrimaryFromResolvedOf(resolvedOf);
story = resolvedOf.csfFile.stories[0] || null;
}

if (!story) {
Expand Down

0 comments on commit d3cabc6

Please sign in to comment.