Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
chore: account comparison block
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhy-Deriv committed Oct 20, 2023
1 parent af65c15 commit 7ce3993
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 1 deletion.
1 change: 1 addition & 0 deletions libs/blocks/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './lib/account-comparison';
export * from './lib/stat';
export * from './lib/navigation';
export * from './lib/navigation/mobile/mobile.nav-toggle';
Expand Down
33 changes: 33 additions & 0 deletions libs/blocks/src/lib/account-comparison/account-comparison.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';

import AccountComparison from '.';
import { Heading } from '@deriv/quill-design';

const Content = () => <Heading.H2>This is a heading content</Heading.H2>;

describe('AccountComparison', () => {
it('renders with correct class names and content', () => {
const className = 'text-heading-h2';
const title = 'This is the title';
const description = 'Description here';

const { getByText } = render(
<AccountComparison
title={title}
description={description}
content={Content}
/>,
);
const titleElement = getByText(title);

//renders with correct classname
expect(titleElement).toHaveClass(className);

//renders with the correct title
expect(getByText(title)).toBeInTheDocument();

//renders with the correct description
expect(getByText(description)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import AccountComparison from '.';

const meta = {
title: 'Blocks/AccountComparison',
component: AccountComparison,
} satisfies Meta<typeof AccountComparison>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
className: '',
title: 'Title here',
description:
'Description goes here description goes here description goes here description goes here',
content: () => (
<img
className="flex w-full flex-1"
src="https://placehold.co/712x200"
alt="Placeholder"
/>
),
},
};
38 changes: 38 additions & 0 deletions libs/blocks/src/lib/account-comparison/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { FluidContainer, Heading, Text, Section } from '@deriv/quill-design';
import clsx from 'clsx';

export interface AccountComparisonProps {
className?: string;
title?: string;
description?: string;
content: React.FC;
}

const AccountComparison = ({
className,
title,
description,
content: Content,
}: AccountComparisonProps) => {
return (
<Section
className={clsx(
'py-general-4xl',
'bg-background-primary-container',
className,
)}
>
<FluidContainer className="flex flex-col items-center gap-gap-xl lg:gap-gap-2xl">
{(title || description) && (
<div className="flex flex-col items-center gap-gap-lg lg:gap-gap-xl">
{title && <Heading.H2>{title}</Heading.H2>}
{description && <Text>{description}</Text>}
</div>
)}
{Content && <Content />}
</FluidContainer>
</Section>
);
};

export default AccountComparison;
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('CardContent', () => {
<CardContentBlock
title={'this is a title'}
description={'this is a description'}
cardsVariant="ContentBottom"
variant="ContentBottom"
cards={cards}
/>,
);
Expand Down

0 comments on commit 7ce3993

Please sign in to comment.