From 02233cb3139be9a3084cee595d7aa67678e907f1 Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Mon, 12 Feb 2024 12:18:38 +0700 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20theming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/dropzone.tsx | 9 +- .../src/components/file-tree/file-icon.tsx | 11 +- .../src/components/file-tree/index.tsx | 14 +- .../src/components/file-tree/title.tsx | 2 +- .../src/components/playground.tsx | 12 +- .../src/hooks/use-dotlottie.tsx | 2 +- apps/dotlottie-playground/src/store/types.ts | 2 +- packages/common/package.json | 4 +- packages/common/src/dotlottie-loader.ts | 8 +- packages/common/src/dotlottie-player.ts | 13 +- packages/common/src/dotlottie-styler.ts | 24 --- packages/react-player/README.md | 2 +- pnpm-lock.yaml | 148 ++++-------------- 13 files changed, 64 insertions(+), 187 deletions(-) delete mode 100644 packages/common/src/dotlottie-styler.ts diff --git a/apps/dotlottie-playground/src/components/dropzone.tsx b/apps/dotlottie-playground/src/components/dropzone.tsx index 3f858a21..1905b1a3 100644 --- a/apps/dotlottie-playground/src/components/dropzone.tsx +++ b/apps/dotlottie-playground/src/components/dropzone.tsx @@ -7,7 +7,7 @@ import ReactDropzone, { type DropzoneState, type FileError, type FileRejection, import { toast } from 'react-toastify'; interface DropzoneProps { - accept: 'lottie' | 'json' | 'lss'; + accept: 'lottie' | 'json'; children: (state: DropzoneState) => JSX.Element; multiple?: boolean; noClick?: boolean; @@ -40,13 +40,6 @@ export const Dropzone: React.FC = ({ accept, children, multiple, }; } - if (accept === 'lss' && !fileName.endsWith('.lss')) { - return { - message: 'Invalid .lss', - code: ErrorCode.FileInvalidType, - }; - } - return null; }, []); diff --git a/apps/dotlottie-playground/src/components/file-tree/file-icon.tsx b/apps/dotlottie-playground/src/components/file-tree/file-icon.tsx index b40484f8..60ad53fe 100644 --- a/apps/dotlottie-playground/src/components/file-tree/file-icon.tsx +++ b/apps/dotlottie-playground/src/components/file-tree/file-icon.tsx @@ -3,14 +3,15 @@ */ import React from 'react'; -import { BsFiletypeJson, BsFiletypeCss } from 'react-icons/bs'; +import { BsFiletypeJson } from 'react-icons/bs'; import type { SupportedFileTypes } from '.'; export const FileIcon = ({ type }: { type: SupportedFileTypes }): JSX.Element => { - if (type === 'lss') { - return ; - } else { - return ; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (type !== 'json') { + return <>; } + + return ; }; diff --git a/apps/dotlottie-playground/src/components/file-tree/index.tsx b/apps/dotlottie-playground/src/components/file-tree/index.tsx index f778b92e..fbaf6419 100644 --- a/apps/dotlottie-playground/src/components/file-tree/index.tsx +++ b/apps/dotlottie-playground/src/components/file-tree/index.tsx @@ -2,7 +2,7 @@ * Copyright 2023 Design Barn Inc. */ -import React, { useCallback, useMemo, useState } from 'react'; +import React, { useCallback, useState } from 'react'; import { useKey } from 'react-use'; import { useDotLottie } from '../../hooks/use-dotlottie'; @@ -14,7 +14,7 @@ import { AddNew } from './add-new'; import { EditableItem } from './editable-item'; import { Title } from './title'; -const FILE_TYPES = ['json', 'lss'] as const; +const FILE_TYPES = ['json'] as const; export type SupportedFileTypes = typeof FILE_TYPES[number]; @@ -54,8 +54,6 @@ export const FileTree: React.FC = ({ [onClick, title], ); - const fileExtention = useMemo(() => (title.toLowerCase() === 'themes' ? 'lss' : 'json'), [title]); - const handleRemove = useCallback( (fileName: string) => { onRemove?.(title, fileName); @@ -79,10 +77,10 @@ export const FileTree: React.FC = ({ const handleAddNew = useCallback( (value: string) => { - onAddNew?.(title, `${value}.${fileExtention}`); + onAddNew?.(title, `${value}.json`); setDisplayAdd(false); }, - [onAddNew, title, fileExtention], + [onAddNew, title], ); const handleRename = useCallback( @@ -121,7 +119,7 @@ export const FileTree: React.FC = ({ buttons={title === 'Animations' ? ['upload'] : ['upload', 'add']} />
- + {(state): JSX.Element => { return (
@@ -157,7 +155,7 @@ export const FileTree: React.FC = ({ {displayAdd && (
  • - +
  • )} diff --git a/apps/dotlottie-playground/src/components/file-tree/title.tsx b/apps/dotlottie-playground/src/components/file-tree/title.tsx index cdaed463..50126a34 100644 --- a/apps/dotlottie-playground/src/components/file-tree/title.tsx +++ b/apps/dotlottie-playground/src/components/file-tree/title.tsx @@ -57,7 +57,7 @@ export const Title: React.FC = ({ buttons, onClickAdd, onUpload, tit case 'upload': buttonsToDisplay.push( - + {({ getInputProps, getRootProps }): JSX.Element => (