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

[docs] Add "Building design system components" guide with Pigment CSS #41635

Merged
merged 14 commits into from
Apr 2, 2024

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Mar 25, 2024

I use this opportunity to add a test the API altogether.

closes #41537

@siriwatknp siriwatknp added docs Improvements or additions to the documentation package: pigment-css Specific to @pigment-css/* labels Mar 25, 2024
Comment on lines 55 to 58
if (_source.startsWith('@pigment-css/react')) {
return require.resolve(`../exports/${tag}`);
}
return null;
Copy link
Member Author

Choose a reason for hiding this comment

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

@brijeshb42 without this change, all imports are considered pigment related APIs. import * as React from 'react'; is not possible in the input file.

Copy link
Member Author

@siriwatknp siriwatknp Mar 25, 2024

Choose a reason for hiding this comment

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

All ears to any better solution.

@mui-bot
Copy link

mui-bot commented Mar 25, 2024

Netlify deploy preview

https://deploy-preview-41635--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against d918e22


### 3. Style the slot with ownerState

When you need to style the slot-based props or internal state, wrap them in the `ownerState` object and pass it to each slot as a prop.
Copy link
Contributor

Choose a reason for hiding this comment

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

onwerState is MUI specific primitive. We should also mention that users get access to the direct props as well.

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 think ownerState is also Pigment specific. It's in all of the Pigment codebase. By using ownerState, you don't have to write shouldForwardProp all the time. It makes a lot of sense to me to mention ownerState for styling.

We should also mention that users get access to the direct props as well.

Yes, we can do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's added only to support material-ui. Otherwise, it's not needed and has nothing to do with Pigment itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I won't mention ownerState for now but I feel that developers will have to come up with some name anyway, so why not use what we already have?

It's not just for Material UI but quite common use cases. I don't think anyone would like to deal with shouldForwardProp, it's pretty annoying. For me, I just need Pigment to tell me what prop name I should put info for styling into and that's done. I don't want to be aware of props spreading to DOM.

name: 'MuiStat',
slot: 'root',
- })(({ theme }) => ({
+ })(({ theme, ownerState }) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition/deletion seems reverse

// framework config file, for example next.config.js
const { withPigment } = require('@pigment-css/nextjs-plugin');

const theme = {
Copy link
Contributor

@brijeshb42 brijeshb42 Mar 25, 2024

Choose a reason for hiding this comment

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

Maybe we can also emphasize that library authors can also export their pre configured theme that can be directly imported and passed to the config.

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 decided not to mention the theme configuration at the beginning. I think the theme should be added after teaching how to create a component.

packages/pigment-css-react/tests/testUtils.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Just a few remarks came to mind while reading it! Haven't done any writing review here as I'm sure Sam will point out a few things, but it looks good!

packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
packages/pigment-css-react/README.md Outdated Show resolved Hide resolved
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 29, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 1, 2024
@siriwatknp siriwatknp changed the title [docs] Add "Building a UI library" guide with Pigment CSS [docs] Add "Building design system components" guide with Pigment CSS Apr 1, 2024
Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Looking great to me! 🤙

@@ -0,0 +1,50 @@
import { styled as _styled3 } from '@pigment-css/react';
Copy link
Contributor

Choose a reason for hiding this comment

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

This file might not have been formatted correctly and will later report issue in CI. Can you verify? After prettier, imports to the same module are consolidated into one.

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 run test:update but it remains the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you look at styled.output.js, it becomes

import { styled as _styled, styled as _styled2, styled as _styled3 } from '@pigment-css/react';

Copy link
Contributor

Choose a reason for hiding this comment

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

So I am not sure what is correct.

@siriwatknp siriwatknp enabled auto-merge (squash) April 2, 2024 02:52
@siriwatknp siriwatknp merged commit 1e11691 into mui:next Apr 2, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation package: pigment-css Specific to @pigment-css/*
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pigment-css][docs] Add a "how to build a UI library guide"
5 participants