restructure scm-ui and use ui-components and ui-types

This commit is contained in:
Sebastian Sdorra
2018-09-05 14:32:49 +02:00
parent 6a4f3a8cf6
commit c64a5a74d6
275 changed files with 12693 additions and 11311 deletions

View File

@@ -0,0 +1,11 @@
//@flow
import React from "react";
import Button, { type ButtonProps } from "./Button";
class AddButton extends React.Component<ButtonProps> {
render() {
return <Button color="default" {...this.props} />;
}
}
export default AddButton;

View File

@@ -0,0 +1,69 @@
//@flow
import React from "react";
import classNames from "classnames";
import { Link } from "react-router-dom";
export type ButtonProps = {
label: string,
loading?: boolean,
disabled?: boolean,
action?: (event: Event) => void,
link?: string,
fullWidth?: boolean,
className?: string,
classes: any
};
type Props = ButtonProps & {
type: string,
color: string
};
class Button extends React.Component<Props> {
static defaultProps = {
type: "button",
color: "default"
};
renderButton = () => {
const {
label,
loading,
disabled,
type,
color,
action,
fullWidth,
className
} = this.props;
const loadingClass = loading ? "is-loading" : "";
const fullWidthClass = fullWidth ? "is-fullwidth" : "";
return (
<button
type={type}
disabled={disabled}
onClick={action ? action : (event: Event) => {}}
className={classNames(
"button",
"is-" + color,
loadingClass,
fullWidthClass,
className
)}
>
{label}
</button>
);
};
render() {
const { link } = this.props;
if (link) {
return <Link to={link}>{this.renderButton()}</Link>;
} else {
return this.renderButton();
}
}
}
export default Button;

View File

@@ -0,0 +1,24 @@
//@flow
import React from "react";
import injectSheet from "react-jss";
import AddButton, { type ButtonProps } from "./Button";
import classNames from "classnames";
const styles = {
spacing: {
margin: "1em 0 0 1em"
}
};
class CreateButton extends React.Component<ButtonProps> {
render() {
const { classes } = this.props;
return (
<div className={classNames("is-pulled-right", classes.spacing)}>
<AddButton {...this.props} />
</div>
);
}
}
export default injectSheet(styles)(CreateButton);

View File

@@ -0,0 +1,11 @@
//@flow
import React from "react";
import Button, { type ButtonProps } from "./Button";
class DeleteButton extends React.Component<ButtonProps> {
render() {
return <Button color="warning" {...this.props} />;
}
}
export default DeleteButton;

View File

@@ -0,0 +1,11 @@
//@flow
import React from "react";
import Button, { type ButtonProps } from "./Button";
class EditButton extends React.Component<ButtonProps> {
render() {
return <Button color="default" {...this.props} />;
}
}
export default EditButton;

View File

@@ -0,0 +1,33 @@
//@flow
import React from "react";
import { DeleteButton } from ".";
import classNames from "classnames";
type Props = {
entryname: string,
removeEntry: string => void,
disabled: boolean,
label: string
};
type State = {};
class RemoveEntryOfTableButton extends React.Component<Props, State> {
render() {
const { label, entryname, removeEntry, disabled } = this.props;
return (
<div className={classNames("is-pulled-right")}>
<DeleteButton
label={label}
action={(event: Event) => {
event.preventDefault();
removeEntry(entryname);
}}
disabled={disabled}
/>
</div>
);
}
}
export default RemoveEntryOfTableButton;

View File

@@ -0,0 +1,11 @@
//@flow
import React from "react";
import Button, { type ButtonProps } from "./Button";
class SubmitButton extends React.Component<ButtonProps> {
render() {
return <Button type="submit" color="primary" {...this.props} />;
}
}
export default SubmitButton;

View File

@@ -0,0 +1,10 @@
// @create-index
export { default as AddButton } from "./AddButton.js";
export { default as Button } from "./Button.js";
export { default as CreateButton } from "./CreateButton.js";
export { default as DeleteButton } from "./DeleteButton.js";
export { default as EditButton } from "./EditButton.js";
export { default as RemoveEntryOfTableButton } from "./RemoveEntryOfTableButton.js";
export { default as SubmitButton } from "./SubmitButton.js";