@bitrise/bitkit 9.20.0 → 9.21.0-alpha-chakra.3
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/package.json +1 -1
- package/src/Components/IconButton/IconButton.tsx +9 -4
- package/src/Components/Tooltip/Tooltip.theme.ts +16 -0
- package/src/Components/Tooltip/Tooltip.tsx +29 -0
- package/src/Foundations/Shadows/Shadows.ts +1 -0
- package/src/index.ts +3 -0
- package/src/old.ts +0 -3
- package/src/theme.ts +2 -0
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IconButton as ChakraIconButton, IconButtonProps as ChakraIconButtonProps, forwardRef } from '@chakra-ui/react';
|
|
3
3
|
import Icon, { TypeIconName } from '../Icon/Icon';
|
|
4
|
+
import Tooltip from '../Tooltip/Tooltip';
|
|
4
5
|
|
|
5
6
|
export interface IconButtonProps extends ChakraIconButtonProps {
|
|
6
7
|
as?: 'a' | 'button';
|
|
@@ -8,6 +9,7 @@ export interface IconButtonProps extends ChakraIconButtonProps {
|
|
|
8
9
|
isDanger?: boolean;
|
|
9
10
|
label?: string;
|
|
10
11
|
size?: 'small' | 'medium';
|
|
12
|
+
tooltipCloseDelay?: number;
|
|
11
13
|
variant?: 'primary' | 'secondary' | 'tertiary';
|
|
12
14
|
}
|
|
13
15
|
|
|
@@ -15,22 +17,25 @@ export interface IconButtonProps extends ChakraIconButtonProps {
|
|
|
15
17
|
* IconButton composes the `Button` component except that it renders only an icon.
|
|
16
18
|
*/
|
|
17
19
|
const IconButton = forwardRef<IconButtonProps, 'button'>((props, ref) => {
|
|
18
|
-
const { as, iconName, isDanger, isDisabled, label, variant, ...rest } = props;
|
|
20
|
+
const { as, iconName, isDanger, isDisabled, label, tooltipCloseDelay, variant, ...rest } = props;
|
|
19
21
|
const properties: ChakraIconButtonProps = {
|
|
20
22
|
as: isDisabled ? 'button' : as,
|
|
21
23
|
icon: <Icon name={iconName} />,
|
|
22
24
|
isDisabled,
|
|
23
|
-
// TODO: Use Tooltip
|
|
24
|
-
title: label || rest['aria-label'],
|
|
25
25
|
variant: isDanger ? `${variant}--danger` : variant,
|
|
26
26
|
...rest,
|
|
27
27
|
};
|
|
28
|
-
return
|
|
28
|
+
return (
|
|
29
|
+
<Tooltip closeDelay={tooltipCloseDelay} label={label || rest['aria-label']} shouldWrapChildren={isDisabled}>
|
|
30
|
+
<ChakraIconButton {...properties} ref={ref} />
|
|
31
|
+
</Tooltip>
|
|
32
|
+
);
|
|
29
33
|
});
|
|
30
34
|
|
|
31
35
|
IconButton.defaultProps = {
|
|
32
36
|
as: 'button',
|
|
33
37
|
size: 'medium',
|
|
38
|
+
tooltipCloseDelay: 0,
|
|
34
39
|
variant: 'primary',
|
|
35
40
|
} as IconButtonProps;
|
|
36
41
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SystemStyleObject } from '@chakra-ui/theme-tools';
|
|
2
|
+
|
|
3
|
+
const TooltipTheme: SystemStyleObject = {
|
|
4
|
+
baseStyle: {
|
|
5
|
+
bg: 'neutral.10',
|
|
6
|
+
color: 'neutral.95',
|
|
7
|
+
fontSize: '2',
|
|
8
|
+
lineHeight: '2',
|
|
9
|
+
paddingX: '12',
|
|
10
|
+
paddingY: '8',
|
|
11
|
+
borderRadius: '8',
|
|
12
|
+
boxShadow: 'tooltip',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default TooltipTheme;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tooltip as ChakraTooltip, TooltipProps as ChakraTooltipProps, forwardRef, chakra } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
export interface TooltipProps extends ChakraTooltipProps {
|
|
5
|
+
shouldWrapChildren?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A tooltip is a brief, informative message that appears when a user interacts with an element. Tooltips are usually initiated in one of two ways: through a mouse-hover gesture or through a keyboard-hover gesture.
|
|
9
|
+
*/
|
|
10
|
+
const Tooltip = forwardRef<TooltipProps, 'div'>((props, ref) => {
|
|
11
|
+
const { children, shouldWrapChildren, ...rest } = props;
|
|
12
|
+
const properties: ChakraTooltipProps = {
|
|
13
|
+
bg: 'neutral.10',
|
|
14
|
+
children,
|
|
15
|
+
hasArrow: true,
|
|
16
|
+
placement: 'top',
|
|
17
|
+
...rest,
|
|
18
|
+
};
|
|
19
|
+
if (shouldWrapChildren) {
|
|
20
|
+
properties.children = (
|
|
21
|
+
<chakra.span display="inline-block" tabIndex={0}>
|
|
22
|
+
{children}
|
|
23
|
+
</chakra.span>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return <ChakraTooltip {...properties} ref={ref} />;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default Tooltip;
|
package/src/index.ts
CHANGED
|
@@ -62,3 +62,6 @@ export { default as Badge } from './Components/Badge/Badge';
|
|
|
62
62
|
|
|
63
63
|
export type { IconButtonProps } from './Components/IconButton/IconButton';
|
|
64
64
|
export { default as IconButton } from './Components/IconButton/IconButton';
|
|
65
|
+
|
|
66
|
+
export type { TooltipProps } from './Components/Tooltip/Tooltip';
|
|
67
|
+
export { default as Tooltip } from './Components/Tooltip/Tooltip';
|
package/src/old.ts
CHANGED
|
@@ -225,9 +225,6 @@ export { default as Textarea } from './Old/Textarea/Textarea';
|
|
|
225
225
|
export type { Props as ToggleProps } from './Old/Toggle/Toggle';
|
|
226
226
|
export { default as Toggle } from './Old/Toggle/Toggle';
|
|
227
227
|
|
|
228
|
-
export type { Props as TooltipProps } from './Old/Tooltip/Tooltip';
|
|
229
|
-
export { default as Tooltip } from './Old/Tooltip/Tooltip';
|
|
230
|
-
|
|
231
228
|
export type { Props as VisibilityProps } from './Old/Visibility/Visibility';
|
|
232
229
|
export { default as Visibility } from './Old/Visibility/Visibility';
|
|
233
230
|
|
package/src/theme.ts
CHANGED
|
@@ -7,6 +7,7 @@ import Link from './Components/Link/Link.theme';
|
|
|
7
7
|
import Menu from './Components/Menu/Menu.theme';
|
|
8
8
|
import Tabs from './Components/Tabs/Tabs.theme';
|
|
9
9
|
import Text from './Components/Text/Text.theme';
|
|
10
|
+
import Tooltip from './Components/Tooltip/Tooltip.theme';
|
|
10
11
|
|
|
11
12
|
import colors from './Foundations/Colors/Colors';
|
|
12
13
|
import radii from './Foundations/Radii/Radii';
|
|
@@ -57,6 +58,7 @@ const theme = {
|
|
|
57
58
|
Menu,
|
|
58
59
|
Tabs,
|
|
59
60
|
Text,
|
|
61
|
+
Tooltip,
|
|
60
62
|
},
|
|
61
63
|
};
|
|
62
64
|
|