diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 6d8204d..e98c9e4 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,11 @@
-
-
+
+
+
+
@@ -293,14 +295,6 @@
-
-
- 1720565760853
-
-
-
- 1720565760853
-
1720656867853
@@ -685,7 +679,15 @@
1740936527951
-
+
+
+ 1741211604972
+
+
+
+ 1741211604972
+
+
@@ -744,7 +746,6 @@
-
@@ -769,7 +770,8 @@
-
+
+
diff --git a/src/components/ToolContent.tsx b/src/components/ToolContent.tsx
index 448c52a..4b45a9a 100644
--- a/src/components/ToolContent.tsx
+++ b/src/components/ToolContent.tsx
@@ -10,7 +10,7 @@ import ToolExamples, {
} from '@components/examples/ToolExamples';
import { ToolComponentProps } from '@tools/defineTool';
-interface ToolContentPropsBase extends ToolComponentProps {
+interface ToolContentPropsBase extends ToolComponentProps {
// Input/Output components
inputComponent: ReactNode;
resultComponent: ReactNode;
@@ -20,7 +20,7 @@ interface ToolContentPropsBase extends ToolComponentProps {
getGroups: GetGroupsType;
// Computation function
- compute: (optionsValues: T, input: any) => void;
+ compute: (optionsValues: T, input: I) => void;
// Tool info (optional)
toolInfo?: {
@@ -29,27 +29,29 @@ interface ToolContentPropsBase extends ToolComponentProps {
};
// Input value to pass to the compute function
- input: any;
+ input: I;
// Validation schema (optional)
validationSchema?: any;
}
-interface ToolContentPropsWithExamples extends ToolContentPropsBase {
+interface ToolContentPropsWithExamples
+ extends ToolContentPropsBase {
exampleCards: CardExampleType[];
- setInput: React.Dispatch>;
+ setInput: React.Dispatch>;
}
-interface ToolContentPropsWithoutExamples extends ToolContentPropsBase {
- exampleCards?: undefined;
- setInput?: undefined;
+interface ToolContentPropsWithoutExamples
+ extends ToolContentPropsBase {
+ exampleCards?: never;
+ setInput?: never;
}
-type ToolContentProps =
- | ToolContentPropsWithExamples
- | ToolContentPropsWithoutExamples;
+type ToolContentProps =
+ | ToolContentPropsWithExamples
+ | ToolContentPropsWithoutExamples;
-export default function ToolContent({
+export default function ToolContent({
title,
inputComponent,
resultComponent,
@@ -61,7 +63,7 @@ export default function ToolContent({
input,
setInput,
validationSchema
-}: ToolContentProps) {
+}: ToolContentProps) {
const formRef = useRef>(null);
return (
diff --git a/src/components/examples/ToolExamples.tsx b/src/components/examples/ToolExamples.tsx
index d7298d0..8bd236c 100644
--- a/src/components/examples/ToolExamples.tsx
+++ b/src/components/examples/ToolExamples.tsx
@@ -15,7 +15,7 @@ export interface ExampleProps {
exampleCards: CardExampleType[];
getGroups: GetGroupsType;
formRef: React.RefObject>;
- setInput: React.Dispatch>;
+ setInput: React.Dispatch>;
}
export default function ToolExamples({
diff --git a/src/pages/tools/image/png/change-colors-in-png/index.tsx b/src/pages/tools/image/png/change-colors-in-png/index.tsx
index 816bdc9..2dad38b 100644
--- a/src/pages/tools/image/png/change-colors-in-png/index.tsx
+++ b/src/pages/tools/image/png/change-colors-in-png/index.tsx
@@ -3,12 +3,14 @@ import React, { useState } from 'react';
import * as Yup from 'yup';
import ToolFileInput from '@components/input/ToolFileInput';
import ToolFileResult from '@components/result/ToolFileResult';
-import ToolOptions from '@components/options/ToolOptions';
+import ToolOptions, { GetGroupsType } from '@components/options/ToolOptions';
import ColorSelector from '@components/options/ColorSelector';
import Color from 'color';
import TextFieldWithDesc from 'components/options/TextFieldWithDesc';
import ToolInputAndResult from '@components/ToolInputAndResult';
import { areColorsSimilar } from 'utils/color';
+import ToolContent from '@components/ToolContent';
+import { ToolComponentProps } from '@tools/defineTool';
const initialValues = {
fromColor: 'white',
@@ -18,7 +20,7 @@ const initialValues = {
const validationSchema = Yup.object({
// splitSeparator: Yup.string().required('The separator is required')
});
-export default function ChangeColorsInPng() {
+export default function ChangeColorsInPng({ title }: ToolComponentProps) {
const [input, setInput] = useState(null);
const [result, setResult] = useState(null);
@@ -83,58 +85,65 @@ export default function ChangeColorsInPng() {
processImage(input, fromRgb, toRgb, Number(similarity));
};
+ const getGroups: GetGroupsType = ({
+ values,
+ updateField
+ }) => [
+ {
+ title: 'From color and to color',
+ component: (
+
+ updateField('fromColor', val)}
+ description={'Replace this color (from color)'}
+ inputProps={{ 'data-testid': 'from-color-input' }}
+ />
+ updateField('toColor', val)}
+ description={'With this color (to color)'}
+ inputProps={{ 'data-testid': 'to-color-input' }}
+ />
+ updateField('similarity', val)}
+ description={
+ 'Match this % of similar colors of the from color. For example, 10% white will match white and a little bit of gray.'
+ }
+ />
+
+ )
+ }
+ ];
return (
-
-
- }
- result={
-
- }
- />
- [
- {
- title: 'From color and to color',
- component: (
-
- updateField('fromColor', val)}
- description={'Replace this color (from color)'}
- inputProps={{ 'data-testid': 'from-color-input' }}
- />
- updateField('toColor', val)}
- description={'With this color (to color)'}
- inputProps={{ 'data-testid': 'to-color-input' }}
- />
- updateField('similarity', val)}
- description={
- 'Match this % of similar colors of the from color. For example, 10% white will match white and a little bit of gray.'
- }
- />
-
- )
- }
- ]}
- initialValues={initialValues}
- input={input}
- />
-
+
+ }
+ resultComponent={
+
+ }
+ toolInfo={{
+ title: 'Make Colors Transparent',
+ description:
+ 'This tool allows you to make specific colors in a PNG image transparent. You can select the color to replace and adjust the similarity threshold to include similar colors.'
+ }}
+ />
);
}
diff --git a/src/pages/tools/list/reverse/index.tsx b/src/pages/tools/list/reverse/index.tsx
index dbcfbc4..9de94f8 100644
--- a/src/pages/tools/list/reverse/index.tsx
+++ b/src/pages/tools/list/reverse/index.tsx
@@ -1,5 +1,5 @@
import { Box } from '@mui/material';
-import React, { useRef, useState } from 'react';
+import React, { useState } from 'react';
import ToolTextInput from '@components/input/ToolTextInput';
import ToolTextResult from '@components/result/ToolTextResult';
import { GetGroupsType } from '@components/options/ToolOptions';
@@ -7,7 +7,6 @@ import { reverseList, SplitOperatorType } from './service';
import SimpleRadio from '@components/options/SimpleRadio';
import TextFieldWithDesc from '@components/options/TextFieldWithDesc';
import { CardExampleType } from '@components/examples/ToolExamples';
-import { FormikProps } from 'formik';
import { ToolComponentProps } from '@tools/defineTool';
import ToolContent from '@components/ToolContent';