Feat/76 Use UI toolkit components for 'jump to block' (#147)

* frontend-monorepo-76 Use UI toolkit components for 'jump to block'

* frontend-monorepo-76 Use UI toolkit components for 'go to party'

* Added reusable component for 'jump to block' and 'go to party'
This commit is contained in:
Sam Keen 2022-03-29 19:08:33 +01:00 committed by GitHub
parent 65bb99ea72
commit 7e3e098ae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 40 deletions

View File

@ -1,6 +1,7 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { Routes } from '../../routes/router-config';
import { JumpTo } from '../jump-to';
export const JumpToBlock = () => {
const navigate = useNavigate();
@ -20,25 +21,13 @@ export const JumpToBlock = () => {
};
return (
<form onSubmit={handleSubmit}>
<label
htmlFor="block-input"
className="block uppercase text-h5 font-bold"
>
Jump to block
</label>
<input
id="block-input"
type="number"
name="blockNumber"
<JumpTo
label="Jump to block"
placeholder="Block number"
className="bg-white-25 border-white border px-8 py-4 placeholder-white-60"
inputId="block-input"
inputType="number"
inputName="blockNumber"
submitHandler={handleSubmit}
/>
<input
className="border-white border px-28 py-4 cursor-pointer"
type="submit"
value="Go"
/>
</form>
);
};

View File

@ -0,0 +1,43 @@
import { HTMLInputTypeAttribute, SyntheticEvent } from 'react';
import { Input, Button } from '@vegaprotocol/ui-toolkit';
interface JumpToProps {
label: string;
placeholder: string;
inputId: string;
inputType: HTMLInputTypeAttribute;
inputName: string;
submitHandler: (arg0: SyntheticEvent) => void;
}
export const JumpTo = ({
label,
placeholder,
inputId,
inputType,
inputName,
submitHandler,
}: JumpToProps) => {
return (
<form onSubmit={submitHandler}>
<label
htmlFor={inputId}
className="block uppercase text-h5 font-bold mb-4"
>
{label}
</label>
<div className="flex">
<Input
id={inputId}
type={inputType}
name={inputName}
placeholder={placeholder}
className="max-w-[200px]"
/>
<Button variant="secondary" type="submit">
Go
</Button>
</div>
</form>
);
};

View File

@ -1,5 +1,6 @@
import React from 'react';
import { RouteTitle } from '../../../components/route-title';
import { JumpTo } from '../../../components/jump-to';
import { useNavigate } from 'react-router-dom';
import { Routes } from '../../router-config';
@ -21,25 +22,14 @@ export const JumpToParty = () => {
}
};
return (
<form onSubmit={handleSubmit}>
<label
htmlFor="block-input"
className="block uppercase text-h5 font-bold"
>
Go to party
</label>
<input
id="block-input"
name="partyId"
<JumpTo
label="Go to party"
placeholder="Party id"
className="bg-white-25 border-white border px-8 py-4 placeholder-white-60"
inputId="party-input"
inputType="text"
inputName="partyId"
submitHandler={handleSubmit}
/>
<input
className="border-white border px-28 py-4 cursor-pointer"
type="submit"
value="Go"
/>
</form>
);
};

View File

@ -60,7 +60,7 @@ export const inputStyle = ({
export const Input = forwardRef<HTMLInputElement, InputProps>(
({ prependIconName, appendIconName, className, ...props }, ref) => {
className = `${className} h-28`;
className = `h-28 ${className}`;
if (prependIconName) {
className += ' pl-28';
}