@hyphen/hyphen-components 4.7.0 → 4.7.1
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/dist/components/Badge/Badge.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.stories.d.ts +1 -0
- package/dist/hyphen-components.cjs.development.js +4 -3
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +1 -1
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +4 -3
- package/dist/hyphen-components.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Badge/Badge.tsx +35 -25
- package/src/components/Tooltip/Tooltip.mdx +6 -2
- package/src/components/Tooltip/Tooltip.stories.tsx +14 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode, forwardRef } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { FontSize, BaseSpacing, ResponsiveProp } from '../../types';
|
|
4
4
|
import { generateResponsiveClasses } from '../../lib/generateResponsiveClasses';
|
|
@@ -42,29 +42,39 @@ export interface BadgeProps {
|
|
|
42
42
|
[x: string]: any; // eslint-disable-line
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export const Badge
|
|
46
|
-
|
|
47
|
-
message = '',
|
|
48
|
-
variant = 'light-grey',
|
|
49
|
-
size = 'md',
|
|
50
|
-
...restProps
|
|
51
|
-
}) => {
|
|
52
|
-
const responsiveClasses = generateResponsiveClasses('size', size).map(
|
|
53
|
-
(c) => styles[c]
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const badgeClasses: string = classNames(
|
|
57
|
-
styles.badge,
|
|
58
|
-
className,
|
|
59
|
-
responsiveClasses,
|
|
45
|
+
export const Badge = forwardRef<HTMLDivElement, BadgeProps>(
|
|
46
|
+
(
|
|
60
47
|
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
className = '',
|
|
49
|
+
message = '',
|
|
50
|
+
variant = 'light-grey',
|
|
51
|
+
size = 'md',
|
|
52
|
+
...restProps
|
|
53
|
+
},
|
|
54
|
+
ref
|
|
55
|
+
) => {
|
|
56
|
+
const responsiveClasses = generateResponsiveClasses('size', size).map(
|
|
57
|
+
(c) => styles[c]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const badgeClasses: string = classNames(
|
|
61
|
+
styles.badge,
|
|
62
|
+
className,
|
|
63
|
+
responsiveClasses,
|
|
64
|
+
{
|
|
65
|
+
[styles[variant]]: variant,
|
|
66
|
+
}
|
|
67
|
+
);
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
69
|
+
return (
|
|
70
|
+
<Box
|
|
71
|
+
ref={ref}
|
|
72
|
+
className={badgeClasses}
|
|
73
|
+
display="inline-block"
|
|
74
|
+
{...restProps}
|
|
75
|
+
>
|
|
76
|
+
{message}
|
|
77
|
+
</Box>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
@@ -16,8 +16,12 @@ This component is extended from [Radix](https://www.radix-ui.com/primitives/docs
|
|
|
16
16
|
|
|
17
17
|
## Basic Usage
|
|
18
18
|
|
|
19
|
-
<Canvas of={Stories.BasicUsage} />
|
|
19
|
+
<Canvas of={Stories.BasicUsage} sourceState="shown" />
|
|
20
20
|
|
|
21
21
|
## With Portal
|
|
22
22
|
|
|
23
|
-
<Canvas of={Stories.WithPortal} />
|
|
23
|
+
<Canvas of={Stories.WithPortal} sourceState="shown" />
|
|
24
|
+
|
|
25
|
+
## Badge with Tooltip
|
|
26
|
+
|
|
27
|
+
<Canvas of={Stories.BadgeTooltip} sourceState="shown" />
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from './Tooltip';
|
|
9
9
|
import type { Meta } from '@storybook/react';
|
|
10
10
|
import { Button } from '../Button/Button';
|
|
11
|
+
import { Badge } from '../Badge/Badge';
|
|
11
12
|
|
|
12
13
|
const meta: Meta<typeof Tooltip> = {
|
|
13
14
|
title: 'Components/Tooltip',
|
|
@@ -39,3 +40,16 @@ export const WithPortal = () => (
|
|
|
39
40
|
</Tooltip>
|
|
40
41
|
</TooltipProvider>
|
|
41
42
|
);
|
|
43
|
+
|
|
44
|
+
export const BadgeTooltip = () => (
|
|
45
|
+
<TooltipProvider delayDuration={100}>
|
|
46
|
+
<Tooltip>
|
|
47
|
+
<TooltipTrigger asChild>
|
|
48
|
+
<Badge as="button" message="hover" variant="blue" />
|
|
49
|
+
</TooltipTrigger>
|
|
50
|
+
<TooltipPortal>
|
|
51
|
+
<TooltipContent>This is the tooltip content</TooltipContent>
|
|
52
|
+
</TooltipPortal>
|
|
53
|
+
</Tooltip>
|
|
54
|
+
</TooltipProvider>
|
|
55
|
+
);
|
|
@@ -19,7 +19,7 @@ const TooltipContent = React.forwardRef<
|
|
|
19
19
|
ref={ref}
|
|
20
20
|
sideOffset={sideOffset}
|
|
21
21
|
className={classNames(
|
|
22
|
-
'background-color-tooltip font-color-tooltip font-size-xs overflow-hidden br-sm p-h-sm p-v-xs shadow-sm
|
|
22
|
+
'background-color-tooltip font-color-tooltip font-size-xs z-index-popover overflow-hidden br-sm p-h-sm p-v-xs shadow-sm',
|
|
23
23
|
className
|
|
24
24
|
)}
|
|
25
25
|
{...props}
|