@stevederico/skateboard-ui 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/ProtectedRoute.jsx +8 -0
- package/README.md +7 -0
- package/Utilities.js +20 -2
- package/index.js +3 -1
- package/package.json +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
|
+
0.9.8
|
|
3
|
+
|
|
4
|
+
Add ProtectedRoute component
|
|
5
|
+
Add useAppSetup hook
|
|
6
|
+
Export isAuthenticated utility
|
|
7
|
+
Add react-router-dom peer dependency
|
|
8
|
+
|
|
9
|
+
0.9.7
|
|
10
|
+
|
|
11
|
+
Export getCSRFToken utility
|
|
12
|
+
Export getAppKey utility
|
|
13
|
+
|
|
2
14
|
0.9.6
|
|
3
15
|
|
|
4
16
|
Add SignOutView component
|
package/README.md
CHANGED
|
@@ -45,6 +45,13 @@ import { ThemeToggle } from '@stevederico/skateboard-ui/ThemeToggle'
|
|
|
45
45
|
```javascript
|
|
46
46
|
import { cn } from '@stevederico/skateboard-ui/shadcn/lib/utils'
|
|
47
47
|
import { useMobile } from '@stevederico/skateboard-ui/shadcn/hooks/use-mobile'
|
|
48
|
+
import { isAuthenticated, getAppKey, useAppSetup } from '@stevederico/skateboard-ui/Utilities'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Routing
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
import ProtectedRoute from '@stevederico/skateboard-ui/ProtectedRoute'
|
|
48
55
|
```
|
|
49
56
|
|
|
50
57
|
## Dependencies
|
package/Utilities.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
1
2
|
import constants from "@/constants.json";
|
|
2
3
|
|
|
3
4
|
export function getCookie(name) {
|
|
@@ -14,17 +15,25 @@ export function getCookie(name) {
|
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
function getCSRFToken() {
|
|
18
|
+
export function getCSRFToken() {
|
|
18
19
|
const appName = constants.appName || 'skateboard';
|
|
19
20
|
const csrfKey = `${appName.toLowerCase().replace(/\s+/g, '-')}_csrf`;
|
|
20
21
|
return localStorage.getItem(csrfKey);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
function getAppKey(suffix) {
|
|
24
|
+
export function getAppKey(suffix) {
|
|
24
25
|
const appName = constants.appName || 'skateboard';
|
|
25
26
|
return `${appName.toLowerCase().replace(/\s+/g, '-')}_${suffix}`;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
export function isAuthenticated() {
|
|
30
|
+
if (constants.noLogin === true) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const csrfKey = getAppKey('csrf');
|
|
34
|
+
return Boolean(localStorage.getItem(csrfKey));
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
export function getBackendURL() {
|
|
29
38
|
let result = import.meta.env.DEV ? constants.devBackendURL : constants.backendURL;
|
|
30
39
|
return result
|
|
@@ -373,4 +382,13 @@ export function timestampToString(input, format = "DOB") {
|
|
|
373
382
|
}
|
|
374
383
|
}
|
|
375
384
|
|
|
385
|
+
export function useAppSetup(location) {
|
|
386
|
+
useEffect(() => {
|
|
387
|
+
document.title = constants.appName;
|
|
388
|
+
if (!location.pathname.toLowerCase().includes('app')) {
|
|
389
|
+
document.documentElement.classList.remove('dark');
|
|
390
|
+
document.body.classList.remove('dark');
|
|
391
|
+
}
|
|
392
|
+
}, [location.pathname]);
|
|
393
|
+
}
|
|
376
394
|
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stevederico/skateboard-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./AppSidebar": {
|
|
@@ -72,6 +72,10 @@
|
|
|
72
72
|
"import": "./Utilities.js",
|
|
73
73
|
"default": "./Utilities.js"
|
|
74
74
|
},
|
|
75
|
+
"./ProtectedRoute": {
|
|
76
|
+
"import": "./ProtectedRoute.jsx",
|
|
77
|
+
"default": "./ProtectedRoute.jsx"
|
|
78
|
+
},
|
|
75
79
|
"./shadcn/ui/*": "./shadcn/ui/*.jsx",
|
|
76
80
|
"./shadcn/lib/utils": {
|
|
77
81
|
"import": "./shadcn/lib/utils.js",
|
|
@@ -136,7 +140,8 @@
|
|
|
136
140
|
},
|
|
137
141
|
"peerDependencies": {
|
|
138
142
|
"react": "^19.1.0",
|
|
139
|
-
"react-dom": "^19.1.0"
|
|
143
|
+
"react-dom": "^19.1.0",
|
|
144
|
+
"react-router-dom": "^6.0.0"
|
|
140
145
|
},
|
|
141
146
|
"overrides": {
|
|
142
147
|
"@radix-ui/react-slot": "^1.2.3"
|