feat: improve upload flow (#240)
* feat: separate flow for folder and file uploads * feat: add basic index document detection * feat(wip): separate preview step * fix: fix kb and mb units * feat: add post upload summary, add some styling * feat: upload flow * fix: change element order and add conditional rendering * refactor: remove unused variables for now * fix: put back stamp creation to stamp page * refactor: rework postage stamps and grid * feat: add website and folder icons * feat: add asset preview to download flow, add file icon * feat: add basic design to postage stamp selection dialog * feat: add web icon, shorten stamp in preview * feat: extract swarm hash in download flow * fix: extract swarmbutton and solve icon hover and focus color * fix: always show buy button on stamp page * refactor: downgrade * refactor: speed up icon transition * style: improve download buttons * style: change [back to upload] icon * style: add spacing before swarm gateway text * style: post upload summary spacing * refactor: drop verticalspacing and use box * refactor: merge icons to one component * refactor: use conditions instead of weird assignment * docs: explain filter(x => x) * refactor: generalize capacity * refactor: avoid passing arrow functions * refactor: get rid of PaperGridContainer and Container * fix: fix hover color for postage stamps * feat: add disabled and loading state to buttons * fix: make drag and drop work for websites * feat: handle folders and non existing hashes * fix: provide empty default value to select to avoid console warning * style: remove body2 font variants * fix: remove typo * feat: disable folder upload, add website upload * fix: disable showPreviews to avoid flickering * feat(temp): remove folder upload * fix: remove stuck focus on buttons even after rendering different buttons * style: merge hover and focus styles, fix safari text wrap issue * style: remove dropbox outline in safari
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { Button, CircularProgress, createStyles, makeStyles } from '@material-ui/core'
|
||||
import React, { ReactElement } from 'react'
|
||||
import { IconProps } from 'react-feather'
|
||||
|
||||
interface Props {
|
||||
onClick: () => void
|
||||
iconType: React.ComponentType<IconProps>
|
||||
children: string
|
||||
className?: string
|
||||
disabled?: boolean
|
||||
loading?: boolean
|
||||
}
|
||||
|
||||
const useStyles = makeStyles(() =>
|
||||
createStyles({
|
||||
button: {
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
'&:hover, &:focus': {
|
||||
'& svg': {
|
||||
stroke: '#fff',
|
||||
transition: '0.1s',
|
||||
},
|
||||
},
|
||||
},
|
||||
spinnerWrapper: {
|
||||
position: 'absolute',
|
||||
left: '50%',
|
||||
top: '50%',
|
||||
width: '40px',
|
||||
height: '40px',
|
||||
transform: 'translate(-50%, -50%)',
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
export function SwarmButton({ children, onClick, iconType, className, disabled, loading }: Props): ReactElement {
|
||||
const classes = useStyles()
|
||||
|
||||
const icon = React.createElement(iconType, {
|
||||
size: '1.25rem',
|
||||
color: disabled ? 'rgba(0, 0, 0, 0.26)' : '#dd7700',
|
||||
})
|
||||
|
||||
const classNames = className ? [className, classes.button].join(' ') : classes.button
|
||||
|
||||
return (
|
||||
<Button
|
||||
className={classNames}
|
||||
onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
onClick()
|
||||
event.currentTarget.blur()
|
||||
}}
|
||||
variant="contained"
|
||||
startIcon={icon}
|
||||
disabled={disabled}
|
||||
>
|
||||
{children}
|
||||
{loading && (
|
||||
<div className={classes.spinnerWrapper}>
|
||||
<CircularProgress />
|
||||
</div>
|
||||
)}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user