This commit is contained in:
Lukasz Ostrowski 2023-01-29 20:23:51 +01:00
parent 20f439f3ce
commit de68dcca7b
9 changed files with 277 additions and 2686 deletions

View file

@ -1,7 +1,6 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["custom"],
extends: ["saleor"],
settings: {
next: {
rootDir: ["apps/*/"],

View file

@ -8,7 +8,7 @@
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-custom": "workspace:*",
"eslint-config-saleor": "workspace:*",
"prettier": "^2.5.1",
"turbo": "^1.7.0"
},

View file

@ -1,4 +1,8 @@
module.exports = {
extends: ["next", "turbo", "prettier"],
rules: {},
};
plugins: ["simple-import-sort"],
extends: ["next", "turbo", "prettier"],
rules: {
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
},
};

View file

@ -4,12 +4,13 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"eslint-config-next": "^13.1.3",
"eslint-config-next": "^13.1.6",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-react": "7.32.1",
"eslint-config-turbo": "^0.0.7"
"eslint-config-turbo": "^0.0.7",
"eslint-plugin-simple-import-sort": "^10.0.0"
},
"publishConfig": {
"access": "public"
}
}
}

View file

@ -0,0 +1,3 @@
{
"extends": ["saleor"]
}

View file

@ -2,10 +2,21 @@ import { useAppBridge } from "@saleor/app-sdk/app-bridge";
import { useTheme } from "@saleor/macaw-ui";
import { memo, useEffect } from "react";
/**
* Macaw-ui stores its theme mode in memory and local storage. To synchronize App with Dashboard,
* Macaw must be informed about this change from AppBridge.
*
* If you are not using Macaw, you can remove this.
*/
function _ThemeSynchronizer() {
const { appBridgeState } = useAppBridge();
const { appBridgeState, appBridge } = useAppBridge();
const { setTheme, themeType } = useTheme();
// todo - replace this hook to appBridge.subscribe and react only only on initial theme event
// useEffect(() =>{
// appBridge?.subscribe('theme',console.log)
// },[appBridge])
useEffect(() => {
if (!setTheme || !appBridgeState?.theme) {
return;
@ -13,6 +24,11 @@ function _ThemeSynchronizer() {
if (themeType !== appBridgeState?.theme) {
setTheme(appBridgeState.theme);
/**
* Hack to fix macaw, which is going into infinite loop on light mode (probably de-sync local storage with react state)
* TODO Fix me when Macaw 2.0 is shipped
*/
window.localStorage.setItem("macaw-ui-theme", appBridgeState.theme);
}
}, [appBridgeState?.theme, setTheme, themeType]);

View file

@ -10,6 +10,7 @@
},
"devDependencies": {
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10"
"@types/react-dom": "^18.0.10",
"eslint-config-saleor": "workspace:*"
}
}

File diff suppressed because it is too large Load diff

View file

@ -4,25 +4,6 @@
"build": {
"outputs": [".next/**"]
},
"saleor-app-invoice#build": {
"env": [
"APL",
"APP_DEBUG",
"NODE_ENV",
"SECRET_KEY",
"VERCEL_URL",
"PORT",
"ALLOWED_DOMAIN_PATTERN",
"TEMP_PDF_STORAGE_DIR",
"SENTRY_AUTH_TOKEN",
"SENTRY_PROJECT",
"SENTRY_ORG",
"REST_APL_TOKEN",
"REST_APL_ENDPOINT",
"NEXT_PUBLIC_SENTRY_DSN",
"SENTRY_DSN"
]
},
"saleor-app-slack#build": {
"env": ["APL", "SENTRY_AUTH_TOKEN", "SENTRY_PROJECT", "SENTRY_ORG"]
},