Skip to content

Commit

Permalink
[sparkle] Add tooltip on header (#8667)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdraier authored Nov 15, 2024
1 parent c8e72ae commit 0cc7a94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sparkle/src/components/BarHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";

import { Tooltip } from "@sparkle/components/Tooltip";
import {
ArrowUpOnSquareIcon,
ChevronLeftIcon,
Expand All @@ -12,13 +13,15 @@ import { Button } from "./Button";

interface BarHeaderProps {
title: string;
tooltip?: string;
leftActions?: React.ReactNode;
rightActions?: React.ReactNode;
className?: string;
}

export function BarHeader({
title,
tooltip,
leftActions,
rightActions,
className = "",
Expand All @@ -39,7 +42,17 @@ export function BarHeader({
)}
>
{leftActions && <div className={buttonBarClasses}>{leftActions}</div>}
<div className={titleClasses}>{title}</div>
<div className={titleClasses}>
{tooltip ? (
<Tooltip
tooltipTriggerAsChild
trigger={<span>{title}</span>}
label={tooltip}
></Tooltip>
) : (
title
)}
</div>
{rightActions && <div className={buttonBarClasses}>{rightActions}</div>}
</div>
);
Expand Down
1 change: 1 addition & 0 deletions sparkle/src/stories/BarHeader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export const BasicBarHeaderConversation = () => (
<div className="s-mt-16 s-h-full s-w-full">
<BarHeader
title="Knowledge Base"
tooltip="This is a tooltip"
rightActions={<BarHeader.ButtonBar variant="conversation" />}
/>
<div className="s-flex s-flex-col s-gap-16 s-overflow-auto">
Expand Down

0 comments on commit 0cc7a94

Please sign in to comment.