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

Add Shortcuts #958

Merged
merged 19 commits into from
Jan 9, 2023
Merged
Changes from 1 commit
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
44 changes: 34 additions & 10 deletions src/ui/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { jsx, useColorMode } from 'theme-ui';

import { Link, NavLink, useLocation } from 'react-router-dom';
import { Fragment, useState } from 'react';
import React, { Fragment, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
Expand Down Expand Up @@ -97,6 +97,16 @@ const NavElement = ({ target, children, icon, ...rest }) => {
const { isRecording } = useStudioState();
const [ colorMode ] = useColorMode();

const [matches, setMatches] = useState(
window.matchMedia("(min-width: 700px)").matches
)

React.useEffect(() => {
window
.matchMedia("(min-width: 700px)")
.addEventListener('change', e => setMatches( e.matches ));
}, []);
narickmann marked this conversation as resolved.
Show resolved Hide resolved

return (
<NavLink
to={{
Expand Down Expand Up @@ -129,15 +139,29 @@ const NavElement = ({ target, children, icon, ...rest }) => {
}}
{...rest}
>
<div sx={{
width: '20px',
display: 'inline-block',
textAlign: 'right',
mr: [3, 3, 2],
}}>
<FontAwesomeIcon icon={icon} />
</div>
{children}
{matches && ( <>
<div sx={{
width: '20px',
display: 'inline-block',
textAlign: 'right',
mr: [3, 3, 2],
}}>
<FontAwesomeIcon icon={icon} />
</div>
{children}
</> )}

{!matches && ( <>
<div sx={{
width: '20px',
display: 'contents',
textAlign: 'right',
mr: [3, 3, 2],
}}>
<FontAwesomeIcon icon={icon} />
</div>
</> )}
narickmann marked this conversation as resolved.
Show resolved Hide resolved

</NavLink>
);
}
Expand Down