djangocms-frontend icon indicating copy to clipboard operation
djangocms-frontend copied to clipboard

feat: Make frontend plugins re-usable components

Open fsbraun opened this issue 1 year ago • 1 comments

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.

fsbraun avatar May 28 '24 19:05 fsbraun

Codecov Report

Attention: Patch coverage is 80.83004% with 97 lines in your changes missing coverage. Please review.

Project coverage is 86.70%. Comparing base (f11feee) to head (effbde2). Report is 51 commits behind head on master.

Files with missing lines Patch % Lines
djangocms_frontend/contrib/link/helpers.py 48.14% 18 Missing and 10 partials :warning:
djangocms_frontend/templatetags/frontend.py 81.81% 11 Missing and 7 partials :warning:
djangocms_frontend/helpers.py 68.00% 9 Missing and 7 partials :warning:
djangocms_frontend/frameworks/tailwind.py 0.00% 13 Missing :warning:
djangocms_frontend/contrib/component/components.py 93.02% 2 Missing and 4 partials :warning:
...ms_frontend/contrib/icon/templatetags/icon_tags.py 37.50% 5 Missing :warning:
djangocms_frontend/contrib/component/registry.py 76.47% 2 Missing and 2 partials :warning:
djangocms_frontend/common/__init__.py 76.92% 3 Missing :warning:
djangocms_frontend/cms_plugins.py 90.47% 1 Missing and 1 partial :warning:
djangocms_frontend/component_pool.py 97.91% 0 Missing and 1 partial :warning:
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #220      +/-   ##
==========================================
- Coverage   86.93%   86.70%   -0.23%     
==========================================
  Files         120      124       +4     
  Lines        3107     3422     +315     
  Branches      330      404      +74     
==========================================
+ Hits         2701     2967     +266     
- Misses        304      333      +29     
- Partials      102      122      +20     

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

codecov[bot] avatar May 28 '24 19:05 codecov[bot]