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

feat: add tabs to switch between query and event mode #296

Merged

Conversation

aganglada
Copy link
Collaborator

@aganglada aganglada commented Nov 13, 2020

What:

This PR fixes #172 and merge the /events route with the playground, showing the two views together and making it possible for the user to switch between them.

Screenshot 2020-11-13 at 12 52 13

Why:

Required from #172 in which we wanted a way to switch between views.

How:

  • Extracted TabButton to be used from Embed and the new view.
  • Created a new component called PlaygroundPanels
  • Moved the bottom part of DomEvents view into PlaygroundPanels
  • Moved the bottom part of Playground into PlaygroundPanels
  • Refactor functionality of DomEvents into a context, so we are able to get the correct ref for the Preview
  • Extracted DomEvent dom utilities into separate file.

Checklist:

  • Tests N/A
  • Ready to be merged

@smeijer
Copy link
Member

smeijer commented Nov 16, 2020

Hi @aganglada,

I want to let you know that I've noticed the PR. But it's quite large, so I need some time to properly review it.

I'll try to get to it somewhere this week.

Thanks for the PR. The screenshot looks great!

@smeijer
Copy link
Member

smeijer commented Nov 16, 2020

@aganglada, although I did not yet review these changes, I do appreciate your recent contributions! Thanks again.

I've added you as a 🐸 collaborator on the project. Please make sure that you review the MAINTAINING.md and CONTRIBUTING.md files (specifically the bit about the commit messages and the git hooks) and familiarize yourself with the code of conduct (we're using the contributor covenant).

You might also want to watch the repo to be notified when someone files an issue/PR. Please continue to make PRs as you feel the need (you can make your branches directly on the repo rather than your fork if you want).

Thanks! And welcome to the team 🎉

@aganglada
Copy link
Collaborator Author

This is great!!!! 👏 So happy to be part of the team 😄 Thank you so much! 💪

@aganglada aganglada self-assigned this Nov 16, 2020
@aganglada aganglada added feature New feature or request project:events Tickets related to the /events route labels Nov 16, 2020
@aganglada
Copy link
Collaborator Author

@smeijer have you had time to have a closer look to this?

@smeijer
Copy link
Member

smeijer commented Dec 2, 2020

@marcosvega91, @delca85, I'm running really short on time this week. Does one of you have time to review this PR?

@delca85
Copy link
Member

delca85 commented Dec 2, 2020

If you are not in a great rush, I think I will be able to check this before the end of the week!

@smeijer
Copy link
Member

smeijer commented Dec 2, 2020

Works for me. Thanks, @delca85!

@smeijer smeijer changed the title Move Events to Tabs feat: add tabs to switch between query and event mode Dec 2, 2020
@smeijer smeijer requested a review from delca85 December 2, 2020 12:45
Copy link
Member

@delca85 delca85 left a comment

Choose a reason for hiding this comment

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

I think we should merge this PR.
I have added just few comments but just on code readability because the final result is great.
Thank you!

? 'border-blue-600 text-blue-600'
: 'border-transparent text-gray-800',
].join(' ')}
onClick={disabled ? undefined : onClick}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this ternary is not needed, if the button is disabled the onClick callback should never be triggered.

active
? 'border-blue-600 text-blue-600'
: 'border-transparent text-gray-800',
].join(' ')}
Copy link
Member

Choose a reason for hiding this comment

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

This is totally a personal opinion, but I think this way to define the className string could be more readable:

className = {`text-xs select-none border-b-2 
        ${disabled ? '' : 'hover:text-blue-400 hover:border-blue-400'} 
        ${active ? 'border-blue-600 text-blue-600' : 'border-transparent text-gray-800'}`
}

const [eventCount, setEventCount] = useState(0);
const [eventListeners, setEventListeners] = useState([]);

// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this line is not needed anymore because no react-hooks/exhaustive-deps is defined in eslintrc.js.

);
previewRef.current = null;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

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

Same consideration than above: maybe this line is not needed anymore because no react-hooks/exhaustive-deps is defined in eslintrc.js.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's not in the eslintrc, because it comes with one of the plugins.

Copy link
Member

Choose a reason for hiding this comment

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

Are you sure? Because I ran the lint:eslint without these lines and nothing was revealed as problematic. But, for sure, it is not a problem to keep these lines! :D

@smeijer
Copy link
Member

smeijer commented Dec 3, 2020

Awesome! Thanks, @delca85! As the few comments are only related to subtle style things, I'm going to merge this. If someone cares enough for code style, they're welcome to open a PR for that.

Thanks so much for this @aganglada! And sorry to have kept you waiting.

@smeijer smeijer merged commit 351c6ff into testing-library:develop Dec 3, 2020
@aganglada
Copy link
Collaborator Author

Thank you @smeijer @delca85 you are awesome! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request project:events Tickets related to the /events route
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add a way to switch between query and events mode
3 participants