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

fix(Button): Add bool to propTypes of attached #2105

Merged
merged 3 commits into from
Sep 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/elements/Button/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export interface ButtonProps {
/** A button can animate to show hidden content. */
animated?: boolean | 'fade' | 'vertical';

/** A button can be attached to the top or bottom of other content. */
attached?: 'left' | 'right' | 'top' | 'bottom';
/** A button can be attached to other content. */
attached?: boolean | 'left' | 'right' | 'top' | 'bottom';

/** A basic button is less pronounced. */
basic?: boolean;
Expand Down
7 changes: 5 additions & 2 deletions src/elements/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ class Button extends Component {
PropTypes.oneOf(['fade', 'vertical']),
]),

/** A button can be attached to the top or bottom of other content. */
attached: PropTypes.oneOf(['left', 'right', 'top', 'bottom']),
/** A button can be attached to other content. */
attached: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(['left', 'right', 'top', 'bottom']),
]),

/** A basic button is less pronounced. */
basic: PropTypes.bool,
Expand Down
4 changes: 2 additions & 2 deletions src/elements/Button/ButtonGroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export interface ButtonGroupProps {
/** An element type to render as (string or function). */
as?: any;

/** A button can be attached to the top or bottom of other content. */
attached?: 'left' | 'right' | 'top' | 'bottom';
/** Groups can be attached to other content. */
attached?: boolean | 'left' | 'right' | 'top' | 'bottom';

/** Groups can be less pronounced. */
basic?: boolean;
Expand Down
10 changes: 7 additions & 3 deletions src/elements/Button/ButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
META,
SUI,
useKeyOnly,
useKeyOrValueAndKey,
useValueAndKey,
useWidthProp,
} from '../../lib'
Expand Down Expand Up @@ -55,7 +56,7 @@ function ButtonGroup(props) {
useKeyOnly(secondary, 'secondary'),
useKeyOnly(toggle, 'toggle'),
useKeyOnly(vertical, 'vertical'),
useValueAndKey(attached, 'attached'),
useKeyOrValueAndKey(attached, 'attached'),
useValueAndKey(floated, 'floated'),
useWidthProp(widths),
'buttons',
Expand All @@ -77,8 +78,11 @@ ButtonGroup.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** A button can be attached to the top or bottom of other content. */
attached: PropTypes.oneOf(['left', 'right', 'top', 'bottom']),
/** Groups can be attached to other content. */
attached: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(['left', 'right', 'top', 'bottom']),
]),

/** Groups can be less pronounced. */
basic: PropTypes.bool,
Expand Down
3 changes: 2 additions & 1 deletion test/specs/elements/Button/ButtonGroup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('ButtonGroup', () => {
widthClass: 'buttons',
})

common.propKeyAndValueToClassName(ButtonGroup, 'attached', ['left', 'right', 'top', 'bottom'])
common.propKeyAndValueToClassName(ButtonGroup, 'floated', SUI.FLOATS)

common.propKeyOnlyToClassName(ButtonGroup, 'basic')
Expand All @@ -31,6 +30,8 @@ describe('ButtonGroup', () => {
common.propKeyOnlyToClassName(ButtonGroup, 'toggle')
common.propKeyOnlyToClassName(ButtonGroup, 'vertical')

common.propKeyOrValueAndKeyToClassName(ButtonGroup, 'attached', ['left', 'right', 'top', 'bottom'])

common.propValueOnlyToClassName(ButtonGroup, 'color', SUI.COLORS)
common.propValueOnlyToClassName(ButtonGroup, 'size', SUI.SIZES)
})