Skip to content

Commit

Permalink
Rename stylisedUi to stylized
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Oct 19, 2023
1 parent d093257 commit 21e31e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ use Extended\ACF\Fields\TrueFalse;
TrueFalse::make('Social Media', 'display_social_media')
->instructions('Select whether to display social media links or not.')
->default(false)
->stylisedUi() // optional on and off text labels
->stylized(on: 'Yes', off: 'No') // optional on and off text labels
->required()
```

Expand Down Expand Up @@ -838,6 +838,13 @@ The `weekStartsOn` method has been renamed to `firstDayOfWeek`.
+DatePicker::make('Date')->firstDayOfWeek(1)
```

The `stylisedUi` method has been renamed to `stylized` on the `TrueFalse` field.

```diff
-TrueFalse::make('Disabled')->stylisedUi(onText: 'Yes')
+TrueFalse::make('Disabled')->stylized(on: 'Yes')
```

The `CharacterLimit` trait has been renamed to `MaxLength`.

```diff
Expand Down
10 changes: 5 additions & 5 deletions src/Fields/TrueFalse.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ class TrueFalse extends Field

protected string|null $type = 'true_false';

public function stylisedUi(string|null $onText = null, string|null $offText = null): static
public function stylized(string $on = null, string $off = null): static
{
$this->settings['ui'] = true;

if ($onText !== null) {
$this->settings['ui_on_text'] = $onText;
if ($on) {
$this->settings['ui_on_text'] = $on;
}

if ($offText !== null) {
$this->settings['ui_off_text'] = $offText;
if ($off) {
$this->settings['ui_off_text'] = $off;
}

return $this;
Expand Down
6 changes: 3 additions & 3 deletions tests/Fields/TrueFalseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public function testType()
$this->assertSame('true_false', $field['type']);
}

public function testStylisedUi()
public function testStylized()
{
$field = TrueFalse::make('UI')->stylisedUi('Wax on', 'Wax off')->get();
$field = TrueFalse::make('UI')->stylized(off: 'Wax off')->get();
$this->assertTrue($field['ui']);
$this->assertEquals($field['ui_on_text'], 'Wax on');
$this->assertArrayNotHasKey('ui_on_text', $field);
$this->assertEquals($field['ui_off_text'], 'Wax off');
}
}

0 comments on commit 21e31e9

Please sign in to comment.