diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 0350b44219..b7852bd927 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -282,6 +282,26 @@ exports[`Storyshots Buttons|EditButton Default 1`] = ` `; +exports[`Storyshots Buttons|IconButton Default 1`] = ` +
+ +
+`; + exports[`Storyshots Buttons|SubmitButton Default 1`] = `
void; + link?: string; + className?: string; +}; + +type Props = ButtonProps & + RouteComponentProps & { + type?: "button" | "submit" | "reset"; + color?: string; + }; + +class IconButton extends React.Component { + static defaultProps: Partial = { + 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 ( + + ); + } +} + +export default withRouter(IconButton); diff --git a/scm-ui/ui-components/src/buttons/index.stories.tsx b/scm-ui/ui-components/src/buttons/index.stories.tsx index acfd513139..4da801f8a1 100644 --- a/scm-ui/ui-components/src/buttons/index.stories.tsx +++ b/scm-ui/ui-components/src/buttons/index.stories.tsx @@ -3,6 +3,7 @@ import Button from "./Button"; import { storiesOf } from "@storybook/react"; import styled from "styled-components"; import { MemoryRouter } from "react-router-dom"; +import IconButton from "./IconButton"; import AddButton from "./AddButton"; import CreateButton from "./CreateButton"; import DeleteButton from "./DeleteButton"; @@ -48,7 +49,7 @@ const buttonStory = (name: string, storyFn: () => ReactElement) => { .addDecorator(SpacingDecorator) .add("Default", storyFn); }; - +buttonStory("IconButton", () => ); buttonStory("AddButton", () => Add); buttonStory("CreateButton", () => Create); buttonStory("DeleteButton", () => Delete); diff --git a/scm-ui/ui-components/src/buttons/index.ts b/scm-ui/ui-components/src/buttons/index.ts index c5d536133f..3bbfd05c4b 100644 --- a/scm-ui/ui-components/src/buttons/index.ts +++ b/scm-ui/ui-components/src/buttons/index.ts @@ -2,6 +2,7 @@ export { default as AddButton } from "./AddButton"; export { default as Button } from "./Button"; +export { default as IconButton } from "./IconButton"; export { default as CreateButton } from "./CreateButton"; export { default as DeleteButton } from "./DeleteButton"; export { default as EditButton } from "./EditButton";