diff --git a/packages/pageheader/README.md b/packages/pageheader/README.md new file mode 100644 index 000000000..9e27520a1 --- /dev/null +++ b/packages/pageheader/README.md @@ -0,0 +1 @@ +# PageHeader diff --git a/packages/pageheader/components/PageHeader.tsx b/packages/pageheader/components/PageHeader.tsx new file mode 100644 index 000000000..b0cbc5038 --- /dev/null +++ b/packages/pageheader/components/PageHeader.tsx @@ -0,0 +1,31 @@ +import * as React from "react"; + +import { default as Breadcrumb } from "../../breadcrumb/components/Breadcrumb"; + +import { flush } from "../../shared/styles/styleUtils"; + +import { style } from "../style"; + +export interface PageHeaderProps { + breadcrumbElements: React.ReactNodeArray; + actions?: Array>; +} + +class PageHeader extends React.PureComponent { + public render() { + const { breadcrumbElements, actions = [] } = this.props; + + return ( +
+ {breadcrumbElements} +
    + {actions.map(action => { + return
  • {action}
  • ; + })} +
+
+ ); + } +} + +export default PageHeader; diff --git a/packages/pageheader/index.ts b/packages/pageheader/index.ts new file mode 100644 index 000000000..4fbd4bf63 --- /dev/null +++ b/packages/pageheader/index.ts @@ -0,0 +1 @@ +export { default as PageHeader } from "./components/PageHeader"; diff --git a/packages/pageheader/stories/PageHeader.stories.tsx b/packages/pageheader/stories/PageHeader.stories.tsx new file mode 100644 index 000000000..47f430add --- /dev/null +++ b/packages/pageheader/stories/PageHeader.stories.tsx @@ -0,0 +1,25 @@ +import * as React from "react"; +import { storiesOf } from "@storybook/react"; +import { withReadme } from "storybook-readme"; + +import { PageHeader } from "../index"; +import { Clickable } from "../../clickable"; + +const readme = require("../README.md"); +const action = () => alert("Action 1 triggered"); + +storiesOf("PageHeader", module) + .addDecorator(withReadme([readme])) + .add("default", () => ( + One, + Two + ]} + actions={[ + +
Action 1
+
+ ]} + /> + )); diff --git a/packages/pageheader/style.ts b/packages/pageheader/style.ts new file mode 100644 index 000000000..8f762ff63 --- /dev/null +++ b/packages/pageheader/style.ts @@ -0,0 +1,6 @@ +import { css } from "emotion"; + +export const style = css` + display: grid; + grid-template-columns: repeat(2, 50%); +`; diff --git a/packages/pageheader/tests/PageHeader.test.tsx b/packages/pageheader/tests/PageHeader.test.tsx new file mode 100644 index 000000000..7a3c221ba --- /dev/null +++ b/packages/pageheader/tests/PageHeader.test.tsx @@ -0,0 +1,29 @@ +import React from "react"; +import { render } from "enzyme"; +import toJSON from "enzyme-to-json"; + +import { PageHeader } from "../"; +import { Clickable } from "../../clickable"; + +describe("PageHeader", () => { + it("default", () => { + const action = () => 1; + expect( + toJSON( + render( + One, + Two + ]} + actions={[ + +
Action 1
+
+ ]} + /> + ) + ) + ).toMatchSnapshot(); + }); +}); diff --git a/packages/pageheader/tests/__snapshots__/PageHeader.test.tsx.snap b/packages/pageheader/tests/__snapshots__/PageHeader.test.tsx.snap new file mode 100644 index 000000000..4b291a281 --- /dev/null +++ b/packages/pageheader/tests/__snapshots__/PageHeader.test.tsx.snap @@ -0,0 +1,31 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PageHeader default 1`] = ` +
+
+ + One + + + Two + +
+
    +
  • +
    + Action 1 +
    +
  • +
+
+`;