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

[Doc] Convert Dialog to use the new standard. #2483

Merged
merged 1 commit into from
Dec 14, 2015

Conversation

alitaheri
Copy link
Member

@oliviertassinari What do you think?

@alitaheri alitaheri added docs Improvements or additions to the documentation PR: Needs Review labels Dec 11, 2015
@alitaheri alitaheri added this to the Improve the documentation milestone Dec 11, 2015
@@ -0,0 +1,6 @@
## Dialog

Dialog can only be a controlled component.
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.

on it

@oliviertassinari
Copy link
Member

@subjectix Wow, that's some hard work here!

/**
* The `className` to add to the `Dialog` window content container.
* This is the `Paper` element that is seen when the `Dialog` is shown.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Should we add the className property in the doc?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, but who will take the className? I wanted to ask, I forgot 😅

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 we have to make an standard.

for each xxxStyle we should have xxxClassName and for each style a className, don't you think?

@alitaheri
Copy link
Member Author

Wow, that's some hard work here!

Thanks ^^

@alitaheri
Copy link
Member Author

I'll take a look at the test

@alitaheri
Copy link
Member Author

@oliviertassinari I fixed the test and added a whole bunch of props for completeness.

This is only for demonstration, please take a long good look at my PR 👯

Do you think this set of (standardized) props make the library a lot easier to customize? or it only bloats the components?

@alitaheri
Copy link
Member Author

@newoga I'd like to hear your idea on this one too, if you don't mind ^^

@newoga
Copy link
Contributor

newoga commented Dec 11, 2015

Do you think this set of (standardized) props make the library a lot easier to customize? or it only bloats the components?

@subjectix, this is a very interesting problem and something I've been considering lately. Below are some of my initial thoughts:

My first thought is, either way, I like standardization and API predictability. The consistent {name}Style {name}ClassName makes the API more predictable which I like, (ie if you learn that pattern for one component, you'll get the idea for all components). I also think it would be cool if inline-styles weren't the only way to extend and customize component style.

Some possible problems in the current implementation that come to mind that we might have to look into/investigate further are:

1. Style precedence may limit effectiveness of {name}ClassName props for customizability

Based on my understanding, right now for most of our components, when users provide their own {name}Style prop, we merge their style object into our default/internal style definition letting them override pretty much anything (for better or worse).

Since inline styles always take precedence over classes, will our default/internal style definitions ultimately override css properties that matter the most?

Simple example would be if someone attempted to do this:

.dialog-title {
  color: 'orange';
}
<Dialog {...other} titleClassName="dialog-title" />

Unless we'd have the ability to export our internal inline-styles to stylesheets and have them loaded before theirs, I think their css class would be ineffective in this particular use case.

2. Possible increased API surface area for components that have several layers of deeply nested children

I think you suggested that this might be a concern. I don't think any of our current components excessively suffer from this right now, but I think it's valid concern nonetheless.

Since I recently worked with the text-field.jsx component, I started wondering if we might eventually run into issues if the props on our parent component are too coupled with our children components. We kind of discussed some of the challenges with the whole errorText vs helperText in #2474.

Other random thoughts:
It's possible that the problem right now with customizability is that consumers of material-ui don't have enough flexibility in modifying how styles are applied. Not because they don't have enough flexibility in where styles are applied.

I'd be interested in exploring programatic approaches for developers to hook into the style transformation for material-ui components, or approaches that allow consumers to essentially build material components during build time or run time based on their own definitions.

It might mean that components like TextField are really high order components themselves that can take custom style transformations that process CSS, inline-styles, or whatever it be, and returns a <TextField /> component that works and looks the way they want it to. They could put those components in their own projects in their own material folders and import them themselves so they don't have to reapply customizations each time they use it.

I know it's really abstract right now. I haven't tried anything but I think it's certainly possible. Part of me wonders if something like this will be a necessity to even support desktop on native/mobile at the same time.

@alitaheri
Copy link
Member Author

@newoga

I think their css class would be ineffective in this particular use case.

Well it's a common pattern for those who want to override react inline styles with css classes to use the !important modifier. So it is practical, and there are some issues submitted wanting css classes hooks so they can use this capability of css (goo thing we have it 😅 )

Possible increased API surface

I think this is a valid trade-off, maybe if we can categorize props and make separate tables for functionality and customization the surface would become cleaner?

But maybe, if the users see xxxClassName and xxxStyle all over the place, they'll easily get used to it. a limiting API is much worse than an over populated one, imo.

@oliviertassinari Thoughts?

@newoga
Copy link
Contributor

newoga commented Dec 11, 2015

But maybe, if the users see xxxClassName and xxxStyle all over the place, they'll easily get used to it. a limiting API is much worse than an over populated one, imo.

I definitely agree with this. If I'm honest with myself, I think it feels more natural for components to be able to accept both classes and styles so they feel more normal.

I think this is a valid trade-off, maybe if we can categorize props and make separate tables for functionality and customization the surface would become cleaner?
That's true, there are probably definitely approaches to organization documentation so that it is clearer and more approachable. Also, now that we have doc gen, its a ton easier to maintain.

From a pure maintenance standpoint, having className doesn't add a lot of risk/work because we're simply going to pass it directly to the relevant component.

@alitaheri
Copy link
Member Author

@newoga Well the issue isn't maintenance actually, I just want to follow the best convention and make it standard from now on. Need to have people agreeing with this approach. This is not a small decision :D

@alitaheri
Copy link
Member Author

@oliviertassinari Take a final look at this when you get the time ^_^

children: React.PropTypes.node,

/**
* The `className` to add to the `Dialog` root element.
Copy link
Member

Choose a reason for hiding this comment

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

What about The css class name of the root element.?

@oliviertassinari
Copy link
Member

Could you update the example of the #/customization/themes page? I can see some warnings:

Warning: Failed propType: Invalid prop `actions` supplied to `Dialog`, expected a ReactNode. Check the render method of `ThemesPage`.

@@ -116,20 +117,26 @@ const DialogInline = React.createClass({

propTypes: {
actionFocus: React.PropTypes.string,
actions: React.PropTypes.array,
actions: React.PropTypes.node,
actionsContainerClassName: React.PropTypes.string,
Copy link
Member

Choose a reason for hiding this comment

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

Double spaces here. The rule relative eslint rule is not inforced yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, thanks.

@oliviertassinari
Copy link
Member

@subjectix I have done some comment on the code. Otherwise, that a great improvement for this component 👍.

@alitaheri
Copy link
Member Author

@oliviertassinari Please take another look, I remove Dialog from some other comments too.

@oliviertassinari
Copy link
Member

What about renaming Dialog/ModalExample.jsx to Dialog/ExampleModal.jsx to follow the component name DialogExampleModal, same for the other example?
Otherwise, I'm Ok to merge this 😄.

@alitaheri
Copy link
Member Author

@oliviertassinari Ok, I'll change the names, squash and merge, thanks for your feedbacks 👍 😄

alitaheri added a commit that referenced this pull request Dec 14, 2015
[Doc] Convert Dialog to use the new standard.
@alitaheri alitaheri merged commit 37f71b6 into mui:master Dec 14, 2015
@alitaheri alitaheri deleted the doc-codegen-dialog branch December 14, 2015 11:05
@oliviertassinari
Copy link
Member

🎉

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.

3 participants