@qoretechnologies/reqore 0.27.6 → 0.28.1
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/__tests__/tabs.test.tsx +1 -1
- package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/index.js +4 -5
- package/dist/components/Breadcrumbs/index.js.map +1 -1
- package/dist/components/Breadcrumbs/item.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/item.js +1 -1
- package/dist/components/Breadcrumbs/item.js.map +1 -1
- package/dist/components/Button/index.d.ts +8 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +49 -29
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Collection/item.js +1 -1
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js +2 -1
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/Header/index.d.ts +2 -1
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +5 -2
- package/dist/components/Header/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts +2 -1
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +17 -6
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.js +1 -1
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Menu/index.js +2 -2
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Message/index.d.ts +2 -3
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +8 -7
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Notifications/notification.d.ts +3 -4
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Notifications/notification.js +23 -20
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Panel/index.d.ts +3 -2
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +19 -11
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Table/row.js +1 -1
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +2 -6
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/item.d.ts.map +1 -1
- package/dist/components/Tabs/item.js +19 -10
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tabs/list.d.ts +8 -0
- package/dist/components/Tabs/list.d.ts.map +1 -1
- package/dist/components/Tabs/list.js +32 -12
- package/dist/components/Tabs/list.js.map +1 -1
- package/dist/components/Tag/group.d.ts +2 -1
- package/dist/components/Tag/group.d.ts.map +1 -1
- package/dist/components/Tag/group.js +8 -4
- package/dist/components/Tag/group.js.map +1 -1
- package/dist/components/Tag/index.d.ts +3 -2
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +50 -25
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/constants/sizes.d.ts +22 -0
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +36 -14
- package/dist/constants/sizes.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +1 -1
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +8 -4
- package/dist/helpers/colors.js.map +1 -1
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +7 -2
- package/dist/helpers/utils.js.map +1 -1
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +5 -3
- package/dist/styles.js.map +1 -1
- package/dist/types/global.d.ts +13 -0
- package/dist/types/global.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Breadcrumbs/index.tsx +6 -21
- package/src/components/Breadcrumbs/item.tsx +1 -7
- package/src/components/Button/index.tsx +112 -58
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/Collection/item.tsx +1 -1
- package/src/components/Effect/index.tsx +4 -0
- package/src/components/Header/index.tsx +6 -3
- package/src/components/Icon/index.tsx +21 -8
- package/src/components/Input/index.tsx +1 -1
- package/src/components/Menu/index.tsx +6 -6
- package/src/components/Message/index.tsx +20 -13
- package/src/components/Notifications/notification.tsx +46 -39
- package/src/components/Panel/index.tsx +40 -8
- package/src/components/Table/row.tsx +1 -1
- package/src/components/Tabs/index.tsx +2 -6
- package/src/components/Tabs/item.tsx +33 -24
- package/src/components/Tabs/list.tsx +47 -15
- package/src/components/Tag/group.tsx +22 -5
- package/src/components/Tag/index.tsx +120 -45
- package/src/constants/sizes.ts +39 -13
- package/src/containers/ReqoreProvider.tsx +1 -1
- package/src/containers/UIProvider.tsx +3 -0
- package/src/helpers/colors.ts +8 -4
- package/src/helpers/utils.ts +7 -2
- package/src/mock/collectionData.tsx +4 -0
- package/src/stories/Button/Button.stories.tsx +43 -17
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +2 -2
- package/src/stories/Message/Message.stories.tsx +6 -6
- package/src/stories/Notifications/Notification.stories.tsx +4 -3
- package/src/stories/Panel/Panel.stories.tsx +18 -1
- package/src/stories/Tabs/Tabs.stories.tsx +20 -13
- package/src/stories/Tag/Tag.stories.tsx +43 -0
- package/src/styles.ts +5 -2
- package/src/types/global.ts +14 -0
- package/tests.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { animated } from '@react-spring/web';
|
|
2
2
|
import React, { forwardRef, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { useMount, useUnmount } from 'react-use';
|
|
4
|
-
import { TEXT_FROM_SIZE } from '../../constants/sizes';
|
|
5
4
|
import { IReqoreTheme } from '../../constants/theme';
|
|
6
5
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
7
6
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
@@ -9,15 +8,16 @@ import {
|
|
|
9
8
|
IReqoreIntent,
|
|
10
9
|
IWithReqoreCustomTheme,
|
|
11
10
|
IWithReqoreEffect,
|
|
11
|
+
IWithReqoreMinimal,
|
|
12
12
|
IWithReqoreSize,
|
|
13
13
|
} from '../../types/global';
|
|
14
14
|
import { IReqoreIconName } from '../../types/icons';
|
|
15
|
+
import { ReqoreHeading } from '../Header';
|
|
15
16
|
import ReqoreIcon from '../Icon';
|
|
16
17
|
import {
|
|
17
18
|
StyledIconWrapper,
|
|
18
19
|
StyledNotificationContent,
|
|
19
20
|
StyledNotificationContentWrapper,
|
|
20
|
-
StyledNotificationTitle,
|
|
21
21
|
StyledReqoreNotification,
|
|
22
22
|
typeToIcon,
|
|
23
23
|
} from '../Notifications/notification';
|
|
@@ -27,6 +27,7 @@ export interface IReqoreMessageProps
|
|
|
27
27
|
IWithReqoreEffect,
|
|
28
28
|
IWithReqoreSize,
|
|
29
29
|
IReqoreIntent,
|
|
30
|
+
IWithReqoreMinimal,
|
|
30
31
|
React.HTMLAttributes<HTMLDivElement> {
|
|
31
32
|
title?: string;
|
|
32
33
|
children: any;
|
|
@@ -36,7 +37,6 @@ export interface IReqoreMessageProps
|
|
|
36
37
|
duration?: number;
|
|
37
38
|
onFinish?: () => any;
|
|
38
39
|
flat?: boolean;
|
|
39
|
-
inverted?: boolean;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export interface IReqoreNotificationStyle extends IReqoreMessageProps {
|
|
@@ -57,7 +57,7 @@ const ReqoreMessage = forwardRef<HTMLDivElement, IReqoreMessageProps>(
|
|
|
57
57
|
duration,
|
|
58
58
|
onFinish,
|
|
59
59
|
flat,
|
|
60
|
-
|
|
60
|
+
minimal,
|
|
61
61
|
size = 'normal',
|
|
62
62
|
customTheme,
|
|
63
63
|
...rest
|
|
@@ -114,7 +114,7 @@ const ReqoreMessage = forwardRef<HTMLDivElement, IReqoreMessageProps>(
|
|
|
114
114
|
clickable={!!onClick}
|
|
115
115
|
onClick={onClick}
|
|
116
116
|
flat={flat}
|
|
117
|
-
|
|
117
|
+
minimal={minimal}
|
|
118
118
|
asMessage
|
|
119
119
|
fluid
|
|
120
120
|
className={`${rest?.className || ''} reqore-message`}
|
|
@@ -124,16 +124,23 @@ const ReqoreMessage = forwardRef<HTMLDivElement, IReqoreMessageProps>(
|
|
|
124
124
|
>
|
|
125
125
|
{leftIcon ? (
|
|
126
126
|
<StyledIconWrapper intent={intent} size={size} theme={theme}>
|
|
127
|
-
<ReqoreIcon
|
|
128
|
-
icon={leftIcon}
|
|
129
|
-
margin={flat && inverted ? undefined : 'left'}
|
|
130
|
-
size={`${TEXT_FROM_SIZE[size]}px`}
|
|
131
|
-
/>
|
|
127
|
+
<ReqoreIcon icon={leftIcon} margin={flat && minimal ? 'right' : 'both'} size={size} />
|
|
132
128
|
</StyledIconWrapper>
|
|
133
129
|
) : null}
|
|
134
130
|
<StyledNotificationContentWrapper size={size} theme={theme}>
|
|
135
|
-
{title &&
|
|
136
|
-
|
|
131
|
+
{title && (
|
|
132
|
+
<ReqoreHeading
|
|
133
|
+
size={size}
|
|
134
|
+
customTheme={
|
|
135
|
+
rest.effect?.color ? { text: { color: rest.effect.color } } : undefined
|
|
136
|
+
}
|
|
137
|
+
>
|
|
138
|
+
{title}
|
|
139
|
+
</ReqoreHeading>
|
|
140
|
+
)}
|
|
141
|
+
<StyledNotificationContent theme={theme} hasTitle={!!title} size={size}>
|
|
142
|
+
{children}
|
|
143
|
+
</StyledNotificationContent>
|
|
137
144
|
</StyledNotificationContentWrapper>
|
|
138
145
|
{onClose && (
|
|
139
146
|
<StyledIconWrapper
|
|
@@ -147,7 +154,7 @@ const ReqoreMessage = forwardRef<HTMLDivElement, IReqoreMessageProps>(
|
|
|
147
154
|
onClose && onClose();
|
|
148
155
|
}}
|
|
149
156
|
>
|
|
150
|
-
<ReqoreIcon icon='CloseFill' margin='both' size={
|
|
157
|
+
<ReqoreIcon icon='CloseFill' margin='both' size={size} />
|
|
151
158
|
</StyledIconWrapper>
|
|
152
159
|
)}
|
|
153
160
|
</StyledReqoreNotification>
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { animated, useTransition } from '@react-spring/web';
|
|
2
|
-
import {
|
|
2
|
+
import { rgba } from 'polished';
|
|
3
3
|
import React, { forwardRef, useEffect, useState } from 'react';
|
|
4
4
|
import { useMount, useUnmount } from 'react-use';
|
|
5
5
|
import styled, { css, keyframes } from 'styled-components';
|
|
6
6
|
import { SPRING_CONFIG } from '../../constants/animations';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ICON_WRAPPER_FROM_HEADER_SIZE,
|
|
9
|
+
PADDING_FROM_SIZE,
|
|
10
|
+
TABS_SIZE_TO_PX,
|
|
11
|
+
TEXT_FROM_SIZE,
|
|
12
|
+
TSizes,
|
|
13
|
+
} from '../../constants/sizes';
|
|
8
14
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
9
15
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
10
16
|
import { fadeIn } from '../../helpers/animations';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
changeLightness,
|
|
14
|
-
getNotificationIntent,
|
|
15
|
-
getReadableColorFrom,
|
|
16
|
-
} from '../../helpers/colors';
|
|
17
|
-
import { IWithReqoreEffect } from '../../types/global';
|
|
17
|
+
import { changeLightness, getNotificationIntent, getReadableColor } from '../../helpers/colors';
|
|
18
|
+
import { IWithReqoreEffect, IWithReqoreMinimal } from '../../types/global';
|
|
18
19
|
import { IReqoreIconName } from '../../types/icons';
|
|
19
20
|
import { StyledEffect } from '../Effect';
|
|
21
|
+
import { ReqoreHeading } from '../Header';
|
|
20
22
|
import ReqoreIcon from '../Icon';
|
|
21
23
|
|
|
22
24
|
export type IReqoreNotificationType = TReqoreIntent;
|
|
23
25
|
|
|
24
|
-
export interface IReqoreNotificationProps extends IWithReqoreEffect {
|
|
26
|
+
export interface IReqoreNotificationProps extends IWithReqoreEffect, IWithReqoreMinimal {
|
|
25
27
|
type?: IReqoreNotificationType;
|
|
26
28
|
intent?: TReqoreIntent;
|
|
27
29
|
title?: string;
|
|
@@ -33,7 +35,6 @@ export interface IReqoreNotificationProps extends IWithReqoreEffect {
|
|
|
33
35
|
onFinish?: () => any;
|
|
34
36
|
fluid?: boolean;
|
|
35
37
|
flat?: boolean;
|
|
36
|
-
inverted?: boolean;
|
|
37
38
|
size?: TSizes;
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -46,7 +47,7 @@ export interface IReqoreNotificationStyle {
|
|
|
46
47
|
hasShadow?: boolean;
|
|
47
48
|
fluid?: boolean;
|
|
48
49
|
flat?: boolean;
|
|
49
|
-
|
|
50
|
+
minimal?: boolean;
|
|
50
51
|
size?: TSizes;
|
|
51
52
|
asMessage?: boolean;
|
|
52
53
|
}
|
|
@@ -79,8 +80,6 @@ export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotification
|
|
|
79
80
|
animation: 0.2s ${fadeIn} ease-in;
|
|
80
81
|
`};
|
|
81
82
|
|
|
82
|
-
font-size: ${({ size = 'normal' }) => TEXT_FROM_SIZE[size]}px;
|
|
83
|
-
|
|
84
83
|
&:not(:first-child) {
|
|
85
84
|
margin-top: ${({ asMessage }) => (asMessage ? undefined : `10px`)};
|
|
86
85
|
}
|
|
@@ -93,13 +92,13 @@ export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotification
|
|
|
93
92
|
timeout,
|
|
94
93
|
hasShadow,
|
|
95
94
|
flat,
|
|
96
|
-
|
|
95
|
+
minimal,
|
|
97
96
|
}: IReqoreNotificationStyle) => css`
|
|
98
|
-
background-color: ${
|
|
97
|
+
background-color: ${minimal
|
|
98
|
+
? 'transparent'
|
|
99
|
+
: rgba(getNotificationIntent(theme, intent || type), 0.3)};
|
|
99
100
|
border: ${flat ? 0 : '1px solid'};
|
|
100
|
-
border-color: ${
|
|
101
|
-
? getNotificationIntent(theme, intent || type)
|
|
102
|
-
: darken(0.2, getNotificationIntent(theme, intent || type))};
|
|
101
|
+
border-color: ${getNotificationIntent(theme, intent || type)};
|
|
103
102
|
|
|
104
103
|
${hasShadow &&
|
|
105
104
|
css`
|
|
@@ -120,34 +119,39 @@ export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotification
|
|
|
120
119
|
}
|
|
121
120
|
`}
|
|
122
121
|
|
|
123
|
-
color: ${
|
|
124
|
-
? getNotificationIntent(theme, intent || type)
|
|
125
|
-
: getReadableColorFrom(getNotificationIntent(theme, intent || type), true)};
|
|
122
|
+
color: ${getReadableColor(theme, null, null, true, theme.originalMain)};
|
|
126
123
|
|
|
127
124
|
${clickable &&
|
|
128
125
|
css`
|
|
129
126
|
cursor: pointer;
|
|
130
127
|
&:hover {
|
|
131
|
-
background-color: ${
|
|
132
|
-
|
|
133
|
-
|
|
128
|
+
background-color: ${rgba(
|
|
129
|
+
getNotificationIntent(theme, intent || type),
|
|
130
|
+
minimal ? 0.2 : 0.5
|
|
131
|
+
)};
|
|
132
|
+
border-color: ${changeLightness(getNotificationIntent(theme, intent || type), 0.1)};
|
|
134
133
|
}
|
|
135
134
|
`}
|
|
136
135
|
`}
|
|
137
136
|
`;
|
|
138
137
|
|
|
139
138
|
export const StyledIconWrapper = styled.div<IReqoreNotificationStyle>`
|
|
140
|
-
|
|
139
|
+
height: ${({ size = 'normal' }: IReqoreNotificationStyle) =>
|
|
140
|
+
ICON_WRAPPER_FROM_HEADER_SIZE[size]}px;
|
|
141
141
|
flex: 0 1 auto;
|
|
142
142
|
flex-shrink: 0;
|
|
143
143
|
display: flex;
|
|
144
144
|
justify-content: center;
|
|
145
145
|
align-items: center;
|
|
146
146
|
transition: all 0.2s ease-out;
|
|
147
|
+
margin-top: ${({ size = 'normal' }: IReqoreNotificationStyle) => `${PADDING_FROM_SIZE[size]}px`};
|
|
147
148
|
|
|
148
149
|
${({ clickable, theme, intent, type }) =>
|
|
149
150
|
clickable &&
|
|
150
151
|
css`
|
|
152
|
+
margin-top: unset;
|
|
153
|
+
height: unset;
|
|
154
|
+
|
|
151
155
|
.reqore-icon {
|
|
152
156
|
transform: scale(0.85);
|
|
153
157
|
}
|
|
@@ -178,12 +182,17 @@ export const StyledNotificationTitle = styled.h4`
|
|
|
178
182
|
align-items: center;
|
|
179
183
|
`;
|
|
180
184
|
|
|
181
|
-
export const StyledNotificationContent = styled.
|
|
185
|
+
export const StyledNotificationContent = styled.div`
|
|
182
186
|
margin: 0;
|
|
183
187
|
padding: 0;
|
|
184
188
|
flex: 1;
|
|
185
|
-
|
|
186
|
-
|
|
189
|
+
font-size: ${({ size = 'normal' }) => TEXT_FROM_SIZE[size]}px;
|
|
190
|
+
|
|
191
|
+
${({ hasTitle, size = 'normal' }) =>
|
|
192
|
+
hasTitle &&
|
|
193
|
+
css`
|
|
194
|
+
padding-top: ${PADDING_FROM_SIZE[size]}px;
|
|
195
|
+
`}
|
|
187
196
|
`;
|
|
188
197
|
|
|
189
198
|
export const typeToIcon: { [type: string]: IReqoreIconName } = {
|
|
@@ -208,7 +217,7 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
|
|
|
208
217
|
duration,
|
|
209
218
|
onFinish,
|
|
210
219
|
flat,
|
|
211
|
-
|
|
220
|
+
minimal,
|
|
212
221
|
size = 'normal',
|
|
213
222
|
},
|
|
214
223
|
ref: any
|
|
@@ -259,7 +268,7 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
|
|
|
259
268
|
clickable={!!onClick}
|
|
260
269
|
onClick={onClick}
|
|
261
270
|
flat={flat}
|
|
262
|
-
|
|
271
|
+
minimal={minimal}
|
|
263
272
|
className='reqore-notification'
|
|
264
273
|
ref={ref}
|
|
265
274
|
style={styles}
|
|
@@ -267,16 +276,14 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
|
|
|
267
276
|
>
|
|
268
277
|
{type || intent || icon ? (
|
|
269
278
|
<StyledIconWrapper type={type || intent} size={size}>
|
|
270
|
-
<ReqoreIcon
|
|
271
|
-
icon={icon || typeToIcon[type || intent]}
|
|
272
|
-
margin={'both'}
|
|
273
|
-
size={`${TEXT_FROM_SIZE[size]}px`}
|
|
274
|
-
/>
|
|
279
|
+
<ReqoreIcon icon={icon || typeToIcon[type || intent]} margin={'both'} size={size} />
|
|
275
280
|
</StyledIconWrapper>
|
|
276
281
|
) : null}
|
|
277
282
|
<StyledNotificationContentWrapper size={size}>
|
|
278
|
-
{title && <
|
|
279
|
-
<StyledNotificationContent
|
|
283
|
+
{title && <ReqoreHeading size={size}>{title}</ReqoreHeading>}
|
|
284
|
+
<StyledNotificationContent hasTitle={!!title} size={size}>
|
|
285
|
+
{content}
|
|
286
|
+
</StyledNotificationContent>
|
|
280
287
|
</StyledNotificationContentWrapper>
|
|
281
288
|
<StyledIconWrapper
|
|
282
289
|
type={type || intent}
|
|
@@ -288,7 +295,7 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
|
|
|
288
295
|
onClose && onClose();
|
|
289
296
|
}}
|
|
290
297
|
>
|
|
291
|
-
<ReqoreIcon icon='CloseFill' margin='both' size={
|
|
298
|
+
<ReqoreIcon icon='CloseFill' margin='both' size={size} />
|
|
292
299
|
</StyledIconWrapper>
|
|
293
300
|
</StyledReqoreNotification>
|
|
294
301
|
</ReqoreThemeProvider>
|
|
@@ -5,6 +5,7 @@ import { useUpdateEffect } from 'react-use';
|
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
6
|
import {
|
|
7
7
|
ICON_FROM_HEADER_SIZE,
|
|
8
|
+
PADDING_FROM_SIZE,
|
|
8
9
|
RADIUS_FROM_SIZE,
|
|
9
10
|
TEXT_FROM_SIZE,
|
|
10
11
|
TSizes,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
20
21
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
21
22
|
import { useTooltip } from '../../hooks/useTooltip';
|
|
23
|
+
import { ACTIVE_ICON_SCALE, INACTIVE_ICON_SCALE } from '../../styles';
|
|
22
24
|
import {
|
|
23
25
|
IReqoreIntent,
|
|
24
26
|
IWithReqoreCustomTheme,
|
|
@@ -27,19 +29,20 @@ import {
|
|
|
27
29
|
IWithReqoreTooltip,
|
|
28
30
|
} from '../../types/global';
|
|
29
31
|
import { IReqoreIconName } from '../../types/icons';
|
|
30
|
-
import ReqoreButton, { IReqoreButtonProps } from '../Button';
|
|
32
|
+
import ReqoreButton, { ButtonBadge, IReqoreButtonProps, TReqoreBadge } from '../Button';
|
|
31
33
|
import { StyledCollectionItemContent } from '../Collection/item';
|
|
32
34
|
import ReqoreControlGroup from '../ControlGroup';
|
|
33
35
|
import ReqoreDropdown from '../Dropdown';
|
|
34
36
|
import { IReqoreDropdownItem } from '../Dropdown/list';
|
|
35
37
|
import { IReqoreEffect, StyledEffect } from '../Effect';
|
|
36
38
|
import { ReqoreHeading } from '../Header';
|
|
37
|
-
import ReqoreIcon from '../Icon';
|
|
39
|
+
import ReqoreIcon, { StyledIconWrapper } from '../Icon';
|
|
40
|
+
import { ReqoreSpacer } from '../Spacer';
|
|
38
41
|
|
|
39
42
|
export interface IReqorePanelAction extends IReqoreButtonProps, IWithReqoreTooltip, IReqoreIntent {
|
|
40
43
|
label?: string | number;
|
|
41
44
|
onClick?: () => void;
|
|
42
|
-
actions?: IReqoreDropdownItem[]
|
|
45
|
+
actions?: Omit<IReqoreDropdownItem[], 'value'>;
|
|
43
46
|
// Custom react element
|
|
44
47
|
as?: React.ElementType;
|
|
45
48
|
props?: any;
|
|
@@ -62,7 +65,7 @@ export interface IReqorePanelProps
|
|
|
62
65
|
children?: any;
|
|
63
66
|
icon?: IReqoreIconName;
|
|
64
67
|
label?: string | ReactElement<any>;
|
|
65
|
-
|
|
68
|
+
badge?: TReqoreBadge | TReqoreBadge[];
|
|
66
69
|
collapsible?: boolean;
|
|
67
70
|
isCollapsed?: boolean;
|
|
68
71
|
onClose?: () => void;
|
|
@@ -114,6 +117,10 @@ export const StyledPanel = styled(StyledEffect)<IStyledPanel>`
|
|
|
114
117
|
cursor: pointer;
|
|
115
118
|
|
|
116
119
|
&:hover {
|
|
120
|
+
${StyledPanelTitle} > div > ${StyledIconWrapper} {
|
|
121
|
+
transform: scale(${ACTIVE_ICON_SCALE});
|
|
122
|
+
}
|
|
123
|
+
|
|
117
124
|
background-color: ${rgba(
|
|
118
125
|
darken(0.025, rgba(changeDarkness(getMainBackgroundColor(theme), 0.03), opacity)),
|
|
119
126
|
opacity === 0 ? 0.2 : opacity
|
|
@@ -159,7 +166,7 @@ export const StyledPanel = styled(StyledEffect)<IStyledPanel>`
|
|
|
159
166
|
export const StyledPanelTitle = styled.div<IStyledPanel>`
|
|
160
167
|
display: flex;
|
|
161
168
|
background-color: ${({ theme, opacity = 1 }: IStyledPanel) =>
|
|
162
|
-
rgba(changeLightness(getMainBackgroundColor(theme), 0.
|
|
169
|
+
rgba(changeLightness(getMainBackgroundColor(theme), 0.03), opacity)};
|
|
163
170
|
justify-content: space-between;
|
|
164
171
|
height: 40px;
|
|
165
172
|
align-items: center;
|
|
@@ -175,13 +182,21 @@ export const StyledPanelTitle = styled.div<IStyledPanel>`
|
|
|
175
182
|
overflow: hidden;
|
|
176
183
|
flex: 0 0 auto;
|
|
177
184
|
|
|
185
|
+
> div > ${StyledIconWrapper} {
|
|
186
|
+
transform: scale(${INACTIVE_ICON_SCALE});
|
|
187
|
+
}
|
|
188
|
+
|
|
178
189
|
${({ collapsible }) =>
|
|
179
190
|
collapsible &&
|
|
180
191
|
css`
|
|
181
192
|
cursor: pointer;
|
|
182
193
|
&:hover {
|
|
194
|
+
> div > ${StyledIconWrapper} {
|
|
195
|
+
transform: scale(${ACTIVE_ICON_SCALE});
|
|
196
|
+
}
|
|
197
|
+
|
|
183
198
|
background-color: ${({ theme, opacity = 1 }: IStyledPanel) =>
|
|
184
|
-
rgba(changeLightness(getMainBackgroundColor(theme), 0.
|
|
199
|
+
rgba(changeLightness(getMainBackgroundColor(theme), 0.05), opacity)};
|
|
185
200
|
}
|
|
186
201
|
`}
|
|
187
202
|
`;
|
|
@@ -247,6 +262,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
247
262
|
contentSize = 'normal',
|
|
248
263
|
minimal,
|
|
249
264
|
tooltip,
|
|
265
|
+
badge,
|
|
250
266
|
...rest
|
|
251
267
|
}: IReqorePanelProps,
|
|
252
268
|
ref
|
|
@@ -267,12 +283,17 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
267
283
|
setIsCollapsed(!!isCollapsed);
|
|
268
284
|
}, [isCollapsed]);
|
|
269
285
|
|
|
286
|
+
// Return true if the card has a title bar, otherwise return false.
|
|
270
287
|
const hasTitleBar: boolean = useMemo(
|
|
271
|
-
() => !!label || collapsible || !!onClose || !!size(actions),
|
|
272
|
-
[label, collapsible, onClose, actions]
|
|
288
|
+
() => !!label || collapsible || !!onClose || !!size(actions) || !!badge,
|
|
289
|
+
[label, collapsible, onClose, actions, badge]
|
|
273
290
|
);
|
|
274
291
|
|
|
292
|
+
// If collapsible is true, toggle the isCollapsed state
|
|
293
|
+
// If the isCollapsed state is true, the component is expanded
|
|
294
|
+
// If the isCollapsed state is false, the component is collapsed
|
|
275
295
|
const handleCollapseClick = useCallback(() => {
|
|
296
|
+
// If collapsible is true, toggle the isCollapsed state
|
|
276
297
|
if (collapsible) {
|
|
277
298
|
setIsCollapsed(!_isCollapsed);
|
|
278
299
|
onCollapseChange?.(!_isCollapsed);
|
|
@@ -289,6 +310,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
289
310
|
[bottomActions]
|
|
290
311
|
);
|
|
291
312
|
|
|
313
|
+
// Calculates whether or not the bottom actions should be displayed.
|
|
292
314
|
const hasBottomActions: boolean = useMemo(
|
|
293
315
|
() => !!(size(leftBottomActions) || size(rightBottomActions)),
|
|
294
316
|
[leftBottomActions, rightBottomActions]
|
|
@@ -437,6 +459,16 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
437
459
|
) : (
|
|
438
460
|
label
|
|
439
461
|
)}
|
|
462
|
+
{badge || badge === 0 ? (
|
|
463
|
+
<>
|
|
464
|
+
<ButtonBadge
|
|
465
|
+
color={changeLightness(theme.main, 0.18)}
|
|
466
|
+
size='big'
|
|
467
|
+
content={badge}
|
|
468
|
+
/>
|
|
469
|
+
<ReqoreSpacer width={PADDING_FROM_SIZE.normal} />
|
|
470
|
+
</>
|
|
471
|
+
) : null}
|
|
440
472
|
</StyledPanelTitleHeader>
|
|
441
473
|
<ReqoreControlGroup>
|
|
442
474
|
{actions.map(renderActions)}
|
|
@@ -2,22 +2,18 @@ import React, { ReactElement, useEffect, useState } from 'react';
|
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { TSizes } from '../../constants/sizes';
|
|
4
4
|
import { IReqoreCustomTheme, TReqoreIntent } from '../../constants/theme';
|
|
5
|
-
import { TReqoreTooltipProp } from '../../types/global';
|
|
6
5
|
import { IReqoreIconName } from '../../types/icons';
|
|
6
|
+
import { IReqoreButtonProps } from '../Button';
|
|
7
7
|
import ReqoreTabsList from './list';
|
|
8
8
|
|
|
9
|
-
export interface IReqoreTabsListItem {
|
|
9
|
+
export interface IReqoreTabsListItem extends Omit<IReqoreButtonProps, 'id'> {
|
|
10
10
|
label: string;
|
|
11
|
-
icon?: IReqoreIconName;
|
|
12
11
|
as?: any;
|
|
13
|
-
disabled?: boolean;
|
|
14
12
|
id: string | number;
|
|
15
|
-
tooltip?: TReqoreTooltipProp;
|
|
16
13
|
props?: React.HTMLAttributes<any>;
|
|
17
14
|
onClick?: (event: any) => any;
|
|
18
15
|
onCloseClick?: (id: string | number) => any;
|
|
19
16
|
activeIntent?: TReqoreIntent;
|
|
20
|
-
intent?: TReqoreIntent;
|
|
21
17
|
closeIcon?: IReqoreIconName;
|
|
22
18
|
}
|
|
23
19
|
|
|
@@ -3,11 +3,10 @@ import styled, { css } from 'styled-components';
|
|
|
3
3
|
import { IReqoreTabsListItem } from '.';
|
|
4
4
|
import { TABS_PADDING_TO_PX, TSizes } from '../../constants/sizes';
|
|
5
5
|
import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
|
|
6
|
-
import { changeLightness } from '../../helpers/colors';
|
|
7
6
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
8
7
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
9
8
|
import { IWithReqoreFlat } from '../../types/global';
|
|
10
|
-
import ReqoreButton from '../Button';
|
|
9
|
+
import ReqoreButton, { StyledButton } from '../Button';
|
|
11
10
|
import ReqoreControlGroup from '../ControlGroup';
|
|
12
11
|
|
|
13
12
|
export interface IReqoreTabListItemProps extends IReqoreTabsListItem, IWithReqoreFlat {
|
|
@@ -28,7 +27,7 @@ export interface IReqoreTabListItemStyle extends IReqoreTabListItemProps {
|
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
|
|
31
|
-
${({
|
|
30
|
+
${({ disabled, vertical, size, fill }: IReqoreTabListItemStyle) => {
|
|
32
31
|
return css`
|
|
33
32
|
display: flex;
|
|
34
33
|
flex-shrink: 0;
|
|
@@ -37,19 +36,30 @@ export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
|
|
|
37
36
|
align-items: center;
|
|
38
37
|
width: ${vertical ? `100%` : undefined};
|
|
39
38
|
padding: ${vertical ? `${TABS_PADDING_TO_PX[size!]}px` : `${TABS_PADDING_TO_PX[size!]}px`};
|
|
40
|
-
${
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
padding-bottom: ${!vertical && 0};
|
|
40
|
+
padding-right: ${vertical && 0};
|
|
41
|
+
|
|
42
|
+
${vertical
|
|
43
|
+
? css`
|
|
44
|
+
${StyledButton}:last-child {
|
|
45
|
+
border-right: 0;
|
|
46
|
+
}
|
|
47
|
+
${StyledButton}:last-child {
|
|
48
|
+
border-top-right-radius: 0;
|
|
49
|
+
border-bottom-right-radius: 0;
|
|
50
|
+
}
|
|
51
|
+
`
|
|
52
|
+
: css`
|
|
53
|
+
${StyledButton} {
|
|
54
|
+
border-bottom: 0;
|
|
55
|
+
}
|
|
56
|
+
${StyledButton}:first-child {
|
|
57
|
+
border-bottom-left-radius: 0;
|
|
58
|
+
}
|
|
59
|
+
${StyledButton}:last-child {
|
|
60
|
+
border-bottom-right-radius: 0;
|
|
61
|
+
}
|
|
62
|
+
`}
|
|
53
63
|
|
|
54
64
|
${fill &&
|
|
55
65
|
css`
|
|
@@ -98,13 +108,13 @@ const ReqoreTabsListItem = memo(
|
|
|
98
108
|
className,
|
|
99
109
|
flat = true,
|
|
100
110
|
wrapTabNames,
|
|
111
|
+
id,
|
|
112
|
+
...rest
|
|
101
113
|
}: IReqoreTabListItemProps,
|
|
102
114
|
ref
|
|
103
115
|
) => {
|
|
104
116
|
const { targetRef } = useCombinedRefs(ref);
|
|
105
117
|
const theme = useReqoreTheme('main', customTheme);
|
|
106
|
-
const _intent = activeIntent || intent;
|
|
107
|
-
const activeColor = _intent ? theme.intents[_intent] : changeLightness(theme.main, 0.05);
|
|
108
118
|
|
|
109
119
|
return (
|
|
110
120
|
<StyledTabListItem
|
|
@@ -112,8 +122,6 @@ const ReqoreTabsListItem = memo(
|
|
|
112
122
|
{...props}
|
|
113
123
|
className={className}
|
|
114
124
|
intent={intent}
|
|
115
|
-
activeIntent={activeIntent}
|
|
116
|
-
activeColor={activeColor}
|
|
117
125
|
as={as}
|
|
118
126
|
size={size}
|
|
119
127
|
active={active}
|
|
@@ -125,7 +133,7 @@ const ReqoreTabsListItem = memo(
|
|
|
125
133
|
{label || icon ? (
|
|
126
134
|
<ReqoreControlGroup stack size={size} fluid={fill || vertical}>
|
|
127
135
|
<ReqoreButton
|
|
128
|
-
flat={
|
|
136
|
+
flat={intent ? false : flat}
|
|
129
137
|
fluid={fill || vertical}
|
|
130
138
|
icon={icon}
|
|
131
139
|
minimal
|
|
@@ -135,21 +143,22 @@ const ReqoreTabsListItem = memo(
|
|
|
135
143
|
disabled={disabled}
|
|
136
144
|
onClick={onClick}
|
|
137
145
|
tooltip={tooltip}
|
|
138
|
-
customTheme={
|
|
146
|
+
customTheme={theme}
|
|
139
147
|
className={`reqore-tabs-list-item ${active ? 'reqore-tabs-list-item-active' : ''}`}
|
|
148
|
+
{...rest}
|
|
140
149
|
>
|
|
141
150
|
{label}
|
|
142
151
|
</ReqoreButton>
|
|
143
152
|
{onCloseClick && !disabled ? (
|
|
144
153
|
<ReqoreButton
|
|
145
154
|
fixed
|
|
146
|
-
flat={
|
|
155
|
+
flat={intent ? false : flat}
|
|
147
156
|
icon={closeIcon || 'CloseLine'}
|
|
148
157
|
intent={active ? activeIntent || intent : intent}
|
|
149
158
|
minimal
|
|
150
159
|
active={active}
|
|
151
160
|
className='reqore-tabs-list-item-close'
|
|
152
|
-
customTheme={
|
|
161
|
+
customTheme={theme}
|
|
153
162
|
onClick={(event) => {
|
|
154
163
|
event.stopPropagation();
|
|
155
164
|
onCloseClick?.();
|