@true-engineering/true-react-common-ui-kit 3.9.2 → 3.10.0
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/README.md +12 -0
- package/dist/components/Button/constants.d.ts +1 -0
- package/dist/components/Button/types.d.ts +2 -2
- package/dist/components/CloseButton/CloseButton.d.ts +1 -0
- package/dist/components/CloseButton/CloseButton.stories.d.ts +5 -0
- package/dist/components/IconButton/IconButton.d.ts +19 -0
- package/dist/components/IconButton/IconButton.stories.d.ts +6 -0
- package/dist/components/IconButton/IconButton.styles.d.ts +3 -0
- package/dist/components/IconButton/constants.d.ts +2 -0
- package/dist/components/IconButton/index.d.ts +3 -0
- package/dist/components/IconButton/types.d.ts +5 -0
- package/dist/components/Modal/Modal.styles.d.ts +3 -2
- package/dist/components/TextButton/TextButton.d.ts +6 -5
- package/dist/components/TextButton/TextButton.stories.d.ts +2 -1
- package/dist/components/TextButton/constants.d.ts +2 -0
- package/dist/components/TextButton/index.d.ts +1 -1
- package/dist/components/TextButton/types.d.ts +5 -0
- package/dist/components/Toaster/Toaster.styles.d.ts +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/theme/types.d.ts +2 -1
- package/dist/true-react-common-ui-kit.js +667 -459
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +667 -459
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.stories.tsx +3 -5
- package/src/components/Button/constants.ts +2 -0
- package/src/components/Button/types.ts +2 -2
- package/src/components/CloseButton/CloseButton.stories.tsx +11 -0
- package/src/components/CloseButton/CloseButton.tsx +1 -0
- package/src/components/IconButton/IconButton.stories.tsx +32 -0
- package/src/components/IconButton/IconButton.styles.ts +88 -0
- package/src/components/IconButton/IconButton.tsx +74 -0
- package/src/components/IconButton/constants.ts +3 -0
- package/src/components/IconButton/index.ts +3 -0
- package/src/components/IconButton/types.ts +11 -0
- package/src/components/Modal/Modal.styles.ts +17 -2
- package/src/components/Modal/Modal.tsx +7 -4
- package/src/components/Select/CustomSelect.stories.tsx +1 -1
- package/src/components/TextButton/TextButton.stories.tsx +3 -2
- package/src/components/TextButton/TextButton.tsx +72 -65
- package/src/components/TextButton/constants.ts +3 -0
- package/src/components/TextButton/index.ts +1 -2
- package/src/components/TextButton/types.ts +11 -0
- package/src/components/Toaster/Toaster.styles.ts +2 -2
- package/src/components/Toaster/Toaster.tsx +5 -4
- package/src/components/index.ts +1 -0
- package/src/theme/types.ts +8 -6
package/package.json
CHANGED
|
@@ -2,9 +2,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
|
2
2
|
import { IIconType, iconsList } from '../Icon';
|
|
3
3
|
import { complexIcons } from '../Icon/complexIcons';
|
|
4
4
|
import { Button, IButtonProps } from './Button';
|
|
5
|
-
import { BUTTON_VIEWS } from './constants';
|
|
6
|
-
|
|
7
|
-
const sizeTypes: Array<IButtonProps['size']> = ['s', 'm', 'l', 'xl'];
|
|
5
|
+
import { BUTTON_SIZES, BUTTON_VIEWS } from './constants';
|
|
8
6
|
|
|
9
7
|
const iconTypes = [
|
|
10
8
|
undefined,
|
|
@@ -31,9 +29,9 @@ export default {
|
|
|
31
29
|
isFullWidth: false,
|
|
32
30
|
},
|
|
33
31
|
argTypes: {
|
|
34
|
-
view: { options: BUTTON_VIEWS, control: 'inline-radio' },
|
|
35
32
|
icon: { options: iconTypes, control: 'select' },
|
|
36
|
-
size: { options:
|
|
33
|
+
size: { options: BUTTON_SIZES, control: 'inline-radio' },
|
|
34
|
+
view: { options: BUTTON_VIEWS, control: 'inline-radio' },
|
|
37
35
|
iconPosition: { options: ['left', 'right'], control: 'inline-radio' },
|
|
38
36
|
preloaderType: { options: preloaderTypes, control: 'inline-radio' },
|
|
39
37
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BUTTON_VIEWS } from './constants';
|
|
1
|
+
import { BUTTON_SIZES, BUTTON_VIEWS } from './constants';
|
|
2
2
|
|
|
3
|
-
export type IButtonSize =
|
|
3
|
+
export type IButtonSize = (typeof BUTTON_SIZES)[number];
|
|
4
4
|
|
|
5
5
|
export type IButtonView = (typeof BUTTON_VIEWS)[number];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import { CloseButton } from './CloseButton';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Buttons/CloseButton',
|
|
6
|
+
component: CloseButton,
|
|
7
|
+
args: {},
|
|
8
|
+
argTypes: {},
|
|
9
|
+
} as ComponentMeta<typeof CloseButton>;
|
|
10
|
+
|
|
11
|
+
export const Default: ComponentStory<typeof CloseButton> = (args) => <CloseButton {...args} />;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import { IIconType, iconsList } from '../Icon';
|
|
3
|
+
import { complexIcons } from '../Icon/complexIcons';
|
|
4
|
+
import { IconButton } from './IconButton';
|
|
5
|
+
import { ICON_BUTTON_SIZES, ICON_BUTTON_VIEWS } from './constants';
|
|
6
|
+
|
|
7
|
+
const iconTypes = [...Object.keys(iconsList), ...Object.keys(complexIcons)] as IIconType[];
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'Buttons/IconButton',
|
|
11
|
+
component: IconButton,
|
|
12
|
+
args: {
|
|
13
|
+
icon: iconTypes[0],
|
|
14
|
+
view: 'main',
|
|
15
|
+
size: 'm',
|
|
16
|
+
isDisabled: false,
|
|
17
|
+
isLoading: false,
|
|
18
|
+
isActive: false,
|
|
19
|
+
},
|
|
20
|
+
argTypes: {
|
|
21
|
+
icon: { options: iconTypes, control: 'select' },
|
|
22
|
+
size: { options: ICON_BUTTON_SIZES, control: 'inline-radio' },
|
|
23
|
+
view: { options: ICON_BUTTON_VIEWS, control: 'inline-radio' },
|
|
24
|
+
},
|
|
25
|
+
parameters: {
|
|
26
|
+
controls: {
|
|
27
|
+
exclude: ['tweakStyles', 'testId', 'data'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
} as ComponentMeta<typeof IconButton>;
|
|
31
|
+
|
|
32
|
+
export const Default: ComponentStory<typeof IconButton> = (args) => <IconButton {...args} />;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ITweakStyles, createThemedStyles } from '../../theme';
|
|
2
|
+
|
|
3
|
+
const BUTTON_SIZE_S = 24;
|
|
4
|
+
const BUTTON_SIZE_M = 32;
|
|
5
|
+
const ICON_SIZE = 20;
|
|
6
|
+
|
|
7
|
+
export const useStyles = createThemedStyles('IconButton', {
|
|
8
|
+
root: {
|
|
9
|
+
display: 'flex',
|
|
10
|
+
justifyContent: 'center',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
cursor: 'pointer',
|
|
13
|
+
outline: 'none',
|
|
14
|
+
boxSizing: 'border-box',
|
|
15
|
+
transition: '0.25s ease-in-out',
|
|
16
|
+
transitionProperty: 'background-color, color, border-color',
|
|
17
|
+
border: 'none',
|
|
18
|
+
position: 'relative',
|
|
19
|
+
boxShadow: 'none',
|
|
20
|
+
borderRadius: '50%',
|
|
21
|
+
background: 'none',
|
|
22
|
+
padding: 0,
|
|
23
|
+
flexShrink: 0,
|
|
24
|
+
|
|
25
|
+
'&:disabled': {
|
|
26
|
+
extend: 'disabled',
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
'&:active': {
|
|
30
|
+
extend: 'active',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
'cancel-light': {},
|
|
35
|
+
|
|
36
|
+
cancel: {},
|
|
37
|
+
|
|
38
|
+
main: {},
|
|
39
|
+
|
|
40
|
+
custom: {},
|
|
41
|
+
|
|
42
|
+
active: {},
|
|
43
|
+
|
|
44
|
+
disabled: {
|
|
45
|
+
cursor: 'not-allowed',
|
|
46
|
+
pointerEvents: 'none',
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
loading: {
|
|
50
|
+
'& $content': {
|
|
51
|
+
visibility: 'hidden',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
'& $loader': {
|
|
55
|
+
display: 'block',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
icon: {
|
|
60
|
+
display: 'flex',
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
width: ICON_SIZE,
|
|
63
|
+
height: ICON_SIZE,
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
loader: {
|
|
67
|
+
display: 'none',
|
|
68
|
+
position: 'absolute',
|
|
69
|
+
left: '50%',
|
|
70
|
+
top: '50%',
|
|
71
|
+
transform: 'translate(-50%, -50%)',
|
|
72
|
+
|
|
73
|
+
width: ICON_SIZE,
|
|
74
|
+
height: ICON_SIZE,
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
s: {
|
|
78
|
+
width: BUTTON_SIZE_S,
|
|
79
|
+
height: BUTTON_SIZE_S,
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
m: {
|
|
83
|
+
width: BUTTON_SIZE_M,
|
|
84
|
+
height: BUTTON_SIZE_M,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export type IIconButtonStyles = ITweakStyles<typeof useStyles>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { addDataTestId } from '@true-engineering/true-react-platform-helpers';
|
|
4
|
+
import { addDataAttributes } from '../../helpers';
|
|
5
|
+
import { ICommonProps } from '../../types';
|
|
6
|
+
import { renderIcon, IIcon } from '../Icon';
|
|
7
|
+
import { ThemedPreloader } from '../ThemedPreloader';
|
|
8
|
+
import { IIconButtonSize, IIconButtonView, IIconButtonHTMLBaseProps } from './types';
|
|
9
|
+
import { useStyles, IIconButtonStyles } from './IconButton.styles';
|
|
10
|
+
|
|
11
|
+
export interface IIconButtonProps
|
|
12
|
+
extends IIconButtonHTMLBaseProps,
|
|
13
|
+
ICommonProps<IIconButtonStyles> {
|
|
14
|
+
icon: IIcon;
|
|
15
|
+
/** @default 'm' */
|
|
16
|
+
size?: IIconButtonSize;
|
|
17
|
+
/** @default 'cancel-light' */
|
|
18
|
+
view?: IIconButtonView;
|
|
19
|
+
/** @default false */
|
|
20
|
+
isDisabled?: boolean;
|
|
21
|
+
/** @default false */
|
|
22
|
+
isActive?: boolean;
|
|
23
|
+
/** @default false */
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const IconButton = forwardRef<HTMLButtonElement, IIconButtonProps>(
|
|
28
|
+
(
|
|
29
|
+
{
|
|
30
|
+
icon,
|
|
31
|
+
size = 'm',
|
|
32
|
+
view = 'cancel-light',
|
|
33
|
+
isDisabled = false,
|
|
34
|
+
isActive = false,
|
|
35
|
+
isLoading = false,
|
|
36
|
+
type = 'button',
|
|
37
|
+
testId,
|
|
38
|
+
tweakStyles,
|
|
39
|
+
data,
|
|
40
|
+
onClick,
|
|
41
|
+
...restProps
|
|
42
|
+
},
|
|
43
|
+
ref,
|
|
44
|
+
) => {
|
|
45
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
46
|
+
|
|
47
|
+
const hasNoAction = isDisabled || isLoading;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<button
|
|
51
|
+
ref={ref}
|
|
52
|
+
className={clsx(classes.root, classes[view], classes[size], {
|
|
53
|
+
[classes.disabled]: isDisabled,
|
|
54
|
+
[classes.active]: isActive,
|
|
55
|
+
[classes.loading]: isLoading,
|
|
56
|
+
})}
|
|
57
|
+
type={type}
|
|
58
|
+
disabled={isDisabled}
|
|
59
|
+
onClick={hasNoAction ? undefined : onClick}
|
|
60
|
+
{...restProps}
|
|
61
|
+
{...addDataTestId(testId)}
|
|
62
|
+
{...addDataAttributes(data)}
|
|
63
|
+
>
|
|
64
|
+
{isLoading ? (
|
|
65
|
+
<span className={classes.loader}>
|
|
66
|
+
<ThemedPreloader type="default" useCurrentColor />
|
|
67
|
+
</span>
|
|
68
|
+
) : (
|
|
69
|
+
<span className={classes.icon}>{renderIcon(icon)}</span>
|
|
70
|
+
)}
|
|
71
|
+
</button>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { ICON_BUTTON_SIZES, ICON_BUTTON_VIEWS } from './constants';
|
|
3
|
+
|
|
4
|
+
export type IIconButtonSize = (typeof ICON_BUTTON_SIZES)[number];
|
|
5
|
+
|
|
6
|
+
export type IIconButtonView = (typeof ICON_BUTTON_VIEWS)[number];
|
|
7
|
+
|
|
8
|
+
export type IIconButtonHTMLBaseProps = Omit<
|
|
9
|
+
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
10
|
+
'disabled' | 'style' | 'className'
|
|
11
|
+
>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rgba } from '../../helpers';
|
|
2
2
|
import { colors, dimensions, ITweakStyles, createThemedStyles } from '../../theme';
|
|
3
|
-
import {
|
|
3
|
+
import { IIconButtonStyles } from '../IconButton';
|
|
4
4
|
|
|
5
5
|
const VERTICAL_OVERLAY_PADDING = 50;
|
|
6
6
|
|
|
@@ -8,6 +8,9 @@ const MODAL_HORIZONTAL_PADDING_L = 40;
|
|
|
8
8
|
const MODAL_HORIZONTAL_PADDING_M = 36;
|
|
9
9
|
const MODAL_HORIZONTAL_PADDING_S = 26;
|
|
10
10
|
|
|
11
|
+
const MODAL_CLOSE_BUTTON_SIZE = 40;
|
|
12
|
+
const MODAL_CLOSE_BUTTON_ICON_SIZE = 30;
|
|
13
|
+
|
|
11
14
|
export const useStyles = createThemedStyles('Modal', {
|
|
12
15
|
root: {},
|
|
13
16
|
|
|
@@ -300,4 +303,16 @@ export const useStyles = createThemedStyles('Modal', {
|
|
|
300
303
|
'modal-exit-active': { extend: 'animationEnd' },
|
|
301
304
|
});
|
|
302
305
|
|
|
303
|
-
export
|
|
306
|
+
export const closeButtonStyles: IIconButtonStyles = {
|
|
307
|
+
m: {
|
|
308
|
+
width: MODAL_CLOSE_BUTTON_SIZE,
|
|
309
|
+
height: MODAL_CLOSE_BUTTON_SIZE,
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
icon: {
|
|
313
|
+
width: MODAL_CLOSE_BUTTON_ICON_SIZE,
|
|
314
|
+
height: MODAL_CLOSE_BUTTON_ICON_SIZE,
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export type IModalStyles = ITweakStyles<typeof useStyles, { tweakCloseButton: IIconButtonStyles }>;
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
import { addDataAttributes } from '../../helpers';
|
|
11
11
|
import { useTweakStyles } from '../../hooks';
|
|
12
12
|
import { ICommonProps } from '../../types';
|
|
13
|
-
import {
|
|
13
|
+
import { IconButton } from '../IconButton';
|
|
14
14
|
import { IModalPosition, IModalTransitionProps } from './types';
|
|
15
|
-
import { useStyles, IModalStyles } from './Modal.styles';
|
|
15
|
+
import { useStyles, IModalStyles, closeButtonStyles } from './Modal.styles';
|
|
16
16
|
|
|
17
17
|
export interface IModalProps extends ICommonProps<IModalStyles>, IModalTransitionProps {
|
|
18
18
|
title?: ReactNode;
|
|
@@ -68,6 +68,7 @@ export const Modal: FC<IModalProps> = ({
|
|
|
68
68
|
const classes = useStyles({ theme: tweakStyles });
|
|
69
69
|
|
|
70
70
|
const tweakCloseButtonStyles = useTweakStyles({
|
|
71
|
+
innerStyles: closeButtonStyles,
|
|
71
72
|
tweakStyles,
|
|
72
73
|
className: 'tweakCloseButton',
|
|
73
74
|
currentComponentName: 'Modal',
|
|
@@ -154,10 +155,12 @@ export const Modal: FC<IModalProps> = ({
|
|
|
154
155
|
>
|
|
155
156
|
{hasCloseButton && (
|
|
156
157
|
<div className={classes.close}>
|
|
157
|
-
<
|
|
158
|
+
<IconButton
|
|
158
159
|
testId={getTestId(testId, 'close-button')}
|
|
159
160
|
tweakStyles={tweakCloseButtonStyles}
|
|
160
|
-
|
|
161
|
+
view="cancel-light"
|
|
162
|
+
icon="close"
|
|
163
|
+
onClick={onClose}
|
|
161
164
|
/>
|
|
162
165
|
</div>
|
|
163
166
|
)}
|
|
@@ -2,6 +2,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
|
2
2
|
import { IIconType, iconsList } from '../Icon';
|
|
3
3
|
import { complexIcons } from '../Icon/complexIcons';
|
|
4
4
|
import { TextButton } from './TextButton';
|
|
5
|
+
import { TEXT_BUTTON_SIZES, TEXT_BUTTON_VIEWS } from './constants';
|
|
5
6
|
|
|
6
7
|
const iconTypes = [
|
|
7
8
|
undefined,
|
|
@@ -28,8 +29,8 @@ export default {
|
|
|
28
29
|
|
|
29
30
|
argTypes: {
|
|
30
31
|
icon: { control: 'select', options: iconTypes },
|
|
31
|
-
size: { control: 'inline-radio' },
|
|
32
|
-
view: { control: 'inline-radio' },
|
|
32
|
+
size: { options: TEXT_BUTTON_SIZES, control: 'inline-radio' },
|
|
33
|
+
view: { options: TEXT_BUTTON_VIEWS, control: 'inline-radio' },
|
|
33
34
|
iconPosition: { control: 'inline-radio' },
|
|
34
35
|
preloaderType: { control: 'inline-radio' },
|
|
35
36
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { forwardRef, ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
4
4
|
import { addDataAttributes } from '../../helpers';
|
|
@@ -6,17 +6,18 @@ import { useTweakStyles } from '../../hooks';
|
|
|
6
6
|
import { ICommonProps } from '../../types';
|
|
7
7
|
import { IIcon, renderIcon } from '../Icon';
|
|
8
8
|
import { IThemedPreloaderProps, ThemedPreloader } from '../ThemedPreloader';
|
|
9
|
+
import { ITextButtonHTMLBaseProps, ITextButtonSize, ITextButtonView } from './types';
|
|
9
10
|
import { useStyles, ITextButtonStyles, preloaderStyles } from './TextButton.styles';
|
|
10
11
|
|
|
11
12
|
export interface ITextButtonProps
|
|
12
13
|
extends ICommonProps<ITextButtonStyles>,
|
|
13
|
-
|
|
14
|
+
ITextButtonHTMLBaseProps {
|
|
14
15
|
/** @default 'undefined' */
|
|
15
16
|
children?: ReactNode;
|
|
16
17
|
/** @default 'undefined' */
|
|
17
18
|
icon?: IIcon;
|
|
18
19
|
/** @default 'primary' */
|
|
19
|
-
view?:
|
|
20
|
+
view?: ITextButtonView;
|
|
20
21
|
/** @default false */
|
|
21
22
|
isBold?: boolean;
|
|
22
23
|
/** @default false */
|
|
@@ -28,76 +29,82 @@ export interface ITextButtonProps
|
|
|
28
29
|
/** @default false */
|
|
29
30
|
isActive?: boolean;
|
|
30
31
|
/** @default 'l' */
|
|
31
|
-
size?:
|
|
32
|
+
size?: ITextButtonSize;
|
|
32
33
|
/** @default 'left' */
|
|
33
34
|
iconPosition?: 'left' | 'right';
|
|
34
35
|
/** @default 'dots' */
|
|
35
36
|
preloaderType?: IThemedPreloaderProps['type'];
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
export const TextButton
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
39
|
+
export const TextButton = forwardRef<HTMLButtonElement, ITextButtonProps>(
|
|
40
|
+
(
|
|
41
|
+
{
|
|
42
|
+
children,
|
|
43
|
+
icon,
|
|
44
|
+
view = 'primary',
|
|
45
|
+
isDisabled = false,
|
|
46
|
+
isBold = false,
|
|
47
|
+
isLoading = false,
|
|
48
|
+
isActive = false,
|
|
49
|
+
hasCircleUnderIcon = false,
|
|
50
|
+
size = 'l',
|
|
51
|
+
iconPosition = 'left',
|
|
52
|
+
preloaderType = 'dots',
|
|
53
|
+
type = 'button',
|
|
54
|
+
testId,
|
|
55
|
+
tweakStyles,
|
|
56
|
+
data,
|
|
57
|
+
onClick,
|
|
58
|
+
...restProps
|
|
59
|
+
},
|
|
60
|
+
ref,
|
|
61
|
+
) => {
|
|
62
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
const tweakPreloaderStyles = useTweakStyles({
|
|
65
|
+
innerStyles: preloaderStyles,
|
|
66
|
+
tweakStyles,
|
|
67
|
+
className: 'tweakPreloader',
|
|
68
|
+
currentComponentName: 'TextButton',
|
|
69
|
+
});
|
|
65
70
|
|
|
66
|
-
|
|
71
|
+
const hasNoAction = isDisabled || isLoading;
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
<span className={classes.
|
|
73
|
+
return (
|
|
74
|
+
<button
|
|
75
|
+
ref={ref}
|
|
76
|
+
type={type}
|
|
77
|
+
className={clsx(classes.root, classes[size], classes[view], {
|
|
78
|
+
[classes.bold]: isBold,
|
|
79
|
+
[classes.loading]: isLoading,
|
|
80
|
+
[classes.active]: isActive,
|
|
81
|
+
[classes.disabled]: isDisabled,
|
|
82
|
+
})}
|
|
83
|
+
disabled={hasNoAction}
|
|
84
|
+
onClick={!hasNoAction ? onClick : undefined}
|
|
85
|
+
{...restProps}
|
|
86
|
+
{...addDataTestId(testId)}
|
|
87
|
+
{...addDataAttributes(data)}
|
|
88
|
+
>
|
|
89
|
+
<span className={clsx(classes.content, iconPosition === 'right' && classes.reverseContent)}>
|
|
90
|
+
{isReactNodeNotEmpty(icon) && (
|
|
91
|
+
<span className={clsx(classes.iconContainer, hasCircleUnderIcon && classes.circle)}>
|
|
92
|
+
<span className={classes.icon}>{renderIcon(icon)}</span>
|
|
93
|
+
</span>
|
|
94
|
+
)}
|
|
95
|
+
{children}
|
|
96
|
+
</span>
|
|
97
|
+
|
|
98
|
+
{isLoading && (
|
|
99
|
+
<span className={classes.loader}>
|
|
100
|
+
<ThemedPreloader
|
|
101
|
+
type={preloaderType}
|
|
102
|
+
useCurrentColor
|
|
103
|
+
tweakStyles={tweakPreloaderStyles}
|
|
104
|
+
/>
|
|
87
105
|
</span>
|
|
88
106
|
)}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<span className={classes.loader}>
|
|
94
|
-
<ThemedPreloader
|
|
95
|
-
type={preloaderType}
|
|
96
|
-
useCurrentColor
|
|
97
|
-
tweakStyles={tweakPreloaderStyles}
|
|
98
|
-
/>
|
|
99
|
-
</span>
|
|
100
|
-
)}
|
|
101
|
-
</button>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
107
|
+
</button>
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { TEXT_BUTTON_SIZES, TEXT_BUTTON_VIEWS } from './constants';
|
|
3
|
+
|
|
4
|
+
export type ITextButtonSize = (typeof TEXT_BUTTON_SIZES)[number];
|
|
5
|
+
|
|
6
|
+
export type ITextButtonView = (typeof TEXT_BUTTON_VIEWS)[number];
|
|
7
|
+
|
|
8
|
+
export type ITextButtonHTMLBaseProps = Omit<
|
|
9
|
+
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
10
|
+
'disabled' | 'style' | 'className'
|
|
11
|
+
>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { colors, ITweakStyles, createThemedStyles } from '../../theme';
|
|
2
|
-
import {
|
|
2
|
+
import { IIconButtonStyles } from '../IconButton';
|
|
3
3
|
|
|
4
4
|
export const useStyles = createThemedStyles('Toaster', {
|
|
5
5
|
root: {
|
|
@@ -56,5 +56,5 @@ export const useStyles = createThemedStyles('Toaster', {
|
|
|
56
56
|
|
|
57
57
|
export type IToasterStyles = ITweakStyles<
|
|
58
58
|
typeof useStyles,
|
|
59
|
-
{ tweakCloseButton:
|
|
59
|
+
{ tweakCloseButton: IIconButtonStyles }
|
|
60
60
|
>;
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
import { addDataAttributes } from '../../helpers';
|
|
10
10
|
import { useTweakStyles } from '../../hooks';
|
|
11
11
|
import { ICommonProps } from '../../types';
|
|
12
|
-
import { CloseButton } from '../CloseButton';
|
|
13
12
|
import { Icon } from '../Icon';
|
|
13
|
+
import { IconButton } from '../IconButton';
|
|
14
14
|
import { DEFAULT_TIMEOUT } from './constants';
|
|
15
15
|
import { IToasterType } from './types';
|
|
16
16
|
import { useStyles, IToasterStyles } from './Toaster.styles';
|
|
@@ -96,10 +96,11 @@ export const Toaster: FC<IToasterProps> = ({
|
|
|
96
96
|
</div>
|
|
97
97
|
{hasCloseButton && isNotEmpty(onClose) && (
|
|
98
98
|
<div className={classes.close}>
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
<IconButton
|
|
100
|
+
view="cancel-light"
|
|
101
|
+
icon="close-window"
|
|
102
102
|
tweakStyles={tweakCloseButtonStyles}
|
|
103
|
+
onClick={onClose}
|
|
103
104
|
/>
|
|
104
105
|
</div>
|
|
105
106
|
)}
|
package/src/components/index.ts
CHANGED