Skip to content

Commit dc5394d

Browse files
feat: add popover support to all form components with set class of popover trigger and popover content; (#1073)
Co-authored-by: Robson Tenório <rrtenorio@gmail.com>
1 parent ca5303a commit dc5394d

File tree

16 files changed

+276
-2
lines changed

16 files changed

+276
-2
lines changed

src/View/Components/Choices.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ public function __construct(
4545
public Collection|array $options = new Collection(),
4646
public ?string $noResultText = 'No results found.',
4747

48+
// Popover
49+
public ?string $popover = null,
50+
public ?string $popoverIcon = "o-question-mark-circle",
51+
public ?string $popoverTriggerClass = '',
52+
public ?string $popoverContentClass = '',
53+
4854
// Validations
4955
public ?string $errorField = null,
5056
public ?string $errorClass = 'text-error',
@@ -242,6 +248,18 @@ public function render(): View|Closure|string
242248
@if($attributes->get('required'))
243249
<span class="text-error">*</span>
244250
@endif
251+
252+
{{-- INPUT POPOVER --}}
253+
@if($popover)
254+
<x-mary-popover offset="5" position="top-start">
255+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
256+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
257+
</x-slot:trigger>
258+
<x-slot:content class="{{ $popoverContentClass }}">
259+
{{ $popover }}
260+
</x-slot:content>
261+
</x-mary-popover>
262+
@endif
245263
</legend>
246264
@endif
247265

src/View/Components/ChoicesOffline.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public function __construct(
4343
public Collection|array $options = new Collection(),
4444
public ?string $noResultText = 'No results found.',
4545

46+
// Popover
47+
public ?string $popover = null,
48+
public ?string $popoverIcon = "o-question-mark-circle",
49+
public ?string $popoverTriggerClass = '',
50+
public ?string $popoverContentClass = '',
51+
4652
// Validations
4753
public ?string $errorField = null,
4854
public ?string $errorClass = 'text-error label-text-alt p-1',
@@ -248,6 +254,18 @@ public function render(): View|Closure|string
248254
@if($attributes->get('required'))
249255
<span class="text-error">*</span>
250256
@endif
257+
258+
{{-- INPUT POPOVER --}}
259+
@if($popover)
260+
<x-mary-popover offset="5" position="top-start">
261+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
262+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
263+
</x-slot:trigger>
264+
<x-slot:content class="{{ $popoverContentClass }}">
265+
{{ $popover }}
266+
</x-slot:content>
267+
</x-mary-popover>
268+
@endif
251269
</legend>
252270
@endif
253271

src/View/Components/Colorpicker.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ public function __construct(
2222
public ?bool $inline = false,
2323
public ?bool $clearable = false,
2424

25+
// Popover
26+
public ?string $popover = null,
27+
public ?string $popoverIcon = "o-question-mark-circle",
28+
public ?string $popoverTriggerClass = '',
29+
public ?string $popoverContentClass = '',
30+
2531
// Validations
2632
public ?string $errorField = null,
2733
public ?string $errorClass = 'text-error',
@@ -70,6 +76,18 @@ public function render(): View|Closure|string
7076
@if($attributes->get('required'))
7177
<span class="text-error">*</span>
7278
@endif
79+
80+
{{-- INPUT POPOVER --}}
81+
@if($popover)
82+
<x-mary-popover offset="5" position="top-start">
83+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
84+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
85+
</x-slot:trigger>
86+
<x-slot:content class="{{ $popoverContentClass }}">
87+
{{ $popover }}
88+
</x-slot:content>
89+
</x-mary-popover>
90+
@endif
7391
</legend>
7492
@endif
7593

src/View/Components/DatePicker.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ public function __construct(
2222
public ?bool $clearable = false,
2323
public ?array $config = [],
2424

25+
// Popover
26+
public ?string $popover = null,
27+
public ?string $popoverIcon = "o-question-mark-circle",
28+
public ?string $popoverTriggerClass = '',
29+
public ?string $popoverContentClass = '',
30+
2531
// Slots
2632
public mixed $prepend = null,
2733
public mixed $append = null,
@@ -117,6 +123,18 @@ public function render(): View|Closure|string
117123
@if($attributes->get('required'))
118124
<span class="text-error">*</span>
119125
@endif
126+
127+
{{-- INPUT POPOVER --}}
128+
@if($popover)
129+
<x-mary-popover offset="5" position="top-start">
130+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
131+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
132+
</x-slot:trigger>
133+
<x-slot:content class="{{ $popoverContentClass }}">
134+
{{ $popover }}
135+
</x-slot:content>
136+
</x-mary-popover>
137+
@endif
120138
</legend>
121139
@endif
122140

src/View/Components/DateTime.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public function __construct(
1919
public ?string $hintClass = 'fieldset-label',
2020
public ?bool $inline = false,
2121

22+
// Popover
23+
public ?string $popover = null,
24+
public ?string $popoverIcon = "o-question-mark-circle",
25+
public ?string $popoverTriggerClass = '',
26+
public ?string $popoverContentClass = '',
27+
2228
// Slots
2329
public mixed $prepend = null,
2430
public mixed $append = null,
@@ -61,6 +67,18 @@ public function render(): View|Closure|string
6167
@if($attributes->get('required'))
6268
<span class="text-error">*</span>
6369
@endif
70+
71+
{{-- INPUT POPOVER --}}
72+
@if($popover)
73+
<x-mary-popover offset="5" position="top-start">
74+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
75+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
76+
</x-slot:trigger>
77+
<x-slot:content class="{{ $popoverContentClass }}">
78+
{{ $popover }}
79+
</x-slot:content>
80+
</x-mary-popover>
81+
@endif
6482
</legend>
6583
@endif
6684

src/View/Components/Editor.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ public function __construct(
2222
public ?bool $gplLicense = false,
2323
public ?array $config = [],
2424

25+
// Popover
26+
public ?string $popover = null,
27+
public ?string $popoverIcon = "o-question-mark-circle",
28+
public ?string $popoverTriggerClass = '',
29+
public ?string $popoverContentClass = '',
30+
2531
// Validations
2632
public ?string $errorField = null,
2733
public ?string $errorClass = 'text-error',
@@ -79,6 +85,18 @@ public function render(): View|Closure|string
7985
@if($attributes->get('required'))
8086
<span class="text-error">*</span>
8187
@endif
88+
89+
{{-- INPUT POPOVER --}}
90+
@if($popover)
91+
<x-mary-popover offset="5" position="top-start">
92+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
93+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
94+
</x-slot:trigger>
95+
<x-slot:content class="{{ $popoverContentClass }}">
96+
{{ $popover }}
97+
</x-slot:content>
98+
</x-mary-popover>
99+
@endif
82100
</legend>
83101
@endif
84102

src/View/Components/File.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public function __construct(
2424
public ?array $cropConfig = [],
2525
public ?string $cropMimeType = "image/png",
2626

27+
// Popover
28+
public ?string $popover = null,
29+
public ?string $popoverIcon = "o-question-mark-circle",
30+
public ?string $popoverTriggerClass = '',
31+
public ?string $popoverContentClass = '',
32+
2733
// Validations
2834
public ?string $errorField = null,
2935
public ?string $errorClass = 'text-error',
@@ -145,6 +151,18 @@ public function render(): View|Closure|string
145151
@if($attributes->get('required'))
146152
<span class="text-error">*</span>
147153
@endif
154+
155+
{{-- INPUT POPOVER --}}
156+
@if($popover)
157+
<x-mary-popover offset="5" position="top-start">
158+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
159+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
160+
</x-slot:trigger>
161+
<x-slot:content class="{{ $popoverContentClass }}">
162+
{{ $popover }}
163+
</x-slot:content>
164+
</x-mary-popover>
165+
@endif
148166
</legend>
149167
@endif
150168

src/View/Components/ImageLibrary.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public function __construct(
2929
public ?array $cropConfig = [],
3030
public Collection $preview = new Collection(),
3131

32+
// Popover
33+
public ?string $popover = null,
34+
public ?string $popoverIcon = "o-question-mark-circle",
35+
public ?string $popoverTriggerClass = '',
36+
public ?string $popoverContentClass = '',
37+
3238
) {
3339
$this->uuid = "mary" . md5(serialize($this)) . $id;
3440
}
@@ -142,6 +148,18 @@ public function render(): View|Closure|string
142148
@if($attributes->get('required'))
143149
<span class="text-error">*</span>
144150
@endif
151+
152+
{{-- INPUT POPOVER --}}
153+
@if($popover)
154+
<x-mary-popover offset="5" position="top-start">
155+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
156+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
157+
</x-slot:trigger>
158+
<x-slot:content class="{{ $popoverContentClass }}">
159+
{{ $popover }}
160+
</x-slot:content>
161+
</x-mary-popover>
162+
@endif
145163
</legend>
146164
@endif
147165

src/View/Components/Input.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ public function __construct(
2323
public ?bool $clearable = false,
2424
public ?bool $money = false,
2525
public ?string $locale = 'en-US',
26+
27+
// Popover
2628
public ?string $popover = null,
2729
public ?string $popoverIcon = "o-question-mark-circle",
30+
public ?string $popoverTriggerClass = '',
31+
public ?string $popoverContentClass = '',
2832

2933
// Slots
3034
public mixed $prepend = null,
@@ -91,10 +95,10 @@ public function render(): View|Closure|string
9195
{{-- INPUT POPOVER --}}
9296
@if($popover)
9397
<x-mary-popover offset="5" position="top-start">
94-
<x-slot:trigger>
98+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
9599
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
96100
</x-slot:trigger>
97-
<x-slot:content>
101+
<x-slot:content class="{{ $popoverContentClass }}">
98102
{{ $popover }}
99103
</x-slot:content>
100104
</x-mary-popover>

src/View/Components/Markdown.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public function __construct(
2121
public ?string $folder = 'markdown',
2222
public ?array $config = [],
2323

24+
// Popover
25+
public ?string $popover = null,
26+
public ?string $popoverIcon = "o-question-mark-circle",
27+
public ?string $popoverTriggerClass = '',
28+
public ?string $popoverContentClass = '',
29+
2430
// Validations
2531
public ?string $errorField = null,
2632
public ?string $errorClass = 'text-error',
@@ -93,6 +99,18 @@ public function render(): View|Closure|string
9399
@if($attributes->get('required'))
94100
<span class="text-error">*</span>
95101
@endif
102+
103+
{{-- INPUT POPOVER --}}
104+
@if($popover)
105+
<x-mary-popover offset="5" position="top-start">
106+
<x-slot:trigger class="{{ $popoverTriggerClass }}">
107+
<x-mary-icon :name="$popoverIcon" class="w-4 h-4 opacity-40 mb-0.5" />
108+
</x-slot:trigger>
109+
<x-slot:content class="{{ $popoverContentClass }}">
110+
{{ $popover }}
111+
</x-slot:content>
112+
</x-mary-popover>
113+
@endif
96114
</legend>
97115
@endif
98116

0 commit comments

Comments
 (0)