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 Modal component #309

Merged
merged 9 commits into from
May 3, 2021
Merged

Conversation

bkonuwa
Copy link
Contributor

@bkonuwa bkonuwa commented Mar 29, 2021

No description provided.

Copy link
Contributor

@pixelbandito pixelbandito left a comment

Choose a reason for hiding this comment

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

Sorry, lot of words.
I checked out the code and overall, I'm really happy with how it looks and functions!

So please bear with my nitpicks, and feel free to push back on any of them.

}
}, [isOpen]);

const modalContentStyle = useMemo(
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect this doesn't need to be memoized because:

  • The amount of processing it's doing is trivial
  • Changes to its output don't cause re-renders of large trees of react components below

),
[passedClassName, size]
);
return ReactDOM.createPortal(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if there's a catch, but on initial testing, this seems much cleaner than how we were handling the portals in the tk-ui modals. 👏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm not sure there's a catch. That's how portal is used in this react TS cheet sheet. https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/portals/

example/src/App.js Show resolved Hide resolved
@@ -0,0 +1,129 @@
.modal {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the RoverUI convention, the main class for a component uses the same casing as the component name, so "Modal" here.

opacity: 0;
}

.modalContent {
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering we're already in a file named "Modal.*", maybe this should just be .content

<div
role="presentation"
className={modalContentStyle}
onClick={(e) => e.stopPropagation()}
Copy link
Contributor

Choose a reason for hiding this comment

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

There's always a chance that a consumer will have a good reason for wanting to capture clicks inside the modal, from a parent.

Instead of using stopPropagation, you could handle this use case with a handleClickBackground function.
That function would look at the click event's target, and only call onClose if the event target is not inside the modal.

src/components/Modal/Modal.tsx Show resolved Hide resolved
src/components/Modal/Modal.tsx Show resolved Hide resolved
@@ -25,4 +25,5 @@

/* Borders */
--rvr-border-radius: 4px;
--rvr-tile-border-radius: 6px;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is nitpicky, but I'd rename this one, twice. Here's why:
For any css vars with multiple values (like border-radius, now), the convention should be

  • Have an ordered list of the values that doesn't use any semantic names. Think of this like a color palette.
  • Then add a semantic section that maps those values to their use cases.

In this case, it would be something like:

/* Palette */
--rvr-border-radius-md: 4px;
--rvr-border-radius-lg: 6px;

/* Semantic-ish */
--rvr-border-radius-tile: var(--rvr-border-radius-md);

That lets us change the whole feel of the app by changing the "palette" values, but it also gives developers a cheat sheet to know what size we typically use for tile-type components.

@@ -25,4 +25,5 @@

/* Borders */
--rvr-border-radius: 4px;
--rvr-tile-border-radius: 6px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Separate naming thing:
I think I would label this border radius with "dialog" instead of "tile"

There's no tight definition, but I found the breakdown on this page helpful. https://ux.stackexchange.com/questions/78798/whats-the-difference-between-cards-panels-and-tiles

The article suggests that "tile" is mostly associated with those square in Microsoft's Metro UI, and those aren't like modals at all.

I don't think modals quite fit into any of those categories, but I can imagine we'd end up with a few types of dialog box that should share the same border radius.

@bkonuwa
Copy link
Contributor Author

bkonuwa commented Mar 30, 2021

Sorry, lot of words.
I checked out the code and overall, I'm really happy with how it looks and functions!

So please bear with my nitpicks, and feel free to push back on any of them.

No worries. Thanks for the feedback. I will add these suggestions this week.

Copy link
Contributor

@pixelbandito pixelbandito left a comment

Choose a reason for hiding this comment

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

🌹 🍔

src/components/Modal/Modal.test.tsx Outdated Show resolved Hide resolved
@bkonuwa bkonuwa merged commit 144c622 into master May 3, 2021
pixelbandito added a commit that referenced this pull request May 10, 2021
* feat: Add Modal component (#309)

* feat: Add Modal component

* cleaned up css class names

* add logic to auto focus and focus trapping in the modal

* Add example of Modal usage

* update unit test by adding snapshot to verify the component renders what is expected in the UI

* fix: Modal focus trap works better with keydown listener, add focus trap tests, upgrade testing-library packages

* fix: use userEvent.type to simulate escape key press

* fixed failing test

Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
Co-authored-by: Chris Garcia <pixelbandito@gmail.com>

* feat: EVER-13212: a11y colors for buttons and text links

Co-authored-by: bkonuwa <bkonuwa@gmail.com>
Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
pixelbandito added a commit that referenced this pull request May 17, 2021
* feat: Add Modal component (#309)

* feat: Add Modal component

* cleaned up css class names

* add logic to auto focus and focus trapping in the modal

* Add example of Modal usage

* update unit test by adding snapshot to verify the component renders what is expected in the UI

* fix: Modal focus trap works better with keydown listener, add focus trap tests, upgrade testing-library packages

* fix: use userEvent.type to simulate escape key press

* fixed failing test

Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
Co-authored-by: Chris Garcia <pixelbandito@gmail.com>

* feat: EVER-13212: a11y colors for buttons and text links

Co-authored-by: bkonuwa <bkonuwa@gmail.com>
Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
pixelbandito added a commit that referenced this pull request May 18, 2021
* feat: Add Modal component (#309)

* feat: Add Modal component

* cleaned up css class names

* add logic to auto focus and focus trapping in the modal

* Add example of Modal usage

* update unit test by adding snapshot to verify the component renders what is expected in the UI

* fix: Modal focus trap works better with keydown listener, add focus trap tests, upgrade testing-library packages

* fix: use userEvent.type to simulate escape key press

* fixed failing test

Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
Co-authored-by: Chris Garcia <pixelbandito@gmail.com>

* feat: EVER-13212: a11y colors for buttons and text links

Co-authored-by: bkonuwa <bkonuwa@gmail.com>
Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
pixelbandito added a commit that referenced this pull request May 21, 2021
* feat: Add Modal component (#309)

* feat: Add Modal component

* cleaned up css class names

* add logic to auto focus and focus trapping in the modal

* Add example of Modal usage

* update unit test by adding snapshot to verify the component renders what is expected in the UI

* fix: Modal focus trap works better with keydown listener, add focus trap tests, upgrade testing-library packages

* fix: use userEvent.type to simulate escape key press

* fixed failing test

Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
Co-authored-by: Chris Garcia <pixelbandito@gmail.com>

* feat: EVER-13212: a11y colors for buttons and text links

Co-authored-by: bkonuwa <bkonuwa@gmail.com>
Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
pixelbandito added a commit that referenced this pull request Aug 20, 2021
* feat: Add Modal component (#309)

* feat: Add Modal component

* cleaned up css class names

* add logic to auto focus and focus trapping in the modal

* Add example of Modal usage

* update unit test by adding snapshot to verify the component renders what is expected in the UI

* fix: Modal focus trap works better with keydown listener, add focus trap tests, upgrade testing-library packages

* fix: use userEvent.type to simulate escape key press

* fixed failing test

Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
Co-authored-by: Chris Garcia <pixelbandito@gmail.com>

* feat: EVER-13212: a11y colors for buttons and text links

Co-authored-by: bkonuwa <bkonuwa@gmail.com>
Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
pixelbandito added a commit that referenced this pull request Aug 24, 2021
* feat: Add Modal component (#309)

* feat: Add Modal component

* cleaned up css class names

* add logic to auto focus and focus trapping in the modal

* Add example of Modal usage

* update unit test by adding snapshot to verify the component renders what is expected in the UI

* fix: Modal focus trap works better with keydown listener, add focus trap tests, upgrade testing-library packages

* fix: use userEvent.type to simulate escape key press

* fixed failing test

Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
Co-authored-by: Chris Garcia <pixelbandito@gmail.com>

* feat: EVER-13212: a11y colors for buttons and text links

Co-authored-by: bkonuwa <bkonuwa@gmail.com>
Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
ManoloAlvarezForo added a commit that referenced this pull request Sep 16, 2021
* Feature ever 13205 a11y buttons and links (#311)

* feat: Add Modal component (#309)

* feat: Add Modal component

* cleaned up css class names

* add logic to auto focus and focus trapping in the modal

* Add example of Modal usage

* update unit test by adding snapshot to verify the component renders what is expected in the UI

* fix: Modal focus trap works better with keydown listener, add focus trap tests, upgrade testing-library packages

* fix: use userEvent.type to simulate escape key press

* fixed failing test

Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
Co-authored-by: Chris Garcia <pixelbandito@gmail.com>

* feat: EVER-13212: a11y colors for buttons and text links

Co-authored-by: bkonuwa <bkonuwa@gmail.com>
Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>

* docs: Update changelog, publishing.md

* Merge new features from v3.x to v4-alpha (#339)

* Feature: EVER-13451: Add `Select` component (#325)

* feat: EVER-13451: Initial commit of Select and Select.Option components

* WIP: Keyboard handler for moving selected option focus with up arrow.

* feat: EVER-13451: Up and down arrow keys, validity with hidden native select, break some code into separate hooks

* feat: EVER-13451: Add tests for , make  a child, export from index and import into example app

* feat: EVER-13451: Update jsdom env to sixteen

* feat: EVER-13451: Restore non-clicky style to plain Dropdown.Menu.Item content, style stories a bit

* feat: EVER-13451: Update Dropdown.Menu.Item README

* chore: EVER-13451: Update more tests and snapshots

* v3.1.0 (#338)

Just publishing a new minor version, no diff except the changelog and package.json version number.

* Deploying v4.0.0-alpha.2

Co-authored-by: Chris Garcia <pixelbandito@gmail.com>
Co-authored-by: bkonuwa <bkonuwa@gmail.com>
Co-authored-by: Boima Konuwa <boima.konuwa@cision.com>
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.

3 participants