@kvell-group/ui 1.19.5 → 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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@kvell-group/ui",
3
3
  "author": "Kvell Group",
4
4
  "private": false,
5
- "version": "1.19.5",
5
+ "version": "1.19.6",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/kvell-group/ui.git"
@@ -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,3 @@
1
+ export const WARNING_ALERT_VARIANT = 'warning' as const
2
+
3
+ export const AlertVariants = [WARNING_ALERT_VARIANT]
@@ -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]
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'