Skip to content

Commit

Permalink
style(Checkbox|Flag|Image|Radio): propTypes cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Fedyashov committed Jan 13, 2017
1 parent b7ffa6a commit 0d7d1cf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 40 deletions.
7 changes: 2 additions & 5 deletions src/addons/Radio/Radio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropTypes } from 'react'
import React from 'react'

import { getUnhandledProps, META } from '../../lib'
import Checkbox from '../../modules/Checkbox'
Expand All @@ -23,9 +23,6 @@ function Radio(props) {
Radio._meta = {
name: 'Radio',
type: META.TYPES.ADDON,
props: {
type: Checkbox._meta.props.type,
},
}

Radio.propTypes = {
Expand All @@ -36,7 +33,7 @@ Radio.propTypes = {
toggle: Checkbox.propTypes.toggle,

/** HTML input type, either checkbox or radio. */
type: PropTypes.oneOf(Radio._meta.props.type),
type: Checkbox.propTypes.type,
}

Radio.defaultProps = {
Expand Down
10 changes: 3 additions & 7 deletions src/elements/Flag/Flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const names = [

function Flag(props) {
const { className, name } = props
const classes = cx(name, className, 'flag')
const classes = cx(name, 'flag', className)
const rest = getUnhandledProps(Flag, props)
const ElementType = getElementType(Flag, props)

Expand All @@ -65,9 +65,6 @@ function Flag(props) {
Flag._meta = {
name: 'Flag',
type: META.TYPES.ELEMENT,
props: {
name: names,
},
}

Flag.propTypes = {
Expand All @@ -77,8 +74,8 @@ Flag.propTypes = {
/** Additional classes. */
className: PropTypes.string,

/** Flag name, can use the two digit country code, the full name, or a common alias */
name: customPropTypes.suggest(Flag._meta.props.name),
/** Flag name, can use the two digit country code, the full name, or a common alias. */
name: customPropTypes.suggest(names),
}

Flag.defaultProps = {
Expand All @@ -88,4 +85,3 @@ Flag.defaultProps = {
Flag.create = createShorthandFactory(Flag, value => ({ name: value }))

export default Flag

23 changes: 8 additions & 15 deletions src/elements/Image/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ Image.Group = ImageGroup
Image._meta = {
name: 'Image',
type: META.TYPES.ELEMENT,
props: {
verticalAlign: SUI.VERTICAL_ALIGNMENTS,
floated: SUI.FLOATS,
shape: ['rounded', 'circular'],
size: SUI.SIZES,
spaced: ['left', 'right'],
},
}

Image.propTypes = {
Expand Down Expand Up @@ -133,7 +126,7 @@ Image.propTypes = {
dimmer: customPropTypes.itemShorthand,

/** An image can sit to the left or right of other content. */
floated: PropTypes.oneOf(Image._meta.props.floated),
floated: PropTypes.oneOf(SUI.FLOATS),

/** An image can take up the width of its container. */
fluid: customPropTypes.every([
Expand All @@ -160,15 +153,15 @@ Image.propTypes = {
label: customPropTypes.itemShorthand,

/** An image may appear rounded or circular. */
shape: PropTypes.oneOf(Image._meta.props.shape),
shape: PropTypes.oneOf(['rounded', 'circular']),

/** An image may appear at different sizes. */
size: PropTypes.oneOf(Image._meta.props.size),
size: PropTypes.oneOf(SUI.SIZES),

/** An image can specify that it needs an additional spacing to separate it from nearby content. */
spaced: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(Image._meta.props.spaced),
PropTypes.oneOf(['left', 'right']),
]),

/** Specifies the URL of the image. */
Expand All @@ -177,16 +170,16 @@ Image.propTypes = {
/** Whether or not to add the ui className. */
ui: PropTypes.bool,

/** An image can specify its vertical alignment */
verticalAlign: PropTypes.oneOf(Image._meta.props.verticalAlign),
/** An image can specify its vertical alignment. */
verticalAlign: PropTypes.oneOf(SUI.VERTICAL_ALIGNMENTS),

/** The img element width attribute */
/** The img element width attribute. */
width: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),

/** An image can render wrapped in a `div.ui.image` as alternative HTML markup */
/** An image can render wrapped in a `div.ui.image` as alternative HTML markup. */
wrapped: customPropTypes.every([
PropTypes.bool,
// these props wrap the image in an a tag already
Expand Down
18 changes: 5 additions & 13 deletions src/modules/Checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ import {
} from '../../lib'
const debug = makeDebugger('checkbox')

const _meta = {
name: 'Checkbox',
type: META.TYPES.MODULE,
props: {
type: [
'checkbox',
'radio',
],
},
}

/**
* A checkbox allows a user to select a value from a small set of options, often binary
* @see Form
Expand Down Expand Up @@ -100,7 +89,7 @@ export default class Checkbox extends Component {
]),

/** HTML input type, either checkbox or radio. */
type: PropTypes.oneOf(_meta.props.type),
type: PropTypes.oneOf(['checkbox', 'radio']),

/** The HTML input value. */
value: PropTypes.string,
Expand All @@ -121,7 +110,10 @@ export default class Checkbox extends Component {
'indeterminate',
]

static _meta = _meta
static _meta = {
name: 'Checkbox',
type: META.TYPES.MODULE,
}

state = {}

Expand Down

0 comments on commit 0d7d1cf

Please sign in to comment.