fix: Settings styles

This commit is contained in:
Artemy 2023-04-04 17:15:25 +03:00
parent 2c07e71349
commit f3106daa4b
4 changed files with 97 additions and 92 deletions

View file

@ -1,5 +1,5 @@
import { CheckBox } from "./checkbox"; import { CheckBox } from "./checkbox";
import { inputStyle } from "./styles"; import { inputStyle, settingsAddInput } from "./styles";
function SettingsCheckBox({ label, title, className, settingName, onClick }) { function SettingsCheckBox({ label, title, className, settingName, onClick }) {
return ( return (
@ -27,12 +27,12 @@ function SettingsTextInput({
secret, secret,
}) { }) {
return ( return (
<div className="ml-2"> <div>
<label className="block mb-2 text-base font-medium text-gray-700 dark:text-white"> <label className="block mb-2 text-base font-medium text-gray-700 dark:text-white">
{label} {label}
</label> </label>
<input <input
className={`${inputStyle} m-2 ${className}`} className={`${inputStyle} ${settingsAddInput} m-2 ${className}`}
type={secret ? "password" : "text"} type={secret ? "password" : "text"}
placeholder={placeholder} placeholder={placeholder}
title={title} title={title}
@ -55,12 +55,12 @@ function SettingsSelectInput({
onChange, onChange,
}) { }) {
return ( return (
<div className="ml-2"> <div>
<label className="block mb-2 text-base font-medium text-gray-700 dark:text-white"> <label className="block mb-2 text-base font-medium text-gray-700 dark:text-white">
{label} {label}
</label> </label>
<select <select
className={`${inputStyle} m-2 ${className}`} className={`${inputStyle} ${settingsAddInput} m-2 ${className}`}
defaultValue={window.settings[settingName]} defaultValue={window.settings[settingName]}
onChange={(e) => { onChange={(e) => {
window.settings[settingName] = e.target.value; window.settings[settingName] = e.target.value;
@ -78,11 +78,14 @@ function SettingsSelectInput({
); );
} }
function SettingsPlaceholder({ text }) { function SettingsSection({ name, children }) {
return ( return (
<div className="ml-0 lg:ml-6 mt-6 lg:mt-3">
<h1 className="text-center lg:text-left leading-tight text-xl font-semibold"> <h1 className="text-center lg:text-left leading-tight text-xl font-semibold">
{text} {name}
</h1> </h1>
<div className="ml-0 lg:ml-6 mt-6 lg:mt-3">{children}</div>
</div>
); );
} }
@ -90,5 +93,5 @@ export {
SettingsCheckBox, SettingsCheckBox,
SettingsTextInput, SettingsTextInput,
SettingsSelectInput, SettingsSelectInput,
SettingsPlaceholder, SettingsSection,
}; };

View file

@ -1,4 +1,5 @@
let inputStyle = let inputStyle =
"w-full 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"; "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";
let settingsAddInput = "w-full lg:w-1/4";
export { inputStyle }; export { inputStyle, settingsAddInput };

View file

@ -17,7 +17,7 @@ import remarkGfm from "remark-gfm";
import remarkMath from "remark-math"; import remarkMath from "remark-math";
import { import {
SettingsCheckBox, SettingsCheckBox,
SettingsPlaceholder, SettingsSection,
} from "../components/settingsInputs"; } from "../components/settingsInputs";
import { inputStyle } from "../components/styles"; import { inputStyle } from "../components/styles";
import { Complete } from "../components/openai"; import { Complete } from "../components/openai";
@ -136,7 +136,7 @@ function CreateNote() {
{settings.additionalFeatures && ( {settings.additionalFeatures && (
<div className="justify-self-start lg:justify-self-start"> <div className="justify-self-start lg:justify-self-start">
<SettingsPlaceholder text={locals.AdditionalFeatures} /> <SettingsSection name={locals.AdditionalFeatures}>
{!!settings.openAiKey && ( {!!settings.openAiKey && (
<ButtonWithIcon <ButtonWithIcon
icon={DocumentTextIcon} icon={DocumentTextIcon}
@ -148,6 +148,7 @@ function CreateNote() {
}} }}
/> />
)} )}
</SettingsSection>
</div> </div>
)} )}
</div> </div>

View file

@ -2,20 +2,19 @@ import {
SettingsCheckBox, SettingsCheckBox,
SettingsTextInput, SettingsTextInput,
SettingsSelectInput, SettingsSelectInput,
SettingsPlaceholder, SettingsSection,
} from "../components/settingsInputs"; } from "../components/settingsInputs";
import { reRenderPage } from "../components/utils"; import { reRenderPage } from "../components/utils";
import Locales from "../localisation/main"; import Locales from "../localisation/main";
function Settings() { function Settings() {
return ( return (
<div className=""> <div>
<h1 className="text-center lg:text-left leading-tight text-2xl font-bold"> <h1 className="text-center lg:text-left leading-tight text-2xl font-bold">
{locals.Settings} {locals.Settings}
</h1> </h1>
<SettingsPlaceholder text={locals.User} /> <SettingsSection name={locals.User}>
<SettingsTextInput <SettingsTextInput
placeholder={locals.Name} placeholder={locals.Name}
label={locals.UserName} label={locals.UserName}
@ -33,9 +32,9 @@ function Settings() {
label={locals.UserStatus} label={locals.UserStatus}
settingName="userStatus" settingName="userStatus"
/> />
</SettingsSection>
<SettingsPlaceholder text={locals.Notes} /> <SettingsSection name={locals.Notes}>
<SettingsCheckBox <SettingsCheckBox
label={locals.EditPreview} label={locals.EditPreview}
title={locals.EditPreviewWarn} title={locals.EditPreviewWarn}
@ -52,9 +51,9 @@ function Settings() {
label={locals.AdditionalFeatures} label={locals.AdditionalFeatures}
settingName="additionalFeatures" settingName="additionalFeatures"
/> />
</SettingsSection>
<SettingsPlaceholder text={locals.Interface} /> <SettingsSection name={locals.Interface}>
<SettingsSelectInput <SettingsSelectInput
label={locals.Language} label={locals.Language}
settingName="language" settingName="language"
@ -78,15 +77,16 @@ function Settings() {
reRenderPage(); reRenderPage();
}} }}
/> />
</SettingsSection>
<SettingsPlaceholder text={locals.ThirdPartyApi} /> <SettingsSection name={locals.ThirdPartyApi}>
<SettingsTextInput <SettingsTextInput
placeholder={locals.Key} placeholder={locals.Key}
label={locals.OpenAiKey} label={locals.OpenAiKey}
settingName="openAiKey" settingName="openAiKey"
secret secret
/> />
</SettingsSection>
</div> </div>
); );
} }