Initial API thoughts #1
Replies: 5 comments 1 reply
-
Single component (basic)Definition{# bird/h1.html #}
<h1>
{{ slot }}
</h1>
<style>
h1 {
font-size: 2rem;
}
</style> {# bird/h1.html #}
<h1>
{{ slot name="default" }}
</h1>
<style>
h1 {
font-size: 2rem;
}
</style> {# bird/h1.html #}
<h1>
{% slot %}
Fallback content
{% endslot %}
</h1>
<style>
h1 {
font-size: 2rem;
}
</style> {# bird/h1.html #}
<h1>
{% slot default %}
Fallback content
{% endslot default %}
</h1>
<style>
h1 {
font-size: 2rem;
}
</style> Usage<bird:h1>
This is an H1 component
</bird:h1> |
Beta Was this translation helpful? Give feedback.
-
Single component (named slots)Definition{# bird/h1.html #}
<h1>
{% slot %}
{% endslot %}
</h1>
{% if slots.subheading %}
<p role="doc-subtitle">
{% slot subheading %}
{% endslot subheading %}
</p>
{% endif %}
<style>
h1 {
font-size: 2rem;
}
p {
font-size: 1.25rem;
}
</style> Usage<bird:h1>
This is an H1 component
<bird:h1 slot="subheading">
...with a subheading
</bird:h1>
</bird:h1> |
Beta Was this translation helpful? Give feedback.
-
Multiple/grouped componentsDirectory structureI'm using a heading component as a simple example, even though in the real world you wouldn't likely split out a heading component this way. Option Abird
└── heading
├── h1.html
├── h2.html
├── h3.html
├── h4.html
├── h5.html
├── h6.html
└── index.html Option BIf bird
└── heading
├── heading.html
├── h1.html
├── h2.html
├── h3.html
├── h4.html
├── h5.html
└── h6.html Option Cbird
├── heading.html
├── heading.h1.html
├── heading.h2.html
├── heading.h3.html
├── heading.h4.html
├── heading.h5.html
└── heading.h6.html Definition{# bird/heading/index.html #}
{% if level == "1" %}
<bird:heading.h1>{{ slot }}</bird:heading.h1>
... Usage<bird:heading level="1">
This is an H1 component
</bird:heading>
<bird:heading level="2">
This is an H2 component
</bird:heading>
... |
Beta Was this translation helpful? Give feedback.
-
Component islandsDefinition{# bird/carousel/index.html #}
{# TODO #} {# bird/carousel/item.html #}
{# TODO #} Usage{# 11ty/is-land style #}
<bird:carousel on="idle">
<bird:carousel.item />
<bird:carousel.item />
<bird:carousel.item />
</bird:carousel> {# Astro style #}
<bird:carousel client="idle">
<bird:carousel.item />
<bird:carousel.item />
<bird:carousel.item />
</bird:carousel> Client directivesDirective signifier choices:
Directive states:
Inspiration and references
|
Beta Was this translation helpful? Give feedback.
-
A major impetus for this wanting to create this library in the first place is Caleb Porzio's talk introducing his component library, Flux, at Laracon US 2024: Flux, the UI Library for Livewire | Caleb Porzio at Laracon US 2024 in Dallas, TX |
Beta Was this translation helpful? Give feedback.
-
This is a discussion to gather my thoughts about the initial API for django-bird. All of this has been bouncing around in my head for a while, but I've never taken the time to actually write it down until now. I'm still not 100% on what the final API for defining and using django-bird components is, but I hope in actually getting it out of my head and down on the page that the obvious path will reveal itself.
Anyone is welcome to comment, to offer your own thoughts, or even alternatives if you should have one.
Beta Was this translation helpful? Give feedback.
All reactions