mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Add title option to Button and remove IconButton
This commit is contained in:
@@ -282,26 +282,6 @@ exports[`Storyshots Buttons|EditButton Default 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`Storyshots Buttons|IconButton Default 1`] = `
|
|
||||||
<div
|
|
||||||
className="sc-htoDjs bIDNS"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
className="button is-default"
|
|
||||||
onClick={[Function]}
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="icon is-medium"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
className="fas fa-icons has-text-inherit"
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`Storyshots Buttons|SubmitButton Default 1`] = `
|
exports[`Storyshots Buttons|SubmitButton Default 1`] = `
|
||||||
<div
|
<div
|
||||||
className="sc-htoDjs bIDNS"
|
className="sc-htoDjs bIDNS"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export type ButtonProps = {
|
|||||||
|
|
||||||
type Props = ButtonProps &
|
type Props = ButtonProps &
|
||||||
RouteComponentProps & {
|
RouteComponentProps & {
|
||||||
|
title?: string;
|
||||||
type?: "button" | "submit" | "reset";
|
type?: "button" | "submit" | "reset";
|
||||||
color?: string;
|
color?: string;
|
||||||
};
|
};
|
||||||
@@ -38,7 +39,19 @@ class Button extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { label, loading, disabled, type, color, className, icon, fullWidth, reducedMobile, children } = this.props;
|
const {
|
||||||
|
label,
|
||||||
|
title,
|
||||||
|
loading,
|
||||||
|
disabled,
|
||||||
|
type,
|
||||||
|
color,
|
||||||
|
className,
|
||||||
|
icon,
|
||||||
|
fullWidth,
|
||||||
|
reducedMobile,
|
||||||
|
children
|
||||||
|
} = this.props;
|
||||||
const loadingClass = loading ? "is-loading" : "";
|
const loadingClass = loading ? "is-loading" : "";
|
||||||
const fullWidthClass = fullWidth ? "is-fullwidth" : "";
|
const fullWidthClass = fullWidth ? "is-fullwidth" : "";
|
||||||
const reducedMobileClass = reducedMobile ? "is-reduced-mobile" : "";
|
const reducedMobileClass = reducedMobile ? "is-reduced-mobile" : "";
|
||||||
@@ -46,6 +59,7 @@ class Button extends React.Component<Props> {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type={type}
|
type={type}
|
||||||
|
title={title}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={this.onClick}
|
onClick={this.onClick}
|
||||||
className={classNames("button", "is-" + color, loadingClass, fullWidthClass, reducedMobileClass, className)}
|
className={classNames("button", "is-" + color, loadingClass, fullWidthClass, reducedMobileClass, className)}
|
||||||
@@ -63,6 +77,7 @@ class Button extends React.Component<Props> {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type={type}
|
type={type}
|
||||||
|
title={title}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={this.onClick}
|
onClick={this.onClick}
|
||||||
className={classNames("button", "is-" + color, loadingClass, fullWidthClass, className)}
|
className={classNames("button", "is-" + color, loadingClass, fullWidthClass, className)}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
import React, { MouseEvent } from "react";
|
|
||||||
import { withRouter, RouteComponentProps } from "react-router-dom";
|
|
||||||
import classNames from "classnames";
|
|
||||||
import Icon from "../Icon";
|
|
||||||
|
|
||||||
export type ButtonProps = {
|
|
||||||
icon: string;
|
|
||||||
title?: string;
|
|
||||||
loading?: boolean;
|
|
||||||
disabled?: boolean;
|
|
||||||
action?: (event: MouseEvent) => void;
|
|
||||||
link?: string;
|
|
||||||
className?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Props = ButtonProps &
|
|
||||||
RouteComponentProps & {
|
|
||||||
type?: "button" | "submit" | "reset";
|
|
||||||
color?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
class IconButton extends React.Component<Props> {
|
|
||||||
static defaultProps: Partial<Props> = {
|
|
||||||
type: "button",
|
|
||||||
color: "default"
|
|
||||||
};
|
|
||||||
|
|
||||||
onClick = (event: React.MouseEvent) => {
|
|
||||||
const { action, link, history } = this.props;
|
|
||||||
if (action) {
|
|
||||||
action(event);
|
|
||||||
} else if (link) {
|
|
||||||
history.push(link);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { icon, title, loading, disabled, type, color, className } = this.props;
|
|
||||||
const loadingClass = loading ? "is-loading" : "";
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
className={classNames("button", "is-" + color, loadingClass, className)}
|
|
||||||
title={title}
|
|
||||||
type={type}
|
|
||||||
disabled={disabled}
|
|
||||||
onClick={this.onClick}
|
|
||||||
>
|
|
||||||
<span className="icon is-medium">
|
|
||||||
<Icon name={icon} color="inherit" />
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default withRouter(IconButton);
|
|
||||||
@@ -3,7 +3,6 @@ import Button from "./Button";
|
|||||||
import { storiesOf } from "@storybook/react";
|
import { storiesOf } from "@storybook/react";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { MemoryRouter } from "react-router-dom";
|
import { MemoryRouter } from "react-router-dom";
|
||||||
import IconButton from "./IconButton";
|
|
||||||
import AddButton from "./AddButton";
|
import AddButton from "./AddButton";
|
||||||
import CreateButton from "./CreateButton";
|
import CreateButton from "./CreateButton";
|
||||||
import DeleteButton from "./DeleteButton";
|
import DeleteButton from "./DeleteButton";
|
||||||
@@ -49,7 +48,6 @@ const buttonStory = (name: string, storyFn: () => ReactElement) => {
|
|||||||
.addDecorator(SpacingDecorator)
|
.addDecorator(SpacingDecorator)
|
||||||
.add("Default", storyFn);
|
.add("Default", storyFn);
|
||||||
};
|
};
|
||||||
buttonStory("IconButton", () => <IconButton icon="icons" />);
|
|
||||||
buttonStory("AddButton", () => <AddButton>Add</AddButton>);
|
buttonStory("AddButton", () => <AddButton>Add</AddButton>);
|
||||||
buttonStory("CreateButton", () => <CreateButton>Create</CreateButton>);
|
buttonStory("CreateButton", () => <CreateButton>Create</CreateButton>);
|
||||||
buttonStory("DeleteButton", () => <DeleteButton>Delete</DeleteButton>);
|
buttonStory("DeleteButton", () => <DeleteButton>Delete</DeleteButton>);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
export { default as AddButton } from "./AddButton";
|
export { default as AddButton } from "./AddButton";
|
||||||
export { default as Button } from "./Button";
|
export { default as Button } from "./Button";
|
||||||
export { default as IconButton } from "./IconButton";
|
|
||||||
export { default as CreateButton } from "./CreateButton";
|
export { default as CreateButton } from "./CreateButton";
|
||||||
export { default as DeleteButton } from "./DeleteButton";
|
export { default as DeleteButton } from "./DeleteButton";
|
||||||
export { default as EditButton } from "./EditButton";
|
export { default as EditButton } from "./EditButton";
|
||||||
|
|||||||
Reference in New Issue
Block a user