@kvell-group/ui 1.19.4 → 1.19.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Alert/Alert.module.css +28 -0
- package/src/components/Alert/Alert.stories.tsx +69 -0
- package/src/components/Alert/Alert.tsx +33 -0
- package/src/components/Alert/constants.ts +3 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/Alert/types.ts +8 -0
- package/src/components/Badge/Badge.module.css +1 -0
- package/src/components/Modal/Modal.module.css +4 -0
- package/src/constants/font-variants.ts +1 -0
- package/src/index.ts +1 -0
- package/src/styles/typography.module.css +8 -0
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
padding: rem(16px);
|
|
3
|
+
box-shadow:
|
|
4
|
+
0px 3px 10px -2px rgba(20, 21, 26, 0.02),
|
|
5
|
+
0px 10px 16px -3px rgba(20, 21, 26, 0.05);
|
|
6
|
+
|
|
7
|
+
&[data-variant='warning'] {
|
|
8
|
+
--alert-bg: var(--color-background-surface-warning-subtle);
|
|
9
|
+
--alert-bd: rem(1px) solid var(--color-border-action-normal);
|
|
10
|
+
--alert-color: var(--color-icon-status-warning);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wrapper {
|
|
15
|
+
align-items: flex-start;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.icon {
|
|
19
|
+
margin-inline-end: rem(12px);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.message {
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
font-size: var(--mantine-font-size-body-s);
|
|
25
|
+
line-height: var(--mantine-line-height-body-s);
|
|
26
|
+
letter-spacing: var(--mantine-spacing-body-s);
|
|
27
|
+
color: var(--color-text-base-primary);
|
|
28
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import { KvellUiProvider } from '@/components/KvellUiProvider'
|
|
4
|
+
|
|
5
|
+
import { theme } from '@/theme'
|
|
6
|
+
import { Alert } from '@/components/Alert'
|
|
7
|
+
import { AlertVariants, WARNING_ALERT_VARIANT } from '@/components/Alert/constants'
|
|
8
|
+
|
|
9
|
+
// ----------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'Components/Alert',
|
|
13
|
+
argTypes: { variant: AlertVariants },
|
|
14
|
+
component: Alert,
|
|
15
|
+
decorators: (Story) => (
|
|
16
|
+
<KvellUiProvider theme={theme}>
|
|
17
|
+
<Story />
|
|
18
|
+
</KvellUiProvider>
|
|
19
|
+
),
|
|
20
|
+
} satisfies Meta<typeof Alert>
|
|
21
|
+
|
|
22
|
+
type Story = StoryObj<typeof meta>
|
|
23
|
+
|
|
24
|
+
// ----------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
export const ComponentAlert: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
variant: WARNING_ALERT_VARIANT,
|
|
29
|
+
children: 'Проверьте данные карты перед оплатой',
|
|
30
|
+
},
|
|
31
|
+
argTypes: {
|
|
32
|
+
variant: {
|
|
33
|
+
control: 'select',
|
|
34
|
+
options: AlertVariants,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const WarningAlert: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
variant: WARNING_ALERT_VARIANT,
|
|
42
|
+
children: 'Оплата будет доступна после подтверждения банком',
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const CustomIconAlert: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
icon: null,
|
|
49
|
+
children: 'Алерт без иконки',
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const WarningAlertWithoutIcon: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
variant: WARNING_ALERT_VARIANT,
|
|
56
|
+
icon: null,
|
|
57
|
+
children: 'Алерт с вариантом warning, но без иконки (icon явно передан как null)',
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const DefaultAlert: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
children: 'Алерт без variant и без icon — прозрачный фон, без иконки',
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ----------------------------------------------------------------------
|
|
68
|
+
|
|
69
|
+
export default meta
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { forwardRef } from 'react'
|
|
2
|
+
import { Alert as MantineAlert } from '@mantine/core'
|
|
3
|
+
import type { AlertProps as MantineAlertProps } from '@mantine/core'
|
|
4
|
+
import { RiErrorWarningFill } from '@remixicon/react'
|
|
5
|
+
import classNames from './Alert.module.css'
|
|
6
|
+
import { WARNING_ALERT_VARIANT } from './constants'
|
|
7
|
+
import type { ExtendedAlertVariant } from './types'
|
|
8
|
+
|
|
9
|
+
// ----------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
export type AlertProps = Omit<MantineAlertProps, 'variant'> & { variant?: ExtendedAlertVariant }
|
|
12
|
+
|
|
13
|
+
const variantIcons: Partial<Record<ExtendedAlertVariant & string, React.ReactNode>> = {
|
|
14
|
+
[WARNING_ALERT_VARIANT]: <RiErrorWarningFill size={20} />,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ----------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
20
|
+
const { variant, icon, ...others } = props
|
|
21
|
+
|
|
22
|
+
const resolvedIcon = icon === undefined ? (variant ? variantIcons[variant] : null) : icon
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<MantineAlert
|
|
26
|
+
ref={ref}
|
|
27
|
+
variant={variant ?? 'transparent'}
|
|
28
|
+
icon={resolvedIcon}
|
|
29
|
+
{...others}
|
|
30
|
+
classNames={classNames}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Alert } from './Alert'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AlertVariants } from './constants'
|
|
2
|
+
import type { AlertProps as MantineAlertProps } from '@mantine/core'
|
|
3
|
+
|
|
4
|
+
// ----------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
type AlertVariantsType = typeof AlertVariants
|
|
7
|
+
|
|
8
|
+
export type ExtendedAlertVariant = MantineAlertProps['variant'] | AlertVariantsType[number]
|
|
@@ -19,6 +19,7 @@ export const BODY_S_BOLD_FONT_VARIANT = 'body-s-bold' as const
|
|
|
19
19
|
//caption
|
|
20
20
|
export const CAPTION_L_MEDIUM_FONT_VARIANT = 'caption-l-medium' as const
|
|
21
21
|
export const CAPTION_L_REGULAR_FONT_VARIANT = 'caption-l-regular' as const
|
|
22
|
+
export const CAPTION_M_MEDIUM_FONT_VARIANT = 'caption-m-medium' as const
|
|
22
23
|
export const CAPTION_M_REGULAR_FONT_VARIANT = 'caption-m-regular' as const
|
|
23
24
|
|
|
24
25
|
// ----------------------------------------------------------------------
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ export { PinInput } from './components/Inputs/PinInput'
|
|
|
21
21
|
export * from './components/Notifications'
|
|
22
22
|
|
|
23
23
|
//components
|
|
24
|
+
export { Alert } from './components/Alert'
|
|
24
25
|
export * from './components/Button'
|
|
25
26
|
export { CardLogoByPan } from './components/CardLogoByPan'
|
|
26
27
|
export { Loader } from './components/Loader'
|
|
@@ -131,6 +131,14 @@ p.caption-l-regular,
|
|
|
131
131
|
letter-spacing: var(--mantine-spacing-caption-l);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
.caption-m-medium {
|
|
135
|
+
font-family: var(--mantine-font-family);
|
|
136
|
+
font-weight: 500;
|
|
137
|
+
font-size: var(--mantine-font-size-caption-m);
|
|
138
|
+
line-height: var(--mantine-line-height-caption-m);
|
|
139
|
+
letter-spacing: var(--mantine-spacing-caption-m);
|
|
140
|
+
}
|
|
141
|
+
|
|
134
142
|
.caption-m-regular {
|
|
135
143
|
font-family: var(--mantine-font-family);
|
|
136
144
|
font-weight: 400;
|