fix: Правки внешнего вида кода линтером

This commit is contained in:
Ilia Mashkov
2025-11-20 09:58:13 +03:00
parent 5c869eb215
commit d3731ad513
4 changed files with 139 additions and 111 deletions

View File

@@ -1,18 +1,26 @@
.button {
display: inline-flex;
align-items: center;
justify-content: center;
border: none;
background: transparent;
cursor: pointer;
transition: all 0.3s ease;
align-items: center;
padding: 0;
outline: none;
font-family: var(--font-family-main);
border: none;
background: transparent;
outline: none;
cursor: pointer;
transition: all 0.3s ease;
&:disabled {
opacity: 0.5;
cursor: not-allowed;
opacity: 0.5;
}
// Variants
@@ -22,33 +30,39 @@
}
&.regular {
border-radius: 1em;
padding: 0.5em 1em;
border-radius: 1em;
}
// Sizes
&.small {
height: 40px;
font-size: 14px;
}
&.medium {
height: 50px;
font-size: 18px;
}
&.large {
height: 60px;
font-size: 24px;
}
// Color Schemes
&.primary {
$color-primary: var(--color-primary);
background-color: transparent;
color: $color-primary;
border: 1px solid $color-primary;
background-color: transparent;
&:hover:not(:disabled) {
background-color: var(--color-white);
}
@@ -56,22 +70,26 @@
&.secondary {
$color-blue: var(--color-blue);
background-color: var(--color-white);
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 {
display: flex;
align-items: center;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
svg {
width: 40%;
height: 40%;
object-fit: contain;
}
}

View File

@@ -1,36 +1,38 @@
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from './Button'
import ChevronLeftIcon from '@/shared/assets/chevron--left.svg'
import { Button } from './Button'
import type { Meta, StoryObj } from '@storybook/react'
const meta = {
title: 'Shared/Button',
component: Button,
parameters: {
layout: 'centered',
title: 'Shared/Button',
component: Button,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {
variant: {
control: 'select',
options: ['round', 'regular'],
description: 'Вариант внешнего вида',
},
tags: ['autodocs'],
argTypes: {
variant: {
control: 'select',
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' },
size: {
control: 'select',
options: ['small', 'medium', 'large'],
description: 'Размер кнопки',
},
colorScheme: {
control: 'select',
options: ['primary', 'secondary'],
description: 'Цветовая схема',
},
disabled: {
control: 'boolean',
description: 'Активность кнопки',
},
onClick: { action: 'clicked' },
},
} satisfies Meta<typeof Button>
export default meta
@@ -40,63 +42,63 @@ type Story = StoryObj<typeof meta>
* Базовая кнопка
*/
export const Default: Story = {
args: {
children: 'Submit',
variant: 'regular',
size: 'medium',
colorScheme: 'primary',
},
args: {
children: 'Submit',
variant: 'regular',
size: 'medium',
colorScheme: 'primary',
},
}
/**
* Альтернативная цветовая схема
*/
export const SecondaryColorScheme: Story = {
args: {
children: 'Submit',
variant: 'regular',
size: 'medium',
colorScheme: 'secondary',
},
args: {
children: 'Submit',
variant: 'regular',
size: 'medium',
colorScheme: 'secondary',
},
}
/**
* Маленькая кнопка
*/
export const Small: Story = {
args: {
children: 'Submit',
size: 'small',
},
args: {
children: 'Submit',
size: 'small',
},
}
/**
* Большая кнопка
*/
export const Large: Story = {
args: {
children: 'Submit',
size: 'large',
},
args: {
children: 'Submit',
size: 'large',
},
}
/**
* Кнопка с SVG иконкой (шеврон)
*/
export const WithIcon: Story = {
args: {
children: <ChevronLeftIcon />,
variant: 'round',
size: 'medium',
},
args: {
children: <ChevronLeftIcon />,
variant: 'round',
size: 'medium',
},
}
/**
* Отключенная кнопка
*/
export const Disabled: Story = {
args: {
children: 'Submit',
disabled: true,
},
args: {
children: 'Submit',
disabled: true,
},
}

View File

@@ -1,27 +1,30 @@
import { ButtonHTMLAttributes, memo, PropsWithChildren } from 'react'
import classNames from 'classnames'
import { ButtonHTMLAttributes, memo, PropsWithChildren } from 'react'
import styles from './Button.module.scss'
export type ButtonVariant = 'round' | 'regular'
export type ButtonSize = 'small' | 'medium' | 'large'
export type ButtonColorScheme = 'primary' | 'secondary'
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, PropsWithChildren {
/**
* Вариант внешнего вида кнопки
* @default 'round'
*/
variant?: ButtonVariant
/**
* Размер кнопки
* @default 'medium'
*/
size?: ButtonSize
/**
* Цветовая схема
* @default 'timeframe'
*/
colorScheme?: ButtonColorScheme
export interface ButtonProps
extends ButtonHTMLAttributes<HTMLButtonElement>,
PropsWithChildren {
/**
* Вариант внешнего вида кнопки
* @default 'round'
*/
variant?: ButtonVariant
/**
* Размер кнопки
* @default 'medium'
*/
size?: ButtonSize
/**
* Цветовая схема
* @default 'timeframe'
*/
colorScheme?: ButtonColorScheme
}
/**
@@ -29,32 +32,32 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, Pr
* Поддерживает различные варианты отображения, размеры и цветовые схемы.
*/
export const Button = memo((props: ButtonProps) => {
const {
className,
children,
variant = 'round',
size = 'medium',
colorScheme = 'primary',
disabled,
...otherProps
} = props
const {
className,
children,
variant = 'round',
size = 'medium',
colorScheme = 'primary',
disabled,
...otherProps
} = props
const mods: Record<string, boolean | undefined> = {
[styles[variant]]: true,
[styles[size]]: true,
[styles[colorScheme]]: true,
}
const mods: Record<string, boolean | undefined> = {
[styles[variant]]: true,
[styles[size]]: true,
[styles[colorScheme]]: true,
}
return (
<button
type="button"
className={classNames(styles.button, mods, className)}
disabled={disabled}
{...otherProps}
>
{children}
</button>
)
return (
<button
type='button'
className={classNames(styles.button, mods, className)}
disabled={disabled}
{...otherProps}
>
{children}
</button>
)
})
Button.displayName = 'Button'

View File

@@ -1,2 +1,7 @@
export { Button } from './Button'
export type { ButtonProps, ButtonVariant, ButtonSize, ButtonColorScheme } from './Button'
export type {
ButtonProps,
ButtonVariant,
ButtonSize,
ButtonColorScheme,
} from './Button'