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

feat(Checkbox|FormField) support label shorthand #967

Merged
merged 3 commits into from
Dec 1, 2016

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Dec 1, 2016

Addresses part of #939.

This PR:

  • cleanups components and tests code;
  • adds docs about label shorthand;
  • improves label shorthand for Checkbox and FormField components.

@codecov-io
Copy link

codecov-io commented Dec 1, 2016

Current coverage is 100% (diff: 100%)

Merging #967 into master will not change coverage

@@           master   #967   diff @@
====================================
  Files         137    137          
  Lines        2283   2281     -2   
  Methods         0      0          
  Messages        0      0          
  Branches        0      0          
====================================
- Hits         2283   2281     -2   
  Misses          0      0          
  Partials        0      0          

Powered by Codecov. Last update ac40713...f308274

@@ -41,6 +37,15 @@ describe('Checkbox', () => {
})
})

describe('defaultChecked', () => {
it('sets the initial checked state', () => {
// consoleUtil.disableOnce()
Copy link
Member

Choose a reason for hiding this comment

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

Is this meant to be uncommented or removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like cruft.

<div>
<Checkbox label={{ children: 'Prop label', className: 'foo' }} />
<Divider />
<Checkbox label={<label><b>Element label</b></label>} />
Copy link
Member

Choose a reason for hiding this comment

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

We're listing each shorthand as separate examples. Ideally, shorthand examples immediately follow the example showing the regular usage. I think we should split this into two examples and show them immediately after the first Checkbox example:

image

@levithomason
Copy link
Member

Though this solves the Checkbox usage, I don't see the FormField updates as the title states.

@levithomason
Copy link
Member

levithomason commented Dec 1, 2016

I'm thinking if a user does this:

<Form.Field label={<MyLabel />} control={<MyControl />} />
<Form.Field label={{ children: 'Name' }} control={<input name='name' />} />

That we should pass that ^ value through the factory as well. Currently, we assume it is a string and render it nested in a <label />.

We can do this on another PR if you like and just leave this one to the Checkbox label updates. LMK.

@layershifter
Copy link
Member Author

I've added updates for FormField and splited shorthand examples 👍

@layershifter
Copy link
Member Author

We can do this on another PR if you like and just leave this one to the Checkbox label updates. LMK.

I think we don't need touch control in this PR.

@levithomason levithomason merged commit c113cf5 into master Dec 1, 2016
@levithomason levithomason deleted the fix/label-shorthand branch December 1, 2016 20:19
@levithomason
Copy link
Member

Awesome work, thanks :D

I updated the PR description to not close #939 since the PR adding shorthand to the FormField label should close that one.

@layershifter
Copy link
Member Author

Hm... It seems there happened misunderstanding.


This PR improved label shorthand on Checkbox and FormField, but didn't touch control shorthand on FormField. Now we can to do this:

<FormField label='my label' />
<FormField label={123} />
<FormField label={{ children: 'foo' }} />
<FormField label={<div className='label' />} />
<FormField label={<MyComponent />} />

But, we can't do this:

<FormField control={<input name='name' />} />

In this case control shorthand will go to this branch and will fail due createElement :)

So, I think #939 can be closed, but we need to open new issue about control shorthand improvement.

@levithomason
Copy link
Member

Indeed, thanks for clarifying. I've closed the other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants