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

add tooltip to button #377

Merged
merged 11 commits into from
Jan 5, 2023
Merged

add tooltip to button #377

merged 11 commits into from
Jan 5, 2023

Conversation

vipineth
Copy link
Contributor

@vipineth vipineth commented Dec 5, 2022

[x] Add tooltip to swapbox button for Pool Exceeded
[x] Add tooltip for invalid liquidation price.
[x] Refactor Tooltip and TooltipWithPortal to tsx


@netlify
Copy link

netlify bot commented Dec 5, 2022

Deploy Preview for superb-tarsier-e2aa29 ready!

Name Link
🔨 Latest commit 18fdfc8
🔍 Latest deploy log https://app.netlify.com/sites/superb-tarsier-e2aa29/deploys/63b12f1f16080a00098a9540
😎 Deploy Preview https://deploy-preview-377--superb-tarsier-e2aa29.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Dec 5, 2022

Deploy Preview for vigilant-albattani-df38ec ready!

Name Link
🔨 Latest commit 18fdfc8
🔍 Latest deploy log https://app.netlify.com/sites/vigilant-albattani-df38ec/deploys/63b12f1fe677780008415771
😎 Deploy Preview https://deploy-preview-377--vigilant-albattani-df38ec.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@cloudflare-pages
Copy link

cloudflare-pages bot commented Dec 5, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 18fdfc8
Status: ✅  Deploy successful!
Preview URL: https://ecae812c.gmx-interface.pages.dev
Branch Preview URL: https://tooltip-to-button.gmx-interface.pages.dev

View logs

@@ -461,6 +463,35 @@ export default function PositionEditor(props) {
[DEPOSIT]: t`Deposit`,
[WITHDRAW]: t`Withdraw`,
};
const ERROR_TOOLTIP_MSG = {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Should we move this to ./constants too?
  2. Can there be a case where there is an error code that is not in the config? Maybe we need to define a default message for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Other messages can need access to token or position info. Like in the case of SwapBox here (
    const ERROR_TOOLTIP_MSG = {
    ). So I think we can let it be here for now. LMK you thoughts.
  2. I have updated the condition which is responsible for rendering the Tooltip

@@ -0,0 +1,11 @@
export enum ErrorCodes {
Copy link
Contributor

Choose a reason for hiding this comment

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

We recently discussed with G, enums should be called in the singular for consistency: ErrorCodes -> ErrorCode

You can also capitalize field names - ErrorCodes.Buffer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Updated

invalidLiqPrice = "INVALID_LIQ_PRICE",
}

export enum ErrorTypes {
Copy link
Contributor

Choose a reason for hiding this comment

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

For me personally ErrorType sounds like the type of the error and not how we show it

I would call it ErrorDisplayType - but that's as you like it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

if (intervalCloseRef.current) {
clearInterval(intervalCloseRef.current);
intervalCloseRef.current = null;
}
if (!intervalOpenRef.current) {
intervalOpenRef.current = setTimeout(() => {
intervalOpenRef.current = window.setTimeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm why we need window here?

if typescript shows an error here it's strange because in other places we use just setTimeout (see lib/sleep.ts)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference is assigning to a variable with type null | number. I will update type.

className?: string;
disableHandleStyle?: boolean;
handleClassName?: string;
onDisabled?: boolean;
Copy link
Contributor

@divhead divhead Dec 29, 2022

Choose a reason for hiding this comment

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

  1. mm, onDisabled sounds like an event handler callback

Not sure properly naming here, maybe isHandlerDisabled/disablePointerEvents?

  1. I think comment should be here instead of Wrapper, it would be clearer for user of Tooltip component
    // For onMouseLeave to work on disabled button mouseleave don't trigger on disabled inputs and button react-component/tooltip#18 (comment)

  2. I'm not sure we need a Wrapper component with so little functionality, Wrapper sounds like something global, not just a specific rare case handler. Maybe leaving a conditional div or className event is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

@vipineth vipineth merged commit c3705de into master Jan 5, 2023
@vipineth vipineth deleted the tooltip-to-button branch January 5, 2023 11:35
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.

None yet

2 participants