From e7564d40581a6353f6d12005f946c831a8aadc51 Mon Sep 17 00:00:00 2001 From: Artemy Date: Mon, 3 Apr 2023 19:38:03 +0300 Subject: [PATCH] feat: more settings --- src/components/settingsInputs.jsx | 66 ++++++++++++++++++++++++++++++- src/components/styles.js | 4 ++ src/pages/create.jsx | 2 +- src/pages/settings.jsx | 62 ++++++++++++++++++++++++++++- 4 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 src/components/styles.js diff --git a/src/components/settingsInputs.jsx b/src/components/settingsInputs.jsx index dca9ef2..6caa12d 100644 --- a/src/components/settingsInputs.jsx +++ b/src/components/settingsInputs.jsx @@ -1,4 +1,5 @@ import { CheckBox } from "./checkbox"; +import { inputStyle } from "./styles"; function SettingsCheckBox({ label, title, className, settingName, onClick }) { return ( @@ -10,10 +11,71 @@ function SettingsCheckBox({ label, title, className, settingName, onClick }) { onClick={(e) => { window.settings[settingName] = e.target.checked; localStorage.setObj("settings", window.settings); - onClick(e); + onClick && onClick(e); }} /> ); } -export { SettingsCheckBox }; +function SettingsTextInput({ + placeholder, + title, + label, + className, + settingName, + onChange, + secret, +}) { + return ( +
+ + { + window.settings[settingName] = e.target.value; + localStorage.setObj("settings", window.settings); + onChange && onChange(e); + }} + /> +
+ ); +} + +function SettingsSelectInput({ + label, + className, + settingName, + options, + onChange, +}) { + return ( +
+ + +
+ ); +} + +export { SettingsCheckBox, SettingsTextInput, SettingsSelectInput }; diff --git a/src/components/styles.js b/src/components/styles.js new file mode 100644 index 0000000..a1cbf46 --- /dev/null +++ b/src/components/styles.js @@ -0,0 +1,4 @@ +let inputStyle = + "form-control block px-3 py-1.5 text-base font-normal text-gray-700 dark:text-white bg-white dark:bg-zinc-900 bg-clip-padding border border-solid border-gray-300 rounded-lg transition ease-in-out focus:border-blue-600 focus:outline-none"; + +export { inputStyle }; diff --git a/src/pages/create.jsx b/src/pages/create.jsx index 201af01..5fcd2c5 100644 --- a/src/pages/create.jsx +++ b/src/pages/create.jsx @@ -13,6 +13,7 @@ import remarkStringify from "remark-stringify"; import remarkGfm from "remark-gfm"; import remarkMath from "remark-math"; import { SettingsCheckBox } from "../components/settingsInputs"; +import { inputStyle } from "../components/styles"; function CreateNote() { const [preview, setPreview] = useState(false); @@ -36,7 +37,6 @@ function CreateNote() { localStorage.setItem("NoteText", md); } - let inputStyle = `form-control block px-3 py-1.5 text-base font-normal text-gray-700 dark:text-white bg-white dark:bg-zinc-900 bg-clip-padding border border-solid border-gray-300 rounded-lg transition ease-in-out focus:border-blue-600 focus:outline-none`; return (
diff --git a/src/pages/settings.jsx b/src/pages/settings.jsx index 9b6ff1e..2e07b08 100644 --- a/src/pages/settings.jsx +++ b/src/pages/settings.jsx @@ -1,4 +1,8 @@ -import { SettingsCheckBox } from "../components/settingsInputs"; +import { + SettingsCheckBox, + SettingsTextInput, + SettingsSelectInput, +} from "../components/settingsInputs"; function Settings() { return (
@@ -6,6 +10,32 @@ function Settings() { Настройки +

+ Пользователь +

+ + + + + + + +

+ Заметки +

+ + +

+ Интерфейс +

+ + + +

+ Стороннее API +

+ +
); }