diff --git a/src/wmnds/components/form-elements/date-input/_date-input.njk b/src/wmnds/components/form-elements/date-input/_date-input.njk new file mode 100644 index 000000000..a32cdcd56 --- /dev/null +++ b/src/wmnds/components/form-elements/date-input/_date-input.njk @@ -0,0 +1,74 @@ +{% macro wmndsDateInput(params) %} + +{# Imports #} +{% from "wmnds/components/form-elements/label/_label.njk" import wmndsLabel %} +{% from "wmnds/components/form-elements/error-message/_error-message.njk" import wmndsFeErrorMessage %} + +{# Params #} +{% set id = params.id if params.id else "date-input" %} +{% set name = params.name if params.name else id %} +{% set required = params.required if params.required else false %} +{% set classes = " " + params.classes if params.classes %} {# set paramClass to params.classNames if any #} +{# Error Message Params #} +{% set groupErrorClass = " wmnds-fe-group--error" if params.error %} +{% set inputErrorClass = " wmnds-fe-input--error" if params.error %} +{% set errorContentText = params.errorMessage.contentText if params.errorMessage.contentText else "Please enter a valid date" %} +{% set errorContentHTML = params.errorMessage.contentHTML if params.errorMessage.contentHTML else null %} +{% set errorClasses = " " + params.errorMessage.classes if params.errorMessage.classes else null %} +{% set errorId = params.errorMessage.id if params.errorMessage.id else null %} +{# Params of formGroup #} +{% set formGroupClasses = " " + params.formGroup.classes if params.formGroup.classes else null %} +{# Params of Attributes #} +{% set disabled = params.attributes.disabled if params.attributes.disabled else null %} +{% set maxLength = params.attributes.maxLength if params.attributes.maxLength else null %} +{% set placeholder = params.attributes.placeholder if params.attributes.placeholder else null %} +{% set value = params.attributes.value if params.attributes.value else null %} + +
false
."
+ },
+ {
+ "name": "error",
+ "type": "boolean",
+ "description": "If true, error will be displayed. Defaults to false
."
+ },
+ {
+ "name": "errorMessage",
+ "type": "object",
+ "description": "Options for the error message component. See errorMessage.",
+ "arrayOptions": [
+ {
+ "name": "id",
+ "type": "string",
+ "description": "Id attribute to add to the error message span tag."
+ },
+ {
+ "name": "contentText",
+ "type": "string",
+ "description": "Required. Text to use within the error message. If contentHTML
is supplied, this is ignored."
+ },
+ {
+ "name": "contentHTML",
+ "type": "string",
+ "description": "Required. HTML to use within the error message"
+ },
+ {
+ "name": "classes",
+ "type": "string",
+ "description": "Classes to add to the error message span tag."
+ }
+ ]
+ },
+ {
+ "name": "formGroup",
+ "type": "object",
+ "description": "Options for the form-group wrapper. See formGroup below.",
+ "arrayOptions": [
+ {
+ "name": "classes",
+ "type": "string",
+ "description": "Classes to add to the form group (e.g. to show error state for the whole group)"
+ }
+ ]
+ }
+ ]
+}
diff --git a/src/www/data.njk.json b/src/www/data.njk.json
index a71e6e84b..6ead99de3 100644
--- a/src/www/data.njk.json
+++ b/src/www/data.njk.json
@@ -47,6 +47,9 @@
{
"name": "Content tiles"
},
+ {
+ "name": "Date Input"
+ },
{
"name": "Details"
},
diff --git a/src/www/pages/components/date-input/index.njk.md b/src/www/pages/components/date-input/index.njk.md
new file mode 100644
index 000000000..d80b5aae1
--- /dev/null
+++ b/src/www/pages/components/date-input/index.njk.md
@@ -0,0 +1,57 @@
+{% extends "www/_layouts/layout-left-pane.njk" %}
+{% set pageTitle = "Date Input" %}
+{% from "www/_partials/component-example/component-example.njk" import compExample %}
+{% from "wmnds/components/form-elements/date-input/_date-input.njk" import wmndsDateInput %}
+
+{% block content %}
+{% markdown %}
+
+## About
+
+### What does it do?
+
+- Help users enter a memorable date or one they can easily look up.
+
+### When to use it?
+
+- Use the date input component when you’re asking users for a date they’ll already know, or can look up without using a calendar.
+
+### When not to use it?
+
+- Do not use the date input component if users are unlikely to know the exact date of the event you’re asking about.
+
+{% endmarkdown %}
+
+{{
+ compExample([wmndsDateInput()], {
+ componentPath: "wmnds/components/form-elements/date-input/",
+ njk: true,
+ njkProps: wmndsDateInputProps,
+ js: false,
+ iframe: false
+ })
+}}
+{# End Input #}
+
+{% markdown %}
+
+## Showing error
+
+{% endmarkdown %}
+
+{{
+ compExample([wmndsDateInput({
+ error: true,
+ errorMessage: {
+ contentText: "Date input custom error message"
+ }
+ })], {
+ componentPath: "wmnds/components/form-elements/date-input/",
+ njk: true,
+ njkProps: wmndsDateInputProps,
+ js: false,
+ iframe: false
+ })
+}}
+
+{% endblock %}