-
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.
- Loading branch information
1 parent
6330f56
commit f97a20f
Showing
6 changed files
with
94 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
25 changes: 25 additions & 0 deletions
25
frontend/packages/ui/src/components/Tooltip/Tooltip.module.css
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,25 @@ | ||
.content { | ||
z-index: var(--z-index-tooltip); | ||
padding: var(--spacing-1half) var(--spacing-1); | ||
font-size: var(--font-size-1); | ||
color: var(--tooltip-foreground); | ||
background-color: var(--tooltip-background); | ||
border: 1px solid var(--tooltip-border); | ||
border-radius: var(--border-radius-sm); | ||
animation-duration: 150ms; | ||
animation-timing-function: var(--default-timing-function); | ||
} | ||
|
||
.content[data-state='delayed-open'] { | ||
animation-name: fadeIn; | ||
} | ||
|
||
@keyframes fadeIn { | ||
from { | ||
opacity: 0; | ||
} | ||
|
||
to { | ||
opacity: 1; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
frontend/packages/ui/src/components/Tooltip/Tooltip.stories.tsx
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,32 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { | ||
TooltipContent, | ||
TooltipPortal, | ||
TooltipProvider, | ||
TooltipRoot, | ||
TooltipTrigger, | ||
} from './Tooltip' | ||
|
||
const StoryComponent = () => { | ||
return ( | ||
<TooltipProvider> | ||
<TooltipRoot> | ||
<TooltipTrigger asChild> | ||
<span>Hover me</span> | ||
</TooltipTrigger> | ||
<TooltipPortal> | ||
<TooltipContent sideOffset={5}>Add to library</TooltipContent> | ||
</TooltipPortal> | ||
</TooltipRoot> | ||
</TooltipProvider> | ||
) | ||
} | ||
|
||
const meta = { | ||
component: StoryComponent, | ||
} satisfies Meta<typeof StoryComponent> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = {} |
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,31 @@ | ||
/* eslint-disable no-restricted-imports */ | ||
import { | ||
Content, | ||
Portal, | ||
Provider, | ||
Root, | ||
Trigger, | ||
} from '@radix-ui/react-tooltip' | ||
import { | ||
type ComponentProps, | ||
type FC, | ||
type PropsWithChildren, | ||
forwardRef, | ||
} from 'react' | ||
import styles from './Tooltip.module.css' | ||
|
||
export const TooltipContent = forwardRef< | ||
HTMLDivElement, | ||
ComponentProps<typeof Content> | ||
>((props, ref) => { | ||
return <Content {...props} ref={ref} className={styles.content} /> | ||
}) | ||
|
||
TooltipContent.displayName = 'TooltipContent' | ||
|
||
export const TooltipProvider: FC<PropsWithChildren> = ({ children }) => { | ||
return <Provider delayDuration={100}>{children}</Provider> | ||
} | ||
export const TooltipPortal = Portal | ||
export const TooltipRoot = Root | ||
export const TooltipTrigger = Trigger |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './DropdownMenu' | ||
export * from './Tooltip' |