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

Name Customization: Not possible to use logic (concat string, helper functions etc.) #124

Closed
ttristan opened this issue May 4, 2022 · 1 comment · Fixed by #138
Closed
Labels
documentation Improvements or additions to documentation

Comments

@ttristan
Copy link

ttristan commented May 4, 2022

Is your feature request related to a problem? Please describe.
I would like to streamline story namespaces using the Name Customization feature. However, it does not seem to be possible to use any logic exporting a story title.

Doing so a blank page is shown an I get this error in the browser console:

Uncaught SyntaxError: The requested module '/generated/generated-list.tsx' does not provide an export named 'storySource' (at source.tsx:6:1)

Working Example:

export default {
    title: 'Core / Button',
};

Broken Exmaples:

export default {
    title: 'Core' + ' / ' + 'Button',
};

or 

export default {
    title: `${'Core'} / ${'Button'}`,
};

My usecase:

// utils.ts
const getStoryName = (namespace: 'Core' | 'Features', componentName: string) =>
    `${namespace} / ${componentName}`;

// button.story.ts
export default {
    title: getStoryName('Core', 'Button'),
};
@ttristan ttristan added the needs triage needs to be reviewed label May 4, 2022
@tajo tajo added documentation Improvements or additions to documentation and removed needs triage needs to be reviewed labels May 4, 2022
@tajo
Copy link
Owner

tajo commented May 4, 2022

Story names need to be static (simple strings). It's the intentional limitation of Ladle to support automatic code-splitting and some other features. It seems there might be some regression in the error message that's makes it unclear - should look into it. Also, we should probably highlight this more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants