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

disable continue creation button and add tooltip for unverified users in draft project page #4896

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

Conversation

maryjaf
Copy link
Collaborator

@maryjaf maryjaf commented Dec 9, 2024

#4895

Summary by CodeRabbit

  • New Features

    • Introduced a tooltip to provide feedback on email verification status when the project creation button is disabled.
    • Enhanced user experience with mouse hover events to toggle tooltip visibility.
  • Bug Fixes

    • Updated the continue project creation button to be disabled when the user's email is not verified.
  • Style

    • Adjusted styling and positioning of the tooltip and button for improved layout and visibility.

Copy link

vercel bot commented Dec 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
giveth-dapps-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 2:04pm

Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

Walkthrough

The changes in this pull request enhance the ProjectIndex component by adding a tooltip feature that informs users about email verification status. A new state variable, isTooltipVisible, manages the tooltip's visibility based on mouse events. The "Continue Creation" button is disabled for users without a verified email, and a tooltip appears when the button is hovered over. Minor layout and styling adjustments ensure the tooltip is correctly positioned. These modifications aim to improve user experience by providing clear feedback regarding email verification requirements.

Changes

File Path Change Summary
src/components/views/project/ProjectIndex.tsx - Added state variable isTooltipVisible to manage tooltip visibility.
- Introduced event handlers handleMouseEnter and handleMouseLeave for tooltip display.
- Updated button to be disabled based on isEmailVerifiedStatus.
- Modified button wrapper to include mouse event handlers.
- Styled tooltip and button for proper positioning and transitions.
- Minor layout adjustments to ensure correct tooltip appearance.

Possibly related issues

Possibly related PRs

  • Fixing statuses for unverified email #4879: This PR modifies the ProjectIndex component to use a new variable isEmailVerifiedStatus, which is directly related to the changes made in the main PR regarding the management of email verification status.
  • Fix button boost behaviour #4885: This PR updates the handleBoostClick function in the ProjectGIVbackToast component to check the isEmailVerifiedStatus, aligning with the changes in the main PR that also involve managing email verification visibility and actions.

Suggested reviewers

  • kkatusic
  • CarlosQ96

Poem

🐇 In the meadow where projects grow,
A tooltip whispers, "Verify, you know!"
With buttons that guide, and styles that shine,
Email checked, your path aligns.
So hop along, don’t delay,
Create your dreams, the rabbit way! 🌼


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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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.

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

🧹 Outside diff range and nitpick comments (1)
src/components/views/project/ProjectIndex.tsx (1)

101-109: Consider memoizing event handlers for better performance

The mouse event handlers could be memoized using useCallback to prevent unnecessary re-renders.

-const handleMouseEnter = () => {
+const handleMouseEnter = useCallback(() => {
	setTooltipVisible(true);
-};
+}, []);

-const handleMouseLeave = () => {
+const handleMouseLeave = useCallback(() => {
	setTooltipVisible(false);
-};
+}, []);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2981622 and cdf2d3c.

📒 Files selected for processing (1)
  • src/components/views/project/ProjectIndex.tsx (3 hunks)

src/components/views/project/ProjectIndex.tsx Outdated Show resolved Hide resolved
Comment on lines 294 to 321

{/* Wrapper for hover events */}
<div
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
style={{
display: 'inline-block', // Ensures it wraps the button
cursor: !isEmailVerifiedStatus
? 'not-allowed'
: 'pointer', // Pointer only when enabled
}}
>
<ContinueCreationButton
label={formatMessage({
id: 'label.continue_creation',
})}
disabled={!isEmailVerifiedStatus} // Button disabled when email is not verified
buttonType='primary'
type='submit'
onClick={() =>
router.push(
idToProjectEdit(
projectData?.id || '',
),
)
}
/>
</div>
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

Enhance button wrapper accessibility

The button wrapper should include proper ARIA attributes to indicate the disabled state and relationship with the tooltip.

 <div
   onMouseEnter={handleMouseEnter}
   onMouseLeave={handleMouseLeave}
+  role="presentation"
   style={{
     display: 'inline-block',
     cursor: !isEmailVerifiedStatus
       ? 'not-allowed'
       : 'pointer',
   }}
 >
   <ContinueCreationButton
     label={formatMessage({
       id: 'label.continue_creation',
     })}
     disabled={!isEmailVerifiedStatus}
     buttonType='primary'
     type='submit'
+    aria-describedby="email-verification-tooltip"
     onClick={() =>
       router.push(
         idToProjectEdit(
           projectData?.id || '',
         ),
       )
     }
   />
 </div>

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

Comment on lines 434 to 463
const ContinueCreationButton = styled(Button)`
align-self: flex-end;
position: relative;
cursor: pointer;
`;

const TooltipWrapper = styled.div`
position: absolute;
bottom: -35px;
left: buttonRect.left + window.scrollX + 10;
transform: translateX(-50%);
background: #1a1a1a;
color: #fff;
padding: 8px 12px;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
opacity: 0;
visibility: hidden;
transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out;
z-index: 1000;

/* Tooltip on hover */
${ContinueCreationButton}:hover & {
opacity: 1;
visibility: visible;
}
`;
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

Fix styled components implementation

There are several issues in the styled components implementation:

  1. Invalid CSS in TooltipWrapper (buttonRect is undefined)
  2. Redundant cursor style in ContinueCreationButton
  3. Complex hover selector that might not work as intended
 const ContinueCreationButton = styled(Button)`
   align-self: flex-end;
   position: relative;
-  cursor: pointer;
 `;

 const TooltipWrapper = styled.div<{ $isVisible: boolean }>`
   position: absolute;
   bottom: -35px;
-  left: buttonRect.left + window.scrollX + 10;
+  left: 50%;
   transform: translateX(-50%);
   background: #1a1a1a;
   color: #fff;
   padding: 8px 12px;
   border-radius: 4px;
   font-size: 12px;
   white-space: nowrap;
-  opacity: 0;
-  visibility: hidden;
+  opacity: ${props => (props.$isVisible ? 1 : 0)};
+  visibility: ${props => (props.$isVisible ? 'visible' : 'hidden')};
   transition:
     opacity 0.2s ease-in-out,
     visibility 0.2s ease-in-out;
   z-index: 1000;

-  /* Tooltip on hover */
-  ${ContinueCreationButton}:hover & {
-    opacity: 1;
-    visibility: visible;
-  }
 `;

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

edit style of tooltip
Copy link
Collaborator

@kkatusic kkatusic left a comment

Choose a reason for hiding this comment

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

LGTM ;) thx @maryjaf

src/components/views/project/ProjectIndex.tsx Outdated Show resolved Hide resolved
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)
src/components/views/project/ProjectIndex.tsx (1)

101-109: Enhance state management implementation

Consider these improvements for better TypeScript support and performance:

  1. Add explicit type for the state
  2. Memoize event handlers
-const [isTooltipVisible, setTooltipVisible] = useState(false);
+const [isTooltipVisible, setTooltipVisible] = useState<boolean>(false);

-const handleMouseEnter = () => {
+const handleMouseEnter = useCallback(() => {
   setTooltipVisible(true);
-};
+}, []);

-const handleMouseLeave = () => {
+const handleMouseLeave = useCallback(() => {
   setTooltipVisible(false);
-};
+}, []);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a2bb2b2 and cb1b173.

📒 Files selected for processing (1)
  • src/components/views/project/ProjectIndex.tsx (3 hunks)
🔇 Additional comments (2)
src/components/views/project/ProjectIndex.tsx (2)

270-305: 🛠️ Refactor suggestion

Improve accessibility and component structure

The implementation needs several improvements:

  1. Add ARIA attributes for accessibility
  2. Move styles to styled components
  3. Simplify the component structure
 <Flex
-  $justifyContent='flex-end'
-  style={{ position: 'relative' }}
+  $justifyContent='flex-end'
+  role="group"
+  aria-label="Project creation controls"
 >
-  {!isEmailVerifiedStatus && (
-    <TooltipWrapper
-      isTooltipVisible={isTooltipVisible}
-    >
+  <TooltipWrapper
+    $isVisible={!isEmailVerifiedStatus && isTooltipVisible}
+    role="tooltip"
+    id="email-verification-tooltip"
+  >
       {formatMessage({
         id: 'label.email_tooltip',
       })}
-    </TooltipWrapper>
-  )}
+  </TooltipWrapper>

-  <div
+  <ButtonWrapper
     onMouseEnter={handleMouseEnter}
     onMouseLeave={handleMouseLeave}
   >
     <ContinueCreationButton
       label={formatMessage({
         id: 'label.continue_creation',
       })}
       disabled={!isEmailVerifiedStatus}
       buttonType='primary'
       type='submit'
+      aria-describedby="email-verification-tooltip"
       onClick={() =>
         router.push(
           idToProjectEdit(
             projectData?.id || '',
           ),
         )
       }
     />
-  </div>
+  </ButtonWrapper>
 </Flex>

418-450: ⚠️ Potential issue

Fix critical issues in styled components implementation

There are several critical issues in the styled components:

  1. Invalid CSS using undefined buttonRect variable
  2. Incorrect prop destructuring in template literals
  3. Invalid hover selector implementation
 const ContinueCreationButton = styled(Button)`
   align-self: flex-end;
   position: relative;
-  cursor: pointer;
 `;

 interface TooltipWrapperProps {
-  isTooltipVisible: boolean;
+  $isVisible: boolean;
   top?: string;
   left?: string;
 }

 const TooltipWrapper = styled.div<TooltipWrapperProps>`
-  visibility: ${isTooltipVisible => (isTooltipVisible ? 'visible' : 'hidden')};
-  opacity: ${({ isTooltipVisible }) => (isTooltipVisible ? 1 : 0)};
+  visibility: ${({ $isVisible }) => ($isVisible ? 'visible' : 'hidden')};
+  opacity: ${({ $isVisible }) => ($isVisible ? 1 : 0)};
   position: absolute;
   bottom: -35px;
-  left: buttonRect.left + window.scrollX + 10;
+  left: 50%;
   transform: translateX(-50%);
   background: #1a1a1a;
   color: #fff;
   padding: 8px 12px;
   border-radius: 4px;
   font-size: 12px;
   white-space: nowrap;
-  transition: 'opacity 0.2s ease';
+  transition: opacity 0.2s ease;
   z-index: 1000;
-  /* Tooltip on hover */
-  ${ContinueCreationButton}:hover & {
-    opacity: 1;
-    visibility: visible;
-    display: 'inline-block';
-    cursor: !isEmailVerifiedStatus ? 'not-allowed' : 'pointer'
-  }
 `;

+const ButtonWrapper = styled.div<{ disabled?: boolean }>`
+  display: inline-block;
+  cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
+`;

Likely invalid or redundant comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Code Review/PR
Development

Successfully merging this pull request may close these issues.

2 participants