Skip to content
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

[material-ui] Export Pigment CSS layout components #42693

Merged
merged 28 commits into from
Jun 27, 2024

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Jun 20, 2024

closes #35993, closes #41273

Waiting for mui/pigment-css#160 to be released.

Summary

import PigmentStack from '@mui/material/PigmentStack';
import PigmentHidden from '@mui/material/PigmentHidden';
import PigmentContainer from '@mui/material/PigmentContainer';
import PigmentGrid from '@mui/material/PigmentGrid';

RSC components

  • PigmentContainer
  • PigmentGrid
  • PigmentStack

PigmentGrid

The class is pretty long and should be refined from Pigment CSS (not a blocker of this PR).

image

@siriwatknp siriwatknp added package: material-ui Specific to @mui/material v6.x package: pigment-css Specific to @pigment-css/* on hold There is a blocker, we need to wait labels Jun 20, 2024
@mui-bot
Copy link

mui-bot commented Jun 20, 2024

Netlify deploy preview

PigmentHidden: parsed: +Infinity% , gzip: +Infinity%
PigmentGrid: parsed: +Infinity% , gzip: +Infinity%
PigmentContainer: parsed: +Infinity% , gzip: +Infinity%
PigmentStack: parsed: +Infinity% , gzip: +Infinity%

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against e66f40d

* If `true`, component is hidden on screens below (but not including) this size.
* @default false
*/
lgDown?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

While we are working on finalizing the Grid API, I think we should also update this component to follow a similar API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hidden is a bit complicated as it contains HiddenJs implementation. I don't think changing the API would be simple and what's should be the name of the prop.

How do we handle this?

<Hidden smDown lgUp>

Copy link
Contributor

Choose a reason for hiding this comment

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

The major issue I see currently is the props (TS or prop-types). It's hardcoded to the default breakpoints. But if someone changes that, they won't get correct autocompletion. This is also an issue for core Material UI packages.

Copy link
Member Author

Choose a reason for hiding this comment

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

The major issue I see currently is the props (TS or prop-types)

You mean just for this component or the layout components?

Copy link
Contributor

Choose a reason for hiding this comment

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

For all the layout components that we have that have similar props that depend on the theme.

@mnajdova
Copy link
Member

Are we final on the names? 😅

@siriwatknp
Copy link
Member Author

siriwatknp commented Jun 20, 2024

Are we final on the names? 😅

99.99% unless someone has a better name 😅.

They have to have Pigment either a prefix or suffix because it's for Pigment CSS specifically.
Using RSC would not work because Hidden is not RSC and they are not built for RSC but for Pigment CSS (RSC compatibility is just a by-product).

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 23, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 24, 2024
@brijeshb42
Copy link
Contributor

@siriwatknp Can you try using these csb packages - https://ci.codesandbox.io/status/mui/pigment-css/pr/160/builds/516964

@siriwatknp
Copy link
Member Author

@siriwatknp Can you try using these csb packages - https://ci.codesandbox.io/status/mui/pigment-css/pr/160/builds/516964

Thanks, it's working!

@siriwatknp siriwatknp reopened this Jun 25, 2024
@siriwatknp siriwatknp marked this pull request as ready for review June 25, 2024 07:03
Comment on lines +25 to +32
*
* Use an array to target more than one entrypoint.
*
* @example 'src/index.d.ts'
* @example ['src/index.d.ts', 'src/PigmentStack/PigmentStack.tsx']
* `PigmentStack` cannot be included in the `index.d.ts` file because it is using Pigment CSS specific API.
*/
entryPointPath?: string;
entryPointPath?: string | string[];
Copy link
Member Author

@siriwatknp siriwatknp Jun 25, 2024

Choose a reason for hiding this comment

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

@mui/docs-infra there is a change related to docs-infra. I appreciate another eye to make sure I don't break other projects.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a way it could break other projects.

I tried it on mui-x and the proptypes & docs:api script do not modify anything 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

import PropTypes from 'prop-types';
import clsx from 'clsx';
import { OverridableComponent, OverrideProps } from '@mui/types';
// @ts-ignore
Copy link
Member Author

@siriwatknp siriwatknp Jun 25, 2024

Choose a reason for hiding this comment

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

Removing this @ts-ignore is far beyond this PR, it's related to the tsconfig setup with proper module resolution which I am not sure how to solve it.

@siriwatknp siriwatknp removed the on hold There is a blocker, we need to wait label Jun 25, 2024
Comment on lines +27 to +29
'packages/mui-material/src/PigmentContainer/PigmentContainer.tsx', // RSC compatible
'packages/mui-material/src/PigmentGrid/PigmentGrid.tsx', // RSC compatible
'packages/mui-material/src/PigmentStack/PigmentStack.tsx', // RSC compatible
Copy link
Member

Choose a reason for hiding this comment

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

🎉

Copy link
Member Author

Choose a reason for hiding this comment

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

I was wrong. The layout components still need useDefaultProps so use client is required for them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on the discussion, I remove the useDefaultProps for now.


export type GridSize = 'auto' | 'grow' | number;

export interface GridBaseProps {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe not for this PR, but should we consider sharing types between the components and their pigment version? I think this would help us keep the interchangeable

Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

Besides my comment here, which I think we can deal with later, this looks good to me 🚀

@siriwatknp siriwatknp enabled auto-merge (squash) June 27, 2024 03:18
@siriwatknp siriwatknp disabled auto-merge June 27, 2024 05:02
@siriwatknp siriwatknp merged commit 20565ce into mui:next Jun 27, 2024
21 checks passed
joserodolfofreitas pushed a commit to joserodolfofreitas/material-ui that referenced this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: material-ui Specific to @mui/material package: pigment-css Specific to @pigment-css/* v6.x
Projects
None yet
6 participants