Skip to content

Commit

Permalink
add PluginWallet component (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyanB authored Jun 12, 2023
1 parent 4040cef commit e0e5fcb
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/assets/plugins/wallet/walletActive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/assets/plugins/wallet/walletInactive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/components/PluginWallet/PluginWallet.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { PluginWallet } from './PluginWallet';
import WalletActive from '../../assets/plugins/wallet/walletActive.svg';
import WalletInactive from '../../assets/plugins/wallet/walletInactive.svg';

export default { title: 'Components/PluginWallet', component: PluginWallet };

export const _PluginWalletActive = {
render: () => (
<PluginWallet
isActive={true}
title={'Massawallet'}
iconActive={<WalletActive />}
iconInactive={<WalletInactive />}
onClickActive={() => console.log('intall')}
onClickInactive={() => console.log('launch')}
/>
),
};

export const _PluginWalletIncative = {
render: () => (
<PluginWallet
isActive={false}
title={'Massawallet'}
iconActive={<WalletActive />}
iconInactive={<WalletInactive />}
onClickActive={() => console.log('intall')}
onClickInactive={() => console.log('launch')}
/>
),
};
23 changes: 23 additions & 0 deletions src/components/PluginWallet/PluginWallet.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';

import { PluginWallet } from './PluginWallet';

describe('Components | PluginWallet', () => {
test('it should render', () => {
render(
<PluginWallet
isActive={true}
title={'Massawallet'}
iconActive={null}
iconInactive={null}
onClickActive={() => console.log('intall')}
onClickInactive={() => console.log('launch')}
/>,
);

let pluginWallet = screen.getByTestId('pluginWallet');

expect(pluginWallet).toBeInTheDocument();
});
});
95 changes: 95 additions & 0 deletions src/components/PluginWallet/PluginWallet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import React from 'react';

import { ReactNode } from 'react';
import { Button } from '../Button';
import { FiArrowUpRight } from 'react-icons/fi';

export interface PluginWalletProps {
isActive: boolean;
title: string;
iconActive: ReactNode;
iconInactive: ReactNode;
onClickActive: () => void;
onClickInactive: () => void;
}

export interface ActivePluginProps {
title: string;
iconActive: ReactNode;
onClickActive: () => void;
}

export interface InactivePluginProps {
title: string;
iconInactive: ReactNode;
onClickInactive: () => void;
}

export function ActivePlugin(props: ActivePluginProps) {
const { title, iconActive, onClickActive } = props;

return (
<>
{iconActive}
<div className="w-full py-6 text-f-primary bg-secondary flex flex-col items-center">
<div className="w-4/5 px-4 py-2 text-center mas-subtitle min-[450px]:mas-title">
{title}
</div>
<div className="w-4/5 px-4 py-2">
<Button onClick={onClickActive} preIcon={<FiArrowUpRight />}>
Launch
</Button>
</div>
</div>
</>
);
}

export function InactivePlugin(props: InactivePluginProps) {
const { title, iconInactive, onClickInactive } = props;

return (
<>
{iconInactive}
<div className="w-full py-6 text-f-primary bg-secondary flex flex-col items-center">
<div className="w-4/5 px-4 py-2 text-center mas-buttons">
{`${title} is not installed in your station`}
</div>
<div className="w-4/5 px-4 py-2">
<Button onClick={onClickInactive}>Install</Button>
</div>
</div>
</>
);
}

export function PluginWallet(props: PluginWalletProps) {
const {
isActive,
title,
iconActive,
iconInactive,
onClickActive,
onClickInactive,
} = props;

return (
<div data-testid="pluginWallet" className="w-full sm:w-80 flex flex-col">
{isActive ? (
<ActivePlugin
title={title}
iconActive={iconActive}
onClickActive={onClickActive}
/>
) : (
<InactivePlugin
title={title}
iconInactive={iconInactive}
onClickInactive={onClickInactive}
/>
)}
</div>
);
}
1 change: 1 addition & 0 deletions src/components/PluginWallet/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './PluginWallet';

0 comments on commit e0e5fcb

Please sign in to comment.