Skip to content

Commit

Permalink
[FIX] login input error message & button height (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny-jinn authored Nov 12, 2024
2 parents 11c0266 + be27ea7 commit c31fca0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const LoginModal: FC<Props> = ({ context, ...props }) => {
css={css`
margin-bottom: 20px;
`}
login
/>
<InputBox
name='password'
Expand All @@ -116,6 +117,7 @@ export const LoginModal: FC<Props> = ({ context, ...props }) => {
css={css`
margin-bottom: 40px;
`}
login
/>

<button
Expand Down
26 changes: 18 additions & 8 deletions src/common/InputBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ interface Props {
value?: string
onChange?: (event: ChangeEvent<HTMLInputElement>) => void
readOnly?: boolean // Add readOnly prop here
login?: boolean
}

const InputBoxStyle = {
inputBoxContainer: css`
display: flex;
flex-direction: column;
position: relative;
`,
mb: css`
margin-top: 10px;
`,
labelParagraph: css`
margin-bottom: 5px;
`,
Expand Down Expand Up @@ -121,12 +124,15 @@ const InputBoxStyle = {
content: url(${successIcon});
}
`,
errorMessage: (inputId: string) => css`
opacity: 0;
errorMessage: (inputId: string, login: boolean) => css`
position: absolute;
bottom: -22px;
font-size: 14px;
#${inputId}:invalid:not(:focus)[data-is-touched='true'] ~ &:not(:empty) {
display: inline;
opacity: 1;
${login ? 'opacity: 0;' : 'display: none;'}
#${inputId}:invalid:not(:focus)[data-is-touched='true'] ~ & {
${login ? 'opacity: 1;' : 'display: inline;'}
color: ${Color.Red};
}
`,
Expand All @@ -141,13 +147,17 @@ export const InputBox: FC<Props> = ({
errorMessage,
onChange,
readOnly = false,
login = false,
...props
}) => {
const [input, setInput] = useState('')
const [isTouched, setIsTouched] = useState(false)

return (
<label css={InputBoxStyle.inputBoxContainer} className={className}>
<label
css={[InputBoxStyle.inputBoxContainer, login && InputBoxStyle.mb]}
className={className}
>
<p css={InputBoxStyle.labelParagraph}>
<span css={InputBoxStyle.label}>{label}</span>
<span css={InputBoxStyle.detailedLabel}>{detailedLabel}</span>
Expand All @@ -174,7 +184,7 @@ export const InputBox: FC<Props> = ({
onClick={() => setInput('')}
disabled={readOnly} // Disable discard button when readOnly
/>
<span css={InputBoxStyle.errorMessage(name)}>{errorMessage}</span>
<span css={InputBoxStyle.errorMessage(name, login)}>{errorMessage}</span>
</label>
)
}

0 comments on commit c31fca0

Please sign in to comment.