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

feat: poc for center align and toolbar shadow #37264

Closed
wants to merge 4 commits into from

Conversation

albinAppsmith
Copy link
Collaborator

@albinAppsmith albinAppsmith commented Nov 6, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags=""

🔍 Cypress test results

Warning

Tests have not run on the HEAD ac8daad yet


Fri, 08 Nov 2024 11:50:31 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a dynamic box-shadow effect on the toolbar based on scroll position for improved visual feedback.
    • Enhanced layout and accessibility of the UQIEditorForm component.
  • Style

    • Adjusted padding and alignment properties in the PluginActionForm and UQIEditorForm components for better visual spacing and layout.
    • Updated CSS styles for the Zone component to allow for more flexible and dynamic layouts.
    • Improved styling and layout of form information text with new properties for better handling of width and overflow behavior.

Copy link
Contributor

coderabbitai bot commented Nov 6, 2024

Walkthrough

The pull request introduces several modifications across multiple components: Toolbar, PluginActionForm, UQIEditorForm, and related CSS files. The Toolbar component now includes a useEffect hook to manage the box-shadow style based on the scroll position of a specific element. The PluginActionForm and UQIEditorForm components have updated their JSX structures to adjust padding and alignment properties, enhancing their layout without altering functionality. CSS changes focus on improving flexibility and responsiveness in component styling.

Changes

File Change Summary
app/client/src/IDE/Structure/Toolbar.tsx Added useEffect hook to manage box-shadow based on scroll position; cleaned up event listener.
app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx Updated Flex component's padding from p="spaces-4" to p="spaces-4" and pt="spaces-0".
app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx Modified Flex component to include alignItems="center" and id="uqi-editor-form-content".
app/client/src/PluginActionEditor/components/PluginActionForm/components/ActionForm/Zone/styles.module.css Adjusted styles for layout flexibility, removed fixed dimensions and margins from several classes.
app/client/src/components/editorComponents/form/fields/StyledFormComponents.tsx Updated StyledFormInfo with new CSS properties and added className prop to FormInfoText.

Possibly related PRs

Suggested labels

UI Improvement, IDE Product, Task, IDE Pod, ok-to-test

Suggested reviewers

  • hetunandu
  • ankitakinger

🎉 In the toolbar where shadows play,
A scroll brings style to brighten the day.
Padding adjusted, components align,
UQIEditor shines, all looking fine!
With hooks and flex, the layout's a charm,
Enhancements abound, keeping users warm! 🌟


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.

@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

@github-actions github-actions bot added the Enhancement New feature or request label Nov 6, 2024
Copy link

github-actions bot commented Nov 6, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11706195006.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 37264.
recreate: .

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ec246fd and bc5ca39.

📒 Files selected for processing (3)
  • app/client/src/IDE/Structure/Toolbar.tsx (1 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx (1 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx
🔇 Additional comments (3)
app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx (1)

25-31: LGTM! The Flex component changes implement the required features.

The center alignment and scroll container setup look correct. The id addition properly supports the toolbar shadow feature.

Let's verify the scroll behavior integration:

✅ Verification successful

The scroll behavior integration is properly implemented

The Toolbar component in IDE/Structure/Toolbar.tsx correctly uses the uqi-editor-form-content id to detect scrolling and apply shadow effects. The implementation includes proper event cleanup.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the scroll behavior integration between UQIEditorForm and Toolbar
# Expected: Find usage of the uqi-editor-form-content id in Toolbar component for scroll detection

# Search for scroll-related logic using the form content id
rg -A 5 "uqi-editor-form-content.*scroll" app/client/src/

Length of output: 59


Script:

#!/bin/bash
# Let's try a broader search to find any usage of this id
rg -A 5 "uqi-editor-form-content" app/client/src/

# Also search for any Toolbar component that might use scroll detection
ast-grep --pattern 'const Toolbar = $_ => {
  $$$
}'

# Search for scroll-related hooks or utilities that might be used
rg -A 5 "useScroll|handleScroll" app/client/src/

Length of output: 8358

app/client/src/IDE/Structure/Toolbar.tsx (2)

1-1: LGTM: Import changes are correct


38-45: LGTM: Styling changes look good

The transition and positioning styles are well implemented. However, verify that the sticky positioning works correctly with all parent containers.

✅ Verification successful

Let me analyze the sticky positioning concern by checking the parent containers of the Toolbar component.


Let me check how this toolbar is being used in the parent container and if there are any potential positioning conflicts.


Let me check the parent container structure and scroll behavior implementation.


Sticky positioning implementation is correct and safe

The toolbar's sticky positioning works correctly with its parent container:

  • Parent uqi-editor-form-content has overflowY="scroll" which creates a proper scroll context
  • Toolbar's scroll detection and box-shadow transition are properly implemented
  • No conflicting position styles in the parent containers
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any potential CSS positioning conflicts in parent containers
rg -l "position:\s*(relative|absolute|fixed)" $(fd -e tsx -e css)

Length of output: 165497


Script:

#!/bin/bash
# Check for any parent containers that might affect sticky positioning
rg -A 5 -B 5 "action-toolbar" app/client/src/IDE/Structure/Toolbar.tsx

Length of output: 697


Script:

#!/bin/bash
# Check how the toolbar is being used in parent containers
rg -A 10 "import.*Toolbar" app/client/src/IDE/Structure/

Length of output: 58


Script:

#!/bin/bash
# Check for the parent container and scroll handling
rg -A 15 "uqi-editor-form-content" app/client/src/

Length of output: 3141

Comment on lines +9 to +31
useEffect(function detectScrollbar() {
const ele = document.getElementById("uqi-editor-form-content");
const toolbar = document.getElementById("action-toolbar");

const handleScroll = function () {
if (ele && ele.scrollTop > 0) {
toolbar?.style.setProperty(
"box-shadow",
"0 4px 6px rgba(0, 0, 0, 0.1)",
);
} else {
toolbar?.style.setProperty("box-shadow", "none");
}
};

if (ele) {
ele.addEventListener("scroll", handleScroll);
}

return function cleanup() {
ele?.removeEventListener("scroll", handleScroll);
};
}, []);
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

Consider using refs instead of direct DOM queries

The current implementation has several areas for improvement:

  1. Replace getElementById with React refs for better reliability and type safety
  2. Extract the shadow value to a constant
  3. Add null checks for better error handling
+ const toolbarRef = useRef<HTMLDivElement>(null);
+ const contentRef = useRef<HTMLDivElement>(null);
+ const TOOLBAR_SHADOW = "0 4px 6px rgba(0, 0, 0, 0.1)";

  useEffect(function detectScrollbar() {
-   const ele = document.getElementById("uqi-editor-form-content");
-   const toolbar = document.getElementById("action-toolbar");
+   const ele = contentRef.current;
+   const toolbar = toolbarRef.current;

    const handleScroll = function () {
-     if (ele && ele.scrollTop > 0) {
-       toolbar?.style.setProperty(
-         "box-shadow",
-         "0 4px 6px rgba(0, 0, 0, 0.1)",
-       );
+     if (ele?.scrollTop > 0 && toolbar) {
+       toolbar.style.setProperty("box-shadow", TOOLBAR_SHADOW);
      } else {
-       toolbar?.style.setProperty("box-shadow", "none");
+       toolbar?.style.setProperty("box-shadow", "none");
      }
    };

Committable suggestion skipped: line range outside the PR's diff.

Copy link

github-actions bot commented Nov 6, 2024

Deploy-Preview-URL: https://ce-37264.dp.appsmith.com

@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

Copy link

github-actions bot commented Nov 7, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11718347481.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 37264.
recreate: .

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 and nitpick comments (1)
app/client/src/IDE/Structure/Toolbar.tsx (1)

41-46: Enhance styling robustness

The styling changes look good, but consider these improvements:

  1. Make the transition more specific to avoid unnecessary animations
  2. Ensure the z-index creates proper stacking context
  style={{
-   transition: "box-shadow 0.3s ease",
+   transition: "box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1)",
    position: "sticky",
    top: 0,
+   backgroundColor: "inherit", // Ensure background is solid for sticky positioning
  }}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bc5ca39 and 89ff506.

📒 Files selected for processing (1)
  • app/client/src/IDE/Structure/Toolbar.tsx (1 hunks)
🔇 Additional comments (1)
app/client/src/IDE/Structure/Toolbar.tsx (1)

9-31: 🛠️ Refactor suggestion

Add error boundaries and extract constants

While the scroll detection logic works, there are a few improvements needed:

  1. Add null checks before accessing ele and toolbar
  2. Extract the shadow value to a constant for reusability
  3. Consider adding error logging for cases where elements aren't found
+ const TOOLBAR_SHADOW = "0 4px 6px rgba(0, 0, 0, 0.1)";
+ 
  useEffect(function detectScrollbar() {
    const ele = document.getElementById("uqi-editor-form-content");
    const toolbar = document.getElementById("action-toolbar");
+   
+   if (!ele || !toolbar) {
+     console.warn("Required elements not found for toolbar shadow effect");
+     return;
+   }

    const handleScroll = function () {
      if (ele && ele.scrollTop > 0) {
-       toolbar?.style.setProperty(
-         "box-shadow",
-         "0 4px 6px rgba(0, 0, 0, 0.1)",
-       );
+       toolbar.style.setProperty("box-shadow", TOOLBAR_SHADOW);
      } else {
-       toolbar?.style.setProperty("box-shadow", "none");
+       toolbar.style.setProperty("box-shadow", "none");
      }
    };

Note: Previous review's suggestion about using refs instead of DOM queries is still applicable.

Copy link

github-actions bot commented Nov 7, 2024

Deploy-Preview-URL: https://ce-37264.dp.appsmith.com

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 and nitpick comments (2)
app/client/src/PluginActionEditor/components/PluginActionForm/components/ActionForm/Zone/styles.module.css (1)

71-71: Consider creating a tracking issue for the DB config update.

The comment indicates this is temporary pending DB configuration updates for Twilio and Airtable integrations.

Would you like me to help create a GitHub issue to track the pending DB configuration updates for Section and Zone in Twilio and Airtable integrations?

app/client/src/components/editorComponents/form/fields/StyledFormComponents.tsx (1)

35-37: Consider using less aggressive word breaking.

The break-word: break-all property might break words at unnatural points. Consider using word-break: break-word or overflow-wrap: break-word for better readability.

  max-width: 270px;
  overflow: hidden;
- break-word: break-all;
+ overflow-wrap: break-word;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 89ff506 and ac8daad.

📒 Files selected for processing (2)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/ActionForm/Zone/styles.module.css (1 hunks)
  • app/client/src/components/editorComponents/form/fields/StyledFormComponents.tsx (2 hunks)
🔇 Additional comments (2)
app/client/src/PluginActionEditor/components/PluginActionForm/components/ActionForm/Zone/styles.module.css (1)

71-74: LGTM, but note this is a temporary solution.

The change aligns with the file's pattern of removing fixed dimensions for more flexible layouts.

Let's verify if there are any existing issues tracking this temporary change:

app/client/src/components/editorComponents/form/fields/StyledFormComponents.tsx (1)

183-185: LGTM!

The addition of the className prop allows for external styling customization while maintaining the base styled-component styles.

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant