Skip to content

Commit

Permalink
Apply Prettier & Add eslint-exceptions where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
aliciusschroeder committed Oct 19, 2024
1 parent 58e24c5 commit c1a61e0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 37 deletions.
11 changes: 7 additions & 4 deletions src/components/App/ImageGeneration/ImageGeneration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ const ImageGeneration = () => {
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5 }}
>
<div className="grid gap-4 mt-4">
<div className="mt-4 grid gap-4">
{generatedImages.length > 0 && (
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
{generatedImages.slice().reverse().map((image, index) => (
<ImageCard key={index} generatedImage={image} />
))}
{generatedImages
.slice()
.reverse()
.map((image, index) => (
<ImageCard key={index} generatedImage={image} />
))}
</div>
)}
</div>
Expand Down
23 changes: 11 additions & 12 deletions src/components/ImageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ExpandIcon,
InfoIcon,
LoaderIcon,
Trash2Icon
Trash2Icon,
} from "lucide-react";
import { useState } from "react";

Expand All @@ -28,9 +28,9 @@ export default function ImageCard({
generatedImage,
}: Readonly<ImageCardProperties>) {
const [showRevisedPrompt, setShowRevisedPrompt] = useState(false);
const onDownloadIcon = () => { };
const onFullscreen = () => { };
const onDelete = () => { };
const onDownloadIcon = () => {};
const onFullscreen = () => {};
const onDelete = () => {};

return (
<Card className="w-full max-w-md overflow-hidden transition-shadow hover:shadow-lg">
Expand All @@ -39,23 +39,22 @@ export default function ImageCard({
{generatedImage.state !== "error" && (
<img
src={
generatedImage.state === "pending" ?
placeHolderSvgBase64 :
generatedImage.image
generatedImage.state === "pending"
? placeHolderSvgBase64
: generatedImage.image
}
alt={generatedImage.usedOptions.prompt}
className="h-64 w-full object-cover"
/>)}
/>
)}
{generatedImage.state === "pending" && (
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center w-full h-full text-foreground text-lg font-bold">
<div className="absolute left-1/2 top-1/2 flex h-full w-full -translate-x-1/2 -translate-y-1/2 items-center justify-center text-lg font-bold text-foreground">
<LoaderIcon className="h-14 w-14 animate-spin text-gray-500" />
</div>
)}
</div>
{generatedImage.state === "error" && (
<p className="text-red-500">
{generatedImage.error}
</p>
<p className="text-red-500">{generatedImage.error}</p>
)}

{!generatedImage.locallySaved && (
Expand Down
7 changes: 7 additions & 0 deletions src/components/ui/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const SelectTrigger = forwardRef<
JSX.IntrinsicElements["button"]
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Trigger
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={ref as any}
className={cn(
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
Expand All @@ -40,6 +41,7 @@ const SelectScrollUpButton = forwardRef<
JSX.IntrinsicElements["div"]
>(({ className, ...props }, ref) => (
<SelectPrimitive.ScrollUpButton
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={ref as any}
className={cn(
"flex cursor-default items-center justify-center py-1",
Expand All @@ -57,6 +59,7 @@ const SelectScrollDownButton = forwardRef<
JSX.IntrinsicElements["div"]
>(({ className, ...props }, ref) => (
<SelectPrimitive.ScrollDownButton
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={ref as any}
className={cn(
"flex cursor-default items-center justify-center py-1",
Expand All @@ -78,6 +81,7 @@ const SelectContent = forwardRef<
>(({ className, children, position = "popper", ...props }, ref) => (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={ref as any}
className={cn(
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
Expand Down Expand Up @@ -107,6 +111,7 @@ SelectContent.displayName = SelectPrimitive.Content.displayName;
const SelectLabel = forwardRef<HTMLDivElement, JSX.IntrinsicElements["div"]>(
({ className, ...props }, ref) => (
<SelectPrimitive.Label
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={ref as any}
className={cn("px-2 py-1.5 text-sm font-semibold", className)}
{...props}
Expand All @@ -118,6 +123,7 @@ SelectLabel.displayName = SelectPrimitive.Label.displayName;
const SelectItem = forwardRef<HTMLDivElement, JSX.IntrinsicElements["div"]>(
({ className, children, value, disabled, ...props }, ref) => (
<SelectPrimitive.Item
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={ref as any}
className={cn(
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
Expand All @@ -143,6 +149,7 @@ const SelectSeparator = forwardRef<
JSX.IntrinsicElements["div"]
>(({ className, ...props }, ref) => (
<SelectPrimitive.Separator
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={ref as any}
className={cn("-mx-1 my-1 h-px bg-muted", className)}
{...props}
Expand Down
38 changes: 19 additions & 19 deletions src/config/imageGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ export const aspectRatios: {
description: string;
Icon: typeof SquareIcon;
}[] = [
{
value: "square",
label: "Square",
description: "1024x1024",
Icon: SquareIcon,
},
{
value: "horizontal",
label: "Horizontal",
description: "1792×1024",
Icon: RectangleHorizontalIcon,
},
{
value: "vertical",
label: "Vertical",
description: "1024×1792",
Icon: RectangleVerticalIcon,
},
];
{
value: "square",
label: "Square",
description: "1024x1024",
Icon: SquareIcon,
},
{
value: "horizontal",
label: "Horizontal",
description: "1792×1024",
Icon: RectangleHorizontalIcon,
},
{
value: "vertical",
label: "Vertical",
description: "1024×1792",
Icon: RectangleVerticalIcon,
},
];

export const generationCost = {
hd: {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useImageGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export function useImageGeneration() {
locallySaved: true,
},
});
} catch (error: any) {
} catch (error) {
dispatch({
type: "UPDATE_IMAGE",
id: image.id,
data: {
state: "error",
error: error.message,
error: (error as Error).message,
},
});
} finally {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/api/fetchImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ export const fetchImage = async (

switch (company) {
case "OpenAI":
// eslint-disable-next-line no-case-declarations
const openai = new OpenAI({ apiKey, dangerouslyAllowBrowser: true });

// eslint-disable-next-line no-case-declarations
const result = await openai.images.generate({
model: model,
prompt: options.prompt,
Expand Down

0 comments on commit c1a61e0

Please sign in to comment.