Skip to content

Commit b3dc9b0

Browse files
committed
add SfTooltip
1 parent 5cdc562 commit b3dc9b0

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Slot, component$, useSignal } from '@builder.io/qwik';
2+
import { SfTooltipProps } from './types';
3+
4+
export const SfTooltip = component$<SfTooltipProps>(
5+
({ children, label, class: _class, style, showArrow, ...tooltipOptions }) => {
6+
const isOpen = useSignal(false);
7+
// TODO
8+
// const { isOpen, getTriggerProps, getTooltipProps, getArrowProps } = useTooltip(tooltipOptions);
9+
10+
return (
11+
<span /*{...getTriggerProps({ _class, style })}*/ data-testid="tooltip">
12+
<Slot />
13+
{label && isOpen && (
14+
<div
15+
// {...getTooltipProps({
16+
role="tooltip"
17+
class="bg-black px-2 py-1.5 rounded-md text-white text-xs w-max max-w-[360px] drop-shadow"
18+
// })}
19+
>
20+
{label}
21+
{showArrow && <span class="bg-black rotate-45" /*{...getArrowProps({ class: 'bg-black rotate-45' })}*/ />}
22+
</div>
23+
)}
24+
</span>
25+
);
26+
},
27+
);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './types';
2+
3+
export { SfTooltip } from './SfTooltip';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { QwikIntrinsicElements } from '@builder.io/qwik';
2+
3+
export type SfTooltipProps = QwikIntrinsicElements['span'] & {
4+
class?: string;
5+
label: string;
6+
showArrow?: boolean;
7+
};

0 commit comments

Comments
 (0)