react-device-detect#isBrowser TypeScript Examples
The following examples show how to use
react-device-detect#isBrowser.
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: Header.tsx From peterportal-client with MIT License | 5 votes |
Header: FC<HeaderProps> = ({ courseCount, unitCount, saveRoadmap }) => {
const dispatch = useAppDispatch();
const [target, setTarget] = useState<any>(null!);
const [showMenu, setShowMenu] = useState(false);
const buttons = <>
<Button variant={isMobile ? "primary" : 'light'} className={isMobile ? 'my-1' : "header-btn"} onClick={() => dispatch(setShowTransfer(true))}>
Transfer Credits
<ArrowLeftRight className="header-icon" />
</Button>
<Button variant={isMobile ? "primary" : 'light'} className={isMobile ? 'my-1' : "header-btn"} onClick={saveRoadmap}>
Save
<Save className="header-icon" />
</Button>
<Button variant={isMobile ? "primary" : 'light'} className={isMobile ? 'my-1' : "header-btn"} onClick={() => dispatch(clearPlanner())}>
Clear
<Trash className="header-icon" />
</Button>
</>
const onMenuClick = (event: React.MouseEvent) => {
setShowMenu(!showMenu);
setTarget(event.target);
};
return (
<div className="header">
<Transfer />
<div>
<div id="title">
Peter's Roadmap
</div>
<span id="planner-stats">
Total: <span id="course-count">{courseCount}</span>{" "}
{courseCount === 1 ? "course" : "courses"},{" "}
<span id="unit-count">{unitCount}</span>{" "}
{unitCount === 1 ? "unit" : "units"}
</span>
</div>
<div>
{
isMobile && <>
<Button variant="light" className="header-btn add-course" onClick={() => { dispatch(setShowSearch(true)) }}>
<Plus className="header-icon mr-1" />
Add Course
</Button>
<List className='mx-3' onClick={onMenuClick} />
<Overlay show={showMenu} target={target} placement="left">
<Popover id='roadmap-header-buttons'>
<Popover.Content>
<div className='d-flex flex-column'>
{buttons}
</div>
</Popover.Content>
</Popover>
</Overlay>
</>
}
{
isBrowser && <ButtonGroup>
{buttons}
</ButtonGroup>
}
</div>
</div >
)
}