Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Variants and Action layout. Changed Buttons components #45

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
29 changes: 29 additions & 0 deletions src/components/Buttons/MainButton/MainButton.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.main-button {
background-color: $wide-button-bg-color-default;
color: $wide-button-text-color-default;
width: 100%;
border-radius: 48px;
border: none;
transition: box-shadow, background-color, 0.1s;

&__size {
&--default {
height: 40px;
}

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

&:hover {
box-shadow: $wide-button-box-shadow-on-hover;
}

&:active {
color: $wide-button-text-color-on-click;
border: $wide-button-border-on-click;
background-color: $wide-button-bg-color-on-click;
box-shadow: none;
}
}
28 changes: 28 additions & 0 deletions src/components/Buttons/MainButton/MainButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import styles from './MainButton.module.scss';
import classNames from 'classnames';
import { ButtonSize } from '../../../utils/types/ButtonSize';

type Props = {
onClick?: () => void;
label: string;
size: Exclude<ButtonSize, ButtonSize.Small>;
};

export const MainButton: React.FC<Props> = ({
label,
onClick = () => {},
size,
}) => {
return (
<button
className={classNames('button', styles['main-button'], {
[styles['main-button__size--default']]: size === ButtonSize.Default,
[styles['main-button__size--large']]: size === ButtonSize.Large,
})}
onClick={onClick}
>
{label}
</button>
);
};
1 change: 1 addition & 0 deletions src/components/Buttons/MainButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './MainButton';
Loading
Loading