@material-ui/core#Box JavaScript Examples
The following examples show how to use
@material-ui/core#Box.
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: AppSettingsContainer.js From akashlytics-deploy with GNU General Public License v3.0 | 6 votes |
AppSettingsContainer = () => {
const { isLoadingSettings } = useSettings();
return (
<>
<AutoUpdater />
{isLoadingSettings ? (
<Box display="flex" alignItems="center" justifyContent="center" height="100%" width="100%" flexDirection="column">
<Box paddingBottom="1rem">
<CircularProgress size="3rem" />
</Box>
<div>
<Typography variant="h5">Loading settings...</Typography>
</div>
</Box>
) : (
<AppContainer />
)}
</>
);
}
Example #2
Source File: App.js From connect-4-online-multiplayer with MIT License | 6 votes |
function App() {
const user = useContext(UserContext);
if (!user.id) {
return <Login />;
}
return (
<SocketProvider id={user.id}>
<NavBar />
<Switch>
<Route path="/" exact>
<Rooms />
</Route>
<Route path="/game">
<Box py={4}>
<Game />
</Box>
</Route>
</Switch>
</SocketProvider>
);
}
Example #3
Source File: index.js From AdaptivApps-fe with MIT License | 6 votes |
export default function EventsCalendar() {
const classes = useStyles();
const { loading, error, data, refetch } = useQuery(GET_EVENT_LIST);
// refetches EVENT_LIST without refreshing page
useEffect(() => {
refetch();
}, [refetch]);
if (loading) return <CircularProgress className={classes.loadingSpinner} />;
if (error) return `Error! ${error.message}`;
return (
<main className={classes.root}>
<Box className={classes.headingBox} borderBottom={2}>
<Typography className={classes.heading} variant="h1" gutterBottom>
Upcoming Events
</Typography>
</Box>
<Grid className={classes.grid}>
{data &&
data?.events?.map((event, id) => (
<EventCard key={id} event={event} />
))}
</Grid>
</main>
);
}
Example #4
Source File: Loading.js From usfm-grammar-online with MIT License | 6 votes |
export default function Loading() {
const classes = useStyles();
const { open } = useContext(GrammarContext);
return (
<Modal
open={open}
aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description"
>
<div className={classes.container}>
<Box
fontSize="h5.fontSize"
bgcolor="white"
p={1}
px={3}
borderRadius="5px"
color="grey"
border={2}
borderColor="text.primary"
>
Processing ...
</Box>
</div>
</Modal>
);
}
Example #5
Source File: ApiRoute.js From Designer-Client with GNU General Public License v3.0 | 6 votes |
export function ApisRoute(props) {
return (
<Box>
<Route exact path={props.match.path} component={ApiIndex} />
<Switch>
<Route path={`${props.match.path}/new`} component={New}/>
<Route path={`${props.match.path}/:id`} component={Show}/>
</Switch>
</Box>
)
}
Example #6
Source File: CaptureTooltip.js From treetracker-admin-client with GNU Affero General Public License v3.0 | 6 votes |
CaptureTooltip = ({ capture, toggleDrawer }) => {
return (
<Box>
<OptimizedImage
onClick={toggleDrawer(capture.id)}
src={capture.imageUrl}
style={{
height: '160px',
width: '160px',
border: '2px solid black',
borderRadius: '8px',
}}
/>
</Box>
);
}
Example #7
Source File: SimpleLabelProgress.js From Queen with MIT License | 6 votes |
SimpleLabelProgress = ({ value, label, current }) => {
const classes = useStyles();
return (
<Box>
{!!label && (
<Typography className={current ? classes.current : ''}>{`${label} : `}</Typography>
)}
<ProgressBar value={value} />
</Box>
);
}
Example #8
Source File: Dashboard.js From ehr with GNU Affero General Public License v3.0 | 6 votes |
render() {
const widgets = this.getWidgets();
return (
<Grid container direction="column" spacing={2}>
<Grid item>
<Timeline />
</Grid>
<Grid item>
<Box mt={2} ml={4}>
<Typography variant="h3" color="primary">
{t('ehr', 'Shortcuts')}
</Typography>
<Box mt={1} pl={2}>
<Grid container direction="row" spacing={2}>
<Grid item>
<DashboardWidget
onClick={() => this.props.toggleRequestDataModal(true)}
icon="ArchiveOutlined"
name={t('ehr', 'Request Data from Provider')}
/>
</Grid>
<Grid item>
<DashboardWidget
onClick={() => this.props.toggleImportDataModal(true)}
icon="CloudUploadOutlined"
name={t('ehr', 'Import Data')}
/>
</Grid>
{widgets}
</Grid>
</Box>
</Box>
</Grid>
</Grid>
);
}
Example #9
Source File: stock-details.js From ark-funds-monitor with GNU Affero General Public License v3.0 | 6 votes |
function TabPanel(props) {
const { children, value, index, ...other } = props;
return (
<div
role="tabpanel"
hidden={value !== index}
id={`scrollable-auto-tabpanel-${index}`}
aria-labelledby={`scrollable-auto-tab-${index}`}
{...other}
>
{value === index && (
<Box p={3}>
{children}
</Box>
)}
</div>
);
}
Example #10
Source File: ColorManyPicker.js From course-manager with MIT License | 6 votes |
function IconColor({ sx, ...other }) {
return (
<Box
sx={{
width: 20,
height: 20,
display: 'flex',
borderRadius: '50%',
position: 'relative',
alignItems: 'center',
justifyContent: 'center',
bgcolor: 'currentColor',
transition: (theme) =>
theme.transitions.create('all', {
duration: theme.transitions.duration.shortest
}),
...sx
}}
{...other}
>
<Icon icon={checkmarkFill} />
</Box>
);
}
Example #11
Source File: MainView.js From akashlytics-deploy with GNU General Public License v3.0 | 5 votes |
export function MainView() {
const classes = useStyles();
const [isShowingWelcome, setIsShowingWelcome] = useState(false);
const [isWelcomeShown, setIsWelcomeShown] = useState(false);
const [isNavOpen, setIsNavOpen] = useState(true);
const { balance, isRefreshingBalance } = useWallet();
useEffect(() => {
if (!isRefreshingBalance && typeof balance === "number" && balance === 0 && !isShowingWelcome && !isWelcomeShown) {
setIsShowingWelcome(true);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isRefreshingBalance, balance, isWelcomeShown, isShowingWelcome]);
const onOpenMenuClick = () => {
setIsNavOpen((prev) => !prev);
};
const onWelcomeClose = () => {
setIsWelcomeShown(true);
setIsShowingWelcome(false);
};
return (
<Layout marginTop={`${accountBarHeight}px`} height={`calc(100% - ${accountBarHeight}px) !important`}>
{isShowingWelcome && <WelcomeModal open={isShowingWelcome} onClose={onWelcomeClose} />}
<Box height="100%">
<AppBar position="fixed" color="default" elevation={0} component="header" className={classes.accountAppBar}>
<Toolbar variant="dense" className={classes.accountBar}>
<ErrorBoundary FallbackComponent={ErrorFallback}>
<WalletDisplay />
<CertificateDisplay />
</ErrorBoundary>
</Toolbar>
</AppBar>
<div className={classes.viewContainer}>
<LeftNav onOpenMenuClick={onOpenMenuClick} isNavOpen={isNavOpen} />
<Box className={classes.viewContentContainer} style={{ marginLeft: isNavOpen ? `${drawerWidth}px` : `${closedDrawerWidth}px` }}>
<ErrorBoundary FallbackComponent={ErrorFallback}>
<RightContent />
</ErrorBoundary>
</Box>
</div>
</Box>
</Layout>
);
}
Example #12
Source File: Board.js From TrelloClone with MIT License | 5 votes |
Board = ({ match }) => {
const board = useSelector((state) => state.board.board);
const isAuthenticated = useSelector((state) => state.auth.isAuthenticated);
const dispatch = useDispatch();
useEffect(() => {
dispatch(getBoard(match.params.id));
}, [dispatch, match.params.id]);
useEffect(() => {
if (board?.title) document.title = board.title + ' | TrelloClone';
}, [board?.title]);
if (!isAuthenticated) {
return <Redirect to='/' />;
}
const onDragEnd = (result) => {
const { source, destination, draggableId, type } = result;
if (!destination) {
return;
}
if (type === 'card') {
dispatch(
moveCard(draggableId, {
fromId: source.droppableId,
toId: destination.droppableId,
toIndex: destination.index,
})
);
} else {
dispatch(moveList(draggableId, { toIndex: destination.index }));
}
};
return !board ? (
<Fragment>
<Navbar />
<Box className='board-loading'>
<CircularProgress />
</Box>
</Fragment>
) : (
<div
className='board-and-navbar'
style={{
backgroundImage:
'url(' +
(board.backgroundURL
? board.backgroundURL
: 'https://images.unsplash.com/photo-1598197748967-b4674cb3c266?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2689&q=80') +
')',
}}
>
<Navbar />
<section className='board'>
<div className='board-top'>
<div className='board-top-left'>
<BoardTitle board={board} />
<Members />
</div>
<BoardDrawer />
</div>
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId='all-lists' direction='horizontal' type='list'>
{(provided) => (
<div className='lists' ref={provided.innerRef} {...provided.droppableProps}>
{board.lists.map((listId, index) => (
<List key={listId} listId={listId} index={index} />
))}
{provided.placeholder}
<CreateList />
</div>
)}
</Droppable>
</DragDropContext>
</section>
</div>
);
}
Example #13
Source File: game.js From connect-4-online-multiplayer with MIT License | 5 votes |
export default function Game() {
const [board, setBoard] = useState(intitializeBoard());
const [playerTurn, setPlayerTurn] = useState(Player.One);
const [gameState, setGameState] = useState(GameState.Ongoing);
const renderCells = () => {
return board.map((player, index) => renderCell(player, index));
};
const handleOnClick = (index) => () => {
if (gameState !== GameState.Ongoing) return;
const column = index % 7;
makeMove(column);
};
const makeMove = (column) => {
const index = findLowestEmptyIndex(board, column);
const newBoard = board.slice();
newBoard[index] = playerTurn;
const gameState = getGameState(newBoard);
setBoard(newBoard);
setPlayerTurn(togglePlayerTurn(playerTurn));
setGameState(gameState);
};
const renderCell = (player, index) => {
return (
<Box
className="cell"
key={index}
onClick={handleOnClick(index)}
data-player={getPrettyPlayer(player)}
/>
);
};
const renderGameStatus = () => {
let text;
if (gameState === GameState.Ongoing) {
text = "Game is in progress...";
} else if (gameState === GameState.Draw) {
text = "Game is a draw.";
} else if (gameState === GameState.PlayerOneWin) {
text = "Player 1 won!";
} else if (gameState === GameState.PlayerTwoWin) {
text = "Player 2 won!";
}
return (
<Typography variant="h3" align="center" mb={1}>
{text}
</Typography>
);
};
return (
<Box>
{renderGameStatus()}
<Box className="board" my={2}>
{renderCells()}
</Box>
{gameState === GameState.Ongoing ? (
<Typography variant="h3" align="center">
Player {playerTurn}'s Turn
</Typography>
) : null}
</Box>
);
}
Example #14
Source File: SimpleModal.js From AdaptivApps-fe with MIT License | 5 votes |
export default function SimpleModal({ activity, activityData }) {
const classes = useStyles();
// getModalStyle is not a pure function, we roll the style only on the first render
const [modalStyle] = React.useState(getModalStyle);
const [open, setOpen] = React.useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
const body = (
<Container style={modalStyle} className={classes.paper}>
<Box className={classes.imgBox}>
<img
className={classes.img}
src={
(activity && activity?.event?.imgUrl) ||
(activityData && activityData?.event?.imgUrl)
}
alt="Event"
/>
</Box>
<Box className={classes.modalMiddle}>
<Typography className={classes.title} id="simple-modal-title">
{activity.name}
</Typography>
<Typography className={classes.date}>{activity.startTime}</Typography>
<Typography className={classes.details} id="simple-modal-description">
{activity?.details}
</Typography>
</Box>
<Box className={classes.modalBottom}>
<Box>
<Button className={classes.modalBtn2} onClick={handleClose}>
Close
</Button>
</Box>
</Box>
</Container>
);
return (
<div>
<Button className={classes.btn} onClick={handleOpen}>
{activity.name}
</Button>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description"
>
{body}
</Modal>
</div>
);
}
Example #15
Source File: WriterServices.js From grants-fe with MIT License | 5 votes |
WriterServices = (props) => {
const [value, setValue] = React.useState(0);
const classes = useStyles();
const handleChange = (event, newValue) => {
setValue(newValue);
};
function TabPanel(props) {
const { children, value, index, ...other } = props;
return (
<div
role="tabpanel"
hidden={value !== index}
id={`vertical-tabpanel-${index}`}
aria-labelledby={`vertical-tab-${index}`}
{...other}
>
{value === index && (
<Box p={3}>
<Typography>{children}</Typography>
</Box>
)}
</div>
);
}
TabPanel.propTypes = {
children: PropTypes.node,
index: PropTypes.any.isRequired,
value: PropTypes.any.isRequired,
};
function a11yProps(index) {
return {
id: `vertical-tab-${index}`,
"aria-controls": `vertical-tabpanel-${index}`,
};
}
return (
<div className={classes.userServices}>
<h3 className={classes.userEducation}>Services Offered:</h3>
<Paper>
<Tabs
orientation="vertical"
variant="scrollable"
value={value}
onChange={handleChange}
aria-label="Vertical tabs example"
className={classes.tabs}
>
<Tab label="Grant Writing" {...a11yProps(0)} />
<Tab label="Grant Research" {...a11yProps(1)} />
</Tabs>
<TabPanel value={value} index={0}>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quos
blanditiis tenetur unde suscipit, quam beatae rerum inventore
consectetur, neque doloribus, cupiditate numquam dignissimos
laborum fugiat deleniti? Eum quasi quidem quibusdam.
</TabPanel>
<TabPanel value={value} index={1}>
This is just here to show you this works.
</TabPanel>
</Paper>
</div>
);
}
Example #16
Source File: LeftPanel.js From usfm-grammar-online with MIT License | 5 votes |
LeftPanel = (props) => {
const { usfmValue, setUsfmValue, mode, setMode } = useContext(GrammarContext);
const handleTextChange = (event) => {
setUsfmValue(event.target.value);
};
const handleChange = (event) => {
setMode(event.target.value);
};
return (
<>
<AppBar position="static" color="default">
<Toolbar>
<Box flexGrow={1} display="flex">
<Link href="https://github.com/ubsicap/usfm" target="_blank">
<Typography
style={{
marginRight: 20,
color: "black",
}}
variant="h6"
>
USFM
</Typography>
</Link>
<FormControl variant="outlined" style={{ width: 106 }}>
<InputLabel id="demo-simple-select-outlined-label">
Mode
</InputLabel>
<Select
style={{ height: 37 }}
labelId="demo-simple-select-outlined-label"
id="demo-simple-select-outlined"
value={mode}
onChange={handleChange}
label="Mode"
>
<MenuItem value="regular">Regular</MenuItem>
<MenuItem value="relaxed">Relaxed</MenuItem>
</Select>
</FormControl>
<ParseUsfm />
</Box>
<Upload setValue={setUsfmValue} type="usfm" />
<Download extension="usfm" />
</Toolbar>
</AppBar>
<CssTextField
id="usfmText"
placeholder="Enter/Upload USFM Text"
onChange={handleTextChange}
value={usfmValue}
/>
</>
);
}
Example #17
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 #18
Source File: ResourceRoute.js From Designer-Client with GNU General Public License v3.0 | 5 votes |
export function ResourceRoute(props) {
return (
<Box>
<Route exact path={props.match.path} component={ResourceIndex} />
</Box>
)
}
Example #19
Source File: viewer.js From healthcare-api-dicom-viewer with Apache License 2.0 | 5 votes |
/**
* Renders the component
* @return {ReactComponent} <Viewer/>
*/
render() {
return (
<Box p={2} display="flex" flexWrap="wrap">
<Box mr={2}>
<div id="cornerstone-div"
ref={(input) => {
this.canvasElement = input;
}}
style={{
width: 500,
height: 500,
background: 'black',
}}
>
<canvas className="cornerstone-canvas"></canvas>
</div>
<LinearProgress variant="buffer"
value={this.state.renderedImagesProgress}
valueBuffer={this.state.readyImagesProgress} /><br/>
<TextField
label="Max Simultaneous Requests"
style={{width: 250}}
defaultValue={this.state.maxSimultaneousRequests}
onChange={(e) => {
this.setState({maxSimultaneousRequests: Number(e.target.value)});
}} /><br/><br/>
<Button
variant="contained"
color="primary"
disabled={this.state.isDisplaying}
onClick={() => this.getInstances()}>
Start
</Button>
</Box>
<Box>
<Typography variant="h5">
Frames Loaded: {this.state.numReadyImages}
</Typography>
<Typography variant="h5">
Frames Displayed: {this.state.numRenderedImages}
</Typography>
<Typography variant="h5">
Total Time: {(this.state.totalTimer / 1000).toFixed(2)}s
</Typography>
<Typography variant="h5">
Time to First Image: {
(this.state.timeToFirstImage / 1000).toFixed(2)
}s
</Typography>
<Typography variant="h5">
Average FPS: {(this.state.numRenderedImages /
(this.state.renderTimer / 1000)).toFixed(2)}
</Typography>
<Typography variant="body1">
Use your browser's developer tools to see bandwidth usage.
</Typography>
</Box>
</Box>
);
}
Example #20
Source File: ProfileMenu.js From ehr with GNU Affero General Public License v3.0 | 5 votes |
render() {
const menuItems = this.getMenuItems();
const { anchorEl } = this.state;
const open = Boolean(anchorEl);
return (
<div className="profile-menu">
<DropdownIcon
aria-label="more"
aria-controls="long-menu"
aria-haspopup="true"
onClick={this.handleClick}
disableRipple={true}
size="small"
>
<ArrowDropDown />
</DropdownIcon>
<Menu
id="menu-items"
anchorEl={anchorEl}
keepMounted
open={open}
onClose={this.handleClose}
getContentAnchorEl={null}
anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
transformOrigin={{ vertical: 'top', horizontal: 'left' }}
style={{ marginTop: '9px' }}
>
{menuItems}
<Box m={1}>
<Divider />
</Box>
<MenuItem className="menuItem" onClick={this.onImportDataMenuItemClick}>
<span className="menuItemIcon">{getIcon('CloudUploadOutlined')}</span>
<span className="menuItemLabel">{t('ehr', 'Import Data')}</span>
</MenuItem>
<MenuItem className="menuItem" onClick={this.onPatientProfileMenuItemClick}>
<span className="menuItemIcon">{getIcon('PersonOutline')}</span>
<span className="menuItemLabel">{t('ehr', 'Patient Profile')}</span>
</MenuItem>
</Menu>
</div>
);
}