refactor: use ToolContent in palindrome

This commit is contained in:
Ibrahima G. Coulibaly
2025-03-09 01:29:50 +00:00
parent 0fadb91b2c
commit b372692971
2 changed files with 28 additions and 34 deletions

28
.idea/workspace.xml generated
View File

@@ -4,9 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="refactor: use ToolContent">
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="refactor: use ToolContent in ExtractSubstring">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools/string/extract-substring/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/string/extract-substring/index.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools/string/palindrome/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/string/palindrome/index.tsx" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -333,15 +333,7 @@
<workItem from="1740880919391" duration="4395000" />
<workItem from="1740923024259" duration="23000" />
<workItem from="1740933006573" duration="3679000" />
<workItem from="1741475969294" duration="6863000" />
</task>
<task id="LOCAL-00103" summary="feat: update readme">
<option name="closed" value="true" />
<created>1740276092528</created>
<option name="number" value="00103" />
<option name="presentableId" value="LOCAL-00103" />
<option name="project" value="LOCAL" />
<updated>1740276092528</updated>
<workItem from="1741475969294" duration="6986000" />
</task>
<task id="LOCAL-00104" summary="feat: compress png">
<option name="closed" value="true" />
@@ -727,7 +719,15 @@
<option name="project" value="LOCAL" />
<updated>1741483345639</updated>
</task>
<option name="localTasksCounter" value="152" />
<task id="LOCAL-00152" summary="refactor: use ToolContent in ExtractSubstring">
<option name="closed" value="true" />
<created>1741483603658</created>
<option name="number" value="00152" />
<option name="presentableId" value="LOCAL-00152" />
<option name="project" value="LOCAL" />
<updated>1741483603658</updated>
</task>
<option name="localTasksCounter" value="153" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -786,7 +786,6 @@
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_NEW_TODO" value="false" />
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="chore: handle enter press on search" />
<MESSAGE value="chore: show tooloptions in example" />
<MESSAGE value="refact: examples" />
<MESSAGE value="fix: examples" />
@@ -811,7 +810,8 @@
<MESSAGE value="feat: change pgn opacity" />
<MESSAGE value="feat: csv to json" />
<MESSAGE value="refactor: use ToolContent" />
<option name="LAST_COMMIT_MESSAGE" value="refactor: use ToolContent" />
<MESSAGE value="refactor: use ToolContent in ExtractSubstring" />
<option name="LAST_COMMIT_MESSAGE" value="refactor: use ToolContent in ExtractSubstring" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />

View File

@@ -11,6 +11,7 @@ import ToolExamples, {
} from '@components/examples/ToolExamples';
import { ToolComponentProps } from '@tools/defineTool';
import { FormikProps } from 'formik';
import ToolContent from '@components/ToolContent';
const initialValues = {
splitOperatorType: 'symbol' as SplitOperatorType,
@@ -76,7 +77,6 @@ const exampleCards: CardExampleType<typeof initialValues>[] = [
export default function Palindrome({ title }: ToolComponentProps) {
const [input, setInput] = useState<string>('');
const [result, setResult] = useState<string>('');
const formRef = useRef<FormikProps<typeof initialValues>>(null);
const computeExternal = (
optionsValues: typeof initialValues,
@@ -109,24 +109,18 @@ export default function Palindrome({ title }: ToolComponentProps) {
];
return (
<Box>
<ToolInputAndResult
input={<ToolTextInput value={input} onChange={setInput} />}
result={<ToolTextResult title={'Palindrome results'} value={result} />}
/>
<ToolOptions
compute={computeExternal}
getGroups={getGroups}
initialValues={initialValues}
input={input}
/>
<ToolExamples
<ToolContent
title={title}
exampleCards={exampleCards}
initialValues={initialValues}
getGroups={getGroups}
formRef={formRef}
compute={computeExternal}
input={input}
setInput={setInput}
inputComponent={<ToolTextInput value={input} onChange={setInput} />}
resultComponent={
<ToolTextResult title={'Palindrome results'} value={result} />
}
exampleCards={exampleCards}
/>
</Box>
);
}