From 4f56c453cb38faf51f080b98b29983c7439a5a7d Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Mon, 1 Nov 2021 19:49:06 +0530 Subject: [PATCH] feat: Update "Change Email" and "Change Password" modal designs (#714) * feat: Add new utility classes * feat: Update "Change Email" modal design * feat: Use .sk-input.contrast className to mimic password wizard inputs * feat: Add explicit labels to password wizard inputs * feat: Make button sizing consistent * refactor: Remove unused dependencies * refactor: Remove unused component --- .../components/shared/ModalDialog.tsx | 45 +++-- .../account/changeEmail/ChangeEmailForm.tsx | 64 +++--- .../panes/account/changeEmail/index.tsx | 17 +- .../changePassword/ChangePasswordForm.tsx | 45 ----- .../changePassword/ChangePasswordSuccess.tsx | 12 -- .../panes/account/changePassword/index.tsx | 189 ------------------ app/assets/stylesheets/_sn.scss | 10 + .../templates/directives/password-wizard.pug | 12 +- 8 files changed, 86 insertions(+), 308 deletions(-) delete mode 100644 app/assets/javascripts/preferences/panes/account/changePassword/ChangePasswordForm.tsx delete mode 100644 app/assets/javascripts/preferences/panes/account/changePassword/ChangePasswordSuccess.tsx delete mode 100644 app/assets/javascripts/preferences/panes/account/changePassword/index.tsx diff --git a/app/assets/javascripts/components/shared/ModalDialog.tsx b/app/assets/javascripts/components/shared/ModalDialog.tsx index d1888090a..e2a46a27a 100644 --- a/app/assets/javascripts/components/shared/ModalDialog.tsx +++ b/app/assets/javascripts/components/shared/ModalDialog.tsx @@ -5,7 +5,6 @@ import { AlertDialogLabel, } from '@node_modules/@reach/alert-dialog'; import { useRef } from '@node_modules/preact/hooks'; -import { IconButton } from '@/components/IconButton'; export const ModalDialog: FunctionComponent = ({ children }) => { const ldRef = useRef(null); @@ -19,7 +18,7 @@ export const ModalDialog: FunctionComponent = ({ children }) => {
{children}
@@ -30,17 +29,20 @@ export const ModalDialog: FunctionComponent = ({ children }) => { export const ModalDialogLabel: FunctionComponent<{ closeDialog: () => void; -}> = ({ children, closeDialog }) => ( - -
-
{children}
- closeDialog()} - /> + className?: string; +}> = ({ children, closeDialog, className }) => ( + +
+
+ {children} +
+
+ Close +

@@ -55,17 +57,20 @@ export const ModalDialogDescription: FunctionComponent<{ className?: string }> = ); -export const ModalDialogButtons: FunctionComponent = ({ children }) => ( +export const ModalDialogButtons: FunctionComponent<{ className?: string }> = ({ + children, + className, +}) => ( <>
-
+
{children != undefined && Array.isArray(children) ? children.map((child, idx, arr) => ( - <> - {child} - {idx < arr.length - 1 ?
: undefined} - - )) + <> + {child} + {idx < arr.length - 1 ?
: undefined} + + )) : children}
diff --git a/app/assets/javascripts/preferences/panes/account/changeEmail/ChangeEmailForm.tsx b/app/assets/javascripts/preferences/panes/account/changeEmail/ChangeEmailForm.tsx index c1f8ed7e3..9c6b8344a 100644 --- a/app/assets/javascripts/preferences/panes/account/changeEmail/ChangeEmailForm.tsx +++ b/app/assets/javascripts/preferences/panes/account/changeEmail/ChangeEmailForm.tsx @@ -1,37 +1,47 @@ -import { DecoratedInput } from '@/components/DecoratedInput'; import { StateUpdater } from 'preact/hooks'; import { FunctionalComponent } from 'preact'; -import { HtmlInputTypes } from '@/enums'; type Props = { - setNewEmail: StateUpdater - setCurrentPassword: StateUpdater -} + setNewEmail: StateUpdater; + setCurrentPassword: StateUpdater; +}; + +const labelClassName = `block mb-1`; + +const inputClassName = 'sk-input contrast'; + export const ChangeEmailForm: FunctionalComponent = ({ setNewEmail, - setCurrentPassword + setCurrentPassword, }) => { return ( - ( - <> -
- { - setNewEmail(newEmail); - }} - placeholder={'New Email'} - /> -
-
- { - setCurrentPassword(currentPassword); - }} - placeholder={'Current Password'} - /> -
- - ) +
+
+ + { + setNewEmail((target as HTMLInputElement).value); + }} + /> +
+
+ + { + setCurrentPassword((target as HTMLInputElement).value); + }} + /> +
+
); }; diff --git a/app/assets/javascripts/preferences/panes/account/changeEmail/index.tsx b/app/assets/javascripts/preferences/panes/account/changeEmail/index.tsx index 6569d2216..10e787053 100644 --- a/app/assets/javascripts/preferences/panes/account/changeEmail/index.tsx +++ b/app/assets/javascripts/preferences/panes/account/changeEmail/index.tsx @@ -154,10 +154,13 @@ export const ChangeEmail: FunctionalComponent = ({ return (
- + Change Email - + {currentStep === Steps.InitialStep && ( = ({ )} {currentStep === Steps.FinishStep && } - - {currentStep === Steps.InitialStep && ( -
- ); -}; diff --git a/app/assets/stylesheets/_sn.scss b/app/assets/stylesheets/_sn.scss index 9deeee95e..88f373760 100644 --- a/app/assets/stylesheets/_sn.scss +++ b/app/assets/stylesheets/_sn.scss @@ -427,6 +427,12 @@ padding-right: 0; } +.sn-component .px-4\.5, +.sn-component .sk-panel .px-4\.5 { + padding-left: 1.375rem; + padding-right: 1.375rem; +} + .px-9 { padding-left: 2.25rem; padding-right: 2.25rem; @@ -648,3 +654,7 @@ .list-style-none { list-style-type: none; } + +.rounded-0\.5 { + border-radius: 0.125rem; +} diff --git a/app/assets/templates/directives/password-wizard.pug b/app/assets/templates/directives/password-wizard.pug index 25dcb4a3d..9efa61e4f 100644 --- a/app/assets/templates/directives/password-wizard.pug +++ b/app/assets/templates/directives/password-wizard.pug @@ -12,24 +12,28 @@ .sk-panel-row .sk-panel-column.stretch form.sk-panel-form + label.block.mb-1(for='password-wiz-current-password') Current Password: input.sk-input.contrast( + id='password-wiz-current-password' ng-model='ctrl.state.formData.currentPassword', - placeholder='Current Password', should-focus='true', sn-autofocus='true', type='password' ) .sk-panel-row + label.block.mb-1(for='password-wiz-new-password') New Password: input.sk-input.contrast( + id='password-wiz-new-password', ng-if='ctrl.props.changePassword', ng-model='ctrl.state.formData.newPassword', - placeholder='New Password', type='password' ) + .sk-panel-row + label.block.mb-1(for='password-wiz-confirm-new-password') Confirm New Password: input.sk-input.contrast( + id='password-wiz-confirm-new-password', ng-if='ctrl.props.changePassword', ng-model='ctrl.state.formData.newPasswordConfirmation', - placeholder='Confirm New Password', type='password' ) .sk-panel-section(ng-if='ctrl.state.step == 2') @@ -41,7 +45,7 @@ | Please ensure you are running the latest version of Standard Notes | on all platforms to ensure maximum compatibility. .sk-panel-footer - button.sn-button.small.info( + button.sn-button.min-w-20.info( ng-click='ctrl.nextStep()', ng-disabled='ctrl.state.lockContinue' ) {{ctrl.state.continueTitle}}