Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date macro pattern #397

Closed
wants to merge 8 commits into from
Closed

date macro pattern #397

wants to merge 8 commits into from

Conversation

feedmypixel
Copy link
Contributor

Usage can be seen in #395 here

screen shot 2017-07-31 at 13 49 06

@ztolley ztolley temporarily deployed to datahub-beta2-pr-397 July 31, 2017 14:05 Inactive
@@ -11,6 +11,7 @@

{% from "_macros/form.njk" import EntitySearchForm, Form, MultiStepForm with context %}
{% from "_macros/form.njk" import Fieldset, TextField, MultipleChoiceField, HiddenField %}
{% from "_macros/form.njk" import DateField %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could extend the line above instead:

{% from "_macros/form.njk" import Fieldset, DateField, TextField, MultipleChoiceField, HiddenField %}

@@ -351,6 +358,7 @@
# @param {string} [props.placeholder] - Field placeholder
# @param {string, array} [props.modifier] - form-control modifier
# @param {string} [props.error] - Mark form-control with error
# @param {string} [props.maxlength] - maxlength Input attribute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maxlength can be confusing to users. Could be better just to validate whatever the user enters rather than restricting input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be interesting to see what the preferred users options is. I wonder if entering something long, which disappears from view to then be told its not valid is preferred to restricting the characters entered

Copy link
Contributor

@teneightfive teneightfive Jul 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which disappears from view

It doesn't disappear on most browsers. The cursor will follow the last typed characters so even on smaller input fields the user will still see what they last typed. It would actually seem more like it disappears in this instance if we restrict input.

restricting the characters entered

Some users don't look at the screen when they're typing so they won't necessarily notice that everything they typed on the keyboard isn't on the screen, which is where the confusion often comes from.

This is particularly noticeable in free text fields where the accepted characters are limited. It is better to let the user type over that limit and warn them as they do so as well as validate when they submit or prevent them from submitting.

Twitter's tweet functionality is a good example - it doesn't just stop you writing, it shows you that you typed too much:
image

In this instance with date fields I don't think restricting input adds anything and we're better off just letting the user enter as many characters as they want to and then providing useful date validation feedback if it isn't a valid date.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great point - well made 👍

# @param {string} [props.inputName] - The base input name for date field names
# @param {string} [props.inputValue] - Field values
#}
{% macro DateField(props) %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DateFieldset?

max-width: 4em;
}

.c-form-control--small {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth looking at @tyom's suggestion from the other PR again.

@ztolley ztolley temporarily deployed to datahub-beta2-pr-397 July 31, 2017 15:48 Inactive
@feedmypixel feedmypixel force-pushed the feature/date-macro-pattern branch from cccce13 to 128dbaa Compare July 31, 2017 15:48
@ztolley ztolley temporarily deployed to datahub-beta2-pr-397 July 31, 2017 15:48 Inactive
@feedmypixel feedmypixel force-pushed the feature/date-macro-pattern branch from 128dbaa to 3167d28 Compare July 31, 2017 15:53
@ztolley ztolley temporarily deployed to datahub-beta2-pr-397 July 31, 2017 15:53 Inactive
@teneightfive
Copy link
Contributor

Might be worth adding some examples of the date fieldset to the examples in components app too.

@ztolley ztolley temporarily deployed to datahub-beta2-pr-397 July 31, 2017 16:41 Inactive
@feedmypixel
Copy link
Contributor Author

Might be worth adding some examples of the date fieldset to the examples in components app too.

👍 yeah this and tests are in the TODO's on #395

# @param {string} [props.inputName] - The base input name for date field names
# @param {string} [props.inputValue] - Field values
#}
{% macro DateFieldset(props) %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to add unit tests for all new macros. I know there' a backlog but do consider adding some tests if you can.

@feedmypixel feedmypixel force-pushed the feature/date-macro-pattern branch from 6e6a494 to 3b0248c Compare July 31, 2017 16:52
>
{% if props.legend %}
<legend class="c-form-fieldset__legend">
<span class="c-form-fieldset__legend-text">{{ props.legend }}</span>
</legend>
{% endif %}

{% if props.hint %}
<span id="hint-{{ props.fieldId }}" class="c-form-fieldset__hint">{{ props.hint }}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well use div. I doubt it would ever be displayed inline.


{% call FormGroup(props | assign({ fieldId: fieldId, element: 'fieldset', modifier: 'inline' })) %}
{{ TextField({
inputClass: 'c-form-control--shortest',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just add this to modifier modifier: ['inline', 'shortest'].

@tyom
Copy link
Contributor

tyom commented Jul 31, 2017

Would be good to add example of this fieldset to form components page.

@ztolley ztolley temporarily deployed to datahub-beta2-pr-397 August 1, 2017 08:15 Inactive
@tyom
Copy link
Contributor

tyom commented Aug 1, 2017

Is it meant to look like this on components page?
image

@feedmypixel
Copy link
Contributor Author

closing this as the work can be found in #395

@feedmypixel feedmypixel closed this Aug 2, 2017
@feedmypixel
Copy link
Contributor Author

Is it meant to look like this on components page?

an error with missing stles - full PR can be seen on #395

@feedmypixel
Copy link
Contributor Author

All comments addressed in #395

@teneightfive teneightfive deleted the feature/date-macro-pattern branch August 14, 2017 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants