Skip to content

Commit

Permalink
feat(html): add dropzone component and use it in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inikolova authored and Juveniel committed May 19, 2023
1 parent f2f8a57 commit c34b650
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 29 deletions.
53 changes: 53 additions & 0 deletions packages/html/src/dropzone/dropzone.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Icon } from '../icon';
import { classNames, stateClassNames, States } from '../utils';

export const DROPZONE_CLASSNAME = `k-external-dropzone`;

const states = [
States.hover,
];

export type KendoDropzoneProps = {
icon?: string;
note?: string | boolean;
};

export type KendoDropzoneState = { [K in (typeof states)[number]]?: boolean };

const defaultProps = {
icon: "upload",
note: "Only JPEG, PNG and SVG files are allowed."
};

export const Dropzone = (
props: KendoDropzoneProps &
KendoDropzoneState &
React.HTMLAttributes<HTMLDivElement>
) => {
const {
hover,
icon = defaultProps.icon,
note = defaultProps.note,
...other
} = props;

return (
<div
{...other}
className={classNames(
props.className,
DROPZONE_CLASSNAME,
stateClassNames(DROPZONE_CLASSNAME, {
}), {
"k-external-dropzone-hover": hover
}
)}
>
<div className="k-dropzone-inner">
{icon && <Icon icon={icon} className="k-dropzone-icon" size={"xxxlarge"} />}
<span className="k-dropzone-hint">Drag and drop files here to upload</span>
{note && <span className="k-dropzone-note"> {note} </span>}
</div>
</div>
);
};
1 change: 1 addition & 0 deletions packages/html/src/dropzone/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dropzone.spec';
26 changes: 4 additions & 22 deletions packages/html/src/dropzone/tests/dropzone.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ReactDOM from 'react-dom/client';
import { Icon } from '../../icon';
import { Dropzone } from '../../dropzone';

const root = ReactDOM.createRoot(
document.getElementById('app') as HTMLElement
Expand All @@ -11,37 +11,19 @@ root.render(

<section>
<p>External dropzone</p>
<div className="k-external-dropzone">
<div className="k-dropzone-inner">
<Icon icon="upload" className="k-dropzone-icon" size="xxxlarge" />
<span className="k-dropzone-hint">Drag and drop files here to upload</span>
<span className="k-dropzone-note"> Only JPEG, PNG and SVG files are allowed.</span>
</div>
</div>
<Dropzone />
</section>

<section>
{/* Hover dragging files */}
<p>External dropzone - hover dragging files</p>
<div className="k-external-dropzone k-external-dropzone-hover">
<div className="k-dropzone-inner">
<Icon icon="upload" className="k-dropzone-icon" size="xxxlarge" />
<span className="k-dropzone-hint">Drag and drop files here to upload</span>
<span className="k-dropzone-note"> Only JPEG, PNG and SVG files are allowed.</span>
</div>
</div>
<Dropzone hover />
</section>

<section>
{/* Hight set */}
<p>External dropzone</p>
<div className="k-external-dropzone" style={{ height: "400px" }}>
<div className="k-dropzone-inner">
<Icon icon="upload" className="k-dropzone-icon" size="xxxlarge" />
<span className="k-dropzone-hint">Drag and drop files here to upload</span>
<span className="k-dropzone-note"> Only JPEG, PNG and SVG files are allowed.</span>
</div>
</div>
<Dropzone style={{ height: "400px" }} />
</section>

</div>
Expand Down
9 changes: 2 additions & 7 deletions packages/html/src/pdf-viewer/tests/pdf-viewer-blank-page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ReactDOM from 'react-dom/client';
import { Button } from '../../button';
import { Icon } from '../../icon';
import { Upload } from '../../upload';
import { Toolbar } from '../../toolbar';
import { Pager } from '../../pager';
import { Dropzone } from '../../dropzone';

const root = ReactDOM.createRoot(
document.getElementById('app') as HTMLElement
Expand Down Expand Up @@ -34,12 +34,7 @@ root.render(
<div className="k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto">
<div className="k-pdf-viewer-pages">
<div className="k-page k-blank-page">
<div className="k-external-dropzone">
<div className="k-dropzone-inner">
<Icon icon="upload" className="k-dropzone-icon" size="xxxlarge" />
<span className="k-dropzone-hint">Drag and drop files here to upload</span>
</div>
</div>
<Dropzone note={false}/>
<Upload async empty status="upload"></Upload>
</div>
</div>
Expand Down

0 comments on commit c34b650

Please sign in to comment.