Skip to content

Commit 6cc39e0

Browse files
committed
Tweak the ColSelect Approach
1 parent ffc9247 commit 6cc39e0

26 files changed

+398
-389
lines changed

docs/actions/_index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Actions
3+
weight: 17
4+
---

docs/actions/basic-action.md

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
---
2+
title: Actions
3+
weight: 2
4+
---
5+
6+
### actions()
7+
8+
Define your actions using the actions() method:
9+
10+
```php
11+
public function actions(): array
12+
{
13+
return [
14+
Action::make('View Dashboard')
15+
->setRoute('dashboard'),
16+
];
17+
}
18+
```
19+
20+
## Button Available Methods
21+
22+
### setLabelAttributes
23+
Set custom attributes for an Action Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts.
24+
25+
By default, this replaces the default classes on the Action Label, if you would like to keep them, set the default flag to true.
26+
27+
```php
28+
Action::make('Dashboard')
29+
->setRoute('dashboard')
30+
->wireNavigate()
31+
->setLabelAttributes([
32+
'class' => 'text-xl',
33+
'default' => true,
34+
]),
35+
```
36+
37+
### setActionAttributes
38+
39+
setActionAttributes is used to pass any attributes that you wish to implement on the "button" element for the action button. By default it will merge with the default classes.
40+
41+
You can set "default-styling" and "default-colors" to false to replace, rather than over-ride either default-styling or default-colors.
42+
```php
43+
public function actions(): array
44+
{
45+
return [
46+
Action::make('View Dashboard')
47+
->setActionAttributes([
48+
'class' => 'dark:bg-blue-500 dark:text-white dark:border-blue-600 dark:hover:border-blue-900 dark:hover:bg-blue-800',
49+
'default-colors' => false, // Will over-ride the default colors
50+
'default-styling' => true // Will use the default styling
51+
]),
52+
];
53+
}
54+
```
55+
56+
### setIcon
57+
58+
setIcon is used to set an icon for the action button
59+
60+
```php
61+
public function actions(): array
62+
{
63+
return [
64+
Action::make('Edit Item')
65+
->setIcon("fas fa-edit"),
66+
];
67+
}
68+
```
69+
70+
### setIconAttributes
71+
72+
setIconAttributes is used to set any additional attributes for the Icon for the action button
73+
```php
74+
public function actions(): array
75+
{
76+
return [
77+
Action::make('Edit Item')
78+
->setIcon("fas fa-edit")
79+
->setIconAttributes(['class' => 'font-4xl text-4xl']),
80+
];
81+
}
82+
```
83+
84+
### setIconLeft
85+
86+
setIconLeft is used to prepend the Icon to the Text (Non-Default Behaviour)
87+
88+
```php
89+
public function actions(): array
90+
{
91+
return [
92+
Action::make('Edit Item')
93+
->setIcon("fas fa-edit")
94+
->setIconAttributes(['class' => 'font-4xl text-4xl'])
95+
->setIconLeft(),
96+
];
97+
}
98+
```
99+
100+
### setIconRight
101+
102+
setIconRight is used to append the Icon to the Text (Default Behaviour)
103+
104+
```php
105+
public function actions(): array
106+
{
107+
return [
108+
Action::make('Edit Item')
109+
->setIcon("fas fa-edit")
110+
->setIconAttributes(['class' => 'font-4xl text-4xl'])
111+
->setIconRight(),
112+
];
113+
}
114+
```
115+
116+
### setRoute
117+
118+
Used for non-wireable butons, to set the route that the action button should take the user to upon clicking.
119+
```php
120+
public function actions(): array
121+
{
122+
return [
123+
Action::make('Dashboard')
124+
->setRoute('dashboard')
125+
];
126+
}
127+
```
128+
129+
### wireNavigate
130+
131+
Used in conjunction with setRoute - makes the link "wire:navigate" rather than default behaviour
132+
```php
133+
public function actions(): array
134+
{
135+
return [
136+
Action::make('Dashboard')
137+
->setRoute('dashboard')
138+
->wireNavigate()
139+
];
140+
}
141+
```
142+
143+
### setWireAction
144+
```php
145+
public function actions(): array
146+
{
147+
return [
148+
Action::make('Create 2')
149+
->setWireAction("wire:click")
150+
];
151+
}
152+
```
153+
154+
### setWireActionParams
155+
Specify the action & parameters to pass to the wire:click method
156+
157+
```php
158+
public function actions(): array
159+
{
160+
return [
161+
Action::make('Create 2')
162+
->setWireAction("wire:click")
163+
->setWireActionParams(['id' => 'test']),
164+
];
165+
}
166+
```
167+
168+
### setWireActionDispatchParams
169+
170+
Use $dispatch rather than a typical wire:click action
171+
172+
```php
173+
public function actions(): array
174+
{
175+
return [
176+
Action::make('Create 2')
177+
->setWireAction("wire:click")
178+
->setWireActionDispatchParams("'openModal', { component: 'test-modal' }"),
179+
];
180+
}
181+
```
182+
183+
### setView
184+
185+
This is used to set a Custom View for the Button
186+
187+
```php
188+
public function actions(): array
189+
{
190+
return [
191+
Action::make('Edit Item')
192+
->setView("buttons.edit"),
193+
];
194+
}
195+
```
196+
197+
198+
## Extending
199+
200+
You can extend the Base Action class which can be a useful timesaver, when you wish to re-use the same look/feel of an Action, but wish to set a different route (for example).
201+
You can set any defaults in the __construct method, ensuring that the parent constructor is called first!
202+
203+
```php
204+
use Rappasoft\LaravelLivewireTables\Views\Action;
205+
206+
class EditAction extends Action
207+
{
208+
public function __construct(?string $label = null)
209+
{
210+
parent::__construct($label);
211+
$this
212+
->setActionAttributes([
213+
'class' => 'dark:bg-blue-500 dark:text-white dark:border-blue-600 dark:hover:border-blue-900 dark:hover:bg-blue-800',
214+
'default-colors' => false,
215+
'default-styling' => true
216+
])
217+
->setIcon("fas fa-edit")
218+
->setIconAttributes([
219+
'class' => 'font-4xl text-4xl'
220+
]);
221+
}
222+
}
223+
```
224+
225+
You may define a Custom View to be used via either the setView method, or by defining the view directly in your class.
226+
```php
227+
protected string $view = 'buttons.edit-action';
228+
```
229+

docs/actions/introduction.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Introduction
3+
weight: 1
4+
---
5+
6+
Actions is a beta feature, that allows for the creation of Action Buttons that appear above the toolbar. These are ideal for common Actions that do not impact existing records, such as a "Create", "Assign", "Back" buttons.
7+
8+
This is NOT recommended for production use at this point in time.
9+
10+
## Component Available Methods
11+
### setActionWrapperAttributes
12+
13+
This is used to set attributes for the "div" that wraps all defined Action Buttons:
14+
15+
```php
16+
public function configure(): void
17+
{
18+
$this->setActionWrapperAttributes([
19+
'class' => 'space-x-4'
20+
]);
21+
}
22+
```
23+
24+
### setActionsInToolbarEnabled
25+
26+
Displays the Actions within the Toolbar. Default is displaying above the Toolbar.
27+
28+
```php
29+
public function configure(): void
30+
{
31+
$this->setActionsInToolbarEnabled();
32+
}
33+
```
34+
35+
### setActionsInToolbarDisabled
36+
37+
Displays the Actions above the Toolbar, default behaviour
38+
```php
39+
public function configure(): void
40+
{
41+
$this->setActionsInToolbarDisabled();
42+
}
43+
```
44+
45+
46+
### setActionsLeft
47+
48+
Displays the Actions justified to the left
49+
50+
```php
51+
public function configure(): void
52+
{
53+
$this->setActionsLeft();
54+
}
55+
```
56+
57+
### setActionsCenter
58+
59+
Displays the Actions justified to the center
60+
61+
```php
62+
public function configure(): void
63+
{
64+
$this->setActionsCenter();
65+
}
66+
```
67+
68+
### setActionsRight
69+
70+
Displays the Actions justified to the right
71+
72+
```php
73+
public function configure(): void
74+
{
75+
$this->setActionsRight();
76+
}
77+
```
78+
79+
### Example
80+
81+
The below would:
82+
- Set your Actions as a "Dropdown"
83+
- Add the Actions dropdown as a Toolbar item
84+
- Set the Actions dropdown as a "right" item of the Toolbar.
85+
86+
```php
87+
public function configure(): void
88+
{
89+
$this->setActionsAsDropdownEnabled()
90+
->setActionsInToolbarEnabled()
91+
->setActionsRight();
92+
}
93+
```

docs/examples/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
title: Examples
3-
weight: 17
3+
weight: 18
44
---

docs/misc/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
title: Misc.
3-
weight: 18
3+
weight: 19
44
---

docs/misc/actions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,4 @@ You may define a Custom View to be used via either the setView method, or by def
300300
protected string $view = 'buttons.edit-action';
301301
```
302302

303+
$this->setActionsInToolbarEnabled()->setActionsAsDropdownEnabled()->setActionsRight();

0 commit comments

Comments
 (0)