platform icon indicating copy to clipboard operation
platform copied to clipboard

Added variable for change command bar position

Open bald-cat opened this issue 10 months ago • 0 comments

Fixes #

Proposed Changes

I suggest adding the ability to change the position of the command bar in the Layout::block(). This can be useful in some cases where commands need to be displayed at the table level or to display commands above the form they belong to.

top-commands-table

Code example:

Layout::block([
                Layout::table('table', [
                    TD::make('id', 'ID')
                        ->width('100')
                        ->render(fn (Repository $model) => // Please use view('path')
                        "<img src='https://loremflickr.com/500/300?random={$model->get('id')}'
                              alt='sample'
                              class='mw-100 d-block img-fluid rounded-1 w-100'>
                            <span class='small text-muted mt-1 mb-0'># {$model->get('id')}</span>"),

                    TD::make('name', 'Name')
                        ->width('450')
                        ->render(fn (Repository $model) => Str::limit($model->get('name'), 200)),

                    TD::make('price', 'Price')
                        ->width('100')
                        ->usingComponent(Currency::class, before: '$')
                        ->align(TD::ALIGN_RIGHT),

                    TD::make('created_at', 'Created')
                        ->width('100')
                        ->usingComponent(DateTimeSplit::class)
                        ->align(TD::ALIGN_RIGHT),
                ]),
            ])
                ->vertical()
                ->commands([
                    Button::make('Add')->icon('bs.plus'),
                    Button::make('Delete')->icon('bs.trash'),
                    Button::make('Send')->icon('bs.send'),
                ], top: true),

At first I wanted to add a whole system of constants, but I decided to simplify everything and just added one more optional parameter to the method.

First variant example: )))

    public const COMMAND_TOP = 'top';

    public const COMMAND_BOTTOM = 'bottom';

    public const BAR_TABLE_CLASSES = [
        self::COMMAND_TOP => 'rounded-bottom',
        self::COMMAND_BOTTOM => 'rounded-top',
    ];

    /**
     * @var string
     */
    protected $template = 'platform::layouts.block';

    public $commandBarPosition = self::COMMAND_BOTTOM;
    ```

bald-cat avatar Apr 07 '25 14:04 bald-cat