@luminati-io/uikit 1.2.2 → 1.4.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 (94) hide show
  1. package/assets/icons/account.svg +8 -0
  2. package/assets/icons/adapt.svg +4 -0
  3. package/assets/icons/add.svg +3 -0
  4. package/assets/icons/add_circle.svg +5 -0
  5. package/assets/icons/add_funds.svg +7 -0
  6. package/assets/icons/attach.svg +3 -0
  7. package/assets/icons/book_help.svg +4 -0
  8. package/assets/icons/building.svg +3 -0
  9. package/assets/icons/calendar.svg +13 -0
  10. package/assets/icons/calendar_graph.svg +14 -0
  11. package/assets/icons/call.svg +5 -0
  12. package/assets/icons/camera.svg +5 -0
  13. package/assets/icons/cart.svg +3 -0
  14. package/assets/icons/close.svg +3 -0
  15. package/assets/icons/close_circle.svg +3 -0
  16. package/assets/icons/close_small.svg +5 -0
  17. package/assets/icons/collapse.svg +4 -0
  18. package/assets/icons/column.svg +22 -0
  19. package/assets/icons/columns.svg +10 -0
  20. package/assets/icons/connect.svg +3 -0
  21. package/assets/icons/contact_support.svg +3 -0
  22. package/assets/icons/copy.svg +3 -0
  23. package/assets/icons/copy_small.svg +3 -0
  24. package/assets/icons/customize.svg +6 -0
  25. package/assets/icons/dataset.svg +3 -0
  26. package/assets/icons/delete.svg +4 -4
  27. package/assets/icons/desktop.svg +3 -0
  28. package/assets/icons/dislike.svg +3 -0
  29. package/assets/icons/doc_new.svg +8 -0
  30. package/assets/icons/document.svg +3 -0
  31. package/assets/icons/dots_horizontal.svg +3 -0
  32. package/assets/icons/dots_vertical.svg +3 -0
  33. package/assets/icons/download.svg +3 -0
  34. package/assets/icons/drag_and_drop.svg +3 -0
  35. package/assets/icons/edit.svg +3 -0
  36. package/assets/icons/edit_small.svg +3 -0
  37. package/assets/icons/envelope.svg +4 -0
  38. package/assets/icons/file_csv.svg +7 -0
  39. package/assets/icons/file_json.svg +8 -0
  40. package/assets/icons/filter.svg +3 -0
  41. package/assets/icons/folder.svg +3 -0
  42. package/assets/icons/forward.svg +3 -0
  43. package/assets/icons/index.js +162 -4
  44. package/assets/icons/info.svg +3 -0
  45. package/assets/icons/invite.svg +3 -0
  46. package/assets/icons/lightning.svg +3 -0
  47. package/assets/icons/like.svg +3 -0
  48. package/assets/icons/link_ext.svg +4 -0
  49. package/assets/icons/lock.svg +4 -0
  50. package/assets/icons/login.svg +12 -0
  51. package/assets/icons/logout.svg +4 -0
  52. package/assets/icons/maximize.svg +4 -0
  53. package/assets/icons/mention.svg +3 -0
  54. package/assets/icons/menu_close.svg +3 -0
  55. package/assets/icons/menu_expand.svg +3 -0
  56. package/assets/icons/message.svg +3 -0
  57. package/assets/icons/minimize.svg +4 -0
  58. package/assets/icons/minus.svg +3 -0
  59. package/assets/icons/monitor.svg +3 -0
  60. package/assets/icons/on_off.svg +8 -0
  61. package/assets/icons/pause.svg +3 -0
  62. package/assets/icons/pin.svg +3 -0
  63. package/assets/icons/play.svg +3 -0
  64. package/assets/icons/publish.svg +9 -0
  65. package/assets/icons/question.svg +3 -0
  66. package/assets/icons/queue.svg +8 -0
  67. package/assets/icons/referal.svg +4 -0
  68. package/assets/icons/refresh.svg +3 -0
  69. package/assets/icons/reset.svg +4 -0
  70. package/assets/icons/search.svg +10 -0
  71. package/assets/icons/seo.svg +17 -0
  72. package/assets/icons/settings.svg +3 -0
  73. package/assets/icons/smartphone.svg +4 -0
  74. package/assets/icons/sort.svg +4 -0
  75. package/assets/icons/sum.svg +3 -0
  76. package/assets/icons/trash.svg +3 -0
  77. package/assets/icons/unpin.svg +4 -0
  78. package/assets/icons/upgrade.svg +11 -0
  79. package/assets/icons/upload.svg +4 -0
  80. package/assets/icons/upload_cloud.svg +4 -0
  81. package/assets/icons/verify.svg +4 -0
  82. package/dist/uikit.umd.js +1 -1
  83. package/package.json +6 -3
  84. package/src/button/button.js +121 -0
  85. package/src/button/index.js +6 -0
  86. package/src/button/loading_icon.js +46 -0
  87. package/src/icon.js +16 -24
  88. package/src/icon_button.js +75 -0
  89. package/src/index.js +27 -10
  90. package/src/infochip.js +8 -6
  91. package/src/progress/index.js +1 -1
  92. package/src/tooltip.js +96 -0
  93. package/src/utils.js +136 -1
  94. package/src/button.js +0 -180
package/src/utils.js CHANGED
@@ -2,6 +2,8 @@
2
2
  'use strict'; /*jslint react:true*/
3
3
 
4
4
  import _ from 'lodash';
5
+ import icons from '@icons';
6
+ import {css} from 'styled-components';
5
7
 
6
8
  export const theme = {
7
9
  color: {
@@ -93,6 +95,10 @@ export const theme = {
93
95
  }
94
96
  };
95
97
 
98
+ export const colorNames = Object.keys(theme.color);
99
+
100
+ export const iconNames = Object.keys(icons);
101
+
96
102
  export const toPixel = value=>`${value}px`;
97
103
 
98
104
  export const getCommonProps = props=>_.pickBy(props, (v, k)=>{
@@ -127,5 +133,134 @@ export function fromTheme(propName, defaultValue){
127
133
  };
128
134
  }
129
135
 
136
+ export const getIconProps = (comp, opt)=>{
137
+ const {size, icon, iconPlacement='left'} = opt;
138
+ const isLeft = !!icon&&iconPlacement=='left';
139
+ const isRight = !!icon&&iconPlacement=='right';
140
+ const iconSize = ()=>{
141
+ if (comp=='Link')
142
+ return {lg: 'sm', sm: 'xxs'}[size]||'xs';
143
+ if (comp=='Button')
144
+ return {sm: 'xs', xs: 'xxs'}[size]||'sm';
145
+ if (comp=='MenuItem')
146
+ return size=='sm'?'xs':'sm';
147
+ };
148
+ return {isLeft, isRight, name: icon, size: iconSize()};
149
+ };
150
+
151
+ export const getLinkProps = opt=>{
152
+ const {as, to, href, newTab} = opt;
153
+ let p = {as, to};
154
+ if (href)
155
+ p = {...p, as: 'a', href};
156
+ if (newTab)
157
+ p = {...p, target: '_blank', rel: 'noopener noreferrer'};
158
+ return p;
159
+ };
160
+
161
+ export const getButtonColors = props=>{
162
+ const {variant, disabled} = props;
163
+ if (disabled)
164
+ {
165
+ return {
166
+ color: theme.color.gray_9,
167
+ backColor: theme.color.gray_2,
168
+ border: `1px solid ${theme.color.gray_6}`,
169
+ };
170
+ }
171
+ const styles = {
172
+ primary: {
173
+ color: theme.color.white,
174
+ backColor: theme.color.blue_11,
175
+ hover: {backColor: theme.color.blue_10},
176
+ active: {
177
+ backColor: theme.color.blue_11,
178
+ boxShadow: '0 0 0 2px rgba(0, 106, 220, 0.4)',
179
+ },
180
+ },
181
+ secondary: {
182
+ color: theme.color.blue_11,
183
+ backColor: theme.color.white,
184
+ border: `1px solid ${theme.color.blue_11}`,
185
+ hover: {backColor: theme.color.blue_2},
186
+ active: {
187
+ backColor: theme.color.white,
188
+ boxShadow: '0 0 0 2px rgba(0, 106, 220, 0.4)',
189
+ },
190
+ },
191
+ negative: {
192
+ color: theme.color.white,
193
+ backColor: theme.color.red_11,
194
+ hover: {backColor: theme.color.red_10},
195
+ active: {
196
+ backColor: theme.color.red_11,
197
+ boxShadow: '0 0 0 2px rgba(205, 43, 49, 0.4)',
198
+ },
199
+ },
200
+ negative_secondary: {
201
+ color: theme.color.red_11,
202
+ backColor: theme.color.white,
203
+ border: `1px solid ${theme.color.red_11}`,
204
+ hover: {backColor: theme.color.red_2},
205
+ active: {
206
+ backColor: theme.color.white,
207
+ boxShadow: '0 0 0 2px rgba(205, 43, 49, 0.4)',
208
+ },
209
+ },
210
+ positive: {
211
+ color: theme.color.green_11,
212
+ backColor: theme.color.white,
213
+ border: `1px solid ${theme.color.green_11}`,
214
+ hover: {backColor: theme.color.green_2},
215
+ active: {
216
+ backColor: theme.color.white,
217
+ boxShadow: '0 0 0 2px rgba(6, 122, 111, 0.4)',
218
+ },
219
+ },
220
+ white: {
221
+ color: theme.color.gray_11_50,
222
+ iconColor: theme.color.gray_10,
223
+ backColor: theme.color.white,
224
+ border: `1px solid ${theme.color.gray_8}`,
225
+ hover: {backColor: theme.color.gray_2},
226
+ active: {
227
+ backColor: theme.color.gray_3,
228
+ border: `1px solid ${theme.color.gray_9}`,
229
+ iconColor: theme.color.gray_11_50,
230
+ },
231
+ },
232
+ };
233
+ return styles[variant]||styles.primary;
234
+ };
235
+
236
+ export const toIconSize = size=>{
237
+ const toSize = value=>css`
238
+ width: ${toPixel(value)};
239
+ height: ${toPixel(value)};
240
+ `;
241
+ if (size=='xl')
242
+ return toSize(48);
243
+ if (size=='lg')
244
+ return toSize(32);
245
+ if (size=='sm')
246
+ return toSize(20);
247
+ if (size=='xs')
248
+ return toSize(16);
249
+ if (size=='xxs')
250
+ return toSize(12);
251
+ return toSize(24);
252
+ };
253
+
254
+ export const toButtonSize = size=>{
255
+ let w = 40; // md
256
+ if (size=='lg')
257
+ w = 48;
258
+ if (size=='sm')
259
+ w = 36;
260
+ if (size=='xs')
261
+ w = 28;
262
+ return css`height: ${toPixel(w)};`;
263
+ };
130
264
 
131
- export default {theme, toPixel, getCommonProps, getTypographyProps, fromTheme};
265
+ export default {theme, toPixel, getCommonProps, getTypographyProps, fromTheme,
266
+ colorNames, iconNames};
package/src/button.js DELETED
@@ -1,180 +0,0 @@
1
- // LICENSE_CODE ZON
2
- 'use strict'; /*jslint react:true*/
3
-
4
- import React from 'react';
5
- import styled, {css} from 'styled-components';
6
- import PT from 'prop-types';
7
- import utils from './utils';
8
- import typography from './Typography';
9
-
10
- const {Typography, Label} = typography;
11
- const {theme, toPixel, getCommonProps} = utils;
12
-
13
- const Button = React.forwardRef((props, ref)=>{
14
- const {text, variant, size, icon, iconPlacement, disabled} = props;
15
- const iconLeft = !!icon&&iconPlacement=='left';
16
- const iconRight = !!icon&&iconPlacement=='right';
17
- const iconName = `ic_${icon}.svg`;
18
- const iconSize = {sm: 'xs', xs: 'xxs'}[size]||'sm';
19
- return <StyledButton ref={ref} {...getCommonProps(props)} variant={variant}
20
- size={size} disabled={disabled} $inline={!icon}>
21
- {/* {iconLeft&&<Icon name={iconName} size={iconSize}/>} */}
22
- <Label variant={size=='xs'?'sm':'lg'} no_wrap>{text}</Label>
23
- {/* {iconRight&&<Icon name={iconName} size={iconSize}/>} */}
24
- </StyledButton>;
25
- });
26
- Button.displayName = 'Button';
27
- Button.defaultProps = {size: 'md', iconPlacement: 'left'};
28
- Button.propTypes = {
29
- text: PT.string.isRequired,
30
- variant: PT.oneOf(['primary', 'secondary', 'negative',
31
- 'negative_secondary', 'positive', 'white']).isRequired,
32
- size: PT.oneOf(['xs', 'sm', 'md', 'lg']),
33
- icon: PT.string,
34
- iconPlacement: PT.oneOf(['left', 'right']),
35
- disabled: PT.bool,
36
- };
37
-
38
- const StyledButton = styled.button`
39
- display: flex;
40
- align-items: center;
41
- justify-content: center;
42
- border-radius: 4px;
43
- ${props=>{
44
- let gap = 4;
45
- let paddingLeft = 12;
46
- let paddingRight = 16;
47
- if (props.$inline)
48
- paddingLeft = paddingRight;
49
- if (props.size=='xs')
50
- {
51
- gap = 2;
52
- paddingLeft = paddingRight = 8;
53
- }
54
- return css`
55
- gap: ${toPixel(gap)};
56
- padding-left: ${toPixel(paddingLeft)};
57
- padding-right: ${toPixel(paddingRight)};
58
- `;
59
- }}
60
- ${props=>{
61
- const getColors = ()=>{
62
- const {variant, disabled} = props;
63
- if (disabled)
64
- {
65
- return {
66
- color: theme.color.gray_9,
67
- backColor: theme.color.gray_2,
68
- borderColor: theme.color.gray_6,
69
- };
70
- }
71
- const styles = {
72
- primary: {
73
- color: theme.color.white,
74
- backColor: theme.color.blue_11,
75
- borderColor: theme.color.blue_11,
76
- hover: {
77
- backColor: theme.color.blue_10,
78
- borderColor: theme.color.blue_10,
79
- },
80
- active: {
81
- backColor: theme.color.blue_11,
82
- borderColor: theme.color.blue_11,
83
- boxShadow: '0 0 0 2px rgba(0, 106, 220, 0.4)',
84
- },
85
- },
86
- secondary: {
87
- color: theme.color.blue_11,
88
- backColor: theme.color.white,
89
- borderColor: theme.color.blue_11,
90
- hover: {backColor: theme.color.blue_2},
91
- active: {
92
- backColor: theme.color.white,
93
- boxShadow: '0 0 0 2px rgba(0, 106, 220, 0.4)',
94
- },
95
- },
96
- negative: {
97
- color: theme.color.white,
98
- backColor: theme.color.red_11,
99
- borderColor: theme.color.red_11,
100
- hover: {
101
- backColor: theme.color.red_10,
102
- borderColor: theme.color.red_10,
103
- },
104
- active: {
105
- backColor: theme.color.red_11,
106
- borderColor: theme.color.red_11,
107
- boxShadow: '0 0 0 2px rgba(205, 43, 49, 0.4)',
108
- },
109
- },
110
- negative_secondary: {
111
- color: theme.color.red_11,
112
- backColor: theme.color.white,
113
- borderColor: theme.color.red_11,
114
- hover: {backColor: theme.color.red_2},
115
- active: {
116
- backColor: theme.color.white,
117
- boxShadow: '0 0 0 2px rgba(205, 43, 49, 0.4)',
118
- },
119
- },
120
- positive: {
121
- color: theme.color.green_11,
122
- backColor: theme.color.white,
123
- borderColor: theme.color.green_11,
124
- hover: {backColor: theme.color.green_2},
125
- active: {
126
- backColor: theme.color.white,
127
- boxShadow: '0 0 0 2px rgba(6, 122, 111, 0.4)',
128
- },
129
- },
130
- white: {
131
- color: theme.color.gray_11_50,
132
- iconColor: theme.color.gray_10,
133
- backColor: theme.color.white,
134
- borderColor: theme.color.gray_8,
135
- hover: {backColor: theme.color.gray_2},
136
- active: {
137
- backColor: theme.color.gray_3,
138
- borderColor: theme.color.gray_9,
139
- iconColor: theme.color.gray_11_50,
140
- },
141
- },
142
- };
143
- return styles[variant]||styles.primary;
144
- };
145
- const colors = getColors();
146
- return css`
147
- background-color: ${colors.backColor};
148
- border: 1px solid ${colors.borderColor};
149
- ${Typography} { color: ${colors.color}; }
150
- ${'' /* ${IconContainer} {
151
- background-color: ${colors.iconColor||colors.color};
152
- } */}
153
- ${colors.hover&&`&:hover {
154
- background-color: ${colors.hover.backColor};
155
- border: 1px solid ${colors.hover.borderColor};
156
- }`}
157
- ${colors.active&&`&:active {
158
- background-color: ${colors.active.backColor};
159
- border: 1px solid ${colors.active.borderColor};
160
- box-shadow: ${colors.active.boxShadow};
161
- ${'' /* ${colors.active.iconColor&&`${IconContainer} {
162
- background-color: ${colors.active.iconColor};
163
- }`} */}
164
- }`}
165
- `;
166
- }}
167
- ${props=>{
168
- let w = 40; // md
169
- if (props.size=='lg')
170
- w = 48;
171
- if (props.size=='sm')
172
- w = 36;
173
- if (props.size=='xs')
174
- w = 28;
175
- return css`height: ${toPixel(w)};`;
176
- }}
177
- `;
178
- StyledButton.displayName = 'StyledButton';
179
-
180
- export default Button;