UNPKG

@kiwicom/orbit-components

Version:

<div align="center"> <a href="https://orbit.kiwi" target="_blank"> <img alt="orbit-components" src="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components.png" srcset="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components@2x.png 2x"

75 lines (68 loc) 2.18 kB
// @flow import * as React from "react"; import { storiesOf, setAddon } from "@storybook/react"; import { action } from "@storybook/addon-actions"; import styles from "@sambego/storybook-styles"; import chaptersAddon from "react-storybook-addon-chapters"; import { withKnobs, text, select, boolean } from "@storybook/addon-knobs/react"; import * as Icons from "../icons"; import Tile from "./index"; setAddon(chaptersAddon); const getIcons = defaultIcon => select("Icon", [undefined, ...Object.keys(Icons)], defaultIcon); const getIcon = source => Icons[source]; storiesOf("Tile", module) .addDecorator(withKnobs) .addDecorator( styles({ padding: "20px", }), ) .addWithChapters("Default", () => { const title = text("Title", "Urgent information"); return { info: "This is the default configuration of this component.", chapters: [ { sections: [ { sectionFn: () => <Tile onClick={action("clicked")} title={title} />, }, ], }, ], }; }) .addWithChapters("Playground", () => { const href = text("Href", "https://www.kiwi.com/"); const title = text("Title", "Tile with title"); const external = boolean("External", false); const Icon = getIcon(getIcons("Airplane")); const children = text( "Children", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.", ); const dataTest = text("dataTest", "test"); return { info: "This is the default configuration of this component.", chapters: [ { sections: [ { sectionFn: () => ( <Tile href={href} onClick={action("clicked")} icon={Icon && <Icon />} title={title} external={external} dataTest={dataTest} > {children} </Tile> ), }, ], }, ], }; });