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

BREAKING CHANGE: refactor labeled Button API #616

Merged
merged 3 commits into from
Oct 4, 2016

Conversation

levithomason
Copy link
Member

@levithomason levithomason commented Oct 4, 2016

Fixes #510

This PR makes the Button labeled API consistent with the Input labeled API. Previously, a Button could be used as a labeled button wrapper with another Button/Label child. Now:

  • labeled is now labelPosition
  • Button children are always the content of the Button. A Button can no longer contain another Button as a child.
  • Since Labels are not Button children, you can no longer pass them as such. You must use the shorthand label prop to pass the Label.

Fixes #612

It also fixes a recent regression, rendering labeled Buttons as <button> tags. You cannot nest a <button> in a <button>, the labeled button must be a div so it can contain a Label and a Button (<button>) component.

This did not account for labelPosition with an icon. In that case, a <button> can contain an <i />. A div is only required when there is a label. A fix commit has been made to master, TechnologyAdvice/stardust@3379aa5, and will be included in this release.

@@ -144,7 +144,7 @@ export default class ComponentExample extends Component {
.map(l => {
const defaultImport = _.get(/import\s+(\w+)/.exec(l), '[1]')
const destructuredImports = _.get(/import.*({[\s\w,}]+)\s+from/.exec(l), '[1]')
const module = _.snakeCase(_.get(/import.*from.*'(.*)'/.exec(l), '[1]', '')).toUpperCase()
const module = _.snakeCase(_.get(/import.*from\s+['"]([\w\-_]+)/.exec(l), '[1]', '')).toUpperCase()
Copy link
Member Author

Choose a reason for hiding this comment

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

Would like tests for this someday. This fixes the module name detection RegEx, the previous was too permissive and captured too much.

@codecov-io
Copy link

Current coverage is 100% (diff: 100%)

Merging #616 into master will not change coverage

@@           master   #616   diff @@
====================================
  Files         119    119          
  Lines        1915   1915          
  Methods         0      0          
  Messages        0      0          
  Branches        0      0          
====================================
  Hits         1915   1915          
  Misses          0      0          
  Partials        0      0          

Powered by Codecov. Last update 0b3db00...52d5a1d

@levithomason levithomason merged commit 6c6b733 into master Oct 4, 2016
@levithomason levithomason deleted the refactor/button-labeled branch October 4, 2016 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants