Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(producttable): add isvisible/hidden icons #5407

Merged
merged 3 commits into from
Aug 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { Link } from "react-router-dom";
import { formatPriceString, i18next } from "/client/api";
import TableCell from "@material-ui/core/TableCell";
import TableRow from "@material-ui/core/TableRow";
import Checkbox from "@material-ui/core/Checkbox";
import IconButton from "@material-ui/core/IconButton";
import { TableCell, TableRow, Checkbox, IconButton, withStyles } from "@material-ui/core";
import PencilIcon from "mdi-material-ui/Pencil";
import CircleIcon from "mdi-material-ui/CheckboxBlankCircle";

const styles = (theme) => ({
isVisible: {
color: theme.palette.colors.forestGreen300,
fontSize: theme.typography.fontSize * 1.25,
marginRight: theme.spacing(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but if the unit is 1 it's not required.

We should probably make a decision on whether to always use a number, even 1, or leave it blank if it's 1.

Doesn't matter to me either way, and will be a quick find / replace whichever way we decide.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good to know. Add it to your future Spacing docs :)

},
isHidden: {
color: theme.palette.colors.black40,
fontSize: theme.typography.fontSize * 1.25,
marginRight: theme.spacing(1)
}
});

class ProductGridItems extends Component {
static propTypes = {
classes: PropTypes.object,
displayPrice: PropTypes.func,
isSearch: PropTypes.bool,
isSelected: PropTypes.func,
Expand Down Expand Up @@ -69,13 +81,32 @@ class ProductGridItems extends Component {
);
}

renderStatusIcon() {
const { product, classes } = this.props;

if (product.isVisible) {
return (
<div style={{ display: "flex" }}>
<CircleIcon className={classes.isVisible}/>
<span>{i18next.t("admin.tags.visible")}</span>
</div>
);
}

return (
<div style={{ display: "flex" }}>
<CircleIcon className={classes.isHidden}/>
<span>{i18next.t("admin.tags.hidden")}</span>
</div>
);
}

handleSelect = (event) => {
this.props.onSelect(event.target.checked, this.props.product);
}

render() {
const { isSelected, product } = this.props;

const productItem = (
<TableRow className={`product-table-row-item ${isSelected() ? "active" : ""}`}>
<TableCell padding="checkbox">
Expand All @@ -97,7 +128,7 @@ class ProductGridItems extends Component {
{this.renderPublishStatus()}
</TableCell>
<TableCell>
{i18next.t(product.isVisible ? "admin.tags.visible" : "admin.tags.hidden")}
{this.renderStatusIcon()}
</TableCell>
<TableCell padding="checkbox">
<IconButton onClick={this.handleDoubleClick}>
Expand All @@ -111,4 +142,4 @@ class ProductGridItems extends Component {
}
}

export default ProductGridItems;
export default withStyles(styles)(ProductGridItems);