Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

New maker command #30

wants to merge 2 commits into from

Conversation

WebMamba
Copy link
Contributor

No description provided.

@WebMamba WebMamba requested a review from squrious July 18, 2024 17:31
Copy link
Collaborator

@squrious squrious left a 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');
Copy link
Collaborator

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; ?>";
Copy link
Collaborator

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.

`,
})
}

Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be final

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

Successfully merging this pull request may close these issues.

2 participants