@qoretechnologies/reqore 0.38.6 → 0.38.8
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/build-storybook.log +16 -16
- package/dist/components/Effect/index.d.ts +4 -2
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/InputClearButton/index.d.ts.map +1 -1
- package/dist/components/InputClearButton/index.js +1 -1
- package/dist/components/InputClearButton/index.js.map +1 -1
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +3 -0
- 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 +5 -2
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/helpers/colors.d.ts +1 -0
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +23 -3
- package/dist/helpers/colors.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Effect/index.tsx +23 -10
- package/src/components/InputClearButton/index.tsx +0 -1
- package/src/components/Tag/index.tsx +4 -0
- package/src/components/Textarea/index.tsx +5 -0
- package/src/helpers/colors.ts +30 -7
- package/src/stories/Button/Button.stories.tsx +1 -1
- package/src/stories/Menu/Menu.stories.tsx +3 -1
- package/tests.json +1 -1
package/src/helpers/colors.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cloneDeep, merge, reduce } from 'lodash';
|
|
2
|
-
import { darken, getLuminance, lighten, mix, readableColor } from 'polished';
|
|
2
|
+
import { darken, getLuminance, lighten, mix, readableColor, transparentize } from 'polished';
|
|
3
3
|
import {
|
|
4
4
|
TReqoreEffectColor,
|
|
5
5
|
TReqoreEffectColorList,
|
|
@@ -51,6 +51,23 @@ export const percentToHexAlpha = (p: number) => {
|
|
|
51
51
|
return hexValue.padStart(2, '0').toUpperCase(); // format with leading 0 and upper case characters
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
export const RGBAToHexA = (rgba, forceRemoveAlpha = false): TReqoreHexColor => {
|
|
55
|
+
if (isValidSixCharHex(rgba)) {
|
|
56
|
+
return rgba as TReqoreHexColor;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return ('#' +
|
|
60
|
+
rgba
|
|
61
|
+
.replace(/^rgba?\(|\s+|\)$/g, '') // Get's rgba / rgb string values
|
|
62
|
+
.split(',') // splits them at ","
|
|
63
|
+
.filter((_string, index) => !forceRemoveAlpha || index !== 3)
|
|
64
|
+
.map((string) => parseFloat(string)) // Converts them to numbers
|
|
65
|
+
.map((number, index) => (index === 3 ? Math.round(number * 255) : number)) // Converts alpha to 255 number
|
|
66
|
+
.map((number) => number.toString(16)) // Converts numbers to hex
|
|
67
|
+
.map((string) => (string.length === 1 ? '0' + string : string)) // Adds 0 when length of one number is 1
|
|
68
|
+
.join('')) as TReqoreHexColor; // Puts the array to togehter to a string
|
|
69
|
+
};
|
|
70
|
+
|
|
54
71
|
export const shouldDarken = (mainColor: TReqoreHexColor): boolean => {
|
|
55
72
|
return getLuminance(mainColor) > 0.2;
|
|
56
73
|
};
|
|
@@ -165,7 +182,7 @@ export const getColorFromMaybeString = (
|
|
|
165
182
|
return undefined;
|
|
166
183
|
}
|
|
167
184
|
|
|
168
|
-
const [providedColor, shading, multiplier = 1]: TReqoreEffectColorList = color.split(
|
|
185
|
+
const [providedColor, shading, multiplier = 1, alpha = 1]: TReqoreEffectColorList = color.split(
|
|
169
186
|
':'
|
|
170
187
|
) as TReqoreEffectColorList;
|
|
171
188
|
|
|
@@ -196,6 +213,10 @@ export const getColorFromMaybeString = (
|
|
|
196
213
|
}
|
|
197
214
|
}
|
|
198
215
|
|
|
216
|
+
if (_color && _color.length === 7 && alpha < 1) {
|
|
217
|
+
_color = RGBAToHexA(transparentize(1 - alpha, _color));
|
|
218
|
+
}
|
|
219
|
+
|
|
199
220
|
return _color;
|
|
200
221
|
};
|
|
201
222
|
|
|
@@ -277,11 +298,13 @@ export const getGradientMix = (
|
|
|
277
298
|
const gradientColor1: TReqoreHexColor = getNthGradientColor(theme, _colors);
|
|
278
299
|
const gradientColor2: TReqoreHexColor = getNthGradientColor(theme, _colors, 2);
|
|
279
300
|
|
|
280
|
-
return
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
301
|
+
return RGBAToHexA(
|
|
302
|
+
mix(
|
|
303
|
+
0.5,
|
|
304
|
+
gradientColor1 === '#00000000' ? theme.main : gradientColor1,
|
|
305
|
+
gradientColor2 === '#00000000' ? theme.main : gradientColor2
|
|
306
|
+
) as TReqoreHexColor
|
|
307
|
+
);
|
|
285
308
|
}
|
|
286
309
|
|
|
287
310
|
return fallback;
|
|
@@ -233,7 +233,7 @@ const Template: StoryFn<typeof ReqoreButton> = (buttonProps) => {
|
|
|
233
233
|
{
|
|
234
234
|
effect: {
|
|
235
235
|
gradient: {
|
|
236
|
-
colors: { 0: 'danger', 100: 'danger:darken' },
|
|
236
|
+
colors: { 0: 'danger', 100: 'danger:darken:1:0.1' },
|
|
237
237
|
direction: 'to right bottom',
|
|
238
238
|
},
|
|
239
239
|
},
|
|
@@ -120,7 +120,9 @@ const Template: StoryFn<IReqoreMenuProps> = (args) => {
|
|
|
120
120
|
rightIcon='EditLine'
|
|
121
121
|
onRightIconClick={() => alert('Icon clicked')}
|
|
122
122
|
description='Button with right icon and description'
|
|
123
|
-
|
|
123
|
+
customTheme={{
|
|
124
|
+
main: 'info:darken:1:0.3',
|
|
125
|
+
}}
|
|
124
126
|
>
|
|
125
127
|
Some button
|
|
126
128
|
</ReqoreMenuItem>
|