File tree Expand file tree Collapse file tree 3 files changed +119
-0
lines changed
tests/Unit/Traits/Styling Expand file tree Collapse file tree 3 files changed +119
-0
lines changed Original file line number Diff line number Diff line change 44
55use Rappasoft \LaravelLivewireTables \Traits \Core \{HasCustomAttributes , HasLocalisations };
66use Rappasoft \LaravelLivewireTables \Views \Traits \Core \HasTheme ;
7+ use Rappasoft \LaravelLivewireTables \Traits \Styling \HasDefaultFilterInputStyling ;
78
89trait HasAllTraits
910{
@@ -13,6 +14,7 @@ trait HasAllTraits
1314 use WithLoadingPlaceholder;
1415 use HasTheme;
1516 use ComponentUtilities,
17+ HasDefaultFilterInputStyling,
1618 WithActions,
1719 WithData,
1820 WithQueryString,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rappasoft \LaravelLivewireTables \Traits \Styling ;
4+
5+ use Livewire \Attributes \Computed ;
6+
7+ trait HasDefaultFilterInputStyling
8+ {
9+ public ?string $ defaultFilterInputColors ;
10+ public ?string $ defaultFilterInputStyling ;
11+
12+ protected function setDefaultFilterInputColors (string $ defaultFilterInputColors ): self
13+ {
14+ $ this ->defaultFilterInputColors = $ defaultFilterInputColors ;
15+
16+ return $ this ;
17+ }
18+
19+ protected function setDefaultFilterInputStyling (string $ defaultFilterInputStyling ): self
20+ {
21+ $ this ->defaultFilterInputStyling = $ defaultFilterInputStyling ;
22+
23+ return $ this ;
24+ }
25+
26+ public function hasDefaultFilterInputColors (): bool
27+ {
28+ return isset ($ this ->defaultFilterInputColors );
29+ }
30+
31+ #[Computed]
32+ public function getDefaultFilterInputColors (): string
33+ {
34+ if (isset ($ this ->defaultFilterInputColors ))
35+ {
36+ return $ this ->defaultFilterInputColors ;
37+ }
38+ else
39+ {
40+ if ($ this ->isTailwind ())
41+ {
42+ return 'border-gray-300 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-800 dark:text-white dark:border-gray-600 ' ;
43+ }
44+ else
45+ {
46+ return '' ;
47+ }
48+ }
49+ }
50+
51+ public function hasDefaultFilterInputStyling (): bool
52+ {
53+ return isset ($ this ->defaultFilterInputStyling );
54+ }
55+
56+ #[Computed]
57+ public function getDefaultFilterInputStyling (): string
58+ {
59+ if (isset ($ this ->defaultFilterInputStyling ))
60+ {
61+ return $ this ->defaultFilterInputStyling ;
62+ }
63+ else
64+ {
65+ if ($ this ->isTailwind ())
66+ {
67+ return 'block w-full rounded-md shadow-sm transition duration-150 ease-in-out focus:ring focus:ring-opacity-50 ' ;
68+ }
69+ else
70+ {
71+ return 'form-control ' ;
72+ }
73+ }
74+ }
75+
76+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rappasoft \LaravelLivewireTables \Tests \Unit \Traits \Styling ;
4+
5+ use PHPUnit \Framework \Attributes \Group ;
6+ use Rappasoft \LaravelLivewireTables \Tests \TestCase ;
7+
8+ #[Group('Filters ' )]
9+ #[Group('Styling ' )]
10+ final class FilterInputDefaultStylingTest extends TestCase
11+ {
12+
13+ public function test_has_filter_default_input_styling (): void
14+ {
15+ $ this ->assertFalse ($ this ->basicTable ->hasDefaultFilterInputStyling ());
16+ }
17+
18+ public function test_has_filter_default_input_colors (): void
19+ {
20+ $ this ->assertFalse ($ this ->basicTable ->hasDefaultFilterInputColors ());
21+ }
22+
23+ public function test_can_set_filter_default_input_styling (): void
24+ {
25+ $ this ->assertFalse ($ this ->basicTable ->hasDefaultFilterInputStyling ());
26+
27+ $ this ->basicTable ->setDefaultFilterInputStyling ('p-4 ' );
28+
29+ $ this ->assertTrue ($ this ->basicTable ->hasDefaultFilterInputStyling ());
30+ }
31+
32+ public function test_can_set_filter_default_input_colors (): void
33+ {
34+ $ this ->assertFalse ($ this ->basicTable ->hasDefaultFilterInputColors ());
35+
36+ $ this ->basicTable ->setDefaultFilterInputColors ('bg-blue-500 ' );
37+
38+ $ this ->assertTrue ($ this ->basicTable ->hasDefaultFilterInputColors ());
39+ }
40+
41+ }
You can’t perform that action at this time.
0 commit comments