wrabit / django-cotton

Enabling Modern UI Composition in Django
https://django-cotton.com
MIT License
506 stars 20 forks source link

Is there a way to define default value for "Named slots"? #210

Closed bal-sm closed 23 hours ago

bal-sm commented 3 days ago

It will be really helpful and cool, I think.

I mean if it can also have multi-lined html content as default value in some different tag than c-vars, perhaps?

bal-sm commented 3 days ago

and also can we work on how to properly define variation so we can just:

<c-button:red>Delete account</c-button:red>
copyfactory commented 2 days ago

@bal-sm , @wrabit wrote a guide on creating variations for components. It's worth a read :).

https://medium.com/@willabbott/django-cotton-component-variants-for-smarter-reusability-07d8e4358ed0

wrabit commented 1 day ago

Hi @bal-sm, for now you will need to manage defaults this way:

{% if named_slot %}
  {{ named_slot }}
{% else %}
  my default
{% endif %}

I would like to simplify the syntax and align it to Vue for example, (see here) but nothing is planned in this moment..

About your suggested syntax of variation - there would be no way to say what you are configuring (a component could have many types of variation) so the keyed approach seems to be the most logical for now.