Closed koistya closed 2 years ago
"type": "module"
package.json
db/package.json
^4.4.4
^4.5.5
^8.2.0
^8.7.0
^2.4.1
^2.5.1
.prettierrc.js
package.json->prettier
jest.config.js
package.json->jest
scripts/*.js
zx
api
yarn api:build
moment-timezone
date-fns
date-fns-tz
img
web
Auth
Theme
LoginDialog
authorize: true
useAuth
useAuthCallback
useTheme
user
import { useAuth } from "../core"; function Example(): JSX.Element { const auth = useAuth(); // auth.me → { id: "xxx", username: "john", ... } | null | undefined // auth.signIn() → opens login dialog // auth.signIn({ method: "Google" }) → opens Google login screen (in a popup window) // auth.signOut() → clears authentication session return ( <p>{me ? `Hello, ${me.name}!` : <button onClick={auth.signIn}>SignIn</button>} ) }
import { useAuthCallback } from "../core"; function Example(): JSX.Element { const handleClick = useAuthCallback(() => { alert("You will see this message after signing in."); }, []); return <button onClick={handleClick}>Click me!</button> }
import { useTheme } from "../core"; function Example(): JSX.Element { const [theme, toggleTheme] = useTheme(); return ( <button onClick={toggleTheme}> Dark mode: {theme.palette.mode === "light" ? "ON" : "OFF"} </button> ) }
https://example.com/settings
{ path: "/settings", query: graphql`...`, authorize: true, // <-- only authenticated users can access this page render(data) { ... } }
"type": "module"
inpackage.json
files (except fordb/package.json
for now)^4.4.4
to^4.5.5
(releases, announcement)^8.2.0
to^8.7.0
(releases)^2.4.1
to^2.5.1
(releases.prettierrc.js
in favor ofpackage.json->prettier
jest.config.js
in favor ofpackage.json->jest
scripts/*.js
files to US; usezx
to run these scriptsapi
] Generate ES output onyarn api:build
, tweak Rollup config and source code to support ES buildapi
] Add GitHub OAuth 2.0 authentication exampleapi
] Replacemoment-timezone
withdate-fns
+date-fns-tz
img
] Convert to ESweb
] RefactorAuth
andTheme
providers; updateLoginDialog
to use the new auth React hookweb
] Allow to mark some routes as requiring authentication by addingauthorize: true
flagweb
] AdduseAuth
,useAuthCallback
, anduseTheme
React hooks:Accessing the currently logged in
user
object from anywhere in the appShow login dialog for some user actions requiring authentication
Toggle between light/dark themes
Marking some routes as requiring authentication (e.g.
https://example.com/settings
)