@ssa-ui-kit/core 0.0.25-alpha → 0.0.27-alpha
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/AccordionGroup/AccordionContext.d.ts +3 -3
- package/dist/components/AccordionGroup/types.d.ts +1 -1
- package/dist/components/Badge/helpers.d.ts +2 -2
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Button/ButtonText.d.ts +6 -6
- package/dist/components/Button/fixtures.d.ts +6 -6
- package/dist/components/Button/helpers.d.ts +2 -2
- package/dist/components/Button/types.d.ts +5 -5
- package/dist/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/components/Checkbox/CheckboxBase.d.ts +2 -2
- package/dist/components/Checkbox/types.d.ts +2 -2
- package/dist/components/Dropdown/Dropdown.d.ts +3 -3
- package/dist/components/Dropdown/types.d.ts +3 -3
- package/dist/components/DropdownOption/DropdownOption.d.ts +2 -2
- package/dist/components/DropdownOptions/DropdownOptions.d.ts +2 -2
- package/dist/components/DropdownOptions/index.d.ts +1 -1
- package/dist/components/DropdownOptions/types.d.ts +2 -2
- package/dist/components/DropdownToggle/DropdownToggle.d.ts +3 -3
- package/dist/components/DropdownToggle/types.d.ts +1 -1
- package/dist/components/FormCheckbox/FormCheckbox.d.ts +2 -2
- package/dist/components/FormCheckbox/types.d.ts +2 -2
- package/dist/components/FormHelperText/FormHelperText.d.ts +2 -2
- package/dist/components/FormHelperText/types.d.ts +1 -1
- package/dist/components/FormRadioGroup/FormRadioGroup.d.ts +2 -2
- package/dist/components/FormRadioGroup/types.d.ts +2 -2
- package/dist/components/Icon/types.d.ts +2 -2
- package/dist/components/LargeTab/LargeTab.d.ts +2 -2
- package/dist/components/LargeTab/LargeTabBase.d.ts +2 -2
- package/dist/components/MultipleDropdown/MultipleDropdown.context.d.ts +3 -3
- package/dist/components/MultipleDropdown/MultipleDropdown.d.ts +3 -3
- package/dist/components/MultipleDropdown/types.d.ts +3 -3
- package/dist/components/MultipleDropdown/utils.d.ts +2 -2
- package/dist/components/MultipleDropdownOptions/MultipleDropdownOptions.d.ts +2 -2
- package/dist/components/MultipleDropdownOptions/index.d.ts +1 -1
- package/dist/components/MultipleDropdownOptions/types.d.ts +2 -2
- package/dist/components/Popover/PopoverTrigger.d.ts +2 -2
- package/dist/components/Radio/Radio.d.ts +2 -2
- package/dist/components/Radio/types.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
- package/dist/components/RadioGroup/types.d.ts +3 -3
- package/dist/components/ResponsiveImage/ResponsiveImage.d.ts +2 -2
- package/dist/components/ResponsiveImage/types.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +2 -2
- package/dist/components/Switch/SwitchContext.d.ts +3 -3
- package/dist/components/Switch/types.d.ts +1 -1
- package/dist/components/Tab/Tab.d.ts +2 -2
- package/dist/components/Tab/TabBase.d.ts +2 -2
- package/dist/components/TabBar/TabBar.d.ts +2 -2
- package/dist/components/TabBar/TabBarContext.d.ts +4 -4
- package/dist/components/TabBar/stories/helpers.d.ts +2 -2
- package/dist/components/TabBar/types.d.ts +9 -11
- package/dist/components/Tooltip/ProgressChartTooltip.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.d.ts +2 -2
- package/dist/components/Tooltip/types.d.ts +11 -11
- package/dist/components/Tooltip/utils.d.ts +2 -2
- package/dist/components/TooltipContent/TooltipContent.d.ts +2 -2
- package/dist/components/TooltipTrigger/TooltipTrigger.d.ts +2 -2
- package/dist/components/WithVisibleLG/WithVisibleLG.d.ts +10 -0
- package/dist/components/WithVisibleLG/index.d.ts +1 -0
- package/dist/components/WithVisibleMD/WithVisibleMD.d.ts +6 -0
- package/dist/components/WithVisibleMD/index.d.ts +1 -0
- package/dist/components/WithVisibleSM/WithVisibleSM.d.ts +6 -0
- package/dist/components/WithVisibleSM/index.d.ts +1 -0
- package/dist/components/WithVisibleUpToLG/WithVisibleUpToLG.d.ts +6 -0
- package/dist/components/WithVisibleUpToLG/index.d.ts +1 -0
- package/dist/components/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/AccordionGroup/AccordionContext.tsx +4 -4
- package/src/components/AccordionGroup/types.ts +1 -1
- package/src/components/Badge/helpers.ts +18 -16
- package/src/components/Button/Button.spec.tsx +8 -8
- package/src/components/Button/Button.tsx +3 -3
- package/src/components/Button/ButtonText.tsx +6 -6
- package/src/components/Button/fixtures.ts +14 -14
- package/src/components/Button/helpers.ts +2 -2
- package/src/components/Button/types.ts +5 -5
- package/src/components/Checkbox/Checkbox.spec.tsx +2 -2
- package/src/components/Checkbox/Checkbox.stories.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +2 -2
- package/src/components/Checkbox/CheckboxBase.tsx +2 -2
- package/src/components/Checkbox/types.ts +2 -2
- package/src/components/Dropdown/Dropdown.stories.tsx +3 -3
- package/src/components/Dropdown/Dropdown.tsx +4 -4
- package/src/components/Dropdown/types.ts +4 -3
- package/src/components/DropdownOption/DropdownOption.tsx +2 -2
- package/src/components/DropdownOptions/DropdownOptions.tsx +2 -2
- package/src/components/DropdownOptions/index.ts +1 -1
- package/src/components/DropdownOptions/types.ts +2 -2
- package/src/components/DropdownToggle/DropdownToggle.tsx +3 -3
- package/src/components/DropdownToggle/types.ts +1 -1
- package/src/components/FormCheckbox/FormCheckbox.tsx +2 -2
- package/src/components/FormCheckbox/types.ts +3 -3
- package/src/components/FormHelperText/FormHelperText.tsx +2 -2
- package/src/components/FormHelperText/types.ts +1 -1
- package/src/components/FormRadioGroup/FormRadioGroup.stories.tsx +2 -2
- package/src/components/FormRadioGroup/FormRadioGroup.tsx +2 -2
- package/src/components/FormRadioGroup/types.ts +3 -3
- package/src/components/Icon/Icons.spec.tsx +6 -6
- package/src/components/Icon/icons/index.tsx +3 -3
- package/src/components/Icon/types.ts +2 -2
- package/src/components/LargeTab/LargeTab.tsx +2 -2
- package/src/components/LargeTab/LargeTabBase.tsx +2 -2
- package/src/components/MultipleDropdown/MultipleDropdown.context.ts +3 -3
- package/src/components/MultipleDropdown/MultipleDropdown.tsx +7 -7
- package/src/components/MultipleDropdown/types.ts +3 -3
- package/src/components/MultipleDropdown/utils.ts +2 -2
- package/src/components/MultipleDropdownOptions/MultipleDropdownOptions.tsx +2 -2
- package/src/components/MultipleDropdownOptions/index.ts +1 -1
- package/src/components/MultipleDropdownOptions/types.ts +2 -2
- package/src/components/Popover/PopoverTrigger.tsx +3 -3
- package/src/components/Radio/Radio.tsx +2 -2
- package/src/components/Radio/types.ts +1 -1
- package/src/components/RadioGroup/RadioGroup.tsx +2 -2
- package/src/components/RadioGroup/types.ts +3 -3
- package/src/components/ResponsiveImage/ResponsiveImage.tsx +2 -2
- package/src/components/ResponsiveImage/types.ts +1 -1
- package/src/components/Switch/Switch.tsx +2 -2
- package/src/components/Switch/SwitchContext.tsx +2 -2
- package/src/components/Switch/types.ts +1 -1
- package/src/components/Tab/Tab.tsx +2 -2
- package/src/components/Tab/TabBase.tsx +2 -3
- package/src/components/TabBar/TabBar.spec.tsx +5 -5
- package/src/components/TabBar/TabBar.tsx +2 -2
- package/src/components/TabBar/TabBarContext.tsx +6 -6
- package/src/components/TabBar/stories/helpers.tsx +4 -4
- package/src/components/TabBar/types.ts +9 -12
- package/src/components/Tooltip/ProgressChartTooltip.tsx +2 -2
- package/src/components/Tooltip/Tooltip.tsx +2 -2
- package/src/components/Tooltip/types.ts +11 -11
- package/src/components/Tooltip/utils.tsx +2 -2
- package/src/components/TooltipContent/TooltipContent.tsx +2 -2
- package/src/components/TooltipTrigger/TooltipTrigger.tsx +2 -2
- package/src/components/WithVisibleLG/WithVisibleLG.spec.tsx +27 -0
- package/src/components/WithVisibleLG/WithVisibleLG.tsx +22 -0
- package/src/components/WithVisibleLG/index.ts +1 -0
- package/src/components/WithVisibleMD/WithVisibleMD.spec.tsx +27 -0
- package/src/components/WithVisibleMD/WithVisibleMD.tsx +23 -0
- package/src/components/WithVisibleMD/index.ts +1 -0
- package/src/components/WithVisibleSM/WithVisibleSM.spec.tsx +27 -0
- package/src/components/WithVisibleSM/WithVisibleSM.tsx +22 -0
- package/src/components/WithVisibleSM/index.ts +1 -0
- package/src/components/WithVisibleUpToLG/WithVisibleUpToLG.spec.tsx +27 -0
- package/src/components/WithVisibleUpToLG/WithVisibleUpToLG.tsx +24 -0
- package/src/components/WithVisibleUpToLG/index.ts +1 -0
- package/src/components/index.ts +5 -1
- package/tsbuildcache +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTooltip } from './useTooltip';
|
|
2
2
|
import { TooltipContext } from './useTooltipContext';
|
|
3
|
-
import {
|
|
3
|
+
import { TooltipProps } from './types';
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* <Tooltip>
|
|
@@ -10,7 +10,7 @@ import { ITooltipProps } from './types';
|
|
|
10
10
|
* <TooltipContent>Tooltip</TooltipContent>
|
|
11
11
|
* </Tooltip>
|
|
12
12
|
* */
|
|
13
|
-
const Tooltip = ({ children, ...props }:
|
|
13
|
+
const Tooltip = ({ children, ...props }: TooltipProps) => {
|
|
14
14
|
const tooltip = useTooltip(props);
|
|
15
15
|
|
|
16
16
|
return (
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
UseFloatingReturn,
|
|
6
6
|
} from '@floating-ui/react';
|
|
7
7
|
import { PointTooltipProps, Point } from '@nivo/line';
|
|
8
|
-
import {
|
|
8
|
+
import { MapIconsType } from '@components/Icon/types';
|
|
9
9
|
import { ProgressBarProps } from '@components/ProgressBar/types';
|
|
10
10
|
import { SerializedStyles } from '@emotion/react';
|
|
11
11
|
import { CommonProps } from '@global-types/emotion';
|
|
12
12
|
|
|
13
13
|
export type TooltipSize = 'small' | 'medium' | 'large';
|
|
14
14
|
|
|
15
|
-
export interface
|
|
15
|
+
export interface TooltipProps extends CommonProps {
|
|
16
16
|
children: React.ReactNode;
|
|
17
17
|
placement?: Placement;
|
|
18
18
|
enableHover?: boolean;
|
|
@@ -25,7 +25,7 @@ export interface ITooltipProps extends CommonProps {
|
|
|
25
25
|
isOpen?: boolean;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export type UseTooltipArgs = Omit<
|
|
28
|
+
export type UseTooltipArgs = Omit<TooltipProps, 'children'>;
|
|
29
29
|
|
|
30
30
|
type UseInteractions = ReturnType<typeof useInteractions>;
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ interface MutableRefObject<T> {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export type UseTooltip = (props: UseTooltipArgs) => Pick<
|
|
37
|
-
|
|
37
|
+
TooltipProps,
|
|
38
38
|
'size' | 'hasArrow' | 'arrowProps'
|
|
39
39
|
> & {
|
|
40
40
|
arrowRef: MutableRefObject<null>;
|
|
@@ -47,7 +47,7 @@ export type TooltipContextType =
|
|
|
47
47
|
ReturnType<typeof useInteractions> & {
|
|
48
48
|
isOpen: boolean;
|
|
49
49
|
arrowRef: React.Ref<SVGSVGElement>;
|
|
50
|
-
} & Pick<
|
|
50
|
+
} & Pick<TooltipProps, 'size' | 'hasArrow' | 'arrowProps'>)
|
|
51
51
|
| null;
|
|
52
52
|
|
|
53
53
|
export type TooltipArrowProps = Omit<
|
|
@@ -55,33 +55,33 @@ export type TooltipArrowProps = Omit<
|
|
|
55
55
|
'context'
|
|
56
56
|
>;
|
|
57
57
|
|
|
58
|
-
export interface
|
|
58
|
+
export interface TooltipContentProps {
|
|
59
59
|
children: React.ReactNode;
|
|
60
60
|
className?: string;
|
|
61
61
|
style?: React.CSSProperties;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export interface
|
|
64
|
+
export interface TooltipContentSizes {
|
|
65
65
|
small: SerializedStyles;
|
|
66
66
|
medium: SerializedStyles;
|
|
67
67
|
large: SerializedStyles;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export interface
|
|
70
|
+
export interface TooltipTriggerProps {
|
|
71
71
|
children: React.ReactNode;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export type SimpleChartTooltipProps =
|
|
75
75
|
| PointTooltipProps &
|
|
76
|
-
Pick<
|
|
76
|
+
Pick<TooltipProps, 'size'> & {
|
|
77
77
|
renderValue?: (data: Point['data']) => React.ReactNode;
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
export interface
|
|
80
|
+
export interface ProgressChartTooltipProps {
|
|
81
81
|
caption: string;
|
|
82
82
|
value: number;
|
|
83
83
|
valueFormatted: string;
|
|
84
|
-
iconName?: keyof
|
|
84
|
+
iconName?: keyof MapIconsType;
|
|
85
85
|
barProps?: Partial<Omit<ProgressBarProps, 'currentValue'>>;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TooltipContentSizes } from './types';
|
|
2
2
|
import { small, medium, large } from './styles';
|
|
3
3
|
|
|
4
|
-
export const mapSizes:
|
|
4
|
+
export const mapSizes: TooltipContentSizes = {
|
|
5
5
|
small,
|
|
6
6
|
medium,
|
|
7
7
|
large,
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import { TooltipArrow } from '@components/Tooltip/TooltipArrow';
|
|
9
9
|
import { TooltipContentBase } from '@components/Tooltip/TooltipContentBase';
|
|
10
|
-
import {
|
|
10
|
+
import { TooltipContentProps, TooltipSize } from '@components/Tooltip/types';
|
|
11
11
|
import { useTooltipContext } from '@components/Tooltip/useTooltipContext';
|
|
12
12
|
import { mapSizes } from '@components/Tooltip/utils';
|
|
13
13
|
|
|
14
|
-
const TooltipContent = forwardRef<HTMLDivElement,
|
|
14
|
+
const TooltipContent = forwardRef<HTMLDivElement, TooltipContentProps>(
|
|
15
15
|
function TooltipContent({ children, className, style }, refProp) {
|
|
16
16
|
const tooltipCtx = useTooltipContext();
|
|
17
17
|
const ref = useMergeRefs([tooltipCtx?.refs.setFloating, refProp]);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cloneElement, isValidElement } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { TooltipTriggerProps } from '@components/Tooltip/types';
|
|
4
4
|
import { useTooltipContext } from '@components/Tooltip/useTooltipContext';
|
|
5
5
|
|
|
6
|
-
const TooltipTrigger = ({ children }:
|
|
6
|
+
const TooltipTrigger = ({ children }: TooltipTriggerProps) => {
|
|
7
7
|
const tooltipCtx = useTooltipContext();
|
|
8
8
|
|
|
9
9
|
if (isValidElement(children)) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { ThemeProvider } from '@emotion/react';
|
|
4
|
+
import { WithVisibleLG } from '.';
|
|
5
|
+
import { mainTheme } from '../..';
|
|
6
|
+
|
|
7
|
+
jest.mock('d3-color', () => ({}));
|
|
8
|
+
|
|
9
|
+
const TestComponent = () => {
|
|
10
|
+
return <p>Test</p>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const TestComponentWithVisible = WithVisibleLG(TestComponent);
|
|
14
|
+
|
|
15
|
+
describe('HOC: withVisibleLG', () => {
|
|
16
|
+
// TODO: additional test to test display: block
|
|
17
|
+
it('Should not displayed (less than LG)', () => {
|
|
18
|
+
render(
|
|
19
|
+
<ThemeProvider theme={mainTheme}>
|
|
20
|
+
<TestComponentWithVisible />
|
|
21
|
+
</ThemeProvider>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const wrapper = screen.getByTestId('with-visible-lg');
|
|
25
|
+
expect(wrapper).toHaveStyle('display: none');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
|
|
3
|
+
const VisibleLG = styled.div`
|
|
4
|
+
display: none;
|
|
5
|
+
${({ theme }) => theme.mediaQueries.lg} {
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
export const WithVisibleLG = <T extends object>(
|
|
11
|
+
Component: React.ComponentType<T>,
|
|
12
|
+
rest?: Parameters<typeof VisibleLG>[0],
|
|
13
|
+
) => {
|
|
14
|
+
const decoratedComp = (props: T) => (
|
|
15
|
+
<VisibleLG data-testid="with-visible-lg" {...rest}>
|
|
16
|
+
<Component {...props} />
|
|
17
|
+
</VisibleLG>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
decoratedComp.displayName = `WithVisibleLG(${Component.displayName})`;
|
|
21
|
+
return decoratedComp;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithVisibleLG';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { ThemeProvider } from '@emotion/react';
|
|
4
|
+
import { WithVisibleMD } from '.';
|
|
5
|
+
import { mainTheme } from '../..';
|
|
6
|
+
|
|
7
|
+
jest.mock('d3-color', () => ({}));
|
|
8
|
+
|
|
9
|
+
const TestComponent = () => {
|
|
10
|
+
return <p>Test</p>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const TestComponentWithVisible = WithVisibleMD(TestComponent);
|
|
14
|
+
|
|
15
|
+
describe('HOC: WithVisibleMD', () => {
|
|
16
|
+
// TODO: additional test to test display: block
|
|
17
|
+
it('Should not displayed (less than MD)', () => {
|
|
18
|
+
render(
|
|
19
|
+
<ThemeProvider theme={mainTheme}>
|
|
20
|
+
<TestComponentWithVisible />
|
|
21
|
+
</ThemeProvider>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const wrapper = screen.getByTestId('with-visible-md');
|
|
25
|
+
expect(wrapper).toHaveStyle('display: none');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
|
|
4
|
+
const VisibleMD = styled.div`
|
|
5
|
+
display: none;
|
|
6
|
+
${({ theme }) => theme.mediaQueries.md} {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const WithVisibleMD = <T extends object>(
|
|
12
|
+
Component: React.ComponentType<T>,
|
|
13
|
+
styles?: SerializedStyles,
|
|
14
|
+
) => {
|
|
15
|
+
const decoratedComp = (props: T) => (
|
|
16
|
+
<VisibleMD data-testid="with-visible-md" css={styles}>
|
|
17
|
+
<Component {...props} />
|
|
18
|
+
</VisibleMD>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
decoratedComp.displayName = `WithVisibleMD(${Component.displayName})`;
|
|
22
|
+
return decoratedComp;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithVisibleMD';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { ThemeProvider } from '@emotion/react';
|
|
4
|
+
import { WithVisibleSM } from '.';
|
|
5
|
+
import { mainTheme } from '../..';
|
|
6
|
+
|
|
7
|
+
jest.mock('d3-color', () => ({}));
|
|
8
|
+
|
|
9
|
+
const TestComponent = () => {
|
|
10
|
+
return <p>Test</p>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const TestComponentWithVisible = WithVisibleSM(TestComponent);
|
|
14
|
+
|
|
15
|
+
describe('HOC: WithVisibleSM', () => {
|
|
16
|
+
// TODO: additional test to test display: none
|
|
17
|
+
it('Should be displayed', () => {
|
|
18
|
+
render(
|
|
19
|
+
<ThemeProvider theme={mainTheme}>
|
|
20
|
+
<TestComponentWithVisible />
|
|
21
|
+
</ThemeProvider>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const wrapper = screen.getByTestId('with-visible-sm');
|
|
25
|
+
expect(wrapper).toHaveStyle('display: block');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
|
|
4
|
+
const VisibleSM = styled.div`
|
|
5
|
+
${({ theme }) => theme.mediaQueries.md} {
|
|
6
|
+
display: none;
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
export const WithVisibleSM = <T extends object>(
|
|
11
|
+
Component: React.ComponentType<T>,
|
|
12
|
+
styles?: SerializedStyles,
|
|
13
|
+
) => {
|
|
14
|
+
const decoratedComp = (props: T) => (
|
|
15
|
+
<VisibleSM data-testid="with-visible-sm" css={styles}>
|
|
16
|
+
<Component {...props} />
|
|
17
|
+
</VisibleSM>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
decoratedComp.displayName = `WithVisibleSM(${Component.displayName})`;
|
|
21
|
+
return decoratedComp;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithVisibleSM';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { ThemeProvider } from '@emotion/react';
|
|
4
|
+
import { WithVisibleUpToLG } from '.';
|
|
5
|
+
import { mainTheme } from '../..';
|
|
6
|
+
|
|
7
|
+
jest.mock('d3-color', () => ({}));
|
|
8
|
+
|
|
9
|
+
const TestComponent = () => {
|
|
10
|
+
return <p>Test</p>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const TestComponentWithVisible = WithVisibleUpToLG(TestComponent);
|
|
14
|
+
|
|
15
|
+
describe('HOC: WithVisibleUpToLG', () => {
|
|
16
|
+
// TODO: additional test to test display: block
|
|
17
|
+
it('Should not displayed (less than LG)', () => {
|
|
18
|
+
render(
|
|
19
|
+
<ThemeProvider theme={mainTheme}>
|
|
20
|
+
<TestComponentWithVisible />
|
|
21
|
+
</ThemeProvider>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const wrapper = screen.getByTestId('with-visible-up-to-lg');
|
|
25
|
+
expect(wrapper).toHaveStyle('display: none');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
|
|
4
|
+
const VisibleUpToLG = styled.div`
|
|
5
|
+
display: none;
|
|
6
|
+
|
|
7
|
+
@media screen and (max-width: 1439px) {
|
|
8
|
+
display: block;
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const WithVisibleUpToLG = <T extends object>(
|
|
13
|
+
Component: React.ComponentType<T>,
|
|
14
|
+
styles?: SerializedStyles,
|
|
15
|
+
) => {
|
|
16
|
+
const decoratedComp = (props: T) => (
|
|
17
|
+
<VisibleUpToLG data-testid="with-visible-up-to-lg" css={styles}>
|
|
18
|
+
<Component {...props} />
|
|
19
|
+
</VisibleUpToLG>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
decoratedComp.displayName = `WithVisibleUpToLG(${Component.displayName})`;
|
|
23
|
+
return decoratedComp;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithVisibleUpToLG';
|
package/src/components/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { default as DropdownBase } from './DropdownBase';
|
|
|
17
17
|
export { default as DropdownOption } from './DropdownOption';
|
|
18
18
|
export { default as DropdownOptions } from './DropdownOptions';
|
|
19
19
|
export { default as DropdownToggle } from './DropdownToggle';
|
|
20
|
-
export type {
|
|
20
|
+
export type { DropdownOptionProps } from './DropdownOptions';
|
|
21
21
|
export { default as Icon } from './Icon';
|
|
22
22
|
export * from './Icon';
|
|
23
23
|
export * from './Icon/types';
|
|
@@ -80,3 +80,7 @@ export { default as FormHelperText } from './FormHelperText';
|
|
|
80
80
|
export { default as Indicator } from './Indicator';
|
|
81
81
|
export * from './ButtonGroup';
|
|
82
82
|
export { default as Link } from './Link';
|
|
83
|
+
export * from './WithVisibleLG';
|
|
84
|
+
export * from './WithVisibleMD';
|
|
85
|
+
export * from './WithVisibleSM';
|
|
86
|
+
export * from './WithVisibleUpToLG';
|