Skip to content

Comments

chore: theme and code refactor#5983

Merged
pushya22 merged 2 commits intopreviewfrom
chore-pi-colors
Nov 11, 2024
Merged

chore: theme and code refactor#5983
pushya22 merged 2 commits intopreviewfrom
chore-pi-colors

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Nov 11, 2024

Changes:

This PR includes following changes:

  • Color theme updated.
  • De-dupe modal height issue fix.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new CSS custom properties for enhanced theming flexibility, including a new color palette for light and dark modes.
  • Bug Fixes

    • Improved error handling in the issue creation process, ensuring users receive notifications if the editor is not ready to discard changes.
  • Refactor

    • Adjusted rendering logic in modal components to enhance height behavior and form reset logic based on project ID changes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2024

Walkthrough

The changes in this pull request involve the addition of new CSS custom properties in globals.css to enhance theming capabilities, specifically for a "pi" theme. These properties are defined under the :root, [data-theme="light"], and [data-theme="dark"] selectors. Additionally, modifications in the create-root.tsx and form.tsx files include adjustments to the modal's structure and form handling logic, respectively, without altering core functionalities or introducing new methods.

Changes

File Path Change Summary
packages/ui/styles/globals.css Added new CSS custom properties: --color-pi-50, --color-pi-100, --color-pi-200, --color-pi-300, --color-pi-400, --color-pi-500, --color-pi-600, --color-pi-700, --color-pi-800, --color-pi-900, --color-pi-950 for theming.
web/core/components/inbox/modals/create-modal/create-root.tsx Removed h-full class from modal wrapper; retained error handling in handleEscKeyDown and handleFormSubmit.
web/core/components/issues/issue-modal/form.tsx Removed h-full class from DuplicateModalRoot; updated handleFormSubmit for editor readiness check; refined form reset logic; optimized useEffect hooks.

Possibly related PRs

Suggested labels

🌐frontend, 🎨UI / UX, 🧹chore

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham
  • rahulramesha

Poem

🐇 In the garden of code, colors bloom bright,
New shades of pi dance in the light.
With modals that fit just right,
Forms that reset, oh what a sight!
A hop and a skip, we celebrate,
In this world of code, we create our fate! 🌈


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.

CodeRabbit Configuration 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.

@anmolsinghbhatia anmolsinghbhatia changed the title chore: pi theme and code refactor chore: theme and code refactor Nov 11, 2024
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: 2

🧹 Outside diff range and nitpick comments (4)
web/core/components/issues/issue-modal/form.tsx (1)

Line range hint 279-287: Consider improving the error message

The error message "Editor is not ready to discard changes" might be unclear to users. Consider a more user-friendly message.

-      message: "Editor is not ready to discard changes.",
+      message: "Please wait for the editor to finish processing your changes before submitting.",
packages/ui/styles/globals.css (2)

104-116: Improve consistency in color value definitions.

Some pi theme colors use direct RGB values while others reference existing variables. This inconsistency could make theme maintenance more difficult.

Consider:

  1. Using CSS variables consistently for all colors to maintain a single source of truth
  2. If direct RGB values are needed, document why they can't reference existing variables

For example:

-  --color-pi-600: 151, 150, 246;
+  --color-pi-600: var(--color-primary-300);
-  --color-pi-800: 57, 56, 149;
+  --color-pi-800: var(--color-primary-600);

104-116: Add documentation for pi theme color variables.

The purpose and intended usage of each pi color variable is not documented, making it harder for other developers to use them correctly.

Consider adding comments to explain:

  1. The purpose of each color variable
  2. Where each shade should be used
  3. Any accessibility considerations

Example:

   /* pi */
+  /* Base colors for pi theme components
+   * 50-100: Background colors
+   * 200-500: Primary interactive elements
+   * 600-700: Hover and active states
+   * 800-950: Text and borders
+   */
   --color-pi-50: var(--color-background-90);
web/styles/globals.css (1)

123-135: Consider using CSS custom properties for repeated RGB values.

The pi theme colors are defined using a mix of existing variables and direct RGB values. For better maintainability and consistency, consider:

  1. Using CSS custom properties for the repeated RGB values (e.g., lines 131, 133-135)
  2. Following the pattern of reusing existing color variables where possible
 /* pi */
 --color-pi-50: var(--color-background-90);
 --color-pi-100: var(--color-background-90);
 --color-pi-200: var(--color-primary-200);
 --color-pi-300: var(--color-primary-200);
 --color-pi-400: var(--color-primary-200);
 --color-pi-500: var(--color-primary-200);
-    --color-pi-600: 151, 150, 246;
+    --color-pi-600: var(--color-pi-base-600);
 --color-pi-700: var(--color-primary-100);
-    --color-pi-800: 57, 56, 149;
-    --color-pi-900: 30, 29, 78;
-    --color-pi-950: 14, 14, 37;
+    --color-pi-800: var(--color-pi-base-800);
+    --color-pi-900: var(--color-pi-base-900);
+    --color-pi-950: var(--color-pi-base-950);

Consider adding these base color definitions at the top of the :root section:

--color-pi-base-600: 151, 150, 246;
--color-pi-base-800: 57, 56, 149;
--color-pi-base-900: 30, 29, 78;
--color-pi-base-950: 14, 14, 37;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7082f70 and ce77366.

📒 Files selected for processing (4)
  • packages/ui/styles/globals.css (3 hunks)
  • web/core/components/inbox/modals/create-modal/create-root.tsx (1 hunks)
  • web/core/components/issues/issue-modal/form.tsx (1 hunks)
  • web/styles/globals.css (3 hunks)
🔇 Additional comments (4)
web/core/components/inbox/modals/create-modal/create-root.tsx (1)

289-289: LGTM! The pi theme implementation looks good.

The change successfully implements the pi theme through the bg-pi-50 class while maintaining the modal's height calculation logic.

Let's verify the pi theme color definition:

✅ Verification successful

The pi theme implementation is properly configured and safe to use

The verification confirms that:

  • The bg-pi-50 class is correctly mapped to the CSS variable --color-pi-50
  • The CSS variable --color-pi-50 is properly defined in both web and packages/ui styles, inheriting from --color-background-90
  • The background color value is consistently set across themes (light: 247,247,247 and dark: 32,32,32)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the pi-50 color is defined in the CSS files
# Expected: Find the CSS custom property definition for --color-pi-50

rg --type css "pi-50|--color-pi-50"

Length of output: 919


Script:

#!/bin/bash
# Let's verify the background color variable that pi-50 depends on
rg --type css "color-background-90"

# Also check if this color class is properly configured in Tailwind
rg "bg-pi-\d+" "tailwind.config.*"

Length of output: 3404


Script:

#!/bin/bash
# Let's find the tailwind config file with the correct path
fd -e js -e ts "tailwind.config"

# Then check its content for pi color configuration
fd -e js -e ts "tailwind.config" --exec cat {}

Length of output: 18554

web/core/components/issues/issue-modal/form.tsx (2)

516-516: LGTM: Pi theme integration

The addition of the bg-pi-50 class aligns with the PR objective of updating the Pi color theme.


516-519: LGTM: Modal height fix implementation

The dynamic height calculation using ResizeObserver effectively addresses the de-duplication modal height issue. The implementation:

  • Dynamically adjusts to form height changes
  • Provides a sensible fallback height
  • Uses proper React refs for DOM measurements
web/styles/globals.css (1)

123-135: Verify the color accessibility contrast ratios.

The pi theme introduces new colors that are used across different themes. Ensure that these colors maintain sufficient contrast ratios for accessibility when used for text or UI elements.

Also applies to: 145-157, 259-271

Comment on lines +104 to +116

/* pi */
--color-pi-50: var(--color-background-90);
--color-pi-100: var(--color-background-90);
--color-pi-200: var(--color-primary-200);
--color-pi-300: var(--color-primary-200);
--color-pi-400: var(--color-primary-200);
--color-pi-500: var(--color-primary-200);
--color-pi-600: 151, 150, 246;
--color-pi-700: var(--color-primary-100);
--color-pi-800: 57, 56, 149;
--color-pi-900: 30, 29, 78;
--color-pi-950: 14, 14, 37;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Reduce code duplication in pi theme color definitions.

The pi theme color definitions are identical across three different contexts (root, light theme, and dark theme). This violates the DRY principle and makes maintenance more challenging.

Consider moving the common pi theme colors to the shared theme section where other common properties are defined (around line 320 where [data-theme="light"], [data-theme="dark"], [data-theme="light-contrast"], [data-theme="dark-contrast"] are grouped). This would make the code more maintainable and reduce the risk of inconsistencies when updating colors.

 [data-theme="light"],
 [data-theme="dark"],
 [data-theme="light-contrast"],
 [data-theme="dark-contrast"] {
   /* existing common properties */
+  
+  /* pi theme colors */
+  --color-pi-50: var(--color-background-90);
+  --color-pi-100: var(--color-background-90);
+  --color-pi-200: var(--color-primary-200);
+  --color-pi-300: var(--color-primary-200);
+  --color-pi-400: var(--color-primary-200);
+  --color-pi-500: var(--color-primary-200);
+  --color-pi-600: 151, 150, 246;
+  --color-pi-700: var(--color-primary-100);
+  --color-pi-800: 57, 56, 149;
+  --color-pi-900: 30, 29, 78;
+  --color-pi-950: 14, 14, 37;
 }

Also applies to: 126-138, 229-240

Comment on lines +145 to +157

/* pi */
--color-pi-50: var(--color-background-90);
--color-pi-100: var(--color-background-90);
--color-pi-200: var(--color-primary-200);
--color-pi-300: var(--color-primary-200);
--color-pi-400: var(--color-primary-200);
--color-pi-500: var(--color-primary-200);
--color-pi-600: 151, 150, 246;
--color-pi-700: var(--color-primary-100);
--color-pi-800: 57, 56, 149;
--color-pi-900: 30, 29, 78;
--color-pi-950: 14, 14, 37;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ensure theme color consistency across contexts.

The pi theme colors are duplicated across different theme contexts (light/dark). This could lead to maintenance issues if colors need to be updated. Consider:

  1. Using CSS custom properties defined in the :root selector
  2. Only overriding specific colors that need to change between themes

Refactor the theme-specific sections to only include overrides:

[data-theme="light"],
[data-theme="light-contrast"] {
  /* Only include pi colors that differ from root */
-    --color-pi-50: var(--color-background-90);
-    --color-pi-100: var(--color-background-90);
-    /* ... remove duplicated colors ... */
}

[data-theme="dark"],
[data-theme="dark-contrast"] {
  /* Only include pi colors that differ from root */
-    --color-pi-50: var(--color-background-90);
-    --color-pi-100: var(--color-background-90);
-    /* ... remove duplicated colors ... */
}

Also applies to: 259-271

@pushya22 pushya22 merged commit db8c4f9 into preview Nov 11, 2024
@pushya22 pushya22 deleted the chore-pi-colors branch November 11, 2024 14:23
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.

4 participants