From 8db8645a079b177596cc818908cbfce7ca46af6e Mon Sep 17 00:00:00 2001 From: Yu Qiao Chen Date: Wed, 28 Jun 2023 14:13:33 -0400 Subject: [PATCH 1/2] Rename compact function to compactTheme --- src/Color.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Color.php b/src/Color.php index aedb761..91754ef 100644 --- a/src/Color.php +++ b/src/Color.php @@ -4,8 +4,8 @@ use Exception; use Laravel\Nova\Fields\Field; -use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Fields\SupportsDependentFields; +use Laravel\Nova\Http\Requests\NovaRequest; class Color extends Field { @@ -48,7 +48,7 @@ public function twitter() return $this->pickerType('twitter'); } - public function compact() + public function compactTheme() { return $this->pickerType('compact'); } @@ -90,15 +90,21 @@ public function hidePicker() public function saveAs($saveAs = 'hex') { - if (!in_array($saveAs, ['rgb', 'rgba', 'hex', 'hex8', 'hsl'])) throw new Exception("Invalid saveAs option provided [$saveAs]."); - $saveAs = ($saveAs === "rgba") ? "rgb" : $saveAs; + if (! in_array($saveAs, ['rgb', 'rgba', 'hex', 'hex8', 'hsl'])) { + throw new Exception("Invalid saveAs option provided [{$saveAs}]."); + } + $saveAs = ($saveAs === 'rgba') ? 'rgb' : $saveAs; + return $this->withMeta(['saveAs' => $saveAs]); } public function displayAs($displayAs = 'hex') { - if (!in_array($displayAs, ['rgb', 'rgba', 'hex', 'hex8', 'hsl'])) throw new Exception("Invalid displayAs option provided [$displayAs]."); - $displayAs = ($displayAs === "rgba") ? "rgb" : $displayAs; + if (! in_array($displayAs, ['rgb', 'rgba', 'hex', 'hex8', 'hsl'])) { + throw new Exception("Invalid displayAs option provided [{$displayAs}]."); + } + $displayAs = ($displayAs === 'rgba') ? 'rgb' : $displayAs; + return $this->withMeta(['displayAs' => $displayAs]); } @@ -108,7 +114,10 @@ protected function fillAttributeFromRequest(NovaRequest $request, $requestAttrib // Try to turn into array $value = $request[$requestAttribute]; $arrayValue = json_decode($value, true); - if (!empty($arrayValue)) $value = $arrayValue; + + if (! empty($arrayValue)) { + $value = $arrayValue; + } $model->{$attribute} = $this->isNullValue($value) ? null : $value; } From 790178b4e34d075019f35b327efeca5472b9db18 Mon Sep 17 00:00:00 2001 From: Yu Qiao Chen Date: Thu, 29 Jun 2023 09:21:00 -0400 Subject: [PATCH 2/2] Updated readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7409c21..8aaf5f3 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ public function fields(Request $request) { ### Themes -Available themes: `chrome, compact, grayscale, material, photoshop, sketch, slider, swatches, twitter`. +Available themes: `chrome, compactTheme, grayscale, material, photoshop, sketch, slider, swatches, twitter`. See the theme demos [here](http://xiaokaike.github.io/vue-color/). @@ -76,7 +76,7 @@ Adding custom pallette colors to the pickers can be done like so: ```php Color::make('Color') - ->compact() + ->compactTheme() ->palette(['#beaf00', '#DEADAF', '#000']), ```