forked from raystack/apsara
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tooltip): expose tooltip open property (#42)
* feat(tooltip): expose tooltip open property * feat(tooltip): simplify implementation, added storybook for open by default case * feat(Tooltip): refactor component --------- Co-authored-by: Stewart Jingga <[email protected]>
- Loading branch information
1 parent
2dcbe75
commit d9c511f
Showing
3 changed files
with
66 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
import React from "react"; | ||
import Tooltip, { TooltipProps } from "./Tooltip"; | ||
|
||
import Tooltip from "./Tooltip"; | ||
|
||
export default { | ||
title: "Feedback/Tooltip", | ||
component: Tooltip, | ||
}; | ||
|
||
const Template = (args: TooltipProps) => <Tooltip {...args}>Tooltip</Tooltip>; | ||
export const tooltip = Template.bind({}); | ||
tooltip.args = { | ||
title: "tooltip", | ||
placement: "right", | ||
export const Basic = () => { | ||
return ( | ||
<Tooltip title="This is tooltip content"> | ||
<span>Content Wrapped by Tooltip</span> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export const WithDefaultOpen = () => { | ||
return ( | ||
<Tooltip title="I am open by default" defaultOpen> | ||
<span>Content Wrapped by Tooltip</span> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export const ControlledState = () => { | ||
const [open, setOpen] = React.useState(true); | ||
|
||
return ( | ||
// @ts-ignore | ||
<Tooltip title={( | ||
<span> | ||
This is tooltip content | ||
<span style={{ marginLeft: '8px', cursor: 'pointer'}} onClick={() => setOpen(false)}>X</span> | ||
</span> | ||
)} open={open}> | ||
<span>Content Wrapped by Tooltip</span> | ||
</Tooltip> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters