Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add chip component
dominik-zeglen77e67f4504ed
diff --git a/saleor/static/dashboard-next/components/Chip/Chip.tsx b/saleor/static/dashboard-next/components/Chip/Chip.tsxnew file mode 100644index 0000000000..f003b16b0a--- /dev/null+++ b/saleor/static/dashboard-next/components/Chip/Chip.tsx@@ -0,0 +1,56 @@+import {+ createStyles,+ Theme,+ withStyles,+ WithStyles+} from "@material-ui/core/styles";+import { fade } from "@material-ui/core/styles/colorManipulator";+import Typography from "@material-ui/core/Typography";+import CloseIcon from "@material-ui/icons/Close";+import classNames from "classnames";+import * as React from "react";++export interface ChipProps {+ className?: string;+ label: React.ReactNode;+ onClose?: () => void;+}++const styles = (theme: Theme) =>+ createStyles({+ closeIcon: {+ cursor: "pointer",+ fontSize: 16,+ marginLeft: theme.spacing.unit,+ verticalAlign: "middle"+ },+ label: {+ color: theme.palette.common.white+ },+ root: {+ background: fade(theme.palette.secondary.main, 0.6),+ borderRadius: 8,+ display: "inline-block",+ marginRight: theme.spacing.unit * 2,+ padding: "6px 12px"+ }+ });+const Chip = withStyles(styles, { name: "Chip" })(+ ({+ classes,+ className,+ label,+ onClose+ }: ChipProps & WithStyles<typeof styles>) => (+ <div className={classNames(classes.root, className)}>+ <Typography className={classes.label} variant="caption">+ {label}+ {onClose && (+ <CloseIcon className={classes.closeIcon} onClick={onClose} />+ )}+ </Typography>+ </div>+ )+);+Chip.displayName = "Chip";+export default Chip;diff --git a/saleor/static/dashboard-next/components/Chip/index.ts b/saleor/static/dashboard-next/components/Chip/index.tsnew file mode 100644index 0000000000..6de8518ff9--- /dev/null+++ b/saleor/static/dashboard-next/components/Chip/index.ts@@ -0,0 +1,2 @@+export { default } from './Chip';+export * from './Chip';\ No newline at end of filediff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex 172044633e..9d91fd17b3 100644--- a/saleor/static/dashboard-next/storybook/config.js+++ b/saleor/static/dashboard-next/storybook/config.js@@ -8,6 +8,7 @@ function loadStories() {require("./stories/components/AddressFormatter");require("./stories/components/CardMenu");require("./stories/components/Checkbox");+ require("./stories/components/Chip");require("./stories/components/Date");require("./stories/components/DateTime");require("./stories/components/EditableTableCell");diff --git a/saleor/static/dashboard-next/storybook/stories/components/Chip.tsx b/saleor/static/dashboard-next/storybook/stories/components/Chip.tsxnew file mode 100644index 0000000000..6ad5f40ce4--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/components/Chip.tsx@@ -0,0 +1,16 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import Chip, { ChipProps } from "../../../components/Chip";+import CardDecorator from "../../CardDecorator";+import Decorator from "../../Decorator";++const props: ChipProps = {+ label: "Lorem Ipsum"+};++storiesOf("Generics / Chip", module)+ .addDecorator(CardDecorator)+ .addDecorator(Decorator)+ .add("default", () => <Chip {...props} />)+ .add("with x", () => <Chip {...props} onClose={() => undefined} />);