From 21e31e9371b909e46c4602a8fc9af8846ee32002 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Thu, 19 Oct 2023 08:42:20 +0200 Subject: [PATCH] Rename `stylisedUi` to `stylized` --- README.md | 9 ++++++++- src/Fields/TrueFalse.php | 10 +++++----- tests/Fields/TrueFalseTest.php | 6 +++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d94d63b8..deb71f7a 100644 --- a/README.md +++ b/README.md @@ -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() ``` @@ -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 diff --git a/src/Fields/TrueFalse.php b/src/Fields/TrueFalse.php index e8cff86c..9a097b90 100644 --- a/src/Fields/TrueFalse.php +++ b/src/Fields/TrueFalse.php @@ -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; diff --git a/tests/Fields/TrueFalseTest.php b/tests/Fields/TrueFalseTest.php index 9e55e779..a695238e 100644 --- a/tests/Fields/TrueFalseTest.php +++ b/tests/Fields/TrueFalseTest.php @@ -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'); } }