fix: Правки внешнего вида кода линтером
This commit is contained in:
@@ -1,18 +1,26 @@
|
|||||||
.button {
|
.button {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
border: none;
|
align-items: center;
|
||||||
background: transparent;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
outline: none;
|
|
||||||
font-family: var(--font-family-main);
|
font-family: var(--font-family-main);
|
||||||
|
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
outline: none;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
&:disabled {
|
&:disabled {
|
||||||
opacity: 0.5;
|
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
|
|
||||||
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variants
|
// Variants
|
||||||
@@ -22,33 +30,39 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.regular {
|
&.regular {
|
||||||
border-radius: 1em;
|
|
||||||
padding: 0.5em 1em;
|
padding: 0.5em 1em;
|
||||||
|
|
||||||
|
border-radius: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sizes
|
// Sizes
|
||||||
&.small {
|
&.small {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.medium {
|
&.medium {
|
||||||
height: 50px;
|
height: 50px;
|
||||||
|
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.large {
|
&.large {
|
||||||
height: 60px;
|
height: 60px;
|
||||||
|
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color Schemes
|
// Color Schemes
|
||||||
&.primary {
|
&.primary {
|
||||||
$color-primary: var(--color-primary);
|
$color-primary: var(--color-primary);
|
||||||
background-color: transparent;
|
|
||||||
color: $color-primary;
|
color: $color-primary;
|
||||||
|
|
||||||
border: 1px solid $color-primary;
|
border: 1px solid $color-primary;
|
||||||
|
|
||||||
|
background-color: transparent;
|
||||||
|
|
||||||
&:hover:not(:disabled) {
|
&:hover:not(:disabled) {
|
||||||
background-color: var(--color-white);
|
background-color: var(--color-white);
|
||||||
}
|
}
|
||||||
@@ -56,22 +70,26 @@
|
|||||||
|
|
||||||
&.secondary {
|
&.secondary {
|
||||||
$color-blue: var(--color-blue);
|
$color-blue: var(--color-blue);
|
||||||
background-color: var(--color-white);
|
|
||||||
color: $color-blue;
|
color: $color-blue;
|
||||||
box-shadow: 0px 0px 15px rgb($color-blue / 10%);
|
|
||||||
|
background-color: var(--color-white);
|
||||||
|
|
||||||
|
box-shadow: 0 0 15px rgb($color-blue / 10%);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Icon handling
|
// Icon handling
|
||||||
.icon {
|
.icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
height: 40%;
|
height: 40%;
|
||||||
|
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,38 @@
|
|||||||
import type { Meta, StoryObj } from '@storybook/react'
|
|
||||||
import { Button } from './Button'
|
|
||||||
import ChevronLeftIcon from '@/shared/assets/chevron--left.svg'
|
import ChevronLeftIcon from '@/shared/assets/chevron--left.svg'
|
||||||
|
|
||||||
|
import { Button } from './Button'
|
||||||
|
|
||||||
|
import type { Meta, StoryObj } from '@storybook/react'
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
title: 'Shared/Button',
|
title: 'Shared/Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
parameters: {
|
parameters: {
|
||||||
layout: 'centered',
|
layout: 'centered',
|
||||||
|
},
|
||||||
|
tags: ['autodocs'],
|
||||||
|
argTypes: {
|
||||||
|
variant: {
|
||||||
|
control: 'select',
|
||||||
|
options: ['round', 'regular'],
|
||||||
|
description: 'Вариант внешнего вида',
|
||||||
},
|
},
|
||||||
tags: ['autodocs'],
|
size: {
|
||||||
argTypes: {
|
control: 'select',
|
||||||
variant: {
|
options: ['small', 'medium', 'large'],
|
||||||
control: 'select',
|
description: 'Размер кнопки',
|
||||||
options: ['round', 'regular'],
|
|
||||||
description: 'Вариант внешнего вида',
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
control: 'select',
|
|
||||||
options: ['small', 'medium', 'large'],
|
|
||||||
description: 'Размер кнопки',
|
|
||||||
},
|
|
||||||
colorScheme: {
|
|
||||||
control: 'select',
|
|
||||||
options: ['primary', 'secondary'],
|
|
||||||
description: 'Цветовая схема',
|
|
||||||
},
|
|
||||||
disabled: {
|
|
||||||
control: 'boolean',
|
|
||||||
description: 'Активность кнопки',
|
|
||||||
},
|
|
||||||
onClick: { action: 'clicked' },
|
|
||||||
},
|
},
|
||||||
|
colorScheme: {
|
||||||
|
control: 'select',
|
||||||
|
options: ['primary', 'secondary'],
|
||||||
|
description: 'Цветовая схема',
|
||||||
|
},
|
||||||
|
disabled: {
|
||||||
|
control: 'boolean',
|
||||||
|
description: 'Активность кнопки',
|
||||||
|
},
|
||||||
|
onClick: { action: 'clicked' },
|
||||||
|
},
|
||||||
} satisfies Meta<typeof Button>
|
} satisfies Meta<typeof Button>
|
||||||
|
|
||||||
export default meta
|
export default meta
|
||||||
@@ -40,63 +42,63 @@ type Story = StoryObj<typeof meta>
|
|||||||
* Базовая кнопка
|
* Базовая кнопка
|
||||||
*/
|
*/
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
args: {
|
args: {
|
||||||
children: 'Submit',
|
children: 'Submit',
|
||||||
variant: 'regular',
|
variant: 'regular',
|
||||||
size: 'medium',
|
size: 'medium',
|
||||||
colorScheme: 'primary',
|
colorScheme: 'primary',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Альтернативная цветовая схема
|
* Альтернативная цветовая схема
|
||||||
*/
|
*/
|
||||||
export const SecondaryColorScheme: Story = {
|
export const SecondaryColorScheme: Story = {
|
||||||
args: {
|
args: {
|
||||||
children: 'Submit',
|
children: 'Submit',
|
||||||
variant: 'regular',
|
variant: 'regular',
|
||||||
size: 'medium',
|
size: 'medium',
|
||||||
colorScheme: 'secondary',
|
colorScheme: 'secondary',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Маленькая кнопка
|
* Маленькая кнопка
|
||||||
*/
|
*/
|
||||||
export const Small: Story = {
|
export const Small: Story = {
|
||||||
args: {
|
args: {
|
||||||
children: 'Submit',
|
children: 'Submit',
|
||||||
size: 'small',
|
size: 'small',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Большая кнопка
|
* Большая кнопка
|
||||||
*/
|
*/
|
||||||
export const Large: Story = {
|
export const Large: Story = {
|
||||||
args: {
|
args: {
|
||||||
children: 'Submit',
|
children: 'Submit',
|
||||||
size: 'large',
|
size: 'large',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Кнопка с SVG иконкой (шеврон)
|
* Кнопка с SVG иконкой (шеврон)
|
||||||
*/
|
*/
|
||||||
export const WithIcon: Story = {
|
export const WithIcon: Story = {
|
||||||
args: {
|
args: {
|
||||||
children: <ChevronLeftIcon />,
|
children: <ChevronLeftIcon />,
|
||||||
variant: 'round',
|
variant: 'round',
|
||||||
size: 'medium',
|
size: 'medium',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Отключенная кнопка
|
* Отключенная кнопка
|
||||||
*/
|
*/
|
||||||
export const Disabled: Story = {
|
export const Disabled: Story = {
|
||||||
args: {
|
args: {
|
||||||
children: 'Submit',
|
children: 'Submit',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,30 @@
|
|||||||
import { ButtonHTMLAttributes, memo, PropsWithChildren } from 'react'
|
|
||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
|
import { ButtonHTMLAttributes, memo, PropsWithChildren } from 'react'
|
||||||
|
|
||||||
import styles from './Button.module.scss'
|
import styles from './Button.module.scss'
|
||||||
|
|
||||||
export type ButtonVariant = 'round' | 'regular'
|
export type ButtonVariant = 'round' | 'regular'
|
||||||
export type ButtonSize = 'small' | 'medium' | 'large'
|
export type ButtonSize = 'small' | 'medium' | 'large'
|
||||||
export type ButtonColorScheme = 'primary' | 'secondary'
|
export type ButtonColorScheme = 'primary' | 'secondary'
|
||||||
|
|
||||||
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, PropsWithChildren {
|
export interface ButtonProps
|
||||||
/**
|
extends ButtonHTMLAttributes<HTMLButtonElement>,
|
||||||
* Вариант внешнего вида кнопки
|
PropsWithChildren {
|
||||||
* @default 'round'
|
/**
|
||||||
*/
|
* Вариант внешнего вида кнопки
|
||||||
variant?: ButtonVariant
|
* @default 'round'
|
||||||
/**
|
*/
|
||||||
* Размер кнопки
|
variant?: ButtonVariant
|
||||||
* @default 'medium'
|
/**
|
||||||
*/
|
* Размер кнопки
|
||||||
size?: ButtonSize
|
* @default 'medium'
|
||||||
/**
|
*/
|
||||||
* Цветовая схема
|
size?: ButtonSize
|
||||||
* @default 'timeframe'
|
/**
|
||||||
*/
|
* Цветовая схема
|
||||||
colorScheme?: ButtonColorScheme
|
* @default 'timeframe'
|
||||||
|
*/
|
||||||
|
colorScheme?: ButtonColorScheme
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,32 +32,32 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, Pr
|
|||||||
* Поддерживает различные варианты отображения, размеры и цветовые схемы.
|
* Поддерживает различные варианты отображения, размеры и цветовые схемы.
|
||||||
*/
|
*/
|
||||||
export const Button = memo((props: ButtonProps) => {
|
export const Button = memo((props: ButtonProps) => {
|
||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
variant = 'round',
|
variant = 'round',
|
||||||
size = 'medium',
|
size = 'medium',
|
||||||
colorScheme = 'primary',
|
colorScheme = 'primary',
|
||||||
disabled,
|
disabled,
|
||||||
...otherProps
|
...otherProps
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
const mods: Record<string, boolean | undefined> = {
|
const mods: Record<string, boolean | undefined> = {
|
||||||
[styles[variant]]: true,
|
[styles[variant]]: true,
|
||||||
[styles[size]]: true,
|
[styles[size]]: true,
|
||||||
[styles[colorScheme]]: true,
|
[styles[colorScheme]]: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type='button'
|
||||||
className={classNames(styles.button, mods, className)}
|
className={classNames(styles.button, mods, className)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
Button.displayName = 'Button'
|
Button.displayName = 'Button'
|
||||||
|
|||||||
@@ -1,2 +1,7 @@
|
|||||||
export { Button } from './Button'
|
export { Button } from './Button'
|
||||||
export type { ButtonProps, ButtonVariant, ButtonSize, ButtonColorScheme } from './Button'
|
export type {
|
||||||
|
ButtonProps,
|
||||||
|
ButtonVariant,
|
||||||
|
ButtonSize,
|
||||||
|
ButtonColorScheme,
|
||||||
|
} from './Button'
|
||||||
|
|||||||
Reference in New Issue
Block a user