Repository navigation
Reviving the project - #4
moalhaddar wants to merge 4 commits into
Conversation
…emoved media attr from css, made it work with django 2.2
287c9c0 to
458b538
Compare
|
Hi! Big thanks for contributing your changes back to the project. I've now gone through all the code you've added!
The only thing I don't understand is the child component. Could you give an example of how you use it and why it is good to have? |
|
@mohammedalhaddar Hi! Did you see my last question above? |
Sorry for the late response. Been a really busy week. The child component tag can be used to mock the behavior of react, something like: But there is a problem with that. So the solution i've made is to define the children separately. Suppose that i have a Card component that is expected to receive a prop called title
So a child component tag can be used to build a complex block as follows Then we can pass custom_title as a prop to the main component as
|
|
Thanks for your explaination! I'll have to think about this, if this is a good addition to django-components. Very interesting! :) |
|
Hi again! There's now support for components with nested subparts, similar to how components work in react. I didn't quite use your API, but I think this ended up really nice anyways. Here's an example component: <div class="calendar-component">
<div class="header">
{% slot "header" %}Calendar header{% endslot %}
</div>
<div class="body">
{% slot "body" %}Calendar body{% endslot %}
</div>
</div>When using the component, you specify what slots you want to fill and where you want to use the defaults from the template. It looks like this: {% component_block %}
{% slot "body" %}Today's date is <span>{{ date }}</span>{% endslot %}
{% endcomponent_block %}Since to header block is unspecified, it's taken from the base template. If you put this in a template, and send in date=2020-06-06, this is what's rendered: <div class="calendar-component">
<div class="header">
Calendar header
</div>
<div class="body">
Today's date is <span>2020-06-06</span>
</div>
</div>Easy to use an intuitive. Thanks for the inspiration! |
No description provided.