Skip to content

Commit

Permalink
Merge pull request moonshine-software#534 from DissNik/release-2.22
Browse files Browse the repository at this point in the history
Release 2.22
  • Loading branch information
DissNik authored Sep 6, 2024
2 parents 3223fa9 + 6f3f107 commit 0309288
Show file tree
Hide file tree
Showing 25 changed files with 575 additions and 16 deletions.
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/screenshots/block_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/screenshots/block_icon_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/screenshots/collapse_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/screenshots/collapse_icon_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/vendor/moonshine/assets/main.css

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions resources/views/examples/components/tabs-slots.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<x-moonshine::tabs
:tabs="[
'tab_1' => 'Tab 1',
'tab_2' => 'Tab 2'
]"
>
<x-slot:tab_1>
{{ fake()->text() }}
</x-slot:tab_1>
<x-slot:tab_2>
{{ fake()->text() }}
</x-slot:tab_2>
</x-moonshine::tabs>
12 changes: 12 additions & 0 deletions resources/views/pages/en/advanced/authentication.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@
then specify <code>'avatar'=>''</code> or <code>'avatar'=>false</code>.
</x-moonshine::alert>

<x-p>
It is possible to change <em>Guard</em> in the Profile component.
</x-p>

<x-code language="php">
Profile::make(guard: 'custom')
</x-code>

<x-code language="php">
MoonShineAuth::guard('custom')->user()
</x-code>

<x-sub-title id="pipelines">Pipelines</x-sub-title>

<x-p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'Sections' => [
['url' => '#make', 'label' => 'Make'],
['url' => '#wihtout-heading', 'label' => 'No title'],
['url' => '#icon', 'label' => 'Icon'],
]
]"
>
Expand Down Expand Up @@ -71,4 +72,8 @@ public function components(): array
<x-image theme="light" src="{{ asset('screenshots/block_without_title.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/block_without_title_dark.png') }}"></x-image>

<x-sub-title id="icon">Icon</x-sub-title>

@include('pages.en.components.shared.decoration_icon', ['decoration' => 'Block'])

</x-page>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
:sectionMenu="[
'Sections' => [
['url' => '#make', 'label' => 'Make'],
['url' => '#icon', 'label' => 'Icon'],
['url' => '#show', 'label' => 'Show'],
['url' => '#persist', 'label' => 'Persist'],
]
Expand Down Expand Up @@ -41,6 +42,10 @@ public function components(): array
<x-image theme="light" src="{{ asset('screenshots/collapse.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/collapse_dark.png') }}"></x-image>

<x-sub-title id="icon">Icon</x-sub-title>

@include('pages.en.components.shared.decoration_icon', ['decoration' => 'Collapse'])

<x-sub-title id="show">Show</x-sub-title>

<x-p>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<x-p>
The <code>icon()</code> method allows you to add an icon.
</x-p>

<x-code language="php">
use MoonShine\Decorations\{{ $decoration }};

//...

public function components(): array
{
return [
{{ $decoration }}::make('{{ $decoration }}')
->icon('heroicons.outline.users') // [tl! focus]
];
}

//...
</x-code>

@include('pages.en.shared.alert_icons')

<x-image theme="light" src="{{ asset('screenshots/' . str($decoration)->snake('_')->append('_icon.png')) }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/' . str($decoration)->snake('_')->append('_icon_dark.png')) }}"></x-image>
22 changes: 18 additions & 4 deletions resources/views/pages/en/components/system_profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,26 @@ class <code>Profile</code>.
</x-p>

<x-code language="php">
make(bool $withBorder = false)
make(
?string $route = null,
?string $logOutRoute = null,
Closure|false|null|string $avatar = null,
Closure|null|string $nameOfUser = null,
Closure|null|string $username = null,
bool $withBorder = false,
?string $guard = null
)
</x-code>

<x-p>
<code>$withBorder</code> - to split before the component.
</x-p>
<x-ul>
<li><code>$route</code> - profile page route,</li>
<li><code>$logOutRoute</code> - route for logout</li>
<li><code>$avatar</code> - user avatar</li>
<li><code>$nameOfUser</code> - user name</li>
<li><code>$username</code> - username (email|login|tel ...),</li>
<li><code>$withBorder</code> - split before the component</li>
<li><code>$guard</code> - used by <em>Guard</em> for user authorization.</li>
</x-ul>

<x-code language="php">
namespace App\MoonShine;
Expand Down
76 changes: 76 additions & 0 deletions resources/views/pages/en/fields/json.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
['url' => '#relation', 'label' => 'Relationships via Json'],
['url' => '#filter', 'label' => 'Filter'],
['url' => '#buttons', 'label' => 'Buttons'],
['url' => '#modify', 'label' => 'Modify'],
]
]"
>
Expand Down Expand Up @@ -490,4 +491,79 @@ public function fields(): array
//...
</x-code>

<x-sub-title id="modify">Modify</x-sub-title>

<x-p>
The <em>Json</em> field has methods with which you can modify the delete button or
change <em>TableBuilder</em> for preview and form.
</x-p>

<x-moonshine::divider label="modifyRemoveButton()" />

<x-p>
The <code>modifyRemoveButton()</code> method allows you to change the remove button.
</x-p>

<x-code language="php">
/**
* @param Closure(ActionButton $button, self $field): ActionButton $callback
*/
modifyRemoveButton(Closure $callback)
</x-code>

<x-code language="php">
use MoonShine\ActionButtons\ActionButton;
use MoonShine\Fields\Json;

//...

public function fields(): array
{
return [
Json::make('Data')
->modifyRemoveButton(
fn(ActionButton $button) => $button->customAttributes([
'class' => 'btn-secondary'
])
) // [tl! focus:-4]
];
}

//...
</x-code>

<x-moonshine::divider label="modifyTable()" />

<x-p>
The <code>modifyTable()</code> method allows you to change the <em>TableBuilder</em> for the preview and form.
</x-p>

<x-code language="php">
/**
* @param Closure(TableBuilder $table, bool $preview): TableBuilder $callback
*/
modifyTable(Closure $callback)
</x-code>

<x-code language="php">
use MoonShine\Components\TableBuilder;
use MoonShine\Fields\Json;

//...

public function fields(): array
{
return [
Json::make('Data')
->modifyTable(
fn(TableBuilder $table, bool $preview) => $table->customAttributes([
'style' => 'width: 50%;'
])
) // [tl! focus:-4]
];
}

//...
</x-code>

</x-page>
24 changes: 23 additions & 1 deletion resources/views/pages/en/fields/text.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,29 @@ public function fields(): array
<x-p><x-moonshine::badge color="green">+</x-moonshine::badge> ability to copy a value using a button</x-p>

<x-code language="php">
copy()
copy(string $value = '@{{value}}')
</x-code>

<x-ul>
<li><code>@{{value}}</code> - field value.</li>
</x-ul>

<x-code language="php">
use MoonShine\Fields\Text;

//...

public function fields(): array
{
return [
Text::make('Title')
->copy(), // [tl! focus]
Text::make('Token')
->copy('https://domain.com?token=@{{value}}') // [tl! focus]
];
}

//...
</x-code>

<x-p><x-moonshine::badge color="green">+</x-moonshine::badge> lock with change blocking</x-p>
Expand Down
103 changes: 103 additions & 0 deletions resources/views/pages/en/resources/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
['url' => '#async', 'label' => 'Asynchronous mode'],
['url' => '#update-row', 'label' => 'Updating a row'],
['url' => '#column-display', 'label' => 'Column display'],
['url' => '#modify', 'label' => 'Modify'],
]
]">

Expand Down Expand Up @@ -418,4 +419,106 @@ public function fields(): array
}
</x-code>

<x-sub-title id="modify">Modify</x-sub-title>

<x-p>
You can replace <code>thead</code> or <code>tbody</code> or <code>tfoot</code>,
and also add elements to the table in <code>tbody</code> before and after the first row.
</x-p>

<x-moonshine::divider label="thead()" />

<x-code language="php">
namespace App\MoonShine\Resources;

use MoonShine\Fields\Fields;
use MoonShine\Resources\ModelResource;

class PostResource extends ModelResource
{
// ...

public function thead(): ?Closure
{
return static fn(Fields $headFields): string => '<tr><th>Title</th></tr>';
} // [tl! focus:-3]
}
</x-code>

<x-moonshine::divider label="tbody()" />

<x-code language="php">
namespace App\MoonShine\Resources;

use Illuminate\Support\Collection;
use MoonShine\Resources\ModelResource;

class PostResource extends ModelResource
{
// ...

public function tbody(): ?Closure
{
return static fn(Collection $rows): string => '<tr><td>Content</td></tr>';
} // [tl! focus:-3]
}
</x-code>

<x-moonshine::divider label="tfoot()" />

<x-code language="php">
namespace App\MoonShine\Resources;

use MoonShine\ActionButtons\ActionButtons;
use MoonShine\Resources\ModelResource;

class PostResource extends ModelResource
{
// ...

public function tfoot(): ?Closure
{
return static fn(ActionButtons $bulkButtons): string => '<tr><td>Footer</td></tr>';
} // [tl! focus:-3]
}
</x-code>

<x-moonshine::divider label="tbodyBefore()" />

<x-code language="php">
namespace App\MoonShine\Resources;

use Illuminate\Support\Collection;
use MoonShine\Resources\ModelResource;

class PostResource extends ModelResource
{
// ...

public function tbodyBefore(): ?Closure
{
return static fn(Collection $rows): string => '<tr><td>Before</td></tr>';
} // [tl! focus:-3]
}
</x-code>

<x-moonshine::divider label="tbodyAfter()" />

<x-code language="php">
namespace App\MoonShine\Resources;

use Illuminate\Support\Collection;
use MoonShine\Resources\ModelResource;

class PostResource extends ModelResource
{
// ...

public function tbodyAfter(): ?Closure
{
return static fn(Collection $rows): string => '<tr><td>After</td></tr>';
} // [tl! focus:-3]
}
</x-code>

</x-page>
Loading

0 comments on commit 0309288

Please sign in to comment.