@luminati-io/uikit 1.3.0 → 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.
- package/assets/icons/maximize.svg +1 -1
- package/dist/uikit.umd.js +1 -1
- package/package.json +6 -3
- package/src/button/button.js +121 -0
- package/src/button/index.js +6 -0
- package/src/button/loading_icon.js +46 -0
- package/src/icon.js +2 -6
- package/src/icon_button.js +8 -8
- package/src/index.js +26 -10
- package/src/progress/index.js +1 -1
- package/src/tooltip.js +96 -0
- package/src/utils.js +131 -1
- package/src/button.js +0 -180
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luminati-io/uikit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"author": "Bright Data (http://brightdata.com)",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "brightdata's design system",
|
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
"webpack.*.js"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"
|
|
15
|
+
"@popperjs/core": "^2.11.6",
|
|
16
|
+
"lodash": "^4.17.21",
|
|
16
17
|
"prop-types": "^15.8.1",
|
|
17
|
-
"
|
|
18
|
+
"react-popper": "^2.3.0",
|
|
19
|
+
"styled-components": "^5.3.6"
|
|
18
20
|
},
|
|
19
21
|
"peerDependencies": {
|
|
20
22
|
"react": ">=16.9.0",
|
|
@@ -30,6 +32,7 @@
|
|
|
30
32
|
"@storybook/addon-links": "^6.5.15",
|
|
31
33
|
"@storybook/builder-webpack4": "^6.5.15",
|
|
32
34
|
"@storybook/builder-webpack5": "^6.5.15",
|
|
35
|
+
"@storybook/jest": "0.0.10",
|
|
33
36
|
"@storybook/manager-webpack4": "^6.5.15",
|
|
34
37
|
"@storybook/manager-webpack5": "^6.5.15",
|
|
35
38
|
"@storybook/react": "^6.5.15",
|
|
@@ -0,0 +1,121 @@
|
|
|
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 {
|
|
8
|
+
iconNames,
|
|
9
|
+
toPixel,
|
|
10
|
+
toButtonSize,
|
|
11
|
+
getCommonProps,
|
|
12
|
+
getButtonColors,
|
|
13
|
+
getIconProps,
|
|
14
|
+
} from '../utils';
|
|
15
|
+
import typography from '../Typography';
|
|
16
|
+
import Icon from '../icon';
|
|
17
|
+
import LoadingIcon from './loading_icon';
|
|
18
|
+
|
|
19
|
+
const {Typography, Label} = typography;
|
|
20
|
+
|
|
21
|
+
const Button = React.forwardRef((props, ref)=>{
|
|
22
|
+
const {
|
|
23
|
+
text,
|
|
24
|
+
variant,
|
|
25
|
+
size,
|
|
26
|
+
disabled,
|
|
27
|
+
loading,
|
|
28
|
+
loadingText,
|
|
29
|
+
} = props;
|
|
30
|
+
const {isLeft, isRight, ...iconProps} = getIconProps('Button', props);
|
|
31
|
+
return <StyledButton
|
|
32
|
+
ref={ref}
|
|
33
|
+
type="button"
|
|
34
|
+
{...getCommonProps(props)}
|
|
35
|
+
variant={variant}
|
|
36
|
+
size={size}
|
|
37
|
+
disabled={loading||disabled}
|
|
38
|
+
iconPlacement={isLeft||loading?'left':isRight?'right':''}
|
|
39
|
+
>
|
|
40
|
+
{loading&&<LoadingIcon size={iconProps.size}/>}
|
|
41
|
+
{isLeft&&!loading&&<Icon {...iconProps}/>}
|
|
42
|
+
<Label variant={size=='xs'?'sm':'lg'} no_wrap>
|
|
43
|
+
{loading?loadingText:text}
|
|
44
|
+
</Label>
|
|
45
|
+
{isRight&&!loading&&<Icon {...iconProps}/>}
|
|
46
|
+
</StyledButton>;
|
|
47
|
+
});
|
|
48
|
+
Button.displayName = 'Button';
|
|
49
|
+
Button.defaultProps = {
|
|
50
|
+
variant: 'primary',
|
|
51
|
+
size: 'md',
|
|
52
|
+
iconPlacement: 'left',
|
|
53
|
+
loadingText: 'Loading...',
|
|
54
|
+
};
|
|
55
|
+
Button.propTypes = {
|
|
56
|
+
text: PT.string.isRequired,
|
|
57
|
+
variant: PT.oneOf(['primary', 'secondary', 'negative',
|
|
58
|
+
'negative_secondary', 'positive', 'white']),
|
|
59
|
+
size: PT.oneOf(['xs', 'sm', 'md', 'lg']),
|
|
60
|
+
icon: PT.oneOf(iconNames),
|
|
61
|
+
iconPlacement: PT.oneOf(['left', 'right']),
|
|
62
|
+
disabled: PT.bool,
|
|
63
|
+
loading: PT.bool,
|
|
64
|
+
loadingText: PT.string,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const StyledButton = styled.button`
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
border-radius: 4px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
&:disabled { cursor: not-allowed; }
|
|
74
|
+
text-decoration: none;
|
|
75
|
+
&:hover, &:visited, :focus { text-decoration: none; }
|
|
76
|
+
${props=>{
|
|
77
|
+
let gap = 4;
|
|
78
|
+
let paddingLeft = 16;
|
|
79
|
+
let paddingRight = 16;
|
|
80
|
+
if (props.iconPlacement=='left')
|
|
81
|
+
paddingLeft = 12;
|
|
82
|
+
else if (props.iconPlacement=='right')
|
|
83
|
+
paddingRight = 12;
|
|
84
|
+
if (props.size=='xs')
|
|
85
|
+
{
|
|
86
|
+
gap = 2;
|
|
87
|
+
paddingLeft = paddingRight = 8;
|
|
88
|
+
}
|
|
89
|
+
return css`
|
|
90
|
+
gap: ${toPixel(gap)};
|
|
91
|
+
padding-left: ${toPixel(paddingLeft)};
|
|
92
|
+
padding-right: ${toPixel(paddingRight)};
|
|
93
|
+
`;
|
|
94
|
+
}}
|
|
95
|
+
${props=>{
|
|
96
|
+
const colors = getButtonColors(props);
|
|
97
|
+
return css`
|
|
98
|
+
background-color: ${colors.backColor};
|
|
99
|
+
border: ${colors.border||'0 none'};
|
|
100
|
+
${Typography} { color: ${colors.color}; }
|
|
101
|
+
[data-icon] {
|
|
102
|
+
color: ${colors.iconColor||colors.color};
|
|
103
|
+
}
|
|
104
|
+
${colors.hover&&`&:hover {
|
|
105
|
+
background-color: ${colors.hover.backColor};
|
|
106
|
+
}`}
|
|
107
|
+
${colors.active&&`&:active {
|
|
108
|
+
background-color: ${colors.active.backColor};
|
|
109
|
+
border: ${colors.active.border};
|
|
110
|
+
box-shadow: ${colors.active.boxShadow};
|
|
111
|
+
${colors.active.iconColor&&`[data-icon] {
|
|
112
|
+
color: ${colors.active.iconColor};
|
|
113
|
+
}`}
|
|
114
|
+
}`}
|
|
115
|
+
`;
|
|
116
|
+
}}
|
|
117
|
+
${props=>toButtonSize(props.size)}
|
|
118
|
+
`;
|
|
119
|
+
StyledButton.displayName = 'StyledButton';
|
|
120
|
+
|
|
121
|
+
export default Button;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// LICENSE_CODE ZON
|
|
2
|
+
'use strict'; /*jslint react:true*/
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import {toIconSize} from '../utils';
|
|
7
|
+
|
|
8
|
+
const LoadingIcon = props=>
|
|
9
|
+
<Spinner stroke="rgba(0,106,220,1)" viewBox="0 0 24 24" {...props}>
|
|
10
|
+
<g className="spinner_V8m1">
|
|
11
|
+
<circle cx="12" cy="12" r="9.5" fill="none" strokeWidth="3"/>
|
|
12
|
+
</g>
|
|
13
|
+
</Spinner>;
|
|
14
|
+
|
|
15
|
+
const Spinner = styled.svg`
|
|
16
|
+
${props=>toIconSize(props.size)}
|
|
17
|
+
.spinner_V8m1 {
|
|
18
|
+
transform-origin: center;
|
|
19
|
+
animation: spinner_zKoa 2s linear infinite
|
|
20
|
+
}
|
|
21
|
+
.spinner_V8m1 circle {
|
|
22
|
+
stroke-linecap: round;
|
|
23
|
+
animation: spinner_YpZS 1.5s ease-in-out infinite
|
|
24
|
+
}
|
|
25
|
+
@keyframes spinner_zKoa {
|
|
26
|
+
100% {
|
|
27
|
+
transform: rotate(360deg)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
@keyframes spinner_YpZS {
|
|
31
|
+
0% {
|
|
32
|
+
stroke-dasharray: 0 150;
|
|
33
|
+
stroke-dashoffset: 0
|
|
34
|
+
}
|
|
35
|
+
47.5% {
|
|
36
|
+
stroke-dasharray: 42 150;
|
|
37
|
+
stroke-dashoffset: -16
|
|
38
|
+
}
|
|
39
|
+
95%, 100% {
|
|
40
|
+
stroke-dasharray: 42 150;
|
|
41
|
+
stroke-dashoffset: -59
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
export default LoadingIcon;
|
package/src/icon.js
CHANGED
|
@@ -36,6 +36,7 @@ const Icon = React.forwardRef((props, ref)=>{
|
|
|
36
36
|
size={size}
|
|
37
37
|
viewBox={ic.viewBox}
|
|
38
38
|
color={theme.color[color]}
|
|
39
|
+
data-icon={name}
|
|
39
40
|
>
|
|
40
41
|
<use href={`#${ic.id}`}/>
|
|
41
42
|
</StyledSvg>;
|
|
@@ -48,12 +49,7 @@ Icon.propTypes = {
|
|
|
48
49
|
size: PT.oneOf(['xxs', 'xs', 'sm', 'md', 'lg', 'xl']),
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
export const
|
|
52
|
-
width: '100%',
|
|
53
|
-
height: '100%',
|
|
54
|
-
})``;
|
|
55
|
-
|
|
56
|
-
const StyledSvg = styled.svg`
|
|
52
|
+
export const StyledSvg = styled.svg`
|
|
57
53
|
color: ${props=>props.color};
|
|
58
54
|
${props=>toIconSize(props.size)}
|
|
59
55
|
`;
|
package/src/icon_button.js
CHANGED
|
@@ -5,14 +5,14 @@ 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, {
|
|
8
|
+
import Icon, {StyledSvg as IconSvg} from './icon';
|
|
9
9
|
|
|
10
10
|
const {theme, toPixel, getCommonProps, iconNames} = utils;
|
|
11
11
|
|
|
12
12
|
const IconButton = React.forwardRef((props, ref)=>{
|
|
13
13
|
const {variant: $variant, disabled, icon} = props;
|
|
14
14
|
const p = {...getCommonProps(props), disabled, $variant};
|
|
15
|
-
return <StyledIconButton ref={ref} {...p}>
|
|
15
|
+
return <StyledIconButton ref={ref} {...p} data-testid="icon_button">
|
|
16
16
|
<Icon name={icon} size="sm" />
|
|
17
17
|
</StyledIconButton>;
|
|
18
18
|
});
|
|
@@ -36,8 +36,8 @@ const StyledIconButton = styled.button`
|
|
|
36
36
|
background-color: ${theme.color.white};
|
|
37
37
|
border: ${props.$variant=='icon'?'0 none;':
|
|
38
38
|
`1px solid ${theme.color.gray_6}`};
|
|
39
|
-
${
|
|
40
|
-
|
|
39
|
+
${IconSvg} {
|
|
40
|
+
color: ${theme.color.gray_9};
|
|
41
41
|
}
|
|
42
42
|
`;
|
|
43
43
|
}}
|
|
@@ -50,15 +50,15 @@ const StyledIconButton = styled.button`
|
|
|
50
50
|
background-color: ${theme.color.blue_4};
|
|
51
51
|
border: ${props=>props.$variant=='icon'?'0 none;':
|
|
52
52
|
`1px solid ${theme.color.blue_4}`};
|
|
53
|
-
${
|
|
54
|
-
|
|
53
|
+
${IconSvg} {
|
|
54
|
+
color: ${theme.color.blue_11};
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
&:disabled {
|
|
58
58
|
border: ${props=>props.$variant=='icon'?'0 none;':
|
|
59
59
|
`1px solid ${theme.color.gray_7}`};
|
|
60
|
-
${
|
|
61
|
-
|
|
60
|
+
${IconSvg} {
|
|
61
|
+
color: ${theme.color.gray_7};
|
|
62
62
|
}
|
|
63
63
|
cursor: not-allowed;
|
|
64
64
|
}
|
package/src/index.js
CHANGED
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
// LICENSE_CODE ZON
|
|
2
2
|
'use strict'; /*jslint react:true*/
|
|
3
|
-
import Button from './button';
|
|
4
|
-
import
|
|
3
|
+
import {Button} from './button';
|
|
4
|
+
import Typography from './Typography';
|
|
5
5
|
import InfoChip from './infochip';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import Layout from './layout';
|
|
7
|
+
import {Progress, ProgressBar} from './progress';
|
|
8
8
|
import Icon from './icon';
|
|
9
9
|
import IconButton from './icon_button';
|
|
10
|
+
import Tooltip, {withTooltip} from './tooltip';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export {
|
|
13
|
+
Layout,
|
|
14
|
+
Typography,
|
|
15
|
+
Button,
|
|
16
|
+
InfoChip,
|
|
17
|
+
Progress,
|
|
18
|
+
ProgressBar,
|
|
19
|
+
Icon,
|
|
20
|
+
IconButton,
|
|
21
|
+
Tooltip,
|
|
22
|
+
withTooltip,
|
|
23
|
+
};
|
|
14
24
|
|
|
15
|
-
export const Layout = {Box, Flex};
|
|
16
|
-
export const Typography = {Header, Label, Hyperlink, Paragraph};
|
|
17
25
|
const UIKit = {
|
|
18
26
|
Layout,
|
|
19
27
|
Typography,
|
|
20
|
-
Button,
|
|
28
|
+
Button,
|
|
29
|
+
InfoChip,
|
|
30
|
+
Progress,
|
|
31
|
+
ProgressBar,
|
|
32
|
+
Icon,
|
|
33
|
+
IconButton,
|
|
34
|
+
Tooltip,
|
|
35
|
+
withTooltip,
|
|
21
36
|
};
|
|
37
|
+
|
|
22
38
|
export default UIKit;
|
package/src/progress/index.js
CHANGED
package/src/tooltip.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// LICENSE_CODE ZON
|
|
2
|
+
'use strict'; /*jslint react:true*/
|
|
3
|
+
|
|
4
|
+
import React, {useCallback, useState} from 'react';
|
|
5
|
+
import {usePopper} from 'react-popper';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import PT from 'prop-types';
|
|
8
|
+
import {theme} from './utils';
|
|
9
|
+
import typography from './Typography';
|
|
10
|
+
|
|
11
|
+
const {Label} = typography;
|
|
12
|
+
|
|
13
|
+
const Tooltip = props=>{
|
|
14
|
+
const {children, tooltip, placement} = props;
|
|
15
|
+
const [referenceElement, setReferenceElement] = useState(null);
|
|
16
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
17
|
+
const [arrowElement, setArrowElement] = useState(null);
|
|
18
|
+
const [visible, setVisible] = useState(false);
|
|
19
|
+
const show = useCallback(()=>setVisible(true), []);
|
|
20
|
+
const hide = useCallback(()=>setVisible(false), []);
|
|
21
|
+
const {styles, attributes} = usePopper(referenceElement,
|
|
22
|
+
popperElement, {
|
|
23
|
+
placement,
|
|
24
|
+
modifiers: [
|
|
25
|
+
{name: 'arrow', options: {element: arrowElement}},
|
|
26
|
+
{name: 'offset', options: {offset: [0, 8]}},
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
return <>
|
|
30
|
+
<StyledTooltipReference ref={setReferenceElement}
|
|
31
|
+
onMouseEnter={show} onMouseLeave={hide}>
|
|
32
|
+
{children}
|
|
33
|
+
</StyledTooltipReference>
|
|
34
|
+
<StyledTooltipBody ref={setPopperElement} style={styles.popper}
|
|
35
|
+
{...attributes.popper} visible={visible}>
|
|
36
|
+
<Label variant="sm" color="white">{tooltip}</Label>
|
|
37
|
+
<StyledTooltipArrow ref={setArrowElement} style={styles.arrow}
|
|
38
|
+
{...attributes.arrow} visible={visible}/>
|
|
39
|
+
</StyledTooltipBody>
|
|
40
|
+
</>;
|
|
41
|
+
};
|
|
42
|
+
Tooltip.propTypes = {
|
|
43
|
+
tooltip: PT.node,
|
|
44
|
+
placement: PT.oneOf(['auto', 'top', 'right', 'bottom', 'left']),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const withTooltip = (Comp, tooltipProps)=>function WithTooltip(props){
|
|
48
|
+
return <Tooltip {...tooltipProps}>
|
|
49
|
+
<Comp {...props}/>
|
|
50
|
+
</Tooltip>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const StyledTooltipBody = styled.div`
|
|
54
|
+
background-color: ${theme.color.gray_11_50};
|
|
55
|
+
padding: ${theme.spacing['03']};
|
|
56
|
+
width: fit-content;
|
|
57
|
+
max-width: 500px;
|
|
58
|
+
border-radius: ${theme.spacing['02']};
|
|
59
|
+
visibility: ${props=>props.visible ? 'visible': 'hidden'};
|
|
60
|
+
opacity: ${props=>props.visible ? 1 : 0};
|
|
61
|
+
transition: opacity 200ms;
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const StyledTooltipArrow = styled.div`
|
|
65
|
+
&, &::before {
|
|
66
|
+
position: absolute;
|
|
67
|
+
width: ${theme.spacing['04']};
|
|
68
|
+
height: ${theme.spacing['04']};
|
|
69
|
+
background: inherit;
|
|
70
|
+
border-radius: ${theme.spacing['01']};
|
|
71
|
+
}
|
|
72
|
+
visibility: hidden;
|
|
73
|
+
&::before {
|
|
74
|
+
visibility: ${props=>props.visible ? 'visible': 'hidden'};
|
|
75
|
+
content: '';
|
|
76
|
+
transform: rotate(45deg);
|
|
77
|
+
}
|
|
78
|
+
[data-popper-placement^='top'] > & {
|
|
79
|
+
bottom: -${theme.spacing['02']};
|
|
80
|
+
}
|
|
81
|
+
[data-popper-placement^='right'] > & {
|
|
82
|
+
left: -${theme.spacing['02']};
|
|
83
|
+
}
|
|
84
|
+
[data-popper-placement^='bottom'] > & {
|
|
85
|
+
top: -${theme.spacing['02']};
|
|
86
|
+
}
|
|
87
|
+
[data-popper-placement^='left'] > & {
|
|
88
|
+
right: -${theme.spacing['02']};
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
const StyledTooltipReference = styled.div`
|
|
93
|
+
width: fit-content;
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
export default Tooltip;
|
package/src/utils.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
import icons from '@icons';
|
|
6
|
+
import {css} from 'styled-components';
|
|
6
7
|
|
|
7
8
|
export const theme = {
|
|
8
9
|
color: {
|
|
@@ -132,5 +133,134 @@ export function fromTheme(propName, defaultValue){
|
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
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
|
+
};
|
|
135
264
|
|
|
136
|
-
export default {theme, toPixel, getCommonProps, getTypographyProps, fromTheme
|
|
265
|
+
export default {theme, toPixel, getCommonProps, getTypographyProps, fromTheme,
|
|
266
|
+
colorNames, iconNames};
|