react-feather#Upload TypeScript Examples
The following examples show how to use
react-feather#Upload.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WithdrawModal.tsx From bee-dashboard with BSD 3-Clause "New" or "Revised" License | 6 votes |
export default function WithdrawModal(): ReactElement {
const { beeDebugApi } = useContext(SettingsContext)
return (
<WithdrawDepositModal
successMessage="Successful withdrawal."
errorMessage="Error with withdrawing."
dialogMessage="Specify the amount of BZZ you would like to withdraw from your node."
label="Withdraw"
icon={<Upload size="1rem" />}
min={new BigNumber(0)}
action={(amount: bigint) => {
if (!beeDebugApi) throw new Error('Bee Debug URL is not valid')
return beeDebugApi.withdrawTokens(amount.toString())
}}
/>
)
}
Example #2
Source File: FileInput.tsx From yet-another-generic-startpage with MIT License | 5 votes |
FileInput = ({ label, id, onChange, valid }: FileInputProps) => {
const [dragging, setDragging] = useState(false)
const addDrag = (event: DragEvent<HTMLDivElement>) => {
event.preventDefault()
setDragging(true)
}
const removeDrag = (event: DragEvent<HTMLDivElement>) => {
event.preventDefault()
setDragging(false)
}
const handleDrop = (event: DragEvent<HTMLDivElement>) => {
event.preventDefault()
setDragging(false)
const file = event.dataTransfer.items[0].getAsFile()
if (file) onChange?.(file)
}
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0]
if (file) onChange?.(file)
}
return (
<Wrapper onDrop={handleDrop} onDragOver={addDrag} onDragLeave={removeDrag}>
<HiddenFileInput as="input" type="file" id={id} onChange={handleChange} />
<Label htmlFor={id} valid={valid} dragging={dragging}>
{label} <Upload />
</Label>
</Wrapper>
)
}
Example #3
Source File: routes.ts From Aragorn with MIT License | 5 votes |
routes: Routes = [
{
name: 'dashboard',
path: '/',
component: Dashboard,
icon: Grid
},
{
name: 'uploader',
path: '/uploader',
component: Uploader,
icon: Package
},
{
name: 'profile',
path: '/profile/:id?',
component: Profile,
icon: Box
},
{
name: 'fileManage',
path: '/fileManage/:id?',
component: FileManage,
icon: Server
},
{
name: 'upload',
icon: Upload
},
{
name: 'about',
path: '/about',
component: About,
icon: Info,
isFooter: true
},
{
name: 'setting',
path: '/setting',
component: Setting,
icon: Settings,
isFooter: true
}
]
Example #4
Source File: ImportFeedDialog.tsx From bee-dashboard with BSD 3-Clause "New" or "Revised" License | 4 votes |
export function ImportFeedDialog({ onClose }: Props): ReactElement {
const [textareaValue, setTextareaValue] = useState('')
const [name, setName] = useState('')
const fileInputRef = useRef(null)
const { identities, setIdentities } = useContext(Context)
const { enqueueSnackbar } = useSnackbar()
const classes = useStyles()
async function onImport() {
const feed = await importIdentity(name, textareaValue)
if (feed) {
onFeedReady(feed)
} else {
enqueueSnackbar('Feed is not valid', { variant: 'error' })
}
}
function onUploadIdentityFile() {
if (fileInputRef.current) {
const input = fileInputRef.current as HTMLInputElement
input.click()
}
}
function onIdentityFileSelected(event: React.ChangeEvent<HTMLInputElement>) {
const fileReader = new FileReader()
const file = event.target?.files?.[0]
fileReader.onload = async event => {
const string = event.target?.result
if (string) {
const feed = await importIdentity(name, string as string)
if (feed) {
onFeedReady(feed)
} else {
enqueueSnackbar('Feed is not valid', { variant: 'error' })
}
}
}
if (file) {
fileReader.readAsText(file)
}
}
function onFeedReady(identity: Identity) {
persistIdentity(identities, identity)
setIdentities(identities)
enqueueSnackbar('Feed imported successfully', { variant: 'success' })
onClose()
}
return (
<SwarmDialog>
<input onChange={onIdentityFileSelected} ref={fileInputRef} className={classes.displayNone} type="file" />
<Box mb={4}>
<TitleWithClose onClose={onClose}>Import</TitleWithClose>
</Box>
<Box mb={2}>
<SwarmTextInput label="Identity Name" name="name" onChange={event => setName(event.target.value)} />
</Box>
<Box mb={4}>
<TextareaAutosize
className={classes.textarea}
minRows={5}
onChange={event => setTextareaValue(event.target.value)}
/>
</Box>
<ExpandableListItemActions>
<SwarmButton iconType={Upload} onClick={onUploadIdentityFile}>
Upload Json File
</SwarmButton>
<SwarmButton iconType={Check} onClick={onImport}>
Use Pasted Text
</SwarmButton>
</ExpandableListItemActions>
</SwarmDialog>
)
}