Skip to content

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

Improve styling

dominik-zeglen9ef79d3b1703
diff --git a/saleor/static/dashboard-next/components/CountryList/CountryList.tsx b/saleor/static/dashboard-next/components/CountryList/CountryList.tsx
index 6435d37276..9639d6e93a 100644
--- a/saleor/static/dashboard-next/components/CountryList/CountryList.tsx
+++ b/saleor/static/dashboard-next/components/CountryList/CountryList.tsx
@@ -1,5 +1,6 @@
import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card";
+import CardContent from "@material-ui/core/CardContent";
import IconButton from "@material-ui/core/IconButton";
import {
createStyles,
@@ -12,7 +13,7 @@ import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableRow from "@material-ui/core/TableRow";
import ArrowDropDownIcon from "@material-ui/icons/ArrowDropDown";
-import CloseIcon from "@material-ui/icons/Close";
+import DeleteIcon from "@material-ui/icons/Delete";
import classNames from "classnames";
import * as React from "react";
@@ -34,18 +35,45 @@ export interface CountryListProps {
const styles = (theme: Theme) =>
createStyles({
- arrow: {
- marginRight: theme.spacing.unit * 1.5
+ iconCell: {
+ "&:last-child": {
+ paddingRight: 0
+ },
+ width: 48 + theme.spacing.unit / 2
+ },
+ indicator: {
+ color: theme.palette.text.disabled,
+ display: "inline-block",
+ left: 0,
+ marginRight: theme.spacing.unit * 2,
+ position: "absolute"
+ },
+ offsetCell: {
+ "&:first-child": {
+ paddingLeft: theme.spacing.unit * 3
+ },
+ position: "relative"
},
pointer: {
cursor: "pointer"
},
+ root: {
+ "&:last-child": {
+ paddingBottom: 0
+ },
+ paddingTop: 0
+ },
rotate: {
transform: "rotate(180deg)"
},
textRight: {
textAlign: "right"
},
+ toLeft: {
+ "&:first-child": {
+ paddingLeft: 0
+ }
+ },
wideColumn: {
width: "100%"
}
@@ -78,53 +106,77 @@ const CountryList = withStyles(styles, {
</Button>
}
/>
- <Table>
- <TableBody>
- <TableRow className={classes.pointer} onClick={toggleCollapse}>
- <TableCell className={classes.wideColumn}>
- {i18n.t("{{ number }} Countries", {
- context: "number of countries",
- number: maybe(() => countries.length.toString(), "...")
- })}
- </TableCell>
- <TableCell className={classes.textRight}>
- <ArrowDropDownIcon
- className={classNames({
- [classes.arrow]: true,
- [classes.rotate]: !isCollapsed
+ <CardContent className={classes.root}>
+ <Table>
+ <TableBody>
+ <TableRow className={classes.pointer} onClick={toggleCollapse}>
+ <TableCell
+ className={classNames(classes.wideColumn, classes.toLeft)}
+ >
+ {i18n.t("{{ number }} Countries", {
+ context: "number of countries",
+ number: maybe(() => countries.length.toString(), "...")
})}
- />
- </TableCell>
- </TableRow>
- {!isCollapsed &&
- renderCollection(
- countries,
- country => (
- <TableRow key={country ? country.code : "skeleton"}>
- <TableCell>
- {maybe<React.ReactNode>(
- () => country.country,
- <Skeleton />
- )}
- </TableCell>
- <TableCell className={classes.textRight}>
- <IconButton
- disabled={!country || disabled}
- onClick={() => onCountryUnassign(country.code)}
+ </TableCell>
+ <TableCell
+ className={classNames(classes.textRight, classes.iconCell)}
+ >
+ <IconButton>
+ <ArrowDropDownIcon
+ className={classNames({
+ [classes.rotate]: !isCollapsed
+ })}
+ />
+ </IconButton>
+ </TableCell>
+ </TableRow>
+ {!isCollapsed &&
+ renderCollection(
+ countries,
+ (country, countryIndex) => (
+ <TableRow key={country ? country.code : "skeleton"}>
+ <TableCell className={classes.offsetCell}>
+ {maybe<React.ReactNode>(
+ () => (
+ <>
+ {(countryIndex === 0 ||
+ countries[countryIndex].country[0] !==
+ countries[countryIndex - 1].country[0]) && (
+ <span className={classes.indicator}>
+ {country.country[0]}
+ </span>
+ )}
+ {country.country}
+ </>
+ ),
+ <Skeleton />
+ )}
+ </TableCell>
+ <TableCell
+ className={classNames(
+ classes.textRight,
+ classes.iconCell
+ )}
>
- <CloseIcon />
- </IconButton>
- </TableCell>
- </TableRow>
- ),
- () => (
- <TableRow>
- <TableCell colSpan={2}>{emptyText}</TableCell>
- </TableRow>
- )
- )}
- </TableBody>
- </Table>
+ <IconButton
+ color="secondary"
+ disabled={!country || disabled}
+ onClick={() => onCountryUnassign(country.code)}
+ >
+ <DeleteIcon />
+ </IconButton>
+ </TableCell>
+ </TableRow>
+ ),
+ () => (
+ <TableRow>
+ <TableCell colSpan={2}>{emptyText}</TableCell>
+ </TableRow>
+ )
+ )}
+ </TableBody>
+ </Table>
+ </CardContent>
</Card>
)}
</Toggle>