@luminati-io/uikit 1.4.0 → 1.6.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 (44) hide show
  1. package/assets/fonts/Inter-Regular.ttf +0 -0
  2. package/assets/fonts/Inter-SemiBold.ttf +0 -0
  3. package/assets/icons/account.svg +1 -8
  4. package/assets/icons/adapt.svg +1 -4
  5. package/assets/icons/add.svg +1 -3
  6. package/assets/icons/add_circle.svg +1 -5
  7. package/assets/icons/add_funds.svg +1 -7
  8. package/assets/icons/attach.svg +1 -3
  9. package/assets/icons/book_help.svg +1 -4
  10. package/assets/icons/building.svg +1 -3
  11. package/assets/icons/calendar.svg +1 -13
  12. package/assets/icons/calendar_graph.svg +1 -14
  13. package/assets/icons/call.svg +1 -5
  14. package/assets/icons/camera.svg +1 -5
  15. package/assets/icons/cart.svg +1 -3
  16. package/assets/icons/close.svg +1 -3
  17. package/assets/icons/close_circle.svg +1 -3
  18. package/assets/icons/close_small.svg +1 -5
  19. package/assets/icons/collapse.svg +1 -4
  20. package/assets/icons/column.svg +1 -22
  21. package/assets/icons/columns.svg +1 -10
  22. package/assets/icons/connect.svg +1 -3
  23. package/assets/icons/contact_support.svg +1 -3
  24. package/assets/icons/copy.svg +1 -3
  25. package/assets/icons/copy_small.svg +1 -3
  26. package/assets/icons/customize.svg +1 -6
  27. package/dist/uikit.umd.js +1 -1
  28. package/dist/uikit.umd.js.LICENSE.txt +9 -0
  29. package/package.json +3 -1
  30. package/src/button/button.js +2 -2
  31. package/src/code/code.js +127 -0
  32. package/src/code/index.js +8 -0
  33. package/src/icon.js +1 -1
  34. package/src/icon_button.js +25 -21
  35. package/src/index.js +9 -0
  36. package/src/input/index.js +6 -0
  37. package/src/input/toggle.js +105 -0
  38. package/src/layout/flex.js +19 -1
  39. package/src/link/index.js +6 -0
  40. package/src/link/link.js +77 -0
  41. package/src/tooltip.js +5 -2
  42. package/src/utils.js +9 -5
  43. package/webpack.common.js +2 -4
  44. package/webpack.shared.js +11 -0
@@ -7,6 +7,15 @@
7
7
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8
8
  */
9
9
 
10
+ /**
11
+ * Prism: Lightweight, robust, elegant syntax highlighting
12
+ *
13
+ * @license MIT <https://opensource.org/licenses/MIT>
14
+ * @author Lea Verou <https://lea.verou.me>
15
+ * @namespace
16
+ * @public
17
+ */
18
+
10
19
  /** @license React v16.13.1
11
20
  * react-is.production.min.js
12
21
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminati-io/uikit",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "author": "Bright Data (http://brightdata.com)",
5
5
  "license": "ISC",
6
6
  "description": "brightdata's design system",
@@ -13,7 +13,9 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "@popperjs/core": "^2.11.6",
16
+ "babel-plugin-prismjs": "^2.1.0",
16
17
  "lodash": "^4.17.21",
18
+ "prismjs": "^1.29.0",
17
19
  "prop-types": "^15.8.1",
18
20
  "react-popper": "^2.3.0",
19
21
  "styled-components": "^5.3.6"
@@ -8,7 +8,6 @@ import {
8
8
  iconNames,
9
9
  toPixel,
10
10
  toButtonSize,
11
- getCommonProps,
12
11
  getButtonColors,
13
12
  getIconProps,
14
13
  } from '../utils';
@@ -26,12 +25,13 @@ const Button = React.forwardRef((props, ref)=>{
26
25
  disabled,
27
26
  loading,
28
27
  loadingText,
28
+ ...rest
29
29
  } = props;
30
30
  const {isLeft, isRight, ...iconProps} = getIconProps('Button', props);
31
31
  return <StyledButton
32
32
  ref={ref}
33
33
  type="button"
34
- {...getCommonProps(props)}
34
+ {...rest}
35
35
  variant={variant}
36
36
  size={size}
37
37
  disabled={loading||disabled}
@@ -0,0 +1,127 @@
1
+ // LICENSE_CODE ZON
2
+ 'use strict'; /*jslint react:true*/
3
+
4
+ import React, {useEffect} from 'react';
5
+ import styled from 'styled-components';
6
+ import Prism from 'prismjs';
7
+ import PT from 'prop-types';
8
+ import {theme} from '../utils';
9
+
10
+ const Code = props=>{
11
+ const {text, lang} = props;
12
+ useEffect(()=>{
13
+ Prism.highlightAll();
14
+ }, [text, lang]);
15
+ return <CodeWrapper>
16
+ <code className={`language-${lang} content`}>{text}</code>
17
+ </CodeWrapper>;
18
+ };
19
+ Code.displayName = 'Code';
20
+ Code.propTypes = {
21
+ text: PT.string,
22
+ // XXX davidg: config langs
23
+ lang: PT.string,
24
+ };
25
+
26
+ export default Code;
27
+
28
+ const CodeWrapper = styled.pre`
29
+ &&& {
30
+ padding: 0;
31
+ font-family: ${theme.font_family.mono};
32
+ margin: 0;
33
+ border: none;
34
+ background-color: transparent;
35
+ width: 100%;
36
+ white-space: pre-wrap;
37
+ line-height: 1.5;
38
+ tab-size: 4;
39
+ text-align: left;
40
+ word-spacing: normal;
41
+ word-break: normal;
42
+ word-wrap: normal;
43
+ hyphens: none;
44
+ max-height: none;
45
+ code.content {
46
+ all: inherit;
47
+ color: ${theme.color.gray_8};
48
+ margin: 0;
49
+ padding: 0;
50
+ border: none;
51
+ background-color: transparent;
52
+ text-shadow: none;
53
+ }
54
+ ${'' /* prism selectors below */}
55
+ .token.comment,
56
+ .token.prolog,
57
+ .token.doctype,
58
+ .token.cdata {
59
+ color: slategray;
60
+ }
61
+
62
+ .token.punctuation {
63
+ color: #999;
64
+ }
65
+
66
+ .token.namespace {
67
+ opacity: .7;
68
+ }
69
+
70
+ .token.property,
71
+ .token.tag,
72
+ .token.boolean,
73
+ .token.constant,
74
+ .token.symbol,
75
+ .token.deleted {
76
+ color: #f8c555;
77
+ }
78
+
79
+ .token.selector,
80
+ .token.attr-name,
81
+ .token.string,
82
+ .token.char,
83
+ .token.builtin,
84
+ .token.inserted {
85
+ color: #7ec699;
86
+ }
87
+
88
+ .token.operator,
89
+ .token.entity,
90
+ .token.url,
91
+ .language-css .token.string,
92
+ .style .token.string {
93
+ color: #67cdcc;
94
+ }
95
+
96
+ .token.atrule,
97
+ .token.attr-value,
98
+ .token.keyword {
99
+ color: #cc99cd;
100
+ }
101
+
102
+ .token.function,
103
+ .token.number,
104
+ .token.class-name {
105
+ color: #f08d49;
106
+ }
107
+
108
+ .token.regex,
109
+ .token.important,
110
+ .token.variable {
111
+ color: #e90;
112
+ }
113
+
114
+ .token.important,
115
+ .token.bold {
116
+ font-weight: bold;
117
+ }
118
+ .token.italic {
119
+ font-style: italic;
120
+ }
121
+
122
+ .token.entity {
123
+ cursor: help;
124
+ }
125
+ }
126
+ `;
127
+ CodeWrapper.displayName = 'CodeWrapper';
@@ -0,0 +1,8 @@
1
+ // LICENSE_CODE ZON
2
+ 'use strict'; /*jslint react:true*/
3
+
4
+ import Code from './code';
5
+
6
+ export {Code};
7
+
8
+ export default {Code};
package/src/icon.js CHANGED
@@ -49,7 +49,7 @@ Icon.propTypes = {
49
49
  size: PT.oneOf(['xxs', 'xs', 'sm', 'md', 'lg', 'xl']),
50
50
  };
51
51
 
52
- export const StyledSvg = styled.svg`
52
+ const StyledSvg = styled.svg`
53
53
  color: ${props=>props.color};
54
54
  ${props=>toIconSize(props.size)}
55
55
  `;
@@ -5,16 +5,24 @@ import React from 'react';
5
5
  import styled, {css} from 'styled-components';
6
6
  import PT from 'prop-types';
7
7
  import utils from './utils';
8
- import Icon, {StyledSvg as IconSvg} from './icon';
8
+ import Icon from './icon';
9
+ import Tooltip from './tooltip';
9
10
 
10
- const {theme, toPixel, getCommonProps, iconNames} = utils;
11
+ const {theme, toPixel, getCommonProps, iconNames, tooltipPlacements} = utils;
11
12
 
12
13
  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} data-testid="icon_button">
16
- <Icon name={icon} size="sm" />
17
- </StyledIconButton>;
14
+ const {variant, disabled, icon, tooltip, tooltipPlacement} = props;
15
+ return <Tooltip tooltip={tooltip} placement={tooltipPlacement}>
16
+ <StyledIconButton
17
+ ref={ref}
18
+ {...getCommonProps(props)}
19
+ variant={variant}
20
+ disabled={disabled}
21
+ data-testid="icon_button"
22
+ >
23
+ <Icon name={icon} size="sm" />
24
+ </StyledIconButton>
25
+ </Tooltip>;
18
26
  });
19
27
  IconButton.displayName = 'IconButton';
20
28
  IconButton.defaultProps = {variant: 'icon-button'};
@@ -22,6 +30,8 @@ IconButton.propTypes = {
22
30
  variant: PT.oneOf(['icon', 'icon-button']),
23
31
  icon: PT.oneOf(iconNames).isRequired,
24
32
  disabled: PT.bool,
33
+ tooltip: PT.node,
34
+ tooltipPlacement: PT.oneOf(tooltipPlacements),
25
35
  };
26
36
 
27
37
  const StyledIconButton = styled.button`
@@ -34,36 +44,30 @@ const StyledIconButton = styled.button`
34
44
  ${props=>{
35
45
  return css`
36
46
  background-color: ${theme.color.white};
37
- border: ${props.$variant=='icon'?'0 none;':
47
+ border: ${props.variant=='icon'?'0 none;':
38
48
  `1px solid ${theme.color.gray_6}`};
39
- ${IconSvg} {
40
- color: ${theme.color.gray_9};
41
- }
49
+ [data-icon] { color: ${theme.color.gray_9}; }
42
50
  `;
43
51
  }}
44
52
  &:hover:not(:disabled) {
45
53
  background-color: ${theme.color.gray_2};
46
- border: ${props=>props.$variant=='icon'?'0 none;':
54
+ border: ${props=>props.variant=='icon'?'0 none;':
47
55
  `1px solid ${theme.color.gray_8}`};
48
56
  }
49
57
  &:active:not(:disabled) {
50
58
  background-color: ${theme.color.blue_4};
51
- border: ${props=>props.$variant=='icon'?'0 none;':
59
+ border: ${props=>props.variant=='icon'?'0 none;':
52
60
  `1px solid ${theme.color.blue_4}`};
53
- ${IconSvg} {
54
- color: ${theme.color.blue_11};
55
- }
61
+ [data-icon] { color: ${theme.color.blue_11}; }
56
62
  }
57
63
  &:disabled {
58
- border: ${props=>props.$variant=='icon'?'0 none;':
64
+ border: ${props=>props.variant=='icon'?'0 none;':
59
65
  `1px solid ${theme.color.gray_7}`};
60
- ${IconSvg} {
61
- color: ${theme.color.gray_7};
62
- }
66
+ [data-icon] { color: ${theme.color.gray_7}; }
63
67
  cursor: not-allowed;
64
68
  }
65
69
  ${props=>{
66
- let w = props.$variant=='icon'?24:36;
70
+ let w = props.variant=='icon'?24:36;
67
71
  return css`
68
72
  width: ${toPixel(w)};
69
73
  height: ${toPixel(w)};
package/src/index.js CHANGED
@@ -1,18 +1,23 @@
1
1
  // LICENSE_CODE ZON
2
2
  'use strict'; /*jslint react:true*/
3
3
  import {Button} from './button';
4
+ import Input from './input';
4
5
  import Typography from './Typography';
5
6
  import InfoChip from './infochip';
6
7
  import Layout from './layout';
8
+ import {Link} from './link';
7
9
  import {Progress, ProgressBar} from './progress';
8
10
  import Icon from './icon';
9
11
  import IconButton from './icon_button';
10
12
  import Tooltip, {withTooltip} from './tooltip';
13
+ import {Code} from './code';
11
14
 
12
15
  export {
13
16
  Layout,
17
+ Link,
14
18
  Typography,
15
19
  Button,
20
+ Input,
16
21
  InfoChip,
17
22
  Progress,
18
23
  ProgressBar,
@@ -20,12 +25,15 @@ export {
20
25
  IconButton,
21
26
  Tooltip,
22
27
  withTooltip,
28
+ Code,
23
29
  };
24
30
 
25
31
  const UIKit = {
26
32
  Layout,
33
+ Link,
27
34
  Typography,
28
35
  Button,
36
+ Input,
29
37
  InfoChip,
30
38
  Progress,
31
39
  ProgressBar,
@@ -33,6 +41,7 @@ const UIKit = {
33
41
  IconButton,
34
42
  Tooltip,
35
43
  withTooltip,
44
+ Code,
36
45
  };
37
46
 
38
47
  export default UIKit;
@@ -0,0 +1,6 @@
1
+ // LICENSE_CODE ZON
2
+ 'use strict'; /*jslint react:true*/
3
+
4
+ import Toggle from './toggle';
5
+
6
+ export default {Toggle};
@@ -0,0 +1,105 @@
1
+ // LICENSE_CODE ZON
2
+ 'use strict'; /*jslint react:true*/
3
+
4
+ import React, {useCallback} from 'react';
5
+ import styled from 'styled-components';
6
+ import PT from 'prop-types';
7
+ import {theme, toPixel, getCommonProps} from '../utils';
8
+ import typography from '../Typography';
9
+
10
+ const {Label} = typography;
11
+
12
+ const Toggle = props=>{
13
+ const {value, label, disabled, size, onChange} = props;
14
+ const handleChange = useCallback(evt=>{
15
+ const {checked} = evt.target;
16
+ onChange?.(checked, evt);
17
+ }, [onChange]);
18
+ const color = disabled?value?'gray-11':'gray-9':
19
+ value?'gray-11-50':'gray-11';
20
+ return <ToggleLabel {...getCommonProps(props)} $size={size}>
21
+ <ToggleInput $size={size} checked={value} onChange={handleChange}
22
+ disabled={disabled} />
23
+ {label&&<Label variant="sm" tag="span" color={color} no_wrap>
24
+ {label}
25
+ </Label>}
26
+ </ToggleLabel>;
27
+ };
28
+ Toggle.displayName = 'Toggle';
29
+ Toggle.defaultProps = {size: 'sm'};
30
+ Toggle.propTypes = {
31
+ value: PT.bool,
32
+ label: PT.string,
33
+ disabled: PT.bool,
34
+ size: PT.oneOf(['xs', 'sm']),
35
+ onChange: PT.func,
36
+ };
37
+
38
+ const ToggleLabel = styled.label`
39
+ cursor: pointer;
40
+ display: flex;
41
+ align-items: center;
42
+ gap: 4px;
43
+ margin: 0;
44
+ `;
45
+ ToggleLabel.displayName = 'ToggleLabel';
46
+
47
+ const ToggleInput = styled.input.attrs({type: 'checkbox'})`
48
+ && {
49
+ box-sizing: border-box;
50
+ width: ${props=>toPixel(props.$size=='xs'?32:44)};
51
+ height: ${props=>toPixel(props.$size=='xs'?16:20)};
52
+ display: flex;
53
+ align-items: center;
54
+ margin: 0;
55
+ padding: 0 1px;
56
+ vertical-align: top;
57
+ background-color: ${theme.color.gray_5};
58
+ border: 1px solid ${theme.color.gray_7};
59
+ border-radius: 25px;
60
+ outline: none;
61
+ outline-offset: 0;
62
+ cursor: pointer;
63
+ appearance: none;
64
+ transition: all 0.3s cubic-bezier(0.2, 0.85, 0.32, 1.2);
65
+ &:hover {
66
+ background-color: ${theme.color.gray_7};
67
+ border-color: ${theme.color.gray_8};
68
+ }
69
+ &:focus {
70
+ outline: none;
71
+ outline-offset: 0;
72
+ background-color: ${theme.color.gray_9};
73
+ border-color: ${theme.color.gray_9};
74
+ }
75
+ &:checked {
76
+ background-color: ${theme.color.blue_11};
77
+ border-color: ${theme.color.blue_11};
78
+ &:hover {
79
+ background-color: ${theme.color.blue_10};
80
+ border-color: ${theme.color.blue_10};
81
+ }
82
+ &:focus {
83
+ background-color: ${theme.color.blue_11};
84
+ border-color: ${theme.color.blue_11};
85
+ outline: 3px solid ${theme.color.blue_5};
86
+ }
87
+ }
88
+ }
89
+ &::after {
90
+ content: "";
91
+ display: block;
92
+ width: ${props=>toPixel(props.$size=='xs'?12:16)};
93
+ height: ${props=>toPixel(props.$size=='xs'?12:16)};
94
+ border-radius: 50%;
95
+ background-color: ${theme.color.white};
96
+ box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
97
+ transition: all 0.3s cubic-bezier(0.2, 0.85, 0.32, 1.2);
98
+ }
99
+ &:checked::after {
100
+ transform: translateX(${props=>toPixel(props.$size=='xs'?15:23)});
101
+ }
102
+ `;
103
+ ToggleInput.displayName = 'ToggleInput';
104
+
105
+ export default Toggle;
@@ -1,11 +1,13 @@
1
1
  // LICENSE_CODE ZON
2
2
  'use strict'; /*jslint react:true*/
3
3
 
4
+ import React from 'react';
4
5
  import styled from 'styled-components';
6
+ import PT from 'prop-types';
5
7
 
6
8
  import Box from './box';
7
9
 
8
- const Flex = styled(Box)`
10
+ const StyledFlex = styled(Box)`
9
11
  display: ${props=>props.inline ? 'inline-flex' : 'flex'};
10
12
  align-items: ${props=>props.align_items};
11
13
  align-content: ${props=>props.align_content};
@@ -17,7 +19,23 @@ const Flex = styled(Box)`
17
19
  row-gap: ${props=>props.row_gap};
18
20
  column-gap: ${props=>props.column_gap};
19
21
  `;
22
+ const Flex = props=>{
23
+ return <StyledFlex {...props}/>;
24
+ };
20
25
  Flex.displayName = 'Flex';
21
26
  Flex.defaultProps = {flex_direction: 'row'};
27
+ Flex.propTypes = {
28
+ inline: PT.bool,
29
+ align_items: PT.oneOf(['flex-start', 'center']),
30
+ align_content: PT.string,
31
+ justify_items: PT.string,
32
+ justify_content: PT.string,
33
+ flex_wrap: PT.string,
34
+ flex_direction: PT.oneOf(['row', 'row-reverse', 'column',
35
+ 'column-reverse']),
36
+ gap: PT.string,
37
+ row_gap: PT.string,
38
+ column_gap: PT.string,
39
+ };
22
40
 
23
41
  export default Flex;
@@ -0,0 +1,6 @@
1
+ // LICENSE_CODE ZON
2
+ 'use strict'; /*jslint react:true*/
3
+
4
+ import Link from './link';
5
+
6
+ export {Link};
@@ -0,0 +1,77 @@
1
+ // LICENSE_CODE ZON
2
+ 'use strict'; /*jslint react:true*/
3
+
4
+ import React from 'react';
5
+ import styled from 'styled-components';
6
+ import PT from 'prop-types';
7
+ import {theme, iconNames, toPixel, getIconProps, getLinkProps} from '../utils';
8
+ import typography from '../Typography';
9
+ import Icon from '../icon';
10
+
11
+ const {Typography, Label} = typography;
12
+
13
+ const Link = React.forwardRef((props, ref)=>{
14
+ const {text, variant, size, icon, ...rest} = props;
15
+ const {isLeft, isRight, ...iconProps} = getIconProps('Link', props);
16
+ const labelVariant = {lg: 'lg', sm: 'xs'}[size]||'base';
17
+ return <StyledLink
18
+ ref={ref}
19
+ {...rest}
20
+ {...getLinkProps(props)}
21
+ variant={variant}
22
+ size={size}
23
+ noIcon={!icon}
24
+ >
25
+ {isLeft&&<Icon {...iconProps}/>}
26
+ <Label variant={labelVariant} no_wrap>{text}</Label>
27
+ {isRight&&<Icon {...iconProps}/>}
28
+ </StyledLink>;
29
+ });
30
+ Link.displayName = 'Link';
31
+ Link.defaultProps = {
32
+ variant: 'primary',
33
+ size: 'md',
34
+ iconPlacement: 'left',
35
+ };
36
+ Link.propTypes = {
37
+ text: PT.string.isRequired,
38
+ variant: PT.oneOf(['primary', 'secondary']),
39
+ size: PT.oneOf(['sm', 'md', 'lg']),
40
+ icon: PT.oneOf(iconNames),
41
+ iconPlacement: PT.oneOf(['left', 'right']),
42
+ href: PT.string,
43
+ newTab: PT.bool,
44
+ };
45
+
46
+ const StyledLink = styled.a`
47
+ display: inline-flex;
48
+ align-items: center;
49
+ justify-content: center;
50
+ text-decoration: none;
51
+ background: 0 none;
52
+ border: 0 none;
53
+ padding: 0;
54
+ gap: ${props=>toPixel(props.size=='lg'?8:4)};
55
+ ${Typography} {
56
+ color: ${props=>props.variant=='primary'?
57
+ theme.color.blue_11:theme.color.gray_11_50};
58
+ text-decoration: ${props=>props.variant=='secondary'&&
59
+ props.noIcon?'underline':'none'};
60
+ }
61
+ [data-icon] {
62
+ color: ${props=>props.variant=='primary'?
63
+ theme.color.blue_11:theme.color.gray_11_50};
64
+ }
65
+ &:hover {
66
+ ${Typography} {
67
+ color: ${theme.color.blue_11};
68
+ text-decoration: ${props=>props.variant=='secondary'&&
69
+ props.noIcon?'underline':'none'};
70
+ }
71
+ [data-icon] { color: ${theme.color.blue_11}; }
72
+ }
73
+ &:hover, :visited, :focus { text-decoration: none; }
74
+ `;
75
+ StyledLink.displayName = 'StyledLink';
76
+
77
+ export default Link;
package/src/tooltip.js CHANGED
@@ -5,7 +5,7 @@ import React, {useCallback, useState} from 'react';
5
5
  import {usePopper} from 'react-popper';
6
6
  import styled from 'styled-components';
7
7
  import PT from 'prop-types';
8
- import {theme} from './utils';
8
+ import {theme, tooltipPlacements} from './utils';
9
9
  import typography from './Typography';
10
10
 
11
11
  const {Label} = typography;
@@ -26,6 +26,8 @@ const Tooltip = props=>{
26
26
  {name: 'offset', options: {offset: [0, 8]}},
27
27
  ],
28
28
  });
29
+ if (!tooltip)
30
+ return children;
29
31
  return <>
30
32
  <StyledTooltipReference ref={setReferenceElement}
31
33
  onMouseEnter={show} onMouseLeave={hide}>
@@ -39,9 +41,10 @@ const Tooltip = props=>{
39
41
  </StyledTooltipBody>
40
42
  </>;
41
43
  };
44
+ Tooltip.defaultProps = {placement: 'top'};
42
45
  Tooltip.propTypes = {
43
46
  tooltip: PT.node,
44
- placement: PT.oneOf(['auto', 'top', 'right', 'bottom', 'left']),
47
+ placement: PT.oneOf(tooltipPlacements),
45
48
  };
46
49
 
47
50
  export const withTooltip = (Comp, tooltipProps)=>function WithTooltip(props){
package/src/utils.js CHANGED
@@ -149,10 +149,8 @@ export const getIconProps = (comp, opt)=>{
149
149
  };
150
150
 
151
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};
152
+ const {as, href, newTab} = opt;
153
+ let p = {as, href};
156
154
  if (newTab)
157
155
  p = {...p, target: '_blank', rel: 'noopener noreferrer'};
158
156
  return p;
@@ -262,5 +260,11 @@ export const toButtonSize = size=>{
262
260
  return css`height: ${toPixel(w)};`;
263
261
  };
264
262
 
263
+ export const tooltipPlacements = (()=>{
264
+ const positions = ['auto', 'top', 'right', 'bottom', 'left'];
265
+ const variants = ['', '-start', '-end'];
266
+ return positions.flatMap(p=>variants.map(v=>p+v));
267
+ })();
268
+
265
269
  export default {theme, toPixel, getCommonProps, getTypographyProps, fromTheme,
266
- colorNames, iconNames};
270
+ colorNames, iconNames, tooltipPlacements};
package/webpack.common.js CHANGED
@@ -2,6 +2,7 @@
2
2
  'use strict'; /*jslint node:true*/
3
3
 
4
4
  const path = require('path');
5
+ const {svgRule} = require('./webpack.shared.js');
5
6
 
6
7
  const alias = {
7
8
  '@icons': path.resolve(__dirname, 'assets/icons'),
@@ -15,10 +16,7 @@ const common = {
15
16
  exclude: /node_modules/,
16
17
  use: ['babel-loader'],
17
18
  },
18
- {
19
- test: /\.svg$/,
20
- loader: 'svg-sprite-loader',
21
- }
19
+ svgRule,
22
20
  ]
23
21
  },
24
22
  resolve: {alias},
@@ -0,0 +1,11 @@
1
+ // LICENSE_CODE ZON
2
+ 'use strict'; /*jslint node:true, es9:true*/
3
+
4
+ const svgRule = {
5
+ test: /\.svg$/,
6
+ loader: 'svg-sprite-loader',
7
+ };
8
+
9
+ module.exports = {
10
+ svgRule,
11
+ };