mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
audio upload buttin
This commit is contained in:
parent
d676ff88e4
commit
5e9b6e1819
10 changed files with 89 additions and 6 deletions
14
src/components/editors/AudioEditor/index.tsx
Normal file
14
src/components/editors/AudioEditor/index.tsx
Normal file
|
@ -0,0 +1,14 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
import { INode } from '~/redux/types';
|
||||
import path from 'ramda/es/path';
|
||||
|
||||
interface IProps {
|
||||
data: INode;
|
||||
setData: (val: INode) => void;
|
||||
}
|
||||
|
||||
const AudioEditor: FC<IProps> = ({ data, setData }) => {
|
||||
return <div>something!</div>;
|
||||
};
|
||||
|
||||
export { AudioEditor };
|
25
src/components/editors/EditorAudioUploadButton/index.tsx
Normal file
25
src/components/editors/EditorAudioUploadButton/index.tsx
Normal file
|
@ -0,0 +1,25 @@
|
|||
import React, { FC } from 'react';
|
||||
import { EditorUploadButton } from '~/components/editors/EditorUploadButton';
|
||||
import { INode } from '~/redux/types';
|
||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||
|
||||
interface IProps {
|
||||
data: INode;
|
||||
setData: (val: INode) => void;
|
||||
temp: string[];
|
||||
setTemp: (val: string[]) => void;
|
||||
}
|
||||
|
||||
const EditorAudioUploadButton: FC<IProps> = ({ data, setData, temp, setTemp }) => (
|
||||
<EditorUploadButton
|
||||
data={data}
|
||||
setData={setData}
|
||||
temp={temp}
|
||||
setTemp={setTemp}
|
||||
accept="audio/*"
|
||||
icon="audio"
|
||||
type={UPLOAD_TYPES.AUDIO}
|
||||
/>
|
||||
);
|
||||
|
||||
export { EditorAudioUploadButton };
|
|
@ -1,6 +1,7 @@
|
|||
import React, { FC } from 'react';
|
||||
import { EditorUploadButton } from '~/components/editors/EditorUploadButton';
|
||||
import { INode } from '~/redux/types';
|
||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||
|
||||
interface IProps {
|
||||
data: INode;
|
||||
|
@ -17,6 +18,7 @@ const EditorImageUploadButton: FC<IProps> = ({ data, setData, temp, setTemp }) =
|
|||
setTemp={setTemp}
|
||||
accept="image/*"
|
||||
icon="image"
|
||||
type={UPLOAD_TYPES.IMAGE}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
@ -7,4 +7,17 @@
|
|||
box-sizing: border-box;
|
||||
padding: $gap;
|
||||
z-index: 10;
|
||||
}
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
& > * {
|
||||
margin: 0 $gap;
|
||||
|
||||
&:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ type IProps = ReturnType<typeof mapStateToProps> &
|
|||
|
||||
accept?: string;
|
||||
icon?: string;
|
||||
type?: typeof UPLOAD_TYPES[keyof typeof UPLOAD_TYPES];
|
||||
};
|
||||
|
||||
const EditorUploadButtonUnconnected: FC<IProps> = ({
|
||||
|
@ -42,6 +43,7 @@ const EditorUploadButtonUnconnected: FC<IProps> = ({
|
|||
uploadUploadFiles,
|
||||
accept = 'image/*',
|
||||
icon = 'plus',
|
||||
type = UPLOAD_TYPES.IMAGE,
|
||||
}) => {
|
||||
const eventPreventer = useCallback(event => event.preventDefault(), []);
|
||||
|
||||
|
@ -52,13 +54,15 @@ const EditorUploadButtonUnconnected: FC<IProps> = ({
|
|||
|
||||
if (current >= NODE_SETTINGS.MAX_FILES) return;
|
||||
|
||||
console.log({ type });
|
||||
|
||||
const items: IFileWithUUID[] = Array.from(uploads).map(
|
||||
(file: File): IFileWithUUID => ({
|
||||
file,
|
||||
temp_id: uuid(),
|
||||
subject: UPLOAD_SUBJECTS.EDITOR,
|
||||
target: UPLOAD_TARGETS.NODES,
|
||||
type: UPLOAD_TYPES.IMAGE,
|
||||
type,
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -67,7 +71,7 @@ const EditorUploadButtonUnconnected: FC<IProps> = ({
|
|||
setTemp([...temp, ...temps]);
|
||||
uploadUploadFiles(items);
|
||||
},
|
||||
[setTemp, uploadUploadFiles, temp, data]
|
||||
[setTemp, uploadUploadFiles, temp, data, type]
|
||||
);
|
||||
|
||||
const onFileAdd = useCallback(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue