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

UI fix: revert removed code from button loading/icon states #458

Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ui/admin/app/components/oauth-apps/OAuthAppDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function OAuthAppDetail({
<Button
size="icon"
variant="ghost"
className={cn(className)}
className={cn("mt-0", className)}
>
<SettingsIcon />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion ui/admin/app/components/oauth-apps/OAuthAppTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function OAuthAppTile({
"border-2 border-primary": info.appOverride,
})}
>
<CardHeader className="flex flex-row justify-between pb-2">
<CardHeader className="flex flex-row justify-between items-start pb-2 space-y-0">
<div className="flex flex-wrap gap-2 items-center">
<TypographyH3 className="min-w-fit">
{displayName}
Expand Down
12 changes: 10 additions & 2 deletions ui/admin/app/components/oauth-apps/custom/CustomOAuthAppForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,15 @@ export function CustomOAuthAppForm({
defaultValues,
});

const { isFinalStep, nextLabel, prevLabel, onBack, onNext, disableSubmit } =
getStepInfo(step);
const {
isFinalStep,
nextLabel,
prevLabel,
isLoading,
onBack,
onNext,
disableSubmit,
} = getStepInfo(step);

useEffect(() => {
form.reset(defaultValues);
Expand Down Expand Up @@ -237,6 +244,7 @@ export function CustomOAuthAppForm({
<Button
className="flex-1 w-full"
type="submit"
loading={isLoading}
disabled={disableSubmit}
>
{nextLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function CustomOAuthAppTile({ app }: CustomOAuthAppTileProps) {
size="icon"
className="w-8 h-8 p-0"
disabled={deleteApp.isLoading}
loading={deleteApp.isLoading}
>
<Trash />
</Button>
Expand Down
36 changes: 33 additions & 3 deletions ui/admin/app/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Slot } from "@radix-ui/react-slot";
import { type VariantProps, cva } from "class-variance-authority";
import { Loader2 } from "lucide-react";
import * as React from "react";

import { cn } from "~/lib/utils";
Expand All @@ -24,7 +25,7 @@ const buttonVariants = cva(
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
icon: "h-9 w-9 [&_svg]:size-[1.375rem]",
},
},
defaultVariants: {
Expand All @@ -38,18 +39,47 @@ export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
loading?: boolean;
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
(
{
className,
variant,
size,
asChild = false,
loading = false,
children,
...props
},
ref
) => {
const Comp = asChild ? Slot : "button";

return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
>
{getContent()}
</Comp>
);

function getContent() {
if (size === "icon" && loading)
return <Loader2 className="animate-spin" />;

return loading ? (
<>
<Loader2 className="mr-2 animate-spin" />
{children}
</>
) : (
children
);
}
}
);
Button.displayName = "Button";
Expand Down