Skip to content

Commit

Permalink
Merge branch 'develop' into feature/implement-redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
k-marchuk authored Sep 23, 2024
2 parents 0199829 + bf7605e commit 9a7e472
Show file tree
Hide file tree
Showing 68 changed files with 1,096 additions and 357 deletions.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@reduxjs/toolkit": "^2.2.7",
"@types/react-redux": "^7.1.33",
"@types/redux": "^3.6.31",
"animejs": "^3.2.2",
"classnames": "^2.5.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand All @@ -24,6 +25,7 @@
},
"devDependencies": {
"@eslint/js": "^9.10.0",
"@types/animejs": "^3.1.12",
"@types/node": "^22.5.5",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
Expand Down
38 changes: 38 additions & 0 deletions src/components/Buttons/Button/Button.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.button {
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;

&__size {
&--small {
height: 32px;
width: 32px;
min-width: 32px;
}

&--default {
height: 40px;
width: 40px;
min-width: 40px;
}

&--large {
height: 48px;
width: 48px;
min-width: 48px;
}
}

&__shape {
&--circle {
border-radius: 48px;
}

&--rectangle {
border-radius: 4px;
width: auto;
padding: 8px;
}
}
}
36 changes: 36 additions & 0 deletions src/components/Buttons/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { ReactNode } from 'react';
import styles from './Button.module.scss';
import classNames from 'classnames';
import { ButtonSize } from '../../../utils/types/ButtonSize';
import { ButtonShape } from '../../../utils/types/ButtonShape';

type Props = {
children: ReactNode;
className: string;
onClick?: () => void;
size?: ButtonSize;
shape?: ButtonShape;
};

export const Button: React.FC<Props> = ({
children,
className,
size = ButtonSize.Default,
shape = ButtonShape.Circle,
onClick = () => {},
}) => {
return (
<button
className={classNames(styles.button, className, {
[styles['button__size--small']]: size === ButtonSize.Small,
[styles['button__size--default']]: size === ButtonSize.Default,
[styles['button__size--large']]: size === ButtonSize.Large,
[styles['button__shape--circle']]: shape === ButtonShape.Circle,
[styles['button__shape--rectangle']]: shape === ButtonShape.Rectangle,
})}
onClick={onClick}
>
{children}
</button>
);
};
1 change: 1 addition & 0 deletions src/components/Buttons/Button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Button';
19 changes: 19 additions & 0 deletions src/components/Buttons/ButtonWithColor/ButtonWithColor.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.button-with-color {
border: $button-with-color-border;
overflow: hidden;
padding: 3px;

&__element {
width: 100%;
height: 100%;
border-radius: 50%;

&--selected {
border-color: $primary-color;
}
}

&:hover {
border-color: $icons-color;
}
}
36 changes: 36 additions & 0 deletions src/components/Buttons/ButtonWithColor/ButtonWithColor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import classNames from 'classnames';
import { Button } from '../Button';
import styles from './ButtonWithColor.module.scss';
import colorsMap from '../../../utils/constants/colorsMap.json';
import { ProductColor } from '../../../utils/types/ProductColor';
import React from 'react';
import { ButtonSize } from '../../../utils/types/ButtonSize';

type Props = {
isSelected: boolean;
color: ProductColor;
onClick?: () => void;
size: ButtonSize;
};

export const ButtonWithColor: React.FC<Props> = ({
isSelected,
color,
onClick,
size,
}) => {
return (
<Button
onClick={onClick}
className={classNames(styles['button-with-color'], {
[styles['button-with-color__element--selected']]: isSelected,
})}
size={size}
>
<div
className={styles['button-with-color__element']}
style={{ backgroundColor: colorsMap[color] }}
></div>
</Button>
);
};
1 change: 1 addition & 0 deletions src/components/Buttons/ButtonWithColor/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ButtonWithColor';
16 changes: 16 additions & 0 deletions src/components/Buttons/ButtonWithImage/ButtonWithImage.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.button-with-image {
border: $button-border-default;

&__image {
width: 16px;
height: 16px;
}

&--selected {
border-color: $elemnts-color;
}

&:hover {
border-color: $primary-color;
}
}
31 changes: 31 additions & 0 deletions src/components/Buttons/ButtonWithImage/ButtonWithImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import classNames from 'classnames';
import { Button } from '../Button';
import styles from './ButtonWithImage.module.scss';
import React from 'react';
import { ButtonSize } from '../../../utils/types/ButtonSize';

type Props = {
isSelected: boolean;
path: string;
onClick?: () => void;
size: ButtonSize;
};

export const ButtonWithImage: React.FC<Props> = ({
path,
size,
onClick,
isSelected,
}) => {
return (
<Button
onClick={onClick}
className={classNames(styles['button-with-image'], {
[styles['button-with-image--selected']]: isSelected,
})}
size={size}
>
<img src={path} alt="" className={styles['button-with-image__image']} />
</Button>
);
};
1 change: 1 addition & 0 deletions src/components/Buttons/ButtonWithImage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ButtonWithImage';
14 changes: 14 additions & 0 deletions src/components/Buttons/ButtonWithText/ButtonWithText.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.button-with-text {
border: $button-with-color-border;
font-weight: 600;

&--selected {
border-color: $primary-color;
background-color: $primary-color;
color: $white-color;
}

&:hover {
border-color: $primary-color;
}
}
35 changes: 35 additions & 0 deletions src/components/Buttons/ButtonWithText/ButtonWithText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import classNames from 'classnames';
import { Button } from '../Button';
import styles from './ButtonWithText.module.scss';
import React from 'react';
import { ButtonSize } from '../../../utils/types/ButtonSize';
import { ButtonShape } from '../../../utils/types/ButtonShape';

type Props = {
isSelected: boolean;
shape: ButtonShape;
label: string;
onClick?: () => void;
size: ButtonSize;
};

export const ButtonWithText: React.FC<Props> = ({
shape,
label,
isSelected,
size,
onClick,
}) => {
return (
<Button
shape={shape}
size={size}
onClick={onClick}
className={classNames(styles['button-with-text'], {
[styles['button-with-text--selected']]: isSelected,
})}
>
{label}
</Button>
);
};
1 change: 1 addition & 0 deletions src/components/Buttons/ButtonWithText/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ButtonWithText';
66 changes: 0 additions & 66 deletions src/components/Buttons/Buttons.module.scss

This file was deleted.

25 changes: 25 additions & 0 deletions src/components/Buttons/FavoriteButton/FavoriteButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import heart from '../../../img/headerIcon/like.png';
import heartSelected from '../../../img/heartOnClick.png';
import React, { useState } from 'react';
import { ButtonWithImage } from '../ButtonWithImage';
import { ButtonSize } from '../../../utils/types/ButtonSize';

type Props = {
size: ButtonSize;
};

export const FavoriteButton: React.FC<Props> = ({ size }) => {
const isDefaultSelected = false;
const [isSelected, setIsSelected] = useState(isDefaultSelected);

return (
<ButtonWithImage
onClick={() => {
setIsSelected(!isSelected);
}}
size={size}
path={isSelected ? heartSelected : heart}
isSelected={isSelected}
/>
);
};
1 change: 1 addition & 0 deletions src/components/Buttons/FavoriteButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './FavoriteButton';
Loading

0 comments on commit 9a7e472

Please sign in to comment.