diff --git a/tools/ui-components/src/container/container.stories.tsx b/tools/ui-components/src/container/container.stories.tsx new file mode 100644 index 00000000000..5452a04c98a --- /dev/null +++ b/tools/ui-components/src/container/container.stories.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { Story } from '@storybook/react'; +import { Container, ContainerProps } from '.'; + +const story = { + title: 'Example/Container', + component: Container +}; + +const Template: Story = args => { + return ( + +

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+

Random text to test the element width

+
+ ); +}; + +export const Default = Template.bind({}); +Default.args = {}; + +export const Fluid = Template.bind({}); +Fluid.args = { + fluid: true +}; + +export default story; diff --git a/tools/ui-components/src/container/container.test.tsx b/tools/ui-components/src/container/container.test.tsx new file mode 100644 index 00000000000..5efbb121f52 --- /dev/null +++ b/tools/ui-components/src/container/container.test.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; + +import { Container } from '.'; + +describe('', () => { + it('remove width when the container is fluid', () => { + render( + Random text to test the element width + ); + expect( + screen.getByText('Random text to test the element width') + ).toHaveClass('mx-auto px-[15px] '); + }); + it('should add className to it', () => { + render( + + Random text to test the element width + + ); + expect( + screen.getByText('Random text to test the element width') + ).toHaveClass( + 'mx-auto px-[15px] my-0 md:w-[750px] min-[992px]:w-[970px] min-[1200px]:w-[1170px] certificate-outer-wrapper' + ); + }); +}); diff --git a/tools/ui-components/src/container/container.tsx b/tools/ui-components/src/container/container.tsx new file mode 100644 index 00000000000..3f1585084f2 --- /dev/null +++ b/tools/ui-components/src/container/container.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import type { ContainerProps } from './types'; + +export const Container = ({ + children, + className, + fluid +}: ContainerProps): JSX.Element => { + let elementClasses = ''; + if (!fluid) { + elementClasses = `my-0 md:w-[750px] min-[992px]:w-[970px] min-[1200px]:w-[1170px]`; + } + + if (!className) { + className = ''; + } + + return ( +
+ {children} +
+ ); +}; diff --git a/tools/ui-components/src/container/index.ts b/tools/ui-components/src/container/index.ts new file mode 100644 index 00000000000..b2cb8411b9a --- /dev/null +++ b/tools/ui-components/src/container/index.ts @@ -0,0 +1,2 @@ +export { Container } from './container'; +export type { ContainerProps } from './types'; diff --git a/tools/ui-components/src/container/types.ts b/tools/ui-components/src/container/types.ts new file mode 100644 index 00000000000..12bab782dce --- /dev/null +++ b/tools/ui-components/src/container/types.ts @@ -0,0 +1,5 @@ +export type ContainerProps = { + children?: React.ReactNode; + className?: string; + fluid?: boolean; +};