Download the PHP package bernskioldmedia/laravel-livewire-widgets without Composer

On this page you can find all versions of the php package bernskioldmedia/laravel-livewire-widgets. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-livewire-widgets

A framework for adding self-contained Livewire-powered widgets to your application.

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Installation

You can install the package via composer:

After requiring the package, you should import the base styles to your stylesheet. You can do this by importing the provided widgets.css file in your app.scss file:

Tip: Your import should be placed above any Tailwind imports to ensure that the styles are applied correctly. We'd recommend using the @import syntax instead of @tailwind when loading Tailwind's base, components and utilities.

After installing the package you should review the installation instructions for the Laravel Highcharts package if you plan on using the Chart Widget.

Publishing Config and Views

You don't typically need to publish either the config file or the views.

You can publish the config file with:

This is the contents of the published config file:

Optionally, you can publish the views using

Usage

Supported Widget Types

This package supplies two opinionated widget, and one base widget that you can use to build your own.

See below for how to use each of these.

Creating a Widget

To create a new widget create a new Livewire class that extends either one of the widget type classes, or the base Widget class. A good place to put these is in the App\Livewire\Widgets namespace.

Note: You do not need to create a view/blade file for your widget if you are using one of the pre-defined widgets ( see the list above).

Lazy Loading

Unfortunately we haven't found a good way to default to lazy loading. As such as we recommend that you add the #[Lazy] attribute to your widget classes.

Rendering a widget

To render a widget, you can use the livewire Blade directive as any other Livewire component:

Chart Widget

Chart widgets are widgets that display a chart. They extend the ChartWidget class. To use this widget you must first set up the Laravel Highcharts package. Refer to its documentation for how to create charts.

To create a chart widget, extend the ChartWidget class and implement the getChart method.

Statistic Widget

The Statistic Widget is a widget that displays a statistic with a label, a value and a change indicator.

To create a statistic widget, extend the StatisticWidget class and implement the getValue method.

To display a change indicator, implement the ComparesValues interface and return the previous value from the getPreviousValue method.

There are a few additional properties that you can set on the widget:

Widget Sizes

Widgets are rendered in a responsive grid and can be rendered in different widths and heights.

All widths are available in the WidgetWidths enum, which we recommend over hardcoded string values. These equal:

Heights are based on the number of rows the widget should take up. As such, the height is dependent on the height of surrounding widgets. All heights are available in the WidgetHeights enum, which we recommend over hardcoded strings.

The following heights are available:

Note: Rows do not have a base height by themselves.

By default widgets are rendered in a 1/4 width and 1 row height. You can change this by overriding the width and height properties on your widget.

You can also set the width and height when loading the widget in your view:

Adding a title

You can add support for a title by implementing the HasTitle trait on your widget. The Chart Widget and Statistic Widget both have this included.

This trait adds a title property to your widget. You can set this property when loading the widget in your view, which offers a simple way of customizing the title on load. You may also provide a default title by returning a string from the defaultTitle method.

The title is available in your view as $widgetTitle.

Adding a description

You can add support for a description by implementing the HasDescription trait on your widget. The Chart Widget and Statistic Widget both have this included. This trait adds a description property to your widget. You can set this property when loading the widget in your view, which offers a simple way of customizing the description on load. You may also provide a default description by returning a string from the defaultDescription method.

The description is available in your view as $widgetDescription.

Supporting Filters

You can add support for filters by implementing the Filterable trait on your widget as well as the SupportsFilters interface. This trait adds a filters property to your widget. You can set this property when loading the widget in your view, which offers a simple way of customizing the filters on load.

You may also provide default filters by returning an array from the defaultFilters method.

The default filters will be overridden with any filters you pass when loading the widget.

You may also provide a list of forced filters which cannot be overridden by the user when loading the widget. You do this by overriding the forcedFilters method.

The trait also adds convenience methods for interacting with filters:

Defining a custom view

Because of the helper methods we include, adding a view is slightly different. Instead of using the render method, you define the static view method and return the view name.

You can pass additional data to the view by returning an array from the getViewData method:

Placeholders

The package ships with default placeholders for each widget type, as well as a plain base widget placeholder. To use your our placeholder view, return the view name from the placeholderView method:

You can pass data to the placeholder view by returning an array from the placeholderData method. You should merge your data with the parent method's data.

Customizing the Styles

We have tried to make the styles we ship as unopinionated as possible to only provide the structure you most likely will need regardless of appearance. As such, you will want to apply additional customization to the widget classes to make them fit your application.

You may customize the widget grid gap and widget padding by using the following CSS variables:

Responsive Widget Grid

By default, widgets are rendered in a responsive grid. The grid is based on CSS Grid and is responsive in a slightly opinionated way. This means that each widget only has a specific width configured, which is the width it will take up on desktop. On smaller screens, the width is automatically adjusted.

The base grid is:

Each Widget Width corresponds to a number of columns:

You may customize this setup by overriding the corresponding width classes in your own stylesheet.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-livewire-widgets with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
bernskioldmedia/laravel-highcharts Version ^0.1.0
illuminate/contracts Version ^10.0
livewire/livewire Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bernskioldmedia/laravel-livewire-widgets contains the following files

Loading the files please wait ....