@qoretechnologies/reqore 0.28.4 → 0.28.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/__tests__/button.test.tsx +45 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +5 -5
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts +3 -2
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +28 -24
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts +2 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +8 -8
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +1 -1
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +2 -2
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts +12 -2
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +35 -4
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +28 -34
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Menu/divider.d.ts +2 -0
- package/dist/components/Menu/divider.d.ts.map +1 -1
- package/dist/components/Menu/divider.js +40 -7
- package/dist/components/Menu/divider.js.map +1 -1
- package/dist/components/Message/index.d.ts +3 -2
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Notifications/notification.d.ts +3 -3
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Notifications/notification.js +11 -8
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +6 -6
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/RadioGroup/index.d.ts +8 -6
- package/dist/components/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/RadioGroup/index.js +6 -12
- package/dist/components/RadioGroup/index.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 +7 -3
- package/dist/components/Tag/group.js.map +1 -1
- package/dist/constants/sizes.d.ts +7 -0
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +8 -1
- package/dist/constants/sizes.js.map +1 -1
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +1 -2
- package/dist/helpers/colors.js.map +1 -1
- package/dist/hooks/usePopover.d.ts +6 -2
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +8 -5
- package/src/components/Checkbox/index.tsx +58 -30
- package/src/components/ControlGroup/index.tsx +10 -4
- package/src/components/Dropdown/index.tsx +2 -2
- package/src/components/Icon/index.tsx +75 -1
- package/src/components/InternalPopover/index.tsx +105 -47
- package/src/components/Menu/divider.tsx +20 -3
- package/src/components/Message/index.tsx +3 -0
- package/src/components/Notifications/notification.tsx +23 -13
- package/src/components/Panel/index.tsx +14 -10
- package/src/components/RadioGroup/index.tsx +36 -27
- package/src/components/Tag/group.tsx +5 -2
- package/src/constants/sizes.ts +8 -0
- package/src/helpers/colors.ts +2 -4
- package/src/hooks/usePopover.tsx +15 -2
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +7 -1
- package/src/stories/Icon/Icon.stories.tsx +99 -22
- package/src/stories/Message/Message.stories.tsx +7 -1
- package/src/stories/Panel/Panel.stories.tsx +3 -3
- package/src/stories/Popover/Popover.stories.tsx +91 -12
- package/src/stories/RadioGroup/RadioGroup.stories.tsx +29 -2
- package/src/stories/Tag/Tag.stories.tsx +4 -2
- package/src/stories/utils/args.ts +13 -0
- package/tests.json +1 -1
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { rgba } from 'polished';
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
4
|
+
import { PADDING_FROM_SIZE, SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
5
5
|
import { IReqoreTheme } from '../../constants/theme';
|
|
6
6
|
import { getReadableColor } from '../../helpers/colors';
|
|
7
7
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
8
8
|
import { useTooltip } from '../../hooks/useTooltip';
|
|
9
9
|
import { DisabledElement, ReadOnlyElement } from '../../styles';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
IReqoreDisabled,
|
|
12
|
+
IReqoreReadOnly,
|
|
13
|
+
IWithReqoreEffect,
|
|
14
|
+
TReqoreTooltipProp,
|
|
15
|
+
} from '../../types/global';
|
|
11
16
|
import { IReqoreIconName } from '../../types/icons';
|
|
17
|
+
import { ReqoreTextEffect } from '../Effect';
|
|
12
18
|
import ReqoreIcon from '../Icon';
|
|
13
19
|
|
|
14
20
|
export interface IReqoreCheckboxProps
|
|
15
21
|
extends React.HTMLAttributes<HTMLDivElement>,
|
|
16
22
|
IReqoreDisabled,
|
|
17
|
-
IReqoreReadOnly
|
|
23
|
+
IReqoreReadOnly,
|
|
24
|
+
IWithReqoreEffect {
|
|
18
25
|
label?: string;
|
|
19
26
|
labelDetail?: any;
|
|
20
27
|
labelDetailPosition?: 'left' | 'right';
|
|
@@ -27,12 +34,35 @@ export interface IReqoreCheckboxProps
|
|
|
27
34
|
asSwitch?: boolean;
|
|
28
35
|
uncheckedIcon?: IReqoreIconName;
|
|
29
36
|
checkedIcon?: IReqoreIconName;
|
|
37
|
+
image?: string;
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
export interface IReqoreCheckboxStyle extends IReqoreCheckboxProps {
|
|
33
41
|
theme: IReqoreTheme;
|
|
34
42
|
}
|
|
35
43
|
|
|
44
|
+
const StyledSwitchToggle = styled.div`
|
|
45
|
+
transition: all 0.2s ease-in-out;
|
|
46
|
+
content: '';
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
position: absolute;
|
|
51
|
+
height: ${({ size }) => SIZE_TO_PX[size] - 13}px;
|
|
52
|
+
width: ${({ size }) => SIZE_TO_PX[size] - 13}px;
|
|
53
|
+
top: 50%;
|
|
54
|
+
transform: translateY(-50%);
|
|
55
|
+
left: ${({ checked, size }) =>
|
|
56
|
+
!checked ? '5px' : `${SIZE_TO_PX[size] * 1.8 - (SIZE_TO_PX[size] - 7)}px`};
|
|
57
|
+
border-radius: 100%;
|
|
58
|
+
background-color: ${({ theme, checked, transparent }) =>
|
|
59
|
+
transparent
|
|
60
|
+
? 'transparent'
|
|
61
|
+
: !checked
|
|
62
|
+
? rgba(getReadableColor(theme, undefined, undefined), 0.2)
|
|
63
|
+
: getReadableColor(theme, undefined, undefined)};
|
|
64
|
+
`;
|
|
65
|
+
|
|
36
66
|
const StyledSwitch = styled.div<IReqoreCheckboxStyle>`
|
|
37
67
|
transition: all 0.2s ease-out;
|
|
38
68
|
position: relative;
|
|
@@ -42,32 +72,14 @@ const StyledSwitch = styled.div<IReqoreCheckboxStyle>`
|
|
|
42
72
|
|
|
43
73
|
border: 1px solid
|
|
44
74
|
${({ theme, checked }) =>
|
|
45
|
-
rgba(getReadableColor(theme, undefined, undefined), checked ? 0.
|
|
75
|
+
rgba(getReadableColor(theme, undefined, undefined), checked ? 0.8 : 0.2)};
|
|
46
76
|
border-radius: 50px;
|
|
47
77
|
|
|
48
|
-
margin-right: ${({
|
|
49
|
-
margin-left: ${({
|
|
78
|
+
margin-right: ${({ size }) => PADDING_FROM_SIZE[size]}px;
|
|
79
|
+
margin-left: ${({ size }) => PADDING_FROM_SIZE[size]}px;
|
|
50
80
|
|
|
51
81
|
background-color: ${({ theme, checked }) =>
|
|
52
|
-
checked ? rgba(getReadableColor(theme, undefined, undefined), 0.
|
|
53
|
-
|
|
54
|
-
&::before {
|
|
55
|
-
transition: all 0.2s ease-in-out;
|
|
56
|
-
content: '';
|
|
57
|
-
display: block;
|
|
58
|
-
position: absolute;
|
|
59
|
-
height: ${({ size }) => SIZE_TO_PX[size] - 13}px;
|
|
60
|
-
width: ${({ size }) => SIZE_TO_PX[size] - 13}px;
|
|
61
|
-
top: 50%;
|
|
62
|
-
transform: translateY(-50%);
|
|
63
|
-
left: ${({ checked, size }) =>
|
|
64
|
-
!checked ? '5px' : `${SIZE_TO_PX[size] * 1.8 - (SIZE_TO_PX[size] - 7)}px`};
|
|
65
|
-
border-radius: 100%;
|
|
66
|
-
background-color: ${({ theme, checked }) =>
|
|
67
|
-
!checked
|
|
68
|
-
? rgba(getReadableColor(theme, undefined, undefined), 0.2)
|
|
69
|
-
: getReadableColor(theme, undefined, undefined)};
|
|
70
|
-
}
|
|
82
|
+
checked ? rgba(getReadableColor(theme, undefined, undefined), 0.1) : 'transparent'};
|
|
71
83
|
`;
|
|
72
84
|
|
|
73
85
|
const StyledCheckbox = styled.div<IReqoreCheckboxStyle>`
|
|
@@ -122,6 +134,8 @@ const Checkbox = forwardRef<HTMLDivElement, IReqoreCheckboxProps>(
|
|
|
122
134
|
uncheckedIcon = 'CheckboxBlankCircleLine',
|
|
123
135
|
checkedIcon = 'CheckboxCircleFill',
|
|
124
136
|
readOnly,
|
|
137
|
+
effect,
|
|
138
|
+
image,
|
|
125
139
|
...rest
|
|
126
140
|
}: IReqoreCheckboxProps,
|
|
127
141
|
ref
|
|
@@ -143,23 +157,37 @@ const Checkbox = forwardRef<HTMLDivElement, IReqoreCheckboxProps>(
|
|
|
143
157
|
{label && labelPosition === 'left' ? (
|
|
144
158
|
<>
|
|
145
159
|
{labelDetailPosition === 'left' && labelDetail}
|
|
146
|
-
<
|
|
160
|
+
<ReqoreTextEffect
|
|
161
|
+
effect={{ ...effect, interactive: !disabled && !readOnly && !checked }}
|
|
162
|
+
>
|
|
163
|
+
{label}
|
|
164
|
+
</ReqoreTextEffect>
|
|
147
165
|
{labelDetailPosition === 'right' && labelDetail}
|
|
148
166
|
</>
|
|
149
167
|
) : null}
|
|
150
168
|
{asSwitch ? (
|
|
151
|
-
<StyledSwitch size={size} labelPosition={labelPosition} checked={checked}
|
|
169
|
+
<StyledSwitch size={size} labelPosition={labelPosition} checked={checked}>
|
|
170
|
+
<StyledSwitchToggle size={size} checked={checked} transparent={!!image}>
|
|
171
|
+
{image ? <ReqoreIcon size={size} image={image} grayscale={!checked} /> : null}
|
|
172
|
+
</StyledSwitchToggle>
|
|
173
|
+
</StyledSwitch>
|
|
152
174
|
) : (
|
|
153
175
|
<ReqoreIcon
|
|
154
176
|
size={size}
|
|
155
|
-
icon={checked ? checkedIcon : uncheckedIcon}
|
|
156
|
-
|
|
177
|
+
icon={!image ? (checked ? checkedIcon : uncheckedIcon) : undefined}
|
|
178
|
+
image={image}
|
|
179
|
+
grayscale={image ? !checked : undefined}
|
|
180
|
+
margin='both'
|
|
157
181
|
/>
|
|
158
182
|
)}
|
|
159
183
|
{label && labelPosition === 'right' ? (
|
|
160
184
|
<>
|
|
161
185
|
{labelDetailPosition === 'left' && labelDetail}
|
|
162
|
-
<
|
|
186
|
+
<ReqoreTextEffect
|
|
187
|
+
effect={{ ...effect, interactive: !disabled && !readOnly && !checked }}
|
|
188
|
+
>
|
|
189
|
+
{label}
|
|
190
|
+
</ReqoreTextEffect>
|
|
163
191
|
{labelDetailPosition === 'right' && labelDetail}
|
|
164
192
|
</>
|
|
165
193
|
) : null}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import { RADIUS_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
3
|
+
import { GAP_FROM_SIZE, RADIUS_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
4
4
|
import { IReqoreTheme } from '../../constants/theme';
|
|
5
5
|
|
|
6
6
|
export interface IReqoreControlGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -10,6 +10,7 @@ export interface IReqoreControlGroupProps extends React.HTMLAttributes<HTMLDivEl
|
|
|
10
10
|
children: any;
|
|
11
11
|
fluid?: boolean;
|
|
12
12
|
rounded?: boolean;
|
|
13
|
+
gapSize?: TSizes;
|
|
13
14
|
/*
|
|
14
15
|
* Whether the contents of the control group should be stacked vertically
|
|
15
16
|
*/
|
|
@@ -39,7 +40,8 @@ export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
|
|
|
39
40
|
> .reqore-tag,
|
|
40
41
|
> * {
|
|
41
42
|
&:not(:last-child) {
|
|
42
|
-
margin-bottom: ${({ stack }) =>
|
|
43
|
+
margin-bottom: ${({ stack, gapSize }) =>
|
|
44
|
+
!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined};
|
|
43
45
|
border-bottom: ${({ stack }) => (!stack ? undefined : 0)};
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -61,7 +63,8 @@ export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
> .reqore-control-wrapper:not(:last-child) .reqore-control {
|
|
64
|
-
margin-bottom: ${({ stack }) =>
|
|
66
|
+
margin-bottom: ${({ stack, gapSize }) =>
|
|
67
|
+
!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined};
|
|
65
68
|
border-bottom: ${({ stack }) => (!stack ? undefined : 0)};
|
|
66
69
|
}
|
|
67
70
|
`
|
|
@@ -71,7 +74,8 @@ export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
|
|
|
71
74
|
> .reqore-tag,
|
|
72
75
|
> * {
|
|
73
76
|
&:not(:last-child) {
|
|
74
|
-
margin-right: ${({ stack }) =>
|
|
77
|
+
margin-right: ${({ stack, gapSize }) =>
|
|
78
|
+
!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined};
|
|
75
79
|
border-right: ${({ stack }) => (!stack ? undefined : 0)};
|
|
76
80
|
}
|
|
77
81
|
|
|
@@ -99,6 +103,7 @@ const ReqoreControlGroup = ({
|
|
|
99
103
|
className,
|
|
100
104
|
minimal,
|
|
101
105
|
size = 'normal',
|
|
106
|
+
gapSize = 'normal',
|
|
102
107
|
fluid,
|
|
103
108
|
rounded = true,
|
|
104
109
|
...rest
|
|
@@ -106,6 +111,7 @@ const ReqoreControlGroup = ({
|
|
|
106
111
|
<StyledReqoreControlGroup
|
|
107
112
|
{...rest}
|
|
108
113
|
size={size}
|
|
114
|
+
gapSize={gapSize}
|
|
109
115
|
rounded={rounded}
|
|
110
116
|
fluid={fluid}
|
|
111
117
|
className={`${className || ''} reqore-control-group`}
|
|
@@ -47,7 +47,7 @@ function ReqoreDropdown<T extends unknown = IReqoreButtonProps>({
|
|
|
47
47
|
maxHeight,
|
|
48
48
|
maxWidth,
|
|
49
49
|
noArrow = true,
|
|
50
|
-
|
|
50
|
+
transparent,
|
|
51
51
|
openOnMount,
|
|
52
52
|
show,
|
|
53
53
|
targetElement,
|
|
@@ -90,7 +90,7 @@ function ReqoreDropdown<T extends unknown = IReqoreButtonProps>({
|
|
|
90
90
|
maxHeight={maxHeight}
|
|
91
91
|
maxWidth={maxWidth}
|
|
92
92
|
noArrow={noArrow}
|
|
93
|
-
|
|
93
|
+
transparent={transparent}
|
|
94
94
|
useTargetWidth={useTargetWidth}
|
|
95
95
|
component={component || ReqoreButton}
|
|
96
96
|
componentProps={componentProps}
|
|
@@ -10,12 +10,22 @@ import { isStringSize } from '../../helpers/utils';
|
|
|
10
10
|
import { IReqoreIconName } from '../../types/icons';
|
|
11
11
|
|
|
12
12
|
export interface IReqoreIconProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
13
|
-
icon
|
|
13
|
+
icon?: IReqoreIconName;
|
|
14
14
|
color?: string;
|
|
15
15
|
size?: TSizes | string;
|
|
16
16
|
iconProps?: IconBaseProps;
|
|
17
17
|
intent?: TReqoreIntent;
|
|
18
18
|
margin?: 'right' | 'left' | 'both';
|
|
19
|
+
image?: string;
|
|
20
|
+
rounded?: boolean;
|
|
21
|
+
grayscale?: boolean;
|
|
22
|
+
blur?: number;
|
|
23
|
+
sepia?: boolean;
|
|
24
|
+
invert?: boolean;
|
|
25
|
+
opacity?: number;
|
|
26
|
+
brightness?: number;
|
|
27
|
+
contrast?: number;
|
|
28
|
+
saturate?: number;
|
|
19
29
|
}
|
|
20
30
|
|
|
21
31
|
export const StyledIconWrapper = styled.span<{ margin: 'right' | 'left' | 'both' }>`
|
|
@@ -23,6 +33,51 @@ export const StyledIconWrapper = styled.span<{ margin: 'right' | 'left' | 'both'
|
|
|
23
33
|
flex: 0 0 auto;
|
|
24
34
|
vertical-align: text-bottom;
|
|
25
35
|
transition: all 0.2s ease-out;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
|
|
38
|
+
border-radius: ${({ rounded }) => (rounded ? '50%' : undefined)};
|
|
39
|
+
|
|
40
|
+
${({ grayscale }) =>
|
|
41
|
+
grayscale &&
|
|
42
|
+
css`
|
|
43
|
+
filter: grayscale(100%);
|
|
44
|
+
`};
|
|
45
|
+
${({ blur }) =>
|
|
46
|
+
blur &&
|
|
47
|
+
css`
|
|
48
|
+
filter: blur(${blur}px);
|
|
49
|
+
`};
|
|
50
|
+
${({ sepia }) =>
|
|
51
|
+
sepia &&
|
|
52
|
+
css`
|
|
53
|
+
filter: sepia(100%);
|
|
54
|
+
`};
|
|
55
|
+
${({ invert }) =>
|
|
56
|
+
invert &&
|
|
57
|
+
css`
|
|
58
|
+
filter: invert(100%);
|
|
59
|
+
`};
|
|
60
|
+
${({ opacity }) =>
|
|
61
|
+
opacity || opacity === 0
|
|
62
|
+
? css`
|
|
63
|
+
opacity: ${opacity};
|
|
64
|
+
`
|
|
65
|
+
: undefined};
|
|
66
|
+
${({ brightness }) =>
|
|
67
|
+
brightness &&
|
|
68
|
+
css`
|
|
69
|
+
filter: brightness(${brightness}%);
|
|
70
|
+
`};
|
|
71
|
+
${({ contrast }) =>
|
|
72
|
+
contrast &&
|
|
73
|
+
css`
|
|
74
|
+
filter: contrast(${contrast}%);
|
|
75
|
+
`};
|
|
76
|
+
${({ saturate }) =>
|
|
77
|
+
saturate &&
|
|
78
|
+
css`
|
|
79
|
+
filter: saturate(${saturate}%);
|
|
80
|
+
`};
|
|
26
81
|
|
|
27
82
|
${({ margin, size }) =>
|
|
28
83
|
margin &&
|
|
@@ -38,6 +93,10 @@ export const StyledIconWrapper = styled.span<{ margin: 'right' | 'left' | 'both'
|
|
|
38
93
|
: '10px'
|
|
39
94
|
: undefined};
|
|
40
95
|
`}
|
|
96
|
+
|
|
97
|
+
img {
|
|
98
|
+
width: 100%;
|
|
99
|
+
}
|
|
41
100
|
`;
|
|
42
101
|
|
|
43
102
|
const ReqoreIcon = memo(
|
|
@@ -50,6 +109,7 @@ const ReqoreIcon = memo(
|
|
|
50
109
|
style = {},
|
|
51
110
|
iconProps,
|
|
52
111
|
intent,
|
|
112
|
+
image,
|
|
53
113
|
...rest
|
|
54
114
|
}: IReqoreIconProps) => {
|
|
55
115
|
const theme = useContext(ReqoreThemeContext);
|
|
@@ -57,6 +117,20 @@ const ReqoreIcon = memo(
|
|
|
57
117
|
const finalColor: string | undefined = intent ? theme.intents[intent] : color;
|
|
58
118
|
const finalSize: string = isStringSize(size) ? ICON_FROM_SIZE[size] : size;
|
|
59
119
|
|
|
120
|
+
if (image) {
|
|
121
|
+
return (
|
|
122
|
+
<StyledIconWrapper
|
|
123
|
+
{...rest}
|
|
124
|
+
size={size}
|
|
125
|
+
margin={margin}
|
|
126
|
+
className={`${className || ''} reqore-icon`}
|
|
127
|
+
style={{ ...style, width: finalSize, height: finalSize }}
|
|
128
|
+
>
|
|
129
|
+
<img src={image} alt='' />
|
|
130
|
+
</StyledIconWrapper>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
60
134
|
if (!Icon) {
|
|
61
135
|
return (
|
|
62
136
|
<StyledIconWrapper
|
|
@@ -1,15 +1,44 @@
|
|
|
1
1
|
import { isString } from 'lodash';
|
|
2
|
+
import { rgba } from 'polished';
|
|
2
3
|
import React, { MutableRefObject, useContext, useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { usePopper } from 'react-popper';
|
|
4
5
|
import styled, { css } from 'styled-components';
|
|
6
|
+
import { RADIUS_FROM_SIZE } from '../../constants/sizes';
|
|
5
7
|
import { IReqoreTheme } from '../../constants/theme';
|
|
6
8
|
import { IPopoverData } from '../../containers/PopoverProvider';
|
|
7
9
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
8
10
|
import PopoverContext from '../../context/PopoverContext';
|
|
9
11
|
import { fadeIn } from '../../helpers/animations';
|
|
10
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
changeLightness,
|
|
14
|
+
getColorFromMaybeString,
|
|
15
|
+
getNotificationIntent,
|
|
16
|
+
} from '../../helpers/colors';
|
|
11
17
|
import { StyledBackdrop } from '../Drawer';
|
|
12
|
-
import
|
|
18
|
+
import ReqoreMessage from '../Message';
|
|
19
|
+
|
|
20
|
+
const getPopoverArrowColor = ({ theme, dim, intent, flat, effect, isOpaque }) =>
|
|
21
|
+
rgba(
|
|
22
|
+
effect
|
|
23
|
+
? changeLightness(
|
|
24
|
+
getColorFromMaybeString(
|
|
25
|
+
theme,
|
|
26
|
+
effect.gradient.borderColor || Object.values(effect.gradient.colors)[0]
|
|
27
|
+
),
|
|
28
|
+
0.04
|
|
29
|
+
)
|
|
30
|
+
: intent
|
|
31
|
+
? changeLightness(getNotificationIntent(theme, intent), flat ? 0.1 : 0.2)
|
|
32
|
+
: theme.popover?.main ||
|
|
33
|
+
rgba(
|
|
34
|
+
changeLightness(
|
|
35
|
+
flat ? theme.main : getNotificationIntent(theme, intent),
|
|
36
|
+
flat ? 0.1 : 0.2
|
|
37
|
+
),
|
|
38
|
+
isOpaque ? 1 : 0.3
|
|
39
|
+
),
|
|
40
|
+
dim ? 0.3 : 1
|
|
41
|
+
);
|
|
13
42
|
|
|
14
43
|
const StyledPopoverArrow = styled.div<{ theme: IReqoreTheme }>`
|
|
15
44
|
width: 10px;
|
|
@@ -20,15 +49,10 @@ const StyledPopoverArrow = styled.div<{ theme: IReqoreTheme }>`
|
|
|
20
49
|
&:before {
|
|
21
50
|
content: '';
|
|
22
51
|
display: block;
|
|
23
|
-
width:
|
|
24
|
-
height:
|
|
52
|
+
width: 0;
|
|
53
|
+
height: 0;
|
|
25
54
|
position: absolute;
|
|
26
55
|
z-index: -1;
|
|
27
|
-
transform: rotate(45deg);
|
|
28
|
-
${({ theme, opaque }) => css`
|
|
29
|
-
background-color: ${theme.popover?.main || theme.main};
|
|
30
|
-
box-shadow: ${opaque ? undefined : 'rgba(31, 26, 34, 0.6) 0px 0px 4px'};
|
|
31
|
-
`}
|
|
32
56
|
}
|
|
33
57
|
`;
|
|
34
58
|
|
|
@@ -36,40 +60,65 @@ const StyledPopoverWrapper = styled.div<{ theme: IReqoreTheme }>`
|
|
|
36
60
|
animation: 0.2s ${fadeIn} ease-out;
|
|
37
61
|
max-width: ${({ maxWidth = '80vw' }) => maxWidth};
|
|
38
62
|
max-height: ${({ maxHeight = '80vh' }) => maxHeight};
|
|
63
|
+
z-index: 999999;
|
|
64
|
+
border-radius: ${RADIUS_FROM_SIZE.normal}px;
|
|
39
65
|
|
|
40
|
-
${({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
z-index: 999999;
|
|
46
|
-
background-color: transparent;
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return css`
|
|
51
|
-
z-index: 999999;
|
|
52
|
-
background-color: ${defaultColor};
|
|
53
|
-
color: ${getReadableColor(theme, undefined, undefined, false, defaultColor)};
|
|
54
|
-
border-radius: 5.5px;
|
|
55
|
-
box-shadow: rgba(31, 26, 34, 0.6) 0px 0px 4px;
|
|
56
|
-
`;
|
|
57
|
-
}}
|
|
66
|
+
${({ transparent }) =>
|
|
67
|
+
!transparent &&
|
|
68
|
+
css`
|
|
69
|
+
box-shadow: rgba(31, 26, 34, 0.7) 0px 0px 10px;
|
|
70
|
+
`}
|
|
58
71
|
|
|
59
72
|
&[data-popper-placement^='top'] > ${StyledPopoverArrow} {
|
|
60
73
|
bottom: -5px;
|
|
74
|
+
|
|
75
|
+
&:before {
|
|
76
|
+
border-left: 10px solid transparent;
|
|
77
|
+
border-right: 10px solid transparent;
|
|
78
|
+
border-top: 10px solid ${(props) => getPopoverArrowColor(props)};
|
|
79
|
+
|
|
80
|
+
top: 5px;
|
|
81
|
+
left: -5px;
|
|
82
|
+
}
|
|
61
83
|
}
|
|
62
84
|
|
|
63
85
|
&[data-popper-placement^='bottom'] > ${StyledPopoverArrow} {
|
|
64
86
|
top: -5px;
|
|
87
|
+
|
|
88
|
+
&:before {
|
|
89
|
+
border-left: 10px solid transparent;
|
|
90
|
+
border-right: 10px solid transparent;
|
|
91
|
+
border-bottom: 10px solid ${(props) => getPopoverArrowColor(props)};
|
|
92
|
+
|
|
93
|
+
top: -5px;
|
|
94
|
+
left: -5px;
|
|
95
|
+
}
|
|
65
96
|
}
|
|
66
97
|
|
|
67
98
|
&[data-popper-placement^='left'] > ${StyledPopoverArrow} {
|
|
68
99
|
right: -5px;
|
|
100
|
+
|
|
101
|
+
&:before {
|
|
102
|
+
border-top: 10px solid transparent;
|
|
103
|
+
border-bottom: 10px solid transparent;
|
|
104
|
+
border-left: 10px solid ${(props) => getPopoverArrowColor(props)};
|
|
105
|
+
|
|
106
|
+
top: -5px;
|
|
107
|
+
left: 5px;
|
|
108
|
+
}
|
|
69
109
|
}
|
|
70
110
|
|
|
71
111
|
&[data-popper-placement^='right'] > ${StyledPopoverArrow} {
|
|
72
112
|
left: -5px;
|
|
113
|
+
|
|
114
|
+
&:before {
|
|
115
|
+
border-top: 10px solid transparent;
|
|
116
|
+
border-bottom: 10px solid transparent;
|
|
117
|
+
border-right: 10px solid ${(props) => getPopoverArrowColor(props)};
|
|
118
|
+
|
|
119
|
+
top: -5px;
|
|
120
|
+
left: -5px;
|
|
121
|
+
}
|
|
73
122
|
}
|
|
74
123
|
|
|
75
124
|
&[data-popper-reference-hidden='true'] {
|
|
@@ -81,17 +130,9 @@ const StyledPopoverWrapper = styled.div<{ theme: IReqoreTheme }>`
|
|
|
81
130
|
const StyledPopoverContent = styled.div<{ isString?: boolean }>`
|
|
82
131
|
width: 100%;
|
|
83
132
|
height: 100%;
|
|
84
|
-
padding: ${({ isString }) => (isString ? '8px' : '0px')};
|
|
85
133
|
z-index: 20;
|
|
86
134
|
position: relative;
|
|
87
135
|
overflow: hidden;
|
|
88
|
-
background-color: ${({ theme, opaque }) =>
|
|
89
|
-
opaque ? 'transparent' : theme.popover?.main || theme.main};
|
|
90
|
-
border-radius: ${({ opaque }) => (opaque ? undefined : '3.5px')};
|
|
91
|
-
|
|
92
|
-
.reqore-popover-text {
|
|
93
|
-
font-size: 14px;
|
|
94
|
-
}
|
|
95
136
|
`;
|
|
96
137
|
|
|
97
138
|
export interface IReqoreInternalPopoverProps extends IPopoverData {}
|
|
@@ -103,10 +144,16 @@ const InternalPopover: React.FC<IReqoreInternalPopoverProps> = ({
|
|
|
103
144
|
placement,
|
|
104
145
|
noArrow,
|
|
105
146
|
useTargetWidth,
|
|
106
|
-
|
|
147
|
+
transparent,
|
|
107
148
|
maxWidth,
|
|
108
149
|
maxHeight,
|
|
109
150
|
blur,
|
|
151
|
+
intent,
|
|
152
|
+
title,
|
|
153
|
+
icon,
|
|
154
|
+
minimal,
|
|
155
|
+
flat = true,
|
|
156
|
+
effect,
|
|
110
157
|
}) => {
|
|
111
158
|
const { removePopover, updatePopover, uiScale } = useContext(PopoverContext);
|
|
112
159
|
const [popperElement, setPopperElement] = useState(null);
|
|
@@ -165,7 +212,12 @@ const InternalPopover: React.FC<IReqoreInternalPopoverProps> = ({
|
|
|
165
212
|
<StyledPopoverWrapper
|
|
166
213
|
maxWidth={maxWidth}
|
|
167
214
|
maxHeight={maxHeight}
|
|
168
|
-
|
|
215
|
+
transparent={transparent}
|
|
216
|
+
effect={effect}
|
|
217
|
+
isOpaque={!transparent && !minimal}
|
|
218
|
+
intent={intent}
|
|
219
|
+
flat={flat}
|
|
220
|
+
dim={flat && !transparent && !effect && minimal}
|
|
169
221
|
className='reqore-popover-content'
|
|
170
222
|
ref={(el) => {
|
|
171
223
|
setPopperElement(el);
|
|
@@ -178,17 +230,23 @@ const InternalPopover: React.FC<IReqoreInternalPopoverProps> = ({
|
|
|
178
230
|
}}
|
|
179
231
|
{...attributes.popper}
|
|
180
232
|
>
|
|
181
|
-
{!noArrow && (
|
|
182
|
-
<StyledPopoverArrow
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
style={styles.arrow}
|
|
186
|
-
data-popper-arrow
|
|
187
|
-
/>
|
|
188
|
-
)}
|
|
189
|
-
<StyledPopoverContent isString={isString(content)} opaque={opaque}>
|
|
233
|
+
{!noArrow && !transparent ? (
|
|
234
|
+
<StyledPopoverArrow ref={setArrowElement} style={styles.arrow} data-popper-arrow />
|
|
235
|
+
) : null}
|
|
236
|
+
<StyledPopoverContent isString={isString(content)}>
|
|
190
237
|
{isString(content) ? (
|
|
191
|
-
<
|
|
238
|
+
<ReqoreMessage
|
|
239
|
+
opaque={!transparent && !minimal}
|
|
240
|
+
className='reqore-popover-text'
|
|
241
|
+
intent={intent}
|
|
242
|
+
title={title}
|
|
243
|
+
icon={icon}
|
|
244
|
+
minimal={transparent}
|
|
245
|
+
flat={flat || transparent}
|
|
246
|
+
effect={effect}
|
|
247
|
+
>
|
|
248
|
+
{content}
|
|
249
|
+
</ReqoreMessage>
|
|
192
250
|
) : (
|
|
193
251
|
<>
|
|
194
252
|
{React.Children.map(content, (child) =>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
3
|
import { PADDING_FROM_SIZE } from '../../constants/sizes';
|
|
4
4
|
import { getReadableColor } from '../../helpers/colors';
|
|
5
|
+
import { getOneLessSize, isStringSize } from '../../helpers/utils';
|
|
5
6
|
import { IWithReqoreEffect, IWithReqoreSize } from '../../types/global';
|
|
6
7
|
import { IReqoreEffect, StyledTextEffect } from '../Effect';
|
|
7
8
|
|
|
@@ -10,13 +11,29 @@ export interface IReqoreMenuDividerProps
|
|
|
10
11
|
IWithReqoreEffect,
|
|
11
12
|
IWithReqoreSize {
|
|
12
13
|
label?: string;
|
|
14
|
+
margin?: 'left' | 'right' | 'both';
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
const StyledMenuDivider = styled(StyledTextEffect)`
|
|
17
|
+
export const StyledMenuDivider = styled(StyledTextEffect)`
|
|
16
18
|
width: 100%;
|
|
17
19
|
padding: ${({ size }) => `${PADDING_FROM_SIZE[size]}px 0`};
|
|
18
20
|
background-color: transparent;
|
|
19
21
|
|
|
22
|
+
${({ margin, size }) =>
|
|
23
|
+
margin &&
|
|
24
|
+
css`
|
|
25
|
+
margin-left: ${margin === 'left' || margin === 'both'
|
|
26
|
+
? isStringSize(size)
|
|
27
|
+
? `${PADDING_FROM_SIZE[size]}px`
|
|
28
|
+
: '10px'
|
|
29
|
+
: undefined};
|
|
30
|
+
margin-right: ${margin === 'right' || margin === 'both'
|
|
31
|
+
? isStringSize(size)
|
|
32
|
+
? `${PADDING_FROM_SIZE[size]}px`
|
|
33
|
+
: '10px'
|
|
34
|
+
: undefined};
|
|
35
|
+
`}
|
|
36
|
+
|
|
20
37
|
color: ${({ theme }) => getReadableColor(theme, undefined, undefined)};
|
|
21
38
|
`;
|
|
22
39
|
|
|
@@ -33,7 +50,7 @@ const ReqoreMenuDivider = forwardRef<HTMLDivElement, IReqoreMenuDividerProps>(
|
|
|
33
50
|
uppercase: true,
|
|
34
51
|
spaced: 2,
|
|
35
52
|
textAlign: 'center',
|
|
36
|
-
textSize:
|
|
53
|
+
textSize: getOneLessSize(size),
|
|
37
54
|
weight: 'bold',
|
|
38
55
|
...effect,
|
|
39
56
|
} as IReqoreEffect
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
IWithReqoreCustomTheme,
|
|
11
11
|
IWithReqoreEffect,
|
|
12
12
|
IWithReqoreMinimal,
|
|
13
|
+
IWithReqoreOpaque,
|
|
13
14
|
IWithReqoreSize,
|
|
14
15
|
} from '../../types/global';
|
|
15
16
|
import { IReqoreIconName } from '../../types/icons';
|
|
@@ -29,6 +30,7 @@ export interface IReqoreMessageProps
|
|
|
29
30
|
IWithReqoreSize,
|
|
30
31
|
IReqoreIntent,
|
|
31
32
|
IWithReqoreMinimal,
|
|
33
|
+
IWithReqoreOpaque,
|
|
32
34
|
React.HTMLAttributes<HTMLDivElement> {
|
|
33
35
|
title?: string;
|
|
34
36
|
children: any;
|
|
@@ -38,6 +40,7 @@ export interface IReqoreMessageProps
|
|
|
38
40
|
duration?: number;
|
|
39
41
|
onFinish?: () => any;
|
|
40
42
|
flat?: boolean;
|
|
43
|
+
hasShadow?: boolean;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export interface IReqoreNotificationStyle extends IReqoreMessageProps {
|