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

Refactor: Shinkai UI lib #248

Merged
merged 15 commits into from
May 15, 2024
8 changes: 3 additions & 5 deletions apps/shinkai-app/src/components/ui/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { IonAvatar } from '@ionic/react';

import { cn } from '../../theme/lib/utils';

import { cn } from '@shinkai_network/shinkai-ui/utils';
export default function Avatar({
url,
className,
Expand All @@ -11,11 +9,11 @@ export default function Avatar({
}) {
return (
<IonAvatar
className={cn('bg-white w-8 h-8 [--border-radius:7777px]', className)}
className={cn('h-8 w-8 bg-white [--border-radius:7777px]', className)}
>
<img
alt=""
className="w-full h-full"
className="h-full w-full"
src={url ?? 'https://ionicframework.com/docs/img/demos/avatar.svg'}
/>
</IonAvatar>
Expand Down
7 changes: 3 additions & 4 deletions apps/shinkai-app/src/components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import './Button.css';

import { IonButton } from '@ionic/react';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { Loader2 } from 'lucide-react';
import React from 'react';

import { cn } from '../../theme/lib/utils';

export default function Button({
onClick,
disabled,
Expand All @@ -28,14 +27,14 @@ export default function Button({
className={cn(
'ion-button-custom w-full',
'variant-' + variant,
className
className,
)}
disabled={disabled || isLoading}
onClick={onClick}
shape={'round'}
type={type}
>
{isLoading ? <Loader2 className="h-4 w-4 animate-spin mr-2" /> : null}
{isLoading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
{children}
</IonButton>
);
Expand Down
7 changes: 3 additions & 4 deletions apps/shinkai-app/src/components/ui/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import './Input.css';

import { InputCustomEvent } from '@ionic/core/dist/types/components/input/input-interface';
import { InputChangeEventDetail, IonInput } from '@ionic/react';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import type { Ref } from 'react';
import React from 'react';

import { cn } from '../../theme/lib/utils';

type InputProps = {
onChange: (event: InputCustomEvent<InputChangeEventDetail>) => void;
value: string;
Expand All @@ -18,7 +17,7 @@ type InputProps = {
const Input = React.forwardRef(
(
{ onChange, value, label, className }: InputProps,
ref: Ref<HTMLIonInputElement>
ref: Ref<HTMLIonInputElement>,
) => {
return (
<IonInput
Expand All @@ -34,7 +33,7 @@ const Input = React.forwardRef(
value={value}
/>
);
}
},
);

Input.displayName = 'Input';
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-app/src/pages/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useSendMessageWithFilesToInbox } from '@shinkai_network/shinkai-node-st
import { ChatConversationMessage } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/types';
import { useGetChatConversationWithPagination } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/useGetChatConversationWithPagination';
import { groupMessagesByDate } from '@shinkai_network/shinkai-node-state/lib/utils/date';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import MarkdownPreview from '@uiw/react-markdown-preview';
import { cameraOutline } from 'ionicons/icons';
import { send } from 'ionicons/icons';
Expand All @@ -34,7 +35,6 @@ import {
IonHeaderCustom,
} from '../components/ui/Layout';
import { useAuth } from '../store/auth';
import { cn } from '../theme/lib/utils';
import {
extractReceiverShinkaiName,
getOtherPersonIdentity,
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-app/src/pages/JobChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import { useSendMessageWithFilesToInbox } from '@shinkai_network/shinkai-node-state/lib/mutations/sendMesssageWithFilesToInbox/useSendMessageWithFilesToInbox';
import { ChatConversationMessage } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/types';
import { useGetChatConversationWithPagination } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/useGetChatConversationWithPagination';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import MarkdownPreview from '@uiw/react-markdown-preview';
import { send } from 'ionicons/icons';
import { cameraOutline } from 'ionicons/icons';
Expand All @@ -39,7 +40,6 @@
IonHeaderCustom,
} from '../components/ui/Layout';
import { useAuth } from '../store/auth';
import { cn } from '../theme/lib/utils';

const groupMessagesByDate = (messages: ChatConversationMessage[]) => {
const groupedMessages: Record<string, ChatConversationMessage[]> = {};
Expand Down Expand Up @@ -185,7 +185,7 @@
profile_identity_sk: auth.profile_identity_sk,
});
}
}, [

Check warning on line 188 in apps/shinkai-app/src/pages/JobChat.tsx

View workflow job for this annotation

GitHub Actions / health-checks

React Hook useCallback has a missing dependency: 'auth.node_address'. Either include it or remove the dependency array
inputMessage,
auth.shinkai_identity,
auth.profile,
Expand Down
Binary file not shown.
Binary file removed apps/shinkai-desktop/public/fonts/newake.otf
Binary file not shown.
4 changes: 2 additions & 2 deletions apps/shinkai-desktop/src/components/chat/message.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ShinkaiMessage } from '@shinkai_network/shinkai-message-ts/models';
import { MessageSchemaType } from '@shinkai_network/shinkai-message-ts/models';
import { extractErrorPropertyOrContent } from '@shinkai_network/shinkai-message-ts/utils/shinkai_message_handler';
import { extractErrorPropertyOrContent } from '@shinkai_network/shinkai-message-ts/utils';
import { ChatConversationMessage } from '@shinkai_network/shinkai-node-state/lib/queries/getChatConversation/types';
import {
Avatar,
Expand All @@ -9,9 +9,9 @@ import {
CopyToClipboardIcon,
MarkdownPreview,
} from '@shinkai_network/shinkai-ui';
import { cn } from '@shinkai_network/shinkai-ui/utils';

import icon from '../../assets/icon.png';
import { cn } from '../../lib/utils';
import { FileList } from '../../pages/create-job';

export const getMessageFilesInbox = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
Button,
Input,
ScrollArea,
SharedFolderIcon,
Sheet,
SheetContent,
SheetDescription,
Expand All @@ -21,6 +20,7 @@ import {
ToggleGroup,
ToggleGroupItem,
} from '@shinkai_network/shinkai-ui';
import { SharedFolderIcon } from '@shinkai_network/shinkai-ui/assets';
import { useInView } from 'framer-motion';
import { Maximize2, Minimize2, SearchIcon, XIcon } from 'lucide-react';
import { Tree, TreeExpandedKeysType } from 'primereact/tree';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '@shinkai_network/shinkai-node-state/lib/queries/getVRPathSimplified/types';
import { useGetVRPathSimplified } from '@shinkai_network/shinkai-node-state/lib/queries/getVRPathSimplified/useGetVRPathSimplified';
import {
AddNewFolderIcon,
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
Expand All @@ -19,18 +18,21 @@ import {
ContextMenuContent,
ContextMenuItem,
ContextMenuTrigger,
CreateAIIcon,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
FileEmptyStateIcon,
FileTypeIcon,
GenerateDocIcon,
Input,
ScrollArea,
Separator,
} from '@shinkai_network/shinkai-ui';
import {
AddNewFolderIcon,
CreateAIIcon,
FileEmptyStateIcon,
FileTypeIcon,
GenerateDocIcon,
} from '@shinkai_network/shinkai-ui/assets';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { motion } from 'framer-motion';
import { ChevronRight, PlusIcon, SearchIcon, XIcon } from 'lucide-react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
DirectoryTypeIcon,
ScrollArea,
} from '@shinkai_network/shinkai-ui';
import { DirectoryTypeIcon } from '@shinkai_network/shinkai-ui/assets';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { ChevronRight } from 'lucide-react';
import React, { createContext, useContext, useRef } from 'react';
Expand Down Expand Up @@ -165,7 +165,7 @@ export const FolderSelectionList = () => {
key={idx}
/>
))}
{VRFiles?.child_folders.map((folder, index: number) => {
{VRFiles?.child_folders.map((folder) => {
return (
<button
className={cn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
ScrollArea,
SharedFolderIcon,
} from '@shinkai_network/shinkai-ui';
import { SharedFolderIcon } from '@shinkai_network/shinkai-ui/assets';
import { formatDateToUSLocaleString } from '@shinkai_network/shinkai-ui/helpers';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { Link2Off } from 'lucide-react';
import React from 'react';

import { formatDateToUSLocaleString } from '../../../helpers/date';
import { useAuth } from '../../../store/auth';
import { useVectorFsStore, VectorFSLayout } from '../context/vector-fs-context';
import { VectorFsFolderAction } from './vector-fs-drawer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useGetVRSeachSimplified } from '@shinkai_network/shinkai-node-state/lib
import {
Badge,
Button,
FileTypeIcon,
Form,
FormField,
Input,
Expand All @@ -18,6 +17,7 @@ import {
SheetHeader,
SheetTitle,
} from '@shinkai_network/shinkai-ui';
import { FileTypeIcon } from '@shinkai_network/shinkai-ui/assets';
import { SearchIcon, XIcon } from 'lucide-react';
import { Checkbox } from 'primereact/checkbox';
import { Tree, TreeCheckboxSelectionKeys } from 'primereact/tree';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { VRFolder } from '@shinkai_network/shinkai-node-state/lib/queries/getVRP
import {
buttonVariants,
Checkbox,
DirectoryTypeIcon,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
SharedFolderIcon,
} from '@shinkai_network/shinkai-ui';
import {
DirectoryTypeIcon,
SharedFolderIcon,
} from '@shinkai_network/shinkai-ui/assets';
import { formatDateToUSLocaleString } from '@shinkai_network/shinkai-ui/helpers';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import {
CopyIcon,
Expand All @@ -22,7 +25,6 @@ import {
} from 'lucide-react';
import React from 'react';

import { formatDateToUSLocaleString } from '../../../helpers/date';
import { useVectorFsStore, VectorFSLayout } from '../context/vector-fs-context';
import { VectorFsFolderAction } from './vector-fs-drawer';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { useCreateVRFolder } from '@shinkai_network/shinkai-node-state/lib/mutat
import { useUploadVRFiles } from '@shinkai_network/shinkai-node-state/lib/mutations/uploadVRFiles/useUploadVRFiles';
import {
Button,
DirectoryTypeIcon,
FileItem,
FileTypeIcon,
FileUploader,
Form,
FormControl,
Expand All @@ -17,6 +15,10 @@ import {
SheetTitle,
TextField,
} from '@shinkai_network/shinkai-ui';
import {
DirectoryTypeIcon,
FileTypeIcon,
} from '@shinkai_network/shinkai-ui/assets';
import { useEffect } from 'react';
import { useForm } from 'react-hook-form';
import { useLocation } from 'react-router-dom';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { useDownloadVRFile } from '@shinkai_network/shinkai-node-state/lib/mutat
import {
Badge,
Button,
FileTypeIcon,
SheetFooter,
SheetHeader,
SheetTitle,
} from '@shinkai_network/shinkai-ui';
import { FileTypeIcon } from '@shinkai_network/shinkai-ui/assets';
import {
formatDateToLocaleStringWithTime,
formatDateToUSLocaleString,
} from '@shinkai_network/shinkai-ui/helpers';
import { dialog, fs } from '@tauri-apps/api';
import { BaseDirectory } from '@tauri-apps/api/fs';
import { partial } from 'filesize';
import { LockIcon } from 'lucide-react';
import React from 'react';

import {
formatDateToLocaleStringWithTime,
formatDateToUSLocaleString,
} from '../../../helpers/date';
import { useAuth } from '../../../store/auth';
import { useVectorFsStore } from '../context/vector-fs-context';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
FileTypeIcon,
} from '@shinkai_network/shinkai-ui';
import { FileTypeIcon } from '@shinkai_network/shinkai-ui/assets';
import { formatDateToUSLocaleString } from '@shinkai_network/shinkai-ui/helpers';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { partial } from 'filesize';
import { CopyIcon, FileInputIcon, TrashIcon } from 'lucide-react';
import React from 'react';

import { formatDateToUSLocaleString } from '../../../helpers/date';
import { useVectorFsStore, VectorFSLayout } from '../context/vector-fs-context';
import { VectorFsItemAction } from './vector-fs-drawer';

Expand Down
Loading
Loading