Skip to content

Commit

Permalink
add PluginWallet component
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyanB committed Jun 9, 2023
1 parent 36293f7 commit d7fb9fb
Show file tree
Hide file tree
Showing 6 changed files with 152 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={<></>}
iconInactive={<></>}
onClickActive={() => console.log('intall')}
onClickInactive={() => console.log('launch')}
/>,
);

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

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

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

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

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

const argsButtons = {
onClick: isActive ? onClickInactive : onClickActive,
preIcon: isActive ? <FiArrowUpRight /> : null,
};

return (
<div data-testid="pluginWallet" className="w-full sm:w-80 flex flex-col">
{isActive ? iconActive : iconInactive}
<div className="w-full py-6 text-f-primary bg-secondary flex flex-col items-center">
<div
className={`-2/3 px-4 py-2 text-center ${
isActive ? 'mas-title' : 'mas-buttons'
}`}
>
{isActive ? title : `${title} is not installed in your station`}
</div>
<div className="px-4 py-2">
{isActive ? (
<Button {...argsButtons}>Launch</Button>
) : (
<Button {...argsButtons}>Install</Button>
)}
</div>
</div>
</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 d7fb9fb

Please sign in to comment.