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

[Joy] Add Button - 1st iteration #29464

Merged
merged 85 commits into from
Nov 29, 2021
Merged

[Joy] Add Button - 1st iteration #29464

merged 85 commits into from
Nov 29, 2021

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Nov 2, 2021

https://deploy-preview-29464--material-ui.netlify.app/joy/

This PR

please review the implementation & coding pattern, so that we can make this as a standard for other Joy components.

  • Props
    • variant: text | outlined | contained (same as material)
    • size: small | medium | large (same as material)
    • color: brand (related to theme.palette)
    • fullWidth
  • classes (global className are not combined)
    • no classes as prop

The design is not final, please skip the design discussion in this PR.

Next iteration

  • Design
  • Props
    • start & end icon (with SvgIcon component)
    • loading
    • icon button like
    • ButtonGroup

@mbrookes
Copy link
Member

color: brand (related to theme.palette)

Please see my feedback in Notion

@mbrookes mbrookes added the package: joy-ui Specific to @mui/joy label Nov 12, 2021
@siriwatknp
Copy link
Member Author

color: brand (related to theme.palette)

Please see my feedback in Notion

FYI, this PR is not about design, I will fix it once we have decided about the naming but it should not block this PR.

@mbrookes
Copy link
Member

Please see my feedback in Notion

FYI, this PR is not about design

That's why I left the feedback in Notion not here. 😄 (Not that anyone has responded to it...)
This was simply what prompted the thought.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 16, 2021
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 17, 2021
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 19, 2021
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 24, 2021
skip: ['propsSpread', 'componentsProp', 'classesRoot'],
}));

it('by default, should render with the root, variantText, sizeMedium and colorBrand classes', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Based on the tests if the button is rendered with all classes all test would pass :) Shouldw e maybe test that by default the other classes are not added? Or update the other test to test that the class is not there by default, but it is if the props is added.

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldw e maybe test that by default the other classes are not added

Added.

@siriwatknp siriwatknp requested a review from mnajdova November 25, 2021 02:01
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 25, 2021
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 29, 2021
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.

Looks good 👍

@siriwatknp siriwatknp merged commit 56c9e5e into mui:master Nov 29, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

];
},
})<{ ownerState: ButtonProps }>(({ theme, ownerState }) => {
const colorPalette = theme.vars.palette[ownerState.color || 'brand'];
Copy link
Member

@oliviertassinari oliviertassinari Nov 29, 2021

Choose a reason for hiding this comment

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

From a DX perspective, I wonder if we shouldn't reverse the tradeoff. It seems that the right path (using the CSS variable) is more painful (more to type/read) than accessing the raw value.

Suggested change
const colorPalette = theme.vars.palette[ownerState.color || 'brand'];
const colorPalette = theme.palette[ownerState.color || 'brand'];

Copy link
Member Author

Choose a reason for hiding this comment

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

This is what I propose in #27651 under "Decision on the API".

2 things about using vars

  • I consider CSS variables as a feature on top of ThemeProvider, so adding vars instead of replace the theme makes more sense.
  • When we have to update mui-material to support CSS variables, we can incrementally change the code in each component and it should not break other components.

Anyway, I will try your method and share the finding again. If it is better, we can change Joy to use it.

classes,
testStateOverrides,
render,
ThemeProvider = MDThemeProvider,
Copy link
Member

@oliviertassinari oliviertassinari Nov 29, 2021

Choose a reason for hiding this comment

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

Did we settle on the naming conversions? How are we abbreviating Material Design as "MUI" or "MD"? It seems to be MD and MUI for Material to build UIs. Alright.

Copy link
Member Author

@siriwatknp siriwatknp Nov 30, 2021

Choose a reason for hiding this comment

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

MD is better because the option we want to move forward on the docs says "MUI Core as a product line — System, Joy, MD, and Base as products"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants