Repository navigation
disable date navigation arrows when date is invalid for site - #483
Conversation
|
Thanks! What's the benefit of them being |
|
HTML |
Fair enough. I considered them pagination elements that provide navigation which is why they are link at the moment. According to the Buttons vs. Links section of the linked document, navigation elements should be links. But these arrows also look like buttons and trigger javascript, so according to the doc it seems it's both a link and a button. I don't really mind either way, will give this a review. |
ukutaht
left a comment
There was a problem hiding this comment.
Looks good! The only change I would request is removing LinkButton and using button instead unless there's a good reason to have a LinkButton.
| "env": { | ||
| "browser": true | ||
| }, |
There was a problem hiding this comment.
So eslint won't error about document.get... stuff.
| parseUTCDate, | ||
| isBefore, | ||
| isAfter, |
There was a problem hiding this comment.
these 3 and QueryButton are new
the rest of this import stuff is just formatting
| document.removeEventListener("mousedown", this.handleClick, false); | ||
| } | ||
|
|
||
| handleKeyup(e) { |
There was a problem hiding this comment.
actual changes here
changes in this function prevent the keyboard arrow keys from going past time boundaries
(also a little formatting)
| this.setState({ open: false }); | ||
| } | ||
|
|
||
| timeFrameText() { |
There was a problem hiding this comment.
the changes in this function are linting changes
| ); | ||
| } | ||
|
|
||
| renderArrows() { |
There was a problem hiding this comment.
these are linting changes
| return 'Realtime' | ||
| } | ||
|
|
||
| renderArrow(period, prevDate, nextDate) { |
| const QueryLinkWithRouter = withRouter(QueryLink) | ||
| export { QueryLinkWithRouter as QueryLink }; | ||
|
|
||
| class QueryButton extends React.Component { |
|
I didn't make all the changes the linter suggested, mainly because I figured the diff would become unreadable if I did it all it in one go. But the automatic semi-colons and quotes/inverted-commas and no-else-after-return things, those are in here. I figure getting things formatted is a gradual thing. |
ukutaht
left a comment
There was a problem hiding this comment.
Thanks for the updates!
I think dark mode was introduced since this PR was opened. Anyways I noticed that the Datepicker in this PR does not implement dark mode:
Second, I noticed that on the month view, both buttons are disabled in all cases. Is this intentional? I don't see why we would disable arrow navigation for months.
Third, this is not a showstopper for this PR but my general take on formatting is that whatever checks the formatting should also be able to automatically format the code according to its own styleguide. I've found that when humans have to make linters happy, we end up arguing over style a lot.
With elixir code we enfore mix format for all code and now I've added mix format --check-formatted to our CI so our tests fail if a PR is not formatted properly. I've also added mix format in my personal pre-commit hook.
This need not be part of this PR, but I'd like to devise a similar system for JS/CSS. We can use an automated formatter to format the whole project and start enforcing that every piece of code needs to pass npm run check-format. If your code doesn't adhere to the style, it should be automatically fixable with npm run format. I'm not too familiar with the JS ecosystem, I guess prettier can do this?
|
Prettier does auto-format when it's just formatting, but those code checkers I put in before include more than just formatting. You know how Elixir will tell you "hey, you made this variable, but then you didn't use it"? ESLint tells you that kind of stuff too. It also has other elements of style, like preferring stateless functions over classes in React. Code organization, like alphabetize your functions. Accessibility stuff, like "you forgot to include an aria-label there." I'll get to the dark mode for the buttons. |
|
I did the dark mode and cleaned up a bunch of the linting erros. Here's what remains on these two files:
Some of that involves rearranging order of functions, some involves actual changes to the logic, so I'm leaving that stuff out of this PR. Might tackle it separately, though. |

Changes
Change date navigation arrows to real buttons and disable them when date is invalid for site
Keyboard navigation could still leave the valid zone, but I'm not sure what the correct usability for that would be. Perhaps a nnotification banner? Keyboard nav could imply a disabled user, so it would need to have correct ARIA attributes.
Tests
no js test framework
Changelog
Fits in with previous changelog entry
Documentation