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

Decouple sx prop from system and add docs #57

Merged
merged 12 commits into from
Jun 10, 2024
Merged

Decouple sx prop from system and add docs #57

merged 12 commits into from
Jun 10, 2024

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented May 8, 2024

I decided to change the intention of this PR so that we can ship incrementally.

From Pigment CSS users, sx prop gives a convenient way to style elements without writing any import. The shorthand should not be enabled by default (it's too magical).
If they want shorthand, they need to add some theme config (a new feature for Pigment CSS).

So this PR is about decoupling the shorthand from System so that sx prop does not come with shorthand by default.

Then consider shorthand as another feature that can be worked separately.


@siriwatknp siriwatknp added the docs Improvements or additions to the documentation label May 8, 2024
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

The shorthand properties (currently, the shorthand works but it's tied to MUI System styleFunctionSx). There is a plan to move to theme.unstable_sx so that developer can configure their own which will be a different PR.

This is very important, I would even wait with adding documentation until we have this. The sx prop currently is tight to a theme structure, that people may not be aware of. If we don't have a documentation about this, it looks like magic.

README.md Outdated Show resolved Hide resolved
README.md Outdated
- a callback function that receives the [theme object](#theming) then return a plain style object:

```js
<div sx={(theme) => ({ color: theme.colors.primary })} />
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can add example that is not possible with an object, so that people are aware of what's the different use-case.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean by "not possible with an object"? Can you give me an example?

README.md Outdated
- an array of plain style objects or callback functions. This is useful for applying conditional styles based on other variables:

```js
<div
Copy link
Member

Choose a reason for hiding this comment

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

Great example!

README.md Outdated

The value provided to `sx` prop can be one of the following:

- a plain style object (recommended)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also mention static values.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you give me an example?

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@NeilTheFisher NeilTheFisher mentioned this pull request May 21, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 1, 2024
@siriwatknp siriwatknp changed the title [docs] Add sx prop to readme (part 1) [docs] Add sx prop to readme Jun 1, 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 1, 2024
@siriwatknp siriwatknp changed the title [docs] Add sx prop to readme Decouple sx prop from system Jun 1, 2024
@siriwatknp siriwatknp changed the title Decouple sx prop from system Decouple sx prop from system and add docs Jun 1, 2024
interface HTMLAttributes<T> {
sx?:
| React.CSSProperties
| ((theme: Theme) => React.CSSProperties)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also add where to import this Theme from.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added as a placeholder to imply that it comes from the consumer.

@siriwatknp siriwatknp merged commit e8270fa into master Jun 10, 2024
17 of 18 checks passed
@siriwatknp siriwatknp deleted the docs/sx branch June 10, 2024 16:25
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants