Skip to content

Commit

Permalink
fix(button-react): convert icon classes to function
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelflips committed May 28, 2024
1 parent 70577a0 commit 111609b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/sage-react/lib/Button/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { SageClassnames } from '../configs';
import { Link } from '../Link';
import { Loader } from '../Loader';
import { SageTokens } from '../configs';
import { SageTokens, SageClassnames } from '../configs';
import { ButtonGroup } from './ButtonGroup';
import {
BUTTON_COLORS,
Expand Down Expand Up @@ -55,6 +54,13 @@ export const Button = React.forwardRef(({
}
);

let setIconClassName = (iconOnly, iconPosition) => {

Check failure on line 57 in packages/sage-react/lib/Button/Button.jsx

View workflow job for this annotation

GitHub Actions / Lint, Test, Build (16)

'setIconClassName' is never reassigned. Use 'const' instead

Check failure on line 57 in packages/sage-react/lib/Button/Button.jsx

View workflow job for this annotation

GitHub Actions / Lint, Test, Build (18)

'setIconClassName' is never reassigned. Use 'const' instead

Check failure on line 57 in packages/sage-react/lib/Button/Button.jsx

View workflow job for this annotation

GitHub Actions / Lint, Test, Build (20)

'setIconClassName' is never reassigned. Use 'const' instead
if (iconOnly) {
return '';
}
return iconPosition === 'right' ? SageClassnames.SPACERS.XS_LEFT : SageClassnames.SPACERS.XS_RIGHT;
};

if (loading) {
rest['aria-busy'] = true;
rest['aria-label'] = rest['aria-label'] || BUTTON_DEFAULT_LOADING_TEXT;
Expand Down Expand Up @@ -83,17 +89,17 @@ export const Button = React.forwardRef(({
{...rest}
>
{icon && (
<pds-icon
name={icon}
class={iconOnly ? "" : iconPosition === "right" ? SageClassnames.SPACERS.XS_LEFT : SageClassnames.SPACERS.XS_RIGHT}
/>
<pds-icon
name={icon}
class={setIconClassName(iconOnly, iconPosition)}
/>
)}
<span className={generatedClassNames}>
{children}
</span>
{disclosure && (
<pds-icon
name='caret-down'
name="caret-down"
class={SageClassnames.SPACERS.XS_LEFT}
/>
)}
Expand Down

0 comments on commit 111609b

Please sign in to comment.