Download the PHP package tanthammar/laravel-window-size without Composer
On this page you can find all versions of the php package tanthammar/laravel-window-size. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tanthammar/laravel-window-size
More information about tanthammar/laravel-window-size
Files in tanthammar/laravel-window-size
Package laravel-window-size
Short Description Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css
License MIT
Informations about the package laravel-window-size
Laravel Window Size and Breakpoints
Laravel blade
directives and php helpers
for server side rendered content, based on browser window size WITHOUT css.
An example to show the purpose of this package:
Requirements
- php 8
- Laravel 8
- IE11 not supported, (but you can update the blade component yourself :).
Do you use Livewire?
There is a Livewire version of this package. Link >>>
Description
The main purpose of this package is not to avoid duplicated html, but to avoid unnecessary server side code execution, just to render content that will never be seen.
- Vanilla JS syncs the browsers inner
width
andheight
, in realtime (debounced 750ms), when the browser window is resized. - The corresponding Laravel controller will store the values to the Laravel
Session
. - The package has a
config/breakpoints
file where you set your breakpoints - The package provides multiple
@blade
directives and Laravelhelpers()
- You have access to the browser window width/height via
session('windowW')
andsession('windowH')
- You can change the config dynamically with Laravel
Config::set(...)
- The route is throttling the request
15:1
. (The route is:/update-laravel-window-size
)
Important note
It's important to understand the difference between the server side rendered breakpoints, that this package provides, and css media queries.
When using css, the content of the page will update in realtime as the user resizes the window, whereas this package debounces a network request and updates the page on the next page request.
It's important that you place the <x-window-size::save-to-session />
at first point of contact with the user, for your application to look its best. I have it in my app.blade.php
and on the login
/register
pages.
Installation
Publish config
The default settings are based on TailwindCSS breakpoints
Add the component to your layout
- Add this to all layouts where you want to keep track of the browser window size.
- You will have access to the browser window width/height via
session('windowW')
andsession('windowH')
Example: app.blade.php
Blade directives
@elsif..., @else..., @end..., @unless... and @endif works with all the directives. Explanation in Laravel docs.
Example
Helpers
Same name as Blade directives
Example php
Blade directives test component
Add this to any blade view to test the blade directives
💬 Let's connect
- 🔗 Please 💗 sponsor me if you like my work.
Credits
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-window-size with dependencies
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0