@qoretechnologies/reqore 0.28.1 → 0.28.2
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__/effect.test.tsx +6 -6
- package/dist/components/Button/index.d.ts +3 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +2 -1
- package/dist/components/Button/index.js.map +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 +2 -2
- 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/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 +13 -5
- package/src/components/Dropdown/list.tsx +0 -2
- package/src/components/Effect/index.tsx +64 -19
- package/src/components/Header/index.tsx +1 -3
- package/src/components/Input/index.tsx +3 -0
- 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/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/Menu/Menu.stories.tsx +50 -3
- package/src/stories/Message/Message.stories.tsx +3 -4
- package/src/types/global.ts +14 -0
- package/tests.json +1 -1
|
@@ -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
package/src/constants/theme.ts
CHANGED
|
@@ -1,64 +1,66 @@
|
|
|
1
|
+
import { TReqoreEffectColor, TReqoreHexColor } from '../components/Effect';
|
|
2
|
+
|
|
1
3
|
export interface IReqoreSidebarTheme {
|
|
2
|
-
main?:
|
|
3
|
-
color?:
|
|
4
|
-
border?:
|
|
4
|
+
main?: TReqoreHexColor;
|
|
5
|
+
color?: TReqoreHexColor;
|
|
6
|
+
border?: TReqoreHexColor;
|
|
5
7
|
item?: {
|
|
6
|
-
color?:
|
|
7
|
-
background?:
|
|
8
|
-
border?:
|
|
9
|
-
hoverColor?:
|
|
10
|
-
hoverBackground?:
|
|
11
|
-
activeColor?:
|
|
12
|
-
activeBackground?:
|
|
8
|
+
color?: TReqoreHexColor;
|
|
9
|
+
background?: TReqoreHexColor;
|
|
10
|
+
border?: TReqoreHexColor;
|
|
11
|
+
hoverColor?: TReqoreHexColor;
|
|
12
|
+
hoverBackground?: TReqoreHexColor;
|
|
13
|
+
activeColor?: TReqoreHexColor;
|
|
14
|
+
activeBackground?: TReqoreHexColor;
|
|
13
15
|
};
|
|
14
16
|
subItem?: {
|
|
15
|
-
color?:
|
|
16
|
-
border?:
|
|
17
|
-
background?:
|
|
18
|
-
hoverColor?:
|
|
19
|
-
hoverBackground?:
|
|
20
|
-
activeColor?:
|
|
21
|
-
activeBackground?:
|
|
17
|
+
color?: TReqoreHexColor;
|
|
18
|
+
border?: TReqoreHexColor;
|
|
19
|
+
background?: TReqoreHexColor;
|
|
20
|
+
hoverColor?: TReqoreHexColor;
|
|
21
|
+
hoverBackground?: TReqoreHexColor;
|
|
22
|
+
activeColor?: TReqoreHexColor;
|
|
23
|
+
activeBackground?: TReqoreHexColor;
|
|
22
24
|
};
|
|
23
25
|
icon?: {
|
|
24
|
-
color?:
|
|
25
|
-
hoverColor?:
|
|
26
|
-
activeColor?:
|
|
26
|
+
color?: TReqoreHexColor;
|
|
27
|
+
hoverColor?: TReqoreHexColor;
|
|
28
|
+
activeColor?: TReqoreHexColor;
|
|
27
29
|
};
|
|
28
30
|
section?: {
|
|
29
|
-
background?:
|
|
31
|
+
background?: TReqoreHexColor;
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export interface IReqoreBreadcrumbsTheme {
|
|
34
|
-
main?:
|
|
36
|
+
main?: TReqoreHexColor;
|
|
35
37
|
item?: {
|
|
36
|
-
color?:
|
|
37
|
-
hoverColor?:
|
|
38
|
-
activeColor?:
|
|
38
|
+
color?: TReqoreHexColor;
|
|
39
|
+
hoverColor?: TReqoreHexColor;
|
|
40
|
+
activeColor?: TReqoreHexColor;
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
export interface IReqoreNavbarTheme {
|
|
43
|
-
main?:
|
|
44
|
-
color?:
|
|
45
|
-
border?:
|
|
46
|
-
background?:
|
|
47
|
-
hoverColor?:
|
|
45
|
+
main?: TReqoreHexColor;
|
|
46
|
+
color?: TReqoreHexColor;
|
|
47
|
+
border?: TReqoreHexColor;
|
|
48
|
+
background?: TReqoreHexColor;
|
|
49
|
+
hoverColor?: TReqoreHexColor;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export interface IReqoreTheme {
|
|
51
|
-
main:
|
|
52
|
-
originalMain?:
|
|
53
|
+
main: TReqoreHexColor;
|
|
54
|
+
originalMain?: TReqoreHexColor;
|
|
53
55
|
text?: {
|
|
54
|
-
color?:
|
|
56
|
+
color?: TReqoreHexColor;
|
|
55
57
|
dim?: boolean;
|
|
56
58
|
};
|
|
57
59
|
intents: IReqoreIntents;
|
|
58
60
|
sidebar?: IReqoreSidebarTheme;
|
|
59
61
|
notifications: IReqoreIntents;
|
|
60
62
|
popover?: {
|
|
61
|
-
main:
|
|
63
|
+
main: TReqoreHexColor;
|
|
62
64
|
};
|
|
63
65
|
header?: IReqoreNavbarTheme;
|
|
64
66
|
footer?: IReqoreNavbarTheme;
|
|
@@ -66,20 +68,20 @@ export interface IReqoreTheme {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
export interface IReqoreCustomTheme {
|
|
69
|
-
main?:
|
|
71
|
+
main?: TReqoreEffectColor;
|
|
70
72
|
text?: {
|
|
71
|
-
color?:
|
|
73
|
+
color?: TReqoreEffectColor;
|
|
72
74
|
dim?: boolean;
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
export interface IReqoreIntents {
|
|
77
|
-
info?:
|
|
78
|
-
success?:
|
|
79
|
-
pending?:
|
|
80
|
-
warning?:
|
|
81
|
-
danger?:
|
|
82
|
-
muted?:
|
|
79
|
+
info?: TReqoreHexColor;
|
|
80
|
+
success?: TReqoreHexColor;
|
|
81
|
+
pending?: TReqoreHexColor;
|
|
82
|
+
warning?: TReqoreHexColor;
|
|
83
|
+
danger?: TReqoreHexColor;
|
|
84
|
+
muted?: TReqoreHexColor;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
export type TReqoreIntent = 'info' | 'success' | 'pending' | 'warning' | 'danger' | 'muted';
|
package/src/helpers/colors.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { cloneDeep, merge } from 'lodash';
|
|
2
2
|
import { darken, lighten, readableColor } from 'polished';
|
|
3
|
+
import { TReqoreEffectColor, TReqoreEffectColorList, TReqoreHexColor } from '../components/Effect';
|
|
3
4
|
import { Colors } from '../constants/colors';
|
|
4
5
|
import { DEFAULT_INTENTS, IReqoreTheme, TReqoreIntent } from '../constants/theme';
|
|
5
6
|
|
|
6
7
|
export const getReadableColor: (
|
|
7
8
|
theme: Partial<IReqoreTheme>,
|
|
8
|
-
ifLight?:
|
|
9
|
-
ifDark?:
|
|
9
|
+
ifLight?: TReqoreHexColor,
|
|
10
|
+
ifDark?: TReqoreHexColor,
|
|
10
11
|
dimmed?: boolean,
|
|
11
|
-
fallback?:
|
|
12
|
-
) =>
|
|
12
|
+
fallback?: TReqoreHexColor
|
|
13
|
+
) => TReqoreHexColor = (theme, ifLight, ifDark, dimmed, fallback) => {
|
|
13
14
|
if (theme.text?.color) {
|
|
14
15
|
return theme.text.dim
|
|
15
16
|
? dimmed
|
|
@@ -25,15 +26,15 @@ export const getReadableColor: (
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
export const getReadableColorFrom = (
|
|
28
|
-
from:
|
|
29
|
+
from: TReqoreHexColor,
|
|
29
30
|
dim?: boolean,
|
|
30
|
-
ifLight?:
|
|
31
|
-
ifDark?:
|
|
32
|
-
) => {
|
|
31
|
+
ifLight?: TReqoreHexColor,
|
|
32
|
+
ifDark?: TReqoreHexColor
|
|
33
|
+
): TReqoreHexColor => {
|
|
33
34
|
const returnIfLight = ifLight || lighten(dim ? 0.05 : 0, Colors.DARK);
|
|
34
35
|
const returnIfDark = ifDark || darken(dim ? 0.05 : 0, Colors.LIGHT);
|
|
35
36
|
|
|
36
|
-
return readableColor(from, returnIfLight, returnIfDark, false);
|
|
37
|
+
return readableColor(from, returnIfLight, returnIfDark, false) as TReqoreHexColor;
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
export const percentToHexAlpha = (p: number) => {
|
|
@@ -44,29 +45,33 @@ export const percentToHexAlpha = (p: number) => {
|
|
|
44
45
|
return hexValue.padStart(2, '0').toUpperCase(); // format with leading 0 and upper case characters
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
export const shouldDarken = (mainColor:
|
|
48
|
+
export const shouldDarken = (mainColor: TReqoreHexColor): boolean => {
|
|
48
49
|
const contrast = getColorByBgColor(mainColor);
|
|
49
50
|
|
|
50
51
|
return contrast === '#000000';
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
export const getMainColor: (theme: IReqoreTheme, component: string) =>
|
|
54
|
+
export const getMainColor: (theme: IReqoreTheme, component: string) => TReqoreHexColor = (
|
|
54
55
|
theme,
|
|
55
56
|
component
|
|
56
57
|
) => theme[component]?.main || theme.main;
|
|
57
58
|
|
|
58
59
|
//export const changeBasedOnContrast = (color: string, lightness?: number): string =>
|
|
59
60
|
|
|
60
|
-
export const changeLightness = (color:
|
|
61
|
+
export const changeLightness = (color: TReqoreHexColor, lightness?: number): TReqoreHexColor => {
|
|
61
62
|
return lightness
|
|
62
63
|
? shouldDarken(color)
|
|
63
|
-
? darken(lightness, color)
|
|
64
|
-
: lighten(lightness, color)
|
|
64
|
+
? (darken(lightness, color) as TReqoreHexColor)
|
|
65
|
+
: (lighten(lightness, color) as TReqoreHexColor)
|
|
65
66
|
: color;
|
|
66
67
|
};
|
|
67
68
|
|
|
68
|
-
export const changeDarkness = (color:
|
|
69
|
-
lightness
|
|
69
|
+
export const changeDarkness = (color: TReqoreHexColor, lightness?: number): TReqoreHexColor =>
|
|
70
|
+
lightness
|
|
71
|
+
? shouldDarken(color)
|
|
72
|
+
? (lighten(lightness, color) as TReqoreHexColor)
|
|
73
|
+
: (darken(lightness, color) as TReqoreHexColor)
|
|
74
|
+
: color;
|
|
70
75
|
|
|
71
76
|
export const getColorByBgColor = (bgColor) => {
|
|
72
77
|
if (!bgColor) {
|
|
@@ -76,7 +81,7 @@ export const getColorByBgColor = (bgColor) => {
|
|
|
76
81
|
};
|
|
77
82
|
|
|
78
83
|
export const isValidSixCharHex = (hex: string): boolean => {
|
|
79
|
-
return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(hex);
|
|
84
|
+
return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$/.test(hex);
|
|
80
85
|
};
|
|
81
86
|
|
|
82
87
|
export const buildTheme = (theme: IReqoreTheme): IReqoreTheme => {
|
|
@@ -142,20 +147,47 @@ export const getNotificationIntent = (theme: IReqoreTheme, intent?: TReqoreInten
|
|
|
142
147
|
return changeLightness(theme.main, 0.1);
|
|
143
148
|
};
|
|
144
149
|
|
|
145
|
-
export const getMainBackgroundColor = (theme: IReqoreTheme):
|
|
150
|
+
export const getMainBackgroundColor = (theme: IReqoreTheme): TReqoreHexColor =>
|
|
146
151
|
changeLightness(theme.main, 0.02);
|
|
147
152
|
|
|
148
|
-
export const
|
|
153
|
+
export const getColorFromMaybeString = (
|
|
149
154
|
theme: IReqoreTheme,
|
|
150
|
-
|
|
151
|
-
):
|
|
152
|
-
if (
|
|
153
|
-
return
|
|
155
|
+
color: TReqoreEffectColor
|
|
156
|
+
): TReqoreHexColor => {
|
|
157
|
+
if (!color) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const [providedColor, shading, multiplier = 1]: TReqoreEffectColorList = color.split(
|
|
162
|
+
':'
|
|
163
|
+
) as TReqoreEffectColorList;
|
|
164
|
+
|
|
165
|
+
if (providedColor === 'transparent') {
|
|
166
|
+
return '#00000000';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// First we need to get the actual color
|
|
170
|
+
let _color: TReqoreHexColor;
|
|
171
|
+
|
|
172
|
+
if (!providedColor || providedColor === 'main') {
|
|
173
|
+
_color = theme.main;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (theme.intents[providedColor]) {
|
|
177
|
+
_color = theme.intents[providedColor];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (isValidSixCharHex(color)) {
|
|
181
|
+
_color = providedColor as TReqoreHexColor;
|
|
154
182
|
}
|
|
155
183
|
|
|
156
|
-
if (
|
|
157
|
-
|
|
184
|
+
if (shading) {
|
|
185
|
+
if (shading === 'lighten') {
|
|
186
|
+
_color = lighten(0.1 * multiplier, _color) as TReqoreHexColor;
|
|
187
|
+
} else if (shading === 'darken') {
|
|
188
|
+
_color = darken(0.1 * multiplier, _color) as TReqoreHexColor;
|
|
189
|
+
}
|
|
158
190
|
}
|
|
159
191
|
|
|
160
|
-
return
|
|
192
|
+
return _color;
|
|
161
193
|
};
|
package/src/hooks/useTheme.ts
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
import { cloneDeep } from 'lodash';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
|
+
import { TReqoreEffectColor } from '../components/Effect';
|
|
3
4
|
import { IReqoreTheme, TReqoreIntent } from '../constants/theme';
|
|
4
5
|
import ThemeContext from '../context/ThemeContext';
|
|
5
|
-
import { mergeThemes } from '../helpers/colors';
|
|
6
|
+
import { getColorFromMaybeString, mergeThemes } from '../helpers/colors';
|
|
7
|
+
|
|
8
|
+
export interface IReqoreCustomTheme extends Partial<Omit<IReqoreTheme, 'main' | 'text'>> {
|
|
9
|
+
main?: TReqoreEffectColor;
|
|
10
|
+
text?: {
|
|
11
|
+
color?: TReqoreEffectColor;
|
|
12
|
+
dim?: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
6
15
|
|
|
7
16
|
export const useReqoreTheme = (
|
|
8
17
|
element: string,
|
|
9
|
-
customTheme:
|
|
18
|
+
customTheme: IReqoreCustomTheme = {},
|
|
10
19
|
intent?: TReqoreIntent
|
|
11
20
|
) => {
|
|
12
21
|
const theme: IReqoreTheme = useContext<IReqoreTheme>(ThemeContext);
|
|
13
|
-
let _customTheme:
|
|
22
|
+
let _customTheme: IReqoreCustomTheme = cloneDeep(customTheme);
|
|
23
|
+
|
|
24
|
+
if (_customTheme.main) {
|
|
25
|
+
_customTheme.main = getColorFromMaybeString(theme, customTheme.main);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (_customTheme.text?.color) {
|
|
29
|
+
_customTheme.text.color = getColorFromMaybeString(theme, customTheme.text.color);
|
|
30
|
+
}
|
|
14
31
|
|
|
15
32
|
if (element === 'main' && intent) {
|
|
16
33
|
_customTheme.main = theme.intents[intent];
|
|
@@ -110,7 +110,7 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
|
|
|
110
110
|
{
|
|
111
111
|
effect: {
|
|
112
112
|
gradient: {
|
|
113
|
-
colors: { 0: '
|
|
113
|
+
colors: { 0: 'danger', 100: 'danger:darken' },
|
|
114
114
|
direction: 'to right bottom',
|
|
115
115
|
},
|
|
116
116
|
},
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react/types-6-0';
|
|
2
2
|
import { IReqoreMenuProps } from '../../components/Menu';
|
|
3
3
|
import { IReqoreMenuItemProps } from '../../components/Menu/item';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
ReqoreInput,
|
|
6
|
+
ReqoreMenu,
|
|
7
|
+
ReqoreMenuDivider,
|
|
8
|
+
ReqoreMenuItem,
|
|
9
|
+
ReqorePopover,
|
|
10
|
+
} from '../../index';
|
|
11
|
+
import { argManager, IntentArg } from '../utils/args';
|
|
6
12
|
|
|
7
13
|
const { createArg } = argManager<IReqoreMenuProps>();
|
|
8
14
|
|
|
@@ -11,7 +17,7 @@ export default {
|
|
|
11
17
|
argTypes: {
|
|
12
18
|
...createArg('width', {
|
|
13
19
|
type: 'string',
|
|
14
|
-
defaultValue: '
|
|
20
|
+
defaultValue: '210px',
|
|
15
21
|
name: 'Width',
|
|
16
22
|
}),
|
|
17
23
|
...createArg('maxHeight', {
|
|
@@ -35,6 +41,38 @@ export default {
|
|
|
35
41
|
},
|
|
36
42
|
description: 'Whether to wrap text or not',
|
|
37
43
|
}),
|
|
44
|
+
...createArg('minimal', {
|
|
45
|
+
defaultValue: false,
|
|
46
|
+
name: 'Minimal',
|
|
47
|
+
control: {
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
},
|
|
50
|
+
description: 'Whether to use minimal style or not',
|
|
51
|
+
}),
|
|
52
|
+
...createArg('flat', {
|
|
53
|
+
defaultValue: true,
|
|
54
|
+
name: 'Flat',
|
|
55
|
+
control: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
},
|
|
58
|
+
description: 'Whether to use flat style or not',
|
|
59
|
+
}),
|
|
60
|
+
...createArg('rounded', {
|
|
61
|
+
defaultValue: true,
|
|
62
|
+
name: 'Rounded',
|
|
63
|
+
control: {
|
|
64
|
+
type: 'boolean',
|
|
65
|
+
},
|
|
66
|
+
description: 'Whether to use rounded style or not',
|
|
67
|
+
}),
|
|
68
|
+
...createArg('transparent', {
|
|
69
|
+
defaultValue: false,
|
|
70
|
+
name: 'Transparent',
|
|
71
|
+
control: {
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
},
|
|
74
|
+
description: 'Whether to use transparent style or not',
|
|
75
|
+
}),
|
|
38
76
|
...IntentArg,
|
|
39
77
|
},
|
|
40
78
|
} as Meta<IReqoreMenuProps>;
|
|
@@ -42,6 +80,7 @@ export default {
|
|
|
42
80
|
const Template: Story<IReqoreMenuProps> = (args) => {
|
|
43
81
|
return (
|
|
44
82
|
<ReqoreMenu {...args}>
|
|
83
|
+
<ReqoreInput placeholder='Custom component' icon='Search2Fill' flat={false} />
|
|
45
84
|
<ReqoreMenuItem icon='Save3Fill' intent='success' selected>
|
|
46
85
|
Selected success
|
|
47
86
|
</ReqoreMenuItem>
|
|
@@ -143,7 +182,15 @@ export const WrappedText = Template.bind({});
|
|
|
143
182
|
WrappedText.args = {
|
|
144
183
|
wrapText: true,
|
|
145
184
|
};
|
|
185
|
+
export const Minimal = Template.bind({});
|
|
186
|
+
Minimal.args = {
|
|
187
|
+
minimal: true,
|
|
188
|
+
};
|
|
146
189
|
export const NotFlat = Template.bind({});
|
|
147
190
|
NotFlat.args = {
|
|
148
191
|
flat: false,
|
|
149
192
|
};
|
|
193
|
+
export const Transparent = Template.bind({});
|
|
194
|
+
Transparent.args = {
|
|
195
|
+
transparent: true,
|
|
196
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react/types-6-0';
|
|
2
2
|
import { noop } from 'lodash';
|
|
3
3
|
import ReqoreMessage, { IReqoreMessageProps } from '../../components/Message';
|
|
4
|
-
import { FlatArg, IntentArg, SizeArg
|
|
4
|
+
import { argManager, FlatArg, IntentArg, SizeArg } from '../utils/args';
|
|
5
5
|
|
|
6
6
|
const { createArg } = argManager<IReqoreMessageProps>();
|
|
7
7
|
|
|
@@ -64,10 +64,9 @@ Effect.args = {
|
|
|
64
64
|
effect: {
|
|
65
65
|
gradient: {
|
|
66
66
|
colors: {
|
|
67
|
-
0: '#
|
|
68
|
-
100: '
|
|
67
|
+
0: '#eb0e8c',
|
|
68
|
+
100: 'danger:darken:2',
|
|
69
69
|
},
|
|
70
70
|
},
|
|
71
|
-
color: '#000000',
|
|
72
71
|
},
|
|
73
72
|
};
|
package/src/types/global.ts
CHANGED
|
@@ -140,6 +140,20 @@ export interface IWithReqoreMinimal {
|
|
|
140
140
|
minimal?: boolean;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
export interface IWithReqoreTransparent {
|
|
144
|
+
/**
|
|
145
|
+
* If true, the component will be transparent
|
|
146
|
+
* @default false
|
|
147
|
+
* @type boolean
|
|
148
|
+
* @example
|
|
149
|
+
* <ReqoreButton transparent />
|
|
150
|
+
* <ReqoreButton transparent={true} />
|
|
151
|
+
* <ReqoreButton transparent={false} />
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
154
|
+
transparent?: boolean;
|
|
155
|
+
}
|
|
156
|
+
|
|
143
157
|
export interface IWithReqoreEffect {
|
|
144
158
|
/**
|
|
145
159
|
* If true, the component will have an effect
|