@material-ui/core#ListItemText JavaScript Examples
The following examples show how to use
@material-ui/core#ListItemText.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreatePost.js From social-media-strategy-fe with MIT License | 6 votes |
CreatePost = () => {
const [isOpen, setIsOpen] = useState(false);
const handleOpen = () => {
setIsOpen(true);
};
const handleClose = () => {
setIsOpen(false);
};
return (
<>
<List>
<ListItem button onClick={handleOpen}>
<ListItemIcon>
<AddCircleIcon color="primary" />
</ListItemIcon>
<ListItemText primary="Add post" />
</ListItem>
</List>
<CreatePostModal open={isOpen} handleClose={handleClose} />
</>
);
}
Example #2
Source File: UserMoreMenu.js From course-manager with MIT License | 6 votes |
function UserMoreMenu({ id }) {
const navigate = useNavigate();
const ref = useRef(null);
const [isOpen, setIsOpen] = useState(false);
return (
<>
<IconButton ref={ref} onClick={() => setIsOpen(true)}>
<Icon icon={moreVerticalFill} width={20} height={20} />
</IconButton>
<Menu
open={isOpen}
anchorEl={ref.current}
onClose={() => setIsOpen(false)}
PaperProps={{
sx: { width: 200, maxWidth: '100%' }
}}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
>
<MenuItem sx={{ color: 'text.secondary' }} onClick={() => navigate(id)}>
<ListItemIcon>
<Icon icon={trash2Outline} width={24} height={24} />
</ListItemIcon>
<ListItemText primary="Delete" primaryTypographyProps={{ variant: 'body2' }} />
</MenuItem>
<MenuItem component={RouterLink} to="#" sx={{ color: 'text.secondary' }}>
<ListItemIcon>
<Icon icon={editFill} width={24} height={24} />
</ListItemIcon>
<ListItemText primary="Create" primaryTypographyProps={{ variant: 'body2' }} />
</MenuItem>
</Menu>
</>
);
}
Example #3
Source File: Navbar.js From wiki with GNU General Public License v3.0 | 6 votes |
export default function SimpleAccordion() {
const classes = useStyles();
return (
<div className={classes.root}>
<Accordion>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography className={classes.heading}>Accordion 1</Typography>
</AccordionSummary>
<AccordionDetails>
<List>
<ListItem button key={1}>
<ListItemIcon>
<NotificationsActiveIcon />
</ListItemIcon>
<ListItemText primary="Hello" />
</ListItem>
</List>
</AccordionDetails>
</Accordion>
</div>
);
}
Example #4
Source File: SideBar.js From surveillance-forms with MIT License | 6 votes |
SideBarCard = ({ user, onLanguageSelect, lang, langCode }) => {
const classes = useStyles();
//TODO: this could be done better
const fields = {
label: lang.t("note.lable"),
notes: [
lang.t("note.note1"),
lang.t("note.note2"),
lang.t("note.note3"),
lang.t("note.note4"),
],
};
return (
<Card className={classes.card}>
<CardContent>
<Typography variant="h6" component="h2">
{fields.label}
</Typography>
<List>
{fields.notes.map((el, index) => {
return (
<ListItem key={index} disableGutters>
<ListItemAvatar style={{ flexShrink: 1 }}>
<Avatar style={{ background: '#fff', margin: 0 }}>
<CheckIcon style={{ fill: 'green', width: 20 }}/>
</Avatar>
</ListItemAvatar>
<ListItemText className="sidebarText">{el}</ListItemText>
</ListItem>
);
})}
</List>
</CardContent>
</Card>
);
}
Example #5
Source File: TagList.js From ra-data-django-rest-framework with MIT License | 6 votes |
SubTree = ({ level, root, getChildNodes, openChildren, toggleNode }) => {
const childNodes = getChildNodes(root);
const hasChildren = childNodes.length > 0;
const open = openChildren.includes(root.id);
return (
<Fragment>
<ListItem
button={hasChildren}
onClick={() => hasChildren && toggleNode(root)}
style={{ paddingLeft: level * 16 }}
>
{hasChildren && open && <ExpandLess />}
{hasChildren && !open && <ExpandMore />}
{!hasChildren && <div style={{ width: 24 }}> </div>}
<ListItemText primary={root.name} />
<ListItemSecondaryAction>
<EditButton record={root} basePath="/tags" />
</ListItemSecondaryAction>
</ListItem>
<Collapse in={open} timeout="auto" unmountOnExit>
<MuiList component="div" disablePadding>
{childNodes.map(node => (
<SubTree
key={node.id}
root={node}
getChildNodes={getChildNodes}
openChildren={openChildren}
toggleNode={toggleNode}
level={level + 1}
/>
))}
</MuiList>
</Collapse>
</Fragment>
);
}
Example #6
Source File: LanguageSelector.js From covid-trials-dashboard with MIT License | 6 votes |
LanguageSelector = ({ languages, onSelect }) => {
const { t } = useTranslation('languages')
const [open, setOpen] = useState(false)
const classes = useStyles()
console.log({ languages })
return (
<>
<ListItem button onClick={() => setOpen(!open)}>
<ListItemIcon>
<LanguageOutlined />
</ListItemIcon>
<ListItemText primary={t('selectorTitle')} />
{open ? <ExpandLess /> : <ExpandMore />}
</ListItem>
<Collapse in={open} timeout={300} unmountOnExit>
<List component='div' disablePadding>
{languages.map(lan => (
<ListItem
key={lan}
button
className={classes.nested}
onClick={() => onSelect(lan)}
>
<ListItemText primary={t(lan)} />
</ListItem>
))}
</List>
</Collapse>
</>
)
}
Example #7
Source File: AlertBox.js From Edlib with GNU General Public License v3.0 | 6 votes |
AlertBox = () => {
const {
state: {
messages = [],
messageTitle,
},
dispatch,
} = useForm();
if (!messages || messages.length === 0) {
return null;
}
return (
<div className="editorAlertBox">
<Alert
color="danger"
onClose={() => dispatch({ type: FormActions.resetError })}
elevation={2}
>
<div className="editorAlertBoxHeader">
<WarningIcon />
<strong>{messageTitle}</strong>
</div>
<List>
{messages.map((message, index) => (
<ListItemText
primaryTypographyProps={{ style: { fontSize: '1.4rem' } }}
key={message + index}
>
{message}
</ListItemText>))}
</List>
</Alert>
</div>
);
}
Example #8
Source File: ToolbarExtension.js From eSim-Cloud with GNU General Public License v3.0 | 6 votes |
export function ImageExportDialog (props) {
const classes = useStyles()
const { onClose, open } = props
const handleClose = () => {
onClose('')
}
const handleListItemClick = (value) => {
onClose(value)
}
return (
<Dialog onClose={handleClose} aria-labelledby="image-export-dialog-title" open={open}>
<DialogTitle id="image-export-dialog-title">Select Image type</DialogTitle>
<List>
{ImgTypes.map((img) => (
<ListItem button onClick={() => handleListItemClick(img)} key={img}>
<ListItemAvatar>
<Avatar className={classes.avatar}>
{img.charAt(0).toUpperCase()}
</Avatar>
</ListItemAvatar>
<ListItemText primary={img} />
</ListItem>
))}
</List>
<DialogActions>
<Button onClick={handleClose} color="primary" autoFocus>
Close
</Button>
</DialogActions>
</Dialog>
)
}
Example #9
Source File: Sidebar.js From paper-and-ink with MIT License | 6 votes |
function Sidebar(props) {
const { open, variant, onClose } = props;
const classes = useStyles();
return (
<Drawer
anchor="left"
classes={{ paper: classes.drawer }}
open={open}
onClose={onClose}
variant={variant}
>
<section className={classes.root}>
<Hidden mdUp>
<IconButton className={classes.menuButton} aria-label="Menu" onClick={onClose}>
<CloseIcon />
</IconButton>
</Hidden>
<Profile className={classes.profile} />
<List component="div" disablePadding>
{pages.map(page => (
<ListItem
key={page.title}
activeClassName={classes.activeListItem}
className={classes.listItem}
component={NavLink}
to={page.href}
>
<ListItemIcon className={classes.listItemIcon}>{page.icon}</ListItemIcon>
<ListItemText classes={{ primary: classes.listItemText }} primary={page.title} />
</ListItem>
))}
</List>
</section>
</Drawer>
);
}
Example #10
Source File: Rule.js From gitlab-lint-react with BSD 3-Clause "New" or "Revised" License | 6 votes |
RuleProjects = ({ projects }) => {
if (projects.length <= 0) {
return <p>Found no projects matching the criteria.</p>;
}
return (
<React.Fragment>
<Typography variant="h6" paragraph>
These {projects.length} repositories in the gitlab trigger this rule:
</Typography>
<List>
{projects.map((row) => {
return (
<ListItem
key={row.projectId}
button
component={RouterLink}
to={`/projects/${row.projectId}`}
>
<ListItemText primary={row.pathWithNamespace} />
</ListItem>
);
})}
</List>
</React.Fragment>
);
}
Example #11
Source File: ChatList.jsx From react-03.03 with MIT License | 6 votes |
ChatList = ({ chats, createChat }) => {
const classes = useStyles();
const [name, setName, setNameState] = useInput('');
const handleAddChat = (event) => {
event.preventDefault();
createChat(name);
setNameState('');
}
return (
<List className={classes.root}>
{ chats.map(({id, name}) => {
return (
<Link key={id} to={`/chats/${id}`}>
<ListItem className={classes.listItem}>
<ListItemAvatar>
<Avatar />
</ListItemAvatar>
<ListItemText
primary={name}
/>
</ListItem>
</Link>
)
})
}
<ListItem className={classes.listItem}>
<form onSubmit={handleAddChat}>
<input type="text" placeholder="Chat name" value={name} onChange={setName} />
<button>Create chat</button>
</form>
</ListItem>
</List>
)
}
Example #12
Source File: sidebar-item.js From horondi_client_fe with MIT License | 6 votes |
SideBarItem = ({ category, handlerItem, models, translationsKey, mainItemStyles }) => {
const { sort, page, countPerPage, categoryFilter, modelsFilter, defaultPage } = URL_QUERIES_NAME;
const { t } = useTranslation();
const styles = useStyles();
const [isListOpen, setIsListOpen] = useState(false);
const handleClick = () => {
setIsListOpen((prevValue) => setIsListOpen(!prevValue));
};
const countPerPageValue = ITEMS_PER_PAGE[0].value;
return (
<>
<li className={mainItemStyles}>
<ListItemText button='true' onClick={handleClick} primary={t(`${translationsKey}.name`)} />
{isListOpen ? <RemoveIcon onClick={handleClick} /> : <AddIcon onClick={handleClick} />}
</li>
<Collapse in={isListOpen} timeout='auto' unmountOnExit>
<List className={styles.list}>
{models.map((model) => (
<ListItem button className={styles.nested} key={model._id} onClick={handlerItem}>
<Link
to={`/catalog/products?${page}=${defaultPage}&${sort}=${POPULARITY}&${countPerPage}=${countPerPageValue}&${categoryFilter}=${category}&${modelsFilter}=${model._id}`}
>
<ListItemText primary={t(`${model.translationsKey}.name`)} />
</Link>
</ListItem>
))}
</List>
</Collapse>
<div className={styles.itemHighlighting} />
</>
);
}
Example #13
Source File: AppDrawer.js From module-federation-examples with MIT License | 6 votes |
function ListItemLink(props) {
const selected = useMatch(props.to);
const CustomLink = React.useMemo(
() => React.forwardRef((linkProps, ref) => <Link ref={ref} to={props.to} {...linkProps} />),
[props.to],
);
return (
<li>
<ListItem selected={selected} button component={CustomLink}>
<ListItemIcon>{props.icon}</ListItemIcon>
<ListItemText primary={props.text} />
</ListItem>
</li>
);
}
Example #14
Source File: OftadehNavItem.jsx From oftadeh-react-admin with MIT License | 6 votes |
OftadehNavItem = props => {
const classes = useStyles();
const { item } = props;
return (
<ListItem
button
component={NavLinkAdapter}
to={item.url}
activeClassName={classes.active}
exact={item.exact}
>
{item.icon && (
<ListItemIcon>
<Icon>{item.icon}</Icon>
</ListItemIcon>
)}
<ListItemText primary={item.title} />
{item.badge && <OftadehNavBadge className="mr-4" badge={item.badge} />}
</ListItem>
);
}
Example #15
Source File: ListExpansion.js From mui-storyblok with MIT License | 6 votes |
MuiListExpansion = ({
rootClass,
handleClick,
icon,
open,
primaryText,
}) => {
const styles = StoryBlok.arrayToMuiStyles(rootClass);
return (
<>
<ListItem button onClick={handleClick} className={styles.root}>
{icon.length ? <ListItemIcon {...icon[0]} /> : null}
<ListItemText primary={primaryText} />
{open ? <ExpandLess /> : <ExpandMore />}
</ListItem>
</>
);
}
Example #16
Source File: UserMenuItem.js From generator-webapp-rocket with MIT License | 6 votes |
UserMenuItem = ({ userMenu, drawerOpen, activeRoute, withGradient }) => {
const classes = useStyles({withGradient})
const { t } = useTranslation()
const navLinkClasses =
classes.itemLink +
' ' +
cx({
[' ' + classes.menuActiveColor]: activeRoute(userMenu.path)
})
const itemText =
classes.itemText +
' ' +
cx({
[classes.itemTextMini]: !drawerOpen
})
const text = t(userMenu.text)
return (
<Tooltip disableHoverListener={drawerOpen} title={text}>
<ListItem className={classes.collapseItem}>
<NavLink to={userMenu.path} className={navLinkClasses}>
<ListItemIcon className={classes.itemIcon}>{userMenu.icon}</ListItemIcon>
<ListItemText primary={text} disableTypography={true} className={itemText} />
</NavLink>
</ListItem>
</Tooltip>
)
}
Example #17
Source File: NavList.js From A2 with GNU General Public License v3.0 | 6 votes |
export default function NavList() {
return (
<div>
<List component="nav" aria-label="main mailbox folders">
<Divider />
<ListItem button className={styles.navButton}>
<PaymentIcon className={styles.navIcon} />
<ListItemLink href="#/home/transactions" className={styles.navButton}>
<ListItemText
primary="Transactions"
className={styles.unselectedNavText}
/>
</ListItemLink>
</ListItem>
<Divider />
<ListItem button>
<PeopleOutlineIcon className={styles.navIcon} />
<ListItemLink href="#/home/split">
<ListItemText
primary="Split a Bill"
className={styles.unselectedNavText}
/>
</ListItemLink>
</ListItem>
<Divider />
</List>
</div>
);
}
Example #18
Source File: CategoryMenus.js From youtube-clone with MIT License | 6 votes |
SideCategoryMenu = () => {
const classes = useStyles();
return (
<List>
<ListItem>
<ListItemText
primary="BEST OF YOUTUBE"
classes={{ primary: classes.title }}
/>
</ListItem>
{categoryIcons.map((item, index) => {
return (
<NavItem
key={index}
to={`/trending?category=${index}`}
title={item.title}
icon={() => (
<img
className={classes.bestOfYoutubeIcon}
src={item.icon}
alt={item.title + " logo"}
/>
)}
/>
);
})}
</List>
);
}
Example #19
Source File: AccountsModal.js From akashlytics-deploy with GNU General Public License v3.0 | 5 votes |
AccountsModal = ({ onClose }) => {
const classes = useStyles();
const { address, setSelectedWallet, wallets, setWallets } = useWallet();
const { localCerts, setLocalCert, setValidCertificates, setSelectedCertificate } = useCertificate();
const { wallets: storageWallets } = useStorageWallets();
const history = useHistory();
const handleSelectAccount = (wallet) => {
if (wallet.address !== address) {
const newWallet = wallets.find((w) => w.address === wallet.address);
// Update memory wallets
for (let i = 0; i < wallets.length; i++) {
wallets[i].selected = wallets[i].address === wallet.address;
}
// Update storage wallets
const newStorageWallets = storageWallets.map((w) => ({ ...w, selected: w.address === wallet.address }));
const localCert = localCerts.find((c) => c.address === wallet.address);
updateStorageWallets(newStorageWallets);
setWallets(wallets);
setSelectedWallet(newWallet);
setValidCertificates([]);
setSelectedCertificate(null);
if (localCert) {
setLocalCert(localCert);
}
onClose();
history.replace(UrlService.dashboard());
}
};
const handleAddAccount = () => {
history.push(UrlService.register(true));
onClose();
};
return (
<Dialog open={true} onClose={onClose} maxWidth="xs" fullWidth>
<DialogTitle>
<span className={classes.dialogTitle}>
Accounts
<Button variant="contained" size="small" color="primary" onClick={handleAddAccount}>
Add account
</Button>
</span>
</DialogTitle>
<DialogContent dividers className={classes.dialogContent}>
<List className={classes.list}>
{storageWallets.map((wallet) => {
return (
<ListItem key={wallet.address} dense button onClick={() => handleSelectAccount(wallet)}>
<ListItemIcon>{wallet.address === address && <CheckIcon color="primary" />}</ListItemIcon>
<ListItemText
classes={{ secondary: classes.secondaryText }}
primary={
<Box display="flex" alignItems="center" justifyContent="space-between" fontSize="1rem">
{wallet.name}
</Box>
}
secondary={wallet.address}
/>
</ListItem>
);
})}
</List>
</DialogContent>
<DialogActions>
<Button onClick={onClose} type="button" autoFocus variant="contained" color="primary">
Close
</Button>
</DialogActions>
</Dialog>
);
}
Example #20
Source File: PostMenu.js From social-media-strategy-fe with MIT License | 5 votes |
PostMenu = ({ post, setEditing }) => {
const dispatch = useDispatch();
const [modalOpen, setModalOpen] = useState(false);
const [anchorEl, setAnchorEl] = useState(null);
const isOpen = Boolean(anchorEl);
const handleAnchorEl = (e) => {
setAnchorEl(e.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const handleEdit = () => {
setEditing();
};
const handleDeleteClick = () => {
setModalOpen(true);
handleClose();
};
const handleDeleteConfirmation = async () => {
dispatch(deletePost(post));
handleClose();
};
return (
<>
<Modal
open={modalOpen}
handleClose={() => setModalOpen(false)}
title="Delete this post?"
handleConfirmation={handleDeleteConfirmation}
/>
<IconButton
aria-label="account of current user"
aria-controls="menu-appbar"
aria-haspopup="true"
onClick={handleAnchorEl}
color="inherit"
>
<MoreHorizIcon fontSize="small" />
</IconButton>
<Menu
id="menu-appbar"
anchorEl={anchorEl}
getContentAnchorEl={null}
anchorOrigin={{
vertical: "bottom",
horizontal: "right",
}}
keepMounted
transformOrigin={{
vertical: "top",
horizontal: "right",
}}
open={isOpen}
onClose={handleClose}
>
{!post.posted && (
<MenuItem onClick={handleEdit}>
<ListItemIcon>
<EditIcon fontSize="small" />
</ListItemIcon>
<ListItemText primary="Edit" />
</MenuItem>
)}
<MenuItem onClick={handleDeleteClick}>
<ListItemIcon>
<DeleteIcon fontSize="small" />
</ListItemIcon>
<ListItemText primary="Delete" />
</MenuItem>
</Menu>
</>
);
}
Example #21
Source File: PublicComments.js From app with MIT License | 5 votes |
function CommentList({ requestId }) {
const classes = useStyles();
const firestore = useFirestore();
const querySnapshot = useFirestoreCollection(
firestore
.collection(`${REQUESTS_COMMENTS_PUBLIC_COLLECTION}`)
.where('requestId', '==', requestId)
.orderBy('createdAt', 'asc'),
);
if (querySnapshot.empty) {
return (
<Box color="text.disabled">
<Typography
variant="body2"
className={classes.noComments}
data-test="no-comments">
No public comments.
</Typography>
</Box>
);
}
return (
<List>
{querySnapshot.docs.map(
(docSnap) =>
// When new comment is added locally, the createdAt can be the serverTimestamp() value.
// So, we wait on rendering until any new snapshot has finished writing.
!docSnap.metadata.hasPendingWrites && (
<ListItem
key={docSnap.id}
divider
alignItems="flex-start"
data-test="public-comment">
<ListItemAvatar>
<Avatar>{docSnap.get('author.firstName').slice(0, 1)}</Avatar>
</ListItemAvatar>
<ListItemText
disableTypography
primary={
<Typography variant="subtitle2" data-test="comment-author">
{docSnap.get('author.firstName')} –{' '}
<Typography
variant="body2"
display="inline"
color="textSecondary">
{format(docSnap.get('createdAt').toDate(), 'p - PPPP')}
</Typography>
</Typography>
}
secondary={docSnap
.get('content')
.split('\n')
.map((content, key) => (
<Typography
variant="body1"
/* eslint-disable react/no-array-index-key */
key={key}
/* eslint-enable react/no-array-index-key */
gutterBottom
data-test="comment-content">
{content}
</Typography>
))}
/>
</ListItem>
),
)}
</List>
);
}
Example #22
Source File: OwnerOrganizers.js From Quizzie with MIT License | 5 votes |
function OwnerUsers() {
const [organizers, setOrganizers] = useState([]);
const getUsers = async () => {
let token = localStorage.getItem("authToken");
let url = `https://quizzie-api.herokuapp.com/owner/allAdmins`;
try {
await axios.get(url, {
headers: {
"auth-token": token
}
}).then(res => {
setOrganizers(res.data.result);
})
} catch(error) {
console.log(error);
}
}
useEffect(() => {
getUsers();
}, [])
return (
<div className="owner-quizzes">
<List aria-label="users-display" className="owner-quiz-list">
{organizers.map((user) => (
<ListItem button key={user._id}>
<ListItemText primary={user.email} secondary={user.name} />
<ListItemSecondaryAction>
<IconButton edge="end" aria-label="details">
<ArrowForwardIos />
</IconButton>
</ListItemSecondaryAction>
</ListItem>
))}
</List>
</div>
)
}
Example #23
Source File: header.js From React-Messenger-App with MIT License | 5 votes |
render() {
return (
<div>
<AppBar position="static">
<Toolbar>
<Typography
className={this.props.classes.heading}
variant="display1"
color="inherit"
>
Chat Server
</Typography>
<Hidden mdUp>
<IconButton
color="inherit"
onClick={this.handleMenubutton}
className={this.props.classes.menuButton}
>
<MenuIcon />
</IconButton>
</Hidden>
<Hidden smDown>
<Typography className={this.props.classes.links}>
<Button href="/api/signup" color="primary" variant="contained">
Signup
</Button>
<Button href="/api/signin" color="primary" variant="contained">
Signin
</Button>
<Button href="/api/chat" color="primary" variant="contained">
Chat
</Button>
</Typography>
</Hidden>
</Toolbar>
</AppBar>
<Hidden mdUp>
<Drawer
variant="persistent"
anchor="top"
open={this.state.open}
classes={{ paperAnchorTop: this.props.classes.drawerColor }}
>
<div className={this.props.classes.drawerWidth}>
<IconButton onClick={this.handleMenubutton}>
<KeyboardArrowUpIcon />
</IconButton>
<List>
{["SignUp", "SignIn", "Chat"].map((text, index) => (
<ListItem button key={index}>
<Button href={`#${text}`} onClick={this.handleMenubutton}>
<ListItemText primary={text} />
</Button>
</ListItem>
))}
</List>
</div>
</Drawer>
</Hidden>
</div>
);
}
Example #24
Source File: searchlist.js From healthcare-api-dicom-viewer with Apache License 2.0 | 5 votes |
/**
* React component for creating a list of items filtered using a search query
* @param {Object} props
* @param {Object[]} props.items Array of items to be filtered
* @param {string} props.items[].value
* @param {number} props.items[].index
* @param {string} props.searchQuery Search query to filter with
* @param {function(string): *} props.onClickItem Function to run when
* user clicks an item
* @param {number} props.maxDisplayAmount Max number of items to render
* @return {ReactElement} <FilterItems/>
*/
function FilterItems({items, searchQuery, onClickItem, maxDisplayAmount}) {
if (items.length == 0) {
return (
<ListItem>
<ListItemText
primary="No data to display." />
</ListItem>
);
}
const filteredItems = items.filter((item) => {
return item.value.toLowerCase().includes(searchQuery.toLowerCase().trim());
});
if (filteredItems.length == 0) {
return (
<ListItem>
<ListItemText
primary="No results found." />
</ListItem>
);
}
return filteredItems.slice(0, maxDisplayAmount).map((item) => {
return (
<ListItem button key={item.index} onClick={() => onClickItem(item.index)}>
<ListItemText
primary={item.value} />
</ListItem>
);
});
}
Example #25
Source File: Inbox.js From treetracker-admin-client with GNU Affero General Public License v3.0 | 5 votes |
Inbox = ({ threads, selected, handleListItemClick }) => {
const { paper, searchInbox, list, listItem, listText, avatar } = useStyles();
const [search, setSearch] = useState('');
return (
<Paper className={paper}>
<List className={list}>
{threads
.filter((thread) => {
if (search === '') {
return thread;
} else if (
thread.userName.toLowerCase().includes(search.toLowerCase())
) {
return thread;
}
})
.map((thread, i) => (
<ListItem
key={`${thread.userName}-${i}`}
alignItems="flex-start"
className={listItem}
selected={thread.userName === selected}
onClick={() => handleListItemClick(thread.userName)}
>
<ListItemAvatar>
{thread.messages[0].type === 'message' ? (
<Avatar src={thread.avatar} className={avatar}></Avatar>
) : thread.messages[0].type === 'announce' ? (
<Announcement color="inherit" />
) : (
<Ballot color="inherit" />
)}
</ListItemAvatar>
{thread.messages[0].type === 'survey' ||
thread.messages[0].type === 'announce' ? (
<ListItemText
primary={thread.messages[0].subject}
secondary={
thread.messages[0].subject
? thread.messages[0].composed_at.slice(0, 10)
: thread.userName
}
className={listText}
/>
) : (
<ListItemText primary={thread.userName} className={listText} />
)}
<Typography>
{timeAgoFormatDate(
new Date(
thread.messages[thread.messages.length - 1].composed_at
)
)}
</Typography>
</ListItem>
))}
</List>
<SearchInbox className={searchInbox} setSearch={setSearch} />
</Paper>
);
}
Example #26
Source File: Footer.js From WebApp with MIT License | 5 votes |
Footer = () => {
const classes = useStyles()
const [openFeedback, setOpenFeedback] = useState(false)
const [openJoinUs, setOpenJoinUs] = useState(false)
const handleClickOpenFeedBack = (e) => {
e.preventDefault()
setOpenFeedback(true)
}
const handleClickCloseFeedBack = () => {
setOpenFeedback(false)
}
const handleClickOpenJoinUs = (e) => {
e.preventDefault()
setOpenJoinUs(true)
}
const handleClickCloseJoinUs = () => {
setOpenJoinUs(false)
}
function FooterListElement (props) {
return (
<ListItemText className={classes.footerListItemStyle} onClick={props.onClick}>
<Typography variant="h6" align="left">
<Link color="textPrimary" href={props.href}>
<FormattedMessage id={props.idMessage} defaultMessage="Missing String" />
</Link>
</Typography>
</ListItemText>
)
}
return (
<footer className={classes.footer}>
<Divider className={classes.dividerStyle} />
<List className={classes.footerListStyle}>
<FooterListElement idMessage="footer.feedback" href="#" onClick={handleClickOpenFeedBack} />
<FooterListElement idMessage="footer.aboutus" href="/#/aboutus" />
<FooterListElement idMessage="footer.joinus" href="#" onClick={handleClickOpenJoinUs} />
</List>
<Feedback open={openFeedback} handleClose={handleClickCloseFeedBack} />
<JoinUs open={openJoinUs} handleClose={handleClickCloseJoinUs} />
</footer>
)
}
Example #27
Source File: DesktopNavigation.jsx From archeage-tools with The Unlicense | 5 votes |
render() {
const {
setMobile,
darkMode,
setDarkMode,
menuItems,
session,
myAccountUrl,
openDialog,
hideAds,
setHideAds,
} = this.props;
return (
<>
{navigation.map(navLink => <NavMenu key={navLink.name} {...navLink} />)}
{session.isAuthenticated && !session.verified &&
<Tooltip title="E-mail is not verified. Click to verify.">
<MuiLink href={myAccountUrl}>
<WarningIcon className="verify-warn" />
</MuiLink>
</Tooltip>}
<NavMenu
name="My Account"
button={
<IconButton
className="user-menu-icon"
aria-controls="user-menu"
aria-haspopup="true"
>
<Avatar src={session.avatarSrc} className={cn('avatar', { [session.avatarPlatform]: true })}>
{!session.avatarSrc && <PersonIcon />}
</Avatar>
</IconButton>
}
>
<>
<ListItem dense divider>
<ListItemText primary={<Typography variant="overline">{session.isAuthenticated ? session.username
: 'Account'}</Typography>} />
</ListItem>
{menuItems}
<MenuItem button onClick={() => openDialog(DIALOG_MY_GAME)}>My ArcheAge</MenuItem>
<Divider />
<MenuItem onClick={() => setDarkMode(!darkMode)}>
<div className="menu-item-icon">
<span>{darkMode ? 'Light' : 'Dark'} Mode</span>
{darkMode ? <BrightnessHighIcon /> : <Brightness4Icon />}
</div>
</MenuItem>
{isMobileBrowser() &&
<MenuItem onClick={() => setMobile(true)}>
<div className="menu-item-icon">
<span>Switch to Mobile</span>
<PhoneIphoneIcon />
</div>
</MenuItem>}
<MenuItem onClick={() => setHideAds(!hideAds)}>
<div className="menu-item-icon">
<span>{hideAds ? 'Show' : 'Hide'} Ads</span>
{hideAds ? <VisibilityIcon /> : <VisibilityOffIcon />}
</div>
</MenuItem>
</>
</NavMenu>
</>
);
}
Example #28
Source File: LanguagePopover.js From course-manager with MIT License | 5 votes |
// ----------------------------------------------------------------------
export default function LanguagePopover() {
const anchorRef = useRef(null);
const [open, setOpen] = useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
return (
<>
<IconButton
ref={anchorRef}
onClick={handleOpen}
sx={{
padding: 0,
width: 44,
height: 44,
...(open && {
bgcolor: (theme) => alpha(theme.palette.primary.main, theme.palette.action.focusOpacity)
})
}}
>
<img src={LANGS[0].icon} alt={LANGS[0].label} />
</IconButton>
<MenuPopover open={open} onClose={handleClose} anchorEl={anchorRef.current}>
<Box sx={{ py: 1 }}>
{LANGS.map((option) => (
<MenuItem
key={option.value}
selected={option.value === LANGS[0].value}
onClick={handleClose}
sx={{ py: 1, px: 2.5 }}
>
<ListItemIcon>
<Box component="img" alt={option.label} src={option.icon} />
</ListItemIcon>
<ListItemText primaryTypographyProps={{ variant: 'body2' }}>
{option.label}
</ListItemText>
</MenuItem>
))}
</Box>
</MenuPopover>
</>
);
}
Example #29
Source File: Budget.js From Simplify-Testing-with-React-Testing-Library with MIT License | 5 votes |
Budget = ({
classes,
categoryName,
totalBudget,
setAmtSpent,
amtSpent,
deleteBudget,
id,
}) => {
const addExpense = () => {
return amtSpent + 5 <= totalBudget ? setAmtSpent(id, 'add') : null;
};
const subtractExpense = () => {
return amtSpent - 5 >= 0 ? setAmtSpent(id, 'subtract') : null;
};
const handleDeleteBudget = () => deleteBudget(id, totalBudget);
// This method transforms a value in any range to a scale of 0 - 100:
const normalize = (value) => ((value - 0) * 100) / (totalBudget - 0);
return (
<ListItem style={{ paddingRight: 0, paddingLeft: 0 }} divider>
<Grid alignItems='center' container>
<Grid item xs={1}>
<DeleteForeverTwoToneIcon
aria-label='trash can'
onClick={handleDeleteBudget}
className={classes.icon}
/>
</Grid>
<Grid item xs={3}>
<ListItemText
classes={{ primary: classes.primary }}
primary={categoryName}
/>
</Grid>
<Grid style={{ textAlign: 'right' }} item xs={8}>
<Typography classes={{ root: classes.root }} variant='h6'>
<IconButton aria-label='ArrowLeft' onClick={subtractExpense}>
<ArrowLeft />
</IconButton>
${amtSpent}
<IconButton aria-label='ArrowRight' onClick={addExpense}>
<ArrowRight />
</IconButton>
<span className={classes.span}>of</span>${totalBudget}
</Typography>
</Grid>
<Grid item xs={12}>
<LinearProgress
style={{ width: '100%', height: '10px', background: 'green' }}
color='secondary'
variant='determinate'
value={normalize(amtSpent)}
/>
</Grid>
</Grid>
</ListItem>
);
}