From f219bd14b681929fd19b31596baffb616014ec28 Mon Sep 17 00:00:00 2001 From: Vlad Gerasimov Date: Sat, 9 Aug 2025 07:33:55 +0400 Subject: [PATCH] refactor(settings): wrap CorrectWords with SettingContainer --- src/components/settings/CorrectWords.tsx | 92 +++++++++--------------- 1 file changed, 32 insertions(+), 60 deletions(-) diff --git a/src/components/settings/CorrectWords.tsx b/src/components/settings/CorrectWords.tsx index e0115c3..0d87d2c 100644 --- a/src/components/settings/CorrectWords.tsx +++ b/src/components/settings/CorrectWords.tsx @@ -1,5 +1,6 @@ import React, { useState } from "react"; import { useSettings } from "../../hooks/useSettings"; +import { SettingContainer } from "../ui/SettingContainer"; interface CorrectWordsProps { descriptionMode?: "inline" | "tooltip"; @@ -12,12 +13,10 @@ export const CorrectWords: React.FC = ({ }) => { const { getSetting, updateSetting, isUpdating } = useSettings(); const [newWord, setNewWord] = useState(""); - const correctWords = getSetting("correct_words") || []; const handleAddWord = () => { const trimmedWord = newWord.trim(); - // Don't allow spaces in words if (trimmedWord && !trimmedWord.includes(' ') && !correctWords.includes(trimmedWord)) { updateSetting("correct_words", [...correctWords, trimmedWord]); setNewWord(""); @@ -25,10 +24,7 @@ export const CorrectWords: React.FC = ({ }; const handleRemoveWord = (wordToRemove: string) => { - updateSetting( - "correct_words", - correctWords.filter((word) => word !== wordToRemove) - ); + updateSetting("correct_words", correctWords.filter((word) => word !== wordToRemove)); }; const handleKeyPress = (e: React.KeyboardEvent) => { @@ -39,48 +35,34 @@ export const CorrectWords: React.FC = ({ }; return ( -
- {/* Title, info button, input and add button all in one line */} -
-

Custom Words

- {descriptionMode === "tooltip" && ( -
- - - -
- )} - setNewWord(e.target.value)} - onKeyPress={handleKeyPress} - placeholder="Add a word" - className="flex-1 px-2 py-1 text-sm border border-mid-gray/30 rounded focus:outline-none focus:ring-1 focus:ring-logo-primary focus:border-transparent bg-background" - disabled={isUpdating("correct_words")} - /> - -
- - {/* Words list - flex wrap layout */} + <> + +
+ setNewWord(e.target.value)} + onKeyPress={handleKeyPress} + placeholder="Add a word" + className="px-2 py-1 text-sm border border-mid-gray/30 rounded focus:outline-none focus:ring-1 focus:ring-logo-primary focus:border-transparent bg-background" + disabled={isUpdating("correct_words")} + /> + +
+
{correctWords.length > 0 && ( -
+
{correctWords.map((word) => ( ))}
)} -
+ ); }; \ No newline at end of file