joshuadavidthomas / django-bird

High-flying components for perfectionists with deadlines
https://django-bird.readthedocs.io
MIT License
37 stars 1 forks source link

Collect CSS and JS static assets #14

Open joshuadavidthomas opened 2 weeks ago

joshuadavidthomas commented 2 weeks ago

Any CSS or JS defined in a bird component should be collected as part of the compilation and thrown in some registry that can then be referenced to provide assets when a component is included in a template.

I really like Flux here, where there's just one reference per asset type in the base template:

<head>
    ...
    @fluxStyles
</head>

<body>
    ...
    @fluxScripts
</body>

I assume that's laravel's version of a templatetag, so for django-bird the equivalent would look something like:

{% load django_bird %}

<head>
    {% django_bird_css %}
</head>
<body>
    {% django_bird_js %}
</body>

(Not married to those templatetag names, but it'll do for now.)

Then in the templatetag's themselves, have someway to look up what components are on the page and only return those. This is a wishlist item, as I sit here now I'm struggling to come up with how to handle partials e.g. through an HTMX request.

There may be a way to accomplish this, but in the mean time just returning all the component asset files will be fine.