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

make it pretty #4999

Merged
merged 3 commits into from
Oct 29, 2024
Merged

make it pretty #4999

merged 3 commits into from
Oct 29, 2024

Conversation

CamronStaley
Copy link
Contributor

@CamronStaley CamronStaley commented Oct 29, 2024

What changes are proposed in this pull request?

Aligning the toast for the query performance panel more closely with the mocks.

How is this patch tested? If it is not, please explain why.

Local dev:

image

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features

    • Enhanced QueryPerformanceToast to display for a longer duration and show by default.
    • Updated theme colors for better responsiveness and styling.
    • Improved layout of Toast notifications for a cohesive user experience.
  • Bug Fixes

    • Adjusted button text for clarity and consistency.
  • Chores

    • Updated Material-UI imports to the latest version for improved performance and features.

@CamronStaley CamronStaley requested review from minhtuev and a team October 29, 2024 19:35
Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

Warning

Rate limit exceeded

@CamronStaley has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between e5a811a and 83ac5a0.

Walkthrough

The changes in this pull request involve updates to the QueryPerformanceToast, ThemeProvider, and Toast components. The QueryPerformanceToast component has been modified to use a newer version of Material-UI, with changes to the toast's display duration, initial visibility, and theme-based styling. The ThemeProvider has been enhanced with new color properties for theming. The Toast component has been restructured to improve the layout of the message and action area. Overall, these updates enhance the visual and functional aspects of toast notifications and theming.

Changes

File Path Change Summary
app/packages/app/src/components/QueryPerformanceToast.tsx Updated Material-UI import, increased toast display duration, changed initial visibility, added theme-based styles, and modified button text and colors.
app/packages/components/src/components/ThemeProvider/index.tsx Added new color properties (lightning and toastBackgroundColor) to light and dark themes.
app/packages/components/src/components/Toast/Toast.tsx Restructured message prop to include a Box component for layout control, preserving core functionality.

Possibly related PRs

  • Toast component #4955: The main PR modifies the QueryPerformanceToast component, which is related to the Toast component introduced in this PR, as both involve toast notifications and utilize Material-UI components.
  • Toast component refactor #4957: This PR refactors the Toast component, which is directly related to the changes in the main PR that also involve modifications to the toast's behavior and styling.
  • Add ToastView to Python Panels #4968: This PR enhances the Toast component's functionality, which aligns with the main PR's updates to the QueryPerformanceToast component, particularly in terms of rendering and layout customization.

Suggested reviewers

  • benjaminpkane
  • imanjra
  • ritch
  • minhtuev

🐇 In the garden where toasts do bloom,
A sprinkle of color, dispelling the gloom.
With themes that dance and buttons that cheer,
Our notifications now bring joy near!
So hop along, let the good times flow,
For every toast, a vibrant glow! 🌼


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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 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.


const SHOWN_FOR = 10000;
const SHOWN_FOR = 50000;
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be 50 seconds instead of 5 seconds btw ~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just copied this from your PR: #4966. Do you wanna merge that one and I can rebase onto it or merge this one and do the opposite?

Copy link
Contributor

@minhtuev minhtuev Oct 29, 2024

Choose a reason for hiding this comment

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

My bad, my PR was WIP so I set a high number for debugging; you can set to 5000 and merge directly to develop.

Copy link
Contributor

@minhtuev minhtuev left a comment

Choose a reason for hiding this comment

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

Thanks Cam, looking great! Small comment about duration, otherwise LGTM ✅

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: 5

🧹 Outside diff range and nitpick comments (5)
app/packages/components/src/components/Toast/Toast.tsx (3)

Line range hint 4-17: Improve type safety for primary and secondary action props

The primary and secondary props are currently typed as any. Consider adding proper function types to improve type safety and documentation.

 interface ToastProps {
   message: React.ReactNode;
-  primary?: any;
-  secondary?: any;
+  primary?: (setOpen: (open: boolean) => void) => React.ReactNode;
+  secondary?: (setOpen: (open: boolean) => void) => React.ReactNode;
   duration?: number;
   layout?: {

89-99: Enhance accessibility and design system consistency

The new layout structure looks good, but consider these improvements:

  1. Add proper aria-labels for the action area
  2. Ensure the gap value (4) aligns with your design system spacing scale
 <Box
   display="flex"
   alignItems="center"
   justifyContent="space-between"
-  gap={4}
+  gap={2} // Assuming your design system uses multiples of 2 for spacing
+  role="presentation"
 >
-  <Box>{message}</Box>
+  <Box role="alert">{message}</Box>
   {action}
 </Box>

Line range hint 100-107: Use theme values instead of hardcoded colors

The component uses hardcoded color values which may not maintain consistency with the theme. Consider using theme values for better maintainability and consistency.

 sx={{
-  backgroundColor: layout?.backgroundColor || "#333",
-  color: layout?.color || "#fff",
+  backgroundColor: layout?.backgroundColor || (theme) => theme.palette.grey[900],
+  color: layout?.color || (theme) => theme.palette.common.white,
   fontSize: layout?.fontSize || "14px",
   display: "block",
   textAlign: layout?.textAlign || "left",
 }}
app/packages/app/src/components/QueryPerformanceToast.tsx (2)

Line range hint 57-61: Enhance security and style reusability

Two suggestions for improvement:

  1. Add security attributes when opening new window
  2. Extract common button styles to a theme or constant
 onClick={() => {
-  open(QP_MODE, "_blank")?.focus();
+  open(QP_MODE, "_blank", "noopener,noreferrer")?.focus();
   setOpen(false);
 }}
 sx={{ marginLeft: "auto", backgroundColor: theme.primary.main, color: theme.text.primary, boxShadow: 0 }}

94-97: Utilize theme spacing system

Replace hardcoded spacing values with theme.spacing to maintain consistency across the application.

 sx={{
   color: theme.custom.lightning,
   borderRadius: "2px",
-  padding: "2px 4px",
+  padding: theme.spacing(0.25, 0.5),
   fontSize: "1rem",
 }}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 574c954 and e5a811a.

📒 Files selected for processing (3)
  • app/packages/app/src/components/QueryPerformanceToast.tsx (5 hunks)
  • app/packages/components/src/components/ThemeProvider/index.tsx (2 hunks)
  • app/packages/components/src/components/Toast/Toast.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
app/packages/app/src/components/QueryPerformanceToast.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/components/src/components/ThemeProvider/index.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/components/src/components/Toast/Toast.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

🔇 Additional comments (2)
app/packages/components/src/components/Toast/Toast.tsx (1)

Line range hint 19-22: Consider setting default toast state to false

The toast's default state is set to true, which means it will show immediately when mounted. This might not be the desired behavior in all scenarios and could lead to unexpected toast appearances.

 const toastStateAtom = atom({
   key: "toastOpenState",
-  default: true,
+  default: false,
 });
app/packages/components/src/components/ThemeProvider/index.tsx (1)

Line range hint 1-277: Verify toast-related component dependencies.

The changes align with the PR objective to update toast notifications. However, we should verify that all dependent toast components are properly consuming these new theme values.

✅ Verification successful

Let me search for toast-related components and their theme usage to get more context.


Let me check the Toast component implementation to see how it uses the theme properties.


No theme-related issues found with toast implementation

The Toast component is properly implemented with configurable styling through the layout prop, which allows overriding any theme values. The default background color (#333) matches the toastBackgroundColor value defined in both light and dark themes. The component doesn't directly consume theme values, instead opting for a more flexible prop-based approach, which is appropriate for this use case.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for components that might need updates for the new theme properties
echo "Searching for toast-related components and theme usage..."
rg -l "toastBackgroundColor|lightning" app/packages/components/src/

Length of output: 257


Script:

#!/bin/bash
# Search for toast components and their theme usage
echo "Searching for toast-related components..."
rg -g '!*.test.*' -g '!*.stories.*' -l "toast" app/packages/components/src/

# Search for specific toast theme property usage
echo -e "\nSearching for toast theme property usage..."
rg -g '!*.test.*' -g '!*.stories.*' "toastBackgroundColor" app/packages/components/src/

Length of output: 683


Script:

#!/bin/bash
# Check Toast component implementation
echo "Checking Toast component implementation..."
cat app/packages/components/src/components/Toast/Toast.tsx

Length of output: 2739


const SHOWN_FOR = 10000;
const SHOWN_FOR = 50000;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider reducing the toast display duration

50 seconds (50000ms) is an unusually long duration for a toast notification. According to Material Design guidelines, toasts should typically be visible for 5-10 seconds to avoid disrupting user experience while ensuring the message is noticed.

-const SHOWN_FOR = 50000;
+const SHOWN_FOR = 10000; // 10 seconds
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const SHOWN_FOR = 50000;
const SHOWN_FOR = 10000; // 10 seconds

@CamronStaley CamronStaley merged commit 790ae51 into develop Oct 29, 2024
10 of 11 checks passed
@CamronStaley CamronStaley deleted the feat/prettify-qp branch October 29, 2024 20:07
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.

2 participants