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

Added rowStyle prop to SimpleList #5252

Merged
merged 8 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 2 additions & 4 deletions cypress/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@
"videosFolder": "videos",
"viewportWidth": 1280,
"viewportHeight": 720,
"blockHosts": [
"source.unsplash.com"
]
}
"blockHosts": ["source.unsplash.com"]
}
2 changes: 1 addition & 1 deletion cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"cypress": "^5.1.0",
"cypress-skip-and-only-ui": "^1.2.7"
}
}
}
14 changes: 12 additions & 2 deletions packages/ra-ui-materialui/src/list/SimpleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const SimpleList: FC<SimpleListProps> = props => {
rightIcon,
secondaryText,
tertiaryText,
rowStyle,
...rest
} = props;
const { basePath, data, ids, loaded, total } = useListContext(props);
Expand All @@ -95,15 +96,22 @@ const SimpleList: FC<SimpleListProps> = props => {
return (
total > 0 && (
<List className={className} {...sanitizeListRestProps(rest)}>
{ids.map(id => (
{ids.map((id, rowIndex) => (
<LinkOrNot
linkType={linkType}
basePath={basePath}
id={id}
key={id}
record={data[id]}
>
<ListItem button={!!linkType as any}>
<ListItem
button={!!linkType as any}
style={
rowStyle
? rowStyle(data[id], rowIndex)
: undefined
}
>
{leftIcon && (
<ListItemIcon>
{leftIcon(data[id], id)}
Expand Down Expand Up @@ -166,6 +174,7 @@ SimpleList.propTypes = {
rightIcon: PropTypes.func,
secondaryText: PropTypes.func,
tertiaryText: PropTypes.func,
rowStyle: PropTypes.func,
};

export type FunctionToElement = (
Expand All @@ -185,6 +194,7 @@ export interface SimpleListProps extends Omit<ListProps, 'classes'> {
rightIcon?: FunctionToElement;
secondaryText?: FunctionToElement;
tertiaryText?: FunctionToElement;
rowStyle?: (record: Record, index: number) => any;
}

const useLinkOrNotStyles = makeStyles(
Expand Down