mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-24 00:19:34 +02:00
Initial commit for new tool video to gif
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { tool as videoVideoToGif } from './video-to-gif/meta';
|
||||
import { tool as videoChangeSpeed } from './change-speed/meta';
|
||||
import { tool as videoFlip } from './flip/meta';
|
||||
import { rotate } from '../string/rotate/service';
|
||||
@@ -9,6 +10,7 @@ import { tool as loopVideo } from './loop/meta';
|
||||
import { tool as flipVideo } from './flip/meta';
|
||||
import { tool as cropVideo } from './crop-video/meta';
|
||||
import { tool as changeSpeed } from './change-speed/meta';
|
||||
import { tool as videoToGif } from './video-to-gif/meta';
|
||||
|
||||
export const videoTools = [
|
||||
...gifTools,
|
||||
@@ -18,5 +20,6 @@ export const videoTools = [
|
||||
loopVideo,
|
||||
flipVideo,
|
||||
cropVideo,
|
||||
changeSpeed
|
||||
changeSpeed,
|
||||
videoToGif
|
||||
];
|
||||
|
69
src/pages/tools/video/video-to-gif/index.tsx
Normal file
69
src/pages/tools/video/video-to-gif/index.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
import { Box } from '@mui/material';
|
||||
import React, { useState } from 'react';
|
||||
import ToolContent from '@components/ToolContent';
|
||||
import { ToolComponentProps } from '@tools/defineTool';
|
||||
import ToolTextInput from '@components/input/ToolTextInput';
|
||||
import ToolTextResult from '@components/result/ToolTextResult';
|
||||
import { GetGroupsType } from '@components/options/ToolOptions';
|
||||
import { CardExampleType } from '@components/examples/ToolExamples';
|
||||
import { main } from './service';
|
||||
import { InitialValuesType } from './types';
|
||||
import ToolVideoInput from '@components/input/ToolVideoInput';
|
||||
import ToolFileResult from '@components/result/ToolFileResult';
|
||||
|
||||
const initialValues: InitialValuesType = {
|
||||
// splitSeparator: '\n'
|
||||
};
|
||||
|
||||
export default function VideoToGif({
|
||||
title,
|
||||
longDescription
|
||||
}: ToolComponentProps) {
|
||||
const [input, setInput] = useState<File | null>(null);
|
||||
const [result, setResult] = useState<File | null>(null);
|
||||
const [loading, setIsLoading] = useState(false);
|
||||
|
||||
const compute = (values: InitialValuesType, input: File | null) => {
|
||||
setResult(main(input, values));
|
||||
};
|
||||
|
||||
const getGroups: GetGroupsType<InitialValuesType> | null = ({
|
||||
values,
|
||||
updateField
|
||||
}) => [
|
||||
{
|
||||
title: 'Example Settings',
|
||||
component: <Box></Box>
|
||||
}
|
||||
];
|
||||
|
||||
return (
|
||||
<ToolContent
|
||||
title={title}
|
||||
input={input}
|
||||
inputComponent={
|
||||
<ToolVideoInput value={input} onChange={setInput} title="Input Video" />
|
||||
}
|
||||
resultComponent={
|
||||
loading ? (
|
||||
<ToolFileResult
|
||||
title="Converting to Gif"
|
||||
value={null}
|
||||
loading={true}
|
||||
/>
|
||||
) : (
|
||||
<ToolFileResult
|
||||
title="Converted to Gif"
|
||||
value={result}
|
||||
extension="gif"
|
||||
/>
|
||||
)
|
||||
}
|
||||
initialValues={initialValues}
|
||||
getGroups={getGroups}
|
||||
setInput={setInput}
|
||||
compute={compute}
|
||||
toolInfo={{ title: `What is a ${title}?`, description: longDescription }}
|
||||
/>
|
||||
);
|
||||
}
|
12
src/pages/tools/video/video-to-gif/meta.ts
Normal file
12
src/pages/tools/video/video-to-gif/meta.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineTool } from '@tools/defineTool';
|
||||
import { lazy } from 'react';
|
||||
|
||||
export const tool = defineTool('video', {
|
||||
name: 'Video to Gif',
|
||||
path: 'video-to-gif',
|
||||
icon: 'fluent:gif-16-regular',
|
||||
description: 'This online utility lets you convert a short video to gif.',
|
||||
shortDescription: 'Quickly convert a short video to gif',
|
||||
keywords: ['video', 'to', 'gif', 'convert'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
5
src/pages/tools/video/video-to-gif/service.ts
Normal file
5
src/pages/tools/video/video-to-gif/service.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { InitialValuesType } from './types';
|
||||
|
||||
export function main(input: File, options: InitialValuesType): File {
|
||||
return input;
|
||||
}
|
3
src/pages/tools/video/video-to-gif/types.ts
Normal file
3
src/pages/tools/video/video-to-gif/types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type InitialValuesType = {
|
||||
// splitSeparator: string;
|
||||
};
|
@@ -0,0 +1,6 @@
|
||||
import { expect, describe, it } from 'vitest';
|
||||
// import { main } from './service';
|
||||
//
|
||||
// describe('video-to-gif', () => {
|
||||
//
|
||||
// })
|
Reference in New Issue
Block a user