Skip to content

[Toolkit] Minor adjustements on Kit creation command (reword questions, fix doc format) #2724

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

Merged
merged 1 commit into from
May 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions src/Toolkit/src/Command/CreateKitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);

// Get the kit name
$question = new Question('What is the name of your kit?');
$question = new Question("What's the name of your kit?");
$question->setValidator(function (?string $value) {
if (empty($value)) {
throw new \RuntimeException('Kit name cannot be empty');
throw new \RuntimeException('Kit name cannot be empty.');
}
Assert::kitName($value);

Expand All @@ -55,21 +55,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$kitName = $io->askQuestion($question);

// Get the kit homepage
$question = new Question('What is the homepage of your kit?');
$question = new Question("What's the Homepage URL of your kit?");
$question->setValidator(function (?string $value) {
if (empty($value) || !filter_var($value, \FILTER_VALIDATE_URL)) {
throw new \Exception('The homepage must be a valid URL');
throw new \Exception('The homepage URL must be valid.');
}

return $value;
});
$kitHomepage = $io->askQuestion($question);

// Get the kit author name
$question = new Question('What is the author name of your kit?');
$question = new Question("What's the name of the author?");
$question->setValidator(function (?string $value) {
if (empty($value)) {
throw new \Exception('The author name cannot be empty');
throw new \Exception('The author name cannot be empty.');
}

return $value;
Expand All @@ -80,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$question = new Question('What is the license of your kit?');
$question->setValidator(function (string $value) {
if (empty($value)) {
throw new \Exception('The license cannot be empty');
throw new \Exception('The license cannot be empty.');
}

return $value;
Expand All @@ -107,38 +107,51 @@ protected function execute(InputInterface $input, OutputInterface $output): int
) -%}

<button class="{{ style.apply({ variant }, attributes.render('class'))|tailwind_merge }}"
{{ attributes.defaults({}).without('class') }}
{{ attributes }}
>
{%- block content %}{% endblock -%}
</button>
TWIG
);
$this->filesystem->dumpFile('docs/components/Button.twig', <<<TWIG
{% block meta %}
title: Button
description: The Button component is a versatile component that allows you to create clickable buttons with various styles and states.
{% endblock %}
$this->filesystem->dumpFile('docs/components/Button.md', <<<TWIG
# Button

{% block examples %}
# Basic Button
The Button component is a versatile component that allows you to create clickable buttons with various styles and states.

## Installation

Ensure the Symfony UX Toolkit is installed in your Symfony app:

```shell
$ composer require --dev symfony/ux-toolkit
```

Then, run the following command to install the component and its dependencies:
```shell
$ bin/console ux:toolkit:install-component Button --kit github.com/user/my-ux-toolkit-kit
```

## Usage

```twig
<twig:Button>
Click me
</twig:Button>
```

# Button with Variants
## Examples

### Button with Variants

```twig
<twig:Button variant="default">Default</twig:Button>
<twig:Button variant="secondary">Secondary</twig:Button>
```
{% endblock %}

TWIG
);

$io->success('Perfect, you can now start building your kit!');
$io->success('Your kit has been scaffolded, enjoy!');

return self::SUCCESS;
}
Expand Down