mirror of
https://github.com/django-components/django-components.git
synced 2025-08-31 03:07:19 +00:00
Add type hints
This commit is contained in:
parent
f5855b50e3
commit
2ed3b40d05
3 changed files with 19 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
from typing import Any, Dict
|
||||
|
||||
from django_components import component
|
||||
from django_components import types as t
|
||||
|
||||
|
||||
@component.register("greeting")
|
||||
|
@ -13,12 +14,12 @@ class Greeting(component.Component):
|
|||
def get_context_data(self, name, *args, **kwargs) -> Dict[str, Any]:
|
||||
return {"name": name}
|
||||
|
||||
template = """
|
||||
template: t.django_html = """
|
||||
<div id="greeting">Hello, {{ name }}!</div>
|
||||
{% slot "message" %}{% endslot %}
|
||||
"""
|
||||
|
||||
css = """
|
||||
css: t.css = """
|
||||
#greeting {
|
||||
display: inline-block;
|
||||
color: blue;
|
||||
|
@ -26,7 +27,7 @@ class Greeting(component.Component):
|
|||
}
|
||||
"""
|
||||
|
||||
js = """
|
||||
js: t.js = """
|
||||
document.getElementById("greeting").addEventListener("click", (event) => {
|
||||
alert("Hello!");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue