Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Pashin committed Nov 30, 2023
1 parent 1478406 commit f8db570
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/shared/types/commonTypes.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export type AnyFunctional = (...args: any[]) => any;

Check warning on line 1 in src/shared/types/commonTypes.ts

View workflow job for this annotation

GitHub Actions / pipeline (17.x)

Unexpected any. Specify a different type
export type ComponentWithClassNameProp = { className?: string };
export type Optional<T> = {
[P in keyof T]?: T[P]
};
11 changes: 6 additions & 5 deletions src/shared/ui/Button/ButtonGeneral/ButtonGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ export type ButtonGeneralProps =
GeneralButtonSquare | GeneralAnchorSquare | GeneralLinkSquare | GeneralButtonIcon;

export const ButtonGeneral: FC<ButtonGeneralProps> = (props) => {
const nessaryProps: CommonButtonUIProps = {
size: 'm',
};

const {
children,
typeButton,
} = props;

switch (props.typeButton) {
const nessaryProps: CommonButtonUIProps = {
size: 'm',
};

switch (typeButton) {
case 'ButtonSquare':
return (
<ButtonSquare {...props} {...nessaryProps}>
Expand Down
7 changes: 5 additions & 2 deletions src/shared/ui/Button/ButtonIconUI/ButtonIconUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ export interface ButtonIconUIProps extends CommonButtonUIProps {
}

export const ButtonIconUI: FC<ButtonIconUIProps> = ({
children, round, classNameButton, ...restProps
children, round, classNameButton, disabled, invertedTheme, nonInteractive, size,
}) => (
<div
className={classNames(
s.buttonIconUI,
round && s.round,
classNameButton,
s[size],
disabled && s.disabled,
invertedTheme && s.invertedTheme,
nonInteractive && s.nonInteractive,
)}
{...restProps}
>
{children}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/shared/ui/Button/ButtonSquare/ButtonSquare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const ButtonSquare: FC<ButtonSquareProps> = ({
}) => (
<ButtonWrapper
classNameWrapper={classNameWrapper}
disabled={disabled || isLoading}
disabled={disabled}
nonInteractive={nonInteractive}
{...restProps}
>
<ButtonSquareUI
Expand Down
10 changes: 4 additions & 6 deletions src/shared/ui/Button/ButtonWrapper/ButtonWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { ComponentPropsWithoutRef, FC, ReactNode } from 'react';
import { Wrapper } from '../Wrapper/Wrapper';
import { ComponentPropsWithoutRef, FC } from 'react';
import { Optional } from 'shared/types/commonTypes';
import { Wrapper, WrapperProps } from '../Wrapper/Wrapper';

export interface ButtonWrapperProps extends Omit<ComponentPropsWithoutRef<'button'>, 'className'> {
children: ReactNode;
classNameWrapper?: string;
}
export interface ButtonWrapperProps extends Omit<ComponentPropsWithoutRef<'button'>, 'className' | 'children'>, Optional<WrapperProps> {}

export const ButtonWrapper: FC<ButtonWrapperProps> = ({ children, ...restProps }) => (
<Wrapper
Expand Down
4 changes: 4 additions & 0 deletions src/shared/ui/Button/Wrapper/Wrapper.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
display: block;
text-decoration: none;
}

.nonInteractive {
pointer-events: none;
}
8 changes: 6 additions & 2 deletions src/shared/ui/Button/Wrapper/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ export type WrapperProps = {
tag: WrapperTags;
children: React.ReactNode;
classNameWrapper?: string,
nonInteractive?: boolean,
disabled?: boolean,
// TODO: Fix
typeButton?: any,
};

export const Wrapper: FC<WrapperProps> = ({
children, tag = 'button', classNameWrapper, ...restProps
children, tag = 'button', classNameWrapper, disabled, nonInteractive, typeButton, ...restProps
}) => {
if (tag === 'a') {
const restPropsCopy = { ...restProps } as WrapperAttributes['a'];
Expand All @@ -42,7 +46,7 @@ export const Wrapper: FC<WrapperProps> = ({

const restPropsCopy = { ...restProps } as WrapperAttributes['button'];
return (
<button className={classNames(s.button, classNameWrapper)} type="button" {...restPropsCopy}>
<button disabled={disabled} className={classNames(s.button, classNameWrapper, nonInteractive && s.nonInteractive)} type="button" {...restPropsCopy}>
{children}
</button>
);
Expand Down

0 comments on commit f8db570

Please sign in to comment.