Skip to content

Commit

Permalink
GUI: increase prettier print width (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasavila00 committed Mar 21, 2024
1 parent 4f91a7f commit 63ed3e3
Show file tree
Hide file tree
Showing 49 changed files with 149 additions and 507 deletions.
5 changes: 1 addition & 4 deletions gui/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"@typescript-eslint/no-unused-vars": "off",
"no-console": "error",
},
Expand Down
3 changes: 2 additions & 1 deletion gui/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"trailingComma": "all"
"trailingComma": "all",
"printWidth": 100
}
6 changes: 1 addition & 5 deletions gui/src/components/ui/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { cn } from "../../../lib/utils";

export const DropdownCategoryTitle = ({
children,
}: {
children: React.ReactNode;
}) => {
export const DropdownCategoryTitle = ({ children }: { children: React.ReactNode }) => {
return (
<div className="text-[.65rem] font-semibold mb-1 uppercase text-neutral-500 dark:text-neutral-400 px-1.5">
{children}
Expand Down
7 changes: 1 addition & 6 deletions gui/src/components/ui/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ export const Icon = memo(({ name, className, strokeWidth }: IconProps) => {
return null;
}

return (
<IconComponent
className={cn("w-4 h-4", className)}
strokeWidth={strokeWidth || 2.5}
/>
);
return <IconComponent className={cn("w-4 h-4", className)} strokeWidth={strokeWidth || 2.5} />;
});

Icon.displayName = "Icon";
5 changes: 1 addition & 4 deletions gui/src/components/ui/Surface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ export type SurfaceProps = HTMLProps<HTMLDivElement> & {
};

export const Surface = forwardRef<HTMLDivElement, SurfaceProps>(
(
{ children, className, withShadow = true, withBorder = true, ...props },
ref,
) => {
({ children, className, withShadow = true, withBorder = true, ...props }, ref) => {
const surfaceClass = cn(
className,
"bg-white rounded-lg dark:bg-black",
Expand Down
25 changes: 3 additions & 22 deletions gui/src/components/ui/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ export type ToolbarWrapperProps = {
} & HTMLProps<HTMLDivElement>;

export const ToolbarWrapper = forwardRef<HTMLDivElement, ToolbarWrapperProps>(
(
{
shouldShowContent = true,
children,
isVertical = false,
className,
...rest
},
ref,
) => {
({ shouldShowContent = true, children, isVertical = false, className, ...rest }, ref) => {
const toolbarClassName = cn(
"text-black inline-flex h-full leading-none gap-0.5",
isVertical ? "flex-col p-2" : "flex-row p-1 items-center",
Expand Down Expand Up @@ -56,12 +47,7 @@ export const ToolbarDivider = forwardRef<HTMLDivElement, ToolbarDividerProps>(
},
);

type ButtonVariant =
| "primary"
| "secondary"
| "tertiary"
| "quaternary"
| "ghost";
type ButtonVariant = "primary" | "secondary" | "tertiary" | "quaternary" | "ghost";
type ButtonSize = "medium" | "small" | "icon" | "iconSmall";

type ButtonProps = {
Expand Down Expand Up @@ -137,12 +123,7 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
);

return (
<button
ref={ref}
disabled={disabled}
className={buttonClassName}
{...rest}
>
<button ref={ref} disabled={disabled} className={buttonClassName} {...rest}>
{children}
</button>
);
Expand Down
8 changes: 2 additions & 6 deletions gui/src/components/ui/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { useCallback } from "react";
import { TippyProps, TooltipProps } from "./types";

const isMac =
typeof window !== "undefined"
? navigator.platform.toUpperCase().indexOf("MAC") >= 0
: false;
typeof window !== "undefined" ? navigator.platform.toUpperCase().indexOf("MAC") >= 0 : false;

const ShortcutKey = ({ children }: { children: string }): JSX.Element => {
const className =
Expand Down Expand Up @@ -43,9 +41,7 @@ export const Tooltip = ({
data-reference-hidden={attrs["data-reference-hidden"]}
data-escaped={attrs["data-escaped"]}
>
{title && (
<span className="text-xs font-medium text-neutral-500">{title}</span>
)}
{title && <span className="text-xs font-medium text-neutral-500">{title}</span>}
{shortcut && (
<span className="flex items-center gap-0.5">
{shortcut.map((shortcutKey) => (
Expand Down
5 changes: 1 addition & 4 deletions gui/src/components/ui/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const Avatar = React.forwardRef<
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
className,
)}
className={cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className)}
{...props}
/>
));
Expand Down
15 changes: 4 additions & 11 deletions gui/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ const buttonVariants = cva(
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
outline:
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
secondary:
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
Expand Down Expand Up @@ -44,11 +41,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
<Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
);
},
);
Expand Down
28 changes: 5 additions & 23 deletions gui/src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,14 @@ const DialogContent = React.forwardRef<
));
DialogContent.displayName = DialogPrimitive.Content.displayName;

const DialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-1.5 text-center sm:text-left",
className,
)}
{...props}
/>
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
);
DialogHeader.displayName = "DialogHeader";

const DialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className,
)}
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
{...props}
/>
);
Expand All @@ -84,10 +69,7 @@ const DialogTitle = React.forwardRef<
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className,
)}
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
{...props}
/>
));
Expand Down
25 changes: 6 additions & 19 deletions gui/src/components/ui/dropdown-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
<ChevronRight className="ml-auto h-4 w-4" />
</DropdownMenuPrimitive.SubTrigger>
));
DropdownMenuSubTrigger.displayName =
DropdownMenuPrimitive.SubTrigger.displayName;
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;

const DropdownMenuSubContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
Expand All @@ -50,8 +49,7 @@ const DropdownMenuSubContent = React.forwardRef<
{...props}
/>
));
DropdownMenuSubContent.displayName =
DropdownMenuPrimitive.SubContent.displayName;
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;

const DropdownMenuContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
Expand Down Expand Up @@ -110,8 +108,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
{children}
</DropdownMenuPrimitive.CheckboxItem>
));
DropdownMenuCheckboxItem.displayName =
DropdownMenuPrimitive.CheckboxItem.displayName;
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;

const DropdownMenuRadioItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
Expand Down Expand Up @@ -143,11 +140,7 @@ const DropdownMenuLabel = React.forwardRef<
>(({ className, inset, ...props }, ref) => (
<DropdownMenuPrimitive.Label
ref={ref}
className={cn(
"px-2 py-1.5 text-sm font-semibold",
inset && "pl-8",
className,
)}
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
{...props}
/>
));
Expand All @@ -165,15 +158,9 @@ const DropdownMenuSeparator = React.forwardRef<
));
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;

const DropdownMenuShortcut = ({
className,
...props
}: React.HTMLAttributes<HTMLSpanElement>) => {
const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
return (
<span
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
{...props}
/>
<span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />
);
};
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
Expand Down
48 changes: 16 additions & 32 deletions gui/src/components/ui/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ type FormFieldContextValue<
name: TName;
};

const FormFieldContext = React.createContext<FormFieldContextValue>(
{} as FormFieldContextValue,
);
const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);

const FormField = <
TFieldValues extends FieldValues = FieldValues,
Expand Down Expand Up @@ -66,22 +64,19 @@ type FormItemContextValue = {
id: string;
};

const FormItemContext = React.createContext<FormItemContextValue>(
{} as FormItemContextValue,
);
const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);

const FormItem = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
const id = React.useId();
const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
const id = React.useId();

return (
<FormItemContext.Provider value={{ id }}>
<div ref={ref} className={cn("space-y-2", className)} {...props} />
</FormItemContext.Provider>
);
});
return (
<FormItemContext.Provider value={{ id }}>
<div ref={ref} className={cn("space-y-2", className)} {...props} />
</FormItemContext.Provider>
);
},
);
FormItem.displayName = "FormItem";

const FormLabel = React.forwardRef<
Expand All @@ -105,18 +100,13 @@ const FormControl = React.forwardRef<
React.ElementRef<typeof Slot>,
React.ComponentPropsWithoutRef<typeof Slot>
>(({ ...props }, ref) => {
const { error, formItemId, formDescriptionId, formMessageId } =
useFormField();
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();

return (
<Slot
ref={ref}
id={formItemId}
aria-describedby={
!error
? `${formDescriptionId}`
: `${formDescriptionId} ${formMessageId}`
}
aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
aria-invalid={!!error}
{...props}
/>
Expand All @@ -129,11 +119,7 @@ const UnconnectedFormDescription = React.forwardRef<
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => {
return (
<p
ref={ref}
className={cn("text-[0.8rem] text-muted-foreground", className)}
{...props}
/>
<p ref={ref} className={cn("text-[0.8rem] text-muted-foreground", className)} {...props} />
);
});

Expand All @@ -143,9 +129,7 @@ const FormDescription = React.forwardRef<
>(({ className, ...props }, ref) => {
const { formDescriptionId } = useFormField();

return (
<UnconnectedFormDescription ref={ref} id={formDescriptionId} {...props} />
);
return <UnconnectedFormDescription ref={ref} id={formDescriptionId} {...props} />;
});
FormDescription.displayName = "FormDescription";

Expand Down
3 changes: 1 addition & 2 deletions gui/src/components/ui/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from "react";

import { cn } from "../../lib/utils";

export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}

const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
Expand Down
9 changes: 2 additions & 7 deletions gui/src/components/ui/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ const labelVariants = cva(

const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
{...props}
/>
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
));
Label.displayName = LabelPrimitive.Root.displayName;

Expand Down
Loading

0 comments on commit 63ed3e3

Please sign in to comment.