Skip to content

Commit

Permalink
fix(html): handle html attributes in button html helper
Browse files Browse the repository at this point in the history
  • Loading branch information
joneff committed Oct 5, 2021
1 parent 28bf2d2 commit c3f4a7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions packages/html/src/button.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as styles from '../utils/styles';
import { Component } from './component';
import { Component, globalDefaultProps } from './component';
import { IconStatic } from './icon.jsx';

class Button extends Component {
Expand Down Expand Up @@ -29,7 +29,9 @@ function ButtonStatic(props) {
icon,

aria,
legacy
legacy,

...htmlAttributes
} = props;

let buttonClasses = [
Expand Down Expand Up @@ -58,22 +60,24 @@ function ButtonStatic(props) {

if (legacy) {
return (
<button type={type} className={legacyClasses} {...ariaAttr}>
<button type={type} className={legacyClasses} {...ariaAttr} {...htmlAttributes}>
<IconStatic name={icon} />
{ text }
</button>
);
}

return (
<button type={type} className={buttonClasses} {...ariaAttr}>
<button type={type} className={buttonClasses} {...ariaAttr} {...htmlAttributes}>
<IconStatic className="k-button-icon" name={icon} />
<span className="k-button-text">{ text }</span>
</button>
);
}

ButtonStatic.defaultProps = {
...globalDefaultProps,

text: '',
icon: '',

Expand All @@ -85,10 +89,7 @@ ButtonStatic.defaultProps = {
shape: 'rectangle',

fillMode: 'solid',
themeColor: 'base',

aria: false,
legacy: false
themeColor: 'base'
};

ButtonStatic.propTypes = {
Expand Down
4 changes: 2 additions & 2 deletions packages/html/src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Component {
constructor( element ) {

this._element = element;
this._props = { ...globalDefaultProps, ...attrToProps( element ) };
this._props = attrToProps( element );

delete this._props.is;

Expand All @@ -40,4 +40,4 @@ class Component {

}

export { Component };
export { Component, globalDefaultProps };

0 comments on commit c3f4a7b

Please sign in to comment.