EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
4.05k stars 1.02k forks source link

[Feature] Display a loading bar to show the page loading progress #5882

Open dwd-akira opened 1 year ago

dwd-akira commented 1 year ago

Hi @javiereguiluz,

Some of my javascript code can lengthen the loading of the page, the favicon show the loading but a progress bar on top of the page can be more visible.

Pace library (https://codebyzach.github.io/pace/) can do it easily.

  1. Include https://cdn.jsdelivr.net/npm/pace-js@latest/pace.min.js in the header
  2. Include https://cdn.jsdelivr.net/npm/pace-js@latest/pace-theme-default.min.css in the header
  3. Add pace-done on body class

If it's not possible to add this feature, how can i do that without rewrite layout.html.twig (add body class for all pages) ?

dwd-akira commented 1 year ago

I found how, but i need to create "template/admin/bundles/EasyAdminBundle/crud/" twig template for all crud.

{% extends '@!EasyAdmin/crud/new.html.twig' %}

{% block body_class %}{{ parent() }} pace-done{% endblock %}

...

{% extends '@!EasyAdmin/page/content.html.twig' %}

{% block body_class %}{{ parent() }} pace-done{% endblock %}

And in my DashboardController

public function configureAssets(): Assets
    {
        return Assets::new()
            ->addJsFile('the pace js')
            ->addCssFile('the pace css');
    }