Skip to content

[system] Reexport Pigment CSS from index file #43218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,35 @@ pnpm dev

Open the browser and navigate to the localhost URL, you should see the app running with Pigment CSS.

### Typescript
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Typescript
### TypeScript

Fixing this in #43751


If you are using TypeScript, you need to extend the Pigment CSS theme types with Material UI `Theme`.
Add the following code to a file that is included in your `tsconfig.json`:

```ts
// e.g. App.tsx
import { Theme } from '@mui/material/styles';

declare module '@mui/material-pigment-css' {
interface ThemeArgs {
theme: Theme;
}
}
```

Then, verify that the types is correctly picked up by Pigment CSS with the following code:

```ts
// e.g. App.tsx
import { styled } from '@mui/material-pigment-css';

const TestThemeTypes = styled('div')(({ theme }) => ({
color: theme.palette.primary.main,
}));
```

You should see no TypeScript errors in your editor. Finally, remove the test code.

## How it works

When a Pigment CSS plugin is configured through a framework bundler, it intercepts the styling APIs that Material UI uses and replaces them with those from Pigment CSS instead. Pigment CSS then extracts the styles at build time and injects them into the stylesheet.
Expand Down
1 change: 1 addition & 0 deletions packages/mui-material-pigment-css/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from '@pigment-css/react';
export * from '@pigment-css/react/theme';
1 change: 0 additions & 1 deletion packages/mui-material-pigment-css/src/theme.ts

This file was deleted.

Loading