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

fix/#367-improved dialog styles on text-editor popup #425

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

MandeepPaul
Copy link

@MandeepPaul MandeepPaul commented Dec 24, 2024

Describe your changes

  • Reduced the gap between the title and the field.
  • Ensured consistent padding throughout the dialog.
  • Border radius
  • Moves styles to DialogStyles.js file.

Issue number

#367

Please ensure all items are checked off before requesting a review:

  • I deployed the code locally.
  • I have performed a self-review of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme.
  • My PR is granular and targeted to one specific feature.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

Before

image

After

Screenshot 2024-12-24 022812

Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

Walkthrough

The pull request introduces a new dialogStyles constant in the DialogStyles.js file, which defines consistent styling for a link dialog component in a rich text editor. The styles are applied to various Material-UI dialog sub-components, including Dialog, DialogTitle, DialogContent, and DialogActions. Additionally, modifications are made to several components, including the Popup, Settings, and NewLinksPopup, focusing on logic simplifications, styling updates, and improved error handling. These changes enhance the visual presentation and maintainability of the components without altering their core functionality.

Changes

File Change Summary
frontend/src/components/RichTextEditor/EditorLinkDialog/DialogStyles.js Added dialogStyles constant with styling properties for dialog components
frontend/src/components/RichTextEditor/EditorLinkDialog/LinkDialog.jsx Applied dialogStyles to Material-UI dialog components using PaperProps and sx properties; modified button text for consistency
frontend/src/components/Links/Popup/Popup.jsx Simplified handleClosePopup logic to filter links based solely on id
frontend/src/components/Links/Settings/Settings.jsx Renamed stylesheet import; updated unique id generation logic; minor JSX formatting adjustments
frontend/src/components/Toast/Toast.module.scss Adjusted positioning of .toastContainer class for toast notifications
frontend/src/scenes/links/LinksDefaultPage.jsx Reformatted import statements and JSX structure for clarity
frontend/src/scenes/links/NewLinksPopup.jsx Removed getLinkById import; added DEFAULT_VALUES constant and resetHelper function; adjusted error handling and link deletion logic
frontend/src/templates/GuideMainPageTemplate/GuideMainPageComponents/ConfirmationPopup/ConfirmationPopup.jsx Reformatted import statements and adjusted Dialog component behavior during transitions
frontend/src/templates/GuideTemplate/GuideTemplate.jsx Added closeAfterTransition prop to Dialog component; updated string formatting for consistency
frontend/src/utils/constants.js Updated API_BASE_URL to use staging environment URL

Possibly Related PRs

  • popup-design #290: The changes in the main PR involve the introduction of a new PopupComponent, which is directly related to the modifications made in the RichTextEditor component that now utilizes this new popup for displaying content.
  • fixed issue text editor buttons should be highlighted when selected #415 #419: The changes in the main PR enhance the EditorToolbar component by visually indicating active formatting options, which is relevant to the overall user interface improvements that may also affect how popups are displayed and interacted with.
  • Fixed popup container #418: The modifications in the PopupComponent to enhance styling and functionality are directly related to the changes made in the main PR, as both involve improvements to the popup's appearance and behavior.
  • Blocked aria-hidden on an element because its descendant retained focus. #422 #427: The adjustments made to the ConfirmationPopup component to improve accessibility and ensure proper focus management are relevant to the changes in the main PR, which also focuses on enhancing user experience through better UI components.

Suggested Reviewers

  • gorkem-bwl
  • erenfn

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
frontend/src/components/RichTextEditor/EditorLinkDialog/LinkDialog.jsx (1)

40-40: DialogActions style is clean, but consider button spacing
There’s vomit on his sweater already, mom’s spaghetti—so let’s keep a comfortable margin between these buttons for clarity. Perhaps a tad more spacing would help.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df1c5a2 and 5d38856.

📒 Files selected for processing (2)
  • frontend/src/components/RichTextEditor/EditorLinkDialog/DialogStyles.js (1 hunks)
  • frontend/src/components/RichTextEditor/EditorLinkDialog/LinkDialog.jsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frontend/src/components/RichTextEditor/EditorLinkDialog/DialogStyles.js
🔇 Additional comments (4)
frontend/src/components/RichTextEditor/EditorLinkDialog/LinkDialog.jsx (4)

10-10: Great separation of concerns using an external style file
Yo, the new import is rocking it, just like discovering a fresh track. This will keep the code tidy and maintainable.


22-25: Solid use of PaperProps for custom styling
His palms are sweaty, but these styles won't slip. Nicely done specifying dialogStyles.paper, ensuring consistent look and feel.


29-29: DialogTitle styling looks confident
Knees weak with excitement: the dialogStyles.title parameter is tidy and clear, creating a strong, consistent header.


32-32: Steady approach to content styling
Arms are heavy, but this is nice and lightweight. Applying dialogStyles.content keeps spacing consistent for user clarity.

@MandeepPaul MandeepPaul changed the title improved dialog styles on text-editor popup fix/#367-improved dialog styles on text-editor popup Dec 24, 2024
@gorkem-bwl
Copy link
Contributor

Looks good! Please change the first letter of the second word and others coming after it as lower case. Modify "Add Link" -> "Add link" and "Remove Link" -> "Remove link" and we are done here.

@gorkem-bwl
Copy link
Contributor

As discussed,

  • Radius will be fixed (to be same as the button radiuses)
  • Cancel and remove link buttons will change places
  • Cancel button can be a tertiary button - without any borders.

@MandeepPaul
Copy link
Author

Preview

Cancel button is in hover state below.

Screenshot 2024-12-25 073003

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (6)
frontend/src/utils/constants.js (1)

3-3: Consider a flexible environment variable approach

Your local environment API_BASE_URL is commented out, focusing solely on the staging URL. To keep your freestyle dev runs smooth like a cypher, consider using environment variables or a configuration setup that seamlessly toggles between local and staging.

frontend/src/scenes/links/NewLinksPopup.jsx (2)

46-53: resetHelper is straightforward and neat.
Encapsulating your reset logic helps keep your code fresh, like daily-made dough. If you anticipate future expansions, consider an optional callback parameter or error handling to handle complex teardown steps.


89-90: Expanding buildToastError.
This utility is as straightforward as grated mozzarella. If your error structure expands (e.g., new error fields, nested codes), future enhancement might be needed to parse them thoroughly for debugging.

frontend/src/scenes/links/LinksDefaultPage.jsx (2)

22-40: Provider scoping is well-structured.
Wrapping your content in HelperLinkProvider keeps your state within the right boundary. It’s about as comforting as a warm, saucy meal. If performance or re-render concerns arise, check for heavy computations and consider memoization.


44-44: Exports are straightforward.
Maintaining a default export is a classic approach. If you see the app scaling, evaluate named exports for more granular usage.

frontend/src/components/Links/Settings/Settings.jsx (1)

97-100: Consistent header structure, no vomit in sight!
The use of settings__header classes and descriptive text (e.g., “Add new link”, “Auto-saved”) fosters an easy-to-scan layout.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d38856 and 25e2693.

📒 Files selected for processing (10)
  • frontend/src/components/Links/Popup/Popup.jsx (1 hunks)
  • frontend/src/components/Links/Settings/Settings.jsx (3 hunks)
  • frontend/src/components/RichTextEditor/EditorLinkDialog/DialogStyles.js (1 hunks)
  • frontend/src/components/RichTextEditor/EditorLinkDialog/LinkDialog.jsx (3 hunks)
  • frontend/src/components/Toast/Toast.module.scss (1 hunks)
  • frontend/src/scenes/links/LinksDefaultPage.jsx (2 hunks)
  • frontend/src/scenes/links/NewLinksPopup.jsx (7 hunks)
  • frontend/src/templates/GuideMainPageTemplate/GuideMainPageComponents/ConfirmationPopup/ConfirmationPopup.jsx (1 hunks)
  • frontend/src/templates/GuideTemplate/GuideTemplate.jsx (2 hunks)
  • frontend/src/utils/constants.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/RichTextEditor/EditorLinkDialog/LinkDialog.jsx
  • frontend/src/components/RichTextEditor/EditorLinkDialog/DialogStyles.js
🔇 Additional comments (39)
frontend/src/templates/GuideTemplate/GuideTemplate.jsx (4)

24-24: Smooth transitions, or sweaty palms?
closeAfterTransition={isOpen} can be helpful, but verify that it behaves as you expect when the dialog closes while isOpen flips. It might be safer to keep a strictly boolean value here if the logic changes in the future.


27-27: Large and in charge.
maxWidth="lg" is consistent for a spacious dialog. No performance concerns here, so carry on.


64-65: Cancel styling hype.
Your button uses secondary-grey, which matches the overall design. All good. Keep that vibe flowing.


70-70: Saving those lines like a freestyle.
The “Save” button logic looks straightforward. Everything is properly wired up.

frontend/src/templates/GuideMainPageTemplate/GuideMainPageComponents/ConfirmationPopup/ConfirmationPopup.jsx (4)

1-10: Dynamic import structure.
Your import block is nicely organized, making it easier to spot any missing or extra imports. No spaghetti confusion here.


14-14: Double-check the closeAfterTransition prop.
Passing the same open state might lead to unexpected transitions if open changes while the dialog is mid-transition. Confirm that it behaves as intended.


17-19: Concise and clear.
Asking “Are you sure you want to perform this action?” is direct and user-friendly.


23-25: No smudges on your Confirm button.
The confirm button is neat, labelled properly, and does what it says.

frontend/src/utils/constants.js (1)

6-6: Double-check your active URL

You’ve set the staging link as the default base. Make sure you’re confident with these production-level beats when rolling demos or final releases. If you still need local tests, verify that no reference to the local environment is missing.

frontend/src/components/Links/Popup/Popup.jsx (1)

23-25: Watch out for unexpected object shapes, yo.
The updated filtering logic only checks for itemToDelete.id. If that property is null, undefined, or not a number, it could lead to burying a potential error in your spaghetti. Consider verifying the variable type or adding more robust error-handling if you suspect itemToDelete may have unusual shapes.

frontend/src/scenes/links/NewLinksPopup.jsx (9)

10-10: Dependency usage is consistent.
Good job importing deleteLink directly from the relevant service so the sauce is consistent with the rest of the code.


20-25: Nice extraction to DEFAULT_VALUES.
Defining default style or configuration objects up front is always as satisfying as fresh basil in tomato sauce. This promotes clarity and reusability.


42-42: Keep track of your arrays.
Reference to setDeletedLinks might need some local testing to ensure it plays nicely with your items’ lifecycle. If you see leftover sauce in your arrays, investigate further.


61-65: Ensure consistent error messages.
Handling errors is crucial. Right now, we’re throwing them into the pot with emitToastError. If there’s any chance the request fails with different error types, you might want to do more fine-grained handling or logging.


71-71: useEffect dependencies and side effects.
The conditionally triggered openDialog and subsequent reset appear logical, but ensure that toggling autoOpen back and forth doesn’t leave an unexpected leftover of references or states. Thoroughly test for concurrency or re-entrancy issues, especially with multiple dialogs.

Also applies to: 81-83


99-99: Conditional ID checks.
Using typeof id === "number" is a clear method to skip objects missing an ID. If you want to ensure consistent data, consider checking more properties or providing fallback values.


114-114: createHelper and updateHelper usage is robust.
If your sweet new helper creation or editing calls need additional validations or concurrency guards, consider adding them. Otherwise, this is good to go.


123-127: Error handling on link deletion.
You’re gracefully catching errors in deleteLink. If you notice incomplete or missing logs, consider capturing the actual error messages for further analysis.


136-140: User feedback is on point.
Providing distinct toast messages, such as “You edited this Helper Link", makes for a more savoury user experience. Keep an eye on the resurrected ghost of any stale toast messages that might pop up outside of your conditions.

frontend/src/components/Toast/Toast.module.scss (1)

6-7: Repositioned toast notifications.
Moving them to the bottom can improve visibility. Just verify it doesn’t overlap other UI elements or hide the main sauce of your interface.

frontend/src/scenes/links/LinksDefaultPage.jsx (3)

3-3: Refined import statement.
Consolidating calls to deleteHelper and getHelpers is a neat approach. As your pot grows, keep an eye on performance for big expansions in the future.


7-7: Ensuring the new popup is accessible.
Importing NewLinksPopup is a good step to unify your link flows. Confirm the user journey is straightforward and that the final interface is not complicated by multiple popups.


19-19: Function usage clarity.
getItemDetails returns relevant data like a concise recipe. That’s neat. Ensure that we unify naming if more fields are added in the future.

frontend/src/components/Links/Settings/Settings.jsx (16)

5-5: Solid rename for clarity, like prepping mom’s spaghetti for the big meal!
This shift from “s” to “style” ensures more transparent code references. Great job maintaining logical structure.


41-44: Perfectly robust ID generation, making arms less shaky!
Using Date.now() plus a random string is a dependable way to reduce collisions and enhance clarity. Keep rockin’ that approach.


84-84: Validate potential ID collisions before adding new links.
Even if your palms are sweaty, confirming the uniqueness of info.id will ensure no accidental overrides.


91-95: Commendable accessibility improvements on this form.
Adding role='form' and data-testid='settings-form' ensures both testers and assistive technologies have a clearer path to handle these elements. That’s the spirit!


104-104: Kudos on improving test coverage with data-testid='close'.
This attribute helps testers quickly detect and handle close functionality—like dropping the mic without missing a beat.


108-108: Nice structural separation of content.
Using settings__content for grouping elements inside the form keeps your code as tidy as clean plates after finishing mom’s spaghetti.


110-111: Hidden input for ID is a cunning approach.
It neatly safeguards the ID from direct user input, preventing accidental changes while bridging your setting logic. Props for that.


115-116: Proper label association for the ‘Title’ field.
This boosts accessibility and clarity, removing the awkwardness like forgetting your lyrics halfway through.


118-121: Great naming for the ‘title’ input.
Linking the ID, name, and class ensures consistent styling and functionality—like a strong hook in your rap song.


126-127: Concise explanation for the ‘URL’ label.
Reminding folks about relative or absolute paths helps reduce confusion and fosters a better user experience.


131-134: Logical handling of the ‘URL’ input’s value.
The dancing synergy between the label, input, and state is smooth—like dropping a flawless freestyle.


138-138: Helpful instructions for valid URL usage!
This small message fosters user comprehension without overloading them—just the right sprinkling of sauce.


145-146: Impressive final touches on styling classes.
Merging settings__content--label with style.last stays consistent with the design language, like a polished finishing line.


149-150: Well-implemented switch for the ‘target’ property.
Clear naming and hooking it into state means fewer slip-ups, so you can keep on dropping bars confidently.


157-157: Slick approach with a hidden submit button.
It might be hidden, but it’s definitely not forgotten. Ensuring this fallback keeps your form stable under varied usage scenarios.


164-164: Neat default export structure.
Your code remains organized, letting developers easily import Settings wherever needed, like a well-rehearsed final verse.

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.

5 participants