Skip to content

Commit 46b3811

Browse files
authored
Merge pull request #114 from neonexus/master
v4.3.0
2 parents 2b2b6cc + 0cbad83 commit 46b3811

File tree

92 files changed

+1678
-16723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1678
-16723
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ config/local.js
1414
test
1515

1616
**/README*
17-
CHANGELOG.md
17+
*.md
1818
LICENSE

.github/workflows/codeql.yml renamed to .github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
analyze:
2020
name: Analyze
2121
runs-on: ubuntu-latest
22+
timeout-minutes: 360
2223
permissions:
2324
actions: read
2425
contents: read

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,7 @@ app.zip
149149

150150
# Downloaded binary files
151151
.bin
152+
153+
# Code coverage
154+
test/coverage/*
155+
!test/coverage/.gitkeep

.mocharc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require:
55
spec:
66
- 'test/unit/index.js'
77
- 'test/integration/index.js'
8-
timeout: 10000 # Give Sails some breathing room... We are building schemas / data fixtures.
8+
timeout: 60000 # Give Sails some breathing room... We are building schemas / data fixtures.
99
checkLeaks: true
1010
global:
1111
- '_' # Lodash global

.npmrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
# Hide NPM log output unless it is related to an error of some kind:
88
loglevel=error
99

10-
# Make "npm audit" an opt-in thing for subsequent installs within this app:
10+
# Run "npm audit" after installs
1111
audit=true
12-
13-
# Don't install optional dependencies automatically (which is a weird default NPM...):
14-
omit=optional

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ services: mysql
88
before_install:
99
- mysql -e 'CREATE DATABASE IF NOT EXISTS testing;'
1010
- mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'mypass'"
11+
after_success: npm run codecov
12+
deploy:
13+
skip_cleanup: true

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
# Changelog
2+
3+
## [v4.3.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v4.2.4...v4.3.0) (2023-11-04)
4+
### Features
5+
6+
* Fixed the "create user" modal.
7+
* Fixed the pagination bar when `pages` = 0.
8+
* Added small css tweaks for light / dark theme transitions.
9+
* Updated Node LTS version for docker / package.
10+
* Removed `omit=optional` from `.npmrc`.
11+
* Replaced code coverage files with [Codecov](https://codecov.io).
12+
* Updated dependencies.
13+
14+
### Breaking Changes
15+
16+
* Replaced [`ngrok`](https://npmjs.org/package/ngrok) with official [`@ngrok/ngrok`](https://npmjs.org/package/@ngrok/ngrok) in [ngrok.js](ngrok.js).
17+
18+
## [v4.2.4](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v4.2.3...v4.2.4) (2023-10-30)
19+
### Features
20+
21+
* Fixed Bootstrap build. (Missing dark-mode file.)
22+
* Built light / dark / auto switch for admin.
23+
* Updated dependencies.
24+
225
## [v4.2.3](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v4.2.2...v4.2.3) (2023-10-03)
326
### Features
427

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18.17
1+
FROM node:20-slim
22
MAINTAINER NeoNexus DeMortis
33

44
RUN mkdir /var/www && mkdir /var/www/myapp

README.md

Lines changed: 79 additions & 43 deletions
Large diffs are not rendered by default.

assets/src/Admin/NavBar.jsx

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,119 @@
1-
import { useState, useContext } from 'react';
1+
import {useState, useContext, useEffect} from 'react';
22
import PropTypes from 'prop-types';
33

44
import {Button, Nav, Navbar, NavDropdown} from 'react-bootstrap';
55
import {NavLink as ReactNavLink} from 'react-router-dom';
66

77
import UserContext from '../data/UserContext';
88

9+
function scrollListener() {
10+
const nav = document.querySelector('nav');
11+
12+
if (nav) {
13+
if (window.scrollY > 0 && window.scrollY < 26) {
14+
nav.classList.add('shadow-sm');
15+
nav.classList.remove('shadow');
16+
} else if (window.scrollY > 25) {
17+
nav.classList.add('shadow');
18+
nav.classList.remove('shadow-sm');
19+
} else {
20+
nav.classList.remove('shadow');
21+
nav.classList.remove('shadow-sm');
22+
}
23+
}
24+
}
25+
926
function NavBar(props) {
1027
const [isExpanded, setIsExpanded] = useState(false);
1128
const user = useContext(UserContext);
1229

30+
const [lightOrDark, setLightOrDark] = useState(window.localStorage.getItem('theme'));
31+
let lightDarkAutoClass = 'bi-circle-half';
32+
33+
if (lightOrDark === 'dark') {
34+
lightDarkAutoClass = 'bi-moon-fill';
35+
} else if (lightOrDark === 'light') {
36+
lightDarkAutoClass = 'bi-sun-fill';
37+
}
38+
1339
function closeNavbar() {
1440
setIsExpanded(false);
1541
}
1642

43+
function switchTheme(e) {
44+
const newTheme = e.target.getAttribute('data-theme-set');
45+
46+
setLightOrDark(newTheme);
47+
window.localStorage.setItem('theme', newTheme);
48+
49+
tellBootstrapAboutTheme(newTheme);
50+
}
51+
52+
function tellBootstrapAboutTheme(newTheme) {
53+
if (newTheme === 'light' || newTheme === 'dark') {
54+
document.documentElement.setAttribute('data-bs-theme', newTheme);
55+
} else {
56+
document.documentElement.setAttribute('data-bs-theme', window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
57+
}
58+
}
59+
60+
function themeListener() {
61+
tellBootstrapAboutTheme(lightOrDark);
62+
}
63+
64+
useEffect(() => {
65+
window.addEventListener('scroll', scrollListener);
66+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', themeListener);
67+
68+
// If we don't do this, and the page loads with "auto" and the user wants it dark, it won't change.
69+
tellBootstrapAboutTheme(lightOrDark);
70+
71+
return () => {
72+
window.removeEventListener('scroll', scrollListener);
73+
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', themeListener);
74+
};
75+
});
76+
1777
return (
1878
<Navbar
19-
bg="dark"
20-
variant="dark"
79+
bg="body-tertiary"
2180
expand="sm"
2281
sticky="top"
23-
className="mb-3 ps-3 pe-3"
82+
className="mb-3 ps-3 pe-3 border-bottom"
2483
expanded={isExpanded}
2584
onToggle={() => setIsExpanded(!isExpanded)}
2685
>
2786
<Navbar.Brand>{appConfig.appName}</Navbar.Brand>
2887
<Navbar.Toggle aria-controls="basic-navbar-nav" />
2988
<Navbar.Collapse id="basic-navbar-nav">
30-
<Nav className="me-auto">
89+
<Nav className="me-auto" navbarScroll>
3190
<Nav.Link as={ReactNavLink} to="/admin/dashboard" onClick={closeNavbar}>Home</Nav.Link>
3291
{
3392
(user.info.role === 'admin')
3493
? <Nav.Link as={ReactNavLink} to="/admin/users" onClick={closeNavbar}>Users</Nav.Link>
3594
: null
3695
}
3796
<Nav.Link as={ReactNavLink} to="/admin/404" onClick={closeNavbar}>404 Page</Nav.Link>
38-
<NavDropdown title="Settings" id="basic-nav-dropdown" menuVariant="dark">
39-
<NavDropdown.Item className="ps-3 pe-3" as={ReactNavLink} to="/admin/settings/profile" onClick={closeNavbar}>Profile</NavDropdown.Item>
40-
<NavDropdown.Item className="ps-3 pe-3" as={ReactNavLink} to="/admin/settings/security" onClick={closeNavbar}>Security</NavDropdown.Item>
97+
<NavDropdown title="Settings" id="basic-nav-dropdown">
98+
<NavDropdown.Item className="ps-3 pe-3" as={ReactNavLink} to="/admin/settings/profile" onClick={closeNavbar}><i className="bi bi-person-fill" /> Profile</NavDropdown.Item>
99+
<NavDropdown.Item className="ps-3 pe-3" as={ReactNavLink} to="/admin/settings/security" onClick={closeNavbar}><i className="bi bi-shield-lock-fill" /> Security</NavDropdown.Item>
41100
</NavDropdown>
42101
</Nav>
43102

44103
{
45104
user.isLoggedIn ?
46105
<>
47-
<span className="text-white d-none d-md-block">Welcome, {user.info.firstName} &nbsp; &nbsp; </span>
106+
<Navbar.Text>Welcome, {user.info.firstName} &nbsp; &nbsp; </Navbar.Text>
48107
<Button variant="danger" onClick={() => props.handleLogout()} size="sm" className="mt-2 mt-sm-0 mb-2 mb-sm-0">Logout</Button>
49108
</>
50109
: null
51110
}
111+
112+
<NavDropdown title={<i className={'bi ' + lightDarkAutoClass}/>} id="light-or-dark-toggle" className="ms-3 right-align-menu">
113+
<NavDropdown.Item className="bi bi-sun-fill" active={lightOrDark === 'light'} data-theme-set="light" onClick={switchTheme}>Light</NavDropdown.Item>
114+
<NavDropdown.Item className="bi bi-moon-fill" active={lightOrDark === 'dark'} data-theme-set="dark" onClick={switchTheme}>Dark</NavDropdown.Item>
115+
<NavDropdown.Item className="bi bi-circle-half" active={lightOrDark !== 'light' && lightOrDark !== 'dark'} data-theme-set="auto" onClick={switchTheme}>Auto</NavDropdown.Item>
116+
</NavDropdown>
52117
</Navbar.Collapse>
53118
</Navbar>
54119
);

0 commit comments

Comments
 (0)