From 5a5ec76eb8d1e3ac6a47a2a5e76ffbe8aa1d4fd5 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 21 Mar 2021 14:50:42 +0100 Subject: [PATCH] Payout button for society (#4890) * Add society payout button * Split kusama design modal * payout tag * Adjust design size --- .../src/Overview/DesignKusama.tsx | 77 +++++++++++++ packages/page-society/src/Overview/Member.tsx | 105 +++++++++--------- packages/page-society/src/draw/canary.ts | 4 +- 3 files changed, 129 insertions(+), 57 deletions(-) create mode 100644 packages/page-society/src/Overview/DesignKusama.tsx diff --git a/packages/page-society/src/Overview/DesignKusama.tsx b/packages/page-society/src/Overview/DesignKusama.tsx new file mode 100644 index 0000000000..c09a303e27 --- /dev/null +++ b/packages/page-society/src/Overview/DesignKusama.tsx @@ -0,0 +1,77 @@ +// Copyright 2017-2021 @polkadot/app-society authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { AccountId } from '@polkadot/types/interfaces'; + +import React, { useEffect, useRef, useState } from 'react'; + +import { KUSAMA_GENESIS } from '@polkadot/apps-config'; +import { Button, Modal } from '@polkadot/react-components'; +import { useApi, useToggle } from '@polkadot/react-hooks'; + +import drawCanary, { PADD, SIZE } from '../draw/canary'; +import { useTranslation } from '../translate'; + +interface Props { + accountId: AccountId; +} + +const CANVAS_STYLE = { + display: 'block', + margin: '0 auto' +}; + +const HEIGHT = (SIZE * 2) + (PADD * 1); +const WIDTH = (SIZE * 3) + (PADD * 2); + +function DesignKusama ({ accountId }: Props): React.ReactElement | null { + const { t } = useTranslation(); + const { api } = useApi(); + const canvasRef = useRef(null); + const [onKusama] = useState(() => api.genesisHash.eq(KUSAMA_GENESIS)); + const [isShowing, toggleDesign] = useToggle(); + + useEffect((): void => { + if (canvasRef.current) { + const ctx = canvasRef.current.getContext('2d'); + + if (ctx) { + drawCanary(ctx, accountId); + } + } + }); + + if (!onKusama) { + return null; + } + + return ( + <> +