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

Navbar cleanup and enable mobile menu #989

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file modified www/public/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions www/src/App.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.body-content {
min-height: calc(100vh - 56px);
min-width: 400px;
display: flex;
margin-top: 56px;
margin-top: 58px;
flex-direction: column;
padding: 10px 20px;
}
36 changes: 17 additions & 19 deletions www/src/Components/ColorScheme.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
import { Dropdown } from 'react-bootstrap';
import { Dropdown, DropdownButton } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';

import { AppContext } from '../Contexts/AppContext';
Expand Down Expand Up @@ -47,24 +47,22 @@ const ColorScheme = () => {
};

return (
<Dropdown>
<Dropdown.Toggle variant="secondary" style={{ marginRight: '7px' }}>
<MoonStarsIcon />
</Dropdown.Toggle>

<Dropdown.Menu>
{translatedDropdownOptions.map((option) => (
<Dropdown.Item
key={option.scheme}
as={'button'}
className={savedColorScheme === option.scheme ? 'active' : ''}
onClick={() => setThemeAndState(option.scheme)}
>
<option.icon /> {option.label}
</Dropdown.Item>
))}
</Dropdown.Menu>
</Dropdown>
<DropdownButton
variant="secondary"
align="end"
title={<MoonStarsIcon />}
>
{translatedDropdownOptions.map((option) => (
<Dropdown.Item
key={option.scheme}
as={'button'}
className={savedColorScheme === option.scheme ? 'active' : ''}
onClick={() => setThemeAndState(option.scheme)}
>
<option.icon /> {option.label}
</Dropdown.Item>
))}
</DropdownButton>
);
};

Expand Down
38 changes: 18 additions & 20 deletions www/src/Components/LanguageSelector.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext, useEffect } from 'react';
import { Dropdown } from 'react-bootstrap';
import { Dropdown , DropdownButton } from 'react-bootstrap';
import { AppContext } from '../Contexts/AppContext';
import { useTranslation } from 'react-i18next';
import GlobeIcon from '../Icons/Globe';
Expand Down Expand Up @@ -37,25 +37,23 @@ const LanguageSelector = () => {
};

return (
<Dropdown>
<Dropdown.Toggle variant="secondary" style={{ marginRight: '7px' }}>
<GlobeIcon />
</Dropdown.Toggle>

<Dropdown.Menu>
{dropdownOptions.map((option) => (
<Dropdown.Item
key={option.code}
className={`dropdown-item ${
savedLanguage === option.code ? 'active' : ''
}`}
onClick={() => setLanguageAndState(option.code)}
>
<option.icon /> {t(`language-selector.${option.code}`)}
</Dropdown.Item>
))}
</Dropdown.Menu>
</Dropdown>
<DropdownButton
variant="secondary"
align="end"
title={<GlobeIcon />}
>
{dropdownOptions.map((option) => (
<Dropdown.Item
key={option.code}
className={`dropdown-item ${
savedLanguage === option.code ? 'active' : ''
}`}
onClick={() => setLanguageAndState(option.code)}
>
<option.icon /> {t(`language-selector.${option.code}`)}
</Dropdown.Item>
))}
</DropdownButton>
);
};

Expand Down
59 changes: 24 additions & 35 deletions www/src/Components/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Navbar,
Button,
Modal,
Dropdown,
} from 'react-bootstrap';
import { NavLink } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -51,6 +50,10 @@ const Navigation = () => {
};

const { t } = useTranslation('');

// eventKey prop is required on NavLink components in order for mobile menu
// to autoclose, so just auto increment as we build the menu
let eventKey = 0;

return (
<Navbar
Expand All @@ -60,43 +63,43 @@ const Navigation = () => {
expand="md"
fixed="top"
>
<Navbar.Brand href="/">
<img src="images/logo.png" className="title-logo" alt="logo" />{' '}
{t('Common:brand-text')}
<Navbar.Brand href="/" title={`GP2040-CE ${t('Navigation:home-label')}`}>
<img src="images/logo.png" className="title-logo" alt="GP2040-CE logo" />{' '}
</Navbar.Brand>
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="me-auto">
<Nav.Link as={NavLink} to="/">
{t('Navigation:home-label')}
</Nav.Link>
<Nav.Link as={NavLink} to="/settings">
<Nav.Link as={NavLink} to="/settings" eventKey={eventKey++}>
{t('Navigation:settings-label')}
</Nav.Link>
<NavDropdown title={t('Navigation:config-label')}>
<NavDropdown.Item as={NavLink} to="/pin-mapping">
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/pin-mapping">
{t('Navigation:pin-mapping-label')}
</NavDropdown.Item>
<NavDropdown.Item as={NavLink} to="/peripheral-mapping">
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/peripheral-mapping">
{t('Navigation:peripheral-mapping-label')}
</NavDropdown.Item>
<NavDropdown.Item as={NavLink} to="/led-config">
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/led-config">
{t('Navigation:led-config-label')}
</NavDropdown.Item>
<NavDropdown.Item as={NavLink} to="/custom-theme">
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/custom-theme">
{t('Navigation:custom-theme-label')}
</NavDropdown.Item>
<NavDropdown.Item as={NavLink} to="/display-config">
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/display-config">
{t('Navigation:display-config-label')}
</NavDropdown.Item>
<NavDropdown.Item as={NavLink} to="/add-ons">
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/add-ons">
{t('Navigation:add-ons-label')}
</NavDropdown.Item>
<NavDropdown.Item as={NavLink} to="/macro">
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/macro">
{t('Navigation:macro-label')}
</NavDropdown.Item>
<NavDropdown.Item as={NavLink} to="/backup">
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/backup">
{t('Navigation:backup-label')}
</NavDropdown.Item>
<NavDropdown.Item as={NavLink} eventKey={eventKey++} to="/reset-settings">
<span className="reset-settings-link">{t('Navigation:resetSettings-label')}</span>
</NavDropdown.Item>
</NavDropdown>
<NavDropdown title={t('Navigation:links-label')}>
<NavDropdown.Item href="https://gp2040-ce.info/" target="_blank">
Expand All @@ -109,33 +112,20 @@ const Navigation = () => {
{t('Navigation:github-label')}
</NavDropdown.Item>
</NavDropdown>

<Dropdown>
<Dropdown.Toggle variant="danger">
{t('Navigation:dangerZone-label').toUpperCase()}
</Dropdown.Toggle>

<Dropdown.Menu>
<Dropdown.Item href="/reset-settings">
{t('Navigation:resetSettings-label')}
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Nav>
<Nav>
<LanguageSelector />
<ColorScheme />
<Nav className="navbar-actions">
<Button
style={{ marginRight: '7px' }}
variant="success"
onClick={handleShow}
>
{t('Navigation:reboot-label')}
</Button>
<div style={{ marginTop: '4px', marginRight: '10px' }}>
<ColorScheme />
<LanguageSelector />
<div className="navbar-label-select">
<FormSelect
name="buttonLabels"
className="form-select-sm"
className="form-select"
value={buttonLabels.buttonLabelType}
onChange={updateButtonLabels}
>
Expand All @@ -148,7 +138,6 @@ const Navigation = () => {
</option>
))}
</FormSelect>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
</div>
</Nav>
</Navbar.Collapse>
Expand Down
46 changes: 44 additions & 2 deletions www/src/Components/Navigation.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,51 @@
$nav-outer-margin: 0.75rem;

nav.navbar {
padding: 0;

.navbar-brand {
margin-right: $nav-outer-margin;
}

.navbar-toggler {
margin-right: $nav-outer-margin;
}

.navbar-actions {
margin-right: $nav-outer-margin;
column-gap: 0.5rem;
align-items: center;
flex-direction: row-reverse;

.dropdown-menu {
position: absolute;
}
}

.reset-settings-link {
color: #FF0000;
}
}

.title-logo {
height: 30px;
margin: -5px 8px 0 12px;
height: 40px;
margin: 0.25rem 0rem 0.25rem $nav-outer-margin;
}

.nav-link,
.nav-item * {
font-size: 0.875rem;
}

@media (max-width: 767.98px) {
nav.navbar {
.navbar-actions {
margin-top: 1rem;
margin-bottom: 1rem;
}

.nav-link {
margin-left: $nav-outer-margin;
}
}
}
4 changes: 2 additions & 2 deletions www/src/Data/Buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const BUTTONS = {
Fn: 'Function',
},
switch: {
label: 'Nintendo Switch',
label: 'Switch',
value: 'switch',
Up: 'Up',
Down: 'Down',
Expand Down Expand Up @@ -138,7 +138,7 @@ export const BUTTONS = {
Fn: 'Function',
},
dinput: {
label: 'DirectInput',
label: 'DInput',
value: 'dinput',
Up: 'Up',
Down: 'Down',
Expand Down