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

Add file input dialog #90

Merged
merged 13 commits into from
Oct 3, 2024
Merged

Conversation

yoonieaj
Copy link
Collaborator

@yoonieaj yoonieaj commented Oct 2, 2024

Proposed Changes

Adds a modal to the file input section to clean up the user interface.

...

current input section:

image

input section following changes:

image

The Upload JSON File button opens a modal:

image

Screenshots of your changes (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots) X
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📚 Documentation update (change that only updates documentation)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.
  • I have updated the project Changelog (this is required for all changes).

After opening your pull request:

  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

Hello Professor! I managed to get the button to a reasonable size without having to rewrite any classes, but I can't seem to vertically center the file browse button within the modal window -- I included screenshots of this. From using the inspect tool, it seems like the file browse/input button is placed inside a div once the website is rendered but not centered within it. I'm not sure how to modify this div, or get rid of it. Do you have any suggestions on next steps? Thanks!

@yoonieaj yoonieaj requested a review from david-yz-liu October 2, 2024 01:10
Copy link
Owner

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

@yoonieaj A general principle is to rely on the library to do the styling for us, and avoid custom CSS as much as possible. In this particular case, it seems like you have a bunch of custom CSS that's fighting against the default styling. I don't actually think that's necessary for this modal.

Use the provided components; it's fine to have the file input above the upload button rather than beside it. I imagine that's easier to achieve using these library components, and then the library and handle the layout for you.

@yoonieaj yoonieaj marked this pull request as ready for review October 2, 2024 19:42
@yoonieaj yoonieaj marked this pull request as draft October 2, 2024 19:52
2,
fileString
);
expect(setTextDataMock).toHaveBeenCalledWith(fileString);
Copy link
Collaborator Author

@yoonieaj yoonieaj Oct 2, 2024

Choose a reason for hiding this comment

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

Previously, setTextData would be called called twice (once upon uploading the file, and again upon clicking the Load file data button). I made changes so that setTextData is only called once the button is clicked, and had to change this test to reflect that.

@yoonieaj yoonieaj marked this pull request as ready for review October 2, 2024 23:52
@coveralls
Copy link
Collaborator

coveralls commented Oct 2, 2024

Pull Request Test Coverage Report for Build 11168684885

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 89.862%

Totals Coverage Status
Change from base Build 11041171333: 0.05%
Covered Lines: 409
Relevant Lines: 439

💛 - Coveralls

@yoonieaj yoonieaj requested a review from david-yz-liu October 2, 2024 23:56
data-testid="file-input-modal"
>
<Paper
sx={{
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure why any of these custom styles are necessary, doesn't the Modal component take care of the layout for us?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The default styling for the modal was pretty much unusable:

image

As far as I can tell, the MUI Modal component doesn't actually have useful style presets. The examples in their documentation all set the CSS manually. (I did find something called Joy UI, which seems to be an offshoot of MUI that does offer good default Modal styling, but I think that's a separate library we'd have to install.)

Copy link
Owner

Choose a reason for hiding this comment

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

@yoonieaj aha, thanks for clarifying. This prompted me to do some more digging in the MUI documentation, since this seemed counter-intuitive to me. If you look at the documentation for Modal, it includes the following warning:

The term "modal" is sometimes used to mean "dialog", but this is a misnomer. A modal window describes parts of a UI. An element is considered modal if it blocks interaction with the rest of the application.

and

If you are creating a modal dialog, you probably want to use the Dialog component rather than directly using Modal. Modal is a lower-level construct that is leveraged by the following components...

So, I think we should be using Dialog here instead of Modal!

Load file data
<div>
<Button onClick={handleOpen} sx={{ textTransform: "none" }}>
File Input
Copy link
Owner

Choose a reason for hiding this comment

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

Rename to "Upload JSON File"

@yoonieaj yoonieaj requested a review from david-yz-liu October 3, 2024 02:07
@yoonieaj yoonieaj changed the title File input modal File input dialog Oct 3, 2024
@yoonieaj yoonieaj changed the title File input dialog Add file input dialog Oct 3, 2024
@david-yz-liu david-yz-liu merged commit 4ba4dfd into david-yz-liu:master Oct 3, 2024
4 checks passed
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