diff --git a/crispy_tailwind/templates/tailwind/layout/baseinput.html b/crispy_tailwind/templates/tailwind/layout/baseinput.html index aa3f2fe..432a3a3 100644 --- a/crispy_tailwind/templates/tailwind/layout/baseinput.html +++ b/crispy_tailwind/templates/tailwind/layout/baseinput.html @@ -2,7 +2,7 @@ name="{% if input.name|wordcount > 1 %}{{ input.name|slugify }}{% else %}{{ input.name }}{% endif %}" value="{{ input.value }}" {% if input.input_type != "hidden" %} - class="{{ input.field_classes }}" + class="{{ input.field_classes }} bg-white focus:outline-none focus:shadow-outline border border-gray-300 rounded-lg py-2 px-4 block w-full appearance-none leading-normal" id="{% if input.id %}{{ input.id }}{% else %}{{ input.input_type }}-id-{{ input.name|slugify }}{% endif %}" {% endif %} {{ input.flat_attrs|safe }} diff --git a/crispy_tailwind/templatetags/tailwind_field.py b/crispy_tailwind/templatetags/tailwind_field.py index e3e9d46..c1a5a46 100644 --- a/crispy_tailwind/templatetags/tailwind_field.py +++ b/crispy_tailwind/templatetags/tailwind_field.py @@ -77,7 +77,38 @@ def pairwise(iterable): class CrispyTailwindFieldNode(template.Node): - default_styles = {"text": "tailwind-text", "radioselect": " tailwind-radio"} + base_input = ( + "bg-white focus:outline-none border border-gray-300 rounded-lg py-2 px-4 block w-full " + "appearance-none leading-normal text-gray-700" + ) + + default_styles = { + "text": base_input, + "number": base_input, + "radioselect": "", + "email": base_input, + "url": base_input, + "password": base_input, + "hidden": "", + "multiplehidden": "", + "file": "", + "clearablefile": "", + "textarea": base_input, + "date": base_input, + "datetime": base_input, + "time": base_input, + "checkbox": "", + "select": "", + "nullbooleanselect": "", + "selectmultiple": "", + "radioselect": "", + "checkboxselectmultiple": "", + "multi": "", + "splitdatetime": "text-gray-700 bg-white focus:outline border border-gray-300 leading-normal px-4 " + "appearance-none rounded-lg py-2 focus:outline-none mr-2", + "splithiddendatetime": "", + "selectdate": "", + } default_container = CSSContainer(default_styles) @@ -113,11 +144,7 @@ def render(self, context): # noqa: C901 if isinstance(attrs, dict): attrs = [attrs] * len(widgets) - converters = { - "textinput": "textinput textInput", - "fileinput": "fileinput fileUpload", - "passwordinput": "textinput textInput", - } + converters = {} converters.update(getattr(settings, "CRISPY_CLASS_CONVERTERS", {})) for widget, attr in zip(widgets, attrs): @@ -131,7 +158,6 @@ def render(self, context): # noqa: C901 css_class = class_name # Added additional code for Tailwind - if template_pack == "tailwind": css_container = context.get("css_container", self.default_container) if css_container: diff --git a/tests/test_filter.py b/tests/test_filter.py index 0f1fc60..b6144e7 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -27,48 +27,64 @@ def test_crispy_filter(self):
- Insert your email
-
+ +
-
-
+
-
+ """ + """
- - -
+ +
-