@qoretechnologies/reqore 0.44.0 → 0.45.0

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.
Files changed (222) hide show
  1. package/package.json +1 -1
  2. package/tests.json +1 -1
  3. package/.eslintrc.js +0 -40
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  6. package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
  7. package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
  8. package/.github/workflows/beta_release.yml +0 -100
  9. package/.github/workflows/tests.yml +0 -84
  10. package/.gitpod.yml +0 -11
  11. package/.jest-test-results.json +0 -1
  12. package/.prettierrc +0 -7
  13. package/.vscode/settings.json +0 -0
  14. package/__tests__/breadcrumbs.test.tsx +0 -75
  15. package/__tests__/button.test.tsx +0 -218
  16. package/__tests__/checkbox.test.tsx +0 -45
  17. package/__tests__/collection.test.tsx +0 -243
  18. package/__tests__/containers/paging.test.tsx +0 -138
  19. package/__tests__/control_group.test.tsx +0 -32
  20. package/__tests__/drawer.test.tsx +0 -140
  21. package/__tests__/dropdown.test.tsx +0 -381
  22. package/__tests__/effect.test.tsx +0 -70
  23. package/__tests__/heading.test.tsx +0 -58
  24. package/__tests__/helpers/colors.test.tsx +0 -18
  25. package/__tests__/helpers/table.test.tsx +0 -67
  26. package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
  27. package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
  28. package/__tests__/hooks/useTheme.test.tsx +0 -31
  29. package/__tests__/icon.test.tsx +0 -53
  30. package/__tests__/input.test.tsx +0 -482
  31. package/__tests__/layout.test.tsx +0 -37
  32. package/__tests__/menu.test.tsx +0 -65
  33. package/__tests__/messages.test.tsx +0 -79
  34. package/__tests__/modal.test.tsx +0 -204
  35. package/__tests__/multiselect.test.tsx +0 -458
  36. package/__tests__/navbar.test.tsx +0 -31
  37. package/__tests__/notifications.test.tsx +0 -178
  38. package/__tests__/pagination.test.tsx +0 -437
  39. package/__tests__/panel.test.tsx +0 -243
  40. package/__tests__/popover.test.tsx +0 -282
  41. package/__tests__/radiogroup.test.tsx +0 -47
  42. package/__tests__/setup.js +0 -8
  43. package/__tests__/stories/Collection.stories.tsx +0 -0
  44. package/__tests__/table.test.tsx +0 -647
  45. package/__tests__/tabs.test.tsx +0 -321
  46. package/__tests__/tag.test.tsx +0 -160
  47. package/__tests__/textarea.test.tsx +0 -467
  48. package/__tests__/timeAgo.test.tsx +0 -27
  49. package/__tests__/tree.test.tsx +0 -58
  50. package/build-storybook.log +0 -491
  51. package/chromatic.config.json +0 -1
  52. package/icons.ts +0 -1
  53. package/migration-storybook.log +0 -56
  54. package/public/logo-dark.png +0 -0
  55. package/public/logo.png +0 -0
  56. package/public/q-symbol-small.png +0 -0
  57. package/public/q-symbol.png +0 -0
  58. package/public/qoreLogo-dark.png +0 -0
  59. package/public/qoreLogo.png +0 -0
  60. package/src/components/Breadcrumbs/index.tsx +0 -254
  61. package/src/components/Breadcrumbs/item.tsx +0 -44
  62. package/src/components/Button/index.tsx +0 -633
  63. package/src/components/Checkbox/index.tsx +0 -388
  64. package/src/components/Collection/index.tsx +0 -426
  65. package/src/components/Collection/item.tsx +0 -267
  66. package/src/components/Columns/column.tsx +0 -27
  67. package/src/components/Columns/index.tsx +0 -41
  68. package/src/components/Comment/index.tsx +0 -141
  69. package/src/components/CommentFeed/index.tsx +0 -34
  70. package/src/components/Content/index.tsx +0 -34
  71. package/src/components/Content/wrapper.tsx +0 -36
  72. package/src/components/ControlGroup/index.tsx +0 -523
  73. package/src/components/DatePicker/index.tsx +0 -347
  74. package/src/components/Drawer/backdrop.tsx +0 -54
  75. package/src/components/Drawer/index.tsx +0 -365
  76. package/src/components/Dropdown/index.tsx +0 -153
  77. package/src/components/Dropdown/item.tsx +0 -33
  78. package/src/components/Dropdown/list.tsx +0 -222
  79. package/src/components/Effect/index.tsx +0 -464
  80. package/src/components/ExportModal/index.tsx +0 -99
  81. package/src/components/Header/index.tsx +0 -81
  82. package/src/components/Icon/index.tsx +0 -184
  83. package/src/components/Input/index.tsx +0 -295
  84. package/src/components/InputClearButton/index.tsx +0 -59
  85. package/src/components/InternalPopover/index.tsx +0 -303
  86. package/src/components/KeyValueTable/index.tsx +0 -192
  87. package/src/components/Label/index.tsx +0 -10
  88. package/src/components/Layout/content.tsx +0 -31
  89. package/src/components/Layout/index.tsx +0 -55
  90. package/src/components/Menu/divider.tsx +0 -92
  91. package/src/components/Menu/index.tsx +0 -141
  92. package/src/components/Menu/item.tsx +0 -137
  93. package/src/components/Menu/section.tsx +0 -81
  94. package/src/components/Message/index.tsx +0 -220
  95. package/src/components/Modal/index.tsx +0 -26
  96. package/src/components/MultiSelect/index.tsx +0 -288
  97. package/src/components/Navbar/divider.tsx +0 -50
  98. package/src/components/Navbar/group.tsx +0 -53
  99. package/src/components/Navbar/index.tsx +0 -82
  100. package/src/components/Navbar/item.tsx +0 -92
  101. package/src/components/Notifications/index.tsx +0 -57
  102. package/src/components/Notifications/notification.tsx +0 -362
  103. package/src/components/Paging/index.tsx +0 -321
  104. package/src/components/Panel/LabelEditor.tsx +0 -67
  105. package/src/components/Panel/NonResponsiveActions.tsx +0 -79
  106. package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
  107. package/src/components/Panel/index.tsx +0 -912
  108. package/src/components/Panel/panel.screenshot.tsx +0 -29
  109. package/src/components/Paragraph/index.tsx +0 -43
  110. package/src/components/Popover/index.tsx +0 -68
  111. package/src/components/RadioGroup/index.tsx +0 -71
  112. package/src/components/Slider/index.tsx +0 -358
  113. package/src/components/Spacer/index.tsx +0 -142
  114. package/src/components/Spinner/index.tsx +0 -74
  115. package/src/components/Table/body.tsx +0 -109
  116. package/src/components/Table/cell.tsx +0 -136
  117. package/src/components/Table/header.tsx +0 -236
  118. package/src/components/Table/headerCell.tsx +0 -203
  119. package/src/components/Table/helpers.ts +0 -308
  120. package/src/components/Table/index.tsx +0 -797
  121. package/src/components/Table/row.tsx +0 -288
  122. package/src/components/Table/value.tsx +0 -28
  123. package/src/components/Tabs/content.tsx +0 -68
  124. package/src/components/Tabs/index.tsx +0 -124
  125. package/src/components/Tabs/item.tsx +0 -198
  126. package/src/components/Tabs/list.tsx +0 -381
  127. package/src/components/Tag/group.tsx +0 -73
  128. package/src/components/Tag/index.tsx +0 -463
  129. package/src/components/Textarea/index.tsx +0 -277
  130. package/src/components/TimeAgo/index.tsx +0 -15
  131. package/src/components/Tree/index.tsx +0 -271
  132. package/src/constants/animations.ts +0 -9
  133. package/src/constants/colors.ts +0 -13
  134. package/src/constants/paging.ts +0 -93
  135. package/src/constants/sizes.ts +0 -185
  136. package/src/constants/theme.ts +0 -122
  137. package/src/containers/Paging.tsx +0 -136
  138. package/src/containers/PopoverProvider.tsx +0 -124
  139. package/src/containers/ReqoreProvider.tsx +0 -289
  140. package/src/containers/ThemeProvider.tsx +0 -12
  141. package/src/containers/UIProvider.tsx +0 -101
  142. package/src/context/PopoverContext.tsx +0 -11
  143. package/src/context/ReqoreContext.tsx +0 -47
  144. package/src/context/ThemeContext.tsx +0 -4
  145. package/src/helpers/animations.ts +0 -13
  146. package/src/helpers/colors.ts +0 -335
  147. package/src/helpers/time.ts +0 -21
  148. package/src/helpers/utils.ts +0 -152
  149. package/src/hooks/useAutoFocus.ts +0 -106
  150. package/src/hooks/useCloneThroughFragments.ts +0 -39
  151. package/src/hooks/useCombinedRefs.ts +0 -26
  152. package/src/hooks/useLatestZIndex.ts +0 -13
  153. package/src/hooks/useOutsideClick.ts +0 -29
  154. package/src/hooks/usePaging.ts +0 -128
  155. package/src/hooks/usePopover.tsx +0 -220
  156. package/src/hooks/useQueryWithDelay.ts +0 -30
  157. package/src/hooks/useReqore.ts +0 -12
  158. package/src/hooks/useReqoreContext.ts +0 -16
  159. package/src/hooks/useReqoreEffect.ts +0 -49
  160. package/src/hooks/useTextareaAutoSize.ts +0 -22
  161. package/src/hooks/useTheme.ts +0 -48
  162. package/src/hooks/useTooltip.ts +0 -40
  163. package/src/hooks/useWhyDidYouUpdate.ts +0 -32
  164. package/src/icons.json +0 -2295
  165. package/src/index.tsx +0 -80
  166. package/src/mock/breadcrumbs.ts +0 -146
  167. package/src/mock/collectionData.tsx +0 -380
  168. package/src/mock/data.json +0 -11000
  169. package/src/mock/icons.ts +0 -32
  170. package/src/mock/menu.ts +0 -93
  171. package/src/mock/multiSelect.ts +0 -71
  172. package/src/mock/object.json +0 -317
  173. package/src/mock/styleMock.js +0 -1
  174. package/src/mock/tableData.ts +0 -64
  175. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
  176. package/src/stories/Button/Button.stories.tsx +0 -405
  177. package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
  178. package/src/stories/Collection/Collection.stories.tsx +0 -317
  179. package/src/stories/Columns/Columns.stories.tsx +0 -158
  180. package/src/stories/Comment/Comment.stories.tsx +0 -136
  181. package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
  182. package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
  183. package/src/stories/Drawer/Drawer.stories.tsx +0 -294
  184. package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
  185. package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
  186. package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
  187. package/src/stories/Header/Header.stories.tsx +0 -108
  188. package/src/stories/Icon/Icon.stories.tsx +0 -162
  189. package/src/stories/Input/Input.stories.tsx +0 -220
  190. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
  191. package/src/stories/Label/Label.stories.tsx +0 -33
  192. package/src/stories/Menu/Menu.stories.tsx +0 -367
  193. package/src/stories/Message/Message.stories.tsx +0 -167
  194. package/src/stories/Modal/Manager.stories.tsx +0 -192
  195. package/src/stories/Modal/Modal.stories.tsx +0 -252
  196. package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
  197. package/src/stories/Navbar/Navbar.stories.tsx +0 -119
  198. package/src/stories/Notifications/Interactive.stories.tsx +0 -117
  199. package/src/stories/Notifications/Notification.stories.tsx +0 -216
  200. package/src/stories/Notifications/Notifications.stories.tsx +0 -81
  201. package/src/stories/Paging/Paging.stories.tsx +0 -255
  202. package/src/stories/Panel/Panel.stories.tsx +0 -753
  203. package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
  204. package/src/stories/Popover/Popover.stories.tsx +0 -510
  205. package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
  206. package/src/stories/Slider/Slider.stories.tsx +0 -173
  207. package/src/stories/Spacer/Spacer.stories.tsx +0 -100
  208. package/src/stories/Spinner/Spinner.stories.tsx +0 -82
  209. package/src/stories/Table/Table.stories.tsx +0 -571
  210. package/src/stories/Tabs/Tabs.stories.tsx +0 -346
  211. package/src/stories/Tag/Tag.stories.tsx +0 -381
  212. package/src/stories/Tag/TagGroup.stories.tsx +0 -307
  213. package/src/stories/TextArea/TextArea.stories.tsx +0 -287
  214. package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
  215. package/src/stories/Tree/Tree.stories.tsx +0 -124
  216. package/src/stories/Wrapper.tsx +0 -13
  217. package/src/stories/utils/args.ts +0 -151
  218. package/src/stories/utils.ts +0 -39
  219. package/src/styles.ts +0 -124
  220. package/src/types/global.ts +0 -211
  221. package/src/types/icons.ts +0 -2272
  222. package/tsconfig.prod.json +0 -26
@@ -1,222 +0,0 @@
1
- import { size } from 'lodash';
2
- import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
3
- import { TReqorePaginationType } from '../../constants/paging';
4
- import { PADDING_FROM_SIZE } from '../../constants/sizes';
5
- import { ReqorePaginationContainer } from '../../containers/Paging';
6
- import { IReqoreComponent } from '../../types/global';
7
- import ReqoreButton from '../Button';
8
- import ReqoreControlGroup from '../ControlGroup';
9
- import ReqoreInput, { IReqoreInputProps } from '../Input';
10
- import ReqoreMenu from '../Menu';
11
- import ReqoreMenuDivider, { IReqoreMenuDividerProps } from '../Menu/divider';
12
- import { IReqoreMenuItemProps } from '../Menu/item';
13
- import { ReqoreVerticalSpacer } from '../Spacer';
14
- import { ReqoreDropdownItem } from './item';
15
-
16
- export type TDropdownItemOnClick = (item: IReqoreDropdownItem) => void;
17
- export interface IReqoreDropdownItem
18
- extends Omit<IReqoreMenuItemProps, 'onClick' | 'onRightIconClick'> {
19
- value?: any;
20
- items?: TReqoreDropdownItems;
21
- onClick?: TDropdownItemOnClick;
22
- divider?: boolean;
23
- dividerAlign?: 'left' | 'center' | 'right';
24
- dividerPadded?: 'top' | 'bottom' | 'both' | 'none';
25
- line?: boolean;
26
- }
27
-
28
- export type TReqoreDropdownItem = IReqoreDropdownItem;
29
- export type TReqoreDropdownItems = TReqoreDropdownItem[];
30
-
31
- export interface IReqoreDropdownListProps extends IReqoreComponent {
32
- items?: TReqoreDropdownItems;
33
- multiSelect?: boolean;
34
- listStyle?: React.CSSProperties;
35
- width?: string;
36
- height?: string;
37
-
38
- filterable?: boolean;
39
- onFilterChange?: (query: string) => void;
40
- filter?: string | number;
41
- filterPlaceholder?: string;
42
-
43
- onItemSelect?: TDropdownItemOnClick;
44
- inputProps?: IReqoreInputProps;
45
- scrollToSelected?: boolean;
46
- paging?: TReqorePaginationType<TReqoreDropdownItem>;
47
-
48
- _onBackClick?: () => void;
49
- }
50
-
51
- const ReqoreDropdownList = memo(
52
- ({
53
- items,
54
- multiSelect,
55
- listStyle,
56
- _popoverId,
57
- filterable,
58
- width,
59
- height,
60
- onItemSelect,
61
- inputProps,
62
- scrollToSelected,
63
- paging,
64
- onFilterChange,
65
- filterPlaceholder,
66
- filter,
67
- _onBackClick,
68
- }: IReqoreDropdownListProps) => {
69
- const [_items, setItems] = useState<TReqoreDropdownItems>(items);
70
- const [query, setQuery] = useState<string | number>(onFilterChange ? '' : filter || '');
71
- const [menuRef, setMenuRef] = useState<HTMLDivElement>(undefined);
72
- const [selectedItem, setSelectedItem] = useState<IReqoreDropdownItem>(undefined);
73
-
74
- useEffect(() => {
75
- setItems(items);
76
- }, [items]);
77
-
78
- const filteredItems: TReqoreDropdownItems = useMemo(() => {
79
- if (!filterable || query === '') {
80
- return _items;
81
- }
82
-
83
- return _items.filter((item) => {
84
- if (item.divider) {
85
- return true;
86
- }
87
-
88
- const text: string | undefined = item.label || item.value || item.children;
89
-
90
- if (!text) {
91
- return false;
92
- }
93
-
94
- return text.toString().toLowerCase().indexOf(query.toString().toLowerCase()) !== -1;
95
- });
96
- }, [items, query, _items]);
97
-
98
- const handleQueryChange = (event: React.ChangeEvent<HTMLInputElement>) => {
99
- if (onFilterChange) {
100
- onFilterChange(event.target.value);
101
- } else {
102
- setQuery(event.target.value);
103
- }
104
- };
105
-
106
- const handleItemClick = useCallback(
107
- (item: IReqoreDropdownItem): void => {
108
- if (size(item.items)) {
109
- setSelectedItem(item);
110
-
111
- return;
112
- }
113
-
114
- if (item.onClick) {
115
- item.onClick(item);
116
- }
117
-
118
- if (onItemSelect) {
119
- onItemSelect(item);
120
- }
121
- },
122
- [onItemSelect, selectedItem]
123
- );
124
-
125
- if (selectedItem) {
126
- return (
127
- <ReqoreDropdownList
128
- {...{
129
- items: selectedItem.items,
130
- multiSelect,
131
- listStyle,
132
- _popoverId,
133
- filterable,
134
- width,
135
- height,
136
- onItemSelect,
137
- inputProps,
138
- scrollToSelected,
139
- paging,
140
- onFilterChange,
141
- filterPlaceholder,
142
- filter,
143
- _onBackClick: () => setSelectedItem(undefined),
144
- }}
145
- />
146
- );
147
- }
148
-
149
- return (
150
- <>
151
- {filterable || _onBackClick ? (
152
- <>
153
- <ReqoreControlGroup fluid>
154
- {_onBackClick && (
155
- <ReqoreButton
156
- icon='ArrowLeftSLine'
157
- fluid={!filterable}
158
- fixed={filterable}
159
- onClick={_onBackClick}
160
- className='reqore-dropdown-back-button'
161
- />
162
- )}
163
- {filterable && (
164
- <ReqoreInput
165
- value={onFilterChange ? filter : query}
166
- icon='SearchLine'
167
- onChange={handleQueryChange}
168
- placeholder={
169
- filterPlaceholder ||
170
- `Search ${size(_items.filter((item) => !item.divider))} items...`
171
- }
172
- onClearClick={() => (onFilterChange ? onFilterChange('') : setQuery(''))}
173
- {...inputProps}
174
- />
175
- )}
176
- </ReqoreControlGroup>
177
- <ReqoreVerticalSpacer height={PADDING_FROM_SIZE.normal} />
178
- </>
179
- ) : null}
180
- <ReqorePaginationContainer type={paging} items={filteredItems} scrollContainer={menuRef}>
181
- {(finalItems, Controls, { includeBottomControls }) => (
182
- <ReqoreMenu
183
- _insidePopover={!multiSelect}
184
- _popoverId={_popoverId}
185
- style={listStyle}
186
- width={width}
187
- maxHeight={height || '300px'}
188
- padded={false}
189
- ref={setMenuRef}
190
- >
191
- {finalItems.map(
192
- (
193
- { dividerAlign, dividerPadded, divider, ...item }: IReqoreDropdownItem,
194
- index: number
195
- ) =>
196
- divider ? (
197
- <ReqoreMenuDivider
198
- key={index}
199
- {...(item as unknown as IReqoreMenuDividerProps)}
200
- align={dividerAlign}
201
- padded={dividerPadded}
202
- />
203
- ) : (
204
- <ReqoreDropdownItem
205
- key={item.label || item.value || index}
206
- {...item}
207
- disabled={'items' in item && !size(item.items) ? true : item.disabled}
208
- onItemClick={handleItemClick}
209
- scrollIntoView={scrollToSelected && item.selected && !multiSelect}
210
- />
211
- )
212
- )}
213
- {!includeBottomControls && Controls}
214
- </ReqoreMenu>
215
- )}
216
- </ReqorePaginationContainer>
217
- </>
218
- );
219
- }
220
- );
221
-
222
- export default ReqoreDropdownList;
@@ -1,464 +0,0 @@
1
- import { rgba } from 'polished';
2
- import { HTMLAttributes } from 'react';
3
- import styled, { css, keyframes } from 'styled-components';
4
- import { Colors } from '../../constants/colors';
5
- import { TEXT_FROM_SIZE, TSizes, WEIGHT_TO_NUMBER } from '../../constants/sizes';
6
- import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
7
- import {
8
- changeLightness,
9
- createEffectGradient,
10
- getColorFromMaybeString,
11
- getGradientMix,
12
- getReadableColorFrom,
13
- } from '../../helpers/colors';
14
- import { isStringSize } from '../../helpers/utils';
15
- import { IWithReqoreMinimal } from '../../types/global';
16
-
17
- export type TReqoreEffectColorManipulation = 'darken' | 'lighten';
18
- export type TReqoreEffectColorManipulationMultiplier =
19
- | 1
20
- | 2
21
- | 3
22
- | 4
23
- | 5
24
- | 6
25
- | 7
26
- | 8
27
- | 9
28
- | 10
29
- | 11
30
- | 12
31
- | 13
32
- | 14
33
- | 15
34
- | 16
35
- | 17
36
- | 18
37
- | 19
38
- | 20
39
- | 21
40
- | 22
41
- | 23
42
- | 24
43
- | 25
44
- | 26
45
- | 27
46
- | 28
47
- | 29
48
- | 30;
49
- export type TReqoreEffectColorManipulationAlpha =
50
- | 0
51
- | 0.1
52
- | 0.2
53
- | 0.3
54
- | 0.4
55
- | 0.5
56
- | 0.6
57
- | 0.7
58
- | 0.8
59
- | 0.9
60
- | 1;
61
- export type TReqoreHexColor = `#${string}`;
62
- export type TReqoreRgbColor = `rgb(${number}, ${number}, ${number})`;
63
- export type TReqoreRgbaColor = `rgba(${number}, ${number}, ${number}, ${string})`;
64
- export type TReqoreMultiTypeColor = TReqoreHexColor | TReqoreRgbColor | TReqoreRgbaColor;
65
- export type TReqoreColor = TReqoreHexColor | 'transparent';
66
- export type TReqoreEffectColor =
67
- | (TReqoreColor | TReqoreHexColor | 'main' | TReqoreIntent)
68
- | `${TReqoreIntent | 'main' | TReqoreHexColor}:${TReqoreEffectColorManipulation}`
69
- | `${
70
- | TReqoreIntent
71
- | 'main'
72
- | TReqoreHexColor}:${TReqoreEffectColorManipulation}:${TReqoreEffectColorManipulationMultiplier}`
73
- | `${
74
- | TReqoreIntent
75
- | 'main'
76
- | TReqoreHexColor}:${TReqoreEffectColorManipulation}:${TReqoreEffectColorManipulationMultiplier}:${TReqoreEffectColorManipulationAlpha}`;
77
- export type TReqoreEffectColorList = [
78
- 'main' | TReqoreIntent | TReqoreColor,
79
- TReqoreEffectColorManipulation | undefined,
80
- TReqoreEffectColorManipulationMultiplier | undefined,
81
- TReqoreEffectColorManipulationAlpha | undefined
82
- ];
83
- export type TReqoreEffectGradientColors =
84
- | 'main'
85
- | TReqoreIntent
86
- | TReqoreHexColor
87
- | TReqoreEffectGradientColorsObject;
88
- export type TReqoreEffectGradientColorsObject = Record<number, TReqoreEffectColor>;
89
- export type TReqoreEffectGradientAnimationTrigger = 'always' | 'hover' | 'active' | 'never';
90
-
91
- export interface IReqoreEffectFilters {
92
- grayscale?: boolean;
93
- blur?: number;
94
- sepia?: boolean;
95
- invert?: boolean;
96
- opacity?: number;
97
- brightness?: number;
98
- contrast?: number;
99
- saturate?: number;
100
- }
101
-
102
- export interface IReqoreEffect extends IReqoreEffectFilters {
103
- gradient?: {
104
- type?: 'linear' | 'radial';
105
- shape?: 'circle' | 'ellipse';
106
- colors: TReqoreEffectGradientColors;
107
- direction?: string;
108
- borderColor?: TReqoreEffectColor;
109
- animate?: TReqoreEffectGradientAnimationTrigger;
110
- animationSpeed?: 1 | 2 | 3 | 4 | 5;
111
- };
112
- noWrap?: boolean;
113
- color?: TReqoreEffectColor;
114
- spaced?: number;
115
- weight?: number | 'thin' | 'light' | 'normal' | 'bold' | 'thick';
116
- uppercase?: boolean;
117
- textSize?: TSizes | string;
118
- textAlign?: 'left' | 'center' | 'right';
119
- glow?: {
120
- size?: number;
121
- color: TReqoreEffectColor;
122
- inset?: boolean;
123
- blur?: number;
124
- opacity?: number;
125
- when?: 'always' | 'hover' | 'focus' | 'active';
126
- };
127
- interactive?: boolean;
128
- }
129
-
130
- export interface IReqoreTextEffectProps
131
- extends HTMLAttributes<HTMLSpanElement>,
132
- IWithReqoreMinimal {
133
- children: React.ReactNode;
134
- effect: IReqoreEffect;
135
- as?: React.ElementType;
136
- theme?: IReqoreTheme;
137
- active?: boolean;
138
- isText?: boolean;
139
- }
140
-
141
- // Animate the gradient
142
- const StyledGradientKeyframes = keyframes`
143
- 0% {
144
- background-position: 0% 0%;
145
- }
146
- 50% {
147
- background-position: 100% 100%;
148
- }
149
- 100% {
150
- background-position: 0% 0%;
151
- }
152
- `;
153
-
154
- export const StyledEffect = styled.span`
155
- // If gradient was supplied
156
- ${({ effect, theme, minimal, active, isText }: IReqoreTextEffectProps) => {
157
- if (!effect || !effect.gradient) {
158
- return undefined;
159
- }
160
-
161
- const gradientType: string = effect.gradient.type || 'linear';
162
- const gradientColors = createEffectGradient(
163
- theme,
164
- effect.gradient.colors,
165
- minimal ? 0.05 : 0,
166
- !isText && minimal && !active
167
- );
168
- const gradientColorsActive = createEffectGradient(
169
- theme,
170
- effect.gradient.colors,
171
- 0.05,
172
- minimal,
173
- true
174
- );
175
-
176
- const gradientDirectionOrShape =
177
- gradientType === 'linear'
178
- ? effect.gradient.direction || 'to right'
179
- : `${effect.gradient.shape || 'circle'} ${effect.gradient.direction || 'at center'}`;
180
- let gradient = `${gradientType}-gradient(${gradientDirectionOrShape}${gradientColors}) padding-box`;
181
- let gradientActive = `${gradientType}-gradient(${gradientDirectionOrShape}${gradientColorsActive}) padding-box`;
182
-
183
- // Determine the text color based on the gradient colors
184
- let color: TReqoreHexColor | undefined;
185
- // Only works if there are 2 colors not more and color was not provided
186
- if (!effect.color) {
187
- color = getGradientMix(theme, effect.gradient.colors);
188
- }
189
-
190
- let borderColor: string;
191
- let borderHoverColor: string;
192
-
193
- // The user provided a border color - we will use that
194
- if (effect.gradient.borderColor) {
195
- borderColor = `${getColorFromMaybeString(theme, effect.gradient.borderColor)}`;
196
- borderHoverColor = `${changeLightness(
197
- getColorFromMaybeString(theme, effect.gradient.borderColor),
198
- 0.15
199
- )}`;
200
- } else if (!isText) {
201
- // We will use border-image and create a gradient border
202
- borderColor = 'transparent';
203
- borderHoverColor = 'transparent';
204
-
205
- const borderGradientColors: string = createEffectGradient(
206
- theme,
207
- effect.gradient.colors,
208
- 0.15
209
- );
210
- const borderGradientColorsActive: string = createEffectGradient(
211
- theme,
212
- effect.gradient.colors,
213
- 0.25
214
- );
215
-
216
- gradient = `${gradient}, ${gradientType}-gradient(${gradientDirectionOrShape}${borderGradientColors}) border-box`;
217
- gradientActive = `${gradientActive}, ${gradientType}-gradient(${gradientDirectionOrShape}${borderGradientColorsActive}) border-box`;
218
- }
219
-
220
- return css`
221
- background: ${active ? gradientActive : gradient};
222
- border-color: ${borderColor} !important;
223
-
224
- ${color && !minimal
225
- ? css`
226
- color: ${getReadableColorFrom(getColorFromMaybeString(theme, color), false)} !important;
227
- &::placeholder {
228
- color: ${rgba(
229
- getReadableColorFrom(getColorFromMaybeString(theme, color), false),
230
- 0.7
231
- )} !important;
232
- }
233
- `
234
- : undefined}
235
-
236
- ${effect.gradient.animate === 'always' || (effect.gradient.animate === 'active' && active)
237
- ? css`
238
- background-size: 200% 200%;
239
- animation: ${StyledGradientKeyframes} ${effect.gradient.animationSpeed || 2}s linear
240
- infinite;
241
- `
242
- : undefined}
243
-
244
- ${effect.interactive &&
245
- css`
246
- cursor: pointer;
247
-
248
- &:hover,
249
- &:focus,
250
- &:active {
251
- background: ${gradientActive};
252
- border-color: ${borderHoverColor} !important;
253
-
254
- ${effect.gradient.animate === 'hover' ||
255
- (effect.gradient.animate === 'active' && active) ||
256
- effect.gradient.animate === 'always'
257
- ? css`
258
- background-size: 200% 200%;
259
- animation: ${StyledGradientKeyframes} ${effect.gradient.animationSpeed || 2}s linear
260
- infinite;
261
- `
262
- : undefined}
263
- }
264
- `}
265
- `;
266
- }}
267
-
268
- ${({ effect, theme, isText }: IReqoreTextEffectProps) => {
269
- if (!effect || !effect.glow) {
270
- return undefined;
271
- }
272
-
273
- let glow;
274
-
275
- if (!isText) {
276
- glow = css`
277
- box-shadow: ${effect.glow.inset ? 'inset ' : ''} 0 0 ${effect.glow.blur || 0}px
278
- ${effect.glow.size || 2}px ${getColorFromMaybeString(theme, effect.glow.color)};
279
- `;
280
- } else {
281
- const color = getColorFromMaybeString(
282
- theme,
283
- effect.glow.color === 'main' ? 'main:lighten:2' : effect.glow.color
284
- );
285
- const blur = effect.glow.blur || 0;
286
- const opacity = effect.glow.opacity || 1;
287
-
288
- glow = css`
289
- color: ${Colors.LIGHT};
290
- text-shadow: 0 0 ${blur}px ${rgba(color, opacity)},
291
- 0 0 ${blur + 5}px ${rgba(color, opacity)}, 0 0 ${blur + 10}px ${rgba(color, opacity)},
292
- 0 0 1px ${rgba(getReadableColorFrom(color), opacity)},
293
- 0 0 2px ${rgba(getReadableColorFrom(color), opacity)},
294
- 0 0 3px ${rgba(getReadableColorFrom(color), opacity)};
295
- `;
296
- }
297
-
298
- if (effect.glow.when === 'always' || !effect.glow.when) {
299
- return glow;
300
- }
301
-
302
- if (effect.glow.when === 'hover') {
303
- return css`
304
- &:hover {
305
- ${glow}
306
- }
307
- `;
308
- }
309
-
310
- if (effect.glow.when === 'focus') {
311
- return css`
312
- &:focus {
313
- ${glow}
314
- }
315
- `;
316
- }
317
-
318
- if (effect.glow.when === 'active') {
319
- return css`
320
- &:active {
321
- ${glow}
322
- }
323
- `;
324
- }
325
- }}
326
-
327
- ${({ effect }: IReqoreTextEffectProps) =>
328
- effect && effect.spaced
329
- ? css`
330
- letter-spacing: ${effect.spaced}px;
331
- `
332
- : undefined}
333
-
334
- ${({ effect }: IReqoreTextEffectProps) =>
335
- effect && effect.uppercase
336
- ? css`
337
- text-transform: uppercase;
338
- `
339
- : undefined}
340
-
341
- ${({ effect }: IReqoreTextEffectProps) => {
342
- if (!effect || !effect.weight) {
343
- return undefined;
344
- }
345
-
346
- const weight =
347
- typeof effect.weight === 'number' ? effect.weight : WEIGHT_TO_NUMBER[effect.weight];
348
-
349
- return css`
350
- font-weight: ${weight} !important;
351
- `;
352
- }}
353
-
354
- ${({ effect }: IReqoreTextEffectProps) =>
355
- effect && effect.noWrap
356
- ? css`
357
- white-space: nowrap;
358
- text-overflow: ellipsis;
359
- overflow: hidden;
360
- min-width: 30px;
361
- `
362
- : undefined}
363
-
364
- ${({ effect, theme }: IReqoreTextEffectProps) =>
365
- effect && effect.color
366
- ? css`
367
- color: ${getColorFromMaybeString(theme, effect.color)} !important;
368
- `
369
- : undefined}
370
-
371
- ${({ effect }: IReqoreTextEffectProps) =>
372
- effect && effect.textSize
373
- ? css`
374
- font-size: ${isStringSize(effect.textSize)
375
- ? `${TEXT_FROM_SIZE[effect.textSize]}px`
376
- : effect.textSize} !important;
377
- `
378
- : undefined}
379
-
380
- ${({ effect }: IReqoreTextEffectProps) =>
381
- effect && effect.textAlign
382
- ? css`
383
- width: 100%;
384
- text-align: ${effect.textAlign};
385
- `
386
- : undefined}
387
-
388
- ${({ effect }) =>
389
- effect &&
390
- effect.grayscale &&
391
- css`
392
- filter: grayscale(100%);
393
- `};
394
- ${({ effect }) =>
395
- effect &&
396
- effect.blur &&
397
- css`
398
- filter: blur(${effect.blur}px);
399
- `};
400
- ${({ effect }) =>
401
- effect &&
402
- effect.sepia &&
403
- css`
404
- filter: sepia(100%);
405
- `};
406
- ${({ effect }) =>
407
- effect &&
408
- effect.invert &&
409
- css`
410
- filter: invert(100%);
411
- `};
412
- ${({ effect }) =>
413
- effect && (effect.opacity || effect.opacity === 0)
414
- ? css`
415
- opacity: ${effect.opacity};
416
- `
417
- : undefined};
418
- ${({ effect }) =>
419
- effect &&
420
- effect.brightness &&
421
- css`
422
- filter: brightness(${effect.brightness}%);
423
- `};
424
- ${({ effect }) =>
425
- effect &&
426
- effect.contrast &&
427
- css`
428
- filter: contrast(${effect.contrast}%);
429
- `};
430
- ${({ effect }) =>
431
- effect &&
432
- effect.saturate &&
433
- css`
434
- filter: saturate(${effect.saturate}%);
435
- `};
436
- `;
437
-
438
- export const StyledTextEffect = styled(StyledEffect).attrs((props) => ({ ...props, isText: true }))`
439
- display: inline-block;
440
-
441
- ${({ effect }: IReqoreTextEffectProps) =>
442
- effect && effect.gradient
443
- ? css`
444
- -webkit-background-clip: text !important;
445
- -webkit-text-fill-color: transparent !important;
446
- `
447
- : undefined}
448
- `;
449
-
450
- export const ReqoreEffect = ({ children, ...rest }: IReqoreTextEffectProps) => {
451
- return (
452
- <StyledEffect className='reqore-effect' {...rest}>
453
- {children}
454
- </StyledEffect>
455
- );
456
- };
457
-
458
- export const ReqoreTextEffect = ({ children, className, ...rest }: IReqoreTextEffectProps) => {
459
- return (
460
- <StyledTextEffect className={`${className || ''} reqore-text-effect`} {...rest}>
461
- {children}
462
- </StyledTextEffect>
463
- );
464
- };