Skip to content

Commit

Permalink
upd Form, Button
Browse files Browse the repository at this point in the history
- Add disabled Button
- Del link Button
- Add disabled Form
  • Loading branch information
seelentov committed Jul 29, 2024
1 parent 15027c2 commit 3404960
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export const Form = ({ type = 'default' }) => {
}
};

const enabledButton = Object.values(formData).every(field => field.trim() != "") && token != ""

return (
<form className={cn(styles.form, type === 'default' && styles.default) + " modal-form"}>
{type === 'default' &&
Expand Down Expand Up @@ -101,8 +103,8 @@ export const Form = ({ type = 'default' }) => {
/>}


<Button dubleText='Отправить' onClick={handleSubmit}>
<YMClick child="Отправить" name="form_action" metrik_id={96723379} styleNest="display: inline" />
<Button dubleText='Отправить' onClick={handleSubmit} disabled={!enabledButton}>
Отправить
</Button>
</form>
)
Expand Down
10 changes: 10 additions & 0 deletions src/components/UI/Button/Button.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.main:disabled{
opacity: 0.5;
pointer-events: none;
&:hover {
.textHover {
width: 0%;
}
}
}

.main {
background-color: var(--color_main-text);
border: 2px var(--color_main-text) solid;
Expand Down
7 changes: 4 additions & 3 deletions src/components/UI/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { FC, HTMLAttributes } from 'react';
import styles from './Button.module.scss';

export interface IButtonProps extends HTMLAttributes<HTMLButtonElement> {
dubleText?: string
dubleText?: string,
disabled?: boolean
}

export const Button: FC<IButtonProps> = ({ children, dubleText="", ...rest }) => {
export const Button: FC<IButtonProps> = ({ children, dubleText="", disabled = false, ...rest }) => {
return (
<button className={styles.main} {...rest}>
<button className={styles.main} disabled={disabled} {...rest}>
<noindex>
<span className={styles.textHover}>
<span>{children}</span>
Expand Down

0 comments on commit 3404960

Please sign in to comment.