Skip to content

Commit c943784

Browse files
authored
Renamed clear button components and update references (#59)
* Rename clear button components and update translations for consistency * Refactor translation keys and update dropdown placeholder
1 parent c1f993f commit c943784

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

src/bundle/Resources/translations/ibexa_design_system_twig.en.xliff

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<target state="new">Delete</target>
1212
<note>key: ibexa.chip.delete-btn.label</note>
1313
</trans-unit>
14-
<trans-unit id="61c7070a29f932eb0b1a343509d049aa52c92c09" resname="ibexa.clear-btn.label">
14+
<trans-unit id="325602325410dfc0d83e43dec9a10976368c7154" resname="ibexa.clear-button.label">
1515
<source>Clear</source>
1616
<target state="new">Clear</target>
17-
<note>key: ibexa.clear-btn.label</note>
17+
<note>key: ibexa.clear-button.label</note>
1818
</trans-unit>
1919
<trans-unit id="8bd385b5e5cc2e1edee94e57245b6d8a42f50aac" resname="ibexa.dropdown.placeholder">
2020
<source>Select an item</source>
@@ -36,6 +36,11 @@
3636
<target state="new">Show</target>
3737
<note>key: ibexa.expander.label.expand</note>
3838
</trans-unit>
39+
<trans-unit id="0af0c0b3e944e524dba4b327905685b9300f40e4" resname="ids.dropdown.placeholder">
40+
<source>Select an item</source>
41+
<target state="new">Select an item</target>
42+
<note>key: ids.dropdown.placeholder</note>
43+
</trans-unit>
3944
</body>
4045
</file>
4146
</xliff>

src/bundle/Resources/views/themes/standard/design_system/components/input_text/input.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
%}
3131

3232
{% set clear_action %}
33-
<twig:ibexa:ui:clear_btn :disabled="disabled" />
33+
<twig:ibexa:ui:clear_button :disabled="disabled" />
3434
{% endset %}
3535

3636
{% set actions = [

src/bundle/Resources/views/themes/standard/design_system/components/ui/clear_btn.html.twig renamed to src/bundle/Resources/views/themes/standard/design_system/components/ui/clear_button.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% trans_default_domain 'ibexa_design_system_twig' %}
22

3-
{% set clear_msg = 'ibexa.clear-btn.label'|trans|desc('Clear') %}
3+
{% set clear_msg = 'ibexa.clear-button.label'|trans|desc('Clear') %}
44

55
<twig:ibexa:button
66
type="tertiary-alt"

src/lib/Twig/Components/AbstractDropdown.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
*/
2525
abstract class AbstractDropdown
2626
{
27-
private const string TRANSLATION_DOMAIN = 'ibexa_design_system_twig';
28-
2927
public string $name;
3028

3129
public bool $disabled = false;
@@ -78,7 +76,7 @@ public function validate(array $props): array
7876
/** @Desc("Select an item") */
7977
'ids.dropdown.placeholder',
8078
[],
81-
self::TRANSLATION_DOMAIN
79+
'ibexa_design_system_twig'
8280
)
8381
);
8482
$resolver

src/lib/Twig/Components/UI/ClearBtn.php renamed to src/lib/Twig/Components/UI/ClearButton.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
1313
use Symfony\UX\TwigComponent\Attribute\PreMount;
1414

15-
#[AsTwigComponent('ibexa:ui:clear_btn')]
16-
final class ClearBtn
15+
#[AsTwigComponent('ibexa:ui:clear_button')]
16+
final class ClearButton
1717
{
1818
public bool $disabled = false;
1919

tests/integration/Twig/Components/UI/ClearBtnTest.php renamed to tests/integration/Twig/Components/UI/ClearButtonTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88

99
namespace Ibexa\Tests\Integration\DesignSystemTwig\Twig\Components\UI;
1010

11-
use Ibexa\DesignSystemTwig\Twig\Components\UI\ClearBtn;
11+
use Ibexa\DesignSystemTwig\Twig\Components\UI\ClearButton;
1212
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1313
use Symfony\Component\DomCrawler\Crawler;
1414
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
1515
use Symfony\UX\TwigComponent\Test\InteractsWithTwigComponents;
1616

17-
final class ClearBtnTest extends KernelTestCase
17+
final class ClearButtonTest extends KernelTestCase
1818
{
1919
use InteractsWithTwigComponents;
2020

2121
public function testMount(): void
2222
{
23-
$component = $this->mountTwigComponent(ClearBtn::class, ['disabled' => true]);
23+
$component = $this->mountTwigComponent(ClearButton::class, ['disabled' => true]);
2424

25-
self::assertInstanceOf(ClearBtn::class, $component, 'Component should mount as UI\\ClearBtn.');
25+
self::assertInstanceOf(ClearButton::class, $component, 'Component should mount as UI\\ClearButton.');
2626
self::assertTrue($component->disabled, 'Prop "disabled" should be true.');
2727
}
2828

2929
public function testDefaultRenderProducesConfiguredButton(): void
3030
{
31-
$crawler = $this->renderTwigComponent(ClearBtn::class)->crawler();
31+
$crawler = $this->renderTwigComponent(ClearButton::class)->crawler();
3232

3333
$button = $this->getButton($crawler);
3434
$class = $this->getClassAttr($button);
@@ -53,7 +53,7 @@ public function testDefaultRenderProducesConfiguredButton(): void
5353

5454
public function testDisabledTrueAddsAttributeAndClass(): void
5555
{
56-
$crawler = $this->renderTwigComponent(ClearBtn::class, ['disabled' => true])->crawler();
56+
$crawler = $this->renderTwigComponent(ClearButton::class, ['disabled' => true])->crawler();
5757

5858
$button = $this->getButton($crawler);
5959
$class = $this->getClassAttr($button);
@@ -65,7 +65,7 @@ public function testDisabledTrueAddsAttributeAndClass(): void
6565
public function testInvalidDisabledTypeCausesResolverErrorOnMount(): void
6666
{
6767
$this->expectException(InvalidOptionsException::class);
68-
$this->mountTwigComponent(ClearBtn::class, ['disabled' => 'yes']);
68+
$this->mountTwigComponent(ClearButton::class, ['disabled' => 'yes']);
6969
}
7070

7171
private function getButton(Crawler $crawler): Crawler

0 commit comments

Comments
 (0)