Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move styles to component
Krzysztof Bialoglowicz1000c5a2f2eb
diff --git a/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx b/saleor/static/dashboard-next/components/AppLayout/MenuList.tsxindex 5ff5b7dd94..80cad24ff2 100644--- a/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx+++ b/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx@@ -103,92 +103,6 @@ const styles = (theme: Theme) =>position: "absolute",transition: "opacity 0.2s ease"},- menuListNested: {- "& $menuListItemActive": {- "& $menuListItemText": {- color: theme.palette.primary.main- }- },- "& $menuListItemText": {- textTransform: "none"- },- background: theme.palette.background.paper,- height: "100vh",- position: "absolute",- right: 0,- top: 0,- transition: "right 1s ease",- width: 300,- zIndex: -1- },- menuListNestedClose: {- "& svg": {- fill: theme.palette.primary.main,- left: 7,- position: "relative",- top: -2- },- border: `solid 1px #EAEAEA`,- borderRadius: "100%",- cursor: "pointer",- height: 32,- position: "absolute",- right: 32,- top: 35,- transform: "rotate(180deg)",- width: 32- },- menuListNestedCloseDark: {- border: `solid 1px #252728`- },- menuListNestedHide: {- opacity: 0- },- menuListNestedIcon: {- "& path": {- fill: "initial"- },- "& svg": { height: 32, position: "relative", top: 7, width: 32 }- },- menuListNestedIconDark: {- "& path": {- fill: theme.palette.common.white- }- },- menuListNestedItem: {- "&:hover": {- "& p": {- color: theme.palette.primary.main- }- },- display: "block",- padding: "0px 30px",- textDecoration: "none"- },- menuListNestedOpen: {- [theme.breakpoints.down("sm")]: {- right: 0,- width: drawerWidthExpanded,- zIndex: 2- },- right: -300,- zIndex: -1- },- subHeader: {- borderBottom: "solid 1px #EAEAEA",- margin: "30px",- paddingBottom: 20- },- subHeaderDark: {- borderBottom: "solid 1px #252728"- },- subHeaderTitle: {- [theme.breakpoints.up("md")]: {- paddingLeft: 0- },- display: "inline",- paddingLeft: 10- },subMenu: {padding: "0 15px"},@@ -324,7 +238,6 @@ const MenuList = withStyles(styles, { name: "MenuList" })(</div><MenuNestedactiveItem={activeSubMenu}- classes={classes}closeSubMenu={setActiveSubMenu}menuItem={menuItem}onMenuItemClick={onMenuItemClick}diff --git a/saleor/static/dashboard-next/components/AppLayout/MenuNested.tsx b/saleor/static/dashboard-next/components/AppLayout/MenuNested.tsxindex a9fbefb4d1..1fe571d137 100644--- a/saleor/static/dashboard-next/components/AppLayout/MenuNested.tsx+++ b/saleor/static/dashboard-next/components/AppLayout/MenuNested.tsx@@ -1,4 +1,10 @@import Hidden from "@material-ui/core/Hidden";+import {+ createStyles,+ Theme,+ withStyles,+ WithStyles+} from "@material-ui/core/styles";import Typography from "@material-ui/core/Typography";import classNames from "classnames";import React from "react";@@ -7,29 +13,104 @@ import SVG from "react-inlinesvg";import useTheme from "@saleor/hooks/useTheme";import menuArrowIcon from "../../../images/menu-arrow-icon.svg";import { createHref } from "../../misc";+import { drawerWidthExpanded } from "./consts";import { IActiveSubMenu } from "./MenuList";import { IMenuItem } from "./menuStructure";+const styles = (theme: Theme) =>+ createStyles({+ menuIcon: {+ "& svg": {+ height: 32,+ width: 32+ },+ display: "inline-block",+ position: "relative",+ top: 8+ },+ menuListNested: {+ background: theme.palette.background.paper,+ height: "100vh",+ position: "absolute",+ right: 0,+ top: 0,+ transition: "right 1s ease",+ width: 300,+ zIndex: -1+ },+ menuListNestedClose: {+ "& svg": {+ fill: theme.palette.primary.main,+ left: 7,+ position: "relative",+ top: -2+ },+ border: `solid 1px #EAEAEA`,+ borderRadius: "100%",+ cursor: "pointer",+ height: 32,+ position: "absolute",+ right: 32,+ top: 35,+ transform: "rotate(180deg)",+ width: 32+ },+ menuListNestedCloseDark: {+ border: `solid 1px #252728`+ },+ menuListNestedHide: {+ opacity: 0+ },+ menuListNestedIcon: {+ "& path": {+ fill: "initial"+ },+ "& svg": { height: 32, position: "relative", top: 7, width: 32 }+ },+ menuListNestedIconDark: {+ "& path": {+ fill: theme.palette.common.white+ }+ },+ menuListNestedItem: {+ "&:hover": {+ "& p": {+ color: theme.palette.primary.main+ }+ },+ display: "block",+ padding: "0px 30px",+ textDecoration: "none"+ },+ menuListNestedOpen: {+ [theme.breakpoints.down("sm")]: {+ right: 0,+ width: drawerWidthExpanded,+ zIndex: 2+ },+ right: -300,+ zIndex: -1+ },+ subHeader: {+ borderBottom: "solid 1px #EAEAEA",+ margin: "30px",+ paddingBottom: 20+ },+ subHeaderDark: {+ borderBottom: "solid 1px #252728"+ },+ subHeaderTitle: {+ [theme.breakpoints.up("md")]: {+ paddingLeft: 0+ },+ display: "inline",+ paddingLeft: 10+ }+ });+export interface MenuNestedProps {activeItem: IActiveSubMenu;ariaLabel: string;- classes: Record<- | "menuIcon"- | "menuListItem"- | "menuListItemActive"- | "menuListItemText"- | "menuListNested"- | "menuListNestedClose"- | "menuListNestedCloseDark"- | "menuListNestedIcon"- | "menuListNestedIconDark"- | "menuListNestedItem"- | "menuListNestedOpen"- | "subHeader"- | "subHeaderDark"- | "subHeaderTitle",- string- >;closeSubMenu: ({ isActive, label }: IActiveSubMenu) => void;icon: string;menuItem: IMenuItem;@@ -38,81 +119,85 @@ export interface MenuNestedProps {onMenuItemClick: (url: string, event: React.MouseEvent<any>) => void;}-const MenuNested: React.FC<MenuNestedProps> = ({- activeItem,- ariaLabel,- classes,- closeSubMenu,- icon,- menuItem,- onMenuItemClick,- title-}) => {- const menuItems = menuItem.children;- const { isDark } = useTheme();- const closeMenu = (menuItemUrl, event) => {- onMenuItemClick(menuItemUrl, event);- closeSubMenu({- isActive: false,- label: null- });- event.stopPropagation();- event.preventDefault();- };- return (- <>- <div- className={classNames(classes.menuListNested, {- [classes.menuListNestedOpen]:- activeItem.label === ariaLabel && activeItem.isActive- })}- >- <Typography- className={classNames(classes.subHeader, {- [classes.subHeaderDark]: isDark+const MenuNested = withStyles(styles, { name: "MenuNested" })(+ ({+ activeItem,+ ariaLabel,+ classes,+ closeSubMenu,+ icon,+ menuItem,+ onMenuItemClick,+ title+ }: MenuNestedProps & WithStyles<typeof styles>) => {+ const menuItems = menuItem.children;+ const { isDark } = useTheme();+ const closeMenu = (menuItemUrl, event) => {+ onMenuItemClick(menuItemUrl, event);+ closeSubMenu({+ isActive: false,+ label: null+ });+ event.stopPropagation();+ event.preventDefault();+ };+ return (+ <>+ <div+ className={classNames(classes.menuListNested, {+ [classes.menuListNestedOpen]:+ activeItem.label === ariaLabel && activeItem.isActive})}- variant="h5">- <Hidden mdUp>- <SVG- className={classNames(classes.menuListNestedIcon, {- [classes.menuListNestedIconDark]: isDark- })}- src={icon}- />- </Hidden>- <div className={classes.subHeaderTitle}>{title}</div>- <Hidden mdUp>- <div- className={classNames(classes.menuListNestedClose, {- [classes.menuListNestedCloseDark]: isDark- })}- onClick={() =>- closeSubMenu({- isActive: false,- label: null- })- }- >- <SVG src={menuArrowIcon} />- </div>- </Hidden>- </Typography>- {menuItems.map(item => {- return (- <a- className={classNames(classes.menuListNestedItem)}- href={createHref(item.url)}- onClick={event => closeMenu(item.url, event)}- key={item.label}- >- <SVG className={classes.menuIcon} src={item.icon} />- <Typography aria-label={item.ariaLabel}>{item.label}</Typography>- </a>- );- })}- </div>- </>- );-};+ <Typography+ className={classNames(classes.subHeader, {+ [classes.subHeaderDark]: isDark+ })}+ variant="h5"+ >+ <Hidden mdUp>+ <SVG+ className={classNames(classes.menuListNestedIcon, {+ [classes.menuListNestedIconDark]: isDark+ })}+ src={icon}+ />+ </Hidden>+ <div className={classes.subHeaderTitle}>{title}</div>+ <Hidden mdUp>+ <div+ className={classNames(classes.menuListNestedClose, {+ [classes.menuListNestedCloseDark]: isDark+ })}+ onClick={() =>+ closeSubMenu({+ isActive: false,+ label: null+ })+ }+ >+ <SVG src={menuArrowIcon} />+ </div>+ </Hidden>+ </Typography>+ {menuItems.map(item => {+ return (+ <a+ className={classNames(classes.menuListNestedItem)}+ href={createHref(item.url)}+ onClick={event => closeMenu(item.url, event)}+ key={item.label}+ >+ <SVG className={classes.menuIcon} src={item.icon} />+ <Typography aria-label={item.ariaLabel}>+ {item.label}+ </Typography>+ </a>+ );+ })}+ </div>+ </>+ );+ }+);export default MenuNested;