Skip to content

Commit

Permalink
Adding disabled button to account and registration pages
Browse files Browse the repository at this point in the history
  • Loading branch information
camilovegag committed Apr 19, 2024
1 parent 98f5399 commit 3c91374
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions packages/berlin/src/components/button/Button.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export const StyledButton = styled.button<StyledButtonProps>`
padding-inline: 1rem;
text-transform: uppercase;
&:disabled {
background-color: var(--color-gray);
cursor: not-allowed;
&:hover {
opacity: 1;
}
}
${(props) =>
props.$color === 'primary' &&
css`
Expand Down
6 changes: 4 additions & 2 deletions packages/berlin/src/pages/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function AccountForm({
const {
control,
register,
formState: { errors, isValid },
formState: { errors, isValid, isSubmitting },
handleSubmit,
setValue,
reset,
Expand Down Expand Up @@ -474,7 +474,9 @@ function AccountForm({
icon={{ src: `/icons/add-${theme}.svg`, alt: 'Add icon' }}
/>
</FlexColumn>
<Button type="submit">Submit</Button>
<Button type="submit" disabled={isSubmitting}>
Submit
</Button>
</FlexColumn>
</form>
</FlexColumn>
Expand Down
6 changes: 4 additions & 2 deletions packages/berlin/src/pages/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function RegisterForm(props: {

const {
register,
formState: { errors },
formState: { errors, isSubmitting },
control,
handleSubmit,
getValues,
Expand Down Expand Up @@ -354,7 +354,9 @@ function RegisterForm(props: {
))}
</FlexColumn>
</form>
<Button onClick={handleSubmit(onSubmit)}>Save</Button>
<Button onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
Save
</Button>
<Body>
Need more time? Feel free to come back to these questions later. The deadline is May 15th.
</Body>
Expand Down

0 comments on commit 3c91374

Please sign in to comment.