From 959f576a212be1bb604db6e5a11e664fc486b7e9 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sat, 27 Jun 2020 08:06:16 +0200 Subject: [PATCH] Toggle for file upload (#3060) --- packages/react-params/src/Param/Bytes.tsx | 94 ++++++++++++---------- packages/react-params/src/Param/Option.tsx | 8 +- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/packages/react-params/src/Param/Bytes.tsx b/packages/react-params/src/Param/Bytes.tsx index baadabfc64..0e76d7f881 100644 --- a/packages/react-params/src/Param/Bytes.tsx +++ b/packages/react-params/src/Param/Bytes.tsx @@ -5,20 +5,18 @@ import { Props } from '../types'; import React, { useCallback, useState } from 'react'; +import styled from 'styled-components'; import { Compact } from '@polkadot/types'; -import { Button } from '@polkadot/react-components'; +import { Toggle } from '@polkadot/react-components'; +import { useTranslation } from '../translate'; import BaseBytes from './BaseBytes'; import File from './File'; function Bytes ({ className = '', defaultValue, isDisabled, isError, label, name, onChange, onEnter, onEscape, type, withLabel }: Props): React.ReactElement { + const { t } = useTranslation(); const [isValid, setIsValid] = useState(false); - const [isFileDrop, setIsFileDrop] = useState(false); - - const _toggleFile = useCallback( - (): void => setIsFileDrop(true), - [] - ); + const [isFileDrop, setFileInput] = useState(false); const _onChangeFile = useCallback( (value: Uint8Array): void => { @@ -34,41 +32,53 @@ function Bytes ({ className = '', defaultValue, isDisabled, isError, label, name [onChange] ); - return !isDisabled && isFileDrop - ? ( - - ) - : ( - - {!isDisabled && ( -