Skip to content

Commit 1ea86a7

Browse files
committed
add ability to change style globally
1 parent 72dd800 commit 1ea86a7

11 files changed

+33
-5
lines changed

src/Components/AttachmentComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function init(...$arguments): self
5252
$this->customIcons = $customIcons;
5353
}
5454

55+
$this->setDefaultStyle();
56+
5557
return $this;
5658
}
5759

src/Components/Base64ImageComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public function init(...$arguments): self
4444
$this->resetLabel = Lang::get($upload);
4545
}
4646

47+
$this->setDefaultStyle();
48+
4749
return $this;
4850
}
4951

src/Components/BaseComponent.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ abstract class BaseComponent implements Htmlable
7474
*/
7575
public function __construct(
7676
protected string $resource,
77-
) {
78-
if ($defaultStyle = Config::get('laravel-bootstrap-forms.default_style')) {
79-
$this->style = $defaultStyle;
80-
}
81-
}
77+
) {}
8278

8379
/**
8480
* Initialized the input arguments.
@@ -213,6 +209,18 @@ protected function getViewPath(): string
213209
return Config::get('laravel-bootstrap-forms.views').'.'.$this->viewPath.'.'.$this->style;
214210
}
215211

212+
/**
213+
* Set the default component style.
214+
*/
215+
public function setDefaultStyle(): self
216+
{
217+
if ($defaultStyle = Config::get('laravel-bootstrap-forms.default_style')) {
218+
$this->style = $defaultStyle;
219+
}
220+
221+
return $this;
222+
}
223+
216224
/**
217225
* Set the component style.
218226
*/

src/Components/CheckboxComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public function init(...$arguments): self
4444

4545
$this->setDefaultPlaceholder();
4646

47+
$this->setDefaultStyle();
48+
4749
return $this;
4850
}
4951

src/Components/FileComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function init(...$arguments): self
2323

2424
$this->setDefaultNote($name);
2525

26+
$this->setDefaultStyle();
27+
2628
return $this;
2729
}
2830

src/Components/PhoneComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public function init(...$arguments): self
3030

3131
$this->countries(config('laravel-bootstrap-forms.phone.countries'));
3232

33+
$this->setDefaultStyle();
34+
3335
return $this;
3436
}
3537

src/Components/PriceComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function init(...$arguments): TextualComponent
2929

3030
$this->setDefaultPlaceholder();
3131

32+
$this->setDefaultStyle();
33+
3234
return $this;
3335
}
3436

src/Components/RadioComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public function init(...$arguments): self
2828

2929
$this->setDefaultPlaceholder($name);
3030

31+
$this->setDefaultStyle();
32+
3133
return $this;
3234
}
3335

src/Components/SelectComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function init(...$arguments): self
3232

3333
$this->setDefaultPlaceholder($name);
3434

35+
$this->setDefaultStyle();
36+
3537
return $this;
3638
}
3739

src/Components/SubmitComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function init(...$arguments): self
2323
$this->name($arguments[1] ?? '');
2424
$this->label($arguments[0] ?? '');
2525

26+
$this->setDefaultStyle();
27+
2628
return $this;
2729
}
2830

0 commit comments

Comments
 (0)