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

Dropdown without jQuery #226

Merged
merged 6 commits into from
Apr 30, 2016
Merged

Dropdown without jQuery #226

merged 6 commits into from
Apr 30, 2016

Conversation

levithomason
Copy link
Member

@levithomason levithomason commented Apr 27, 2016

Hey...

This is an interim PR. There are todos, comments, missing features, and ugly things. There shouldn't be any bugs or cruft, though.

The rewrite thus far is >600 lines in the Dropdown and >700 lines in Dropdown tests. I want to get some eyes and feedback on the functionality and approach thus far before cleaning up and abstracting things.

The multiple feature will be added in the next Dropdown PR.

Areas of concern

These are the areas to watch and comment on. These are some known ugly parts. They've been added as TODOs to the main PR #206.

Events

We have two event systems at play, React synthetic events and real DOM events. You'll see lots of document.add/removeEventListener calls. This is necessary for keyboard and mouse events that are dispatched on the document. Example, clicking outside the dropdown or pressing escape to close an open dropdown. Ideally, we'll write a clean abstraction for handling these. Considering that we need to:

  • prevent duplicate handlers
  • cleanup all events on unmount
  • provide once() functionality
  • add/remove events at any time (not just lifecycle methods)

Debug / Logging

Currently, nearly every method has a console.debug() when called and a console.log() for any relevant debugging data. This would be pulled into an actual debug util. Consider:

  • debug module
  • removal in production code
  • runtime flag to enable/disable by module

Spreading Consumer Props

Stardust components should spread the consumer's props. We've experimented with a couple patterns for doing this effectively, though they each beak down. Consider:

  • every prop not defined in propTypes (public interface) is a consumer prop
  • propTypes may be stripped from production code in the future
  • using ...props in render() isn't sufficient when breaking down many render methods

If it weren't for stripping propTypes in production we may be able to naively:

const getConsumerProps = (self) => _.omit(self.props, _.keys(self.constructor.propTypes))

This was referenced Apr 27, 2016
<input type='checkbox' value={search} onChange={this.toggleSearch} />
{' '}Search
</label>
</p>
Copy link
Member Author

Choose a reason for hiding this comment

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

The docs are getting an overhaul to better demonstrate the v1.0 component APIs. Take this example with a grain of salt. It is here only to show that the Dropdown works as expected.

@levithomason levithomason force-pushed the feature/dropdown-no-jquery branch 2 times, most recently from b79e1f7 to 27044f4 Compare April 29, 2016 22:53
@levithomason levithomason force-pushed the feature/dropdown-no-jquery branch from 27044f4 to 7ebc558 Compare April 29, 2016 22:55

static defaultProps = {
icon: 'dropdown',
// TODO 'searchInMenu' or 'search='in menu' or ??? How to handle this markup and functionality?
Copy link

Choose a reason for hiding this comment

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

Just confirming we want this TODO in here.

Copy link
Member Author

Choose a reason for hiding this comment

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

aye, thanks. this is a reminder to handle the search in menu dropdown.

@ghost
Copy link

ghost commented Apr 29, 2016

Lots of code in here, but I passed over and nothing other than the required options attribute stood out at me. Sweet looking tests! 🍶

@levithomason levithomason force-pushed the feature/dropdown-no-jquery branch from 7ebc558 to 645cd6e Compare April 30, 2016 00:23
@levithomason levithomason merged commit 59fcb59 into master Apr 30, 2016
@levithomason levithomason deleted the feature/dropdown-no-jquery branch April 30, 2016 00:25
@levithomason levithomason mentioned this pull request May 24, 2016
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant