@ssa-ui-kit/core 0.0.26-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssa-ui-kit/core",
3
- "version": "0.0.26-alpha",
3
+ "version": "0.0.27-alpha",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "private": false,
@@ -41,8 +41,8 @@
41
41
  "loose-envify": "^1.4.0",
42
42
  "scheduler": "^0.23.0",
43
43
  "uuid": "^9.0.0",
44
- "@ssa-ui-kit/utils": "^0.0.1-alpha",
45
- "@ssa-ui-kit/hooks": "^0.0.2-alpha"
44
+ "@ssa-ui-kit/hooks": "^0.0.2-alpha",
45
+ "@ssa-ui-kit/utils": "^0.0.1-alpha"
46
46
  },
47
47
  "browserslist": [
48
48
  ">0.1%",
@@ -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';
@@ -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';