mirror of
https://github.com/django-components/django-components.git
synced 2025-08-03 22:08:17 +00:00
feat: allow to set main JS and CSS from files + lazy-load component m… (#870)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
8fcb84c002
commit
715bf7d447
20 changed files with 1014 additions and 248 deletions
|
@ -8,9 +8,9 @@ class Calendar(Component):
|
|||
#
|
||||
# `template_name` can be relative to dir where `calendar.py` is, or relative to COMPONENTS.dirs
|
||||
template_name = "calendar/calendar.html"
|
||||
# Or
|
||||
# def get_template_name(context):
|
||||
# return f"template-{context['name']}.html"
|
||||
|
||||
css_file = "calendar/calendar.css"
|
||||
js_file = "calendar/calendar.js"
|
||||
|
||||
# This component takes one parameter, a date string to show in the template
|
||||
def get_context_data(self, date):
|
||||
|
@ -25,10 +25,6 @@ class Calendar(Component):
|
|||
},
|
||||
)
|
||||
|
||||
class Media:
|
||||
css = "calendar/calendar.css"
|
||||
js = "calendar/calendar.js"
|
||||
|
||||
|
||||
@register("calendar_relative")
|
||||
class CalendarRelative(Component):
|
||||
|
@ -37,9 +33,9 @@ class CalendarRelative(Component):
|
|||
#
|
||||
# `template_name` can be relative to dir where `calendar.py` is, or relative to COMPONENTS.dirs
|
||||
template_name = "calendar.html"
|
||||
# Or
|
||||
# def get_template_name(context):
|
||||
# return f"template-{context['name']}.html"
|
||||
|
||||
css_file = "calendar.css"
|
||||
js_file = "calendar.js"
|
||||
|
||||
# This component takes one parameter, a date string to show in the template
|
||||
def get_context_data(self, date):
|
||||
|
@ -53,7 +49,3 @@ class CalendarRelative(Component):
|
|||
"date": request.GET.get("date", ""),
|
||||
},
|
||||
)
|
||||
|
||||
class Media:
|
||||
css = "calendar.css"
|
||||
js = "calendar.js"
|
||||
|
|
|
@ -8,9 +8,9 @@ class CalendarNested(Component):
|
|||
#
|
||||
# `template_name` can be relative to dir where `calendar.py` is, or relative to COMPONENTS.dirs
|
||||
template_name = "calendar.html"
|
||||
# Or
|
||||
# def get_template_name(context):
|
||||
# return f"template-{context['name']}.html"
|
||||
|
||||
css_file = "calendar.css"
|
||||
js_file = "calendar.js"
|
||||
|
||||
# This component takes one parameter, a date string to show in the template
|
||||
def get_context_data(self, date):
|
||||
|
@ -24,7 +24,3 @@ class CalendarNested(Component):
|
|||
"date": request.GET.get("date", ""),
|
||||
},
|
||||
)
|
||||
|
||||
class Media:
|
||||
css = "calendar.css"
|
||||
js = "calendar.js"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue