@stevederico/skateboard-ui 5.8.0 → 5.9.0

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 CHANGED
@@ -1,3 +1,8 @@
1
+ 5.9.0
2
+
3
+ Default to sign up
4
+ Remember past sign-in
5
+
1
6
  5.8.0
2
7
 
3
8
  Fix Sheet scrolling
@@ -4,7 +4,8 @@ import React from 'react';
4
4
  *
5
5
  * Rendered at the app root and controlled via context state.
6
6
  * Opens when SHOW_AUTH_OVERLAY is dispatched (typically via useAuthGate).
7
- * On successful auth, runs the pending callback and closes.
7
+ * On successful auth, runs the pending callback and closes. Opens on Sign Up,
8
+ * or on Sign In when this device has been signed in before.
8
9
  *
9
10
  * @returns {JSX.Element} Auth dialog overlay
10
11
  *
@@ -5,12 +5,22 @@ import ConstantsIcon from './core/constantsIcon.js';
5
5
  import { getState } from './core/Context.js';
6
6
  import SignInView from './views/SignInView.js';
7
7
  import SignUpView from './views/SignUpView.js';
8
+ const HAD_ACCOUNT_KEY = 'skateboard_had_account';
9
+ function hadAccount() {
10
+ try {
11
+ return localStorage.getItem(HAD_ACCOUNT_KEY) === '1';
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ }
8
17
  /**
9
18
  * Modal authentication overlay with sign-in and sign-up forms.
10
19
  *
11
20
  * Rendered at the app root and controlled via context state.
12
21
  * Opens when SHOW_AUTH_OVERLAY is dispatched (typically via useAuthGate).
13
- * On successful auth, runs the pending callback and closes.
22
+ * On successful auth, runs the pending callback and closes. Opens on Sign Up,
23
+ * or on Sign In when this device has been signed in before.
14
24
  *
15
25
  * @returns {JSX.Element} Auth dialog overlay
16
26
  *
@@ -24,11 +34,20 @@ export default function AuthOverlay() {
24
34
  const { state, dispatch } = getState();
25
35
  const constants = state.constants;
26
36
  const { visible } = state.authOverlay;
27
- const [mode, setMode] = useState('signin');
28
- // Reset mode when dialog opens
37
+ const [mode, setMode] = useState('signup');
38
+ // Remember that this device has had an account
39
+ useEffect(() => {
40
+ if (state.user) {
41
+ try {
42
+ localStorage.setItem(HAD_ACCOUNT_KEY, '1');
43
+ }
44
+ catch { /* storage blocked */ }
45
+ }
46
+ }, [state.user]);
47
+ // Most visitors are new: open on Sign Up, or Sign In if this device has signed in before
29
48
  useEffect(() => {
30
49
  if (visible) {
31
- setMode('signin');
50
+ setMode(hadAccount() ? 'signin' : 'signup');
32
51
  }
33
52
  }, [visible]);
34
53
  // Invoke parked 401 retries (apiRequest, Utilities.js) here in event handlers —
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stevederico/skateboard-ui",
3
3
  "private": false,
4
- "version": "5.8.0",
4
+ "version": "5.9.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {