diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e50bab9..6d8204d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,10 @@
-
+
+
-
@@ -29,52 +29,31 @@
- {
+ "history": [
{
- "assignee": "iib0011"
- },
- {
- "state": "OPEN"
+ "assignee": "iib0011"
}
- ],
- "lastFilter": {
- "state": "OPEN"
- }
-}]]>
-
+ }
{
- "selectedUrlAndAccountId": {
+ "selectedUrlAndAccountId": {
"url": "https://github.com/iib0011/omni-tools.git",
"accountId": "45f8cd51-000f-4ba4-a4c6-c4d96ac9b1e5"
- }
-}
+ }
+ }
{
- "isMigrated": true
-}
+ "isMigrated": true
+ }
{
- "associatedIndex": 0
-}
+ "associatedIndex": 0
+ }
@@ -84,51 +63,51 @@
-
+ {
+ "keyToString": {
+ "ASKED_ADD_EXTERNAL_FILES": "true",
+ "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "Docker.Dockerfile build.executor": "Run",
+ "Docker.Dockerfile.executor": "Run",
+ "Playwright.JoinText Component.executor": "Run",
+ "Playwright.JoinText Component.should merge text pieces with specified join character.executor": "Run",
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "Vitest.compute function (1).executor": "Run",
+ "Vitest.compute function.executor": "Run",
+ "Vitest.mergeText.executor": "Run",
+ "Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
+ "Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
+ "Vitest.removeDuplicateLines function.executor": "Run",
+ "Vitest.removeDuplicateLines function.newlines option.executor": "Run",
+ "Vitest.removeDuplicateLines function.newlines option.should filter newlines when newlines is set to filter.executor": "Run",
+ "git-widget-placeholder": "main",
+ "ignore.virus.scanning.warn.message": "true",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/public/assets",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "npm.build.executor": "Run",
+ "npm.dev.executor": "Run",
+ "npm.lint.executor": "Run",
+ "npm.prebuild.executor": "Run",
+ "npm.script:create:tool.executor": "Run",
+ "npm.test.executor": "Run",
+ "npm.test:e2e.executor": "Run",
+ "npm.test:e2e:run.executor": "Run",
+ "prettierjs.PrettierConfiguration.Package": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\prettier",
+ "project.structure.last.edited": "Problems",
+ "project.structure.proportion": "0.0",
+ "project.structure.side.proportion": "0.2",
+ "settings.editor.selected.configurable": "settings.typescriptcompiler",
+ "ts.external.directory.path": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\typescript\\lib",
+ "vue.rearranger.settings.migration": "true"
+ }
+ }
@@ -775,6 +752,7 @@
+
@@ -791,8 +769,7 @@
-
-
+
diff --git a/src/components/ToolContent.tsx b/src/components/ToolContent.tsx
new file mode 100644
index 0000000..448c52a
--- /dev/null
+++ b/src/components/ToolContent.tsx
@@ -0,0 +1,98 @@
+import React, { useRef, useState, ReactNode } from 'react';
+import { Box } from '@mui/material';
+import { FormikProps, FormikValues } from 'formik';
+import ToolOptions, { GetGroupsType } from '@components/options/ToolOptions';
+import ToolInputAndResult from '@components/ToolInputAndResult';
+import ToolInfo from '@components/ToolInfo';
+import Separator from '@components/Separator';
+import ToolExamples, {
+ CardExampleType
+} from '@components/examples/ToolExamples';
+import { ToolComponentProps } from '@tools/defineTool';
+
+interface ToolContentPropsBase extends ToolComponentProps {
+ // Input/Output components
+ inputComponent: ReactNode;
+ resultComponent: ReactNode;
+
+ // Tool options
+ initialValues: T;
+ getGroups: GetGroupsType;
+
+ // Computation function
+ compute: (optionsValues: T, input: any) => void;
+
+ // Tool info (optional)
+ toolInfo?: {
+ title: string;
+ description: string;
+ };
+
+ // Input value to pass to the compute function
+ input: any;
+
+ // Validation schema (optional)
+ validationSchema?: any;
+}
+
+interface ToolContentPropsWithExamples extends ToolContentPropsBase {
+ exampleCards: CardExampleType[];
+ setInput: React.Dispatch>;
+}
+
+interface ToolContentPropsWithoutExamples extends ToolContentPropsBase {
+ exampleCards?: undefined;
+ setInput?: undefined;
+}
+
+type ToolContentProps =
+ | ToolContentPropsWithExamples
+ | ToolContentPropsWithoutExamples;
+
+export default function ToolContent({
+ title,
+ inputComponent,
+ resultComponent,
+ initialValues,
+ getGroups,
+ compute,
+ toolInfo,
+ exampleCards,
+ input,
+ setInput,
+ validationSchema
+}: ToolContentProps) {
+ const formRef = useRef>(null);
+
+ return (
+
+
+
+
+
+ {toolInfo && (
+
+ )}
+
+ {exampleCards && exampleCards.length > 0 && (
+ <>
+
+
+ >
+ )}
+
+ );
+}
diff --git a/src/pages/tools/list/reverse/index.tsx b/src/pages/tools/list/reverse/index.tsx
index dce6d0e..dbcfbc4 100644
--- a/src/pages/tools/list/reverse/index.tsx
+++ b/src/pages/tools/list/reverse/index.tsx
@@ -2,18 +2,14 @@ import { Box } from '@mui/material';
import React, { useRef, useState } from 'react';
import ToolTextInput from '@components/input/ToolTextInput';
import ToolTextResult from '@components/result/ToolTextResult';
-import ToolOptions, { GetGroupsType } from '@components/options/ToolOptions';
+import { GetGroupsType } from '@components/options/ToolOptions';
import { reverseList, SplitOperatorType } from './service';
-import ToolInputAndResult from '@components/ToolInputAndResult';
import SimpleRadio from '@components/options/SimpleRadio';
import TextFieldWithDesc from '@components/options/TextFieldWithDesc';
-import ToolExamples, {
- CardExampleType
-} from '@components/examples/ToolExamples';
-import ToolInfo from '@components/ToolInfo';
+import { CardExampleType } from '@components/examples/ToolExamples';
import { FormikProps } from 'formik';
-import Separator from '@components/Separator';
import { ToolComponentProps } from '@tools/defineTool';
+import ToolContent from '@components/ToolContent';
const initialValues = {
splitOperatorType: 'symbol' as SplitOperatorType,
@@ -118,7 +114,6 @@ argument`,
export default function Reverse({ title }: ToolComponentProps) {
const [input, setInput] = useState('');
const [result, setResult] = useState('');
- const formRef = useRef>(null);
const getGroups: GetGroupsType = ({
values,
@@ -174,36 +169,25 @@ export default function Reverse({ title }: ToolComponentProps) {
};
return (
-
-
- }
- result={}
- />
-
-
-
-
-
+
+ }
+ resultComponent={
+
+ }
+ toolInfo={{
+ title: 'What Is a List Reverser?',
+ description:
+ 'With this utility, you can reverse the order of items in a list. The utility first splits the input list into individual items and then iterates through them from the last item to the first item, printing each item to the output during the iteration. The input list may contain anything that can be represented as textual data, which includes digits, numbers, strings, words, sentences, etc. The input item separator can also be a regular expression. For example, the regex /[;,]/ will allow you to use items that are either comma- or semicolon-separated. The input and output list items delimiters can be customized in the options. By default, both input and output lists are comma-separated. Listabulous!'
+ }}
+ exampleCards={exampleCards}
+ />
);
}