-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(html): add dropzone component and use it in tests
- Loading branch information
Showing
4 changed files
with
60 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './dropzone.spec'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters