@luminati-io/uikit 1.1.0 → 1.3.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 (89) 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 +6 -0
  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 +165 -0
  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 +3 -1
  84. package/src/icon.js +62 -0
  85. package/src/icon_button.js +75 -0
  86. package/src/index.js +3 -1
  87. package/src/infochip.js +8 -6
  88. package/src/utils.js +5 -0
  89. package/webpack.common.js +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminati-io/uikit",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "author": "Bright Data (http://brightdata.com)",
5
5
  "license": "ISC",
6
6
  "description": "brightdata's design system",
@@ -8,6 +8,7 @@
8
8
  "files": [
9
9
  "dist",
10
10
  "src",
11
+ "assets",
11
12
  "webpack.*.js"
12
13
  ],
13
14
  "dependencies": {
@@ -37,6 +38,7 @@
37
38
  "babel-loader": "9.1.2",
38
39
  "react": "^16.9.0",
39
40
  "react-dom": "^16.9.0",
41
+ "svg-sprite-loader": "^6.0.11",
40
42
  "webpack": "5.75.0",
41
43
  "webpack-cli": "5.0.1",
42
44
  "webpack-merge": "^5.8.0"
package/src/icon.js ADDED
@@ -0,0 +1,62 @@
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
+
8
+ import {theme, toPixel, colorNames, iconNames} from './utils';
9
+ import icons from '@icons';
10
+
11
+ const toIconSize = size=>{
12
+ const toSize = value=>css`
13
+ width: ${toPixel(value)};
14
+ height: ${toPixel(value)};
15
+ `;
16
+ if (size=='xl')
17
+ return toSize(48);
18
+ if (size=='lg')
19
+ return toSize(32);
20
+ if (size=='sm')
21
+ return toSize(20);
22
+ if (size=='xs')
23
+ return toSize(16);
24
+ if (size=='xxs')
25
+ return toSize(12);
26
+ return toSize(24);
27
+ };
28
+
29
+ const Icon = React.forwardRef((props, ref)=>{
30
+ const {name, size, color} = props;
31
+ const ic = icons[name];
32
+ if (!ic)
33
+ return null;
34
+ return <StyledSvg
35
+ ref={ref}
36
+ size={size}
37
+ viewBox={ic.viewBox}
38
+ color={theme.color[color]}
39
+ >
40
+ <use href={`#${ic.id}`}/>
41
+ </StyledSvg>;
42
+ });
43
+ Icon.displayName = 'Icon';
44
+ Icon.defaultProps = {size: 'md'};
45
+ Icon.propTypes = {
46
+ name: PT.oneOf(iconNames).isRequired,
47
+ color: PT.oneOf(colorNames),
48
+ size: PT.oneOf(['xxs', 'xs', 'sm', 'md', 'lg', 'xl']),
49
+ };
50
+
51
+ export const IconColorComp = styled.rect.attrs({
52
+ width: '100%',
53
+ height: '100%',
54
+ })``;
55
+
56
+ const StyledSvg = styled.svg`
57
+ color: ${props=>props.color};
58
+ ${props=>toIconSize(props.size)}
59
+ `;
60
+ StyledSvg.displayName = 'StyledSvg';
61
+
62
+ export default Icon;
@@ -0,0 +1,75 @@
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 Icon, {IconColorComp} from './icon';
9
+
10
+ const {theme, toPixel, getCommonProps, iconNames} = utils;
11
+
12
+ const IconButton = React.forwardRef((props, ref)=>{
13
+ const {variant: $variant, disabled, icon} = props;
14
+ const p = {...getCommonProps(props), disabled, $variant};
15
+ return <StyledIconButton ref={ref} {...p}>
16
+ <Icon name={icon} size="sm" />
17
+ </StyledIconButton>;
18
+ });
19
+ IconButton.displayName = 'IconButton';
20
+ IconButton.defaultProps = {variant: 'icon-button'};
21
+ IconButton.propTypes = {
22
+ variant: PT.oneOf(['icon', 'icon-button']),
23
+ icon: PT.oneOf(iconNames).isRequired,
24
+ disabled: PT.bool,
25
+ };
26
+
27
+ const StyledIconButton = styled.button`
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ border-radius: 4px;
32
+ padding: 0;
33
+ cursor: pointer;
34
+ ${props=>{
35
+ return css`
36
+ background-color: ${theme.color.white};
37
+ border: ${props.$variant=='icon'?'0 none;':
38
+ `1px solid ${theme.color.gray_6}`};
39
+ ${IconColorComp} {
40
+ fill: ${theme.color.gray_9};
41
+ }
42
+ `;
43
+ }}
44
+ &:hover:not(:disabled) {
45
+ background-color: ${theme.color.gray_2};
46
+ border: ${props=>props.$variant=='icon'?'0 none;':
47
+ `1px solid ${theme.color.gray_8}`};
48
+ }
49
+ &:active:not(:disabled) {
50
+ background-color: ${theme.color.blue_4};
51
+ border: ${props=>props.$variant=='icon'?'0 none;':
52
+ `1px solid ${theme.color.blue_4}`};
53
+ ${IconColorComp} {
54
+ fill: ${theme.color.blue_11};
55
+ }
56
+ }
57
+ &:disabled {
58
+ border: ${props=>props.$variant=='icon'?'0 none;':
59
+ `1px solid ${theme.color.gray_7}`};
60
+ ${IconColorComp} {
61
+ fill: ${theme.color.gray_7};
62
+ }
63
+ cursor: not-allowed;
64
+ }
65
+ ${props=>{
66
+ let w = props.$variant=='icon'?24:36;
67
+ return css`
68
+ width: ${toPixel(w)};
69
+ height: ${toPixel(w)};
70
+ `;
71
+ }}
72
+ `;
73
+ StyledIconButton.displayName = 'StyledIconButton';
74
+
75
+ export default IconButton;
package/src/index.js CHANGED
@@ -5,6 +5,8 @@ import typography from './Typography';
5
5
  import InfoChip from './infochip';
6
6
  import layout from './layout';
7
7
  import progress from './progress';
8
+ import Icon from './icon';
9
+ import IconButton from './icon_button';
8
10
 
9
11
  const {Header, Label, Hyperlink, Paragraph} = typography;
10
12
  const {Box, Flex} = layout;
@@ -15,6 +17,6 @@ export const Typography = {Header, Label, Hyperlink, Paragraph};
15
17
  const UIKit = {
16
18
  Layout,
17
19
  Typography,
18
- Button, InfoChip, Progress, ProgressBar,
20
+ Button, InfoChip, Progress, ProgressBar, Icon, IconButton,
19
21
  };
20
22
  export default UIKit;
package/src/infochip.js CHANGED
@@ -5,9 +5,10 @@ import React from 'react';
5
5
  import styled from 'styled-components';
6
6
  import PT from 'prop-types';
7
7
 
8
- import {theme} from './utils';
8
+ import {theme, iconNames, getCommonProps} from './utils';
9
9
  import Flex from './layout/flex';
10
10
  import typography from './Typography';
11
+ import Icon from './icon';
11
12
 
12
13
  const {Label} = typography;
13
14
 
@@ -23,14 +24,14 @@ const InfoChipWrapper = styled(Flex).attrs({
23
24
 
24
25
  const InfoChip = props=>{
25
26
  const {variant, text, icon} = props;
26
- const bg_colors = {
27
+ const bgColors = {
27
28
  default: 'gray_3',
28
29
  success: 'green_3',
29
30
  alert: 'red_3',
30
31
  warning: 'yellow_3',
31
32
  info: 'blue_3',
32
33
  };
33
- const bg_color = bg_colors[variant] || bg_colors.default;
34
+ const bgColor = bgColors[variant] || bgColors.default;
34
35
  const colors = {
35
36
  default: 'gray_11_50',
36
37
  success: 'green_11',
@@ -39,8 +40,9 @@ const InfoChip = props=>{
39
40
  info: 'blue_11',
40
41
  };
41
42
  const color = colors[variant] || colors.default;
42
- return <InfoChipWrapper color={bg_color}>
43
- {/* {icon && <Icon size="xxs" color={color} name={icon}/>} */}
43
+ const commonProps = getCommonProps(props);
44
+ return <InfoChipWrapper color={bgColor} {...commonProps}>
45
+ {icon && <Icon size="xxs" color={color} name={icon}/>}
44
46
  <Label variant="xs" color={color}>{text}</Label>
45
47
  </InfoChipWrapper>;
46
48
  };
@@ -49,7 +51,7 @@ InfoChip.defaultProps = {variant: 'default'};
49
51
  InfoChip.propTypes = {
50
52
  variant: PT.oneOf(['default', 'success', 'alert', 'warning', 'info']),
51
53
  text: PT.string,
52
- icon: PT.string,
54
+ icon: PT.oneOf(iconNames),
53
55
  };
54
56
 
55
57
  export default InfoChip;
package/src/utils.js CHANGED
@@ -2,6 +2,7 @@
2
2
  'use strict'; /*jslint react:true*/
3
3
 
4
4
  import _ from 'lodash';
5
+ import icons from '@icons';
5
6
 
6
7
  export const theme = {
7
8
  color: {
@@ -93,6 +94,10 @@ export const theme = {
93
94
  }
94
95
  };
95
96
 
97
+ export const colorNames = Object.keys(theme.color);
98
+
99
+ export const iconNames = Object.keys(icons);
100
+
96
101
  export const toPixel = value=>`${value}px`;
97
102
 
98
103
  export const getCommonProps = props=>_.pickBy(props, (v, k)=>{
package/webpack.common.js CHANGED
@@ -1,6 +1,12 @@
1
1
  // LICENSE_CODE ZON
2
2
  'use strict'; /*jslint node:true*/
3
3
 
4
+ const path = require('path');
5
+
6
+ const alias = {
7
+ '@icons': path.resolve(__dirname, 'assets/icons'),
8
+ };
9
+
4
10
  const common = {
5
11
  module: {
6
12
  rules: [
@@ -8,9 +14,14 @@ const common = {
8
14
  test: /src[\\/].+\.js$/,
9
15
  exclude: /node_modules/,
10
16
  use: ['babel-loader'],
17
+ },
18
+ {
19
+ test: /\.svg$/,
20
+ loader: 'svg-sprite-loader',
11
21
  }
12
22
  ]
13
23
  },
24
+ resolve: {alias},
14
25
  };
15
26
 
16
27
  module.exports = common;