Support drag-and-drop file publishing #4170

Merged
btzr-io merged 14 commits from drag-drop into master 2020-05-25 16:27:37 +02:00
3 changed files with 19 additions and 50 deletions
Showing only changes of commit 5e5ce1296b - Show all commits

View file

@ -1,8 +1,5 @@
// @flow
import React from 'react';
import * as ICONS from 'constants/icons';
import Icon from 'component/common/icon';
import classnames from 'classnames';
import { useRadioState, Radio, RadioGroup } from 'reakit/Radio';
type Props = {
@ -10,6 +7,19 @@ type Props = {
onChange: (WebFile | void) => void,
};
type RadioProps = {
id: string,
label: string,
};
// Same as FormField type="radio" but it works with reakit:
const ForwardedRadio = React.forwardRef((props: RadioProps, ref) => (
<span className="radio">
<input {...props} type="radio" ref={ref} />
<label htmlFor={props.id}>{props.label}</label>
</span>
));
function FileList(props: Props) {
const { files, onChange } = props;
const radio = useRadioState();
@ -53,17 +63,8 @@ function FileList(props: Props) {
return (
<div className={'file-list'}>
<RadioGroup {...radio} aria-label="files">
neb-b commented 2020-05-15 17:36:05 +02:00 (Migrated from github.com)
Review

I would like avoid creating another radio button style. Can you use the current radio buttons? Or update <FormField type="radio" /> (And maybe creating <FormFieldRadioGroup />)

I would like avoid creating another radio button style. Can you use the current radio buttons? Or update `<FormField type="radio" />` (And maybe creating `<FormFieldRadioGroup />`)
btzr-io commented 2020-05-17 22:54:51 +02:00 (Migrated from github.com)
Review

Where are the radio styles? I can't find it

Where are the radio styles? I can't find it
btzr-io commented 2020-05-18 01:18:50 +02:00 (Migrated from github.com)
Review

I can't use the current FormField component with reakit, but now it has the same styles

I can't use the current `FormField` component with `reakit`, but now it has the same styles
{files.map((entry, index) => {
const item = radio.stops[index];
const selected = item && item.id === radio.currentId;
return (
<label key={entry.name} className={classnames(selected && 'selected')}>
<Radio {...radio} value={entry.name} />
<Icon size={18} selected={selected} icon={selected ? ICONS.COMPLETED : ICONS.CIRCLE} />
<span>{entry.name}</span>
</label>
);
{files.map(({ name }) => {
return <Radio key={name} {...radio} value={name} label={name} as={ForwardedRadio} />;
})}
</RadioGroup>
</div>

View file

@ -117,7 +117,7 @@ function FileDrop(props: Props) {
neb-b commented 2020-05-15 17:37:44 +02:00 (Migrated from github.com)
Review

Please wrap this in __()

Please wrap this in `__()`
btzr-io commented 2020-05-18 01:19:54 +02:00 (Migrated from github.com)
Review

ok, done.

ok, done.
neb-b commented 2020-05-15 17:37:44 +02:00 (Migrated from github.com)
Review

Please wrap this in __()

Please wrap this in `__()`
btzr-io commented 2020-05-18 01:19:54 +02:00 (Migrated from github.com)
Review

ok, done.

ok, done.
<div className={classnames('file-drop', show && 'file-drop--show')}>
<div className={classnames('card', 'file-drop__area')}>
<Icon size={64} icon={ICONS.PUBLISH} className={'main-icon'} />
<p>{`Drop here to publish!`} </p>
neb-b commented 2020-05-15 17:37:44 +02:00 (Migrated from github.com)
Review

Please wrap this in __()

Please wrap this in `__()`
btzr-io commented 2020-05-18 01:19:54 +02:00 (Migrated from github.com)
Review

ok, done.

ok, done.
<p>{__(`Drop here to publish!`)} </p>
neb-b commented 2020-05-15 17:37:44 +02:00 (Migrated from github.com)
Review

Please wrap this in __()

Please wrap this in `__()`
btzr-io commented 2020-05-18 01:19:54 +02:00 (Migrated from github.com)
Review

ok, done.

ok, done.
{files && files.length === 1 && <FileList files={files} onChange={handleFileChange} />}
</div>
</div>

neb-b commented 2020-05-15 17:37:44 +02:00 (Migrated from github.com)
Review

Please wrap this in __()

Please wrap this in `__()`
btzr-io commented 2020-05-18 01:19:54 +02:00 (Migrated from github.com)
Review

ok, done.

ok, done.
neb-b commented 2020-05-15 17:37:44 +02:00 (Migrated from github.com)
Review

Please wrap this in __()

Please wrap this in `__()`
btzr-io commented 2020-05-18 01:19:54 +02:00 (Migrated from github.com)
Review

ok, done.

ok, done.

View file

@ -1,38 +1,6 @@
.file-list {
max-height: 200px;
overflow: auto;
width: 100%;
fieldset {
display: flex;
align-items: center;
flex-direction: column;
background: var(--color-menu-background);
label {
margin: 0;
color: inherit;
display: flex;
align-items: center;
padding: var(--spacing-miniscule) var(--spacing-small);
&.selected {
background-color: rgba(10, 10, 10, 0.1);
box-shadow: inset 0 0 0 3px var(--color-focus);
}
.icon {
margin-right: var(--spacing-small);
opacity: 0.64;
}
}
input {
width: 0;
height: 0;
margin: 0;
padding: 0;
opacity: 0;
}
}
overflow: auto;
max-height: 220px;
padding: var(--spacing-small);
}