Skip to content

Commit

Permalink
fix: update adornemnt and use slotprops (#468)
Browse files Browse the repository at this point in the history
* fix: update adornemnt and use slotprops

* fix: rename file

* fix: temp rename file

* fix: use correct file name
  • Loading branch information
spaenleh authored Nov 21, 2024
1 parent d8d89c6 commit b552437
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 32 deletions.
20 changes: 11 additions & 9 deletions src/modules/account/settings/password/PasswordField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ export function PasswordField<T extends string>({

return (
<TextField
InputProps={{
sx: { paddingRight: 0 },
endAdornment: (
<InputAdornment position="end" sx={{ margin: 0 }}>
<IconButton onClick={() => setShowPassword((s) => !s)}>
<Eye />
</IconButton>
</InputAdornment>
),
slotProps={{
input: {
sx: { paddingRight: 0 },
endAdornment: (
<InputAdornment position="end" sx={{ margin: 0 }}>
<IconButton onClick={() => setShowPassword((s) => !s)}>
<Eye />
</IconButton>
</InputAdornment>
),
},
}}
label={label}
variant="outlined"
Expand Down
10 changes: 6 additions & 4 deletions src/modules/account/settings/publicProfile/CustomTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ export function CustomTextField({
rows={rows}
required={required}
multiline={multiline}
InputProps={
slotProps={
Icon && {
startAdornment: (
<InputAdornment position="start">{Icon}</InputAdornment>
),
input: {
startAdornment: (
<InputAdornment position="start">{Icon}</InputAdornment>
),
},
}
}
id={id}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/components/common/PasswordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { NS } from '@/config/constants';

import { AUTH } from '~auth/langs';

import { PasswordAdornment } from './Adornments';
import { StyledTextField } from './StyledTextField';
import { PasswordAdornment } from './adornments';

type Props = {
id: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { InputAdornment } from '@mui/material';

import { LockIcon, MailIcon } from 'lucide-react';
import { LockIcon, MailIcon, UserRoundIcon } from 'lucide-react';

export const EmailAdornment = (
<InputAdornment position="start" color="inherit">
<MailIcon color="currentColor" />
</InputAdornment>
);

export const NameAdornment = (
<InputAdornment position="start" color="inherit">
<UserRoundIcon color="currentColor" />
</InputAdornment>
);

export const PasswordAdornment = (
<InputAdornment position="start" color="inherit">
<LockIcon color="currentColor" />
Expand Down
8 changes: 5 additions & 3 deletions src/modules/auth/components/register/EmailInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { NS } from '@/config/constants';
import { AUTH } from '~auth/langs';
import { emailValidator } from '~auth/validation';

import { EmailAdornment } from '../common/Adornments';
import { StyledTextField } from '../common/StyledTextField';
import { EmailAdornment } from '../common/adornments';

type Props = {
required?: boolean;
Expand Down Expand Up @@ -52,8 +52,10 @@ export function EmailInput({

return (
<StyledTextField
InputProps={{
startAdornment: EmailAdornment,
slotProps={{
input: {
startAdornment: EmailAdornment,
},
}}
variant="outlined"
value={value}
Expand Down
8 changes: 5 additions & 3 deletions src/modules/auth/components/register/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import { useMobileAppLogin } from '~auth/hooks/useMobileAppLogin';
import { AUTH } from '~auth/langs';
import { emailValidator, nameValidator } from '~auth/validation';

import { EmailAdornment } from '../common/Adornments';
import { ErrorDisplay } from '../common/ErrorDisplay';
import { FormHeader } from '../common/FormHeader';
import { StyledTextField } from '../common/StyledTextField';
import { NameAdornment } from '../common/adornments';
import { AgreementForm } from '../register/AgreementForm';
import { EmailInput } from './EmailInput';
import { EnableAnalyticsForm } from './EnableAnalyticsForm';
Expand Down Expand Up @@ -162,8 +162,10 @@ export function Register({ search }: RegisterProps) {
<FormControl>
<Stack direction="column" spacing={1}>
<StyledTextField
InputProps={{
startAdornment: EmailAdornment,
slotProps={{
input: {
startAdornment: NameAdornment,
},
}}
required
placeholder={t(NAME_FIELD_LABEL)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { HELP_EMAIL } from '~auth/constants';
import { AUTH } from '~auth/langs';

import { useRecaptcha } from '../../context/RecaptchaContext';
import { EmailAdornment } from '../common/Adornments';
import { EmailAdornment } from '../common/adornments';
import { CenteredContent } from '../layout/CenteredContent';
import { DialogHeader } from '../layout/DialogHeader';

Expand Down Expand Up @@ -79,11 +79,13 @@ export function RequestPasswordReset() {
validate: (email) =>
isEmail(email, {}) || t(AUTH.INVALID_EMAIL_ERROR),
})}
FormHelperTextProps={{
id: REQUEST_PASSWORD_RESET_EMAIL_FIELD_HELPER_ID,
}}
InputProps={{
startAdornment: EmailAdornment,
slotProps={{
input: {
startAdornment: EmailAdornment,
},
formHelperText: {
id: REQUEST_PASSWORD_RESET_EMAIL_FIELD_HELPER_ID,
},
}}
placeholder={t(AUTH.EMAIL_INPUT_PLACEHOLDER)}
helperText={errorMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { HELP_EMAIL } from '~auth/constants';
import { useValidateJWTToken } from '~auth/hooks/useValidateJWTToken';
import { AUTH } from '~auth/langs';

import { PasswordAdornment } from '../common/Adornments';
import { PasswordAdornment } from '../common/adornments';
import { CenteredContent } from '../layout/CenteredContent';
import { DialogHeader } from '../layout/DialogHeader';
import { InvalidTokenScreen } from './InvalidTokenScreen';
Expand Down
8 changes: 5 additions & 3 deletions src/modules/auth/components/signIn/EmailInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useTranslation } from 'react-i18next';

import { NS } from '@/config/constants';

import { EmailAdornment } from '../common/Adornments';
import { StyledTextField } from '../common/StyledTextField';
import { EmailAdornment } from '../common/adornments';

type Props = {
id?: string;
Expand All @@ -28,8 +28,10 @@ export function EmailInput({
return (
<StyledTextField
id={id}
InputProps={{
startAdornment: EmailAdornment,
slotProps={{
input: {
startAdornment: EmailAdornment,
},
}}
variant="outlined"
error={Boolean(error)}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/auth/reset-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ButtonLink } from '@/components/ui/ButtonLink';
import { TypographyLink } from '@/components/ui/TypographyLink';
import { NS } from '@/config/constants';

import { PasswordAdornment } from '~auth/components/common/Adornments';
import { PasswordAdornment } from '~auth/components/common/adornments';
import { CenteredContent } from '~auth/components/layout/CenteredContent';
import { DialogHeader } from '~auth/components/layout/DialogHeader';
import { InvalidTokenScreen } from '~auth/components/requestPasswordReset/InvalidTokenScreen';
Expand Down

0 comments on commit b552437

Please sign in to comment.