Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
chore(react): improve tooltip story
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Nov 17, 2021
1 parent 0489c78 commit 71b0c15
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
47 changes: 43 additions & 4 deletions packages/react/src/components/message/Tooltip/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,54 @@
import React from "react";
import { StoryTemplate } from "src/components/helpers";

import Text from "../../asorted/Text";
import FlexBox from "../../layout/Flex";
import TooltipComponent, { Props } from "./index";

const description = `
### Tooltips display informative text when users hover over an element.
This component is based on [tippyjs](https://atomiks.github.io/tippyjs/) which is powerful library.
Please check [the documentation](https://github.com/atomiks/tippyjs-react#-props) for the full props list and usage.
## Usage
\`\`\`js
import { Tooltip } from "@ledgerhq/react-ui"
\`\`\`
Wrap some jsx that will make the tooltip visible on mouse over.<br/>
_**Note:** this jsx will automatically be wrapped inside a \`span\` element if the ref cannot be forwarded. \
See [here](https://github.com/atomiks/tippyjs-react#component-children) for a detailed explanation._
To set the tooltip inner contents, use the \`content\` prop.
\`\`\`js
<Tooltip content="Hello!" {...props}>
<div>Hover me</div>
</Tooltip>
\`\`\`
## Sandbox
Placement, style and content can be customized using props as demonstrated in the following example.
`;

export default {
title: "Messages/Tooltip",
component: TooltipComponent,
parameters: {
docs: {
description: {
component: description,
},
},
},
argTypes: {
content: { type: "string", defaultValue: "Hello World!" },
visible: { type: "boolean" },
visible: { options: [true, false, undefined] },
disabled: { type: "boolean" },
placement: {
control: { type: "radio" },
Expand All @@ -34,10 +73,10 @@ export default {
},
};

export const Tooltip = (args: Props): JSX.Element => (
<FlexBox alignItems="center" justifyContent="center" style={{ height: "100vh" }}>
export const Tooltip: StoryTemplate<Props> = (args) => (
<FlexBox alignItems="center" justifyContent="center">
<TooltipComponent {...args}>
<div style={{ padding: "5px" }}>
<div style={{ margin: "50px" }}>
<Text
as="div"
fontWeight="semiBold"
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/components/message/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ type Placement =

// Add more props later on if needed.
// See https://atomiks.github.io/tippyjs/v6/all-props for the full list.
export type Props = TippyProps & {
/* The preferred placement of the tippy. */
export interface Props extends TippyProps {
/** The preferred placement of the tippy. */
placement?: Placement;
};
}

// Tippyjs need the ref to be forwarded to the DOM element wrapping the children.
// This component has been created to add a wrapping span and use its ref when needed.
Expand Down

2 comments on commit 71b0c15

@vercel
Copy link

@vercel vercel bot commented on 71b0c15 Nov 17, 2021

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

ledger-live-ui-native – ./packages/native

ledger-live-ui-native-ledgerhq.vercel.app
ledger-live-ui-native-git-main-ledgerhq.vercel.app
ledger-live-ui-native.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 71b0c15 Nov 17, 2021

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

ledger-live-ui-react – ./packages/react

ledger-live-ui-react-ledgerhq.vercel.app
ledger-live-ui-react.vercel.app
ledger-live-ui-react-git-main-ledgerhq.vercel.app

Please sign in to comment.