From cfbd3a5fa078a7f2424ce0f0e2b11f0372a229ec Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Mon, 16 Jan 2023 13:08:24 +0100 Subject: [PATCH] add basic structure to web apps --- apps/next/next.config.js | 16 +++---- apps/next/package.json | 3 +- apps/next/pages/_app.tsx | 20 ++++---- apps/next/pages/_document.tsx | 56 +++++++++++++++------- apps/next/pages/index.tsx | 25 ++++++---- apps/next/styles/app.css | 20 ++++++++ apps/next/styles/reset.css | 88 +++++++++++++++++++++++++++++++++++ apps/vite/package.json | 3 +- apps/vite/src/app.css | 41 ---------------- apps/vite/src/app.tsx | 86 ++++++++++++++++++++++------------ apps/vite/src/index.css | 70 ---------------------------- apps/vite/src/main.tsx | 9 ++-- apps/vite/styles/app.css | 23 +++++++++ apps/vite/styles/reset.css | 88 +++++++++++++++++++++++++++++++++++ 14 files changed, 358 insertions(+), 190 deletions(-) create mode 100644 apps/next/styles/app.css create mode 100644 apps/next/styles/reset.css delete mode 100644 apps/vite/src/app.css delete mode 100644 apps/vite/src/index.css create mode 100644 apps/vite/styles/app.css create mode 100644 apps/vite/styles/reset.css diff --git a/apps/next/next.config.js b/apps/next/next.config.js index 6275d123..1d488aeb 100644 --- a/apps/next/next.config.js +++ b/apps/next/next.config.js @@ -20,10 +20,10 @@ const plugins = [ // withImages, withTamagui({ config: './tamagui.config.ts', - components: [], + components: ['@status-im/components'], importsWhitelist: ['constants.js', 'colors.js'], logTimings: true, - disableExtraction, + disableExtraction: true, // experiment - reduced bundle size react-native-web useReactNativeWebLite: false, @@ -33,11 +33,11 @@ const plugins = [ } }, excludeReactNativeWebExports: [ - 'Switch', - 'ProgressBar', - 'Picker', - 'CheckBox', - 'Touchable', + // 'Switch', + // 'ProgressBar', + // 'Picker', + // 'CheckBox', + // 'Touchable' ], }), ] @@ -53,7 +53,7 @@ module.exports = function () { }, transpilePackages: [ // 'solito', - // 'react-native-web', + 'react-native-web', // 'expo-linking', // 'expo-constants', // 'expo-modules-core' diff --git a/apps/next/package.json b/apps/next/package.json index 8ec76b19..21766c64 100644 --- a/apps/next/package.json +++ b/apps/next/package.json @@ -14,13 +14,12 @@ "@tamagui/core": "^1.0.8", "@tamagui/next-theme": "1.0.8", "next": "^13.0.6", - "raf": "^3.4.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-native-web": "^0.18.6" }, "devDependencies": { - "@tamagui/next-plugin": "1.0.8", + "@tamagui/next-plugin": "^1.0.8", "@types/node": "^18.6.4", "@types/react": "^18.0.26", "@types/react-dom": "^18.0.9", diff --git a/apps/next/pages/_app.tsx b/apps/next/pages/_app.tsx index 18fcd3f5..3ce5f695 100644 --- a/apps/next/pages/_app.tsx +++ b/apps/next/pages/_app.tsx @@ -2,26 +2,30 @@ import '@tamagui/core/reset.css' import '@tamagui/font-inter/css/400.css' import '@tamagui/font-inter/css/700.css' -import { NextThemeProvider, useRootTheme } from '@tamagui/next-theme' -// import { Provider } from 'app/provider' +import '../styles/reset.css' +import '../styles/app.css' + import Head from 'next/head' -import React, { useMemo } from 'react' -// import type { SolitoAppProps } from 'solito' +import React from 'react' import tamaguiConfig from '../tamagui.config' -import 'raf/polyfill' import { AppProps } from 'next/app' import { TamaguiProvider } from '@tamagui/core' -function MyApp({ Component, pageProps }: AppProps) { +// import { NextThemeProvider, useRootTheme } from '@tamagui/next-theme' +// import { Provider } from 'app/provider' +// import type { SolitoAppProps } from 'solito' + +function App({ Component, pageProps }: AppProps) { return ( <> - Tamagui Example App + Status + @@ -41,4 +45,4 @@ function MyApp({ Component, pageProps }: AppProps) { // ) // } -export default MyApp +export default App diff --git a/apps/next/pages/_document.tsx b/apps/next/pages/_document.tsx index 19ecc65f..e27b9db0 100644 --- a/apps/next/pages/_document.tsx +++ b/apps/next/pages/_document.tsx @@ -1,27 +1,47 @@ import NextDocument, { Head, Html, Main, NextScript } from 'next/document' import { Children } from 'react' -// import { AppRegistry } from 'react-native' +import { AppRegistry } from 'react-native' import Tamagui from '../tamagui.config' +// TODO: the recommended approach breaks HMR when Tmaagui.getCSS() is called in the getInitialProps method. export default class Document extends NextDocument { - static async getInitialProps({ renderPage }: any) { - // AppRegistry.registerComponent('Main', () => Main) + // static async getInitialProps({ renderPage }: any) { + // AppRegistry.registerComponent('Main', () => Main) + // const page = await renderPage() + + // // @ts-ignore + // const { getStyleElement } = AppRegistry.getApplication('Main') + + // /** + // * Note: be sure to keep tamagui styles after react-native-web styles like it is here! + // * So Tamagui styles can override the react-native-web styles. + // */ + // const styles = [ + // getStyleElement(), + //