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

💡 [REQUEST] - Generic Tooltip component #551

Open
abdou6666 opened this issue Jan 10, 2025 · 7 comments · May be fixed by #615
Open

💡 [REQUEST] - Generic Tooltip component #551

abdou6666 opened this issue Jan 10, 2025 · 7 comments · May be fixed by #615
Assignees
Labels
good first issue Good for newcomers question Further information is requested SWOC Social Winter of Code 2025

Comments

@abdou6666
Copy link
Member

abdou6666 commented Jan 10, 2025

Start Date

No response

Implementation PR

No response

Reference Issues

No response

Summary

You can inspire from Shadcn/ui implementation and api here
Acceptance criteria:

  • Create a reusable tooltip component that can wrap other components and display a tooltip when hovered. The tooltip's text and behavior should be controlled programmatically through props.
  • Screenshots containing 3 different examples using the created compoenent in our UI demonstrating the correct behaviour

Basic Example

const Tooltip = ({ children, text, position = "top" }) => {
const [visible, setVisible] = useState(false);

return (
<div
className="tooltip-container"
onMouseEnter={() => setVisible(true)}
onMouseLeave={() => setVisible(false)}
>
{children}
{visible && (
<div className={tooltip-box tooltip-${position}}>
{text}

)}

);
};

Drawbacks

Unresolved questions

No response

@abdou6666 abdou6666 added good first issue Good for newcomers question Further information is requested SWOC Social Winter of Code 2025 labels Jan 10, 2025
@TheCoderAdi
Copy link
Contributor

Please assign this issue to me.

@abdou6666
Copy link
Member Author

@TheCoderAdi Done, good luck

@TheCoderAdi
Copy link
Contributor

TheCoderAdi commented Jan 11, 2025

@TheCoderAdi Done, good luck

Hello @abdou6666 ,

I hope you're doing well. I have a quick question regarding the use of tooltips in React.

Would it be appropriate to use @mui/material's Tooltip component for my project, or would it be better to create a custom tooltip from scratch, including the CSS? Here's the approach I'm considering:

import { Tooltip as MuiTooltip } from "@mui/material";
import React, { ReactNode } from "react";

type TooltipProps = {
  children: ReactNode;
  text: string;
  position?:
    | "top"
    | "bottom"
    | "left"
    | "right"
    | "top-start"
    | "top-end"
    | "bottom-start"
    | "bottom-end"
    | "left-start"
    | "left-end"
    | "right-start"
    | "right-end";
};

export const ToolTip: React.FC<TooltipProps> = ({
  children,
  text,
  position = "top",
}) => {
  return (
    <MuiTooltip title={text} placement={position} arrow>
      <div>{children}</div>
    </MuiTooltip>
  );
};

I’d appreciate your thoughts on whether this approach is suitable or if I should consider implementing a custom tooltip solution.

Thank you!

@abdou6666
Copy link
Member Author

@TheCoderAdi Yes, you can use MUI Tooltip. Just make sure it meets the acceptance criteria

@AselPeiris
Copy link

Hi @TheCoderAdi I'd like to take this on if you're busy atm.

FYI @abdou6666

@TheCoderAdi
Copy link
Contributor

Hi @TheCoderAdi I'd like to take this on if you're busy atm.

FYI @abdou6666

Hey , I am working on it , I will push the code by tomorrow.

@TheCoderAdi TheCoderAdi linked a pull request Jan 22, 2025 that will close this issue
6 tasks
@TheCoderAdi
Copy link
Contributor

Hello @abdou6666,

I have submitted the pull request with the recent updates. Please review it at your convenience and let me know if any changes are required.

Looking forward to your feedback.

Best regards,
Aditya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested SWOC Social Winter of Code 2025
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants