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

update packages and cleaned up types #21

Merged
merged 1 commit into from
May 13, 2024
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
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
"lint": "next lint"
},
"dependencies": {
"@google/generative-ai": "^0.2.0",
"@google/generative-ai": "^0.11.1",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.0.2",
"ai": "^2.2.33",
"ai": "^3.1.5",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"html-escaper": "^3.0.3",
"lucide-react": "^0.297.0",
"next": "^14.1.0",
"lucide-react": "^0.378.0",
"next": "^14.2.3",
"next-themes": "^0.2.1",
"react": "^18",
"react-dom": "^18",
Expand All @@ -46,7 +46,7 @@
"eslint": "^8",
"eslint-config-next": "14.0.4",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"tailwindcss": "^3.4.3",
"typescript": "^5"
}
}
2 changes: 1 addition & 1 deletion src/app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Button } from "@/components/ui/button";
import React from "react";

export default function Error({ error, reset }: any) {
export default function ErrorPage({ error, reset }: any) {
React.useEffect(() => {
console.log("logging error:", error);
}, [error]);
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const metadata: Metadata = {
export default function RootLayout({
children,
}: {
children: React.ReactNode;
readonly children: React.ReactNode;
}) {
return (
<html lang="en" suppressHydrationWarning>
Expand Down
24 changes: 14 additions & 10 deletions src/components/control/SafetySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,27 @@ import {
import { Label } from "@/components/ui/label";
import { Slider } from "@/components/ui/slider";

const safetyLevels = ["none", "few", "some", "most"] as const;

type SafetyLevel = (typeof safetyLevels)[number];

const getSafetyLevel = (value: number): SafetyLevel => {
return safetyLevels[value] || "none";
};

interface SafetySelectorProps {
label: string;
value: number;
onValueChange: (newValue: number[]) => void;
readonly label: string;
readonly value: number;
readonly onValueChange: (newValue: number[]) => void;
}

export function SafetySelector({
label,
value,
onValueChange,
}: SafetySelectorProps) {
const safetyLevel = getSafetyLevel(value);

return (
<div className="grid gap-2 pt-2">
<HoverCard openDelay={200}>
Expand All @@ -29,13 +39,7 @@ export function SafetySelector({
<div className="flex items-center justify-between">
<Label htmlFor={label}>{label}</Label>
<span className="w-12 rounded-md border border-transparent px-2 py-0.5 text-right text-sm text-muted-foreground hover:border-border">
{value === 0
? "none"
: value === 1
? "few"
: value === 2
? "some"
: "most"}
{safetyLevel}
</span>
</div>
<Slider
Expand Down
12 changes: 6 additions & 6 deletions src/components/control/SettingsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { Label } from "@/components/ui/label";
import { Slider } from "@/components/ui/slider";

interface SettingsSelectorProps {
label: string;
hoverText: string;
step: number;
max: number;
value: number;
onValueChange: (newValue: number[]) => void;
readonly label: string;
readonly hoverText: string;
readonly step: number;
readonly max: number;
readonly value: number;
readonly onValueChange: (newValue: number[]) => void;
}

export function SettingsSelector({
Expand Down
31 changes: 17 additions & 14 deletions src/providers/ControlContext/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
// providers/ControlContext.tsx
import { createContext, useState, useContext, ReactNode } from "react";
import { createContext, useState, useContext, ReactNode, useMemo } from "react";

import { MediaData, SafetySettings, GeneralSettings } from "@/types";

Expand Down Expand Up @@ -84,20 +84,23 @@ export const ControlProvider = ({ children }: { children: ReactNode }) => {
});
};

const contextValue = useMemo(
() => ({
selectedModel,
mediaDataList,
handleMediaUpload,
removeMediaData,
generalSettings,
handleGeneralSettingsChange,
safetySettings,
handleModelChange,
handleSafetyChange,
}),
[selectedModel, mediaDataList, generalSettings, safetySettings]
);

return (
<ControlContext.Provider
value={{
selectedModel,
mediaDataList,
handleMediaUpload,
removeMediaData,
generalSettings,
handleGeneralSettingsChange,
safetySettings,
handleModelChange,
handleSafetyChange,
}}
>
<ControlContext.Provider value={contextValue}>
{children}
</ControlContext.Provider>
);
Expand Down
Loading
Loading