mirror of
https://github.com/standardnotes/app
synced 2026-10-02 03:13:49 -04:00
* feat: Add new icons
* Revert "feat: Add new icons"
This reverts commit 0acb403fe8.
* feat: Add new icons for account menu
* feat: Add new Icons
* feat: Add "currentPane" state to prefs view
* feat: Update account menu to new design
* feat: Add input component with icon & toggle
* fix: sync icon & function
* fix: Fix eye icon
* feat: Create re-usable checkbox
feat: Add "merge local" option
* feat: Allow using className on IconButton
* feat: Add disabled state on input
feat: Make toggle circle
* refactor: Move checkbox to components
* feat: Handle invalid email/password error
* feat: Implement new design for Create Account
* feat: Implement new account menu design
* feat: Add disabled option to IconButton
* feat: Set account menu pane from other component
* feat: Add 2fa account menu pane
feat: Add lock icon
* feat: Remove unnecessary 2FA menu pane
feat: Reset current menu pane on clickOutside
* feat: Change "Log in" to "Sign in"
* feat: Remove sync from footer
* feat: Change "Login" to "Sign in"
feat: Add spinner to "Syncing..."
refactor: Use then-catch-finally for sync
* feat: Use common enableCustomServer state
* feat: Animate account menu closing
* fix: Reset menu pane only after it's closed
* feat: Add keyDown handler to InputWithIcon
* feat: Handle Enter press in inputs
* Update app/assets/javascripts/components/InputWithIcon.tsx
Co-authored-by: Antonella Sgarlatta <[email protected]>
* Update app/assets/javascripts/components/InputWithIcon.tsx
Co-authored-by: Antonella Sgarlatta <[email protected]>
* refactor: Use server state from AccountMenuState
* Update app/assets/javascripts/components/AccountMenu/CreateAccount.tsx
Co-authored-by: Antonella Sgarlatta <[email protected]>
* Update app/assets/javascripts/components/AccountMenu/ConfirmPassword.tsx
Co-authored-by: Antonella Sgarlatta <[email protected]>
* feat: Use common AdvancedOptions
* feat: Add "eye-off" icon and toggle state
* feat: Allow undefined values
* refactor: Remove enableCustomServer state
* feat: Persist server option state
* feat: Add bottom-100 and cursor-auto util classes
refactor: Use bottom-100 and cursor-auto classes
* refactor: Invert ternary operator
* refactor: Remove unused imports
* refactor: Use toggled as prop instead of state
* refactor: Change "Log in/out" to "Sign in/out"
* refactor: Change "Login" to "Sign in"
* refactor: Remove hardcoded width/height
* refactor: Use success class
* feat: Remove hardcoded width & height from svg
* fix: Fix chevron-down icon
Co-authored-by: Antonella Sgarlatta <[email protected]>
Co-authored-by: Antonella Sgarlatta <[email protected]>
138 lines
3.7 KiB
TypeScript
138 lines
3.7 KiB
TypeScript
import { WebApplication } from '@/ui_models/application';
|
|
import { AppState } from '@/ui_models/app_state';
|
|
import { observer } from 'mobx-react-lite';
|
|
import { FunctionComponent } from 'preact';
|
|
import { StateUpdater, useEffect, useRef, useState } from 'preact/hooks';
|
|
import { AccountMenuPane } from '.';
|
|
import { Button } from '../Button';
|
|
import { IconButton } from '../IconButton';
|
|
import { InputWithIcon } from '../InputWithIcon';
|
|
import { AdvancedOptions } from './AdvancedOptions';
|
|
|
|
type Props = {
|
|
appState: AppState;
|
|
application: WebApplication;
|
|
setMenuPane: (pane: AccountMenuPane) => void;
|
|
email: string;
|
|
setEmail: StateUpdater<string>;
|
|
password: string;
|
|
setPassword: StateUpdater<string>;
|
|
};
|
|
|
|
export const CreateAccount: FunctionComponent<Props> = observer(
|
|
({
|
|
appState,
|
|
application,
|
|
setMenuPane,
|
|
email,
|
|
setEmail,
|
|
password,
|
|
setPassword,
|
|
}) => {
|
|
const [showPassword, setShowPassword] = useState(false);
|
|
|
|
const emailInputRef = useRef<HTMLInputElement>();
|
|
const passwordInputRef = useRef<HTMLInputElement>();
|
|
|
|
useEffect(() => {
|
|
if (emailInputRef.current) {
|
|
emailInputRef.current.focus();
|
|
}
|
|
}, []);
|
|
|
|
const handleEmailChange = (e: Event) => {
|
|
if (e.target instanceof HTMLInputElement) {
|
|
setEmail(e.target.value);
|
|
}
|
|
};
|
|
|
|
const handlePasswordChange = (e: Event) => {
|
|
if (e.target instanceof HTMLInputElement) {
|
|
setPassword(e.target.value);
|
|
}
|
|
};
|
|
|
|
const handleKeyDown = (e: KeyboardEvent) => {
|
|
if (e.key === 'Enter') {
|
|
handleRegisterFormSubmit(e);
|
|
}
|
|
};
|
|
|
|
const handleRegisterFormSubmit = (e: Event) => {
|
|
e.preventDefault();
|
|
|
|
if (!email || email.length === 0) {
|
|
emailInputRef?.current.focus();
|
|
return;
|
|
}
|
|
|
|
if (!password || password.length === 0) {
|
|
passwordInputRef?.current.focus();
|
|
return;
|
|
}
|
|
|
|
setEmail(email);
|
|
setPassword(password);
|
|
setMenuPane(AccountMenuPane.ConfirmPassword);
|
|
};
|
|
|
|
const handleClose = () => {
|
|
setMenuPane(AccountMenuPane.GeneralMenu);
|
|
setEmail('');
|
|
setPassword('');
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<div className="flex items-center px-3 mt-1 mb-3">
|
|
<IconButton
|
|
icon="arrow-left"
|
|
title="Go back"
|
|
className="flex mr-2 color-neutral"
|
|
onClick={handleClose}
|
|
focusable={true}
|
|
/>
|
|
<div className="sn-account-menu-headline">Create account</div>
|
|
</div>
|
|
<form onSubmit={handleRegisterFormSubmit} className="px-3 mb-1">
|
|
<InputWithIcon
|
|
className="mb-2"
|
|
icon="email"
|
|
inputType="email"
|
|
placeholder="Email"
|
|
value={email}
|
|
onChange={handleEmailChange}
|
|
onKeyDown={handleKeyDown}
|
|
ref={emailInputRef}
|
|
/>
|
|
<InputWithIcon
|
|
className="mb-2"
|
|
icon="password"
|
|
inputType={showPassword ? 'text' : 'password'}
|
|
placeholder="Password"
|
|
value={password}
|
|
onChange={handlePasswordChange}
|
|
onKeyDown={handleKeyDown}
|
|
toggle={{
|
|
toggleOnIcon: 'eye-off',
|
|
toggleOffIcon: 'eye',
|
|
title: 'Show password',
|
|
toggled: showPassword,
|
|
onClick: setShowPassword,
|
|
}}
|
|
ref={passwordInputRef}
|
|
/>
|
|
<Button
|
|
className="btn-w-full mt-1"
|
|
label="Next"
|
|
type="primary"
|
|
onClick={handleRegisterFormSubmit}
|
|
/>
|
|
</form>
|
|
<div className="h-1px my-2 bg-border"></div>
|
|
<AdvancedOptions application={application} appState={appState} />
|
|
</>
|
|
);
|
|
}
|
|
);
|