-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e535b8
commit cfc1d61
Showing
7 changed files
with
227 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { StoryObj, Meta } from '@storybook/react'; | ||
import { | ||
Box, | ||
Tooltip, | ||
TooltipProps, | ||
TooltipProvider, | ||
} from '@br-ignite-ui/react'; | ||
import { StoryFnReactReturnType } from '@storybook/react/dist/ts3.9/client/preview/types'; | ||
|
||
export default { | ||
title: 'Data display/Tooltip', | ||
component: Tooltip, | ||
args: { | ||
triggerComponent: <button>tooltip</button>, | ||
children: 'Disponível', | ||
}, | ||
decorators: [ | ||
(Story: () => StoryFnReactReturnType) => { | ||
return ( | ||
<Box | ||
css={{ | ||
height: '$20', | ||
width: '$20', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '$gray200', | ||
}} | ||
> | ||
<TooltipProvider>{Story()}</TooltipProvider> | ||
</Box> | ||
); | ||
}, | ||
], | ||
} as Meta<TooltipProps>; | ||
|
||
export const Primary: StoryObj<TooltipProps> = { | ||
args: { | ||
arrow: 'top', | ||
}, | ||
}; | ||
|
||
export const NoArrow: StoryObj<TooltipProps> = {}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as Tooltip from '@radix-ui/react-tooltip'; | ||
|
||
import { styled } from '../../styles'; | ||
|
||
export const TooltipContent = styled(Tooltip.Content, { | ||
backgroundColor: '$gray900', | ||
padding: '$3 $4', | ||
borderRadius: '$sm', | ||
color: '$gray100', | ||
fontFamily: '$default', | ||
fontWeight: '$medium', | ||
fontSize: '$sm', | ||
minHeight: 44, | ||
boxSizing: 'border-box', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Provider, Trigger, Arrow, Root } from '@radix-ui/react-tooltip'; | ||
import { ComponentProps } from '@stitches/react'; | ||
import { ReactNode } from 'react'; | ||
import { TooltipContent } from './style'; | ||
|
||
function Tooltip({ | ||
open, | ||
defaultOpen, | ||
onOpenChange, | ||
arrow, | ||
children, | ||
triggerComponent, | ||
...props | ||
}: TooltipProps) { | ||
return ( | ||
<Root> | ||
<Trigger asChild>{triggerComponent}</Trigger> | ||
|
||
<TooltipContent side={arrow} {...props}> | ||
{children} | ||
{!!arrow && <Arrow />} | ||
</TooltipContent> | ||
</Root> | ||
); | ||
} | ||
|
||
export interface TooltipProps extends ComponentProps<typeof TooltipContent> { | ||
children: ReactNode | string; | ||
triggerComponent: ReactNode; | ||
open?: boolean; | ||
defaultOpen?: boolean; | ||
onOpenChange?: (open: boolean) => void; | ||
arrow?: 'top' | 'bottom' | 'left' | 'right'; | ||
} | ||
|
||
export { Tooltip, Provider as TooltipProvider }; |
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