Skip to content

Commit

Permalink
feat: remove not needed pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofzuraw committed Oct 4, 2023
1 parent 5c7dd41 commit f159218
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 747 deletions.
38 changes: 4 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,18 @@ Official React UI components kit for [Saleor](https://saleor.io/) — an open-so
npm i @saleor/macaw-ui
```

Note that this package still bundles the old version of MacawUI so it still depends on the following Material-UI v4 packages: @material-ui/core, @material-ui/icons and @material-ui/lab. If your project doesn't have them installed and you're not using npm v7 with [automatically installed peer dependencies](https://github.blog/2020-10-13-presenting-v7-0-0-of-the-npm-cli/) then you'll need to install them manually:

```sh
npm i @material-ui/core @material-ui/icons @material-ui/lab
```

## Usage

You need to import the styles into your app. You can do it in your main entry point, for example `index.`tsx`:

```tsx
import "@saleor/macaw-ui/next/style";
import "@saleor/macaw-ui/style";
```

Next, you need to add the `ThemeProvider` to your app. It will provide the theme to the components:

```tsx
import { ThemeProvider } from "@saleor/macaw-ui/next";
import { ThemeProvider } from "@saleor/macaw-ui";

const App = () => (
<ThemeProvider>
Expand All @@ -45,23 +39,10 @@ const App = () => (

### Usage with Next.js

As mentioned above, we still bundle the old version of MacawUI so you need to add the following to your `next.config.js`:

```js
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
esmExternals: false,
},
};
```

It tells Next.js not to use ESM exports for external modules. This is needed because MacawUI dependencies (Material-UI v4) are still using CommonJS exports.

If you need to render styles on the server we recommend that you use `getCSSVariables` helper to get the CSS variables that can be injected in `_document.tsx`:

```tsx
import { getCSSVariables } from "@saleor/macaw-ui/next";
import { getCSSVariables } from "@saleor/macaw-ui";
import Document, { Head, Html, Main, NextScript } from "next/document";

const css = getCSSVariables("defaultLight"); // or "defaultDark"
Expand All @@ -81,24 +62,14 @@ export default class AppDocument extends Document {
}
```

If you are using Next.js in version 13 and you got this error:

```
NonErrorEmittedError: (Emitted value instead of an instance of Error) ReferenceError: $RefreshReg$ is not defined
```

Try to change `sprinkles` imports from `@saleor/macaw-ui/next` to `@saleor/macaw-ui/next/theme`.

[Reference](https://github.com/vanilla-extract-css/vanilla-extract/issues/1043)

### Usage with form libraries

#### React Hook Form

You need to wrap the MacawUI component with [`Controller`](https://react-hook-form.com/api/usecontroller/controller/). For example:

```tsx
import { Input } from "@saleor/macaw-ui/next";
import { Input } from "@saleor/macaw-ui";

<Controller
control={control}
Expand Down Expand Up @@ -127,7 +98,6 @@ To begin, you need to install dependencies:

```sh
pnpm install
cd legacy && npm install
```

Then, you can run the Storybook:
Expand Down
18 changes: 2 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
"./style": {
"import": "./dist/style.css",
"default": "./dist/style.css"
},
"./theme": {
"types": "./dist/theme/index.d.ts",
"import": "./dist/theme.mjs",
"default": "./dist/theme.js"
}
},
"keywords": [
Expand Down Expand Up @@ -65,7 +60,6 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "^7.22.9",
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@release-it/conventional-changelog": "^7.0.0",
Expand All @@ -77,7 +71,6 @@
"@storybook/react-vite": "^7.2.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0",
"@types/lodash-es": "4.17.8",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/testing-library__jest-dom": "^5.14.9",
Expand Down Expand Up @@ -105,19 +98,16 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"release-it": "^16.1.3",
"require-from-string": "^2.0.2",
"rollup-plugin-visualizer": "5.9.2",
"storybook": "^7.2.1",
"typescript": "^5.1.6",
"vite": "^4.4.8",
"vite-plugin-dts": "^3.4.0",
"vitest": "^0.34.1",
"webpack": "^5.88.2"
"vitest": "^0.34.1"
},
"dependencies": {
"@dessert-box/react": "^0.4.0",
"@floating-ui/react-dom": "^2.0.2",
"@floating-ui/react-dom-interactions": "^0.5.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.4",
Expand All @@ -130,11 +120,7 @@
"@radix-ui/react-tooltip": "^1.0.6",
"@vanilla-extract/css-utils": "^0.1.3",
"@vanilla-extract/recipes": "^0.5.0",
"clsx": "^1.2.1",
"downshift": "^6.1.12",
"downshift7": "npm:[email protected]",
"lodash-es": "^4.17.21",
"react-inlinesvg": "^3.0.2"
"downshift": "^7.6.0"
},
"peerDependencies": {
"@types/react": "^16.9.0 || ^17.0.0 || ^18.0.0",
Expand Down
Loading

0 comments on commit f159218

Please sign in to comment.