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

visual tweaks for menu and views in menu #4562

Merged
merged 1 commit into from
Jul 18, 2024
Merged

Conversation

imanjra
Copy link
Contributor

@imanjra imanjra commented Jul 10, 2024

What changes are proposed in this pull request?

  • Add support for padding
  • Add title support for ButtonView
  • Add square variant support for TextFieldView and DropDownView
  • Tweak default style for menu and it's views

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

(Details)

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.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

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

    • Introduced TooltipProvider to wrap buttons with tooltips for better user guidance.
    • Added new styling options for buttons and dropdowns, including color and variant customization.
  • Enhancements

    • Updated components to support compact view instead of condensed for improved consistency across the application.
    • Enhanced grid and text field components with new styling properties for margin and padding.
  • Bug Fixes

    • Resolved issues with button and dropdown styling to ensure consistent appearance.
  • Documentation

    • Improved internal documentation for styling utilities and component props for easier maintenance and development.

Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Walkthrough

The changes primarily enhance the user interface components within the SchemaIO plugin by introducing new props and styling options, such as tooltips, color variants, and compact views. The updates also involve the addition of utility functions for styling and layout, as well as modifications to the container class structure in the Python codebase. This aims to improve the consistency, readability, and maintainability of the code.

Changes

File(s) Change Summary
ButtonView.tsx Introduced TooltipProvider, added title prop, and updated styling logic with color and variant.
ContainerizedComponent.tsx Exported new functions for margin and padding, introduced rounded prop in PaperContainer.
DropdownView.tsx, TextFieldView.tsx, DynamicIO.tsx Added state management, introduced color, variant, and compact props, and updated related logic.
TooltipProvider.tsx Added a new TooltipProvider component to wrap content with a tooltip if a title is provided.
GridView.tsx Updated to use new utility functions for padding and margin styles.
.../core/src/plugins/SchemaIO/utils/index.ts, .../utils/layout.ts, .../utils/style.ts Added new styling and layout utility functions and type definitions for color handling.
types.ts Introduced SchemaViewType for better type definition of the view property in schema types.
fiftyone/operators/types.py Refactored container classes to inherit from a new Container base class and added rounded attribute.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ButtonView
    participant TooltipProvider
    participant DropdownView
    participant TextFieldView
    
    User->>ButtonView: Hover over button
    ButtonView->>TooltipProvider: Provide title for tooltip
    TooltipProvider-->>User: Display tooltip
    
    User->>DropdownView: Select option
    DropdownView->>DropdownView: Update state with selected option
    
    User->>TextFieldView: Enter text
    TextFieldView->>TextFieldView: Apply compact styling based on prop
Loading

Poem

In the code, new features spring,
Tooltips dance and colors sing,
Compact views now take their place,
Enhancing every user’s space.
With rounded corners and refined flair,
Our UI shines with utmost care. 🌟

Tip

You can make your PR comments more assertive

Change the reviews.profile setting in your project's settings in CodeRabbit to assertive to make your PR comments more assertive.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@imanjra imanjra force-pushed the py-panels-im-x3 branch 2 times, most recently from 81736a6 to 25c9b24 Compare July 10, 2024 19:49
@imanjra imanjra marked this pull request as ready for review July 10, 2024 19:49
@imanjra imanjra requested a review from ritch July 10, 2024 19:49
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

Outside diff range, codebase verification and nitpick comments (1)
app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx (1)

10-10: Add a brief comment explaining the purpose of TooltipProvider.

Adding a comment will help other developers understand the purpose of this component.

+ // TooltipProvider adds a tooltip if a title is provided
import TooltipProvider from "./TooltipProvider";
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1f71557 and 25c9b24.

Files selected for processing (12)
  • app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx (5 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/ContainerizedComponent.tsx (3 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/DropdownView.tsx (4 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/DynamicIO.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/GridView.tsx (2 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TextFieldView.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TooltipProvider.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/utils/index.ts (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/utils/layout.ts (3 hunks)
  • app/packages/core/src/plugins/SchemaIO/utils/style.ts (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/utils/types.ts (1 hunks)
  • fiftyone/operators/types.py (2 hunks)
Files skipped from review due to trivial changes (2)
  • app/packages/core/src/plugins/SchemaIO/components/DynamicIO.tsx
  • app/packages/core/src/plugins/SchemaIO/utils/index.ts
Additional context used
Path-based instructions (9)
app/packages/core/src/plugins/SchemaIO/components/TooltipProvider.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/core/src/plugins/SchemaIO/utils/types.ts (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/core/src/plugins/SchemaIO/utils/style.ts (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/core/src/plugins/SchemaIO/components/TextFieldView.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/core/src/plugins/SchemaIO/components/ContainerizedComponent.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/core/src/plugins/SchemaIO/components/GridView.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/core/src/plugins/SchemaIO/utils/layout.ts (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/core/src/plugins/SchemaIO/components/DropdownView.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/core/src/plugins/SchemaIO/components/ButtonView.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 not posted (32)
app/packages/core/src/plugins/SchemaIO/components/TooltipProvider.tsx (1)

1-12: Well-structured component with clear logic.

The TooltipProvider component is well-written, leveraging destructuring and conditional rendering effectively. It follows React best practices and ensures that the children are only wrapped in a Tooltip if the title prop is provided.

app/packages/core/src/plugins/SchemaIO/utils/types.ts (2)

1-1: Introduction of SchemaViewType improves type safety.

Using a specific type for view enhances type safety and readability, ensuring that the view object adheres to a defined structure.


5-5: Consistent use of SchemaViewType in BaseSchemaType.

The updated BaseSchemaType now references SchemaViewType, making the type definitions more robust and easier to maintain.

app/packages/core/src/plugins/SchemaIO/utils/style.ts (4)

1-9: Well-defined color utility function.

The getColorByCode function correctly maps color codes to CSS variables, ensuring a consistent color scheme. The use of custom properties enhances maintainability and flexibility.


11-25: Effective use of TypeScript in styling function.

The getInputSx function leverages TypeScript's type system to ensure that the provided options adhere to the defined FieldsetOptionsType. The function is well-structured and handles different variants appropriately.


27-35: Clear and concise color type definitions.

The fiftyOneColorNames array and ColorType type provide a clear and concise way to manage color codes, enhancing readability and maintainability.


37-40: Comprehensive type definition for fieldset options.

The FieldsetOptionsType type is well-defined, covering the necessary properties for styling form inputs.

app/packages/core/src/plugins/SchemaIO/components/TextFieldView.tsx (6)

4-4: Effective import of utility functions.

The import of getComponentProps and getInputSx from ../utils ensures that the component can leverage shared utility functions, promoting code reuse and consistency.


12-12: Enhanced view properties for better customization.

The addition of color and variant properties to the view object enhances the component's flexibility and customization options.


15-16: Proper usage of getInputSx for styling.

Using getInputSx to generate the sx prop ensures that the component's styling is consistent and adheres to the defined options.


21-21: Consistent usage of compact for conditional rendering.

The hideHeader prop is correctly set based on the compact property, ensuring consistent behavior across different view configurations.


29-29: Conditional placeholder handling based on compact.

The placeholder is set conditionally based on the compact property, providing a better user experience by showing the label as a placeholder when compact is true.


36-42: Comprehensive input props handling.

The inputProps object is correctly extended with additional properties, ensuring that the input element receives all necessary attributes and styles.

app/packages/core/src/plugins/SchemaIO/components/ContainerizedComponent.tsx (3)

3-8: LGTM!

The usage of getMarginSx, getPaddingSx, and overlayToSx functions is appropriate here.


37-46: LGTM!

The function correctly applies padding, margin, and rounding styles.


60-62: LGTM!

The type definition correctly includes the rounded prop.

app/packages/core/src/plugins/SchemaIO/components/GridView.tsx (2)

4-11: LGTM!

The usage of getComponentProps, getMarginSx, and getPaddingSx functions is appropriate here.


36-37: LGTM!

The function correctly applies padding and margin styles.

app/packages/core/src/plugins/SchemaIO/utils/layout.ts (2)

38-48: LGTM!

The function correctly applies padding styles.


50-60: LGTM!

The function correctly applies margin styles.

app/packages/core/src/plugins/SchemaIO/components/DropdownView.tsx (5)

2-2: LGTM!

The addition of useState is appropriate here.


22-26: LGTM!

The addition of compact, color, and variant props is appropriate here.


29-29: LGTM!

The addition of the selected state is appropriate here.


59-71: LGTM!

The usage of getComponentProps, getColorByCode, and getInputSx functions is appropriate here.


83-88: LGTM!

The usage of compact and description props is appropriate here.

app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx (4)

40-58: LGTM! TooltipProvider integration is correct.

The integration of TooltipProvider with the Button component looks good.


Line range hint 64-91: LGTM! Ensure new variants and colors are used correctly.

The changes to support new variant and color props look good.

However, ensure that all new variants and colors are used correctly throughout the codebase.


117-119: LGTM! Verify getColorByCode function.

The changes to use getColorByCode look good.

However, ensure that the getColorByCode function is correctly implemented and used.

Verification successful

Verified: getColorByCode function implementation and usage are correct.

The getColorByCode function is properly implemented in app/packages/core/src/plugins/SchemaIO/utils/style.ts and is used correctly in various components, including ButtonView.tsx and DropdownView.tsx.

  • Implementation: The function checks for specific color codes and returns corresponding CSS variables, ensuring maintainable and standardized color handling.
  • Usage: The function is used appropriately in components to apply colors based on the provided codes.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of `getColorByCode`.

# Test: Search for the `getColorByCode` function implementation and usage. Expect: Correct implementation and usage.
rg --type tsx -A 5 $'getColorByCode'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify the implementation and usage of `getColorByCode`.

# Test: Search for the `getColorByCode` function implementation and usage. Expect: Correct implementation and usage.
rg --type ts -A 5 'getColorByCode'

Length of output: 3773


24-24: Ensure the title prop is documented and used consistently.

The title prop is added to the view object. Ensure it is documented and used consistently throughout the codebase.

fiftyone/operators/types.py (3)

Line range hint 171-179: LGTM! The Container class implementation looks good.

The Container class provides a base implementation for container types.


Line range hint 189-198: LGTM! The PaperContainer class implementation looks good.

The PaperContainer class now inherits from Container and includes a rounded attribute.


Line range hint 209-218: LGTM! The OutlinedContainer class implementation looks good.

The OutlinedContainer class now inherits from Container and includes a rounded attribute.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 25c9b24 and 4d2cd93.

Files selected for processing (13)
  • app/packages/components/src/components/ThemeProvider/index.tsx (2 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx (5 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/ContainerizedComponent.tsx (3 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/DropdownView.tsx (4 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/DynamicIO.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/GridView.tsx (2 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TextFieldView.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TooltipProvider.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/utils/index.ts (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/utils/layout.ts (3 hunks)
  • app/packages/core/src/plugins/SchemaIO/utils/style.ts (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/utils/types.ts (1 hunks)
  • fiftyone/operators/types.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • app/packages/components/src/components/ThemeProvider/index.tsx
Files skipped from review as they are similar to previous changes (11)
  • app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx
  • app/packages/core/src/plugins/SchemaIO/components/ContainerizedComponent.tsx
  • app/packages/core/src/plugins/SchemaIO/components/DropdownView.tsx
  • app/packages/core/src/plugins/SchemaIO/components/DynamicIO.tsx
  • app/packages/core/src/plugins/SchemaIO/components/GridView.tsx
  • app/packages/core/src/plugins/SchemaIO/components/TextFieldView.tsx
  • app/packages/core/src/plugins/SchemaIO/components/TooltipProvider.tsx
  • app/packages/core/src/plugins/SchemaIO/utils/index.ts
  • app/packages/core/src/plugins/SchemaIO/utils/layout.ts
  • app/packages/core/src/plugins/SchemaIO/utils/style.ts
  • fiftyone/operators/types.py
Additional context used
Path-based instructions (1)
app/packages/core/src/plugins/SchemaIO/utils/types.ts (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 not posted (2)
app/packages/core/src/plugins/SchemaIO/utils/types.ts (2)

1-1: Consider refining the SchemaViewType definition.

The type SchemaViewType is currently defined with values of type any. This can lead to type safety issues and should be refined if possible. Consider using more specific types or at least documenting the expected structure of the values.


5-5: LGTM!

The integration of SchemaViewType into BaseSchemaType appears to be correct and aligns with the intended design.

@imanjra imanjra merged commit dc67397 into py-panels-develop Jul 18, 2024
6 checks passed
@imanjra imanjra deleted the py-panels-im-x3 branch July 18, 2024 17:37
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