diff --git a/web/apps/accounts/src/pages/_app.tsx b/web/apps/accounts/src/pages/_app.tsx index 8ff4c6a9f..513844237 100644 --- a/web/apps/accounts/src/pages/_app.tsx +++ b/web/apps/accounts/src/pages/_app.tsx @@ -1,4 +1,4 @@ -import { setupI18n } from "@/ui/i18n"; +import { setupI18n } from "@/next/i18n"; import { APPS, APP_TITLES } from "@ente/shared/apps/constants"; import { Overlay } from "@ente/shared/components/Container"; import DialogBoxV2 from "@ente/shared/components/DialogBoxV2"; diff --git a/web/apps/auth/src/pages/_app.tsx b/web/apps/auth/src/pages/_app.tsx index 06dfc2402..891dde1dd 100644 --- a/web/apps/auth/src/pages/_app.tsx +++ b/web/apps/auth/src/pages/_app.tsx @@ -1,4 +1,4 @@ -import { setupI18n } from "@/ui/i18n"; +import { setupI18n } from "@/next/i18n"; import { APPS, APP_TITLES, diff --git a/web/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx b/web/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx index c832be356..a9474a37d 100644 --- a/web/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx +++ b/web/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx @@ -3,7 +3,7 @@ import { setLocaleInUse, supportedLocales, type SupportedLocale, -} from "@/ui/i18n"; +} from "@/next/i18n"; import DropdownInput, { DropdownOption } from "components/DropdownInput"; import { t } from "i18next"; import { useRouter } from "next/router"; diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx index ce06b00da..07662daf4 100644 --- a/web/apps/photos/src/pages/_app.tsx +++ b/web/apps/photos/src/pages/_app.tsx @@ -1,4 +1,4 @@ -import { setupI18n } from "@/ui/i18n"; +import { setupI18n } from "@/next/i18n"; import { APPS, APP_TITLES, diff --git a/web/docs/dependencies.md b/web/docs/dependencies.md index a1daaf0b2..0a7e2b38d 100644 --- a/web/docs/dependencies.md +++ b/web/docs/dependencies.md @@ -47,10 +47,10 @@ bit more exhaustively when changing the crypto layer. ## UI -The UI package uses "react". This is our core framework. +### React -React also has a sibling "react-dom" package that renders "React" interfaces to -the DOM. +[React](https://react.dev) ("react") is our core framework. It also has a +sibling "react-dom" package that renders JSX to the DOM. ### MUI and Emotion @@ -75,6 +75,8 @@ Emotion itself comes in many parts, of which we need the following: > Keep `@emotion/styled` as a dependency of your project. Even if you never > use it explicitly, it's a peer dependency of `@mui/material`. +#### Component selectors + Note that currently the SWC plugin doesn't allow the use of the component selectors API (i.e using `styled.div` instead of `styled("div")`). @@ -104,3 +106,18 @@ Note that inspite of the "next" in the name of the library, it has nothing to do with Next.js. For more details, see [translations.md](translations.md). + +## Meta Frameworks + +### Next.js + +[Next.js](https://nextjs.org) ("next") provides the meta framework for both the +Photos and the Auth app, and also for some of the sidecar apps like accounts and +cast. + +We use a limited subset of Next. The main thing we get out of it is a reasonable +set of defaults for bundling our app into a static export which we can then +deploy to our webserver. In addition, the Next.js page router is convenient. +Apart from this, while we use a few tidbits from Next.js here and there, overall +our apps are regular React SPAs, and are not particularly tied to Next. + diff --git a/web/packages/next/README.md b/web/packages/next/README.md index 1602f873f..4a4dc45ba 100644 --- a/web/packages/next/README.md +++ b/web/packages/next/README.md @@ -1,8 +1,9 @@ ## @/next -Like [@/ui](../ui/README.md), but for things that require Next. +A base package for our UI layer code, for sharing ode between our Next.js apps. ### Packaging This (internal) package exports a React TypeScript library. We rely on the importing project to transpile and bundle it. + diff --git a/web/packages/ui/components/Card.tsx b/web/packages/next/components/Card.tsx similarity index 100% rename from web/packages/ui/components/Card.tsx rename to web/packages/next/components/Card.tsx diff --git a/web/packages/ui/i18n.ts b/web/packages/next/i18n.ts similarity index 100% rename from web/packages/ui/i18n.ts rename to web/packages/next/i18n.ts diff --git a/web/packages/next/next.config.base.js b/web/packages/next/next.config.base.js index 89b745638..f0d1481b4 100644 --- a/web/packages/next/next.config.base.js +++ b/web/packages/next/next.config.base.js @@ -51,7 +51,7 @@ const nextConfig = { emotion: true, }, // Use Next.js to transpile our internal packages before bundling them. - transpilePackages: ["@/next", "@/ui", "@/utils"], + transpilePackages: ["@/next", "@/utils"], // Add environment variables to the JavaScript bundle. They will be // available as `process.env.VAR_NAME` to our code. diff --git a/web/packages/next/package.json b/web/packages/next/package.json index 03f2c17b5..d21ee5c53 100644 --- a/web/packages/next/package.json +++ b/web/packages/next/package.json @@ -3,11 +3,21 @@ "version": "0.0.0", "private": true, "dependencies": { - "@/ui": "*", - "next": "^14.1" + "@emotion/react": "^11.11", + "@emotion/styled": "^11.11", + "@mui/icons-material": "^5.15", + "@mui/material": "^5.15", + "get-user-locale": "^2.3", + "i18next": "^23.10", + "i18next-http-backend": "^2.5", + "next": "^14.1", + "react": "^18", + "react-dom": "^18", + "react-i18next": "^14" }, "devDependencies": { "@/build-config": "*", - "@types/node": "^20" + "@types/react": "^18", + "@types/react-dom": "^18" } } diff --git a/web/packages/shared/README.md b/web/packages/shared/README.md index eaa7babe3..ba92b46f1 100644 --- a/web/packages/shared/README.md +++ b/web/packages/shared/README.md @@ -1,3 +1,3 @@ Deprecated in favor of [@/utils](../utils/README.md) and -[@/ui](../ui/README.md). Don't add new code here - we'll slowly be migrating +[@/next](../next/README.md). Don't add new code here - we'll slowly be migrating existing code from here to those two packages. diff --git a/web/packages/ui/.eslintrc.js b/web/packages/ui/.eslintrc.js deleted file mode 100644 index 7372de729..000000000 --- a/web/packages/ui/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - extends: ["@/build-config/eslintrc-typescript-react"], - parserOptions: { - tsconfigRootDir: __dirname, - }, -}; diff --git a/web/packages/ui/README.md b/web/packages/ui/README.md deleted file mode 100644 index 69c0a71e2..000000000 --- a/web/packages/ui/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## @/ui - -Like [@/utils](../utils/README.md), but for things that require React. - -### Packaging - -This (internal) package exports a React TypeScript library. We rely on the -importing project to transpile and bundle it. diff --git a/web/packages/ui/package.json b/web/packages/ui/package.json deleted file mode 100644 index 125b8de7c..000000000 --- a/web/packages/ui/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "@/ui", - "version": "0.0.0", - "private": true, - "dependencies": { - "@emotion/react": "^11.11", - "@emotion/styled": "^11.11", - "@mui/icons-material": "^5.15", - "@mui/material": "^5.15", - "get-user-locale": "^2.3", - "i18next": "^23.10", - "i18next-http-backend": "^2.5", - "react": "^18", - "react-dom": "^18", - "react-i18next": "^14" - }, - "devDependencies": { - "@/build-config": "*", - "@types/react": "^18", - "@types/react-dom": "^18" - } -} diff --git a/web/packages/ui/tsconfig.json b/web/packages/ui/tsconfig.json deleted file mode 100644 index f5c124842..000000000 --- a/web/packages/ui/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "@/build-config/tsconfig.transpile.json", - /* Typecheck all files with the given extensions (here or in subfolders) */ - "include": ["**/*.ts", "**/*.tsx"] -}