django-cms / djangocms-frontend

django CMS frontend is a plugin bundle for django CMS providing several components for the frontend, currently implemented with the popular Bootstrap 5 framework.
Other
42 stars 20 forks source link

feat: Make frontend plugins re-usable components #220

Open fsbraun opened 1 month ago

fsbraun commented 1 month ago

When designing frontends it is key to avoid repeating template/HTML code. This PR makes djangocms-frontend components like alerts, cards, buttons or links, etc.

This PR provides a simple way to re-use djangocms-frontend plugins in templates:

{% load frontend %}
{% url "some-name" as link_target %}
{% plugin "link" external_link=link_target link_type="btn" link_context="primary" link_outline=False %}
    Click me!
{% endplugin %}

or

{% load frontend %}
{% plugin "card" card_alignment="center" card_outline="info"  card_text_color="primary" card_full_height=True %}
    {% plugin "cardinner" inner_type="card-header" text_alignment="start" %}
        <h4>Card title</h4>
    {% endplugin %}
    {% plugin "cardinner" inner_type="card-body" text_alignment="center" %}
        Some quick example text to build on the card title and make up the
        bulk of the card's content.
    {% endplugin %}
    {% plugin "listgroupitem" %}An item{% endplugin %}
    {% plugin "listgroupitem" %}A second item{% endplugin %}
    {% plugin "listgroupitem" %}A third item{% endplugin %}
{% endplugin %}

These plugins are not created in the database. They work with djangocms-frontend plugins and most other django CMS plugins.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 87.91541% with 40 lines in your changes missing coverage. Please review.

Project coverage is 87.09%. Comparing base (f11feee) to head (5289f5c). Report is 28 commits behind head on master.

Files Patch % Lines
djangocms_frontend/frameworks/tailwind.py 0.00% 13 Missing :warning:
djangocms_frontend/templatetags/frontend.py 85.71% 5 Missing and 7 partials :warning:
djangocms_frontend/contrib/component/components.py 92.59% 3 Missing and 3 partials :warning:
djangocms_frontend/cms_plugins.py 81.25% 3 Missing :warning:
djangocms_frontend/common/__init__.py 76.92% 3 Missing :warning:
djangocms_frontend/pool.py 94.00% 2 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #220 +/- ## ========================================== + Coverage 86.93% 87.09% +0.16% ========================================== Files 120 123 +3 Lines 3107 3316 +209 Branches 330 385 +55 ========================================== + Hits 2701 2888 +187 - Misses 304 317 +13 - Partials 102 111 +9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.