From bfcbb2b20194f896cae5a695f23a57a546d96037 Mon Sep 17 00:00:00 2001 From: Peter Zimon Date: Thu, 1 Jun 2023 18:54:11 +0200 Subject: [PATCH] Added global image upload component (AdminX) refs. https://github.com/TryGhost/Team/issues/3318 --- .../src/admin-x-ds/assets/icons/trash.svg | 1 + .../src/admin-x-ds/global/FileUpload.tsx | 6 ++- .../admin-x-ds/global/ImageUpload.stories.tsx | 51 +++++++++++++++++++ .../src/admin-x-ds/global/ImageUpload.tsx | 50 ++++++++++++++++++ .../src/admin-x-ds/global/Select.tsx | 2 +- .../src/admin-x-ds/global/TextArea.tsx | 2 +- .../src/admin-x-ds/global/TextField.tsx | 8 +-- .../components/settings/general/Twitter.tsx | 16 ++++++ ghost/admin-x-settings/tailwind.config.cjs | 1 + 9 files changed, 129 insertions(+), 8 deletions(-) create mode 100644 ghost/admin-x-settings/src/admin-x-ds/assets/icons/trash.svg create mode 100644 ghost/admin-x-settings/src/admin-x-ds/global/ImageUpload.stories.tsx create mode 100644 ghost/admin-x-settings/src/admin-x-ds/global/ImageUpload.tsx diff --git a/ghost/admin-x-settings/src/admin-x-ds/assets/icons/trash.svg b/ghost/admin-x-settings/src/admin-x-ds/assets/icons/trash.svg new file mode 100644 index 0000000000..16de1465bb --- /dev/null +++ b/ghost/admin-x-settings/src/admin-x-ds/assets/icons/trash.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/FileUpload.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/FileUpload.tsx index ba8e1b7b1d..9a2c9ddc5d 100644 --- a/ghost/admin-x-settings/src/admin-x-ds/global/FileUpload.tsx +++ b/ghost/admin-x-settings/src/admin-x-ds/global/FileUpload.tsx @@ -8,10 +8,12 @@ export interface FileUploadProps { * Can be any component that has no default onClick eventh handline. E.g. buttons and links won't work */ children?: React.ReactNode; + className?: string; onUpload: (file: File) => void; + style: {} } -const FileUpload: React.FC = ({id, onUpload, children, ...props}) => { +const FileUpload: React.FC = ({id, onUpload, children, style, ...props}) => { const [selectedFile, setSelectedFile] = useState(null); const handleFileChange = (event: ChangeEvent) => { @@ -31,7 +33,7 @@ const FileUpload: React.FC = ({id, onUpload, children, ...props }, [handleFileUpload]); return ( -