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] Optional style sheet name #7594

Merged
merged 1 commit into from Jul 29, 2017
Merged

[docs] Optional style sheet name #7594

merged 1 commit into from Jul 29, 2017

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jul 29, 2017

I have seen too many people copy pasting the same component template and forgetting to rename the sheet name. Wouldn't it be better if we could rely on the component name to get a nice debuggable class name in development?

That's what this PR is about:

-const styleSheet = createStyleSheet('AppFrame', theme => ({
+const styleSheet = createStyleSheet(theme => ({

and in development, the class name is correct:
capture d ecran 2017-07-29 a 22 14 48

in production we still have the following:
capture d ecran 2017-07-29 a 22 15 59

P.S. I have been using the following regexp on the codebase: createStyleSheet\('((?!Mui)\w+)', .

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation v1 labels Jul 29, 2017

Generate a new style sheet that represents the style you want to inject in the DOM.

#### Arguments

1. `name` (*String*): The name of the style sheet. Useful for debugging.
1. `name` (*String* [optional]): The name of the style sheet. Useful for debugging.
If the value isn't provided, we will try to fallback to the name of the component.
Copy link
Member Author

Choose a reason for hiding this comment

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

important

meta = currentStyleSheet.name ? currentStyleSheet.name : getDisplayName(BaseComponent);
// Sanitize the string as will be used in development to prefix the generated
// class name.
meta = meta.replace(new RegExp(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g), '-');
Copy link
Member Author

Choose a reason for hiding this comment

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

@kof point of interest.

@oliviertassinari oliviertassinari merged commit b3a367a into mui:v1-beta Jul 29, 2017
@oliviertassinari oliviertassinari deleted the optional-name branch July 29, 2017 20:30
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

1 participant