@takaro/lib-components 0.0.14 → 0.0.18
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/Dockerfile.dev +1 -1
- package/package.json +23 -24
- package/src/components/actions/Button/Button.test.tsx +2 -1
- package/src/components/actions/Button/__snapshots__/Button.test.tsx.snap +18 -0
- package/src/components/actions/Button/style.ts +1 -0
- package/src/components/actions/DropdownButton/index.tsx +51 -36
- package/src/components/actions/IconButton/IconButton.test.tsx +3 -2
- package/src/components/actions/IconButton/__snapshots__/IconButton.test.tsx.snap +18 -0
- package/src/components/actions/IconButton/getIconSize.ts +16 -0
- package/src/components/actions/IconButton/index.tsx +2 -16
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +0 -1
- package/src/components/charts/AreaChart/AreaChart.stories.tsx +15 -20
- package/src/components/charts/GeoMercator/GeoMercator.stories.tsx +24 -18
- package/src/components/charts/GeoMercator/index.tsx +158 -56
- package/src/components/charts/GeoMercator/iso3166-alpha2-to-alpha3.ts +250 -0
- package/src/components/charts/GeoMercator/world.json +333 -0
- package/src/components/charts/RadialBarChart/index.tsx +1 -1
- package/src/components/charts/ZoomControls.tsx +47 -0
- package/src/components/charts/index.tsx +3 -0
- package/src/components/data/Chip/Chip.test.tsx +3 -2
- package/src/components/data/Chip/__snapshots__/Chip.test.tsx.snap +38 -0
- package/src/components/data/Console/Console.tsx +1 -7
- package/src/components/data/Console/ConsoleLine/index.tsx +1 -1
- package/src/components/data/Console/constants.ts +6 -0
- package/src/components/data/Table/index.tsx +31 -2
- package/src/components/data/Table/subcomponents/Filter/field.tsx +2 -3
- package/src/components/data/Table/subcomponents/Filter/index.tsx +1 -11
- package/src/components/data/Table/subcomponents/Filter/types.ts +10 -0
- package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +0 -1
- package/src/components/data/index.ts +0 -3
- package/src/components/dialogs/Dialog/DialogBody.tsx +1 -0
- package/src/components/dialogs/Dialog/DialogContent.tsx +1 -5
- package/src/components/feedback/Alert/Alert.stories.tsx +1 -10
- package/src/components/feedback/Alert/Alert.test.tsx +2 -1
- package/src/components/feedback/Alert/__snapshots__/Alert.test.tsx.snap +44 -0
- package/src/components/feedback/Alert/index.tsx +11 -15
- package/src/components/feedback/Alert/style.ts +9 -11
- package/src/components/feedback/ErrorPage/index.tsx +1 -1
- package/src/components/feedback/IconTooltip/IconTooltip.stories.tsx +22 -0
- package/src/components/feedback/IconTooltip/index.tsx +50 -0
- package/src/components/feedback/Loaders/Loading.test.tsx +2 -1
- package/src/components/feedback/Loaders/Spinner.test.tsx +2 -1
- package/src/components/feedback/Loaders/__snapshots__/Loading.test.tsx.snap +141 -0
- package/src/components/feedback/Loaders/__snapshots__/Spinner.test.tsx.snap +10 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx +2 -1
- package/src/components/feedback/NetworkDetector/__snapshots__/NetworkDetector.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +2 -1
- package/src/components/feedback/NotificationBanner/__snapshots__/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/ProgressBar/ProgressBar.stories.tsx +2 -1
- package/src/components/feedback/ProgressBar/index.tsx +58 -24
- package/src/components/feedback/Skeleton/Skeleton.test.tsx +2 -1
- package/src/components/feedback/Skeleton/__snapshots__/Skeleton.test.tsx.snap +9 -0
- package/src/components/feedback/Tooltip/TooltipContent.tsx +2 -2
- package/src/components/feedback/Tooltip/useTooltip.tsx +3 -0
- package/src/components/feedback/index.ts +2 -1
- package/src/components/feedback/snacks/Drawer/Drawer.stories.tsx +1 -1
- package/src/components/feedback/snacks/Drawer/index.tsx +19 -4
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +1 -1
- package/src/components/inputs/Date/DateRangePicker/Generic.tsx +2 -1
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +1 -17
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +1 -17
- package/src/components/inputs/Date/types.ts +14 -0
- package/src/components/inputs/DurationField/Generic.tsx +0 -1
- package/src/components/inputs/TextField/Controlled.tsx +1 -1
- package/src/components/inputs/TextField/Generic.tsx +79 -56
- package/src/components/inputs/TextField/TextField.stories.tsx +21 -1
- package/src/components/inputs/TextField/style.ts +6 -0
- package/src/components/inputs/TextField/util.ts +7 -2
- package/src/components/inputs/index.ts +1 -0
- package/src/components/inputs/layout/Description.tsx +0 -5
- package/src/components/inputs/layout/Label/style.ts +0 -1
- package/src/components/inputs/layout/index.ts +3 -1
- package/src/components/inputs/layout/setAriaDescribedBy.ts +3 -0
- package/src/components/inputs/selects/SelectField/Controlled.tsx +0 -2
- package/src/components/inputs/selects/SelectField/Generic/index.tsx +11 -14
- package/src/components/inputs/selects/SelectQueryField/Controlled.tsx +2 -2
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +134 -54
- package/src/components/inputs/selects/SelectQueryField/style.ts +0 -1
- package/src/components/inputs/selects/SubComponents/Option.tsx +1 -1
- package/src/components/inputs/selects/sharedStyle.ts +0 -2
- package/src/components/layout/Container/index.ts +1 -1
- package/src/components/layout/index.ts +1 -1
- package/src/components/navigation/HorizontalNav/HorizontalNav.stories.tsx +6 -22
- package/src/components/navigation/HorizontalNav/index.tsx +1 -1
- package/src/components/navigation/HorizontalNav/style.ts +28 -3
- package/src/components/navigation/Steppers/SlimStepper/Stepper.stories.tsx +2 -1
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +4 -4
- package/src/components/navigation/Steppers/Stepper/Stepper.stories.tsx +2 -1
- package/src/components/navigation/Steppers/Stepper/index.tsx +4 -4
- package/src/components/navigation/Steppers/context.tsx +2 -49
- package/src/components/navigation/Steppers/provider.tsx +18 -0
- package/src/components/navigation/Steppers/useStepper.ts +34 -0
- package/src/components/navigation/index.ts +2 -1
- package/src/components/other/ActionMenu/index.tsx +20 -11
- package/src/components/other/ActionMenu/style.ts +2 -2
- package/src/components/other/ClipBoard/ClipBoard.test.tsx +2 -1
- package/src/components/other/ClipBoard/__snapshots__/ClipBoard.test.tsx.snap +36 -0
- package/src/components/other/Empty/Empty.test.tsx +5 -2
- package/src/components/other/Empty/__snapshots__/Empty.test.tsx.snap +21 -0
- package/src/components/other/PermissionsGuard/hasPermissionsHelper.ts +18 -0
- package/src/components/other/PermissionsGuard/index.tsx +1 -17
- package/src/components/other/Plan/Plan.stories.tsx +21 -0
- package/src/components/other/Plan/index.tsx +93 -0
- package/src/components/other/Plan/style.ts +61 -0
- package/src/components/other/Usage/Usage.stories.tsx +21 -0
- package/src/components/other/Usage/Usage.tsx +35 -0
- package/src/components/other/Usage/UsageCard.stories.tsx +31 -0
- package/src/components/other/Usage/UsageCard.tsx +88 -0
- package/src/components/other/index.ts +10 -2
- package/src/components/visual/Card/Card.stories.tsx +4 -1
- package/src/components/visual/Card/CardBody.tsx +11 -0
- package/src/components/visual/Card/CardTitle.tsx +23 -0
- package/src/components/visual/Card/index.tsx +19 -9
- package/src/components/visual/Divider/Divider.test.tsx +2 -1
- package/src/components/visual/Divider/__snapshots__/Divider.test.tsx.snap +13 -0
- package/src/components/visual/Divider/index.tsx +9 -6
- package/src/errors/errors.ts +1 -1
- package/src/helpers/regexprs.ts +2 -1
- package/tsconfig.json +0 -5
- package/vite.config.mts +17 -0
- package/src/components/data/LinkCard/index.tsx +0 -28
- package/src/components/feedback/QuestionTooltip/QuestionTooltip.stories.tsx +0 -20
- package/src/components/feedback/QuestionTooltip/index.tsx +0 -35
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Alert } from '.';
|
|
2
|
-
import { render } from 'test
|
|
2
|
+
import { render } from '../../../test/testUtils';
|
|
3
|
+
import { expect, it } from 'vitest';
|
|
3
4
|
|
|
4
5
|
it('Should render <Alert/>', () => {
|
|
5
6
|
const { container } = render(<Alert text="Alert text" title="Alert title" variant="info" />);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Alert/> 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="sc-aXZVg eHujeX"
|
|
7
|
+
role="status"
|
|
8
|
+
style="opacity: 0; will-change: opacity;"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
class="sc-gEvEer xJHes"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
class="sc-eqUAAy cuxXJQ"
|
|
15
|
+
>
|
|
16
|
+
<svg
|
|
17
|
+
fill="currentColor"
|
|
18
|
+
height="24"
|
|
19
|
+
stroke="currentColor"
|
|
20
|
+
stroke-width="0"
|
|
21
|
+
viewBox="0 0 1024 1024"
|
|
22
|
+
width="24"
|
|
23
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
24
|
+
>
|
|
25
|
+
<path
|
|
26
|
+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"
|
|
27
|
+
/>
|
|
28
|
+
</svg>
|
|
29
|
+
</div>
|
|
30
|
+
<h2>
|
|
31
|
+
Alert title
|
|
32
|
+
</h2>
|
|
33
|
+
<p>
|
|
34
|
+
<p>
|
|
35
|
+
Alert text
|
|
36
|
+
</p>
|
|
37
|
+
</p>
|
|
38
|
+
<div
|
|
39
|
+
class="sc-fqkvVR JhYnd action"
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
`;
|
|
@@ -24,11 +24,10 @@ export interface AlertProps {
|
|
|
24
24
|
elevation?: Elevation;
|
|
25
25
|
dismiss?: boolean;
|
|
26
26
|
action?: Action;
|
|
27
|
-
showIcon?: boolean;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(
|
|
31
|
-
{ variant, title, text, dismiss = false, elevation = 4, action
|
|
30
|
+
{ variant, title, text, dismiss = false, elevation = 4, action },
|
|
32
31
|
ref,
|
|
33
32
|
) {
|
|
34
33
|
const [visible, setVisible] = useState(true);
|
|
@@ -85,19 +84,16 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(
|
|
|
85
84
|
ref={ref}
|
|
86
85
|
role="status"
|
|
87
86
|
>
|
|
88
|
-
<Grid
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{renderText()}
|
|
99
|
-
{hasTitle ? <div /> : null}
|
|
100
|
-
<ButtonContainer hasTitle={hasTitle} show={dismiss || action ? true : false} variant={variant}>
|
|
87
|
+
<Grid>
|
|
88
|
+
<IconContainer variant={variant}>{getIcon()}</IconContainer>
|
|
89
|
+
{title && <h2>{title}</h2>}
|
|
90
|
+
<p>{renderText()}</p>
|
|
91
|
+
<ButtonContainer
|
|
92
|
+
hasTitle={hasTitle}
|
|
93
|
+
show={dismiss || action ? true : false}
|
|
94
|
+
variant={variant}
|
|
95
|
+
className="action"
|
|
96
|
+
>
|
|
101
97
|
{action && (
|
|
102
98
|
<Button size="tiny" variant="outline" onClick={handleExecute} text={action.text} color={variant} />
|
|
103
99
|
)}
|
|
@@ -12,7 +12,8 @@ export const Container = styled(motion.div)<{
|
|
|
12
12
|
$elevation: Elevation;
|
|
13
13
|
}>`
|
|
14
14
|
width: 100%;
|
|
15
|
-
padding: ${({ theme }) =>
|
|
15
|
+
padding: ${({ theme }) =>
|
|
16
|
+
`${theme.spacing['0_75']} ${theme.spacing['0_75']} ${theme.spacing['0_75']} ${theme.spacing['0']}`};
|
|
16
17
|
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
17
18
|
box-shadow: ${({ theme, $elevation }) => theme.elevation[$elevation]};
|
|
18
19
|
margin: ${({ theme }) => `${theme.spacing['1_5']} auto`};
|
|
@@ -58,24 +59,21 @@ export const Container = styled(motion.div)<{
|
|
|
58
59
|
}}
|
|
59
60
|
`;
|
|
60
61
|
|
|
61
|
-
export const Grid = styled.div
|
|
62
|
+
export const Grid = styled.div`
|
|
62
63
|
display: grid;
|
|
63
|
-
grid-template-columns:
|
|
64
|
-
const result = '';
|
|
65
|
-
if (showIcon) result.concat(`${theme.spacing[5]}`);
|
|
66
|
-
result.concat(' 1fr');
|
|
67
|
-
if (hasTitle) result.concat(' fit-content(100px)');
|
|
68
|
-
return result;
|
|
69
|
-
}}
|
|
64
|
+
grid-template-columns: 40px 1fr;
|
|
70
65
|
align-items: center;
|
|
71
|
-
|
|
66
|
+
|
|
67
|
+
p,
|
|
68
|
+
.action {
|
|
69
|
+
grid-column: 2;
|
|
70
|
+
}
|
|
72
71
|
`;
|
|
73
72
|
|
|
74
73
|
export const IconContainer = styled.div<{ variant: AlertVariants }>`
|
|
75
74
|
display: flex;
|
|
76
75
|
align-items: center;
|
|
77
76
|
justify-content: center;
|
|
78
|
-
margin-right: ${({ theme }) => theme.spacing['1']};
|
|
79
77
|
svg {
|
|
80
78
|
fill: ${({ variant, theme }): string => theme.colors[variant]};
|
|
81
79
|
}
|
|
@@ -122,7 +122,7 @@ const defaultListItems = [
|
|
|
122
122
|
icon: <AiOutlineBook />,
|
|
123
123
|
title: 'Documentation',
|
|
124
124
|
description: 'Learn how to integrate our tools with your app',
|
|
125
|
-
to: 'docs.takaro.io',
|
|
125
|
+
to: 'https://docs.takaro.io',
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
icon: <AiOutlineMenu />,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { IconTooltip, IconTooltipProps } from '.';
|
|
4
|
+
import { AiOutlineQuestion as QuestionIcon } from 'react-icons/ai';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Feedback/IconTooltip',
|
|
8
|
+
component: IconTooltip,
|
|
9
|
+
args: {
|
|
10
|
+
placement: 'bottom',
|
|
11
|
+
},
|
|
12
|
+
} as Meta<IconTooltipProps>;
|
|
13
|
+
|
|
14
|
+
export const Default: StoryFn<IconTooltipProps> = (args) => {
|
|
15
|
+
return (
|
|
16
|
+
<div style={{ width: '200px' }}>
|
|
17
|
+
<IconTooltip placement={args.placement} initialOpen={args.initialOpen} icon={<QuestionIcon />}>
|
|
18
|
+
this is the tooltip content
|
|
19
|
+
</IconTooltip>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { cloneElement, FC, ReactElement } from 'react';
|
|
2
|
+
import { Tooltip, TooltipProps } from '../Tooltip';
|
|
3
|
+
import { Size, styled } from '../../../styled';
|
|
4
|
+
import { getIconSize } from '../../actions/IconButton/getIconSize';
|
|
5
|
+
import { ButtonColor } from '../../actions/Button/style';
|
|
6
|
+
import { shade } from 'polished';
|
|
7
|
+
|
|
8
|
+
type TooltipIconColor = Exclude<ButtonColor, 'white'>;
|
|
9
|
+
|
|
10
|
+
const TriggerContainer = styled.div<{ color: TooltipIconColor }>`
|
|
11
|
+
background: ${({ theme, color }) => shade(0.5, theme.colors[color])};
|
|
12
|
+
border: 1px solid ${({ theme, color }) => theme.colors[color]};
|
|
13
|
+
border-radius: ${({ theme }) => theme.borderRadius.small};
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
margin-left: ${({ theme }) => theme.spacing['0_5']};
|
|
18
|
+
margin-right: ${({ theme }) => theme.spacing['0_5']};
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const ContentContainer = styled.div`
|
|
22
|
+
max-width: 450px;
|
|
23
|
+
hyphens: auto;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export interface IconTooltipProps extends TooltipProps {
|
|
27
|
+
icon: ReactElement;
|
|
28
|
+
size?: Size;
|
|
29
|
+
color?: TooltipIconColor;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const IconTooltip: FC<IconTooltipProps> = ({
|
|
33
|
+
children,
|
|
34
|
+
initialOpen,
|
|
35
|
+
open,
|
|
36
|
+
icon,
|
|
37
|
+
size = 'medium',
|
|
38
|
+
color = 'primary',
|
|
39
|
+
}) => {
|
|
40
|
+
return (
|
|
41
|
+
<Tooltip initialOpen={initialOpen} open={open}>
|
|
42
|
+
<Tooltip.Trigger asChild>
|
|
43
|
+
<TriggerContainer color={color}>{cloneElement(icon, { size: getIconSize(size) })}</TriggerContainer>
|
|
44
|
+
</Tooltip.Trigger>
|
|
45
|
+
<Tooltip.Content>
|
|
46
|
+
<ContentContainer>{children}</ContentContainer>
|
|
47
|
+
</Tooltip.Content>
|
|
48
|
+
</Tooltip>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Loading/> 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<svg
|
|
6
|
+
fill="#664de5"
|
|
7
|
+
height="105"
|
|
8
|
+
viewBox="0 0 105 105"
|
|
9
|
+
width="105"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
>
|
|
12
|
+
<circle
|
|
13
|
+
cx="12.5"
|
|
14
|
+
cy="12.5"
|
|
15
|
+
r="12.5"
|
|
16
|
+
>
|
|
17
|
+
<animate
|
|
18
|
+
attributeName="fill-opacity"
|
|
19
|
+
begin="0s"
|
|
20
|
+
calcMode="linear"
|
|
21
|
+
dur="1s"
|
|
22
|
+
repeatCount="indefinite"
|
|
23
|
+
values="1;.2;1"
|
|
24
|
+
/>
|
|
25
|
+
</circle>
|
|
26
|
+
<circle
|
|
27
|
+
cx="12.5"
|
|
28
|
+
cy="52.5"
|
|
29
|
+
fill-opacity=".5"
|
|
30
|
+
r="12.5"
|
|
31
|
+
>
|
|
32
|
+
<animate
|
|
33
|
+
attributeName="fill-opacity"
|
|
34
|
+
begin="100ms"
|
|
35
|
+
calcMode="linear"
|
|
36
|
+
dur="1s"
|
|
37
|
+
repeatCount="indefinite"
|
|
38
|
+
values="1;.2;1"
|
|
39
|
+
/>
|
|
40
|
+
</circle>
|
|
41
|
+
<circle
|
|
42
|
+
cx="52.5"
|
|
43
|
+
cy="12.5"
|
|
44
|
+
r="12.5"
|
|
45
|
+
>
|
|
46
|
+
<animate
|
|
47
|
+
attributeName="fill-opacity"
|
|
48
|
+
begin="300ms"
|
|
49
|
+
calcMode="linear"
|
|
50
|
+
dur="1s"
|
|
51
|
+
repeatCount="indefinite"
|
|
52
|
+
values="1;.2;1"
|
|
53
|
+
/>
|
|
54
|
+
</circle>
|
|
55
|
+
<circle
|
|
56
|
+
cx="52.5"
|
|
57
|
+
cy="52.5"
|
|
58
|
+
r="12.5"
|
|
59
|
+
>
|
|
60
|
+
<animate
|
|
61
|
+
attributeName="fill-opacity"
|
|
62
|
+
begin="600ms"
|
|
63
|
+
calcMode="linear"
|
|
64
|
+
dur="1s"
|
|
65
|
+
repeatCount="indefinite"
|
|
66
|
+
values="1;.2;1"
|
|
67
|
+
/>
|
|
68
|
+
</circle>
|
|
69
|
+
<circle
|
|
70
|
+
cx="92.5"
|
|
71
|
+
cy="12.5"
|
|
72
|
+
r="12.5"
|
|
73
|
+
>
|
|
74
|
+
<animate
|
|
75
|
+
attributeName="fill-opacity"
|
|
76
|
+
begin="800ms"
|
|
77
|
+
calcMode="linear"
|
|
78
|
+
dur="1s"
|
|
79
|
+
repeatCount="indefinite"
|
|
80
|
+
values="1;.2;1"
|
|
81
|
+
/>
|
|
82
|
+
</circle>
|
|
83
|
+
<circle
|
|
84
|
+
cx="92.5"
|
|
85
|
+
cy="52.5"
|
|
86
|
+
r="12.5"
|
|
87
|
+
>
|
|
88
|
+
<animate
|
|
89
|
+
attributeName="fill-opacity"
|
|
90
|
+
begin="400ms"
|
|
91
|
+
calcMode="linear"
|
|
92
|
+
dur="1s"
|
|
93
|
+
repeatCount="indefinite"
|
|
94
|
+
values="1;.2;1"
|
|
95
|
+
/>
|
|
96
|
+
</circle>
|
|
97
|
+
<circle
|
|
98
|
+
cx="12.5"
|
|
99
|
+
cy="92.5"
|
|
100
|
+
r="12.5"
|
|
101
|
+
>
|
|
102
|
+
<animate
|
|
103
|
+
attributeName="fill-opacity"
|
|
104
|
+
begin="700ms"
|
|
105
|
+
calcMode="linear"
|
|
106
|
+
dur="1s"
|
|
107
|
+
repeatCount="indefinite"
|
|
108
|
+
values="1;.2;1"
|
|
109
|
+
/>
|
|
110
|
+
</circle>
|
|
111
|
+
<circle
|
|
112
|
+
cx="52.5"
|
|
113
|
+
cy="92.5"
|
|
114
|
+
r="12.5"
|
|
115
|
+
>
|
|
116
|
+
<animate
|
|
117
|
+
attributeName="fill-opacity"
|
|
118
|
+
begin="500ms"
|
|
119
|
+
calcMode="linear"
|
|
120
|
+
dur="1s"
|
|
121
|
+
repeatCount="indefinite"
|
|
122
|
+
values="1;.2;1"
|
|
123
|
+
/>
|
|
124
|
+
</circle>
|
|
125
|
+
<circle
|
|
126
|
+
cx="92.5"
|
|
127
|
+
cy="92.5"
|
|
128
|
+
r="12.5"
|
|
129
|
+
>
|
|
130
|
+
<animate
|
|
131
|
+
attributeName="fill-opacity"
|
|
132
|
+
begin="200ms"
|
|
133
|
+
calcMode="linear"
|
|
134
|
+
dur="1s"
|
|
135
|
+
repeatCount="indefinite"
|
|
136
|
+
values="1;.2;1"
|
|
137
|
+
/>
|
|
138
|
+
</circle>
|
|
139
|
+
</svg>
|
|
140
|
+
</div>
|
|
141
|
+
`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NetworkDetector } from '.';
|
|
2
|
-
import { render } from 'test
|
|
2
|
+
import { render } from '../../../test/testUtils';
|
|
3
|
+
import { it, expect } from 'vitest';
|
|
3
4
|
|
|
4
5
|
it('Should render <NetworkDetector/>', () => {
|
|
5
6
|
const { container } = render(<NetworkDetector />);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { Meta, StoryFn } from '@storybook/react';
|
|
2
3
|
import { useState } from 'react';
|
|
3
4
|
import { ProgressBar, ProgressBarProps } from '.';
|
|
@@ -28,7 +29,7 @@ export const Determinate: StoryFn<ProgressBarProps> = () => {
|
|
|
28
29
|
|
|
29
30
|
return (
|
|
30
31
|
<>
|
|
31
|
-
<ProgressBar mode="determinate"
|
|
32
|
+
<ProgressBar mode="determinate" showPercentage value={value} />
|
|
32
33
|
<ButtonContainer>
|
|
33
34
|
<button onClick={() => setValue(value + 5)}>+5</button>
|
|
34
35
|
<button onClick={() => setValue(value + 10)}>+10</button>
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { shade } from 'polished';
|
|
3
|
+
import { styled, Color as C, Size } from '../../../styled';
|
|
4
4
|
import { keyframes } from 'styled-components';
|
|
5
|
+
import { AlertVariants } from '../Alert';
|
|
6
|
+
|
|
7
|
+
type Color = C | AlertVariants;
|
|
5
8
|
|
|
6
9
|
const indeterminateAnimation = keyframes`
|
|
7
10
|
0% {
|
|
@@ -28,12 +31,13 @@ const IndeterminateProgress = styled.div<{ color: Color }>`
|
|
|
28
31
|
position: absolute;
|
|
29
32
|
content: '';
|
|
30
33
|
width: 100%;
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
top: 1px;
|
|
35
|
+
height: calc(100% - 4px);
|
|
36
|
+
background-color: ${({ theme, color }) => shade(0.5, theme.colors[color])};
|
|
37
|
+
border: 1px solid ${({ theme, color }) => theme.colors[color]};
|
|
33
38
|
animation: ${indeterminateAnimation} 5s infinite linear;
|
|
34
39
|
transform-origin: 0% 50%;
|
|
35
|
-
border-radius: ${({ theme }) => theme.borderRadius.
|
|
36
|
-
background-color: ${({ theme, color }) => theme.colors[color]};
|
|
40
|
+
border-radius: ${({ theme }) => theme.borderRadius.small};
|
|
37
41
|
}
|
|
38
42
|
`;
|
|
39
43
|
|
|
@@ -43,15 +47,28 @@ const Container = styled.div`
|
|
|
43
47
|
align-items: center;
|
|
44
48
|
justify-content: flex-start;
|
|
45
49
|
width: 100%;
|
|
46
|
-
padding: ${({ theme }) => theme.spacing[1]};
|
|
47
50
|
`;
|
|
48
|
-
const Progress = styled.div<{ color: Color; progress: number }>`
|
|
49
|
-
width:
|
|
51
|
+
const Progress = styled.div<{ color: Color; progress: number; size: Size }>`
|
|
52
|
+
width: 100%;
|
|
50
53
|
position: relative;
|
|
51
54
|
background-color: ${({ theme }) => theme.colors.background};
|
|
52
|
-
height: ${({ theme }) =>
|
|
53
|
-
|
|
55
|
+
height: ${({ theme, size }) => {
|
|
56
|
+
switch (size) {
|
|
57
|
+
case 'tiny':
|
|
58
|
+
return theme.spacing['0_5'];
|
|
59
|
+
case 'small':
|
|
60
|
+
return theme.spacing['0_75'];
|
|
61
|
+
case 'medium':
|
|
62
|
+
return theme.spacing['1_5'];
|
|
63
|
+
case 'large':
|
|
64
|
+
return theme.spacing['2_5'];
|
|
65
|
+
case 'huge':
|
|
66
|
+
return theme.spacing['4'];
|
|
67
|
+
}
|
|
68
|
+
}};
|
|
69
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
54
70
|
overflow: hidden;
|
|
71
|
+
border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
55
72
|
|
|
56
73
|
&::after {
|
|
57
74
|
position: absolute;
|
|
@@ -60,17 +77,23 @@ const Progress = styled.div<{ color: Color; progress: number }>`
|
|
|
60
77
|
top: 50%;
|
|
61
78
|
transform: translateY(-50%);
|
|
62
79
|
left: 0;
|
|
63
|
-
height: ${({ theme }) =>
|
|
80
|
+
height: ${({ theme, size }) => {
|
|
81
|
+
switch (size) {
|
|
82
|
+
case 'tiny':
|
|
83
|
+
return theme.spacing['0_5'];
|
|
84
|
+
case 'small':
|
|
85
|
+
return theme.spacing['0_75'];
|
|
86
|
+
case 'medium':
|
|
87
|
+
return theme.spacing['1_5'];
|
|
88
|
+
case 'large':
|
|
89
|
+
return theme.spacing['2_5'];
|
|
90
|
+
case 'huge':
|
|
91
|
+
return theme.spacing['4'];
|
|
92
|
+
}
|
|
93
|
+
}};
|
|
64
94
|
max-width: 100%;
|
|
65
95
|
transition: 0.2s width ease-out;
|
|
66
|
-
background-color: ${({ theme, color }) =>
|
|
67
|
-
background-image: ${({ theme, color }): string =>
|
|
68
|
-
`url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23${theme.colors[
|
|
69
|
-
color
|
|
70
|
-
].slice(
|
|
71
|
-
1,
|
|
72
|
-
theme.colors[color].length,
|
|
73
|
-
)}' fill-opacity='1' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E")`};
|
|
96
|
+
background-color: ${({ theme, color }) => theme.colors[color]};
|
|
74
97
|
}
|
|
75
98
|
`;
|
|
76
99
|
|
|
@@ -82,15 +105,26 @@ export interface ProgressBarProps {
|
|
|
82
105
|
mode: 'determinate' | 'indeterminate';
|
|
83
106
|
value?: number;
|
|
84
107
|
color?: Color;
|
|
85
|
-
|
|
108
|
+
showPercentage?: boolean;
|
|
109
|
+
size?: Size;
|
|
110
|
+
/// To make the progressbar a bit more visually pleasing, you can set a minimum fill value.
|
|
111
|
+
/// If the actual value is below this value, the progressbar will still show the minimum fill value.
|
|
112
|
+
minFill?: number;
|
|
86
113
|
}
|
|
87
114
|
|
|
88
|
-
export const ProgressBar: FC<ProgressBarProps> = ({
|
|
115
|
+
export const ProgressBar: FC<ProgressBarProps> = ({
|
|
116
|
+
mode,
|
|
117
|
+
value = 0,
|
|
118
|
+
color = 'primary',
|
|
119
|
+
showPercentage = false,
|
|
120
|
+
size = 'medium',
|
|
121
|
+
minFill = 0,
|
|
122
|
+
}) => {
|
|
89
123
|
if (mode === 'determinate') {
|
|
90
124
|
return (
|
|
91
125
|
<Container>
|
|
92
|
-
<Progress color={color} progress={value} />
|
|
93
|
-
{
|
|
126
|
+
<Progress color={color} progress={value > minFill ? value : value == 0 ? 0 : minFill} size={size} />
|
|
127
|
+
{showPercentage && <Label>{Math.min(value, 100)}%</Label>}
|
|
94
128
|
</Container>
|
|
95
129
|
);
|
|
96
130
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Skeleton } from '.';
|
|
2
|
-
import {
|
|
2
|
+
import { it, expect } from 'vitest';
|
|
3
|
+
import { render } from '../../../test/testUtils';
|
|
3
4
|
|
|
4
5
|
it('Should render <Skeleton/>', () => {
|
|
5
6
|
const { container } = render(<Skeleton variant="rectangular" />);
|
|
@@ -22,10 +22,10 @@ export const TooltipContent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElemen
|
|
|
22
22
|
propRef,
|
|
23
23
|
) {
|
|
24
24
|
const theme = useTheme();
|
|
25
|
-
const { floatingStyles, open, arrowRef, context, getFloatingProps } = useTooltipContext();
|
|
25
|
+
const { floatingStyles, open, arrowRef, context, getFloatingProps, disabled } = useTooltipContext();
|
|
26
26
|
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
27
27
|
|
|
28
|
-
if (!open) return null;
|
|
28
|
+
if (!open || disabled) return null;
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<FloatingPortal>
|
|
@@ -20,12 +20,14 @@ export interface TooltipOptions {
|
|
|
20
20
|
placement?: Placement;
|
|
21
21
|
open?: boolean;
|
|
22
22
|
onOpenChange?: (open: boolean) => void;
|
|
23
|
+
disabled?: boolean;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export function useTooltip({
|
|
26
27
|
initialOpen = false,
|
|
27
28
|
placement = 'top',
|
|
28
29
|
open: controlledOpen,
|
|
30
|
+
disabled = false,
|
|
29
31
|
onOpenChange: setControlledOpen,
|
|
30
32
|
}: TooltipOptions = {}) {
|
|
31
33
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
@@ -73,6 +75,7 @@ export function useTooltip({
|
|
|
73
75
|
arrowRef,
|
|
74
76
|
...interactions,
|
|
75
77
|
...data,
|
|
78
|
+
disabled,
|
|
76
79
|
}),
|
|
77
80
|
[open, setOpen, interactions, data],
|
|
78
81
|
);
|
|
@@ -21,7 +21,8 @@ export type { ProgressBarProps } from './ProgressBar';
|
|
|
21
21
|
export { Tooltip } from './Tooltip';
|
|
22
22
|
export type { TooltipProps } from './Tooltip';
|
|
23
23
|
|
|
24
|
-
export {
|
|
24
|
+
export { IconTooltip } from './IconTooltip';
|
|
25
|
+
export type { IconTooltipProps } from './IconTooltip';
|
|
25
26
|
|
|
26
27
|
export { Popover } from './Popover';
|
|
27
28
|
export type { PopoverProps } from './Popover';
|