Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

DateMath: Interactivity #2897

Closed
wants to merge 73 commits into from
Closed

DateMath: Interactivity #2897

wants to merge 73 commits into from

Conversation

GuiltyDolphin
Copy link
Member

@GuiltyDolphin GuiltyDolphin commented Apr 16, 2016

This adds interactivity to the DateMath Goodie through JavaScript.

Hide your eyes.

To-Do

  • Use a single line for the amount input, in the form Years: X Months: X etc. with support for changing the operation from addition to subtraction.

IA Page: https://duck.co/ia/view/date_math

@daxtheduck
Copy link

daxtheduck commented Apr 16, 2016

DateMath

Description: calculate the date with an offset

Example Query: Jan 1 2012 plus 32 days, 1/1/2012 plus 5 months, January first minus ten days, in 5 weeks, 2 weeks ago, 1 month from today, 3 seconds ago, time now + 16 minutes, 4 hours from now

Tab Name: Answer

Source:

These are the important fields from the IA page. Please check these for errors or missing information and update the IA page


This is an automated message which will be updated as changes are made to the IA page

@GuiltyDolphin
Copy link
Member Author

@mintsoft Want to have a look over this? I think the functionality is all there; just a question of getting it to look nice.

I'll have another look pretty soon to make sure I've removed everything that should be, and clean up anything that requires it.

@mintsoft
Copy link
Collaborator

@GuiltyDolphin certainly can

@mintsoft
Copy link
Collaborator

Hmm so I'm a smidge confused by the GUI at first; I've just played with it and it made more sense once I could see how it reacted.

@abeyang Any design thoughts here?

@GuiltyDolphin
Copy link
Member Author

@mintsoft Glad it made sense (eventually)! I'm no designer so any design review is appreciated.

@mintsoft
Copy link
Collaborator

@GuiltyDolphin Immediate things that I've noticed are that I think some labels might help?

  • It'd be nice to highlight the "start date"
  • The input boxes on the start bit are a little difficult to tell that you can edit them, because some bits you can, some you can't
  • Personally I dislike month first date formats; I'd prefer like Monday 25th April 2016 21:17:05

@mintsoft
Copy link
Collaborator

Also it doesn't give me the answer when I query? I have to tinker with it to get the answer out?

@GuiltyDolphin
Copy link
Member Author

Oh lord @mintsoft yeah - forgot to turn that on!

@GuiltyDolphin
Copy link
Member Author

GuiltyDolphin commented Apr 24, 2016

@mintsoft Sure - I was using a random format suggested by moment.js. Probably best to go with the general 'DuckDuckGo' format (with weekday).

I would like locale formats but... moment.js seems to do things its own way, and doesn't currently support CLDR :/

@mintsoft
Copy link
Collaborator

mintsoft commented Apr 24, 2016

Ah somehow I knew it'd be moment.js's fault; it's basically the reason why all date stuff is broken on the internet these days.

@GuiltyDolphin
Copy link
Member Author

@mintsoft I've updated the date format and fixed the date not being initially calculated.

For the 'indication' that the fields are editable; I'm pretty happy with the current 'neutral' style for the date, so how about a popout or tooltip?

@mintsoft
Copy link
Collaborator

@GuiltyDolphin I think my confusion around the input boxes is because that line is small and you highlight things like the sunday it makes it look like it's just text. Maybe if you did user-select: none; (and all the prefixes for different browsers) it'd be more obvious? I dunno

@mintsoft
Copy link
Collaborator

Hmm maybe change them to <input type='number' /> ? Then they'll have little spinners on them too; makes it a bit clearer when you click it

@GuiltyDolphin
Copy link
Member Author

@mintsoft I had that (spinners) before - it was pretty ugly.

There is the indication when you hover over (a caret); but I guess we could make the highlighting a bit more prominent - I'll see how it looks.

@moollaza
Copy link
Member

moollaza commented Jun 2, 2016

Just looking over this. My initial reaction is that there's too much JS here. It looks like a lot of what you've implemented can be handled by the browser:

  • Changing the input type to number will and setting max=, min= will help a lot
  • That should force only acceptable inputs, meaning no more validation required
  • Our btn class should handle all the UI aspects of any buttons: https://duckduckgo.com/styleguide#buttons
  • Our grid classes should help with the layout -- though I suspect our design team will have thoughts on the overall UI

'Second', 'Minute', 'Hour',
'Day', 'Week', 'Month', 'Year'
];
function pad(text, padChar, padWidth) {
Copy link
Member

Choose a reason for hiding this comment

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

Move private functions outside the build function definition

@GuiltyDolphin
Copy link
Member Author

GuiltyDolphin commented Jun 2, 2016

@moollaza

34ca44f - I was using number with min and max before; but I think it was causing some display issues; I'll check it out again.

I am using btn - but there's some overriding going on that made it a little painful and I had to add some custom stuff... Some design advice/feedback would be very welcome (I haven't really delved into front-end (CSS/design) before - it's very finickity)!

Thanks for the review 😄

@GuiltyDolphin
Copy link
Member Author

GuiltyDolphin commented Jun 2, 2016

@moollaza BTW, which (specifically) were you thinking should be switched to number? The day is supposed to allow inputs like 2nd, 3rd etc., the amount ends up looking like:

screenshot-2016-06-02-21 12 42_598_47

The times get really screwed up as well.

Am I missing something? It feels like there should be a way to not have it screw everything up and just have the input type; though looking at other IAs they've used things like tel and text inputs to bypass this.

Unfortunately I couldn't find a class for tx--10 (unless it is one of
the named ones), so I've used tx--11 for now.
Use the plural version for modifier display names; possibly make it
change according to whether the amount is 1?
And a bit o' a cleanup.
Using 'operation' and 'sign' rather than 'actions'.

TODO: Update the tests to only have one possible action.
@GuiltyDolphin
Copy link
Member Author

@tagawa I'll just revert the changes to the date input - they can't complain if it is a text field.

Hmm... Locally the boxes wrap for me, but on Beta it's fine, weird... (I'm on FF).

@daxtheduck daxtheduck deployed to beta.duckduckgo.com August 4, 2016 18:53 Active
<p class="frm__desc pull--left tx--11">DURATION</p>
<span class="frm op--select">
<input type="number" class="frm__input input--op-amt g forty"/>
<span class="frm__select g fifty" style="height:2em">
Copy link
Member

@moollaza moollaza Aug 4, 2016

Choose a reason for hiding this comment

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

use !important to override CSS -- inline styles shouldn't be necessary -- or give these another class and create a more specific selector than .frm .frm__select

Copy link
Member Author

Choose a reason for hiding this comment

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

@moollaza See my comment above - I've tried using CSS with multiple classes + id + tag etc. (with !important) to no avail - unless I'm missing something obvious it looks like I can't override them?

Copy link
Member

@moollaza moollaza Aug 6, 2016

Choose a reason for hiding this comment

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

.zci--date_math .frm__select.g seems to work?

OR

.zci--date_math .frm__select.date--selection if you want it to be more precise

@GuiltyDolphin
Copy link
Member Author

GuiltyDolphin commented Aug 5, 2016

@moollaza Uhh, that appears to be missing the sign toggle?

On Midori it takes it from:

screenshot-2016-08-05-09 22 26_743_234

To:

screenshot-2016-08-05-09 22 46_744_347

(I've played around with it a bit).

I'm not 100% sure what the issue is - on FF it looks screwed up locally, but on Beta it's fine. Could it just be something to do with slightly different styles on Beta and what DuckPAN receives?

@moollaza
Copy link
Member

moollaza commented Aug 6, 2016

Uhh, that appears to be missing the sign toggle?

@GuiltyDolphin looks like your pictures didn't upload in that last comment?

on FF it looks screwed up locally, but on Beta it's fine.

I'll take a look at FF...

Could it just be something to do with slightly different styles on Beta and what DuckPAN receives?

Shouldn't be. If any, it would only be minor and temporary (once Beta is updated internally). AFAIK we haven't made any changes to CSS lately.

<span class="frm op--select">
<input type="number" class="frm__input input--op-amt g forty"/>
<span class="frm__select g fifty" style="height:2em">
<select class="input--op-type" style="height:2em"/>
Copy link
Member

@moollaza moollaza Aug 6, 2016

Choose a reason for hiding this comment

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

can use .frm__select select.input--op-type with !important here.

Our existing DDG style has !important so we need to make our selector more specific first, then force it with !important

Copy link
Member

@moollaza moollaza Aug 6, 2016

Choose a reason for hiding this comment

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

You'll want to also remove the padding on the select as the span already adds some, forcing the seconds option to overlap with the dropdown

@moollaza
Copy link
Member

moollaza commented Aug 6, 2016

@GuiltyDolphin if you reduce the padding-left on the .time--input .frm__input then it should prevent the wrapping on FF.

It may be wrapping due to some kind of calculation bug in FF... Not sure why the math isn't adding up there.

@GuiltyDolphin
Copy link
Member Author

@moollaza Everything just seems... Bigger, locally:

screenshot-2016-08-06-18 35 19_857_220

screenshot-2016-08-06-18 35 33_870_274

(Beta/Local)

Changing anything just seems to screw it up more (locally); @tagawa was that screenshot with the wrapping on FF on beta or local?

@mintsoft
Copy link
Collaborator

I'm going to close this for now until we decide what we want to do with it, feel free to re-open if you disagree

@mintsoft mintsoft closed this Aug 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants