@qoretechnologies/reqore 0.28.1 → 0.28.3
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__/dropdown.test.tsx +1 -1
- package/__tests__/effect.test.tsx +6 -6
- package/dist/components/Button/index.d.ts +4 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +23 -15
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +2 -2
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts +1 -1
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Dropdown/list.js +1 -2
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/Effect/index.d.ts +14 -6
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js +32 -20
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +1 -2
- package/dist/components/Header/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +6 -3
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Menu/divider.js +1 -4
- package/dist/components/Menu/divider.js.map +1 -1
- package/dist/components/Menu/index.d.ts +3 -2
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +11 -7
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/item.d.ts.map +1 -1
- package/dist/components/Menu/item.js +1 -1
- package/dist/components/Menu/item.js.map +1 -1
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +4 -1
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Table/row.js +4 -2
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Tag/index.d.ts +3 -1
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +11 -5
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +1 -0
- package/dist/components/Textarea/index.d.ts.map +1 -1
- package/dist/components/Textarea/index.js +2 -2
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/constants/colors.js +1 -1
- package/dist/constants/theme.d.ts +43 -42
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/constants/theme.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +1 -1
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/helpers/colors.d.ts +11 -10
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +34 -10
- package/dist/helpers/colors.js.map +1 -1
- package/dist/hooks/useTheme.d.ts +9 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useTheme.js +7 -0
- package/dist/hooks/useTheme.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/Button/index.tsx +34 -11
- package/src/components/ControlGroup/index.tsx +2 -0
- package/src/components/Dropdown/list.tsx +2 -3
- package/src/components/Effect/index.tsx +64 -19
- package/src/components/Header/index.tsx +1 -3
- package/src/components/Input/index.tsx +11 -2
- package/src/components/InternalPopover/index.tsx +2 -1
- package/src/components/Menu/divider.tsx +1 -1
- package/src/components/Menu/index.tsx +16 -7
- package/src/components/Menu/item.tsx +3 -2
- package/src/components/Message/index.tsx +4 -1
- package/src/components/Panel/index.tsx +1 -1
- package/src/components/Table/row.tsx +8 -5
- package/src/components/Tag/index.tsx +18 -6
- package/src/components/Textarea/index.tsx +3 -0
- package/src/constants/colors.ts +1 -1
- package/src/constants/theme.ts +44 -42
- package/src/containers/UIProvider.tsx +1 -1
- package/src/helpers/colors.ts +58 -26
- package/src/hooks/useTheme.ts +20 -3
- package/src/stories/Button/Button.stories.tsx +1 -1
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +9 -1
- package/src/stories/Dropdown/Dropdown.stories.tsx +26 -0
- package/src/stories/Menu/Menu.stories.tsx +52 -3
- package/src/stories/Message/Message.stories.tsx +3 -4
- package/src/stories/Tag/Tag.stories.tsx +25 -1
- package/src/types/global.ts +14 -0
- package/tests.json +1 -1
|
@@ -36,6 +36,7 @@ export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
|
|
|
36
36
|
? css`
|
|
37
37
|
> .reqore-control,
|
|
38
38
|
> .reqore-control-wrapper,
|
|
39
|
+
> .reqore-tag,
|
|
39
40
|
> * {
|
|
40
41
|
&:not(:last-child) {
|
|
41
42
|
margin-bottom: ${({ stack }) => (!stack ? '5px' : undefined)};
|
|
@@ -67,6 +68,7 @@ export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
|
|
|
67
68
|
: css`
|
|
68
69
|
> .reqore-control,
|
|
69
70
|
> .reqore-control-wrapper,
|
|
71
|
+
> .reqore-tag,
|
|
70
72
|
> * {
|
|
71
73
|
&:not(:last-child) {
|
|
72
74
|
margin-right: ${({ stack }) => (!stack ? '5px' : undefined)};
|
|
@@ -3,10 +3,10 @@ import { IReqoreComponent } from '../../types/global';
|
|
|
3
3
|
import ReqoreInput from '../Input';
|
|
4
4
|
import ReqoreMenu from '../Menu';
|
|
5
5
|
import ReqoreMenuItem, { IReqoreMenuItemProps } from '../Menu/item';
|
|
6
|
-
import { ReqoreSpacer } from '../Spacer';
|
|
7
6
|
|
|
8
7
|
export type TDropdownItemOnClick = (item: IReqoreDropdownItem) => void;
|
|
9
|
-
export interface IReqoreDropdownItem
|
|
8
|
+
export interface IReqoreDropdownItem
|
|
9
|
+
extends Omit<IReqoreMenuItemProps, 'onClick' | 'rightIcon' | 'onRightIconClick'> {
|
|
10
10
|
value: any;
|
|
11
11
|
label?: string;
|
|
12
12
|
onClick?: TDropdownItemOnClick;
|
|
@@ -86,7 +86,6 @@ const ReqoreDropdownList = memo(
|
|
|
86
86
|
placeholder='Filter'
|
|
87
87
|
onClearClick={() => setQuery('')}
|
|
88
88
|
/>
|
|
89
|
-
<ReqoreSpacer height={10} />
|
|
90
89
|
</>
|
|
91
90
|
)}
|
|
92
91
|
{filteredItems.map((item: IReqoreDropdownItem, index: number) => (
|
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
import { reduce } from 'lodash';
|
|
2
|
+
import { mix } from 'polished';
|
|
2
3
|
import { HTMLAttributes } from 'react';
|
|
3
4
|
import styled, { css } from 'styled-components';
|
|
4
5
|
import { TEXT_FROM_SIZE, TSizes, WEIGHT_TO_NUMBER } from '../../constants/sizes';
|
|
5
6
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
6
7
|
import {
|
|
7
|
-
changeDarkness,
|
|
8
8
|
changeLightness,
|
|
9
|
-
|
|
9
|
+
getColorFromMaybeString,
|
|
10
|
+
getReadableColorFrom,
|
|
10
11
|
} from '../../helpers/colors';
|
|
11
12
|
|
|
13
|
+
export type TReqoreEffectColorManipulation = 'darken' | 'lighten';
|
|
14
|
+
export type TReqoreEffectColorManipulationMultiplier = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
15
|
+
export type TReqoreHexColor = `#${string}`;
|
|
16
|
+
export type TReqoreColor = TReqoreHexColor | 'transparent';
|
|
17
|
+
export type TReqoreEffectColor =
|
|
18
|
+
| TReqoreColor
|
|
19
|
+
| TReqoreIntent
|
|
20
|
+
| `${TReqoreIntent}:${TReqoreEffectColorManipulation}`
|
|
21
|
+
| `${TReqoreIntent}:${TReqoreEffectColorManipulation}:${TReqoreEffectColorManipulationMultiplier}`
|
|
22
|
+
| 'main'
|
|
23
|
+
| `main:${TReqoreEffectColorManipulation}`
|
|
24
|
+
| `main:${TReqoreEffectColorManipulation}:${TReqoreEffectColorManipulationMultiplier}`;
|
|
25
|
+
export type TReqoreEffectColorList = [
|
|
26
|
+
'main' | TReqoreIntent | TReqoreColor,
|
|
27
|
+
TReqoreEffectColorManipulation | undefined,
|
|
28
|
+
TReqoreEffectColorManipulationMultiplier | undefined
|
|
29
|
+
];
|
|
30
|
+
|
|
12
31
|
export interface IReqoreEffect {
|
|
13
32
|
gradient?: {
|
|
14
33
|
type?: 'linear' | 'radial';
|
|
15
34
|
shape?: 'circle' | 'ellipse';
|
|
16
|
-
colors:
|
|
35
|
+
colors: Record<number, TReqoreEffectColor>;
|
|
17
36
|
direction?: string;
|
|
18
|
-
borderColor?:
|
|
37
|
+
borderColor?: TReqoreEffectColor;
|
|
19
38
|
};
|
|
20
39
|
noWrap?: boolean;
|
|
21
|
-
color?:
|
|
40
|
+
color?: TReqoreEffectColor;
|
|
22
41
|
spaced?: number;
|
|
23
42
|
weight?: number | 'thin' | 'light' | 'normal' | 'bold' | 'thick';
|
|
24
43
|
uppercase?: boolean;
|
|
@@ -26,7 +45,7 @@ export interface IReqoreEffect {
|
|
|
26
45
|
textAlign?: 'left' | 'center' | 'right';
|
|
27
46
|
glow?: {
|
|
28
47
|
size?: number;
|
|
29
|
-
color:
|
|
48
|
+
color: TReqoreEffectColor;
|
|
30
49
|
inset?: boolean;
|
|
31
50
|
blur?: number;
|
|
32
51
|
useBorder?: boolean;
|
|
@@ -55,13 +74,16 @@ export const StyledEffect = styled.span`
|
|
|
55
74
|
effect.gradient.colors,
|
|
56
75
|
(colorsString, color, percentage) =>
|
|
57
76
|
`${colorsString}, ${
|
|
58
|
-
color === 'transparent' || !effect.interactive
|
|
77
|
+
color === 'transparent' || !effect.interactive
|
|
78
|
+
? getColorFromMaybeString(theme, color)
|
|
79
|
+
: changeLightness(getColorFromMaybeString(theme, color), 0.03)
|
|
59
80
|
} ${percentage}%`,
|
|
60
81
|
''
|
|
61
82
|
);
|
|
62
83
|
const gradientColorsActive = reduce(
|
|
63
84
|
effect.gradient.colors,
|
|
64
|
-
(colorsString, color, percentage) =>
|
|
85
|
+
(colorsString, color, percentage) =>
|
|
86
|
+
`${colorsString}, ${getColorFromMaybeString(theme, color)} ${percentage}%`,
|
|
65
87
|
''
|
|
66
88
|
);
|
|
67
89
|
|
|
@@ -72,20 +94,44 @@ export const StyledEffect = styled.span`
|
|
|
72
94
|
const gradient = `${gradientType}-gradient(${gradientDirectionOrShape}${gradientColors})`;
|
|
73
95
|
const gradientActive = `${gradientType}-gradient(${gradientDirectionOrShape}${gradientColorsActive})`;
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
// Determine the text color based on the gradient colors
|
|
98
|
+
let color: TReqoreHexColor | undefined;
|
|
99
|
+
// Only works if there are 2 colors not more and color was not provided
|
|
100
|
+
if (!effect.color) {
|
|
101
|
+
if (Object.keys(effect.gradient.colors).length === 2) {
|
|
102
|
+
const gradientColor1: TReqoreHexColor = getColorFromMaybeString(
|
|
103
|
+
theme,
|
|
104
|
+
Object.values(effect.gradient.colors)[0]
|
|
105
|
+
);
|
|
106
|
+
const gradientColor2: TReqoreHexColor = getColorFromMaybeString(
|
|
107
|
+
theme,
|
|
108
|
+
Object.values(effect.gradient.colors)[1]
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
color = mix(
|
|
112
|
+
0.5,
|
|
113
|
+
gradientColor1 === '#00000000' ? theme.main : gradientColor1,
|
|
114
|
+
gradientColor2 === '#00000000' ? theme.main : gradientColor2
|
|
115
|
+
) as TReqoreHexColor;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
76
118
|
|
|
77
119
|
return css`
|
|
78
120
|
background-image: ${gradient};
|
|
79
121
|
// Get the first color from the colors object
|
|
80
122
|
border-color: ${changeLightness(
|
|
81
|
-
|
|
123
|
+
getColorFromMaybeString(
|
|
82
124
|
theme,
|
|
83
|
-
effect.gradient.borderColor ||
|
|
84
|
-
changeDarkness(Object.values(effect.gradient.colors)[0], 0.05)
|
|
125
|
+
effect.gradient.borderColor || Object.values(effect.gradient.colors)[0]
|
|
85
126
|
),
|
|
86
127
|
0.04
|
|
87
128
|
)} !important;
|
|
88
129
|
|
|
130
|
+
${color &&
|
|
131
|
+
css`
|
|
132
|
+
color: ${getReadableColorFrom(getColorFromMaybeString(theme, color), false)} !important;
|
|
133
|
+
`}
|
|
134
|
+
|
|
89
135
|
${effect.interactive &&
|
|
90
136
|
css`
|
|
91
137
|
cursor: pointer;
|
|
@@ -94,10 +140,9 @@ export const StyledEffect = styled.span`
|
|
|
94
140
|
&:focus,
|
|
95
141
|
&:active {
|
|
96
142
|
background-image: ${gradientActive};
|
|
97
|
-
border-color: ${
|
|
143
|
+
border-color: ${getColorFromMaybeString(
|
|
98
144
|
theme,
|
|
99
|
-
effect.gradient.borderColor ||
|
|
100
|
-
changeDarkness(Object.values(effect.gradient.colors)[0], 0.05)
|
|
145
|
+
effect.gradient.borderColor || Object.values(effect.gradient.colors)[0]
|
|
101
146
|
)} !important;
|
|
102
147
|
}
|
|
103
148
|
`}
|
|
@@ -112,13 +157,13 @@ export const StyledEffect = styled.span`
|
|
|
112
157
|
if (effect.glow.useBorder) {
|
|
113
158
|
return css`
|
|
114
159
|
border: ${effect.glow.size || 2}px solid
|
|
115
|
-
${
|
|
160
|
+
${getColorFromMaybeString(theme, effect.glow.color)} !important;
|
|
116
161
|
`;
|
|
117
162
|
}
|
|
118
163
|
|
|
119
164
|
return css`
|
|
120
165
|
box-shadow: ${effect.glow.inset ? 'inset ' : ''} 0 0 ${effect.glow.blur || 0}
|
|
121
|
-
${effect.glow.size || 2}px ${
|
|
166
|
+
${effect.glow.size || 2}px ${getColorFromMaybeString(theme, effect.glow.color)};
|
|
122
167
|
`;
|
|
123
168
|
}}
|
|
124
169
|
|
|
@@ -158,10 +203,10 @@ export const StyledEffect = styled.span`
|
|
|
158
203
|
`
|
|
159
204
|
: undefined}
|
|
160
205
|
|
|
161
|
-
${({ effect }: IReqoreTextEffectProps) =>
|
|
206
|
+
${({ effect, theme }: IReqoreTextEffectProps) =>
|
|
162
207
|
effect && effect.color
|
|
163
208
|
? css`
|
|
164
|
-
color: ${effect.color} !important;
|
|
209
|
+
color: ${getColorFromMaybeString(theme, effect.color)} !important;
|
|
165
210
|
`
|
|
166
211
|
: undefined}
|
|
167
212
|
|
|
@@ -2,7 +2,6 @@ import { memo, useMemo } from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { HEADER_SIZE_TO_NUMBER, TSizes } from '../../constants/sizes';
|
|
4
4
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
5
|
-
import { getReadableColor } from '../../helpers/colors';
|
|
6
5
|
import { isStringSize } from '../../helpers/utils';
|
|
7
6
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
8
7
|
import { IWithReqoreEffect } from '../../types/global';
|
|
@@ -23,8 +22,7 @@ export interface IReqoreHeadingStyle extends IReqoreHeadingProps {
|
|
|
23
22
|
export const StyledHeader = styled(StyledTextEffect)`
|
|
24
23
|
margin: 0;
|
|
25
24
|
padding: 0;
|
|
26
|
-
color: ${({ theme, intent }) =>
|
|
27
|
-
intent ? theme.intents[intent] : getReadableColor(theme, undefined, undefined, true)};
|
|
25
|
+
color: ${({ theme, intent }) => (intent ? theme.intents[intent] : 'inherit')};
|
|
28
26
|
`;
|
|
29
27
|
|
|
30
28
|
export const ReqoreHeading = memo(
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { rgba } from 'polished';
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
PADDING_FROM_SIZE,
|
|
6
|
+
RADIUS_FROM_SIZE,
|
|
7
|
+
SIZE_TO_PX,
|
|
8
|
+
TEXT_FROM_SIZE,
|
|
9
|
+
TSizes,
|
|
10
|
+
} from '../../constants/sizes';
|
|
5
11
|
import { IReqoreTheme } from '../../constants/theme';
|
|
6
12
|
import { changeLightness, getReadableColor } from '../../helpers/colors';
|
|
7
13
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
@@ -41,6 +47,7 @@ export interface IReqoreInputProps
|
|
|
41
47
|
flat?: boolean;
|
|
42
48
|
rounded?: boolean;
|
|
43
49
|
type?: 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
|
|
50
|
+
wrapperStyle?: React.CSSProperties;
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
export interface IReqoreInputStyle extends IReqoreInputProps {
|
|
@@ -75,7 +82,7 @@ export const StyledInput = styled(StyledEffect)<IReqoreInputStyle>`
|
|
|
75
82
|
width: 100%;
|
|
76
83
|
flex: 1;
|
|
77
84
|
margin: 0;
|
|
78
|
-
padding:
|
|
85
|
+
padding: ${({ _size }) => PADDING_FROM_SIZE[_size] / 2}px 7px;
|
|
79
86
|
padding-right: ${({ clearable, _size }) => (clearable ? SIZE_TO_PX[_size] : 7)}px;
|
|
80
87
|
padding-left: ${({ hasIcon, _size }) => (hasIcon ? SIZE_TO_PX[_size] : 7)}px;
|
|
81
88
|
font-size: ${({ _size }) => TEXT_FROM_SIZE[_size]}px;
|
|
@@ -150,6 +157,7 @@ const ReqoreInput = forwardRef<HTMLDivElement, IReqoreInputProps>(
|
|
|
150
157
|
readOnly,
|
|
151
158
|
customTheme,
|
|
152
159
|
intent,
|
|
160
|
+
wrapperStyle,
|
|
153
161
|
...rest
|
|
154
162
|
}: IReqoreInputProps,
|
|
155
163
|
ref
|
|
@@ -173,6 +181,7 @@ const ReqoreInput = forwardRef<HTMLDivElement, IReqoreInputProps>(
|
|
|
173
181
|
ref={targetRef}
|
|
174
182
|
readOnly={readOnly}
|
|
175
183
|
disabled={rest.disabled}
|
|
184
|
+
style={wrapperStyle}
|
|
176
185
|
>
|
|
177
186
|
{icon && (
|
|
178
187
|
<StyledIconWrapper _size={size}>
|
|
@@ -9,6 +9,7 @@ import PopoverContext from '../../context/PopoverContext';
|
|
|
9
9
|
import { fadeIn } from '../../helpers/animations';
|
|
10
10
|
import { getReadableColor } from '../../helpers/colors';
|
|
11
11
|
import { StyledBackdrop } from '../Drawer';
|
|
12
|
+
import { TReqoreHexColor } from '../Effect';
|
|
12
13
|
|
|
13
14
|
const StyledPopoverArrow = styled.div<{ theme: IReqoreTheme }>`
|
|
14
15
|
width: 10px;
|
|
@@ -37,7 +38,7 @@ const StyledPopoverWrapper = styled.div<{ theme: IReqoreTheme }>`
|
|
|
37
38
|
max-height: ${({ maxHeight = '80vh' }) => maxHeight};
|
|
38
39
|
|
|
39
40
|
${({ theme, opaque }) => {
|
|
40
|
-
const defaultColor:
|
|
41
|
+
const defaultColor: TReqoreHexColor = theme.popover?.main || theme.main;
|
|
41
42
|
|
|
42
43
|
if (opaque) {
|
|
43
44
|
return css`
|
|
@@ -15,7 +15,7 @@ export interface IReqoreMenuDividerProps
|
|
|
15
15
|
const StyledMenuDivider = styled(StyledTextEffect)`
|
|
16
16
|
width: 100%;
|
|
17
17
|
padding: ${({ size }) => `${PADDING_FROM_SIZE[size]}px 0`};
|
|
18
|
-
background-color:
|
|
18
|
+
background-color: transparent;
|
|
19
19
|
|
|
20
20
|
color: ${({ theme }) => getReadableColor(theme, undefined, undefined)};
|
|
21
21
|
`;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
+
import { RADIUS_FROM_SIZE } from '../../constants/sizes';
|
|
3
4
|
import { IReqoreCustomTheme, IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
4
5
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
5
|
-
import { changeLightness } from '../../helpers/colors';
|
|
6
|
+
import { changeDarkness, changeLightness, getMainBackgroundColor } from '../../helpers/colors';
|
|
6
7
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
7
|
-
import { IReqoreComponent } from '../../types/global';
|
|
8
|
-
import { StyledReqoreControlGroup } from '../ControlGroup';
|
|
8
|
+
import { IReqoreComponent, IWithReqoreMinimal, IWithReqoreTransparent } from '../../types/global';
|
|
9
9
|
|
|
10
|
-
export interface IReqoreMenuProps
|
|
10
|
+
export interface IReqoreMenuProps
|
|
11
|
+
extends IReqoreComponent,
|
|
12
|
+
IWithReqoreMinimal,
|
|
13
|
+
IWithReqoreTransparent,
|
|
14
|
+
React.HTMLAttributes<HTMLDivElement> {
|
|
11
15
|
children: any;
|
|
12
16
|
position?: 'left' | 'right';
|
|
13
17
|
width?: string;
|
|
@@ -16,6 +20,7 @@ export interface IReqoreMenuProps extends IReqoreComponent, React.HTMLAttributes
|
|
|
16
20
|
intent?: TReqoreIntent;
|
|
17
21
|
wrapText?: boolean;
|
|
18
22
|
flat?: boolean;
|
|
23
|
+
rounded?: boolean;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
export interface IReqoreMenuStyle extends IReqoreMenuProps {
|
|
@@ -30,7 +35,9 @@ const StyledReqoreMenu = styled.div<IReqoreMenuStyle>`
|
|
|
30
35
|
overflow-y: auto;
|
|
31
36
|
overflow-x: hidden;
|
|
32
37
|
|
|
33
|
-
background-color: ${({ theme }) =>
|
|
38
|
+
background-color: ${({ theme, transparent }) =>
|
|
39
|
+
transparent ? 'transparent' : changeDarkness(getMainBackgroundColor(theme), 0.03)};
|
|
40
|
+
border-radius: ${({ rounded }) => (rounded ? `${RADIUS_FROM_SIZE['normal']}px` : `0`)};
|
|
34
41
|
|
|
35
42
|
${({ theme, position }) =>
|
|
36
43
|
position &&
|
|
@@ -42,7 +49,7 @@ const StyledReqoreMenu = styled.div<IReqoreMenuStyle>`
|
|
|
42
49
|
padding-${position === 'left' ? 'right' : 'left'}: 10px;
|
|
43
50
|
`}
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
> *:not(:last-child) {
|
|
46
53
|
margin-bottom: 5px;
|
|
47
54
|
}
|
|
48
55
|
`;
|
|
@@ -58,6 +65,7 @@ const ReqoreMenu = forwardRef<HTMLDivElement, IReqoreMenuProps>(
|
|
|
58
65
|
intent,
|
|
59
66
|
wrapText,
|
|
60
67
|
flat = true,
|
|
68
|
+
minimal,
|
|
61
69
|
...rest
|
|
62
70
|
}: IReqoreMenuProps,
|
|
63
71
|
ref: any
|
|
@@ -75,7 +83,8 @@ const ReqoreMenu = forwardRef<HTMLDivElement, IReqoreMenuProps>(
|
|
|
75
83
|
_popoverId,
|
|
76
84
|
customTheme: child?.props.customTheme || theme,
|
|
77
85
|
wrap: wrapText,
|
|
78
|
-
flat: child?.props.flat
|
|
86
|
+
flat: 'flat' in child?.props ? child.props.flat : flat,
|
|
87
|
+
minimal: 'minimal' in child?.props ? child.props.minimal : minimal,
|
|
79
88
|
})
|
|
80
89
|
: null;
|
|
81
90
|
})}
|
|
@@ -98,10 +98,11 @@ const ReqoreMenuItem = forwardRef<HTMLDivElement, IReqoreMenuItemProps>(
|
|
|
98
98
|
disabled={disabled}
|
|
99
99
|
intent={intent}
|
|
100
100
|
icon={icon}
|
|
101
|
+
rightIcon={onRightIconClick ? undefined : rightIcon}
|
|
101
102
|
>
|
|
102
103
|
{label || children}
|
|
103
104
|
</ReqoreButton>
|
|
104
|
-
{rightIcon && (
|
|
105
|
+
{rightIcon && onRightIconClick ? (
|
|
105
106
|
<ReqoreButton
|
|
106
107
|
icon={rightIcon}
|
|
107
108
|
flat={flat}
|
|
@@ -114,7 +115,7 @@ const ReqoreMenuItem = forwardRef<HTMLDivElement, IReqoreMenuItemProps>(
|
|
|
114
115
|
intent={intent}
|
|
115
116
|
active={selected && !!onRightIconClick}
|
|
116
117
|
/>
|
|
117
|
-
)}
|
|
118
|
+
) : null}
|
|
118
119
|
</ReqoreControlGroup>
|
|
119
120
|
);
|
|
120
121
|
}
|
|
@@ -3,6 +3,7 @@ import React, { forwardRef, useEffect, useMemo, useState } from 'react';
|
|
|
3
3
|
import { useMount, useUnmount } from 'react-use';
|
|
4
4
|
import { IReqoreTheme } from '../../constants/theme';
|
|
5
5
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
6
|
+
import { getColorFromMaybeString } from '../../helpers/colors';
|
|
6
7
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
7
8
|
import {
|
|
8
9
|
IReqoreIntent,
|
|
@@ -132,7 +133,9 @@ const ReqoreMessage = forwardRef<HTMLDivElement, IReqoreMessageProps>(
|
|
|
132
133
|
<ReqoreHeading
|
|
133
134
|
size={size}
|
|
134
135
|
customTheme={
|
|
135
|
-
rest.effect?.color
|
|
136
|
+
rest.effect?.color
|
|
137
|
+
? { text: { color: getColorFromMaybeString(theme, rest.effect.color) } }
|
|
138
|
+
: undefined
|
|
136
139
|
}
|
|
137
140
|
>
|
|
138
141
|
{title}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
2
|
import { darken, rgba } from 'polished';
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef, ReactElement, useCallback, useMemo, useState } from 'react';
|
|
4
4
|
import { useUpdateEffect } from 'react-use';
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
6
|
import {
|
|
@@ -13,6 +13,7 @@ import { ReqorePopover } from '../..';
|
|
|
13
13
|
import { SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
14
14
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
15
15
|
import { changeLightness, getReadableColorFrom } from '../../helpers/colors';
|
|
16
|
+
import { TReqoreColor, TReqoreHexColor } from '../Effect';
|
|
16
17
|
import { ReqoreH4 } from '../Header';
|
|
17
18
|
import ReqoreIcon from '../Icon';
|
|
18
19
|
import { ReqoreP } from '../Paragraph';
|
|
@@ -102,7 +103,7 @@ export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
|
|
|
102
103
|
disabled,
|
|
103
104
|
hovered,
|
|
104
105
|
}: IReqoreTableCellStyle) => {
|
|
105
|
-
const getBackgroundColor = () => {
|
|
106
|
+
const getBackgroundColor = (): TReqoreColor => {
|
|
106
107
|
let color = theme.main;
|
|
107
108
|
let opacity = 0;
|
|
108
109
|
// Is there any intent
|
|
@@ -147,11 +148,11 @@ export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
|
|
|
147
148
|
? 'transparent'
|
|
148
149
|
: rgba(getBackgroundColor(), 0.8)};
|
|
149
150
|
color: ${getReadableColorFrom(
|
|
150
|
-
backgroundColor === 'transparent' ? theme.main :
|
|
151
|
+
backgroundColor === 'transparent' ? theme.main : backgroundColor,
|
|
151
152
|
!hovered
|
|
152
153
|
)};
|
|
153
154
|
border-color: ${changeLightness(
|
|
154
|
-
backgroundColor === 'transparent' ? theme.main :
|
|
155
|
+
backgroundColor === 'transparent' ? theme.main : backgroundColor,
|
|
155
156
|
0.1
|
|
156
157
|
)};
|
|
157
158
|
transition: background-color 0.2s ease-out;
|
|
@@ -214,8 +215,10 @@ const ReqoreTableRow = ({
|
|
|
214
215
|
let intent: TReqoreIntent = intentOrColor?.startsWith('#')
|
|
215
216
|
? undefined
|
|
216
217
|
: (intentOrColor as TReqoreIntent);
|
|
217
|
-
let color:
|
|
218
|
-
intentOrColor?.startsWith('#') && type === 'tag'
|
|
218
|
+
let color: TReqoreHexColor =
|
|
219
|
+
intentOrColor?.startsWith('#') && type === 'tag'
|
|
220
|
+
? (intentOrColor as TReqoreHexColor)
|
|
221
|
+
: undefined;
|
|
219
222
|
// Render content based on the type
|
|
220
223
|
switch (type) {
|
|
221
224
|
case 'time-ago':
|
|
@@ -13,7 +13,12 @@ import {
|
|
|
13
13
|
} from '../../constants/sizes';
|
|
14
14
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
15
15
|
import ThemeContext from '../../context/ThemeContext';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
changeLightness,
|
|
18
|
+
getColorFromMaybeString,
|
|
19
|
+
getReadableColor,
|
|
20
|
+
getReadableColorFrom,
|
|
21
|
+
} from '../../helpers/colors';
|
|
17
22
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
18
23
|
import { useTooltip } from '../../hooks/useTooltip';
|
|
19
24
|
import {
|
|
@@ -24,7 +29,7 @@ import {
|
|
|
24
29
|
IWithReqoreTooltip,
|
|
25
30
|
} from '../../types/global';
|
|
26
31
|
import { IReqoreIconName } from '../../types/icons';
|
|
27
|
-
import { StyledEffect } from '../Effect';
|
|
32
|
+
import { StyledEffect, TReqoreEffectColor, TReqoreHexColor } from '../Effect';
|
|
28
33
|
import ReqoreIcon from '../Icon';
|
|
29
34
|
|
|
30
35
|
export interface IReqoreTagAction extends IWithReqoreTooltip, IReqoreDisabled, IReqoreIntent {
|
|
@@ -45,7 +50,7 @@ export interface IReqoreTagProps
|
|
|
45
50
|
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
46
51
|
icon?: IReqoreIconName;
|
|
47
52
|
rightIcon?: IReqoreIconName;
|
|
48
|
-
color?:
|
|
53
|
+
color?: TReqoreEffectColor;
|
|
49
54
|
actions?: IReqoreTagAction[];
|
|
50
55
|
width?: string;
|
|
51
56
|
badge?: boolean;
|
|
@@ -57,6 +62,7 @@ export interface IReqoreTagStyle extends IReqoreTagProps {
|
|
|
57
62
|
theme: IReqoreTheme;
|
|
58
63
|
removable?: boolean;
|
|
59
64
|
interactive?: boolean;
|
|
65
|
+
color?: TReqoreHexColor;
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
export const StyledTag = styled(StyledEffect)<IReqoreTagStyle>`
|
|
@@ -183,14 +189,16 @@ const StyledButtonWrapper = styled.span<IReqoreTagStyle>`
|
|
|
183
189
|
align-items: center;
|
|
184
190
|
transition: all 0.2s ease-out;
|
|
185
191
|
|
|
186
|
-
${({ color }) =>
|
|
192
|
+
${({ color, effect }) =>
|
|
187
193
|
css`
|
|
188
194
|
.reqore-icon {
|
|
189
195
|
transform: scale(0.85);
|
|
190
196
|
}
|
|
191
197
|
&:hover {
|
|
192
198
|
cursor: pointer;
|
|
193
|
-
background-color: ${color
|
|
199
|
+
background-color: ${color && !effect?.gradient
|
|
200
|
+
? changeLightness(color, 0.09)
|
|
201
|
+
: rgba('#000000', 0.2)};
|
|
194
202
|
|
|
195
203
|
.reqore-icon {
|
|
196
204
|
transform: scale(1);
|
|
@@ -228,7 +236,9 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
|
|
|
228
236
|
useTooltip(targetRef.current, tooltip);
|
|
229
237
|
|
|
230
238
|
// If color or intent was specified, set the color
|
|
231
|
-
let customColor = intent
|
|
239
|
+
let customColor: TReqoreHexColor = intent
|
|
240
|
+
? theme.intents[intent]
|
|
241
|
+
: getColorFromMaybeString(theme, color);
|
|
232
242
|
customColor = minimal ? `${customColor || '#000000'}40` : customColor;
|
|
233
243
|
|
|
234
244
|
return (
|
|
@@ -301,6 +311,7 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
|
|
|
301
311
|
color: customColor,
|
|
302
312
|
className: 'reqore-tag-action',
|
|
303
313
|
onClick: action.onClick,
|
|
314
|
+
effect: rest.effect,
|
|
304
315
|
}}
|
|
305
316
|
{...(action.tooltip
|
|
306
317
|
? typeof action.tooltip === 'string'
|
|
@@ -322,6 +333,7 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
|
|
|
322
333
|
color: customColor,
|
|
323
334
|
className: 'reqore-tag-remove',
|
|
324
335
|
onClick: onRemoveClick,
|
|
336
|
+
effect: rest.effect,
|
|
325
337
|
}}
|
|
326
338
|
noWrapper
|
|
327
339
|
content='Remove'
|
|
@@ -41,6 +41,7 @@ export interface IReqoreTextareaProps
|
|
|
41
41
|
rounded?: boolean;
|
|
42
42
|
flat?: boolean;
|
|
43
43
|
onClearClick?: () => any;
|
|
44
|
+
wrapperStyle?: React.CSSProperties;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export interface IReqoreTextareaStyle extends IReqoreTextareaProps {
|
|
@@ -132,6 +133,7 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
|
|
|
132
133
|
customTheme,
|
|
133
134
|
intent,
|
|
134
135
|
rounded = true,
|
|
136
|
+
wrapperStyle,
|
|
135
137
|
...rest
|
|
136
138
|
}: IReqoreTextareaProps,
|
|
137
139
|
ref: any
|
|
@@ -149,6 +151,7 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
|
|
|
149
151
|
fluid={fluid}
|
|
150
152
|
_size={size}
|
|
151
153
|
theme={theme}
|
|
154
|
+
style={wrapperStyle}
|
|
152
155
|
>
|
|
153
156
|
<StyledTextarea
|
|
154
157
|
{...rest}
|
package/src/constants/colors.ts
CHANGED