Added multiple style props to the button widget: - Button styles - The background colour can change with a hex code - elevation (box-shadow & colour) - There are button variant contained (solid button), outlined (only borders), text (text buttons) - Button can have an end icon or start icon
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import * as React from "react";
|
|
import { ComponentProps } from "components/designSystems/appsmith/BaseComponent";
|
|
import "@uppy/core/dist/style.css";
|
|
import "@uppy/dashboard/dist/style.css";
|
|
import "@uppy/webcam/dist/style.css";
|
|
import { BaseButton } from "components/designSystems/blueprint/ButtonComponent";
|
|
|
|
class FilePickerComponent extends React.Component<
|
|
FilePickerComponentProps,
|
|
FilePickerComponentState
|
|
> {
|
|
constructor(props: FilePickerComponentProps) {
|
|
super(props);
|
|
this.state = {
|
|
isOpen: false,
|
|
};
|
|
}
|
|
|
|
openModal = () => {
|
|
if (!this.props.isDisabled) {
|
|
this.props.uppy.getPlugin("Dashboard").openModal();
|
|
}
|
|
};
|
|
|
|
render() {
|
|
let label = this.props.label;
|
|
if (this.props.files && this.props.files.length) {
|
|
label = `${this.props.files.length} files selected`;
|
|
}
|
|
return (
|
|
<BaseButton
|
|
buttonStyle="PRIMARY"
|
|
disabled={this.props.isDisabled}
|
|
loading={this.props.isLoading}
|
|
onClick={this.openModal}
|
|
text={label}
|
|
/>
|
|
);
|
|
}
|
|
|
|
public closeModal() {
|
|
this.props.uppy.getPlugin("Dashboard").closeModal();
|
|
}
|
|
}
|
|
|
|
export interface FilePickerComponentState {
|
|
isOpen: boolean;
|
|
}
|
|
|
|
export interface FilePickerComponentProps extends ComponentProps {
|
|
label: string;
|
|
uppy: any;
|
|
isLoading: boolean;
|
|
files?: any[];
|
|
}
|
|
|
|
export default FilePickerComponent;
|