Skip to content

Commit

Permalink
[docs] Better support IE11 (#6880)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed May 16, 2017
1 parent ca48b03 commit a88c6a1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
3 changes: 2 additions & 1 deletion docs/src/components/ApiMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import find from 'lodash/find';
import ApiMenuComponents from 'docs/src/components/ApiMenuComponents';
import { demoComponentsTree } from 'docs/src/components/files';

Expand All @@ -12,7 +13,7 @@ function ApiMenu(props) {
return null;
}

const item = demoComponentsTree.find((item2) => item2.demo.name === currentRoute.demo.name);
const item = find(demoComponentsTree, (item2) => item2.demo.name === currentRoute.demo.name);

if (!item) {
return null;
Expand Down
5 changes: 3 additions & 2 deletions docs/src/components/DemoButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import find from 'lodash/find';
import { Link } from 'react-router';
import IconButton from 'material-ui/IconButton';
import PlayCircleOutlineIcon from 'material-ui-icons/PlayCircleOutline';
Expand All @@ -15,8 +16,8 @@ function DemoButton(props) {
return null;
}

const item = demoComponentsTree.find((item2) => {
return item2.components.find((component) => component === currentRoute.componentAPI.name);
const item = find(demoComponentsTree, (item2) => {
return find(item2.components, (component) => component === currentRoute.componentAPI.name);
});

if (!item) {
Expand Down
46 changes: 23 additions & 23 deletions docs/src/pages/component-demos/chips/ChipsArray.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @flow weak
// @flow

import React, { Component } from 'react';
import PropTypes from 'prop-types';
Expand All @@ -17,13 +17,15 @@ const styleSheet = createStyleSheet('ChipsArray', (theme) => ({
}));

class ChipsArray extends Component {
state = { chipData: [
{ key: 0, label: 'Angular' },
{ key: 1, label: 'JQuery' },
{ key: 2, label: 'Polymer' },
{ key: 3, label: 'ReactJS' },
{ key: 4, label: 'Vue.js' },
] };
state = {
chipData: [
{ key: 0, label: 'Angular' },
{ key: 1, label: 'JQuery' },
{ key: 2, label: 'Polymer' },
{ key: 3, label: 'ReactJS' },
{ key: 4, label: 'Vue.js' },
],
};

styles = {
chip: {
Expand All @@ -35,35 +37,33 @@ class ChipsArray extends Component {
},
};

handleRequestDelete = (key) => () => {
if (key === 3) {
handleRequestDelete = (data) => () => {
if (data.label === 'ReactJS') {
alert('Why would you want to delete React?! :)'); // eslint-disable-line no-alert
return;
}

const chipData = [...this.state.chipData];
const chipToDelete = chipData.indexOf(chipData.find((chip) => chip.key === key));
const chipToDelete = chipData.indexOf(data);
chipData.splice(chipToDelete, 1);
this.setState({ chipData });
};

render() {
const classes = this.props.classes;

const renderChip = (data) => {
return (
<Chip
label={data.label}
key={data.key}
onRequestDelete={this.handleRequestDelete(data.key)}
className={classes.chip}
/>
);
};

return (
<div className={classes.row}>
{this.state.chipData.map(renderChip, this)}
{this.state.chipData.map((data) => {
return (
<Chip
label={data.label}
key={data.key}
onRequestDelete={this.handleRequestDelete(data)}
className={classes.chip}
/>
);
})}
</div>
);
}
Expand Down

0 comments on commit a88c6a1

Please sign in to comment.