You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should either rename type to something else such as hue='danger', or add a submit prop that results in <button type='submit'>.
Both approaches have their pros and cons. type fits the button "roles" very well, role would also clash with aria props, etc. At the same time, submit={ Boolean } wouldn't fix support for <button type='button'> either.
There's also the third option of just making a new component that's more direct... ButtonSubmit or whatever. Not a great one either (cuz it'd mostly be a dupe), but that's how it's handled in the current code.
@snide note that there's a bunch of different permutations, so that approach can be problematic:
<input type='button'>
<button>
<button type='button'>
<input type='submit'>
<button type='submit'>
Probably what we need is to expose a function that given a set of parameters will give you the classes to style any of those elements, for the more advanced use cases. Something along the lines of:
exportconstgetButtonClasses=({ size, type })=>`kuiButton kuiButton--${size} kuiButton--${type}`
@snide Here's an example from Cloud (there's quite a few cases like this, for normal buttons too) that would be a great consumer example for the above API:
constAddButton=({ regionId, small =false, ...rest})=><Link{ ...rest}data-test-id='snapshotRepositories-addBtn'className={cx(`btn btn--success`,{'btn--sm': small})}to={createSnapshotRepositoryUrl(regionId)}><FormattedMessageid='snapshot-repository-management.add-repository'defaultMessage='Add Repository'/></Link>
With an API like the above, we could do something like
className={getButtonClasses({type: 'success',size: small ? 'small' : undefined})}
Yep. I agree, I don't think type would need to effect the presentation classes though luckily. I agree type makes better sense for the input type, and theme or even color works fine for the styling.
Normally I'd consider something like this a breaking change because it requires the devs to edit their existing work. We should probably talk a bit (later) about how we'd handle changes like this (release notes, versioning...etc) as we come across more of these.
In Kibana master we changed type to buttonType to avoid this shadowing bug. I think we may have just overlooked this when we created this component in K7. So my suggestion is to rename this prop buttonType, and to apply the same naming pattern to other components which need a "type" property.
In terms of which combination of element and type attribute to support, I think we only need to support <button type="button"> and <button type="submit">. The input element doesn't provide any advantages over button, from what I've read. This would simplify implementation drastically, since we just need to stop shadowing the type prop and All Our Problems Are Magically Solved™.
WRT getButtonClasses, I think this implementation couples the prop values too tightly with the class names:
exportconstgetButtonClasses=({ size, type })=>`kuiButton kuiButton--${size} kuiButton--${type}`
I agree that we'll want these values to be similar/identical to make the code easier to read, but I think decoupling them is just a good defensive programming practice to prevent stuff from accidentally breaking if we decide to tweak CSS class names or acceptable prop values. This also lets you see up-front which types are supported:
Yeah, that's a great point. The implementation should definitely be whatever already exists in the components, and then we can expose those bits as a public API as well, so things that depend upon EUI can use the same logic without necessarily knowing about class names
Activity
snide commentedon Oct 23, 2017
There's also the third option of just making a new component that's more direct...
ButtonSubmitor whatever. Not a great one either (cuz it'd mostly be a dupe), but that's how it's handled in the current code.https://github.com/elastic/kibana/blob/master/ui_framework/src/components/button/button.js#L172-L187
bevacqua commentedon Oct 23, 2017
@snide note that there's a bunch of different permutations, so that approach can be problematic:
<input type='button'><button><button type='button'><input type='submit'><button type='submit'>Probably what we need is to expose a function that given a set of parameters will give you the classes to style any of those elements, for the more advanced use cases. Something along the lines of:
bevacqua commentedon Oct 23, 2017
@snide Here's an example from Cloud (there's quite a few cases like this, for normal buttons too) that would be a great consumer example for the above API:
With an API like the above, we could do something like
snide commentedon Oct 23, 2017
Yep. I agree, I don't think type would need to effect the presentation classes though luckily. I agree
typemakes better sense for the input type, andthemeor evencolorworks fine for the styling.Normally I'd consider something like this a breaking change because it requires the devs to edit their existing work. We should probably talk a bit (later) about how we'd handle changes like this (release notes, versioning...etc) as we come across more of these.
cjcenizal commentedon Oct 23, 2017
In Kibana
masterwe changedtypetobuttonTypeto avoid this shadowing bug. I think we may have just overlooked this when we created this component in K7. So my suggestion is to rename this propbuttonType, and to apply the same naming pattern to other components which need a "type" property.In terms of which combination of element and
typeattribute to support, I think we only need to support<button type="button">and<button type="submit">. Theinputelement doesn't provide any advantages overbutton, from what I've read. This would simplify implementation drastically, since we just need to stop shadowing thetypeprop and All Our Problems Are Magically Solved™.WRT
getButtonClasses, I think this implementation couples the prop values too tightly with the class names:I agree that we'll want these values to be similar/identical to make the code easier to read, but I think decoupling them is just a good defensive programming practice to prevent stuff from accidentally breaking if we decide to tweak CSS class names or acceptable prop values. This also lets you see up-front which types are supported:
bevacqua commentedon Oct 23, 2017
Yeah, that's a great point. The implementation should definitely be whatever already exists in the components, and then we can expose those bits as a public API as well, so things that depend upon EUI can use the same logic without necessarily knowing about class names
Use shouldComponentUpdate to avoid unnecessary calls to updateFocus i…
EuiComboBox: Add buttons for clearing and opening/closing the combo b…
[EuiDataGrid] Fix row height not updating dynamically when set to `au…
[EuiDataGrid] Fix row height not updating dynamically when set to `au…
[EuiButtonGroup] Implement redesign #3 - Selection variant (#9929)
[EuiButtonGroup] Implement redesign elastic#3 - Selection variant (el…
[Theme] Redesign: Implement component updates - part #3 (#10016)
[EuiButtonGroup] Implement redesign elastic#3 - Selection variant (el…