Make List and ListItem reusable

This commit is contained in:
J Francisco Rader committed 2020-08-22 23:03:54 -03:00
1 parent d36ef4ce38
commit eb570f21b3
5 files changed
+45 -36

No files matched your search

+2 -2
View File
@@ -1,11 +1,11 @@
import React from "react"; import React from "react";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText"; import ListItemText from "@material-ui/core/ListItemText";
import { Button } from "@material-ui/core"; import { Button } from "@material-ui/core";
import PhoneIcon from "@material-ui/icons/Phone"; import PhoneIcon from "@material-ui/icons/Phone";
import ChatIcon from "@material-ui/icons/Chat"; import ChatIcon from "@material-ui/icons/Chat";
import { List } from "../../../ui/components/List";
import { ListItem } from "../../../ui/components/ListItem";
export const ContactList = ({ contacts, onCall, onMessage }) => { export const ContactList = ({ contacts, onCall, onMessage }) => {
return ( return (
+21 -21
View File
@@ -1,24 +1,24 @@
import React from 'react'; import React from "react";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText"; import ListItemText from "@material-ui/core/ListItemText";
import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback'; import PhoneCallbackIcon from "@material-ui/icons/PhoneCallback";
import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded'; import PhoneForwardedIcon from "@material-ui/icons/PhoneForwarded";
import { List } from "../../../ui/components/List";
import { ListItem } from "../../../ui/components/ListItem";
const CallTypeIcon = {
incoming: <PhoneCallbackIcon />,
outgoing: <PhoneForwardedIcon />,
};
export const PhoneList = ({ calls }) => { export const PhoneList = ({ calls }) => {
const CallTypeIcon = {'incoming': <PhoneCallbackIcon />, 'outgoing': <PhoneForwardedIcon />} return (
<List>
return ( {calls.map((call) => (
<List> <ListItem key={call.id} divider>
{calls.map((call) => ( <ListItemText primary={call.caller} secondary={call.phoneNumber} />
<ListItem key={call.id} divider> {CallTypeIcon[call.type]}
<ListItemText </ListItem>
primary={call.caller} ))}
secondary={call.phoneNumber} </List>
/> );
{CallTypeIcon[call.type]} };
</ListItem>
))}
</List>
)
}
+3 -3
View File
@@ -1,13 +1,13 @@
import React from "react"; import React from "react";
import { import {
ListItem,
List,
ListItemIcon, ListItemIcon,
ListItemText, ListItemText,
Slide, Slide,
makeStyles, makeStyles,
Paper, Paper,
} from "@material-ui/core"; } from "@material-ui/core";
import { List } from "./List";
import { ListItem } from "./ListItem";
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
@@ -34,7 +34,7 @@ export const ContextMenu = ({ open, onClose, options }) => {
onClose(); onClose();
}} }}
> >
<ListItemIcon>{option.icon}</ListItemIcon> {option.icon && <ListItemIcon>{option.icon}</ListItemIcon>}
<ListItemText primary={option.label} /> <ListItemText primary={option.label} />
</ListItem> </ListItem>
))} ))}
+9 -10
View File
@@ -1,11 +1,10 @@
import React from 'react' import React from "react";
import List from '@material-ui/core/List'; import MaterialList from "@material-ui/core/List";
export const PhoneList = (props) => { export const List = ({ ...props }) => {
return (
return ( <MaterialList {...props} aria-label="list">
<List component='nav' className={props.className} aria-label='mailbox folders'> {props.children}
{props.children} </MaterialList>
</List> );
) };
}
+10
View File
@@ -0,0 +1,10 @@
import React from "react";
import MaterialListItem from "@material-ui/core/ListItem";
export const ListItem = ({ ...props }) => {
return (
<MaterialListItem {...props} aria-label="list item">
{props.children}
</MaterialListItem>
);
};