From 8dc53e9b27898634cbe9b07de8456913d839bba0 Mon Sep 17 00:00:00 2001 From: Christiaan Scheermeijer Date: Wed, 21 Jul 2021 17:29:53 +0200 Subject: [PATCH] feat(auth): connect login form with MediaStore API --- package.json | 2 +- src/components/Button/Button.module.scss | 60 ++++++++------ src/components/Button/Button.tsx | 7 +- src/components/Form/Form.tsx | 4 +- .../Form/__snapshots__/Form.test.tsx.snap | 4 +- .../LoginForm/LoginForm.module.scss | 10 +++ src/components/LoginForm/LoginForm.test.tsx | 2 +- src/components/LoginForm/LoginForm.tsx | 51 +++++------- .../__snapshots__/LoginForm.test.tsx.snap | 1 + .../TextField/TextField.module.scss | 2 +- src/containers/AccountModal/AccountModal.tsx | 5 +- src/containers/AccountModal/forms/Login.tsx | 45 ++++++++++ src/hooks/useForm.ts | 82 +++++++++++++++++++ src/i18n/locales/en_US/account.json | 6 +- src/i18n/locales/nl_NL/account.json | 6 +- src/styles/_theme.scss | 3 + types/account.d.ts | 5 ++ 17 files changed, 231 insertions(+), 64 deletions(-) create mode 100644 src/containers/AccountModal/forms/Login.tsx create mode 100644 src/hooks/useForm.ts diff --git a/package.json b/package.json index b2f32834c..38fa240ca 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "test": "jest", "test-watch": "jest --watch", "test-coverage": "jest --coverage", - "i18next": "i18next src/{components,containers,screens}/**/*.tsx && node ./scripts/i18next/generate.js", + "i18next": "i18next src/{components,containers,screens}/**/{**/,/}*.tsx && node ./scripts/i18next/generate.js", "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"", "lint": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"", "lint:styles": "stylelint \"src/**/*.scss\"", diff --git a/src/components/Button/Button.module.scss b/src/components/Button/Button.module.scss index df597c78d..c721a5d99 100644 --- a/src/components/Button/Button.module.scss +++ b/src/components/Button/Button.module.scss @@ -26,18 +26,27 @@ $large-button-height: 40px; transition: background-color 0.1s ease, transform 0.1s ease; @media (hover: hover) and (pointer: fine) { - &:hover, - &:focus { - transform: scale(1.1); - } - &:focus:not(:focus-visible):not(:hover) { - transform: scale(1); - } - &:focus-visible { - transform: scale(1.1); + &:not(.disabled) { + &:hover, + &:focus { + transform: scale(1.1); + } + + &:focus:not(:focus-visible):not(:hover) { + transform: scale(1); + } + + &:focus-visible { + transform: scale(1.1); + } } } + &.disabled { + cursor: default; + opacity: 0.7; + } + &.large { height: $large-button-height; } @@ -55,11 +64,13 @@ $large-button-height: 40px; &.outlined { border: 1px solid rgba(255, 255, 255, 0.3); - &.active, - &:focus { - color: var(--highlight-contrast-color, theme.$btn-primary-color); - background-color: var(--highlight-color, theme.$btn-primary-bg); - border-color: var(--highlight-color, theme.$btn-primary-bg); + &:not(.disabled) { + &.active, + &:focus { + color: var(--highlight-contrast-color, theme.$btn-primary-color); + background-color: var(--highlight-color, theme.$btn-primary-bg); + border-color: var(--highlight-color, theme.$btn-primary-bg); + } } } @@ -67,14 +78,17 @@ $large-button-height: 40px; background: none; opacity: 0.7; - &.active, - &:focus { - opacity: 1; - } - &:hover { - z-index: 1; - background: theme.$btn-default-bg; - opacity: 1; + &:not(.disabled) { + &.active, + &:focus { + opacity: 1; + } + + &:hover { + z-index: 1; + background: theme.$btn-default-bg; + opacity: 1; + } } } @@ -83,7 +97,7 @@ $large-button-height: 40px; width: 100%; @media (hover: hover) and (pointer: fine) { - &:hover { + &:hover:not(.disabled) { transform: scale(1.04); } } diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index c7349cfc5..b11956bdb 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -22,6 +22,8 @@ type Props = { to?: string; role?: string; className?: string; + type?: 'button' | 'submit' | 'reset'; + disabled?: boolean; } & React.AriaAttributes; const Button: React.FC = ({ @@ -33,6 +35,8 @@ const Button: React.FC = ({ active = false, variant = 'outlined', size = 'medium', + disabled, + type, to, onClick, className, @@ -42,6 +46,7 @@ const Button: React.FC = ({ [styles.active]: active, [styles.fullWidth]: fullWidth, [styles.large]: size === 'large', + [styles.disabled]: disabled, }); const icon = startIcon ?
{startIcon}
: null; @@ -54,7 +59,7 @@ const Button: React.FC = ({ {children} ) : ( -