Skip to content

Commit f189fc0

Browse files
committed
Tooltip now just 1 prop on the button component
1 parent fe31906 commit f189fc0

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

apps/webapp/app/components/ListPagination.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function NextButton({ cursor }: { cursor?: string }) {
3434
)}
3535
onClick={(e) => !path && e.preventDefault()}
3636
shortcut={{ key: "k" }}
37-
showTooltip
38-
tooltipDescription="Next"
37+
tooltip="Next"
38+
disabled={!path}
3939
>
4040
Next
4141
</LinkButton>
@@ -57,8 +57,8 @@ function PreviousButton({ cursor }: { cursor?: string }) {
5757
)}
5858
onClick={(e) => !path && e.preventDefault()}
5959
shortcut={{ key: "j" }}
60-
showTooltip
61-
tooltipDescription="Previous"
60+
tooltip="Previous"
61+
disabled={!path}
6262
>
6363
Prev
6464
</LinkButton>

apps/webapp/app/components/primitives/Buttons.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Link, LinkProps, NavLink, NavLinkProps } from "@remix-run/react";
2-
import React, { forwardRef, useImperativeHandle, useRef } from "react";
2+
import React, { forwardRef, ReactNode, useImperativeHandle, useRef } from "react";
33
import { ShortcutDefinition, useShortcutKeys } from "~/hooks/useShortcutKeys";
44
import { cn } from "~/utils/cn";
55
import { IconNamesOrString, NamedIcon } from "./NamedIcon";
@@ -173,10 +173,9 @@ export type ButtonContentPropsType = {
173173
textAlignLeft?: boolean;
174174
className?: string;
175175
shortcut?: ShortcutDefinition;
176-
showTooltip?: boolean;
177176
variant: keyof typeof variant;
178177
shortcutPosition?: "before-trailing-icon" | "after-trailing-icon";
179-
tooltipDescription?: string;
178+
tooltip?: ReactNode;
180179
iconSpacing?: string;
181180
};
182181

@@ -191,8 +190,7 @@ export function ButtonContent(props: ButtonContentPropsType) {
191190
fullWidth,
192191
textAlignLeft,
193192
className,
194-
showTooltip,
195-
tooltipDescription,
193+
tooltip,
196194
iconSpacing,
197195
} = props;
198196
const variation = allVariants.variant[props.variant];
@@ -254,7 +252,7 @@ export function ButtonContent(props: ButtonContentPropsType) {
254252
))}
255253

256254
{shortcut &&
257-
!showTooltip &&
255+
!tooltip &&
258256
props.shortcutPosition === "before-trailing-icon" &&
259257
renderShortcutKey()}
260258

@@ -281,20 +279,20 @@ export function ButtonContent(props: ButtonContentPropsType) {
281279
))}
282280

283281
{shortcut &&
284-
!showTooltip &&
282+
!tooltip &&
285283
(!props.shortcutPosition || props.shortcutPosition === "after-trailing-icon") &&
286284
renderShortcutKey()}
287285
</div>
288286
</div>
289287
);
290288

291-
if (shortcut && showTooltip) {
289+
if (tooltip) {
292290
return (
293291
<TooltipProvider>
294292
<Tooltip>
295293
<TooltipTrigger asChild>{buttonContent}</TooltipTrigger>
296294
<TooltipContent className="text-dimmed flex items-center gap-3 py-1.5 pl-2.5 pr-3 text-xs">
297-
{tooltipDescription} {renderShortcutKey()}
295+
{tooltip} {shortcut && renderShortcutKey()}
298296
</TooltipContent>
299297
</Tooltip>
300298
</TooltipProvider>

apps/webapp/app/components/primitives/Pagination.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export function PaginationControls({
2525
variant="minimal/small"
2626
LeadingIcon={ChevronLeftIcon}
2727
shortcut={{ key: "j" }}
28-
showTooltip
29-
tooltipDescription="Previous"
28+
tooltip="Previous"
3029
disabled={currentPage === 1}
3130
className={currentPage > 1 ? "group" : ""}
3231
>
@@ -44,8 +43,7 @@ export function PaginationControls({
4443
variant="minimal/small"
4544
TrailingIcon={ChevronRightIcon}
4645
shortcut={{ key: "k" }}
47-
showTooltip
48-
tooltipDescription="Next"
46+
tooltip="Next"
4947
disabled={currentPage === totalPages}
5048
className={currentPage !== totalPages ? "group" : ""}
5149
>

0 commit comments

Comments
 (0)