Skip to content

Adding CHANGELOG for twig/live component #114

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
Show file tree
Hide file tree
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
88 changes: 88 additions & 0 deletions src/LiveComponent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# CHANGELOG

## NEXT

- Minimum PHP version was bumped to 8.0 so that PHP 8 attributes could be used.

- The `LiveComponentInterface` was dropped and replaced by the `AsLiveComponent` attribute,
which extends the new `AsTwigComponent` from the TwigComponent library. All
other annotations (e.g. `@LiveProp` and `@LiveAction`) were also replaced by
PHP 8 attributes.

Before:

```php
use App\Entity\Notification;
use App\Repository\NotificationRepository;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\LiveComponentInterface;

final class NotificationComponent implements LiveComponentInterface
{
private NotificationRepository $repo;

/** @LiveProp */
public bool $expanded = false;

public function __construct(NotificationRepository $repo)
{
$this->repo = $repo;
}

/** @LiveAction */
public function toggle(): void
{
$this->expanded = !$this->expanded;
}

public function getNotifications(): array
{
return $this->repo->findAll();
}

public static function getComponentName(): string
{
return 'notification';
}
}
```

After:

```php
use App\Entity\Notification;
use App\Repository\NotificationRepository;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
use Symfony\UX\LiveComponent\Attribute\LiveProp;

#[AsLiveComponent('notification')]
final class NotificationComponent
{
private NotificationRepository $repo;

#[LiveProp]
public bool $expanded = false;

public function __construct(NotificationRepository $repo)
{
$this->repo = $repo;
}

#[LiveAction]
public function toggle(): void
{
$this->expanded = !$this->expanded;
}

public function getNotifications(): array
{
return $this->repo->findAll();
}
}
```

## Pre-Release

- The LiveComponent library was introduced!
60 changes: 60 additions & 0 deletions src/TwigComponent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# CHANGELOG

## NEXT

- Minimum PHP version was bumped to 8.0 so that PHP 8 attributes could be used.

- The `ComponentInterface` was dropped and replaced by the `AsTwigComponent` attribute.
The `getComponentName()` was replaced by a `name` argument to the attribute.

Before:

```php
use Symfony\UX\TwigComponent\ComponentInterface;

class AlertComponent implements ComponentInterface
{
public string $type = 'success';
public string $message;

public static function getComponentName(): string
{
return 'alert';
}
}
```

After:

```php
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent('alert')]
class AlertComponent
{
public string $type = 'success';
public string $message;
}
```

- If you're using a version _lower_ than Symfony 5.3, you will need
to manually tag all component services with `twig.component`. This is
because Symfony 5.3 introduces autoconfiguration for PHP 8 attributes,
which this library leverages.

- The template for a component can now be controlled via the `template` argument
to the `AsTwigComponent` attribute:

```php
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent('alert', template: 'other/path/alert.html.twig')]
class AlertComponent
{
// ...
}
```

## Pre-Release

- The TwigComponent library was introduced!