Skip to content
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
43 changes: 23 additions & 20 deletions docs/src/js/components/ElementsImage.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

import 'images/marty-mcfly.jpg';

import PropTypes from 'prop-types';
import React from 'react';
import { Card, Header, Image, TitleBar } from 'react-cm-ui';

// Docs UI Components
import Block from 'components/UI/Block.react';
import Highlighter from 'components/UI/Highlighter.react';
import Main from 'components/UI/Main.react';
import TableProps from 'components/UI/TableProps.react';
import Highlighter from 'components/UI/Highlighter.react.js';
import Main from 'components/UI/Main.react.js';
import React from 'react';
import TableProps from 'components/UI/TableProps.react.js';

const imageSample = `import React from 'react';
import { Image } from 'react-cm-ui';
Expand Down Expand Up @@ -56,7 +52,11 @@ export default class SizeSample extends React.Component {
<div>
<Image src="/images/marty-mcfly.jpg" size={100} /><br /><br />
<Image avatar size={44} name="Marty McFly" /><br /><br />
<Image avatar size={66} src="/images/marty-mcfly.jpg" />
<Image avatar size={66} src="/images/marty-mcfly.jpg" /><br /><br />
<Image avatar size={22} /><br /><br />
<Image avatar size={44} /><br /><br />
<Image avatar size={66} /><br /><br />
<Image avatar size={88} />
</div>
);
}
Expand All @@ -70,13 +70,13 @@ export default class ElementsImage extends React.Component {
type: 'enum',
default: 'img',
description: 'An element type to render as.',
allowedTypes: 'div, img'
allowedTypes: 'div, img',
}, {
name: 'avatar',
type: 'bool',
default: '',
description: 'An Image can be shown as a circular avatar.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'className',
type: 'string',
Expand All @@ -88,20 +88,20 @@ export default class ElementsImage extends React.Component {
type: 'number',
default: '',
description: 'Size of Image.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'src',
type: 'string',
default: '',
description: 'Path to image file.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'style',
type: 'object',
default: '',
description: 'Supply any inline styles to the Image or Image\'s container.',
allowedTypes: ''
}
allowedTypes: '',
},
];

const martyMcFlyImageSrc = window.location.host.indexOf('localhost') > -1 ?
Expand All @@ -119,7 +119,7 @@ export default class ElementsImage extends React.Component {
</Card>

{/* Image */}
<Header size="large" style={{ marginTop: '55px' }} sub={true}>
<Header size="large" style={{ marginTop: '55px' }} sub>
Image
<Header.Subheader>
An image.
Expand All @@ -133,7 +133,7 @@ export default class ElementsImage extends React.Component {
</Highlighter>

{/* Avatar */}
<Header size="large" style={{ marginTop: '55px' }} sub={true}>
<Header size="large" style={{ marginTop: '55px' }} sub>
Avatar
<Header.Subheader>
An image can be an avatar.
Expand All @@ -151,7 +151,7 @@ export default class ElementsImage extends React.Component {
</Highlighter>

{/* Size */}
<Header size="large" style={{ marginTop: '55px' }} sub={true}>
<Header size="large" style={{ marginTop: '55px' }} sub>
Size
<Header.Subheader>
Passing a size (number) will contrain the image by its width.
Expand All @@ -160,13 +160,16 @@ export default class ElementsImage extends React.Component {

<Image src={martyMcFlyImageSrc} size={100} /><br /><br />
<Image avatar size={44} name="Marty McFly" /><br /><br />
<Image avatar size={66} src={martyMcFlyImageSrc} />
<Image avatar size={66} src={martyMcFlyImageSrc} /><br /><br />
<Image avatar size={22} /><br /><br />
<Image avatar size={44} /><br /><br />
<Image avatar size={66} /><br /><br />
<Image avatar size={88} />

<Highlighter customStyle={{ marginBottom: '44px', marginTop: '44px' }}>
{sizeSample}
</Highlighter>
</Main>
);
}

}
66 changes: 39 additions & 27 deletions docs/src/js/components/ModulesAccordion.react.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@

'use strict';

import PropTypes from 'prop-types';
import { Accordion, Card, Header, SubNavigation, TitleBar } from 'react-cm-ui';
import Block from 'components/UI/Block.react.js';
import Highlighter from 'components/UI/Highlighter.react.js';
import Main from 'components/UI/Main.react.js';
import React from 'react';
import ReactDOM from 'react-dom';
import ScrollBar from 'react-custom-scrollbars';
import { Accordion, Card, Header, SubNavigation, TitleBar } from 'react-cm-ui';

// Docs UI Components
import Block from 'components/UI/Block.react';
import Highlighter from 'components/UI/Highlighter.react';
import Main from 'components/UI/Main.react';
import TableProps from 'components/UI/TableProps.react';

const accordionSample = `import React from 'react';
Expand Down Expand Up @@ -392,8 +389,7 @@ export default class CustomSummarySample extends React.Component {
</div>
);
}
}`

}`;

export default class CollectionsAccordion extends React.Component {
constructor(props) {
Expand All @@ -402,10 +398,11 @@ export default class CollectionsAccordion extends React.Component {
this.state = {
scrollBarNode: null,
subNavIndex: 0,
controlledExampleSelectedIndex: 0 // first item expanded by default
controlledExampleSelectedIndex: 0, // first item expanded by default
};

this._onClickAccordionItem = this._onClickAccordionItem.bind(this);
this._onClickBasicAccordionItem = this._onClickBasicAccordionItem.bind(this);
}

render() {
Expand All @@ -416,38 +413,38 @@ export default class CollectionsAccordion extends React.Component {
type: 'bool',
default: '',
description: 'Simplify an Accordion to a basic pared down style.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'className',
type: 'string',
default: '',
description: 'Additional classes.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'exclusive',
type: 'bool',
default: 'true',
description: 'Only allow one Accordion Item to open at a time.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'inverse',
type: 'bool',
default: '',
description: 'Format to appear on dark backgrounds.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'selected',
type: 'array || number',
default: '',
description: 'Change the default selected Accordion Item.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'style',
type: 'object',
default: '',
description: 'Supply any inline styles to the Accordion\'s container. Mainly used for padding and margins.',
allowedTypes: ''
}
allowedTypes: '',
},
];

const itemProps = [
Expand All @@ -456,26 +453,26 @@ export default class CollectionsAccordion extends React.Component {
type: 'string',
default: '',
description: 'Additional classes.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'style',
type: 'object',
default: '',
description: 'Supply any inline styles to the Accordion\'s Item container. Mainly used for padding and margins.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'subAccordion',
type: 'bool',
default: '',
description: 'Required boolean for Accordion\'s nested inside of Accordion Item container.',
allowedTypes: ''
allowedTypes: '',
}, {
name: 'summary',
type: 'bool',
default: 'true',
description: 'Use custom content within an Accordion\'s Item.',
allowedTypes: ''
}
allowedTypes: '',
},
];

let examplesJSX;
Expand Down Expand Up @@ -603,7 +600,7 @@ export default class CollectionsAccordion extends React.Component {
<Header size="large" style={{ marginTop: '55px' }} sub>
Accordion
<Header.Subheader>
A baisc Accordion can be inverted to appear on darker backgrounds better.
A basic Accordion can be inverted to appear on darker backgrounds better.
</Header.Subheader>
</Header>

Expand Down Expand Up @@ -642,11 +639,17 @@ export default class CollectionsAccordion extends React.Component {
</Header>

<Accordion basic>
<Accordion.Item title="Option One">
<Accordion.Item
onClick={() => this._onClickBasicAccordionItem('Option One')}
title="Option One"
>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut commodo pretium odio, quis tristique sem suscipit eget. Morbi sit amet nibh quis lorem sodales suscipit. Nam a convallis sem. Pellentesque convallis tellus ex, nec finibus lacus placerat eget. Sed nec placerat nisl. Nam facilisis dolor non ante sollicitudin sollicitudin. Aliquam magna sem, ullamcorper eget ipsum tincidunt, lobortis semper magna. Mauris cursus urna nec tellus convallis mollis ut eget sem.</p>
</Accordion.Item>

<Accordion.Item title="Option Two">
<Accordion.Item
onClick={() => this._onClickBasicAccordionItem('Option Two')}
title="Option Two"
>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut commodo pretium odio, quis tristique sem suscipit eget. Morbi sit amet nibh quis lorem sodales suscipit. Nam a convallis sem. Pellentesque convallis tellus ex, nec finibus lacus placerat eget. Sed nec placerat nisl. Nam facilisis dolor non ante sollicitudin sollicitudin. Aliquam magna sem, ullamcorper eget ipsum tincidunt, lobortis semper magna. Mauris cursus urna nec tellus convallis mollis ut eget sem.</p>
</Accordion.Item>
</Accordion><br /><br />
Expand Down Expand Up @@ -752,7 +755,12 @@ export default class CollectionsAccordion extends React.Component {
</Block><br /><br />

<Block inverse style={{ height: '205px' }}>
<ScrollBar autoHide ref={scrollBarNode => { this.scrollBarNode = scrollBarNode }}>
<ScrollBar
autoHide
ref={scrollBarNode => {
this.scrollBarNode = scrollBarNode;
}}
>
<Accordion basic inverse scrollContainer={scrollBarNode} scrollContainerMarginHeight={15}>
<Accordion.Item title="Option One">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut commodo pretium odio, quis tristique sem suscipit eget. Morbi sit amet nibh quis lorem sodales suscipit. Nam a convallis sem. Pellentesque convallis tellus ex, nec finibus lacus placerat eget. Sed nec placerat nisl. Nam facilisis dolor non ante sollicitudin sollicitudin. Aliquam magna sem, ullamcorper eget ipsum tincidunt, lobortis semper magna. Mauris cursus urna nec tellus convallis mollis ut eget sem.</p>
Expand Down Expand Up @@ -814,7 +822,7 @@ export default class CollectionsAccordion extends React.Component {
<div
dangerouslySetInnerHTML={{
__html: `You can use the Accordion as a controlled component via the <strong>selected</strong> prop
by passing an <strong>onClick</strong> handler function to each item&rsquo;s summary.`
by passing an <strong>onClick</strong> handler function to each item&rsquo;s summary.`,
}}
/>
</Header.Subheader>
Expand Down Expand Up @@ -883,6 +891,10 @@ export default class CollectionsAccordion extends React.Component {
this.setState({ controlledExampleSelectedIndex: newSelectedIndex });
}

_onClickBasicAccordionItem(foo) {
console.log(`${foo} item was clicked!`); // eslint-disable-line no-console
}

_onSubNavClick(index) {
this.setState({ subNavIndex: index });
}
Expand Down
17 changes: 9 additions & 8 deletions src/Elements/Icon.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class Icon extends React.Component {
'icon-size-small': size === 'small',
'icon-size-xlarge': size === 'xlarge',
'icon-size-xsmall': size === 'xsmall',
'icon-size-xxlarge': size === 'xxlarge',
'icon-size-xxsmall': size === 'xxsmall',
'icon-spin': spin || type === 'spinner'
'icon-spin': spin || type === 'spinner',
});
const containerStyle = _.merge(style, {
height: _.isNumber(size) ? `${size / 16}rem` : null,
Expand Down Expand Up @@ -675,7 +676,7 @@ class Icon extends React.Component {
<svg style={svgStyle} viewBox="0 0 24 24">
<title>{title || type}</title>
<defs>
<polygon id={pathId} transform="translate(12.000000, 12.000000) rotate(180.000000) translate(-12.000000, -12.000000) " points="12 5 24 19 0 19"></polygon>
<polygon id={pathId} transform="translate(12.000000, 12.000000) rotate(180.000000) translate(-12.000000, -12.000000) " points="12 5 24 19 0 19" />
{renderGradientColor}
</defs>
<g fill="none" fillRule="evenodd">
Expand All @@ -698,7 +699,7 @@ class Icon extends React.Component {
<svg style={svgStyle} viewBox="0 0 24 24">
<title>{title || type}</title>
<defs>
<polygon id={pathId} points="5 12 19 0 19 24"></polygon>
<polygon id={pathId} points="5 12 19 0 19 24" />
{renderGradientColor}
</defs>
<g fill="none" fillRule="evenodd">
Expand All @@ -721,7 +722,7 @@ class Icon extends React.Component {
<svg style={svgStyle} viewBox="0 0 24 24">
<title>{title || type}</title>
<defs>
<polygon id={pathId} transform="translate(14.000000, 12.000000) rotate(90.000000) translate(-14.000000, -12.000000) " points="14 5 26 19 2 19"></polygon>
<polygon id={pathId} transform="translate(14.000000, 12.000000) rotate(90.000000) translate(-14.000000, -12.000000)" points="14 5 26 19 2 19" />
{renderGradientColor}
</defs>
<g fill="none" fillRule="evenodd">
Expand Down Expand Up @@ -767,7 +768,7 @@ class Icon extends React.Component {
<svg style={svgStyle} viewBox="0 0 24 24">
<title>{title || type}</title>
<defs>
<polygon id={pathId} points="12 5 24 19 0 19"></polygon>
<polygon id={pathId} points="12 5 24 19 0 19" />
{renderGradientColor}
</defs>
<g fill="none" fillRule="evenodd">
Expand Down Expand Up @@ -1028,7 +1029,7 @@ class Icon extends React.Component {
<svg style={svgStyle} viewBox="0 0 24 24">
<title>{title || type}</title>
<defs>
<circle id={pathId} cx="12" cy="12" r="12"></circle>
<circle id={pathId} cx="12" cy="12" r="12" />
{renderGradientColor}
</defs>
<g fill="none" fillRule="evenodd">
Expand Down Expand Up @@ -3645,12 +3646,12 @@ Icon.propTypes = {
rotate: PropTypes.number,
size: PropTypes.oneOfType([
PropTypes.oneOf(Utils.sizeEnums()),
PropTypes.number
PropTypes.number,
]),
spin: PropTypes.bool,
style: PropTypes.object,
title: PropTypes.string,
type: PropTypes.string.isRequired
type: PropTypes.string.isRequired,
};

export default Icon;
Loading