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

style(Loader|Reveal|Segment): propTypes cleanups and typings update #1165

Merged
merged 4 commits into from
Jan 17, 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
14 changes: 7 additions & 7 deletions src/elements/Loader/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ function Loader(props) {
const rest = getUnhandledProps(Loader, props)
const ElementType = getElementType(Loader, props)

return <ElementType {...rest} className={classes}>{_.isNil(children) ? content : children}</ElementType>
return (
<ElementType {...rest} className={classes}>
{_.isNil(children) ? content : children}
</ElementType>
)
}

Loader._meta = {
name: 'Loader',
type: META.TYPES.ELEMENT,
props: {
inline: ['centered'],
size: SUI.SIZES,
},
}

Loader.propTypes = {
Expand Down Expand Up @@ -81,14 +81,14 @@ Loader.propTypes = {
/** Loaders can appear inline with content. */
inline: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(Loader._meta.props.inline),
PropTypes.oneOf(['centered']),
]),

/** Loaders can have their colors inverted. */
inverted: PropTypes.bool,

/** Loaders can have different sizes. */
size: PropTypes.oneOf(Loader._meta.props.size),
size: PropTypes.oneOf(SUI.SIZES),
}

export default Loader
10 changes: 5 additions & 5 deletions src/elements/Loader/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SemanticSIZES } from '../..';
import * as React from 'react';

import { SemanticSIZES } from '../..';

interface LoaderProps {

[key: string]: any;

/** An element type to render as (string or function). */
as?: any;

Expand Down Expand Up @@ -34,5 +34,5 @@ interface LoaderProps {
/** Loaders can have different sizes. */
size?: SemanticSIZES;
}
export class Loader extends React.Component<LoaderProps, void> {
}

export const Loader: React.StatelessComponent<LoaderProps>;
17 changes: 7 additions & 10 deletions src/elements/Reveal/Reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ function Reveal(props) {
Reveal._meta = {
name: 'Reveal',
type: META.TYPES.ELEMENT,
props: {
animated: [
'fade', 'small fade',
'move', 'move right', 'move up', 'move down',
'rotate', 'rotate left',
],
},
}

Reveal.propTypes = {
Expand All @@ -57,6 +50,13 @@ Reveal.propTypes = {
/** An active reveal displays its hidden content. */
active: PropTypes.bool,

/** An animation name that will be applied to Reveal. */
animated: PropTypes.oneOf([
'fade', 'small fade',
'move', 'move right', 'move up', 'move down',
'rotate', 'rotate left',
]),

/** Primary content. */
children: PropTypes.node,

Expand All @@ -66,9 +66,6 @@ Reveal.propTypes = {
/** A disabled reveal will not animate when hovered. */
disabled: PropTypes.bool,

/** An animation name that will be applied to Reveal. */
animated: PropTypes.oneOf(Reveal._meta.props.animated),

/** An element can show its content without delay. */
instant: PropTypes.bool,
}
Expand Down
52 changes: 32 additions & 20 deletions src/elements/Reveal/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,55 @@
import * as React from 'react';

interface RevealContentProps {
interface RevealProps {
[key: string]: any;

/** An element type to render as (string or function). */
as?: any;

/** Additional classes. */
className?: string;

/** A reveal may contain content that is visible before interaction. */
hidden?: boolean;

/** A reveal may contain content that is hidden before user interaction. */
visible?: boolean;
}

export const RevealContent: React.ComponentClass<RevealContentProps>;

interface RevealProps {
/** An active reveal displays its hidden content. */
active?: boolean;

/** An animation name that will be applied to Reveal. */
animated?: 'fade' | 'small fade' | 'move' | 'move right' | 'move up' | 'move down' | 'rotate' | 'rotate left';

/** An element type to render as (string or function). */
as?: any;
animated?: 'fade' | 'small fade'
| 'move' | 'move right' | 'move up' | 'move down'
| 'rotate' | 'rotate left';

/** Additional classes. */
className?: string;

/** Primary content. */
children?: React.ReactNode;

/** A disabled reveal will not animate when hovered. */
disabled?: boolean;

/** An element can show its content without delay. */
instant?: boolean;
}

interface RevealClass extends React.ComponentClass<RevealProps> {
interface RevealComponent extends React.StatelessComponent<RevealProps> {
Content: typeof RevealContent;
}

export const Reveal: RevealClass;
export const Reveal: RevealComponent;

interface RevealContentProps {
[key: string]: any;

/** An element type to render as (string or function). */
as?: any;

/** Primary content. */
children?: React.ReactNode;

/** Additional classes. */
className?: string;

/** A reveal may contain content that is visible before interaction. */
hidden?: boolean;

/** A reveal may contain content that is hidden before user interaction. */
visible?: boolean;
}

export const RevealContent: React.StatelessComponent<RevealContentProps>;
58 changes: 25 additions & 33 deletions src/elements/Segment/Segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ function Segment(props) {
'ui',
color,
size,
useKeyOrValueAndKey(attached, 'attached'),
useKeyOnly(basic, 'basic'),
useKeyOnly(circular, 'circular'),
useKeyOnly(clearing, 'clearing'),
useKeyOnly(compact, 'compact'),
useKeyOnly(disabled, 'disabled'),
useValueAndKey(floated, 'floated'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(loading, 'loading'),
useKeyOrValueAndKey(padded, 'padded'),
useKeyOnly(piled, 'piled'),
useKeyOnly(raised, 'raised'),
useKeyOnly(secondary, 'secondary'),
useKeyOnly(stacked, 'stacked'),
useKeyOnly(tertiary, 'tertiary'),
useTextAlignProp(textAlign),
useKeyOnly(vertical, 'vertical'),
className,
useKeyOrValueAndKey(attached, 'attached'),
useKeyOrValueAndKey(padded, 'padded'),
useTextAlignProp(textAlign),
useValueAndKey(floated, 'floated'),
'segment',
className,
)
const rest = getUnhandledProps(Segment, props)
const ElementType = getElementType(Segment, props)
Expand All @@ -78,63 +78,55 @@ Segment.Group = SegmentGroup
Segment._meta = {
name: 'Segment',
type: META.TYPES.ELEMENT,
props: {
attached: ['top', 'bottom'],
color: SUI.COLORS,
floated: SUI.FLOATS,
padded: ['very'],
size: _.without(SUI.SIZES, 'medium'),
textAlign: SUI.TEXT_ALIGNMENTS,
},
}

Segment.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Attach segment to other content, like a header */
/** Attach segment to other content, like a header. */
attached: PropTypes.oneOfType([
PropTypes.oneOf(Segment._meta.props.attached),
PropTypes.bool,
PropTypes.oneOf('top', 'bottom'),
]),

/** A basic segment has no special formatting */
/** A basic segment has no special formatting. */
basic: PropTypes.bool,

/** Primary content. */
children: PropTypes.node,

/** A segment can be circular */
/** A segment can be circular. */
circular: PropTypes.bool,

/** Additional classes. */
className: PropTypes.string,

/** A segment can clear floated content */
/** A segment can clear floated content. */
clearing: PropTypes.bool,

/** Segment can be colored */
color: PropTypes.oneOf(Segment._meta.props.color),
/** Segment can be colored. */
color: PropTypes.oneOf(SUI.COLORS),

/** A segment may take up only as much space as is necessary */
/** A segment may take up only as much space as is necessary. */
compact: PropTypes.bool,

/** A segment may show its content is disabled */
/** A segment may show its content is disabled. */
disabled: PropTypes.bool,

/** Segment content can be floated to the left or right */
floated: PropTypes.oneOf(Segment._meta.props.floated),
/** Segment content can be floated to the left or right. */
floated: PropTypes.oneOf(SUI.FLOATS),

/** A segment can have its colors inverted for contrast */
/** A segment can have its colors inverted for contrast. */
inverted: PropTypes.bool,

/** A segment may show its content is being loaded */
/** A segment may show its content is being loaded. */
loading: PropTypes.bool,

/** A segment can increase its padding */
/** A segment can increase its padding. */
padded: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf(Segment._meta.props.padded),
PropTypes.oneOf(['very']),
]),

/** Formatted to look like a pile of pages. */
Expand All @@ -143,22 +135,22 @@ Segment.propTypes = {
/** A segment may be formatted to raise above the page. */
raised: PropTypes.bool,

/** A segment can be formatted to appear less noticeable */
/** A segment can be formatted to appear less noticeable. */
secondary: PropTypes.bool,

/** A segment can have different sizes. */
size: PropTypes.oneOf(Segment._meta.props.size),
size: PropTypes.oneOf(_.without(SUI.SIZES, 'medium')),

/** Formatted to show it contains multiple pages. */
stacked: PropTypes.bool,

/** A segment can be formatted to appear even less noticeable */
/** A segment can be formatted to appear even less noticeable. */
tertiary: PropTypes.bool,

/** Formats content to be aligned as part of a vertical group. */
textAlign: PropTypes.oneOf(Segment._meta.props.textAlign),
textAlign: PropTypes.oneOf(SUI.TEXT_ALIGNMENTS),

/** Formats content to be aligned vertically */
/** Formats content to be aligned vertically. */
vertical: PropTypes.bool,
}

Expand Down
31 changes: 19 additions & 12 deletions src/elements/Segment/SegmentGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,27 @@ import {
* A group of segments can be formatted to appear together.
*/
function SegmentGroup(props) {
const { children, className, compact, horizontal, piled, raised, size, stacked } = props
const {
children,
className,
compact,
horizontal,
piled,
raised,
size,
stacked,
} = props

const classes = cx(
'ui',
size,
useKeyOnly(horizontal, 'horizontal'),
useKeyOnly(compact, 'compact'),
useKeyOnly(horizontal, 'horizontal'),
useKeyOnly(piled, 'piled'),
useKeyOnly(raised, 'raised'),
useKeyOnly(stacked, 'stacked'),
className,
'segments',
className,
)
const rest = getUnhandledProps(SegmentGroup, props)
const ElementType = getElementType(SegmentGroup, props)
Expand All @@ -37,25 +47,22 @@ SegmentGroup._meta = {
name: 'SegmentGroup',
parent: 'Segment',
type: META.TYPES.ELEMENT,
props: {
size: _.without(SUI.SIZES, 'medium'),
},
}

SegmentGroup.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Additional classes. */
className: PropTypes.string,

/** Primary content. */
children: PropTypes.node,

/** A segment may take up only as much space as is necessary */
/** Additional classes. */
className: PropTypes.string,

/** A segment may take up only as much space as is necessary. */
compact: PropTypes.bool,

/** Formats content to be aligned horizontally */
/** Formats content to be aligned horizontally. */
horizontal: PropTypes.bool,

/** Formatted to look like a pile of pages. */
Expand All @@ -65,7 +72,7 @@ SegmentGroup.propTypes = {
raised: PropTypes.bool,

/** A segment group can have different sizes. */
size: PropTypes.oneOf(SegmentGroup._meta.props.size),
size: PropTypes.oneOf(_.without(SUI.SIZES, 'medium')),

/** Formatted to show it contains multiple pages. */
stacked: PropTypes.bool,
Expand Down
Loading