From 77c9f09870b5cefcd8f916ba0f6a339a38b5895c Mon Sep 17 00:00:00 2001 From: Alexander Fedyashov Date: Tue, 24 Jan 2017 20:44:50 +0200 Subject: [PATCH 1/2] style(Button): update typings and propTypes usage --- src/elements/Button/Button.js | 127 ++++++++-------- src/elements/Button/ButtonContent.js | 19 ++- src/elements/Button/ButtonGroup.js | 80 ++++++----- src/elements/Button/ButtonOr.js | 2 +- src/elements/Button/index.d.ts | 136 +++++++++++------- src/index.d.ts | 2 - test/specs/elements/Button/Button-test.js | 2 +- .../elements/Button/ButtonContent-test.js | 3 +- 8 files changed, 204 insertions(+), 167 deletions(-) diff --git a/src/elements/Button/Button.js b/src/elements/Button/Button.js index eac59cb854..a047d8f176 100644 --- a/src/elements/Button/Button.js +++ b/src/elements/Button/Button.js @@ -1,5 +1,5 @@ -import _ from 'lodash' import cx from 'classnames' +import _ from 'lodash' import React, { Component, PropTypes } from 'react' import { @@ -16,37 +16,14 @@ import { } from '../../lib' import Icon from '../Icon/Icon' import Label from '../Label/Label' - import ButtonContent from './ButtonContent' import ButtonGroup from './ButtonGroup' import ButtonOr from './ButtonOr' const debug = makeDebugger('button') -const _meta = { - name: 'Button', - type: META.TYPES.ELEMENT, - props: { - animated: ['fade', 'vertical'], - attached: ['left', 'right', 'top', 'bottom'], - color: [ - ...SUI.COLORS, - 'facebook', - 'twitter', - 'google plus', - 'vk', - 'linkedin', - 'instagram', - 'youtube', - ], - floated: SUI.FLOATS, - labelPosition: ['right', 'left'], - size: SUI.SIZES, - }, -} - /** - * A Button indicates a possible user action + * A Button indicates a possible user action. * @see Form * @see Icon * @see Label @@ -56,19 +33,19 @@ class Button extends Component { /** An element type to render as (string or function). */ as: customPropTypes.as, - /** A button can show it is currently the active user selection */ + /** A button can show it is currently the active user selection. */ active: PropTypes.bool, - /** A button can animate to show hidden content */ + /** A button can animate to show hidden content. */ animated: PropTypes.oneOfType([ PropTypes.bool, - PropTypes.oneOf(_meta.props.animated), + PropTypes.oneOf(['fade', 'vertical']), ]), - /** A button can be attached to the top or bottom of other content */ - attached: PropTypes.oneOf(_meta.props.attached), + /** A button can be attached to the top or bottom of other content. */ + attached: PropTypes.oneOf(['left', 'right', 'top', 'bottom']), - /** A basic button is less pronounced */ + /** A basic button is less pronounced. */ basic: PropTypes.bool, /** Primary content. */ @@ -87,31 +64,34 @@ class Button extends Component { ), ]), - /** A button can be circular */ - circular: PropTypes.bool, - /** Additional classes. */ className: PropTypes.string, - /** Shorthand for primary content. */ - content: customPropTypes.contentShorthand, + /** A button can be circular. */ + circular: PropTypes.bool, /** A button can have different colors */ - color: PropTypes.oneOf(_meta.props.color), + color: PropTypes.oneOf([ + ...SUI.COLORS, + 'facebook', 'google plus', 'instagram', 'linkedin', 'twitter', 'vk', 'youtube', + ]), - /** A button can reduce its padding to fit into tighter spaces */ + /** A button can reduce its padding to fit into tighter spaces. */ compact: PropTypes.bool, - /** A button can show it is currently unable to be interacted with */ + /** Shorthand for primary content. */ + content: customPropTypes.contentShorthand, + + /** A button can show it is currently unable to be interacted with. */ disabled: PropTypes.bool, - /** A button can be aligned to the left or right of its container */ - floated: PropTypes.oneOf(_meta.props.floated), + /** A button can be aligned to the left or right of its container. */ + floated: PropTypes.oneOf(SUI.FLOATS), - /** A button can take the width of its container */ + /** A button can take the width of its container. */ fluid: PropTypes.bool, - /** Add an Icon by name, props object, or pass an */ + /** Add an Icon by name, props object, or pass an . */ icon: customPropTypes.some([ PropTypes.bool, PropTypes.string, @@ -119,23 +99,23 @@ class Button extends Component { PropTypes.element, ]), - /** A button can be formatted to appear on dark backgrounds */ + /** A button can be formatted to appear on dark backgrounds. */ inverted: PropTypes.bool, - /** A labeled button can format a Label or Icon to appear on the left or right */ - labelPosition: PropTypes.oneOf(_meta.props.labelPosition), - - /** Add a Label by text, props object, or pass a