Skip to content

Saleor Core: the high performance, composable, headless commerce API.

add basic designe for background and subcategories

Łukasz Szewczyk7b52aff5f8b8
diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx
new file mode 100644
index 0000000000..9deb4f50a0
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx
@@ -0,0 +1,77 @@
+import { withStyles } from "@material-ui/core/styles";
+import * as React from "react";
+
+import Card from "@material-ui/core/Card";
+import Button from "@material-ui/core/Button";
+import CardContent from "@material-ui/core/CardContent";
+import AddPhotoIcon from "@material-ui/icons/AddAPhoto";
+import Typography from "@material-ui/core/Typography";
+
+import CardTitle from "../../../components/CardTitle";
+
+import i18n from "../../../i18n";
+
+interface CategoryBackgroundProps {
+ onImageUpload?(event: React.ChangeEvent<any>);
+ disabled: boolean;
+}
+
+const decorate = withStyles(theme => ({
+ noPhotosIcon: {
+ height: theme.spacing.unit * 8,
+ margin: "0 auto",
+ width: theme.spacing.unit * 8
+ },
+ noPhotosIconContainer: {
+ margin: `${theme.spacing.unit * 5}px 0`,
+ textAlign: "center" as "center"
+ },
+ noPhotosIconText: {
+ fontSize: "1rem",
+ fontWeight: 600 as 600,
+ marginTop: theme.spacing.unit
+ },
+ fileField: {
+ display: "none"
+ }
+}));
+
+export const CategoryBackground = decorate<CategoryBackgroundProps>(
+ ({ classes, onImageUpload, disabled }) => {
+ return (
+ <Card>
+ <CardTitle
+ title={i18n.t("Background image (optional)")}
+ toolbar={
+ <>
+ <Button
+ variant="flat"
+ color="secondary"
+ disabled={disabled}
+ onClick={() => this.upload.click()}
+ >
+ {i18n.t("Upload image")}
+ </Button>
+ <input
+ className={classes.fileField}
+ id="fileUpload"
+ onChange={onImageUpload}
+ type="file"
+ ref={ref => (this.upload = ref)}
+ />
+ </>
+ }
+ />
+ <CardContent>
+ <div className={classes.noPhotosIconContainer}>
+ <AddPhotoIcon className={classes.noPhotosIcon} />
+ <Typography className={classes.noPhotosIconText}>
+ {i18n.t("Drop images to upload")}
+ </Typography>
+ </div>
+ </CardContent>
+ </Card>
+ );
+ }
+);
+export default CategoryBackground;
diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/index.ts b/saleor/static/dashboard-next/categories/components/CategoryBackground/index.ts
new file mode 100644
index 0000000000..f5a59d0a36
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./CategoryBackground";
+export * from "./CategoryBackground";
diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
index 453d6bbe8c..f0bec4554d 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
@@ -4,11 +4,17 @@ import * as React from "react";
import Form from "../../../components/Form";
import Container from "../../../components/Container";
import PageHeader from "../../../components/PageHeader";
-import SeoForm from "../../../components/SeoForm";
import { UserError } from "../../../";
import i18n from "../../../i18n";
-
import CategoryDetailsForm from "../../components/CategoryDetailsForm";
+import SeoForm from "../../../components/SeoForm";
+import CategoryBackground from "../CategoryBackground";
+import CategoryCreateSubcategories from "../CategoryCreateSubcategories";
+
+// import SaveButtonBar from "../../../components/SaveButtonBar/SaveButtonBar";
+// ,{
+// SaveButtonBarState
+// }
interface FormData {
//CategoryDetailsForm
@@ -27,6 +33,7 @@ interface CategoryCreatePageProps {
disabled: boolean;
onSubmit?(data: FormData);
+ onImageUpload?(event: React.ChangeEvent<any>);
}
const decorate = withStyles(theme => ({
@@ -38,12 +45,20 @@ const decorate = withStyles(theme => ({
}));
export const CategoryCreatePage = decorate<CategoryCreatePageProps>(
- ({ classes, header, disabled, onSubmit, errors: userErrors }) => {
+ ({
+ classes,
+ header,
+ disabled,
+ onSubmit,
+ errors: userErrors,
+ onImageUpload
+ }) => {
const initialData: FormData = {
name: "",
description: "",
seoTitle: "",
seoDescription: ""
+ // backgroundImage: ""
};
return (
<Form onSubmit={onSubmit} initial={initialData} errors={userErrors}>
@@ -57,6 +72,11 @@ export const CategoryCreatePage = decorate<CategoryCreatePageProps>(
onChange={change}
errors={errors}
/>
+ <CategoryBackground
+ onImageUpload={onImageUpload}
+ disabled={disabled}
+ />
+ <CategoryCreateSubcategories />
<SeoForm
helperText={i18n.t(
"Add search engine title and description to make this product easier to find"
diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx
new file mode 100644
index 0000000000..457470d66f
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx
@@ -0,0 +1,105 @@
+import { withStyles } from "@material-ui/core/styles";
+import * as React from "react";
+import * as classNames from "classnames";
+
+import Card from "@material-ui/core/Card";
+import Button from "@material-ui/core/Button";
+import CardContent from "@material-ui/core/CardContent";
+import Typography from "@material-ui/core/Typography";
+import TextField from "@material-ui/core/TextField";
+import DeleteIcon from "@material-ui/icons/Delete";
+import IconButton from "@material-ui/core/IconButton";
+import AddIcon from "@material-ui/icons/Add";
+// import CardActions from "@material-ui/core/CardActions";
+
+import CardTitle from "../../../components/CardTitle";
+import Toggle from "../../../components/Toggle";
+// import FormSpacer from "../../../components/FormSpacer";
+
+import i18n from "../../../i18n";
+
+interface CategoryCreateSubcategoriesProps {}
+
+const decorate = withStyles(theme => ({
+ root: {
+ display: "grid",
+ gridColumnGap: theme.spacing.unit * 2 + "px",
+ gridTemplateColumns: "5fr 8fr 0.5fr"
+ },
+ helperText: {
+ marginBottom: theme.spacing.unit * 4
+ },
+ deleteIcon: {
+ justifySelf: "center",
+ alignSelf: "end"
+ },
+ addSubCat: {
+ padding: "0px"
+ },
+ hr: {
+ backgroundColor: "#eaeaea",
+ border: "none",
+ height: 1,
+ marginBottom: theme.spacing.unit,
+ marginTop: theme.spacing.unit * 3
+ }
+}));
+
+export const CategoryCreateSubcategories = decorate<
+ CategoryCreateSubcategoriesProps
+>(({ classes }) => {
+ return (
+ <Toggle>
+ {(toggled, { toggle }) => (
+ <Card>
+ <CardTitle
+ title={i18n.t("Subcategories")}
+ toolbar={
+ <Button
+ color={toggled ? "default" : "secondary"}
+ variant="flat"
+ onClick={toggle}
+ >
+ {toggled ? i18n.t("Cancel") : i18n.t("Add subcategory")}
+ </Button>
+ }
+ />
+ <CardContent>
+ <Typography
+ className={classNames({ [classes.helperText]: toggled })}
+ >
+ {i18n.t("Add subcategories to help you organize your products")}
+ </Typography>
+ {toggled && (
+ <>
+ <div className={classes.root}>
+ <TextField label={i18n.t("Category Name")} />
+ <TextField label={i18n.t("Category Description")} />
+ <IconButton
+ className={classes.deleteIcon}
+ color="secondary"
+ // onClick={onImageDelete}
+ >
+ <DeleteIcon />
+ </IconButton>
+ </div>
+
+ <hr className={classes.hr} />
+
+ <Button
+ variant="flat"
+ color="secondary"
+ className={classes.addSubCat}
+ >
+ {i18n.t("Add subcategory")}
+ <AddIcon />
+ </Button>
+ </>
+ )}
+ </CardContent>
+ </Card>
+ )}
+ </Toggle>
+ );
+});
+export default CategoryCreateSubcategories;
diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/index.ts b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/index.ts
new file mode 100644
index 0000000000..a7a7947bbc
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./CategoryCreateSubcategories";
+export * from "./CategoryCreateSubcategories";