-
Notifications
You must be signed in to change notification settings - Fork 10
New maker command #30
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @WebMamba!
That looks good, just a few things we could discuss.
I wonder if we can go a little bit further, and provide some default args to the story based on static analysis of the component. What do you think, would it be doable in a simple first version, or is it too complicated to introspect Twig components for the moment?
Also, is it possible to write tests for this maker?
$container->register('storybook.maker.story_renderer', \Storybook\Maker\StoryRenderer::class) | ||
->setArgument(0, new Reference('maker.generator')) | ||
->setArgument(1, new Reference('ux.twig_component.component_factory')) | ||
->setArgument(2, '%kernel.project_dir%/stories'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stories path depends on Storybook configuration, so I think this should be handled in a interactive prompt at maker level, with smart suggestions like stories/
or the current component template directory?
@@ -0,0 +1,12 @@ | |||
import <?php echo $componentName; ?> from "../templates/<?php echo $template; ?>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relates to the previous comment on stories path: I'd prefer the full path to be dynamically generated depending on where the story file is created.
`, | ||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to add a default story here, like
export const Default = {};
This is required for Storybook to properly index the story file, otherwise we'll get an indexing error AFAIK.
use Symfony\Bundle\MakerBundle\Generator; | ||
use Symfony\UX\TwigComponent\ComponentFactory; | ||
|
||
class StoryRenderer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to rename this class to something that doesn't collide with the main StoryRenderer
? Like StoryGenerator
?
Also this class could be final
/** | ||
* @method string getCommandDescription() | ||
*/ | ||
class MakeStory extends AbstractMaker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be final
No description provided.