refactor: Use top-level exports as public API (#562)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Juro Oravec 2024-08-03 08:30:39 +02:00 committed by GitHub
parent d819f3ff49
commit e771a0aaaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 615 additions and 598 deletions

View file

@ -1,8 +1,8 @@
from django_components import component
from django_components import Component, register
@component.register("calendar")
class Calendar(component.Component):
@register("calendar")
class Calendar(Component):
# Note that Django will look for templates inside `[your apps]/components` dir and
# `[project root]/components` dir. To customize which template to use based on context
# you can override def get_template_name() instead of specifying the below variable.
@ -25,8 +25,8 @@ class Calendar(component.Component):
js = "calendar/calendar.js"
@component.register("calendar_relative")
class CalendarRelative(component.Component):
@register("calendar_relative")
class CalendarRelative(Component):
# Note that Django will look for templates inside `[your apps]/components` dir and
# `[project root]/components` dir. To customize which template to use based on context
# you can override def get_template_name() instead of specifying the below variable.

View file

@ -1,11 +1,10 @@
from typing import Any, Dict
from django_components import component
from django_components import types as t
from django_components import Component, register, types
@component.register("greeting")
class Greeting(component.Component):
@register("greeting")
class Greeting(Component):
def get(self, request, *args, **kwargs):
slots = {"message": "Hello, world!"}
context = {"name": request.GET.get("name", "")}
@ -14,12 +13,12 @@ class Greeting(component.Component):
def get_context_data(self, name, *args, **kwargs) -> Dict[str, Any]:
return {"name": name}
template: t.django_html = """
template: types.django_html = """
<div id="greeting">Hello, {{ name }}!</div>
{% slot "message" %}{% endslot %}
"""
css: t.css = """
css: types.css = """
#greeting {
display: inline-block;
color: blue;
@ -27,7 +26,7 @@ class Greeting(component.Component):
}
"""
js: t.js = """
js: types.js = """
document.getElementById("greeting").addEventListener("click", (event) => {
alert("Hello!");
});

View file

@ -1,8 +1,8 @@
from django_components import component
from django_components import Component, register
@component.register("calendar_nested")
class CalendarNested(component.Component):
@register("calendar_nested")
class CalendarNested(Component):
# Note that Django will look for templates inside `[your apps]/components` dir and
# `[project root]/components` dir. To customize which template to use based on context
# you can override def get_template_name() instead of specifying the below variable.

View file

@ -1,8 +1,8 @@
from django_components import component
from django_components import Component, register
@component.register("todo")
class Calendar(component.Component):
@register("todo")
class Calendar(Component):
# Note that Django will look for templates inside `[your apps]/components` dir and
# `[project root]/components` dir. To customize which template to use based on context
# you can override def get_template_name() instead of specifying the below variable.