Skip to content

Commit

Permalink
Fix rad-ui#577: [New Feature] Added Multiple direction support for To…
Browse files Browse the repository at this point in the history
…oltip rad-ui#577
  • Loading branch information
anihar2003 committed Dec 2, 2024
1 parent 08cc93b commit 507cd68
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
14 changes: 13 additions & 1 deletion src/components/tools/Popper/Popper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ export type PopperProps = {
customRootClass?: string;
activationStrategy?: 'hover';
className?: string;
placement?: 'top' | 'bottom' | 'bottom-start'; // TODO: fix
placement?:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'top-start'
| 'top-end'
| 'bottom-start'
| 'bottom-end'
| 'left-start'
| 'left-end'
| 'right-start'
| 'right-end';
children?: React.ReactNode; // TODO: fix
open?: boolean;
hoverDelay?: number;
Expand Down
31 changes: 26 additions & 5 deletions src/components/ui/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
import React from 'react';

import Popper from '~/components/tools/Popper/Popper';

const COMPONENT_NAME = 'Tooltip';

type TooltipProps = {
children: React.ReactNode;
label: string;
placement?:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'top-start'
| 'top-end'
| 'bottom-start'
| 'bottom-end'
| 'left-start'
| 'left-end'
| 'right-start'
| 'right-end';
[key: string]: any;
};

const Tooltip = ({ children, label, ...props }:TooltipProps) => {
return <div>
<Popper popperName={COMPONENT_NAME} pop={'hello'} {...props}>{children}</Popper>
</div>;
const Tooltip = ({ children, label="hello", placement = 'top', ...props }: TooltipProps) => {
return (
<div>
<Popper
popperName={COMPONENT_NAME}
pop={label}
placement={placement}
{...props}
>
{children}
</Popper>
</div>
);
};

export default Tooltip;
2 changes: 1 addition & 1 deletion src/components/ui/Tooltip/stories/Tooltip.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
component: Tooltip,
render: (args) => <SandboxEditor>
<ScrollPlayground>
<Tooltip className="text-gray-1000" label="This is a tooltip">
<Tooltip className="text-gray-1000" label="This is a tooltip" placement='left'>
Hello, hover me!
</Tooltip>
</ScrollPlayground>
Expand Down

0 comments on commit 507cd68

Please sign in to comment.