Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltip: rename shortcut to caption and styling fixes #103

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/Tooltip/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const TemplateAlign: StoryFn<typeof TooltipComponent> = () => (
alignItems: "center",
}}
>
<TooltipComponent open={true} align="center" label="Copy" shortcut="⌘ + C">
<TooltipComponent open={true} align="center" label="Copy" sublabel="⌘ + C">
<IconButton>
<UserIcon />
</IconButton>
Expand All @@ -82,7 +82,7 @@ const TemplateAlign: StoryFn<typeof TooltipComponent> = () => (
open={true}
align="start"
label="@bob:example.org"
shortcut="⌘ + C"
sublabel="⌘ + C"
>
<IconButton>
<UserIcon />
Expand All @@ -92,7 +92,7 @@ const TemplateAlign: StoryFn<typeof TooltipComponent> = () => (
open={true}
align="end"
label="@bob:example.org"
shortcut="⌘ + C"
sublabel="⌘ + C"
>
<IconButton>
<UserIcon />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tooltip/Tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Tooltip", () => {
});
it("renders open by default", () => {
const { asFragment } = render(
<Tooltip label="Hello world 👋" shortcut="⌘ + C" open={true}>
<Tooltip label="Hello world 👋" sublabel="⌘ + C" open={true}>
<IconButton>
<svg />
</IconButton>
Expand Down
11 changes: 8 additions & 3 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ type TooltipProps = {
*/
label: string;
/**
* The associated keyboard shortcut
* The tooltip sublabel
*/
sublabel?: string;
/**
* @deprecated replaced by `sublabel`
*/
shortcut?: string;
/**
Expand Down Expand Up @@ -73,6 +77,7 @@ type TooltipProps = {
export const Tooltip = ({
children,
label,
sublabel,
shortcut,
side = "bottom",
align = "center",
Expand All @@ -97,9 +102,9 @@ export const Tooltip = ({
using the text color secondary on a solid dark background.
This is temporary and should only remain until we figure out
the approach to on-solid tokens */}
{shortcut && (
{(sublabel || shortcut) && (
<small className={classNames(styles.shortcut, "cpd-theme-dark")}>
{shortcut}
{sublabel ?? shortcut}
</small>
)}
<Arrow width={10} height={6} className={styles.arrow} />
Expand Down