@qoretechnologies/reqore 0.26.1 → 0.27.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.
Files changed (74) hide show
  1. package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
  2. package/dist/components/Breadcrumbs/index.js +1 -1
  3. package/dist/components/Breadcrumbs/index.js.map +1 -1
  4. package/dist/components/Button/index.d.ts +7 -1
  5. package/dist/components/Button/index.d.ts.map +1 -1
  6. package/dist/components/Button/index.js +45 -20
  7. package/dist/components/Button/index.js.map +1 -1
  8. package/dist/components/Drawer/index.d.ts.map +1 -1
  9. package/dist/components/Drawer/index.js +3 -1
  10. package/dist/components/Drawer/index.js.map +1 -1
  11. package/dist/components/Menu/index.d.ts +1 -0
  12. package/dist/components/Menu/index.d.ts.map +1 -1
  13. package/dist/components/Menu/index.js +3 -2
  14. package/dist/components/Menu/index.js.map +1 -1
  15. package/dist/components/Menu/item.d.ts.map +1 -1
  16. package/dist/components/Menu/item.js +2 -2
  17. package/dist/components/Menu/item.js.map +1 -1
  18. package/dist/components/Spacer/index.d.ts.map +1 -1
  19. package/dist/components/Spacer/index.js +1 -1
  20. package/dist/components/Spacer/index.js.map +1 -1
  21. package/dist/components/Tabs/index.js +2 -2
  22. package/dist/components/Tabs/index.js.map +1 -1
  23. package/dist/components/Tabs/item.d.ts +2 -1
  24. package/dist/components/Tabs/item.d.ts.map +1 -1
  25. package/dist/components/Tabs/item.js +2 -2
  26. package/dist/components/Tabs/item.js.map +1 -1
  27. package/dist/components/Tabs/list.d.ts.map +1 -1
  28. package/dist/components/Tabs/list.js +1 -1
  29. package/dist/components/Tabs/list.js.map +1 -1
  30. package/dist/components/Tag/index.d.ts.map +1 -1
  31. package/dist/components/Tag/index.js +3 -3
  32. package/dist/components/Tag/index.js.map +1 -1
  33. package/dist/constants/animations.d.ts +4 -0
  34. package/dist/constants/animations.d.ts.map +1 -1
  35. package/dist/constants/animations.js +5 -1
  36. package/dist/constants/animations.js.map +1 -1
  37. package/dist/constants/sizes.d.ts +21 -0
  38. package/dist/constants/sizes.d.ts.map +1 -1
  39. package/dist/constants/sizes.js +22 -1
  40. package/dist/constants/sizes.js.map +1 -1
  41. package/dist/containers/ReqoreProvider.js +1 -1
  42. package/dist/containers/ReqoreProvider.js.map +1 -1
  43. package/dist/containers/UIProvider.d.ts +1 -0
  44. package/dist/containers/UIProvider.d.ts.map +1 -1
  45. package/dist/containers/UIProvider.js.map +1 -1
  46. package/dist/context/ReqoreContext.d.ts.map +1 -1
  47. package/dist/context/ReqoreContext.js +2 -1
  48. package/dist/context/ReqoreContext.js.map +1 -1
  49. package/dist/helpers/utils.d.ts +2 -0
  50. package/dist/helpers/utils.d.ts.map +1 -1
  51. package/dist/helpers/utils.js +11 -1
  52. package/dist/helpers/utils.js.map +1 -1
  53. package/package.json +1 -1
  54. package/src/components/Breadcrumbs/index.tsx +1 -0
  55. package/src/components/Button/index.tsx +156 -85
  56. package/src/components/Drawer/index.tsx +5 -3
  57. package/src/components/Menu/index.tsx +13 -1
  58. package/src/components/Menu/item.tsx +3 -2
  59. package/src/components/Spacer/index.tsx +1 -0
  60. package/src/components/Tabs/index.tsx +1 -1
  61. package/src/components/Tabs/item.tsx +7 -3
  62. package/src/components/Tabs/list.tsx +1 -0
  63. package/src/components/Tag/index.tsx +3 -2
  64. package/src/constants/animations.ts +5 -0
  65. package/src/constants/sizes.ts +24 -0
  66. package/src/containers/ReqoreProvider.tsx +1 -1
  67. package/src/containers/UIProvider.tsx +1 -0
  68. package/src/context/ReqoreContext.tsx +1 -0
  69. package/src/helpers/utils.ts +10 -0
  70. package/src/stories/Button/Button.stories.tsx +69 -1
  71. package/src/stories/Menu/Menu.stories.tsx +30 -5
  72. package/src/stories/Tabs/Tabs.stories.tsx +10 -5
  73. package/src/stories/Tag/Tag.stories.tsx +42 -4
  74. package/tests.json +1 -1
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useContext } from 'react';
1
+ import React, { forwardRef, memo, useContext } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import {
4
4
  PADDING_FROM_SIZE,
@@ -10,6 +10,7 @@ import {
10
10
  import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
11
11
  import ReqoreContext from '../../context/ReqoreContext';
12
12
  import { changeLightness, getReadableColor, getReadableColorFrom } from '../../helpers/colors';
13
+ import { getOneLessSize } from '../../helpers/utils';
13
14
  import { useCombinedRefs } from '../../hooks/useCombinedRefs';
14
15
  import { useReqoreTheme } from '../../hooks/useTheme';
15
16
  import { useTooltip } from '../../hooks/useTooltip';
@@ -28,8 +29,10 @@ import {
28
29
  TReqoreTooltipProp,
29
30
  } from '../../types/global';
30
31
  import { IReqoreIconName } from '../../types/icons';
31
- import { StyledEffect } from '../Effect';
32
+ import { ReqoreTextEffect, StyledEffect, StyledTextEffect } from '../Effect';
32
33
  import ReqoreIcon from '../Icon';
34
+ import { ReqoreSpacer } from '../Spacer';
35
+ import ReqoreTag, { IReqoreTagProps } from '../Tag';
33
36
 
34
37
  export interface IReqoreButtonProps
35
38
  extends React.HTMLAttributes<HTMLButtonElement>,
@@ -48,6 +51,10 @@ export interface IReqoreButtonProps
48
51
  rightIcon?: IReqoreIconName;
49
52
  customTheme?: IReqoreCustomTheme;
50
53
  wrap?: boolean;
54
+ badge?: string | number | IReqoreTagProps;
55
+ description?: string | number;
56
+ maxWidth?: string;
57
+ textAlign?: 'left' | 'center' | 'right';
51
58
  }
52
59
 
53
60
  export interface IReqoreButtonStyle extends Omit<IReqoreButtonProps, 'intent'> {
@@ -67,6 +74,7 @@ export const StyledAnimatedTextWrapper = styled.span`
67
74
  overflow: hidden;
68
75
  position: relative;
69
76
  padding: 4px 0;
77
+ text-align: left;
70
78
  `;
71
79
 
72
80
  export const StyledActiveContent = styled.span`
@@ -77,7 +85,7 @@ export const StyledActiveContent = styled.span`
77
85
  filter: blur(10px);
78
86
 
79
87
  ${({ wrap }) =>
80
- wrap &&
88
+ !wrap &&
81
89
  css`
82
90
  overflow: hidden;
83
91
  text-overflow: ellipsis;
@@ -92,7 +100,7 @@ export const StyledInActiveContent = styled.span`
92
100
  transition: all 0.2s ease-out;
93
101
 
94
102
  ${({ wrap }) =>
95
- wrap &&
103
+ !wrap &&
96
104
  css`
97
105
  overflow: hidden;
98
106
  text-overflow: ellipsis;
@@ -107,7 +115,7 @@ export const StyledInvisibleContent = styled.span`
107
115
  overflow: hidden;
108
116
 
109
117
  ${({ wrap }) =>
110
- wrap &&
118
+ !wrap &&
111
119
  css`
112
120
  white-space: nowrap;
113
121
  `}
@@ -115,8 +123,9 @@ export const StyledInvisibleContent = styled.span`
115
123
 
116
124
  export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
117
125
  display: flex;
118
- text-align: left;
126
+ flex-flow: column;
119
127
  align-items: center;
128
+ justify-content: center;
120
129
  margin: 0;
121
130
  font-weight: 600;
122
131
  position: relative;
@@ -129,13 +138,8 @@ export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
129
138
 
130
139
  min-height: ${({ size }) => SIZE_TO_PX[size]}px;
131
140
 
132
- ${({ wrap }) =>
133
- wrap &&
134
- css`
135
- max-height: ${({ size }) => SIZE_TO_PX[size]}px;
136
- `}
137
-
138
141
  min-width: ${({ size }) => SIZE_TO_PX[size]}px;
142
+ max-width: ${({ maxWidth }) => maxWidth || undefined};
139
143
 
140
144
  flex: ${({ fluid, fixed }) => (fixed ? '0 auto' : fluid ? '1 auto' : '0 0 auto')};
141
145
 
@@ -233,82 +237,149 @@ export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
233
237
  border-color: ${({ minimal, theme, color }) =>
234
238
  minimal ? undefined : changeLightness(getButtonMainColor(theme, color), 0.4)};
235
239
  }
240
+
241
+ ${StyledTextEffect} {
242
+ padding-bottom: ${({ size }) => PADDING_FROM_SIZE[getOneLessSize(size)]}px;
243
+ }
236
244
  `;
237
245
 
238
- const ReqoreButton = forwardRef(
239
- (
240
- {
241
- icon,
242
- size = 'normal',
243
- minimal,
244
- children,
245
- tooltip,
246
- className,
247
- fluid,
248
- fixed,
249
- intent,
250
- active,
251
- flat,
252
- rightIcon,
253
- customTheme,
254
- wrap = true,
255
- readOnly,
256
- ...rest
257
- }: IReqoreButtonProps,
258
- ref
259
- ) => {
260
- const { targetRef } = useCombinedRefs(ref);
261
- const { animations } = useContext(ReqoreContext);
262
- const theme: IReqoreTheme = useReqoreTheme('main', customTheme, intent);
263
-
264
- /* A custom hook that is used to add a tooltip to the button. */
265
- useTooltip(targetRef.current, tooltip);
266
-
267
- // If color or intent was specified, set the color
268
- const customColor = theme.main;
269
- const _flat = minimal ? flat : flat !== false;
270
-
271
- return (
272
- <StyledButton
273
- {...rest}
274
- as='button'
275
- theme={theme}
276
- ref={targetRef}
277
- fluid={fluid}
278
- fixed={fixed}
279
- minimal={minimal}
280
- size={size}
281
- color={customColor}
282
- animate={animations.buttons}
283
- flat={_flat}
284
- active={active}
285
- readOnly={readOnly}
286
- className={`${className || ''} reqore-control reqore-button`}
287
- >
288
- {icon && (
289
- <ReqoreIcon
290
- icon={icon}
291
- margin={children || rightIcon ? 'right' : undefined}
292
- size={`${TEXT_FROM_SIZE[size]}px`}
293
- />
294
- )}
295
- {children && (
296
- <StyledAnimatedTextWrapper>
297
- <StyledActiveContent wrap={wrap}>{children}</StyledActiveContent>
298
- <StyledInActiveContent wrap={wrap}>{children}</StyledInActiveContent>
299
- <StyledInvisibleContent wrap={wrap}>{children}</StyledInvisibleContent>
300
- </StyledAnimatedTextWrapper>
301
- )}
302
- {rightIcon && (
303
- <ReqoreIcon
304
- icon={rightIcon}
305
- margin={children ? 'left' : undefined}
306
- size={`${TEXT_FROM_SIZE[size]}px`}
246
+ export const StyledButtonContent = styled.div`
247
+ display: flex;
248
+ align-items: center;
249
+ width: 100%;
250
+ height: 100%;
251
+ flex: 1;
252
+ flex-shrink: 0;
253
+ min-height: ${({ size }) => SIZE_TO_PX[size]}px;
254
+ ${({ wrap, description }) =>
255
+ !wrap && !description
256
+ ? css`
257
+ max-height: ${({ size }) => SIZE_TO_PX[size]}px;
258
+ `
259
+ : null}
260
+ `;
261
+
262
+ const ReqoreButton = memo(
263
+ forwardRef(
264
+ (
265
+ {
266
+ icon,
267
+ size = 'normal',
268
+ minimal,
269
+ children,
270
+ tooltip,
271
+ className,
272
+ fluid,
273
+ fixed,
274
+ intent,
275
+ active,
276
+ flat,
277
+ rightIcon,
278
+ customTheme,
279
+ wrap,
280
+ readOnly,
281
+ badge,
282
+ description,
283
+ maxWidth,
284
+ textAlign = 'left',
285
+ ...rest
286
+ }: IReqoreButtonProps,
287
+ ref
288
+ ) => {
289
+ const { targetRef } = useCombinedRefs(ref);
290
+ const { animations } = useContext(ReqoreContext);
291
+ const theme: IReqoreTheme = useReqoreTheme('main', customTheme, intent);
292
+
293
+ /* A custom hook that is used to add a tooltip to the button. */
294
+ useTooltip(targetRef.current, tooltip);
295
+
296
+ // If color or intent was specified, set the color
297
+ const customColor = theme.main;
298
+ const _flat = minimal ? flat : flat !== false;
299
+ const color = customColor
300
+ ? minimal
301
+ ? getReadableColor(theme, undefined, undefined, true, theme.originalMain)
302
+ : getReadableColorFrom(customColor, true)
303
+ : getReadableColor(theme, undefined, undefined, true);
304
+
305
+ const renderBadge = () => (
306
+ <>
307
+ <ReqoreSpacer width={PADDING_FROM_SIZE[size]} />
308
+ <ReqoreTag
309
+ size={getOneLessSize(size)}
310
+ badge
311
+ color={`${color}70`}
312
+ {...(typeof badge === 'string' || typeof badge === 'number' ? { label: badge } : badge)}
307
313
  />
308
- )}
309
- </StyledButton>
310
- );
311
- }
314
+ </>
315
+ );
316
+
317
+ return (
318
+ <StyledButton
319
+ {...rest}
320
+ as='button'
321
+ theme={theme}
322
+ ref={targetRef}
323
+ fluid={fluid}
324
+ fixed={fixed}
325
+ maxWidth={maxWidth}
326
+ minimal={minimal}
327
+ size={size}
328
+ color={customColor}
329
+ animate={animations.buttons}
330
+ flat={_flat}
331
+ active={active}
332
+ readOnly={readOnly}
333
+ wrap={wrap}
334
+ description={description}
335
+ className={`${className || ''} reqore-control reqore-button`}
336
+ >
337
+ <StyledButtonContent size={size} wrap={wrap} description={description}>
338
+ {icon && (
339
+ <>
340
+ <ReqoreIcon icon={icon} size={`${TEXT_FROM_SIZE[size]}px`} />
341
+ {children || badge || rightIcon ? (
342
+ <ReqoreSpacer width={PADDING_FROM_SIZE[size]} />
343
+ ) : null}
344
+ </>
345
+ )}
346
+ {children && (
347
+ <StyledAnimatedTextWrapper textAlign={textAlign}>
348
+ <StyledActiveContent wrap={wrap}>{children}</StyledActiveContent>
349
+ <StyledInActiveContent wrap={wrap}>{children}</StyledInActiveContent>
350
+ <StyledInvisibleContent wrap={wrap}>{children}</StyledInvisibleContent>
351
+ {badge && wrap ? renderBadge() : null}
352
+ </StyledAnimatedTextWrapper>
353
+ )}
354
+ {badge && !wrap ? renderBadge() : null}
355
+ {rightIcon && (
356
+ <>
357
+ {children || badge ? <ReqoreSpacer width={PADDING_FROM_SIZE[size]} /> : null}
358
+ <ReqoreIcon
359
+ icon={rightIcon}
360
+ size={`${TEXT_FROM_SIZE[size]}px`}
361
+ style={{ marginLeft: 'auto' }}
362
+ />
363
+ </>
364
+ )}
365
+ </StyledButtonContent>
366
+
367
+ {description && (
368
+ <ReqoreTextEffect
369
+ effect={{
370
+ textSize: getOneLessSize(size),
371
+ weight: 'light',
372
+ color: `${color}90`,
373
+ textAlign,
374
+ }}
375
+ >
376
+ {description}
377
+ </ReqoreTextEffect>
378
+ )}
379
+ </StyledButton>
380
+ );
381
+ }
382
+ )
312
383
  );
313
384
 
314
385
  export default ReqoreButton;
@@ -1,10 +1,11 @@
1
1
  import { animated, useTransition } from '@react-spring/web';
2
2
  import { rgba } from 'polished';
3
3
  import { Resizable } from 're-resizable';
4
- import { useEffect, useMemo, useState } from 'react';
4
+ import { useContext, useEffect, useMemo, useState } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import styled, { css } from 'styled-components';
7
- import { SPRING_CONFIG } from '../../constants/animations';
7
+ import { ReqoreContext } from '../..';
8
+ import { SPRING_CONFIG, SPRING_CONFIG_NO_ANIMATIONS } from '../../constants/animations';
8
9
  import { IReqoreTheme } from '../../constants/theme';
9
10
  import ReqoreThemeProvider from '../../containers/ThemeProvider';
10
11
  import { getMainBackgroundColor } from '../../helpers/colors';
@@ -171,6 +172,7 @@ export const ReqoreDrawer = ({
171
172
  height,
172
173
  ...rest
173
174
  }: IReqoreDrawerProps) => {
175
+ const { animations } = useContext(ReqoreContext);
174
176
  const theme = useReqoreTheme('main', customTheme, intent);
175
177
  const layout = useMemo(
176
178
  () =>
@@ -192,7 +194,7 @@ export const ReqoreDrawer = ({
192
194
 
193
195
  const transitions = useTransition(isOpen, {
194
196
  ...getSpringConfig(_isModal, position, floating),
195
- config: SPRING_CONFIG,
197
+ config: animations.dialogs ? SPRING_CONFIG : SPRING_CONFIG_NO_ANIMATIONS,
196
198
  });
197
199
 
198
200
  const zIndex = useLatestZIndex();
@@ -15,6 +15,7 @@ export interface IReqoreMenuProps extends IReqoreComponent, React.HTMLAttributes
15
15
  customTheme?: IReqoreCustomTheme;
16
16
  intent?: TReqoreIntent;
17
17
  wrapText?: boolean;
18
+ flat?: boolean;
18
19
  }
19
20
 
20
21
  export interface IReqoreMenuStyle extends IReqoreMenuProps {
@@ -48,7 +49,17 @@ const StyledReqoreMenu = styled.div<IReqoreMenuStyle>`
48
49
 
49
50
  const ReqoreMenu: React.FC<IReqoreMenuProps> = forwardRef(
50
51
  (
51
- { children, position, _insidePopover, _popoverId, customTheme, intent, wrapText, ...rest },
52
+ {
53
+ children,
54
+ position,
55
+ _insidePopover,
56
+ _popoverId,
57
+ customTheme,
58
+ intent,
59
+ wrapText,
60
+ flat = true,
61
+ ...rest
62
+ },
52
63
  ref: any
53
64
  ) => {
54
65
  const theme = useReqoreTheme('main', customTheme, intent);
@@ -64,6 +75,7 @@ const ReqoreMenu: React.FC<IReqoreMenuProps> = forwardRef(
64
75
  _popoverId,
65
76
  customTheme: theme,
66
77
  wrap: wrapText,
78
+ flat,
67
79
  })
68
80
  : null
69
81
  )}
@@ -50,6 +50,7 @@ const ReqoreMenuItem: React.FC<IReqoreMenuItemProps> = forwardRef(
50
50
  _popoverId,
51
51
  tooltip,
52
52
  intent,
53
+ flat = true,
53
54
  ...rest
54
55
  },
55
56
  ref: any
@@ -88,7 +89,7 @@ const ReqoreMenuItem: React.FC<IReqoreMenuItemProps> = forwardRef(
88
89
  //@ts-ignore
89
90
  as={as}
90
91
  {...rest}
91
- flat
92
+ flat={flat}
92
93
  className='reqore-menu-item'
93
94
  fluid
94
95
  onClick={handleClick}
@@ -103,7 +104,7 @@ const ReqoreMenuItem: React.FC<IReqoreMenuItemProps> = forwardRef(
103
104
  {rightIcon && (
104
105
  <ReqoreButton
105
106
  icon={rightIcon}
106
- flat
107
+ flat={flat}
107
108
  fixed
108
109
  minimal={!onRightIconClick}
109
110
  customTheme={rest.customTheme}
@@ -4,4 +4,5 @@ export const ReqoreSpacer = styled.div`
4
4
  visibility: hidden;
5
5
  height: ${({ height }) => height || 1}px;
6
6
  width: ${({ width }) => width || 1}px;
7
+ flex-shrink: 0;
7
8
  `;
@@ -59,7 +59,7 @@ const ReqoreTabs = ({
59
59
  _testWidth,
60
60
  vertical,
61
61
  activeTabIntent,
62
- flat,
62
+ flat = true,
63
63
  size = 'normal',
64
64
  width,
65
65
  wrapTabNames,
@@ -6,10 +6,11 @@ import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
6
6
  import { changeLightness } from '../../helpers/colors';
7
7
  import { useCombinedRefs } from '../../hooks/useCombinedRefs';
8
8
  import { useReqoreTheme } from '../../hooks/useTheme';
9
+ import { IWithReqoreFlat } from '../../types/global';
9
10
  import ReqoreButton from '../Button';
10
11
  import ReqoreControlGroup from '../ControlGroup';
11
12
 
12
- export interface IReqoreTabListItemProps extends IReqoreTabsListItem {
13
+ export interface IReqoreTabListItemProps extends IReqoreTabsListItem, IWithReqoreFlat {
13
14
  active?: boolean;
14
15
  vertical?: boolean;
15
16
  onCloseClick?: any;
@@ -95,6 +96,8 @@ const ReqoreTabsListItem = memo(
95
96
  closeIcon,
96
97
  customTheme,
97
98
  className,
99
+ flat = true,
100
+ wrapTabNames,
98
101
  }: IReqoreTabListItemProps,
99
102
  ref
100
103
  ) => {
@@ -122,10 +125,11 @@ const ReqoreTabsListItem = memo(
122
125
  {label || icon ? (
123
126
  <ReqoreControlGroup stack size={size} fluid={fill || vertical}>
124
127
  <ReqoreButton
125
- flat={!active && !intent}
128
+ flat={active || intent ? false : flat}
126
129
  fluid={fill || vertical}
127
130
  icon={icon}
128
131
  minimal
132
+ wrap={wrapTabNames}
129
133
  intent={active ? activeIntent || intent : intent}
130
134
  active={active}
131
135
  disabled={disabled}
@@ -139,7 +143,7 @@ const ReqoreTabsListItem = memo(
139
143
  {onCloseClick && !disabled ? (
140
144
  <ReqoreButton
141
145
  fixed
142
- flat={!active && !intent}
146
+ flat={active || intent ? false : flat}
143
147
  icon={closeIcon || 'CloseLine'}
144
148
  intent={active ? activeIntent || intent : intent}
145
149
  minimal
@@ -245,6 +245,7 @@ const ReqoreTabsList = ({
245
245
  {...item}
246
246
  fill={fill}
247
247
  size={size}
248
+ flat={flat}
248
249
  activeIntent={activeTabIntent}
249
250
  customTheme={theme}
250
251
  wrapTabNames={wrapTabNames}
@@ -4,6 +4,7 @@ import React, { forwardRef, useContext } from 'react';
4
4
  import styled, { css } from 'styled-components';
5
5
  import { ReqorePopover } from '../..';
6
6
  import {
7
+ BADGE_SIZE_TO_PX,
7
8
  PADDING_FROM_SIZE,
8
9
  RADIUS_FROM_SIZE,
9
10
  SIZE_TO_PX,
@@ -65,9 +66,9 @@ export const StyledTag = styled(StyledEffect)<IReqoreTagStyle>`
65
66
  overflow: hidden;
66
67
  vertical-align: middle;
67
68
  font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
68
- height: ${({ size }) => SIZE_TO_PX[size]}px;
69
+ height: ${({ size, badge }) => (badge ? BADGE_SIZE_TO_PX[size] : SIZE_TO_PX[size])}px;
69
70
  min-width: ${({ size }) => SIZE_TO_PX[size]}px;
70
- border-radius: ${({ badge, size }) => (badge ? 20 : RADIUS_FROM_SIZE[size])}px;
71
+ border-radius: ${({ badge, size }) => (badge ? 18 : RADIUS_FROM_SIZE[size])}px;
71
72
  width: ${({ width }) => width || undefined};
72
73
  transition: all 0.2s ease-out;
73
74
 
@@ -2,3 +2,8 @@ export const SPRING_CONFIG = {
2
2
  tension: 120,
3
3
  friction: 20,
4
4
  };
5
+
6
+ export const SPRING_CONFIG_NO_ANIMATIONS = {
7
+ tension: 0,
8
+ friction: 0,
9
+ };
@@ -1,6 +1,22 @@
1
1
  export type TSizes = 'tiny' | 'small' | 'normal' | 'big' | 'huge';
2
2
  export type TWeights = 'soft' | 'normal' | 'heavy';
3
3
 
4
+ export const SIZE_TO_NUMBER = {
5
+ tiny: 1,
6
+ small: 2,
7
+ normal: 3,
8
+ big: 4,
9
+ huge: 5,
10
+ };
11
+
12
+ export const NUMBER_TO_SIZE = {
13
+ 1: 'tiny',
14
+ 2: 'small',
15
+ 3: 'normal',
16
+ 4: 'big',
17
+ 5: 'huge',
18
+ };
19
+
4
20
  export const SIZE_TO_PX = {
5
21
  tiny: 10,
6
22
  small: 20,
@@ -9,6 +25,14 @@ export const SIZE_TO_PX = {
9
25
  huge: 50,
10
26
  };
11
27
 
28
+ export const BADGE_SIZE_TO_PX = {
29
+ tiny: 10,
30
+ small: 17,
31
+ normal: 23,
32
+ big: 30,
33
+ huge: 36,
34
+ };
35
+
12
36
  export const TABS_SIZE_TO_PX = {
13
37
  tiny: 20,
14
38
  small: 30,
@@ -121,7 +121,7 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, options }) =
121
121
  isTablet,
122
122
  isMobileOrTablet,
123
123
  getAndIncreaseZIndex,
124
- animations: options?.animations || { buttons: true },
124
+ animations: options?.animations || { buttons: true, dialogs: true },
125
125
  }}
126
126
  >
127
127
  {size(notifications) > 0 ? (
@@ -16,6 +16,7 @@ export interface IReqoreOptions {
16
16
  uiScale?: number;
17
17
  animations?: {
18
18
  buttons?: boolean;
19
+ dialogs?: boolean;
19
20
  };
20
21
  }
21
22
  export interface IReqoreUIProviderProps {
@@ -21,5 +21,6 @@ export default createContext<IReqoreContext>({
21
21
  removeNotification: null,
22
22
  animations: {
23
23
  buttons: true,
24
+ dialogs: true,
24
25
  },
25
26
  });
@@ -8,6 +8,7 @@ import {
8
8
  isString,
9
9
  isUndefined,
10
10
  } from 'lodash';
11
+ import { NUMBER_TO_SIZE, SIZE_TO_NUMBER, TSizes } from '../constants/sizes';
11
12
 
12
13
  export const sleep = async (ms: number) => await new Promise((r) => setTimeout(r, ms));
13
14
 
@@ -73,3 +74,12 @@ export const calculateStringSizeInPixels = (value: string = '', fontSize: number
73
74
  Array.from(value).reduce((acc, cur) => acc + (widths[cur.charCodeAt(0)] ?? avg), 0) * fontSize
74
75
  );
75
76
  };
77
+
78
+ export const getOneLessSize = (size: TSizes): TSizes => {
79
+ // Get the initial sizes number
80
+ const initialSizeNumber: number = SIZE_TO_NUMBER[size];
81
+ // Reduce the size number by one
82
+ const oneLessSizeNumber: number = initialSizeNumber - 1 === 0 ? 1 : initialSizeNumber - 1;
83
+ // Get the size name from the number
84
+ return NUMBER_TO_SIZE[oneLessSizeNumber];
85
+ };