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

Prefix remaining subcomponents with parent name #170

Merged
merged 5 commits into from
Feb 13, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default class StatisticBottomLabelExample extends Component {
render() {
return (
<Statistic>
<Statistic.Label>5,550</Statistic.Label>
<Statistic.Value>Downloads</Statistic.Value>
<Statistic.Value>5,550</Statistic.Value>
<Statistic.Label>Downloads</Statistic.Label>
</Statistic>
)
}
Expand Down
10 changes: 5 additions & 5 deletions src/collections/Grid/Grid.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import classNames from 'classnames'
import React, { Component, PropTypes } from 'react'
import META from '../../utils/Meta'
import Column from './Column'
import Row from './Row'
import GridColumn from './GridColumn'
import GridRow from './GridRow'

export default class Grid extends Component {
static propTypes = {
Expand All @@ -16,15 +16,15 @@ export default class Grid extends Component {
type: META.type.collection,
};

static Column = Column;
static Row = Row;
static Column = GridColumn;
static Row = GridRow;

render() {
const classes = classNames(
'sd-grid',
'ui',
this.props.className,
'grid',
'grid'
)
return (
<div {...this.props} className={classes}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { Component, PropTypes } from 'react'
import numberToWord from '../../utils/numberToWord'
import META from '../../utils/Meta.js'

export default class Column extends Component {
export default class GridColumn extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import classNames from 'classnames'
import React, { Component, PropTypes } from 'react'
import META from '../../utils/Meta'

export default class Row extends Component {
export default class GridRow extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
Expand Down
28 changes: 14 additions & 14 deletions src/elements/Header/Header.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import React, { Component } from 'react'
import META from '../../utils/Meta'
import _Header from './_Header'
import H1 from './H1'
import H2 from './H2'
import H3 from './H3'
import H4 from './H4'
import H5 from './H5'
import H6 from './H6'
import Subheader from './Subheader'
import HeaderH1 from './HeaderH1'
import HeaderH2 from './HeaderH2'
import HeaderH3 from './HeaderH3'
import HeaderH4 from './HeaderH4'
import HeaderH5 from './HeaderH5'
import HeaderH6 from './HeaderH6'
import HeaderSubheader from './HeaderSubheader'

export default class Header extends Component {
static _meta = {
library: META.library.semanticUI,
name: 'Header',
type: META.type.element,
};
static H1 = H1;
static H2 = H2;
static H3 = H3;
static H4 = H4;
static H5 = H5;
static H6 = H6;
static Subheader = Subheader;
static H1 = HeaderH1;
static H2 = HeaderH2;
static H3 = HeaderH3;
static H4 = HeaderH4;
static H5 = HeaderH5;
static H6 = HeaderH6;
static Subheader = HeaderSubheader;
render() {
return (
<_Header {...this.props} _headerElement='div'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react'
import META from '../../utils/Meta'
import _Header from './_Header'

export default class H1 extends Component {
export default class HeaderH1 extends Component {
static _meta = {
library: META.library.semanticUI,
name: 'H1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react'
import META from '../../utils/Meta'
import _Header from './_Header'

export default class H2 extends Component {
export default class HeaderH2 extends Component {
static _meta = {
library: META.library.semanticUI,
name: 'H2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react'
import META from '../../utils/Meta'
import _Header from './_Header'

export default class H3 extends Component {
export default class HeaderH3 extends Component {
static _meta = {
library: META.library.semanticUI,
name: 'H3',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react'
import META from '../../utils/Meta'
import _Header from './_Header'

export default class H4 extends Component {
export default class HeaderH4 extends Component {
static _meta = {
library: META.library.semanticUI,
name: 'H4',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react'
import META from '../../utils/Meta'
import _Header from './_Header'

export default class H5 extends Component {
export default class HeaderH5 extends Component {
static _meta = {
library: META.library.semanticUI,
name: 'H5',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react'
import META from '../../utils/Meta'
import _Header from './_Header'

export default class H6 extends Component {
export default class HeaderH6 extends Component {
static _meta = {
library: META.library.semanticUI,
name: 'H6',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames'
import META from '../../utils/Meta'
import getUnhandledProps from '../../utils/getUnhandledProps'

export default class Subheader extends Component {
export default class HeaderSubheader extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import Confirm from './addons/Confirm/Confirm'
import Textarea from './addons/Textarea/Textarea'

// Collections
import Column from './collections/Grid/Column'
import { default as Column } from './collections/Grid/GridColumn'
import { default as Field } from './collections/Form/FormField'
import { default as Fields } from './collections/Form/FormFields'
import Form from './collections/Form/Form'
import Grid from './collections/Grid/Grid'
import Row from './collections/Grid/Row'
import { default as Row } from './collections/Grid/GridRow'
import Menu from './collections/Menu/Menu'
import MenuItem from './collections/Menu/MenuItem'
import Message from './collections/Message/Message'
Expand Down
8 changes: 4 additions & 4 deletions src/views/Statistic/Statistic.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { customPropTypes } from '../../utils/propUtils'
import META from '../../utils/Meta'

import Statistics from './Statistics'
import Label from './Label'
import Value from './Value'
import StatisticLabel from './StatisticLabel'
import StatisticValue from './StatisticValue'

export default class Statistic extends Component {
static propTypes = {
Expand All @@ -22,8 +22,8 @@ export default class Statistic extends Component {
};

static Statistics = Statistics;
static Label = Label;
static Value = Value;
static Label = StatisticLabel;
static Value = StatisticValue;

render() {
const classes = classNames(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames'
import getUnhandledProps from '../../utils/getUnhandledProps'
import META from '../../utils/Meta'

export default class Label extends Component {
export default class StatisticLabel extends Component {
static propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames'
import getUnhandledProps from '../../utils/getUnhandledProps'
import META from '../../utils/Meta'

export default class Value extends Component {
export default class StatisticValue extends Component {
static propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string,
Expand Down
6 changes: 3 additions & 3 deletions test/specs/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const componentNames = _.map(componentCtx.keys(), key => {

describe('stardust (index.js)', () => {
_.each(componentNames, name => {
const shortName = _.words(name)[1] // => FormField => Field
const nameWithoutPrefix = _.words(name).splice(1).join('') // => HeaderH1 => H1
const isPrivate = META.isPrivate(name)
const isStardustProp = _.has(stardust, name) || _.has(stardust, shortName) // => stardust.H1
const isSubComponent = _.some(stardust, name) // => stardust.Header.H1
const isStardustProp = _.has(stardust, name) || _.has(stardust, nameWithoutPrefix) // => stardust.H1
const isSubComponent = _.some(stardust, name) || _.some(stardust, nameWithoutPrefix) // => stardust.Header.H1

if (isPrivate) {
it(`does not expose private component "${name}"`, () => {
Expand Down