commit
stringlengths 40
40
| old_file
stringlengths 4
150
| new_file
stringlengths 4
150
| old_contents
stringlengths 0
3.26k
| new_contents
stringlengths 1
4.43k
| subject
stringlengths 15
501
| message
stringlengths 15
4.06k
| lang
stringclasses 4
values | license
stringclasses 13
values | repos
stringlengths 5
91.5k
| diff
stringlengths 0
4.35k
|
---|---|---|---|---|---|---|---|---|---|---|
e66ae0aa87a0193c4cdee77408fe67bca0b87fd1 | src/common/Editor/Editor.jsx | src/common/Editor/Editor.jsx | import React from 'react';
import AceEditor from 'react-ace';
import 'brace/mode/python';
import 'brace/mode/javascript';
import 'brace/mode/ruby';
import 'brace/mode/golang';
import 'brace/mode/swift';
import 'brace/mode/php';
import 'brace/mode/json';
import 'brace/mode/html';
import 'brace/mode/django';
import 'brace/theme/tomorrow';
class Editor extends React.Component {
getStyles() {
const { width, height } = this.props;
return {
root: {
width,
height
}
};
}
render() {
const styles = this.getStyles();
const { style, editorName, ...other } = this.props;
return (
<AceEditor
id={editorName}
name={editorName}
ref={`editor-${editorName}`}
editorProps={{ $blockScrolling: 'Infinity' }}
style={{ ...styles.root, ...style }}
{...other}
/>
);
}
}
export default Editor;
| import React from 'react';
import AceEditor from 'react-ace';
import 'brace/mode/python';
import 'brace/mode/javascript';
import 'brace/mode/ruby';
import 'brace/mode/golang';
import 'brace/mode/swift';
import 'brace/mode/php';
import 'brace/mode/json';
import 'brace/mode/html';
import 'brace/mode/django';
import 'brace/theme/tomorrow';
class Editor extends React.Component {
getStyles() {
const { width, height } = this.props;
return {
root: {
width,
height
}
};
}
render() {
const styles = this.getStyles();
const { style, editorName, ...other } = this.props;
return (
<div data-e2e={other['data-e2e']}>
<AceEditor
id={editorName}
name={editorName}
ref={`editor-${editorName}`}
editorProps={{ $blockScrolling: 'Infinity' }}
style={{ ...styles.root, ...style }}
{...other}
/>
</div>
);
}
}
export default Editor;
| Add data-e2e to the editor | [DASH-2407] Add data-e2e to the editor
| JSX | mit | Syncano/syncano-dashboard,Syncano/syncano-dashboard,Syncano/syncano-dashboard | ---
+++
@@ -29,14 +29,16 @@
const { style, editorName, ...other } = this.props;
return (
- <AceEditor
- id={editorName}
- name={editorName}
- ref={`editor-${editorName}`}
- editorProps={{ $blockScrolling: 'Infinity' }}
- style={{ ...styles.root, ...style }}
- {...other}
- />
+ <div data-e2e={other['data-e2e']}>
+ <AceEditor
+ id={editorName}
+ name={editorName}
+ ref={`editor-${editorName}`}
+ editorProps={{ $blockScrolling: 'Infinity' }}
+ style={{ ...styles.root, ...style }}
+ {...other}
+ />
+ </div>
);
}
} |
7eb2f5b58a1c404ed7c3d78d5f8b386f6b075e64 | components/form/index.jsx | components/form/index.jsx | import Form from './Form';
import FormItem from './FormItem';
import ValueMixin from './ValueMixin';
Form.Item = FormItem;
Form.ValueMixin = ValueMixin;
export default Form;
| import Form from './Form';
import FormItem from './FormItem';
import ValueMixin from './ValueMixin';
import Input from '../input';
Form.Item = FormItem;
Form.ValueMixin = ValueMixin;
// 对于 import { Form, Input } from 'antd/lib/form/';
// 的方式做向下兼容
// https://github.com/ant-design/ant-design/pull/566
Form.Form = Form;
Form.Input = Input;
export default Form;
| Add support for degrade usage of form | Add support for degrade usage of form
| JSX | mit | hjin-me/ant-design,hjin-me/ant-design,ant-design/ant-design,waywardmonkeys/ant-design,mitchelldemler/ant-design,elevensky/ant-design,superRaytin/ant-design,RaoHai/ant-design,MarshallChen/ant-design,zhujun24/ant-design,ant-design/ant-design,liekkas/ant-design,MarshallChen/ant-design,vgeyi/ant-design,hotoo/ant-design,codering/ant-design,vgeyi/ant-design,hotoo/ant-design,ddcat1115/ant-design,zheeeng/ant-design,coderhaoxin/ant-design,zheeeng/ant-design,havefive/ant-design,sdgdsffdsfff/ant-design,vgeyi/ant-design,hotoo/ant-design,marswong/ant-design,zheeeng/ant-design,ian-cuc/dingtalkdoc,sdgdsffdsfff/ant-design,waywardmonkeys/ant-design,sdgdsffdsfff/ant-design,zhujun24/ant-design,havefive/ant-design,liekkas/ant-design,vgeyi/ant-design,coderhaoxin/ant-design,icaife/ant-design,codering/ant-design,superRaytin/ant-design,liekkas/ant-design,icaife/ant-design,codering/ant-design,hjin-me/ant-design,waywardmonkeys/ant-design,elevensky/ant-design,havefive/ant-design,ddcat1115/ant-design,ant-design/ant-design,havefive/ant-design,zhujun24/ant-design,ant-design/ant-design,RaoHai/ant-design,marswong/ant-design,zheeeng/ant-design,liekkas/ant-design,mitchelldemler/ant-design,mitchelldemler/ant-design,coderhaoxin/ant-design,marswong/ant-design,codering/ant-design,ian-cuc/dingtalkdoc,marswong/ant-design,RaoHai/ant-design,ian-cuc/dingtalkdoc,MarshallChen/ant-design,elevensky/ant-design,icaife/ant-design,hjin-me/ant-design,mitchelldemler/ant-design,elevensky/ant-design,RaoHai/ant-design,icaife/ant-design | ---
+++
@@ -1,7 +1,15 @@
import Form from './Form';
import FormItem from './FormItem';
import ValueMixin from './ValueMixin';
+import Input from '../input';
Form.Item = FormItem;
Form.ValueMixin = ValueMixin;
+
+// 对于 import { Form, Input } from 'antd/lib/form/';
+// 的方式做向下兼容
+// https://github.com/ant-design/ant-design/pull/566
+Form.Form = Form;
+Form.Input = Input;
+
export default Form; |
c44ee381e3edb841c06d97a55b4aab7ee565bd6f | shared/views/Story/Toolbar.jsx | shared/views/Story/Toolbar.jsx | import React from 'react';
import { connect } from 'redux/react';
import { bindActionCreators } from 'redux';
import FontSizeSelector from './FontSizeSelector';
import * as StoryActions from 'actions/StoryActions';
@connect(state => ({
editing: state.story.get('editing')
}))
export default class Toolbar extends React.Component {
handleAlignment = (e) => {
this.props.dispatch(
ParagraphActions.setAlignment(e.target.name)
);
}
handleLoad = () => {
StoryActions.populateStories()(this.props.dispatch);
this.props.dispatch(this.props.setLoading(true));
}
render() {
const style = {
display: this.props.editing ? 'block' : 'none'
};
return (
<div className='toolbar' style={style}>
<FontSizeSelector defaultSize={this.props.defaultFont.size} {...bindActionCreators(ParagraphActions, this.props.dispatch)}/>
<br />
<button className="btn" name="left" onClick={this.handleAlignment} >Left</button>
<button className="btn" name="center" onClick={this.handleAlignment} >Center</button>
<button className="btn" name="right" onClick={this.handleAlignment} >Right</button>
<br />
<button className="btn" name="load" onClick={this.handleLoad} >Load</button>
<button className="btn" name="save" onClick={this.props.handleSave}>Save</button>
</div>
);
}
}
| import React from 'react';
import { connect } from 'redux/react';
import { bindActionCreators } from 'redux';
import FontSizeSelector from './FontSizeSelector';
import * as StoryActions from 'actions/StoryActions';
@connect(state => ({
editing: state.story.get('editing')
}))
export default class Toolbar extends React.Component {
handleAlignment = (e) => {
}
handleLoad = () => {
StoryActions.populateStories()(this.props.dispatch);
this.props.dispatch(this.props.setLoading(true));
}
render() {
const style = {
display: this.props.editing ? 'block' : 'none'
};
return (
<div className='toolbar' style={style}>
<FontSizeSelector defaultSize={this.props.defaultFont.size} {...bindActionCreators(StoryActions, this.props.dispatch)}/>
<br />
<button className="btn" name="left" onClick={this.handleAlignment} >Left</button>
<button className="btn" name="center" onClick={this.handleAlignment} >Center</button>
<button className="btn" name="right" onClick={this.handleAlignment} >Right</button>
<br />
<button className="btn" name="load" onClick={this.handleLoad} >Load</button>
<button className="btn" name="save" onClick={this.props.handleSave}>Save</button>
</div>
);
}
}
| Remove last trace of ParagraphActions | Remove last trace of ParagraphActions
| JSX | apache-2.0 | checkraiser/chapters,bananaoomarang/chapters | ---
+++
@@ -10,9 +10,6 @@
export default class Toolbar extends React.Component {
handleAlignment = (e) => {
- this.props.dispatch(
- ParagraphActions.setAlignment(e.target.name)
- );
}
handleLoad = () => {
@@ -27,7 +24,7 @@
return (
<div className='toolbar' style={style}>
- <FontSizeSelector defaultSize={this.props.defaultFont.size} {...bindActionCreators(ParagraphActions, this.props.dispatch)}/>
+ <FontSizeSelector defaultSize={this.props.defaultFont.size} {...bindActionCreators(StoryActions, this.props.dispatch)}/>
<br />
|
12385407d37233e77e7f77fe0fbc01c462d71c65 | indico/web/client/js/react/util/Slot.jsx | indico/web/client/js/react/util/Slot.jsx | /* This file is part of Indico.
* Copyright (C) 2002 - 2018 European Organization for Nuclear Research (CERN).
*
* Indico is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Indico is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Indico; if not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import PropTypes from 'prop-types';
export default class Slot extends React.Component {
static propTypes = {
name: PropTypes.string
};
static defaultProps = {
name: 'content'
};
static split(children) {
if (children.every((e) => (React.isValidElement(e) && e.type.name === 'Slot'))) {
const result = {};
for (const child of children) {
result[child.props.name] = child.props.children;
}
return result;
} else {
return {
content: children
};
}
}
}
| /* This file is part of Indico.
* Copyright (C) 2002 - 2018 European Organization for Nuclear Research (CERN).
*
* Indico is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Indico is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Indico; if not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import PropTypes from 'prop-types';
export default class Slot extends React.Component {
static propTypes = {
name: PropTypes.string
};
static defaultProps = {
name: 'content'
};
static split(children) {
if (children.every((e) => (React.isValidElement(e) && e.type.name === 'Slot'))) {
const result = {};
React.Children.forEach(children, (child) => {
result[child.props.name] = child.props.children;
});
return result;
} else {
return {
content: children
};
}
}
}
| Use React.Children.forEach instead of for loop | Use React.Children.forEach instead of for loop
| JSX | mit | indico/indico,mvidalgarcia/indico,mic4ael/indico,pferreir/indico,pferreir/indico,DirkHoffmann/indico,ThiefMaster/indico,OmeGak/indico,OmeGak/indico,pferreir/indico,mvidalgarcia/indico,mvidalgarcia/indico,DirkHoffmann/indico,OmeGak/indico,pferreir/indico,indico/indico,mic4ael/indico,ThiefMaster/indico,mvidalgarcia/indico,ThiefMaster/indico,mic4ael/indico,DirkHoffmann/indico,OmeGak/indico,indico/indico,ThiefMaster/indico,DirkHoffmann/indico,indico/indico,mic4ael/indico | ---
+++
@@ -31,9 +31,9 @@
static split(children) {
if (children.every((e) => (React.isValidElement(e) && e.type.name === 'Slot'))) {
const result = {};
- for (const child of children) {
+ React.Children.forEach(children, (child) => {
result[child.props.name] = child.props.children;
- }
+ });
return result;
} else {
return { |
a09c5fe3596a0dbb4f4c8a1e3458cf138d602f99 | src/components/notes/NoteForm.jsx | src/components/notes/NoteForm.jsx | import React from 'react';
import './NoteForm.scss';
import noteRepository from '../../data/NoteRepository';
export default class NoteForm extends React.Component {
constructor(props) {
super(props);
this.state = {
title: '',
content: '',
};
}
// update state with data from form
handleChange(e) {
const { target: { name: key } } = e;
const newState = {};
newState[key] = e.target.value;
this.setState(newState)
}
// add new note to database, then reset state to initial value
createNote(e) {
e.preventDefault();
const { title, content } = this.state;
if (title.trim() || content.trim()) {
noteRepository.create({ title, content }, err => {
// TODO: inform user
if (err) throw err;
// reset state to initial values
this.setState({
title: '',
content: '',
});
});
}
}
render() {
return (
<form className="create-note" onSubmit={(e) => this.createNote(e)}>
<input
name="title"
value={this.state.title}
placeholder="Title"
onChange={(e) => this.handleChange(e)}
/>
<textarea
name="content"
value={this.state.content}
placeholder="Text goes here..."
rows={3}
onChange={(e) => this.handleChange(e)}
>
</textarea>
<button type="submit">+</button>
</form>
);
}
}
| import React from 'react';
import './NoteForm.scss';
import noteRepository from '../../data/NoteRepository';
// Class for note creation form
export default class NoteForm extends React.Component {
constructor(props) {
super(props);
this.state = {
title: '',
content: '',
};
}
/**
* Update state with data from form
*/
handleChange(e) {
const { target: { name: key } } = e;
const newState = {};
newState[key] = e.target.value;
this.setState(newState)
}
/**
* Add a new note to the database, then reset state
* @param {Object} e - Proxy object
*/
createNote(e) {
e.preventDefault();
const { title, content } = this.state;
if (title.trim() || content.trim()) {
noteRepository.create({ title, content }, err => {
// TODO: inform user
if (err) throw err;
// reset state to initial values
this.setState({
title: '',
content: '',
});
});
}
}
render() {
return (
<form className="create-note" onSubmit={(e) => this.createNote(e)}>
<input
name="title"
value={this.state.title}
placeholder="Title"
onChange={(e) => this.handleChange(e)}
/>
<textarea
name="content"
value={this.state.content}
placeholder="Text goes here..."
rows={3}
onChange={(e) => this.handleChange(e)}
>
</textarea>
<button type="submit">+</button>
</form>
);
}
}
| Update and add clarifying comments | Update and add clarifying comments
| JSX | mit | emyarod/refuge,emyarod/refuge | ---
+++
@@ -2,6 +2,7 @@
import './NoteForm.scss';
import noteRepository from '../../data/NoteRepository';
+// Class for note creation form
export default class NoteForm extends React.Component {
constructor(props) {
super(props);
@@ -11,7 +12,9 @@
};
}
- // update state with data from form
+ /**
+ * Update state with data from form
+ */
handleChange(e) {
const { target: { name: key } } = e;
const newState = {};
@@ -19,7 +22,10 @@
this.setState(newState)
}
- // add new note to database, then reset state to initial value
+ /**
+ * Add a new note to the database, then reset state
+ * @param {Object} e - Proxy object
+ */
createNote(e) {
e.preventDefault();
const { title, content } = this.state; |
0a0afed84b904045088437177952818bde22c49d | samples/react/ReactGrid/ReactApp/components/PeopleGrid.jsx | samples/react/ReactGrid/ReactApp/components/PeopleGrid.jsx | import React from 'react';
import Griddle from 'griddle-react';
import { CustomPager } from './CustomPager.jsx';
import { fakeData } from '../data/fakeData.js';
import { columnMeta } from '../data/columnMeta.jsx';
const resultsPerPage = 10;
const fakeDataWithAction = fakeData.map(data => Object.assign(data, {actions: ''}));
export class PeopleGrid extends React.Component {
render() {
var pageIndex = this.props.params ? (this.props.params.pageIndex || 1) - 1 : 0;
return (
<div>
<h1>People</h1>
<div id="table-area">
<Griddle results={fakeDataWithAction}
columns={columnMeta.map(x => x.columnName)}
columnMetadata={columnMeta}
resultsPerPage={resultsPerPage}
tableClassName="table"
useCustomPagerComponent="true"
customPagerComponent={CustomPager}
externalCurrentPage={pageIndex} />
</div>
</div>
);
}
}
| import React from 'react';
import Griddle from 'griddle-react';
import { CustomPager } from './CustomPager.jsx';
import { fakeData } from '../data/fakeData.js';
import { columnMeta } from '../data/columnMeta.jsx';
const resultsPerPage = 10;
// Griddle requires each row to have a property matching each column, even if you're not displaying
// any data from the row in that column
fakeData.forEach(row => { row.actions = ''; });
export class PeopleGrid extends React.Component {
render() {
var pageIndex = this.props.params ? (this.props.params.pageIndex || 1) - 1 : 0;
return (
<div>
<h1>People</h1>
<div id="table-area">
<Griddle results={fakeData}
columns={columnMeta.map(x => x.columnName)}
columnMetadata={columnMeta}
resultsPerPage={resultsPerPage}
tableClassName="table"
useCustomPagerComponent="true"
customPagerComponent={CustomPager}
externalCurrentPage={pageIndex} />
</div>
</div>
);
}
}
| Add comment about why the 'actions' property is being patched on | Add comment about why the 'actions' property is being patched on
| JSX | apache-2.0 | aspnet/AspNetCore,aspnet/AspNetCore,aspnet/AspNetCore,aspnet/AspNetCore,aspnet/AspNetCore,aspnet/AspNetCore,aspnet/AspNetCore,aspnet/AspNetCore,aspnet/AspNetCore | ---
+++
@@ -5,7 +5,9 @@
import { columnMeta } from '../data/columnMeta.jsx';
const resultsPerPage = 10;
-const fakeDataWithAction = fakeData.map(data => Object.assign(data, {actions: ''}));
+// Griddle requires each row to have a property matching each column, even if you're not displaying
+// any data from the row in that column
+fakeData.forEach(row => { row.actions = ''; });
export class PeopleGrid extends React.Component {
render() {
@@ -14,7 +16,7 @@
<div>
<h1>People</h1>
<div id="table-area">
- <Griddle results={fakeDataWithAction}
+ <Griddle results={fakeData}
columns={columnMeta.map(x => x.columnName)}
columnMetadata={columnMeta}
resultsPerPage={resultsPerPage} |
ad2187f1e3a319beaa4c684b2acaf42233dc41c1 | webapp/components/Collapsable.jsx | webapp/components/Collapsable.jsx | import React, {Component} from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import {Column, Row} from './ResultGrid';
export default class Collapsable extends Component {
static propTypes = {
children: PropTypes.node.isRequired,
collapsable: PropTypes.bool,
maxVisible: PropTypes.number
};
static defaultProps = {
collapsable: false,
maxVisible: 10
};
constructor(props, context) {
super(props, context);
this.state = {collapsed: props.collapsable};
}
render() {
let {children, maxVisible} = this.props;
let totalChildren = children.length;
let collapsed = this.state.collapsed;
let visibleChildren = totalChildren;
if (totalChildren <= maxVisible) {
collapsed = false;
} else if (collapsed) {
visibleChildren = Math.max(5, maxVisible);
children = children.slice(0, visibleChildren);
}
return (
<div>
{children}
{collapsed && (
<ExpandLink onClick={() => this.setState({collapsed: false})}>
<Row style={{color: 'inherit'}}>
<Column>Show {totalChildren - visibleChildren} other item(s)</Column>
</Row>
</ExpandLink>
)}
</div>
);
}
}
const ExpandLink = styled.a`
display: block;
cursor: pointer;
color: #7b6be6;
&:hover {
background-color: #f0eff5;
}
`;
| import React, {Component} from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import {Column, Row} from './ResultGrid';
export default class Collapsable extends Component {
static propTypes = {
children: PropTypes.node.isRequired,
collapsable: PropTypes.bool,
maxVisible: PropTypes.number
};
static defaultProps = {
collapsable: false,
maxVisible: 10
};
constructor(props, context) {
super(props, context);
this.state = {collapsed: props.collapsable};
}
render() {
let {children, maxVisible} = this.props;
let totalChildren = children.length;
let collapsed = this.state.collapsed;
let visibleChildren = totalChildren;
if (totalChildren <= maxVisible) {
collapsed = false;
} else if (collapsed) {
visibleChildren = maxVisible;
children = children.slice(0, visibleChildren);
}
return (
<div>
{children}
{collapsed && (
<ExpandLink onClick={() => this.setState({collapsed: false})}>
<Row style={{color: 'inherit'}}>
<Column>Show {totalChildren - visibleChildren} other item(s)</Column>
</Row>
</ExpandLink>
)}
</div>
);
}
}
const ExpandLink = styled.a`
display: block;
cursor: pointer;
color: #7b6be6;
&:hover {
background-color: #f0eff5;
}
`;
| Remove hardcoded minimum on maxVisible | ref: Remove hardcoded minimum on maxVisible
| JSX | apache-2.0 | getsentry/zeus,getsentry/zeus,getsentry/zeus,getsentry/zeus | ---
+++
@@ -29,7 +29,7 @@
if (totalChildren <= maxVisible) {
collapsed = false;
} else if (collapsed) {
- visibleChildren = Math.max(5, maxVisible);
+ visibleChildren = maxVisible;
children = children.slice(0, visibleChildren);
}
|
3b2c1a73f5b990ba7b705a511ca10afc273a9512 | src/components/app.jsx | src/components/app.jsx | import React, { Component } from 'react';
const ENTER = 13;
export default function appFactory() {
return class App extends Component {
constructor(props) {
super(props);
this.state = {
todoInput: '',
todos: []
};
}
render() {
return <div className="todoapp">
<header className="header">
<h1>todos</h1>
<input type="text" className="new-todo" autoFocus
value={this.state.todoInput}
placeholder="What needs to be done?"
onChange={this.onTodoInputChange.bind(this)}
onKeyDown={e => {
if (e.keyCode === ENTER) {
this.onNewTodo(e.target.value);
}
}}
/>
</header>
<section className="main">
<ul className="todo-list">
{this.state.todos.map((todo, index) =>
<li className="todo" key={index}>
<div className="view">
<label>{todo.title}</label>
</div>
</li>
)}
</ul>
</section>
</div>;
}
onTodoInputChange(e) {
this.setState({
todoInput: e.target.value
});
}
onNewTodo(title) {
this.setState({
todos: this.state.todos.concat({ title })
});
}
};
}
| import React, { Component } from 'react';
const ENTER = 13;
export default function appFactory() {
return class App extends Component {
constructor(props) {
super(props);
this.state = {
todoInput: '',
todos: []
};
}
render() {
return <div className="todoapp">
<header className="header">
<h1>todos</h1>
<input type="text" className="new-todo" autoFocus
value={this.state.todoInput}
placeholder="What needs to be done?"
onChange={this.onTodoInputChange.bind(this)}
onKeyDown={e => {
if (e.keyCode === ENTER) {
this.onNewTodo(e.target.value);
}
}}
/>
</header>
{this.state.todos.length ? this._renderTodos() : null}
</div>;
}
_renderTodos() {
return <section className="main">
<ul className="todo-list">
{this.state.todos.map((todo, index) =>
<li className="todo" key={index}>
<div className="view">
<label>{todo.title}</label>
</div>
</li>
)}
</ul>
</section>;
}
onTodoInputChange(e) {
this.setState({
todoInput: e.target.value
});
}
onNewTodo(title) {
this.setState({
todos: this.state.todos.concat({ title })
});
}
};
}
| Hide the main section when there's no todos | Hide the main section when there's no todos
Didn't need a unit test here since the acceptance test is enough.
| JSX | mit | NiGhTTraX/react-test-buffet,NiGhTTraX/react-test-buffet,NiGhTTraX/react-test-buffet | ---
+++
@@ -29,18 +29,22 @@
}}
/>
</header>
- <section className="main">
- <ul className="todo-list">
- {this.state.todos.map((todo, index) =>
- <li className="todo" key={index}>
- <div className="view">
- <label>{todo.title}</label>
- </div>
- </li>
- )}
- </ul>
- </section>
+ {this.state.todos.length ? this._renderTodos() : null}
</div>;
+ }
+
+ _renderTodos() {
+ return <section className="main">
+ <ul className="todo-list">
+ {this.state.todos.map((todo, index) =>
+ <li className="todo" key={index}>
+ <div className="view">
+ <label>{todo.title}</label>
+ </div>
+ </li>
+ )}
+ </ul>
+ </section>;
}
onTodoInputChange(e) { |
14969a8c0449491091ddbebad71927e857336f56 | src/browser/components/HoveringURL.jsx | src/browser/components/HoveringURL.jsx | const React = require('react');
const divStyle = {
backgroundColor: 'whitesmoke',
position: 'absolute',
bottom: 0,
paddingLeft: 4,
paddingRight: 16,
borderTopRightRadius: 4
};
const spanStyle = {
color: 'gray'
};
class HoveringURL extends React.Component {
render() {
return (
<div style={divStyle}>
<span style={spanStyle}>
{this.props.targetURL}
</span>
</div>
);
}
}
HoveringURL.propTypes = {
targetURL: React.PropTypes.string
};
module.exports = HoveringURL;
| const React = require('react');
const style = {
color: 'gray',
backgroundColor: 'whitesmoke',
maxWidth: '95%',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
position: 'absolute',
bottom: 0,
paddingLeft: 4,
paddingRight: 16,
paddingTop: 2,
paddingBottom: 2,
borderTopRightRadius: 4,
borderTop: 'solid thin lightgray',
borderRight: 'solid thin lightgray'
};
class HoveringURL extends React.Component {
render() {
return (
<div style={style}>
{this.props.targetURL}
</div>
);
}
}
HoveringURL.propTypes = {
targetURL: React.PropTypes.string
};
module.exports = HoveringURL;
| Improve visility of hevering URL | Improve visility of hevering URL
- Add top and bottom padding
- Add border lines
- Truncate long URL using ellipsis
| JSX | apache-2.0 | mattermost/desktop,yuya-oc/desktop,yuya-oc/desktop,jnugh/desktop,yuya-oc/electron-mattermost,mattermost/desktop,mattermost/desktop,mattermost/desktop,mattermost/desktop,yuya-oc/desktop,yuya-oc/electron-mattermost,jnugh/desktop,jnugh/desktop,yuya-oc/electron-mattermost | ---
+++
@@ -1,25 +1,28 @@
const React = require('react');
-const divStyle = {
+const style = {
+ color: 'gray',
backgroundColor: 'whitesmoke',
+ maxWidth: '95%',
+ whiteSpace: 'nowrap',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
position: 'absolute',
bottom: 0,
paddingLeft: 4,
paddingRight: 16,
- borderTopRightRadius: 4
-};
-
-const spanStyle = {
- color: 'gray'
+ paddingTop: 2,
+ paddingBottom: 2,
+ borderTopRightRadius: 4,
+ borderTop: 'solid thin lightgray',
+ borderRight: 'solid thin lightgray'
};
class HoveringURL extends React.Component {
render() {
return (
- <div style={divStyle}>
- <span style={spanStyle}>
- {this.props.targetURL}
- </span>
+ <div style={style}>
+ {this.props.targetURL}
</div>
);
} |
a6c60aedf06197823b5b3d7b34ffb285c4f809be | client/src/containers/UserInstrument.jsx | client/src/containers/UserInstrument.jsx | import React, { Component } from 'react';
import Piano from './Piano';
class UserInstrument extends Component {
render() {
if (this.props.inst==="piano") {
console.log('you selected piano');
return (
<div>
<Piano id="userPiano" />
</div>
);
} else {
return (
<div>
<img id="userDrums" src="../../../style/drums.png" />
</div>
);
}
}
}
export default UserInstrument;
| import React, { Component } from 'react';
// import Piano from './Piano';
class UserInstrument extends Component {
render() {
if (this.props.inst==="piano") {
console.log('you selected piano');
return (
<div>
// <Piano id="userPiano" />
</div>
);
} else {
return (
<div>
<img id="userDrums" src="../../../style/drums.png" />
</div>
);
}
}
}
export default UserInstrument;
| Fix code that was not in pull request | Fix code that was not in pull request
| JSX | mit | NerdDiffer/reprise,NerdDiffer/reprise,NerdDiffer/reprise | ---
+++
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
-import Piano from './Piano';
+// import Piano from './Piano';
class UserInstrument extends Component {
@@ -8,7 +8,7 @@
console.log('you selected piano');
return (
<div>
- <Piano id="userPiano" />
+ // <Piano id="userPiano" />
</div>
);
} else { |
d02a704c9b013eae6c10d252a3c364de06076fd5 | lib/components/groceries/GroceriesListJson.jsx | lib/components/groceries/GroceriesListJson.jsx | import React, { PropTypes } from 'react';
export default class GroceriesListJson extends React.Component {
static propTypes = {
groceries: PropTypes.object.isRequired,
}
render() {
const { groceries } = this.props;
const groceriesJSON = JSON.stringify(
groceries.toJS().map((item) => item.title),
);
return (
<div>
<input
type="hidden"
value={groceriesJSON}
/>
</div>
);
}
}
| import React, { PropTypes } from 'react';
export default class GroceriesListJson extends React.Component {
static propTypes = {
groceries: PropTypes.object.isRequired,
}
render() {
const { groceries } = this.props;
const groceriesJSON = JSON.stringify(
groceries.toJS().map((item) => item.title),
);
return (
<div>
<input
type="hidden"
name="items"
value={groceriesJSON}
/>
</div>
);
}
}
| Add name attribute to input | Add name attribute to input
| JSX | mit | Zapix/react-groceries,Zapix/react-groceries,Zapix/react-groceries | ---
+++
@@ -14,6 +14,7 @@
<div>
<input
type="hidden"
+ name="items"
value={groceriesJSON}
/>
</div> |
edd1543700f5e1b6d4f9d0453b3dc15c6805ead0 | app/scripts/components/login.jsx | app/scripts/components/login.jsx | import React from 'react';
import PropTypes from 'prop-types';
import { Redirect } from 'react-router-dom';
import auth from '../util/auth.js';
export default class Login extends React.Component {
constructor(props) {
super(props);
this.state = {
redirectToReferrer: false,
error: false,
};
}
handleSubmit(event) {
event.preventDefault();
auth.login(this.username.value, this.password.value, loggedIn =>
this.setState({
redirectToReferrer: loggedIn,
error: !loggedIn,
})
);
}
render() {
const { from } = this.props.location.state || { from: { pathname: '/' } };
return this.state.redirectToReferrer ? (
<Redirect to={from} />
) : (
<div className="wrapper">
<form ref={form => (this.form = form)} onSubmit={this.handleSubmit.bind(this)}>
<input type="text" ref={input => (this.username = input)} placeholder="username" autoComplete="off" />
<input type="password" ref={input => (this.password = input)} placeholder="********" />
<input type="submit" value="login" />
{this.state.error && <p className="text error">Incorrect username or password...</p>}
</form>
</div>
);
}
}
Login.propTypes = {
location: PropTypes.object.isRequired,
};
| import React from 'react';
import PropTypes from 'prop-types';
import { Redirect } from 'react-router-dom';
import auth from '../util/auth.js';
export default class Login extends React.Component {
constructor(props) {
super(props);
this.state = {
redirectToReferrer: false,
error: false,
};
}
handleSubmit(event) {
event.preventDefault();
auth.login(this.username.value, this.password.value, loggedIn =>
this.setState({
redirectToReferrer: loggedIn,
error: !loggedIn,
})
);
}
render() {
const { from } = this.props.location.state || { from: { pathname: '/' } };
return this.state.redirectToReferrer ? (
<Redirect to={from} />
) : (
<div className="wrapper text">
{this.props.location.state ? <div className="mbl">Sorry, you need to log in to view this page.</div> : null}
<form onSubmit={this.handleSubmit.bind(this)}>
<input type="text" ref={input => (this.username = input)} placeholder="username" autoComplete="off" />
<input type="password" ref={input => (this.password = input)} placeholder="********" />
<input type="submit" value="login" />
{this.state.error && <p className="text error">Incorrect username or password...</p>}
</form>
</div>
);
}
}
Login.propTypes = {
location: PropTypes.object.isRequired,
};
| Add warning when redirected from restricted page | Add warning when redirected from restricted page
| JSX | mit | benct/tomlin-web,benct/tomlin-web | ---
+++
@@ -30,8 +30,9 @@
return this.state.redirectToReferrer ? (
<Redirect to={from} />
) : (
- <div className="wrapper">
- <form ref={form => (this.form = form)} onSubmit={this.handleSubmit.bind(this)}>
+ <div className="wrapper text">
+ {this.props.location.state ? <div className="mbl">Sorry, you need to log in to view this page.</div> : null}
+ <form onSubmit={this.handleSubmit.bind(this)}>
<input type="text" ref={input => (this.username = input)} placeholder="username" autoComplete="off" />
<input type="password" ref={input => (this.password = input)} placeholder="********" />
<input type="submit" value="login" /> |
f3466fc7c40ef5927f7074c9375732bdff8c46f9 | beavy/jsbeavy/views/HomeView.jsx | beavy/jsbeavy/views/HomeView.jsx | import React from 'react';
import { connect } from 'react-redux';
// We define mapDispatchToProps where we'd normally use the @connect
// decorator so the data requirements are clear upfront, but then
// export the decorated component after the main class definition so
// the component can be tested w/ and w/o being connected.
// See: http://rackt.github.io/redux/docs/recipes/WritingTests.html
const mapDispatchToProps = (state) => ({
counter : state.counter
});
export class HomeView extends React.Component {
static propTypes = {
dispatch : React.PropTypes.func,
counter : React.PropTypes.number
}
constructor () {
super();
}
// normally you'd import an action creator, but I don't want to create
// a file that you're just going to delete anyways!
_increment () {
this.props.dispatch({ type : 'COUNTER_INCREMENT' });
}
render () {
return (
<div className='container text-center'>
<h1>Wecome to Beavy!</h1>
</div>
);
}
}
export default connect(mapDispatchToProps)(HomeView);
| import React from 'react';
import { connect } from 'react-redux';
// We define mapDispatchToProps where we'd normally use the @connect
// decorator so the data requirements are clear upfront, but then
// export the decorated component after the main class definition so
// the component can be tested w/ and w/o being connected.
// See: http://rackt.github.io/redux/docs/recipes/WritingTests.html
const mapDispatchToProps = (state) => ({
counter : state.counter
});
export class HomeView extends React.Component {
static propTypes = {
dispatch : React.PropTypes.func,
counter : React.PropTypes.number
}
constructor () {
super();
}
// normally you'd import an action creator, but I don't want to create
// a file that you're just going to delete anyways!
_increment () {
this.props.dispatch({ type : 'COUNTER_INCREMENT' });
}
render () {
return (
<div className='container text-center'>
<img src="http://beavy.xyz/logos/logo.svg" alt="beavy logo" width="150" />
<h1>Wecome to Beavy!</h1>
<p>
Please take a look at the <a href="https://beavyhq.gitbooks.io/beavy-documentation/content/" target="_blank">documentation</a>.
</p>
</div>
);
}
}
export default connect(mapDispatchToProps)(HomeView);
| Add logo and link to docs | Add logo and link to docs
| JSX | mpl-2.0 | beavyHQ/beavy,beavyHQ/beavy,beavyHQ/beavy,beavyHQ/beavy | ---
+++
@@ -28,7 +28,11 @@
render () {
return (
<div className='container text-center'>
+ <img src="http://beavy.xyz/logos/logo.svg" alt="beavy logo" width="150" />
<h1>Wecome to Beavy!</h1>
+ <p>
+ Please take a look at the <a href="https://beavyhq.gitbooks.io/beavy-documentation/content/" target="_blank">documentation</a>.
+ </p>
</div>
);
} |
8c8c59a88312b596bf0f9b51959c42276fb4b6c6 | app/layout/site-subnav.jsx | app/layout/site-subnav.jsx | import React from 'react';
import ExpandableMenu from './expandable-menu';
class SiteSubnav extends React.Component {
trigger() {
return (
<span
className="site-nav__link"
activeClassName="site-nav__link--active"
title="News"
aria-label="News"
>
News
</span>
);
}
render() {
if (this.props.isMobile) {
return this.props.children;
} else {
return (
<ExpandableMenu
className="site-nav__modal"
trigger={this.trigger()}
>
{this.props.children}
</ExpandableMenu>
);
}
}
}
SiteSubnav.propTypes = {
isMobile: React.PropTypes.bool,
children: React.PropTypes.node
};
export default SiteSubnav;
| import React from 'react';
import ExpandableMenu from './expandable-menu';
class SiteSubnav extends React.Component {
render() {
if (this.props.isMobile) {
return this.props.children;
} else {
return (
<ExpandableMenu
className="site-nav__modal"
trigger={
<span
className="site-nav__link"
activeClassName="site-nav__link--active"
>
News
</span>
}
>
{this.props.children}
</ExpandableMenu>
);
}
}
}
SiteSubnav.propTypes = {
isMobile: React.PropTypes.bool,
children: React.PropTypes.node
};
export default SiteSubnav;
| Tidy up News button HTML Removes unnecessary title and label attributes. | Tidy up News button HTML
Removes unnecessary title and label attributes.
| JSX | apache-2.0 | zooniverse/Panoptes-Front-End,amyrebecca/Panoptes-Front-End,amyrebecca/Panoptes-Front-End,amyrebecca/Panoptes-Front-End,jelliotartz/Panoptes-Front-End,jelliotartz/Panoptes-Front-End,jelliotartz/Panoptes-Front-End | ---
+++
@@ -2,19 +2,6 @@
import ExpandableMenu from './expandable-menu';
class SiteSubnav extends React.Component {
-
- trigger() {
- return (
- <span
- className="site-nav__link"
- activeClassName="site-nav__link--active"
- title="News"
- aria-label="News"
- >
- News
- </span>
- );
- }
render() {
if (this.props.isMobile) {
@@ -23,7 +10,14 @@
return (
<ExpandableMenu
className="site-nav__modal"
- trigger={this.trigger()}
+ trigger={
+ <span
+ className="site-nav__link"
+ activeClassName="site-nav__link--active"
+ >
+ News
+ </span>
+ }
>
{this.props.children}
</ExpandableMenu> |
53763e7b2d12184fd4040e2c3468d656b157c851 | src/client/components/Affinity.jsx | src/client/components/Affinity.jsx | import React from 'react';
import {ImageItem} from './ImageItem.jsx';
// import mapObject from 'lodash.map';
export class Affinity extends React.Component {
render() {
const listItems = this.props.imageList.map(({url, x, y, maxWidth, maxHeight, dimensions}) => {
const wscale = maxWidth / dimensions.width;
const hscale = maxHeight / dimensions.height;
const scale = Math.min(wscale, hscale);
const w = scale * dimensions.width;
const h = scale * dimensions.height;
const props = {
url,
x: x,
y: y,
width: w,
height: h,
key: url
};
return (
<ImageItem {...props} />
);
});
return (<div>{listItems}</div>);
}
}
Affinity.propTypes = {
imageList: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
};
| import React from 'react';
import {ImageItem} from './ImageItem.jsx';
// import mapObject from 'lodash.map';
export class Affinity extends React.Component {
constructor(props) {
super(props);
this.state = props;
}
render() {
const listItems = this.state.imageList.map(({url, x, y, maxWidth, maxHeight, dimensions}) => {
const wscale = maxWidth / dimensions.width;
const hscale = maxHeight / dimensions.height;
const scale = Math.min(wscale, hscale);
const w = scale * dimensions.width;
const h = scale * dimensions.height;
const props = {
url,
x: x,
y: y,
width: w,
height: h,
key: url,
};
return (
<ImageItem {...props} />
);
});
return (<div>{listItems}</div>);
}
}
Affinity.propTypes = {
imageList: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
};
| Move top-level Props into State | Move top-level Props into State
Setting the stage for changing state dynamically.
| JSX | mit | mearns/image-affinity,mearns/image-affinity | ---
+++
@@ -3,8 +3,14 @@
// import mapObject from 'lodash.map';
export class Affinity extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = props;
+ }
+
render() {
- const listItems = this.props.imageList.map(({url, x, y, maxWidth, maxHeight, dimensions}) => {
+ const listItems = this.state.imageList.map(({url, x, y, maxWidth, maxHeight, dimensions}) => {
const wscale = maxWidth / dimensions.width;
const hscale = maxHeight / dimensions.height;
const scale = Math.min(wscale, hscale);
@@ -16,7 +22,7 @@
y: y,
width: w,
height: h,
- key: url
+ key: url,
};
return (
<ImageItem {...props} /> |
08e8c11f66812a19890fea30d7cb54ca1a3a568e | client/modules/core/components/poll.jsx | client/modules/core/components/poll.jsx | import React, { PropTypes } from 'react';
import { ButtonCircle } from 'rebass';
import { partial } from 'partial-application';
import Load from 'shingon-load-jss';
const Poll = ({poll, deletePoll}) => (
<li
className={classes.list}
>
<a
href={`/polls/${poll._id}`}
className={classes.link}
>{poll.question}</a>
{ poll.isOwner() && (
<ButtonCircle
title="Delete"
style={{float: 'right'}}
backgroundColor="error"
onClick={partial(deletePoll, poll._id)}
>
×
</ButtonCircle>
) }
</li>
);
Poll.propTypes = {
poll: PropTypes.object
};
const styles = {
list: {
position: 'relative',
listStyle: 'none',
padding: 15,
borderBottom: '#eee solid 1px'
},
link: {
textDecoration: 'none',
color: '#7700ff',
},
};
const classes = Load(styles);
export default Poll;
| import React, { PropTypes } from 'react';
import { ButtonCircle } from 'rebass';
import { partial } from 'partial-application';
import Load from 'shingon-load-jss';
const Poll = ({poll, deletePoll}) => (
<li
className={classes.list}
>
<a
href={`/polls/${poll._id}`}
className={classes.link}
>{poll.question}</a>
{ poll.isOwner() && (
<ButtonCircle
title="Delete"
style={{float: 'right'}}
backgroundColor="error"
onClick={partial(deletePoll, poll._id)}
>
×
</ButtonCircle>
) }
</li>
);
Poll.propTypes = {
poll: PropTypes.object,
deletePoll: PropTypes.func
};
const styles = {
list: {
position: 'relative',
listStyle: 'none',
padding: 15,
borderBottom: '#eee solid 1px'
},
link: {
textDecoration: 'none',
color: '#7700ff',
},
};
const classes = Load(styles);
export default Poll;
| Add proptype for deletePoll to Poll component | Add proptype for deletePoll to Poll component
| JSX | mit | thancock20/voting-app,thancock20/voting-app | ---
+++
@@ -24,7 +24,8 @@
</li>
);
Poll.propTypes = {
- poll: PropTypes.object
+ poll: PropTypes.object,
+ deletePoll: PropTypes.func
};
const styles = { |
d0aa115084abede78701c318a80d7f4207991077 | src/sentry/static/sentry/app/components/timeSince.jsx | src/sentry/static/sentry/app/components/timeSince.jsx | var React = require("react");
var moment = require("moment");
var TimeSince = React.createClass({
propTypes: {
date: React.PropTypes.any.isRequired
},
componentDidMount() {
var delay = 2600;
this.ticker = setInterval(this.ensureValidity, delay);
},
componentWillUnmount() {
if (this.ticker) {
clearInterval(this.ticker);
this.ticker = null;
}
},
ensureValidity() {
// TODO(dcramer): this should ensure we actually *need* to update the value
this.forceUpdate();
},
shouldComponentUpdate(nextProps, nextState) {
return this.props.date !== nextProps.date;
},
render() {
var date = this.props.date;
if (typeof date === "string" || typeof date === "number") {
date = new Date(date);
}
return (
<time>{moment.utc(date).fromNow()}</time>
);
}
});
module.exports = TimeSince;
| var React = require("react");
var moment = require("moment");
var TimeSince = React.createClass({
propTypes: {
date: React.PropTypes.any.isRequired,
suffix: React.PropTypes.string
},
getDefaultProps() {
return {
suffix: 'ago'
};
},
componentDidMount() {
var delay = 2600;
this.ticker = setInterval(this.ensureValidity, delay);
},
componentWillUnmount() {
if (this.ticker) {
clearInterval(this.ticker);
this.ticker = null;
}
},
ensureValidity() {
// TODO(dcramer): this should ensure we actually *need* to update the value
this.forceUpdate();
},
shouldComponentUpdate(nextProps, nextState) {
return this.props.date !== nextProps.date;
},
render() {
var date = this.props.date;
if (typeof date === "string" || typeof date === "number") {
date = new Date(date);
}
return (
<time>{moment.utc(date).fromNow(true)} {this.props.suffix || ''}</time>
);
}
});
module.exports = TimeSince;
| Add suffix prop to TimeSince | Add suffix prop to TimeSince
| JSX | bsd-3-clause | ifduyue/sentry,zenefits/sentry,korealerts1/sentry,hongliang5623/sentry,looker/sentry,fuziontech/sentry,zenefits/sentry,kevinlondon/sentry,hongliang5623/sentry,BuildingLink/sentry,fuziontech/sentry,daevaorn/sentry,gencer/sentry,beeftornado/sentry,mvaled/sentry,alexm92/sentry,looker/sentry,fotinakis/sentry,JamesMura/sentry,JackDanger/sentry,gencer/sentry,mvaled/sentry,hongliang5623/sentry,nicholasserra/sentry,BuildingLink/sentry,daevaorn/sentry,BayanGroup/sentry,daevaorn/sentry,fotinakis/sentry,BayanGroup/sentry,songyi199111/sentry,felixbuenemann/sentry,daevaorn/sentry,kevinlondon/sentry,felixbuenemann/sentry,korealerts1/sentry,looker/sentry,looker/sentry,JamesMura/sentry,fuziontech/sentry,zenefits/sentry,Kryz/sentry,wong2/sentry,JackDanger/sentry,jean/sentry,songyi199111/sentry,ngonzalvez/sentry,Natim/sentry,ifduyue/sentry,ngonzalvez/sentry,nicholasserra/sentry,BayanGroup/sentry,Kryz/sentry,fotinakis/sentry,beeftornado/sentry,looker/sentry,gencer/sentry,zenefits/sentry,wong2/sentry,nicholasserra/sentry,zenefits/sentry,mitsuhiko/sentry,imankulov/sentry,JamesMura/sentry,mitsuhiko/sentry,mvaled/sentry,Natim/sentry,Natim/sentry,jean/sentry,alexm92/sentry,ifduyue/sentry,mvaled/sentry,jean/sentry,korealerts1/sentry,kevinlondon/sentry,imankulov/sentry,ifduyue/sentry,imankulov/sentry,JackDanger/sentry,alexm92/sentry,ifduyue/sentry,BuildingLink/sentry,gencer/sentry,ngonzalvez/sentry,JamesMura/sentry,beeftornado/sentry,JamesMura/sentry,jean/sentry,mvaled/sentry,mvaled/sentry,BuildingLink/sentry,felixbuenemann/sentry,fotinakis/sentry,wong2/sentry,BuildingLink/sentry,jean/sentry,songyi199111/sentry,gencer/sentry,Kryz/sentry | ---
+++
@@ -3,7 +3,14 @@
var TimeSince = React.createClass({
propTypes: {
- date: React.PropTypes.any.isRequired
+ date: React.PropTypes.any.isRequired,
+ suffix: React.PropTypes.string
+ },
+
+ getDefaultProps() {
+ return {
+ suffix: 'ago'
+ };
},
componentDidMount() {
@@ -36,7 +43,7 @@
}
return (
- <time>{moment.utc(date).fromNow()}</time>
+ <time>{moment.utc(date).fromNow(true)} {this.props.suffix || ''}</time>
);
}
}); |
8beb6851fcd734d474e61f6b12c0936dc22f0516 | examples/clock/src/App.jsx | examples/clock/src/App.jsx | import React, { Component } from 'react'
import moment from 'moment'
import { view, store } from 'react-easy-state'
class App extends Component {
// create a local
clock = store({
id: setInterval(() => this.setTime(), 1000),
time: moment()
.utc()
.format('hh:mm:ss A')
});
// the clock store can be manipulated as a plain JS object
setTime () {
this.clock.time = moment()
.utc()
.format('hh:mm:ss A')
}
// clean up the timer before the component is unmounted
componentWillUnmount () {
clearInterval(this.clock.id)
}
// render is automatically triggered whenever this.clock.time changes
render () {
return <div>{this.clock.time}</div>
}
}
// wrap the component with view() before exporting it
export default view(App)
| import React, { Component } from 'react'
import moment from 'moment'
import { view, store } from 'react-easy-state'
class App extends Component {
// create a local store
clock = store({
id: setInterval(() => this.setTime(), 1000),
time: moment()
.utc()
.format('hh:mm:ss A')
});
// the clock store can be manipulated as a plain JS object
setTime () {
this.clock.time = moment()
.utc()
.format('hh:mm:ss A')
}
// clean up the timer before the component is unmounted
componentWillUnmount () {
clearInterval(this.clock.id)
}
// render is automatically triggered whenever this.clock.time changes
render () {
return <div>{this.clock.time}</div>
}
}
// wrap the component with view() before exporting it
export default view(App)
| Fix a comment typo on the clock example | Fix a comment typo on the clock example | JSX | mit | solkimicreb/react-easy-state | ---
+++
@@ -3,7 +3,7 @@
import { view, store } from 'react-easy-state'
class App extends Component {
- // create a local
+ // create a local store
clock = store({
id: setInterval(() => this.setTime(), 1000),
time: moment() |
94e790f0cc6356f28bee7f1e8b0aee1ddf84397d | js/Sidebar.jsx | js/Sidebar.jsx | import React, { Component, PropTypes } from 'react';
import LeftNav from 'material-ui/lib/left-nav';
import RaisedButton from 'material-ui/lib/raised-button';
import FlatButton from 'material-ui/lib/flat-button';
import styles from '../css/Sidebar.css';
export class Sidebar extends React.Component {
static propTypes = {
onClick: PropTypes.func,
componentList: PropTypes.object,
activeComponent: PropTypes.string,
}
constructor(props) {
super(props);
this.state = { open: false };
}
getComp(comp, i) {
return (
<div
key={i}
onClick={this.props.onClick.bind(null, comp)}
className={(this.props.activeComponent === comp) ? styles.active : ''}
>
{comp}
</div>
);
}
handleToggle = () => { this.setState({ open: !this.state.open }) };
render() {
return (
<div>
<RaisedButton label="Open Sidebar" onClick={this.handleToggle} />
<LeftNav open={this.state.open}>
<div id="sidebar" className={styles.sidebar} >
{Object.keys(this.props.componentList).map((component, i) => this.getComp(component, i))}
<span className={styles.close}>
<FlatButton label="Close Sidebar" onClick={this.handleToggle} />
</span>
</div>
</LeftNav>
</div>
);
}
}
| import React, { Component, PropTypes } from 'react';
import LeftNav from 'material-ui/lib/left-nav';
import RaisedButton from 'material-ui/lib/raised-button';
import FlatButton from 'material-ui/lib/flat-button';
import styles from '../css/Sidebar.css';
export class Sidebar extends React.Component {
static propTypes = {
onClick: PropTypes.func,
componentList: PropTypes.object,
activeComponent: PropTypes.string,
}
constructor(props) {
super(props);
this.state = { open: true };
}
getComp(comp, i) {
return (
<div
key={i}
onClick={this.props.onClick.bind(null, comp)}
className={(this.props.activeComponent === comp) ? styles.active : ''}
>
{comp}
</div>
);
}
handleToggle = () => { this.setState({ open: !this.state.open }) };
render() {
return (
<div>
<RaisedButton label="Open Sidebar" onClick={this.handleToggle} />
<LeftNav open={this.state.open}>
<div id="sidebar" className={styles.sidebar} >
{Object.keys(this.props.componentList).map((component, i) => this.getComp(component, i))}
<span className={styles.close}>
<FlatButton label="Close Sidebar" onClick={this.handleToggle} />
</span>
</div>
</LeftNav>
</div>
);
}
}
| Change default state of sidebar | Change default state of sidebar
| JSX | mit | michaelghinrichs/coding-math,michaelghinrichs/coding-math | ---
+++
@@ -14,7 +14,7 @@
constructor(props) {
super(props);
- this.state = { open: false };
+ this.state = { open: true };
}
getComp(comp, i) { |
8ae76006685b7dac766a6b4dfc0b95294a2aaab5 | src/components/includes/SiteFooter.jsx | src/components/includes/SiteFooter.jsx | import React from 'react';
const currentYear = new Date().getFullYear()
function SiteFooter(props) {
return (
<footer id="bottom" className="page-micro fine-print">
<ul className="list-inline--delimited">
<li>Copyright {currentYear} David Minnerly</li>
<li><a href="https://github.com/vocksel/my-website">Website Source</a></li>
<li>Background from <a href="http://ommwriter.com">OmmWriter</a></li>
</ul>
</footer>
)
}
export default SiteFooter;
| import React from 'react';
const currentYear = new Date().getFullYear()
function SiteFooter(props) {
return (
<footer id="bottom" className="page-micro fine-print">
<ul className="list-inline--delimited">
<li>© {currentYear} David Minnerly</li>
<li><a href="https://github.com/vocksel/my-website">Website Source</a></li>
<li>Background from <a href="http://ommwriter.com">OmmWriter</a></li>
</ul>
</footer>
)
}
export default SiteFooter;
| Change "Copyright" to the copyright symbol | Change "Copyright" to the copyright symbol
This was an accidental change. The copyright symbol is what we were using before.
| JSX | mit | VoxelDavid/voxeldavid-website,vocksel/my-website,VoxelDavid/voxeldavid-website,vocksel/my-website | ---
+++
@@ -6,7 +6,7 @@
return (
<footer id="bottom" className="page-micro fine-print">
<ul className="list-inline--delimited">
- <li>Copyright {currentYear} David Minnerly</li>
+ <li>© {currentYear} David Minnerly</li>
<li><a href="https://github.com/vocksel/my-website">Website Source</a></li>
<li>Background from <a href="http://ommwriter.com">OmmWriter</a></li>
</ul> |
307a02fee9c5c3c2d312750209247f7c2dae5f9d | client/views/readouts/decimal_readout.jsx | client/views/readouts/decimal_readout.jsx | import _ from "lodash";
import React from "react";
import ListeningView from "../listening_view.js";
class DecimalReadout extends ListeningView {
render() {
let formatted;
let raw;
if (typeof this.state.data === "undefined" || this.state.data.length === 0) {
raw = "-";
} else {
if (typeof this.props.quaternionId !== "undefined") {
raw = this.state.data[0][this.props.eulerAxis];
} else if (this.state.data.length > 1) {
raw = _.max(this.state.data, "t").v;
} else {
raw = this.state.data[0].v;
}
if (typeof this.props.conversion !== "undefined") {
formatted = raw * parseFloat(this.props.conversion);
}
if (typeof this.props.scale !== "undefined") {
formatted = raw.toFixed(this.props.scale);
} else {
formatted = raw.toString();
}
if (typeof this.props.precision !== "undefined") {
const integer = parseInt(formatted);
const padded = _.padLeft(integer, this.props.precision, "0");
formatted = formatted.replace(new RegExp("^" + integer), padded);
}
if (this.props.negativePad === "true") {
formatted = formatted.replace(/^([^\-])/, "\u00A0$1");
}
}
return <span data-raw={raw}>{formatted}</span>;
}
}
export {DecimalReadout as default};
| import _ from "lodash";
import React from "react";
import ListeningView from "../listening_view.js";
class DecimalReadout extends ListeningView {
render() {
let formatted;
let raw;
if (typeof this.state.data === "undefined" || this.state.data.length === 0) {
formatted = "-";
} else {
if (typeof this.props.quaternionId !== "undefined") {
raw = this.state.data[0][this.props.eulerAxis];
} else if (this.state.data.length > 1) {
raw = _.max(this.state.data, "t").v;
} else {
raw = this.state.data[0].v;
}
if (typeof this.props.conversion !== "undefined") {
formatted = raw * parseFloat(this.props.conversion);
}
if (typeof this.props.scale !== "undefined") {
formatted = raw.toFixed(this.props.scale);
} else {
formatted = raw.toString();
}
if (typeof this.props.precision !== "undefined") {
const integer = parseInt(formatted);
const padded = _.padLeft(integer, this.props.precision, "0");
formatted = formatted.replace(new RegExp("^" + integer), padded);
}
if (this.props.negativePad === "true") {
formatted = formatted.replace(/^([^\-])/, "\u00A0$1");
}
}
return <span data-raw={raw}>{formatted}</span>;
}
}
export {DecimalReadout as default};
| Fix decimal readout to again show a dash without data. | Fix decimal readout to again show a dash without data.
| JSX | mit | sensedata/space-telemetry,sensedata/space-telemetry | ---
+++
@@ -9,7 +9,7 @@
let raw;
if (typeof this.state.data === "undefined" || this.state.data.length === 0) {
- raw = "-";
+ formatted = "-";
} else {
if (typeof this.props.quaternionId !== "undefined") { |
fba6dfe7a1478d634bab9bee42614a12a780dc63 | lib/map-instance-mixin.jsx | lib/map-instance-mixin.jsx | /**
* @jsx React.DOM
*/
'use strict';
var MapLoader = require('async-google-maps').MapLoader,
React = require('react');
module.exports = {
componentDidMount: function () {
MapLoader.create(this.getDOMNode(), this.props.mapOptions).then(function (map) {
this.idle(map);
}.bind(this));
},
render: function () {
return (
<div className="map-container">
<div className="test"></div>
</div>
);
}
};
| /**
* @jsx React.DOM
*/
'use strict';
var MapLoader = require('async-google-maps').MapLoader,
React = require('react');
module.exports = {
componentDidMount: function () {
MapLoader.create(this.getDOMNode(), this.props.mapOptions).then(function (map) {
this.idle(map);
}.bind(this));
},
render: function () {
return (
<div className="map-container">
</div>
);
}
};
| Remove silly nested element that wasn't needed. | Remove silly nested element that wasn't needed.
| JSX | mit | zpratt/idle-maps,zpratt/idle-maps | ---
+++
@@ -17,7 +17,6 @@
render: function () {
return (
<div className="map-container">
- <div className="test"></div>
</div>
);
} |
4d6d44f13c5af2d9bb38489af7646f77620e648e | client/source/components/Recipe/RecipeIngredientsBS.jsx | client/source/components/Recipe/RecipeIngredientsBS.jsx | import React, {Component} from 'react';
import { Grid, Row, Col, Table } from 'react-bootstrap';
// TODO: Confirm ingredient object structure, ensure that key refers to the proper value
// TODO: Add headers for the 'Ingredient', 'Quantity', 'Unit' and other fields.
export default ({ingredientList}) => {
return (
<Grid>
<Col xs={8} md={8}>
<Table bordered>
<thead>
<tr>
<th data-field="ingredient">Ingredient</th>
<th data-field="quantity">Quantity</th>
<th data-field="unit">Unit</th>
</tr>
</thead>
<tbody>
{ingredientList.map((ingredient) => {
return (
<tr key={ingredient.position}>
<td> {ingredient.name} </td>
<td> {ingredient.amount} </td>
<td> {ingredient.unit} </td>
</tr>
)
})}
</tbody>
</Table>
</Col>
</Grid>
);
}
| import React, {Component} from 'react';
import { Grid, Row, Col, Table } from 'react-bootstrap';
// TODO: Confirm ingredient object structure, ensure that key refers to the proper value
// TODO: Add headers for the 'Ingredient', 'Quantity', 'Unit' and other fields.
class RecipeIngredients extends React.Component {
constructor(props) {
super(props);
}
_renderIngredientName(ingredient){
console.log('Firing render function!');
if (ingredient.prep) {
return (
<p> {`${ingredient.name}, ${ingredient.prep}`} </p>
)
} else {
return (
<p> {`${ingredient.name}`} </p>
)
}
}
render() {
return (
<Grid>
<Col xs={12} md={12}>
<Table bordered>
<thead>
<tr>
<th data-field="ingredient">Ingredient</th>
<th data-field="quantity">Quantity</th>
<th data-field="unit">Unit</th>
</tr>
</thead>
<tbody>
{this.props.ingredientList.map((ingredient) => {
return (
<tr key={ingredient.position}>
<td> {this._renderIngredientName(ingredient)} </td>
<td> {ingredient.amount} </td>
<td> {ingredient.unit} </td>
</tr>
)
})}
</tbody>
</Table>
</Col>
</Grid>
);
}
}
export default RecipeIngredients;
| Implement optional render method that displays a given preparation value along with ingredient name. | Implement optional render method that displays a given preparation value along with ingredient name.
| JSX | mit | JAC-Labs/SkilletHub,JAC-Labs/SkilletHub | ---
+++
@@ -1,35 +1,57 @@
import React, {Component} from 'react';
import { Grid, Row, Col, Table } from 'react-bootstrap';
-
// TODO: Confirm ingredient object structure, ensure that key refers to the proper value
// TODO: Add headers for the 'Ingredient', 'Quantity', 'Unit' and other fields.
-export default ({ingredientList}) => {
- return (
- <Grid>
- <Col xs={8} md={8}>
- <Table bordered>
- <thead>
- <tr>
- <th data-field="ingredient">Ingredient</th>
- <th data-field="quantity">Quantity</th>
- <th data-field="unit">Unit</th>
- </tr>
- </thead>
- <tbody>
- {ingredientList.map((ingredient) => {
- return (
- <tr key={ingredient.position}>
- <td> {ingredient.name} </td>
- <td> {ingredient.amount} </td>
- <td> {ingredient.unit} </td>
- </tr>
- )
- })}
- </tbody>
- </Table>
- </Col>
- </Grid>
- );
+class RecipeIngredients extends React.Component {
+
+ constructor(props) {
+ super(props);
+ }
+
+ _renderIngredientName(ingredient){
+ console.log('Firing render function!');
+ if (ingredient.prep) {
+ return (
+ <p> {`${ingredient.name}, ${ingredient.prep}`} </p>
+ )
+ } else {
+ return (
+ <p> {`${ingredient.name}`} </p>
+ )
+ }
+ }
+
+ render() {
+ return (
+ <Grid>
+ <Col xs={12} md={12}>
+ <Table bordered>
+ <thead>
+ <tr>
+ <th data-field="ingredient">Ingredient</th>
+ <th data-field="quantity">Quantity</th>
+ <th data-field="unit">Unit</th>
+ </tr>
+ </thead>
+ <tbody>
+ {this.props.ingredientList.map((ingredient) => {
+ return (
+ <tr key={ingredient.position}>
+ <td> {this._renderIngredientName(ingredient)} </td>
+ <td> {ingredient.amount} </td>
+ <td> {ingredient.unit} </td>
+ </tr>
+ )
+ })}
+ </tbody>
+ </Table>
+ </Col>
+ </Grid>
+ );
+ }
+
}
+
+export default RecipeIngredients; |
a8fe524987b82e976e11bab1a947ddd20a87776f | client-js/users.jsx | client-js/users.jsx | import "babel-polyfill";
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import UserList from './users/UserList.jsx';
import { store } from './common/store.js';
import api from './common/api.js';
ReactDOM.render(
<Provider store={store}>
<UserList />
</Provider>,
document.getElementById('root')
);
store.dispatch(api.readCollection('users'));
store.dispatch(api.readCollection('reservations'));
store.dispatch(api.readCollection('inventory'));
store.dispatch(api.getCurrentUser());
| import "babel-polyfill";
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import UserList from './users/UserList.jsx';
import { store } from './common/store.js';
import api from './common/api.js';
ReactDOM.render(
<Provider store={store}>
<UserList />
</Provider>,
document.getElementById('root')
);
store.dispatch(api.readCollection('users'));
store.dispatch(api.getCurrentUser());
| Remove unnecessary fetches for User page | Remove unnecessary fetches for User page
| JSX | mit | dragonrobotics/PartTracker,stmobo/PartTracker,dragonrobotics/PartTracker,stmobo/PartTracker,stmobo/PartTracker,dragonrobotics/PartTracker | ---
+++
@@ -18,6 +18,4 @@
);
store.dispatch(api.readCollection('users'));
-store.dispatch(api.readCollection('reservations'));
-store.dispatch(api.readCollection('inventory'));
store.dispatch(api.getCurrentUser()); |
3eae85b18da4211041134f0e8da99d7edff2019f | src/components/HistorySection/index.jsx | src/components/HistorySection/index.jsx | import React from 'react'
import Checkbox from '../Checkbox'
import Item from '../HistoryItem'
import Store from '../../stores/history'
import { observer } from 'mobx-react'
@observer
export default class HistorySection extends React.Component {
constructor () {
super()
this.items = []
}
render () {
const {
data
} = this.props
this.items = []
const onAllCheck = (flag) => {
for (var i = 0; i < this.items.length; i++) {
const checkbox = this.items[i].checkbox
if (flag) {
if (!checkbox.state.checked) {
checkbox.setState({checked: true})
Store.selectedItems.push(checkbox)
}
} else {
checkbox.setState({checked: false})
Store.selectedItems.splice(Store.selectedItems.indexOf(checkbox), 1)
}
}
}
return (
<div className='history-section'>
<div className='subheader'>
<div className='section-checkbox'>
<Checkbox ref={(r) => { this.checkbox = r }} onCheck={onAllCheck} />
</div>
{data.title}
</div>
{
data.items.map((data, key) => {
return <Item ref={(r) => { this.items.push(r) }} data={data} key={key} section={this} />
})
}
</div>
)
}
} | import React from 'react'
import Checkbox from '../Checkbox'
import Item from '../HistoryItem'
import Store from '../../stores/history'
import { observer } from 'mobx-react'
@observer
export default class HistorySection extends React.Component {
constructor () {
super()
this.items = []
}
render () {
const {
data
} = this.props
this.items = []
const onAllCheck = (flag) => {
for (var i = 0; i < this.items.length; i++) {
if (this.items[i] != null) {
const checkbox = this.items[i].checkbox
if (flag) {
if (!checkbox.state.checked) {
checkbox.setState({checked: true})
Store.selectedItems.push(checkbox)
}
} else {
checkbox.setState({checked: false})
Store.selectedItems.splice(Store.selectedItems.indexOf(checkbox), 1)
}
}
}
}
return (
<div className='history-section'>
<div className='subheader'>
<div className='section-checkbox'>
<Checkbox ref={(r) => { this.checkbox = r }} onCheck={onAllCheck} />
</div>
{data.title}
</div>
{
data.items.map((data, key) => {
return <Item ref={(r) => { this.items.push(r) }} data={data} key={key} section={this} />
})
}
</div>
)
}
} | Fix checkbox checking all items when esearched | Fix checkbox checking all items when esearched
| JSX | apache-2.0 | Nersent/Wexond,Nersent/Wexond | ---
+++
@@ -23,16 +23,18 @@
const onAllCheck = (flag) => {
for (var i = 0; i < this.items.length; i++) {
- const checkbox = this.items[i].checkbox
+ if (this.items[i] != null) {
+ const checkbox = this.items[i].checkbox
- if (flag) {
- if (!checkbox.state.checked) {
- checkbox.setState({checked: true})
- Store.selectedItems.push(checkbox)
+ if (flag) {
+ if (!checkbox.state.checked) {
+ checkbox.setState({checked: true})
+ Store.selectedItems.push(checkbox)
+ }
+ } else {
+ checkbox.setState({checked: false})
+ Store.selectedItems.splice(Store.selectedItems.indexOf(checkbox), 1)
}
- } else {
- checkbox.setState({checked: false})
- Store.selectedItems.splice(Store.selectedItems.indexOf(checkbox), 1)
}
}
} |
13491aed1be52c246a37d98386ce18b855f62ac0 | src/client/components/ThreadPost/ThreadPost.jsx | src/client/components/ThreadPost/ThreadPost.jsx | import React from 'react';
import uuid from 'uuid'
import {
createMediaIfExists
} from './Media'
export default function ({post, children}) {
const { id, title, date, imgsrc, comment, ext, references } = post
const SRC = imgsrc
const ID = 'post-media-' + id
return (
<div id={"p"+id} className='thread-post'>
<div className='thread-post-info'>
{() => {if (title) return <span className='thread-post-title'>{title}</span>}}
{children}
<span className='thread-post-number'>No.{id}</span>
<span className='thread-post-backlink'>{renderRefs(references)}</span>
<span className='mdi mdi-dots-vertical thread-post-options'></span>
</div>
{createMediaIfExists(ID, SRC, ext)}
<blockquote dangerouslySetInnerHTML={{__html: comment}}/>
</div>
)
}
function renderRefs(refs) {
if (refs)
return refs.map( ref =>
<a
href={`#p${ref}`}
className="quotelink refered"
key={uuid.v4()}
>{`>>${ref}`}</a>);
} | import React from 'react'
import uuid from 'uuid'
import moment from 'moment'
import {
createMediaIfExists
} from './Media'
import Tooltip from '../Tooltip'
export default function ({post, children}) {
const { id, title, date, imgsrc, comment, ext, references, time } = post
const SRC = imgsrc
const ID = 'post-media-' + id
return (
<div id={"p"+id} className='thread-post clearfix'>
<div className='thread-post-info'>
{renderTitle()}
{renderTimeAgo(time)}
<span className='thread-post-number'>No.{id}</span>
{renderRefs(references)}
<span className='mdi mdi-dots-vertical thread-post-options'></span>
</div>
{createMediaIfExists(ID, SRC, ext)}
<blockquote dangerouslySetInnerHTML={{__html: comment}}/>
</div>
)
}
function renderRefs(refs) {
return refs ? <span className='thread-post-backlink'>
{refs.map( ref =>
<span>
<a
className="quotelink refered"
href={`#p${ref}`}
key={uuid.v4()}>
{`>>${ref}`}
</a>
</span>
)}
</span> : ''
}
function renderTitle(title) {
if (title) return <span className='thread-post-title'>{title}</span>
}
function renderTimeAgo(time){
const post = moment(time);
return <Tooltip
content={post.format('dddd [at] hh:mm:ss A')}
className="date"
position="top"
>
{post.fromNow()}
</Tooltip>
}
| Add timeago tooltip to threadpost | Add timeago tooltip to threadpost
| JSX | mit | AdamSalma/Lurka,AdamSalma/Lurka | ---
+++
@@ -1,22 +1,24 @@
-import React from 'react';
+import React from 'react'
import uuid from 'uuid'
+import moment from 'moment'
import {
createMediaIfExists
} from './Media'
+import Tooltip from '../Tooltip'
export default function ({post, children}) {
- const { id, title, date, imgsrc, comment, ext, references } = post
+ const { id, title, date, imgsrc, comment, ext, references, time } = post
const SRC = imgsrc
const ID = 'post-media-' + id
return (
- <div id={"p"+id} className='thread-post'>
+ <div id={"p"+id} className='thread-post clearfix'>
<div className='thread-post-info'>
- {() => {if (title) return <span className='thread-post-title'>{title}</span>}}
- {children}
+ {renderTitle()}
+ {renderTimeAgo(time)}
<span className='thread-post-number'>No.{id}</span>
- <span className='thread-post-backlink'>{renderRefs(references)}</span>
+ {renderRefs(references)}
<span className='mdi mdi-dots-vertical thread-post-options'></span>
</div>
{createMediaIfExists(ID, SRC, ext)}
@@ -27,12 +29,32 @@
function renderRefs(refs) {
- if (refs)
- return refs.map( ref =>
- <a
- href={`#p${ref}`}
- className="quotelink refered"
- key={uuid.v4()}
- >{`>>${ref}`}</a>);
+ return refs ? <span className='thread-post-backlink'>
+ {refs.map( ref =>
+ <span>
+ <a
+ className="quotelink refered"
+ href={`#p${ref}`}
+ key={uuid.v4()}>
+ {`>>${ref}`}
+ </a>
+ </span>
+ )}
+ </span> : ''
+}
+function renderTitle(title) {
+ if (title) return <span className='thread-post-title'>{title}</span>
}
+
+function renderTimeAgo(time){
+ const post = moment(time);
+ return <Tooltip
+ content={post.format('dddd [at] hh:mm:ss A')}
+ className="date"
+ position="top"
+ >
+ {post.fromNow()}
+ </Tooltip>
+}
+ |
3dc96aaa457c301ad9270bb36460e61c13e7ba1c | src/components/CirclePageNavBar.jsx | src/components/CirclePageNavBar.jsx | import React from 'react';
import { Navbar, Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
export default class CirclePageNavBar extends React.Component {
openPage(e) {
location.href = e.target.getAttribute('href');
}
render() {
var creditURL = this.props.credit;
var openCreditPage = function(e) {
location.href = creditURL;
}
const iconStyle = {
fill: '#9d9d9d',
width: '18px',
height: '18px',
marginRight: '6px',
};
return (
<Navbar inverse collapseOnSelect fixedTop>
<Navbar.Header>
<Navbar.Brand>
<a href="/circles/">
<svg role="img" style={iconStyle}>
<use xmlnsXlink="http://www.w3.org/1999/xlink" xlinkHref="/imgs/svg/sprite.svg#icon"></use>
</svg>
Henge</a>
</Navbar.Brand>
<Navbar.Toggle />
</Navbar.Header>
<Navbar.Collapse>
<Nav>
<NavItem href="/circles/" onClick={this.openPage}>Circles</NavItem>
<NavItem onClick={openCreditPage}>Credits</NavItem>
</Nav>
</Navbar.Collapse>
</Navbar>
);
}
}
| import React from 'react';
import { Navbar, Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
export default class CirclePageNavBar extends React.Component {
openPage(e) {
location.href = e.target.getAttribute('href');
}
render() {
var creditURL = this.props.credit;
var openCreditPage = function(e) {
location.href = creditURL;
}
const iconStyle = {
fill: '#9d9d9d',
width: '18px',
height: '18px',
marginRight: '6px',
};
return (
<Navbar inverse collapseOnSelect fixedTop>
<Navbar.Header>
<Navbar.Brand>
<a href="/circles/">
<svg role="img" style={iconStyle}>
<use xmlnsXlink="http://www.w3.org/1999/xlink" xlinkHref="/imgs/svg/sprite.svg#icon"></use>
</svg>
Henge</a>
</Navbar.Brand>
<Navbar.Toggle />
</Navbar.Header>
<Navbar.Collapse>
<Nav>
<NavItem href="/floors/" onClick={this.openPage}>Floors</NavItem>
<NavItem href="/circles/" onClick={this.openPage}>Circles</NavItem>
<NavItem onClick={openCreditPage}>Credits</NavItem>
</Nav>
</Navbar.Collapse>
</Navbar>
);
}
}
| Add floors link to the header | Add floors link to the header
| JSX | mit | henge-tech/henge-tech,henge-tech/henge-tech,henge-tech/henge-tech,henge-tech/henge-tech | ---
+++
@@ -32,6 +32,7 @@
</Navbar.Header>
<Navbar.Collapse>
<Nav>
+ <NavItem href="/floors/" onClick={this.openPage}>Floors</NavItem>
<NavItem href="/circles/" onClick={this.openPage}>Circles</NavItem>
<NavItem onClick={openCreditPage}>Credits</NavItem>
</Nav> |
33d2b08220a0d05d93dafcb3802e146d4b22fc2f | src/modules/Thread/ThreadHOC.jsx | src/modules/Thread/ThreadHOC.jsx | import React, {Component} from 'react'
import {
Overlay,
Spinner
} from '~/components'
const threadConnect = (ThreadComponent) => {
const ThreadHOC = (props) => {
const {isThreadOpen, posts, closeThread} = props
console.log(props)
return (
<div className="Thread">
<Overlay
isVisible={isThreadOpen}
onClick={closeThread}
/>
<Spinner isSpinning={isThreadOpen && !posts.length}/>
<ThreadComponent {...props} />
</div>
)
}
return ThreadHOC
}
export default threadConnect
| import React, {Component} from 'react'
import {
Overlay,
Spinner
} from '~/components'
const threadConnect = (ThreadComponent) => {
const ThreadHOC = (props) => {
const {isThreadOpen, posts, closeThread, didInvalidate} = props
console.log(props)
return (
<div className="Thread">
<Overlay
isVisible={isThreadOpen && !didInvalidate}
onClick={closeThread}
/>
<Spinner isSpinning={isThreadOpen && !posts.length && !didInvalidate}/>
<ThreadComponent {...props} />
</div>
)
}
return ThreadHOC
}
export default threadConnect
| Disable loading screen when a thread invalidates | fix(Thread): Disable loading screen when a thread invalidates
| JSX | mit | AdamSalma/Lurka,AdamSalma/Lurka | ---
+++
@@ -6,16 +6,16 @@
const threadConnect = (ThreadComponent) => {
const ThreadHOC = (props) => {
- const {isThreadOpen, posts, closeThread} = props
+ const {isThreadOpen, posts, closeThread, didInvalidate} = props
console.log(props)
return (
<div className="Thread">
<Overlay
- isVisible={isThreadOpen}
+ isVisible={isThreadOpen && !didInvalidate}
onClick={closeThread}
/>
- <Spinner isSpinning={isThreadOpen && !posts.length}/>
+ <Spinner isSpinning={isThreadOpen && !posts.length && !didInvalidate}/>
<ThreadComponent {...props} />
</div>
) |
6c8655ab3f2fcff6ee70b6c19a69aa5167036305 | apps/public/src/components/Markdown/Markdown.jsx | apps/public/src/components/Markdown/Markdown.jsx | import React from 'react';
import PropTypes from 'prop-types';
import BaseMarkdown from 'markdown-to-jsx';
import { Typography } from '@material-ui/core';
const overrides = {
h1: {
component: Typography,
props: {
variant: 'h5',
component: 'h2',
gutterBottom: true
}
},
h2: {
component: Typography,
props: {
variant: 'h6',
component: 'h3',
gutterBottom: true
}
},
h3: {
component: Typography,
props: {
variant: 'h6',
component: 'h4',
gutterBottom: true
}
},
p: {
component: Typography,
props: {
variant: 'body1',
gutterBottom: true
}
},
li: {
component: Typography,
props: {
variant: 'body1',
component: 'li'
}
}
};
const Markdown = ({ content = '', options, ...props }) => (
<BaseMarkdown
options={ {
overrides,
forceBlock: true,
...options
} }
{ ...props }
>
{ content }
</BaseMarkdown>
);
Markdown.propTypes = {
content: PropTypes.string,
options: PropTypes.object
};
export default Markdown;
| import React from 'react';
import PropTypes from 'prop-types';
import BaseMarkdown from 'markdown-to-jsx';
import { Typography } from '@material-ui/core';
const overrides = {
h1: {
component: Typography,
props: {
variant: 'h5',
component: 'h2',
gutterBottom: true
}
},
h2: {
component: Typography,
props: {
variant: 'h6',
component: 'h3',
gutterBottom: true
}
},
h3: {
component: Typography,
props: {
variant: 'h6',
component: 'h4',
gutterBottom: true
}
},
p: {
component: Typography,
props: {
variant: 'body1',
gutterBottom: true
}
},
li: {
component: Typography,
props: {
variant: 'body1',
component: 'li'
}
}
};
const Markdown = ({ content = '', options, ...props }) => (
<BaseMarkdown
options={ {
overrides,
forceBlock: true,
...options
} }
{ ...props }
>
{ content || '' }
</BaseMarkdown>
);
Markdown.propTypes = {
content: PropTypes.string,
options: PropTypes.object
};
export default Markdown;
| Fix event description when empty | Fix event description when empty
| JSX | mit | tumido/malenovska,tumido/malenovska | ---
+++
@@ -53,7 +53,7 @@
} }
{ ...props }
>
- { content }
+ { content || '' }
</BaseMarkdown>
);
|
bde0cf621f359b4ce1ad4a648159c07c3aa92ee8 | public/src/components/navigation.jsx | public/src/components/navigation.jsx | import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { ButtonToolbar, DropdownButton } from 'react-bootstrap';
class Navigation extends Component {
constructor(props) {
super(props);
// Bind
this.renderLinks = this.renderLinks.bind(this);
}
// Render all current links
renderLinks() {
return (
this.props.links.map((link) => {
return (
<li role="presentation" key={link.title}>
<Link tabIndex="-1" role="menuitem" to={link.href}>{link.title}</Link>
</li>
);
})
);
}
render() {
return (
<ButtonToolbar>
<DropdownButton title={!!this.props.title ? this.props.title : ''} id="menu">
{this.renderLinks()}
</DropdownButton>
</ButtonToolbar>
);
}
}
export default Navigation;
| import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { ButtonToolbar, DropdownButton, MenuItem } from 'react-bootstrap';
class Navigation extends Component {
constructor(props) {
super(props);
// Bind
this.logoutOnClick = this.logoutOnClick.bind(this);
this.renderLinks = this.renderLinks.bind(this);
}
logoutOnClick() {
const { userInfo, history } = this.props;
this.props.logout(userInfo, history);
}
// Render all current links
renderLinks() {
return (
this.props.links.map((link) => {
if (link.href === '/logout') {
return <MenuItem key={link.title} onClick={this.logoutOnClick}>{link.title}</MenuItem>;
}
return (
<li role="presentation" key={link.title}>
<Link tabIndex="-1" role="menuitem" to={link.href}>{link.title}</Link>
</li>
);
})
);
}
render() {
return (
<ButtonToolbar>
<DropdownButton title={this.props.title ? this.props.title : ''} id="menu">
{this.renderLinks()}
</DropdownButton>
</ButtonToolbar>
);
}
}
export default Navigation;
| Create onClick for logout link and update renderLink method, fix lint issues | Create onClick for logout link and update renderLink method, fix lint issues
| JSX | mit | Twilio-org/phonebank,Twilio-org/phonebank | ---
+++
@@ -1,17 +1,25 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
-import { ButtonToolbar, DropdownButton } from 'react-bootstrap';
+import { ButtonToolbar, DropdownButton, MenuItem } from 'react-bootstrap';
class Navigation extends Component {
constructor(props) {
super(props);
// Bind
+ this.logoutOnClick = this.logoutOnClick.bind(this);
this.renderLinks = this.renderLinks.bind(this);
+ }
+ logoutOnClick() {
+ const { userInfo, history } = this.props;
+ this.props.logout(userInfo, history);
}
// Render all current links
renderLinks() {
return (
this.props.links.map((link) => {
+ if (link.href === '/logout') {
+ return <MenuItem key={link.title} onClick={this.logoutOnClick}>{link.title}</MenuItem>;
+ }
return (
<li role="presentation" key={link.title}>
<Link tabIndex="-1" role="menuitem" to={link.href}>{link.title}</Link>
@@ -23,7 +31,7 @@
render() {
return (
<ButtonToolbar>
- <DropdownButton title={!!this.props.title ? this.props.title : ''} id="menu">
+ <DropdownButton title={this.props.title ? this.props.title : ''} id="menu">
{this.renderLinks()}
</DropdownButton>
</ButtonToolbar> |
e8dfd6f9da4b987f8d3abbb252bdc8dc5b790a6a | lib/client/components/whatsnew/periodSelector.jsx | lib/client/components/whatsnew/periodSelector.jsx | import React from 'react';
class PeriodSelector extends React.Component {
render() {
const from = 1;
const to = 10;
const options = [];
for (let i = from; i <= to; i++) {
options.push((
<option key={i} value={i}>{i} day(s)</option>
));
}
return (
<form className="form-inline pt20">
<div className="form-group">
<label className="mr10" htmlFor="period">Period</label>
<select
className="form-control"
id="period"
defaultValue={this.props.defaultValue}
onChange={this.props.update}
>
{options}
</select>
</div>
</form>
);
}
}
PeriodSelector.propTypes = {
defaultValue: React.PropTypes.number,
update: React.PropTypes.func,
};
export default PeriodSelector;
| import React from 'react';
const PeriodSelector = props => {
const from = 1;
const to = 10;
const options = [];
for (let i = from; i <= to; i++) {
options.push((
<option key={i} value={i}>{i} day(s)</option>
));
}
return (
<form className="form-inline pt20">
<div className="form-group">
<label className="mr10" htmlFor="period">Period</label>
<select
className="form-control"
id="period"
defaultValue={props.defaultValue}
onChange={props.update}
>
{options}
</select>
</div>
</form>);
};
PeriodSelector.propTypes = {
defaultValue: React.PropTypes.number,
update: React.PropTypes.func,
};
export default PeriodSelector;
| Implement react-router and factorize whatsnew page | Implement react-router and factorize whatsnew page
| JSX | mit | dbrugne/ftp-nanny,dbrugne/ftp-nanny | ---
+++
@@ -1,34 +1,31 @@
import React from 'react';
-class PeriodSelector extends React.Component {
- render() {
- const from = 1;
- const to = 10;
+const PeriodSelector = props => {
+ const from = 1;
+ const to = 10;
- const options = [];
- for (let i = from; i <= to; i++) {
- options.push((
- <option key={i} value={i}>{i} day(s)</option>
- ));
- }
+ const options = [];
+ for (let i = from; i <= to; i++) {
+ options.push((
+ <option key={i} value={i}>{i} day(s)</option>
+ ));
+ }
- return (
- <form className="form-inline pt20">
- <div className="form-group">
- <label className="mr10" htmlFor="period">Period</label>
- <select
- className="form-control"
- id="period"
- defaultValue={this.props.defaultValue}
- onChange={this.props.update}
- >
- {options}
- </select>
- </div>
- </form>
- );
- }
-}
+ return (
+ <form className="form-inline pt20">
+ <div className="form-group">
+ <label className="mr10" htmlFor="period">Period</label>
+ <select
+ className="form-control"
+ id="period"
+ defaultValue={props.defaultValue}
+ onChange={props.update}
+ >
+ {options}
+ </select>
+ </div>
+ </form>);
+};
PeriodSelector.propTypes = {
defaultValue: React.PropTypes.number, |
81248730fb617e65ce667218ffa08af36d532570 | app/components/Logo.jsx | app/components/Logo.jsx | import React, {Component} from 'react';
import App from './App';
export default class Logo extends Component {
state = {link: "", image: ""};
loadLogo(name) {
let piece = App.pieces.find(p => p.name == name);
let imageUrl = require('../images/'+piece.logo);
this.setState({link: piece.link, image: imageUrl});
}
componentDidMount() {
this.loadLogo(this.props.params.name);
}
componentDidUpdate(prevProps) {
let name = this.props.params.name;
if (name !== prevProps.params.name) {
this.loadLogo(name);
}
}
render() {
return <a href={this.state.link}><img src={this.state.image} /></a>;
}
}
| import React, {Component} from 'react';
import App from './App';
export default class Logo extends Component {
state = {link: "", image: ""};
loadLogo(name) {
let piece = App.pieces.find(p => p.name == name);
let imageUrl = require('../images/'+piece.logo);
this.setState({link: piece.link, image: imageUrl});
}
componentWillReceiveProps(nextProps) {
let name = nextProps.params.name;
if (name !== this.props.params.name) {
this.loadLogo(name);
}
}
componentDidMount() {
this.loadLogo(this.props.params.name);
}
render() {
return <a href={this.state.link}><img src={this.state.image} /></a>;
}
}
| Use componentWillReceiveProps instead of componentDidUpdate | Use componentWillReceiveProps instead of componentDidUpdate
Because loadLogo will setState, then componentDidUpdate is called two
times in total.
| JSX | isc | J-F-Liu/webpack-react-boilerplate,J-F-Liu/webpack-react-boilerplate | ---
+++
@@ -11,15 +11,15 @@
this.setState({link: piece.link, image: imageUrl});
}
+ componentWillReceiveProps(nextProps) {
+ let name = nextProps.params.name;
+ if (name !== this.props.params.name) {
+ this.loadLogo(name);
+ }
+ }
+
componentDidMount() {
this.loadLogo(this.props.params.name);
- }
-
- componentDidUpdate(prevProps) {
- let name = this.props.params.name;
- if (name !== prevProps.params.name) {
- this.loadLogo(name);
- }
}
render() { |
4468c2d6085d68e1477fda3c0cbfe33b7e861b1f | tutor/src/components/onboarding/onboarding-nag.jsx | tutor/src/components/onboarding/onboarding-nag.jsx | import React from 'react';
import { Button } from 'react-bootstrap';
import { action, observable } from 'mobx';
import { observer, PropTypes as MobxPropTypes } from 'mobx-react';
import Router from '../../helpers/router';
import { OnboardingNag, Heading, Body, Footer } from './nag-components';
export { OnboardingNag, Heading, Body, Footer };
@observer
export class GotItOnboardingNag extends React.PureComponent {
static propTypes = {
ux: MobxPropTypes.observableObject.isRequired,
}
static contextTypes = {
router: React.PropTypes.object,
}
@observable noProblemo = false;
@action.bound
onAddCourse() {
this.context.router.transitionTo(
Router.makePathname('myCourses')
);
}
@action.bound
onContinue() {
if (this.noProblemo) {
this.props.ux.dismissNag();
} else {
this.noProblemo = true;
}
}
renderNoProblem() {
return (
<OnboardingNag className="got-it">
<Body>
No problem. When you’re ready to create a real course, click “Create a course” on the top right of your dashboard.
</Body>
<Footer className="got-it">
<Button bsStyle="primary" onClick={this.onContinue}>Got it</Button>
</Footer>
</OnboardingNag>
);
}
render() {
return this.noProblemo ? this.renderNoProblem() : this.renderPrompt();
}
}
| import React from 'react';
import { Button } from 'react-bootstrap';
import { action, observable } from 'mobx';
import { observer, PropTypes as MobxPropTypes } from 'mobx-react';
import Router from '../../helpers/router';
import { OnboardingNag, Heading, Body, Footer } from './nag-components';
export { OnboardingNag, Heading, Body, Footer };
@observer
export class GotItOnboardingNag extends React.PureComponent {
static propTypes = {
ux: MobxPropTypes.observableObject.isRequired,
}
static contextTypes = {
router: React.PropTypes.object,
}
@observable noProblemo = false;
@action.bound
onAddCourse() {
this.context.router.transitionTo(
Router.makePathname('myCourses')
);
}
@action.bound
onContinue() {
if (this.noProblemo) {
this.props.ux.dismissNag();
} else {
this.noProblemo = true;
}
}
renderNoProblem() {
return (
<OnboardingNag className="got-it">
<Body>
When you’re ready to create a real course, click “Create a course” on the top right of your dashboard.
</Body>
<Footer className="got-it">
<Button bsStyle="primary" onClick={this.onContinue}>Got it</Button>
</Footer>
</OnboardingNag>
);
}
render() {
return this.noProblemo ? this.renderNoProblem() : this.renderPrompt();
}
}
| Remove "No problem" from the ask me later followup | Remove "No problem" from the ask me later followup
https://trello.com/c/HbML3S3w/773-j29-bug-copy-changes | JSX | agpl-3.0 | openstax/tutor-js,openstax/tutor-js,openstax/tutor-js,openstax/tutor-js,openstax/tutor-js | ---
+++
@@ -39,7 +39,7 @@
return (
<OnboardingNag className="got-it">
<Body>
- No problem. When you’re ready to create a real course, click “Create a course” on the top right of your dashboard.
+ When you’re ready to create a real course, click “Create a course” on the top right of your dashboard.
</Body>
<Footer className="got-it">
<Button bsStyle="primary" onClick={this.onContinue}>Got it</Button> |
e96a304a9e9f06b8411e645b5c06ab08cc9dc472 | src/react-autolink.jsx | src/react-autolink.jsx | import React from 'react';
import assign from 'object-assign';
function ReactAutolinkMixin() {
let delimiter = /((?:https?:\/\/)?(?:(?:[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]\.)+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})[a-z0-9.,_\/~#&=;%+?-]*)/ig;
return {
autolink(text, options = {}, bufs = []) {
if (!text) return null;
return text.split(delimiter).map(word => {
let match = word.match(delimiter);
if (match) {
let url = match[0];
return React.createElement(
'a',
assign({href: url.startsWith('http') ? url : `http://${url}`}, options),
url
);
} else {
return word;
}
});
}
};
}
export default ReactAutolinkMixin();
| import React from 'react';
import assign from 'object-assign';
function ReactAutolinkMixin() {
let delimiter = /((?:https?:\/\/)?(?:(?:[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]\.)+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(?::\d{1,5})*[a-z0-9.,_\/~#&=;%+?-]*)/ig;
return {
autolink(text, options = {}, bufs = []) {
if (!text) return null;
return text.split(delimiter).map(word => {
let match = word.match(delimiter);
if (match) {
let url = match[0];
return React.createElement(
'a',
assign({href: url.startsWith('http') ? url : `http://${url}`}, options),
url
);
} else {
return word;
}
});
}
};
}
export default ReactAutolinkMixin();
| Support for matching with port | Support for matching with port
Port regex would be more valid way (0 to 65535), however, I choose more easy (lazy) way
| JSX | mit | banyan/react-autolink,banyan/react-autolink,banyan/react-autolink | ---
+++
@@ -2,7 +2,7 @@
import assign from 'object-assign';
function ReactAutolinkMixin() {
- let delimiter = /((?:https?:\/\/)?(?:(?:[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]\.)+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})[a-z0-9.,_\/~#&=;%+?-]*)/ig;
+ let delimiter = /((?:https?:\/\/)?(?:(?:[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]\.)+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(?::\d{1,5})*[a-z0-9.,_\/~#&=;%+?-]*)/ig;
return {
autolink(text, options = {}, bufs = []) { |
e6a31e0f923e4585bf708525bcdb320753689b11 | app/assets/javascripts/notification-counter.js.jsx | app/assets/javascripts/notification-counter.js.jsx | var NotificationCounter = React.createClass({
getInitialState: function() {
return {messages: 0, mentions: 0};
},
refresh: function() {
var n = this;
$.getJSON("/notifications/counters.json", {}, function(data, status, xhr) {
n.setState({messages: data.messages, mentions: data.mentions});
});
window.setTimeout(this.refresh, 12 * 1000);
},
render: function() {
var messageCounter = this.state.messages > 0 ? <div className="count"><a href="/notifications">{this.state.messages}</a></div> : null;
var mentionCounter = this.state.mentions > 0 ? <div className="count"><a href="/notifications">{this.state.mentions}</a></div> : null;
return <div>
{messageCounter}
{mentionCounter}
</div>
}
})
$(function() {
var counters = $(".toolbar .counters");
if(counters.length > 0) {
var counter = React.render(<NotificationCounter />, counters.get(0));
counter.refresh();
}
});
| var NotificationCounter = React.createClass({
getInitialState: function() {
return {messages: 0, mentions: 0};
},
refresh: function() {
var n = this;
$.getJSON("/notifications/counters.json", {}, function(data, status, xhr) {
n.setState({messages: data.messages, mentions: data.mentions});
});
window.setTimeout(this.refresh, 12 * 1000);
},
render: function() {
var messageCounter = this.state.messages > 0 ? <div className="count"><a href="/notifications">{this.state.messages}</a></div> : null;
var mentionCounter = this.state.mentions > 0 ? <div className="count mentions"><a href="/notifications">{this.state.mentions}</a></div> : null;
return <div>
{messageCounter}
{mentionCounter}
</div>
}
})
$(function() {
var counters = $(".toolbar .counters");
if(counters.length > 0) {
var counter = React.render(<NotificationCounter />, counters.get(0));
counter.refresh();
}
});
| Set mentions class for mentions counter | Set mentions class for mentions counter
| JSX | mit | mutle/fu2,mutle/fu2,mutle/fu2,mutle/fu2 | ---
+++
@@ -11,7 +11,7 @@
},
render: function() {
var messageCounter = this.state.messages > 0 ? <div className="count"><a href="/notifications">{this.state.messages}</a></div> : null;
- var mentionCounter = this.state.mentions > 0 ? <div className="count"><a href="/notifications">{this.state.mentions}</a></div> : null;
+ var mentionCounter = this.state.mentions > 0 ? <div className="count mentions"><a href="/notifications">{this.state.mentions}</a></div> : null;
return <div>
{messageCounter}
{mentionCounter} |
f858f36f202e33a7e690c6cba841ed02246d1baf | examples/counter/src/components/Counter.jsx | examples/counter/src/components/Counter.jsx | import React, { Component, PropTypes } from 'react'
import { withStore, withActions } from 'fluorine-lib'
import dispatcher from '../dispatcher'
import counter from '../reducers/counter'
import * as CounterActions from '../actions/counter'
@withStore(dispatcher.reduce(counter), 'counter')
@withActions(dispatcher, CounterActions)
export default class Counter extends Component {
static propTypes = {
actions: PropTypes.objectOf(PropTypes.func).isRequired,
counter: PropTypes.number.isRequired
}
render() {
const {
counter,
actions
} = this.props
return (
<p>
Clicked: {counter} times
{' '}
<button onClick={() => actions.increment()}>
+
</button>
{' '}
<button onClick={() => actions.decrement()}>
-
</button>
{' '}
<button onClick={() => actions.incrementAsync()}>
Increment async
</button>
</p>
)
}
}
| import React, { Component, PropTypes } from 'react'
import { withStore, withActions } from 'fluorine-lib'
import dispatcher from '../dispatcher'
import counter from '../reducers/counter'
import * as CounterActions from '../actions/counter'
@withStore(dispatcher.reduce(counter), 'counter')
@withActions(dispatcher, CounterActions)
export default class Counter extends Component {
static propTypes = {
actions: PropTypes.objectOf(PropTypes.func).isRequired,
counter: PropTypes.number.isRequired
};
render() {
const {
counter,
actions
} = this.props
return (
<p>
Clicked: {counter} times
{' '}
<button onClick={() => actions.increment()}>
+
</button>
{' '}
<button onClick={() => actions.decrement()}>
-
</button>
{' '}
<button onClick={() => actions.incrementAsync()}>
Increment async
</button>
</p>
)
}
}
| Fix example for stricter babel class transpilation | Fix example for stricter babel class transpilation
| JSX | unknown | philplckthun/fluorine,philpl/fluorine,philpl/fluorine | ---
+++
@@ -12,7 +12,7 @@
static propTypes = {
actions: PropTypes.objectOf(PropTypes.func).isRequired,
counter: PropTypes.number.isRequired
- }
+ };
render() {
const { |
d834c1a26e7b5a6df8f11b99a9297caf48eb4bf8 | packages/lesswrong/components/users/LoginPopup.jsx | packages/lesswrong/components/users/LoginPopup.jsx | import { Components, registerComponent } from 'meteor/vulcan:core';
import React, { PureComponent } from 'react';
import Dialog from '@material-ui/core/Dialog';
// Makes its child a link (wrapping it in an <a> tag) which opens a login
// dialog.
class LoginPopup extends PureComponent {
constructor() {
super();
this.state = {
isOpen: false
}
}
render() {
const { onClose, classes } = this.props;
return (
<Dialog
title="Log In"
modal={false}
open={true}
onClose={this.props.onClose}
>
<Components.WrappedLoginForm/>
</Dialog>
);
}
}
registerComponent('LoginPopup', LoginPopup); | import { Components, registerComponent } from 'meteor/vulcan:core';
import React, { PureComponent } from 'react';
import Dialog from '@material-ui/core/Dialog';
// Makes its child a link (wrapping it in an <a> tag) which opens a login
// dialog.
class LoginPopup extends PureComponent {
constructor() {
super();
this.state = {
isOpen: false
}
}
render() {
const { onClose, classes } = this.props;
return (
<Dialog
open={true}
onClose={this.props.onClose}
>
<Components.WrappedLoginForm/>
</Dialog>
);
}
}
registerComponent('LoginPopup', LoginPopup); | Remove unused props from Dialog | Remove unused props from Dialog
| JSX | mit | Discordius/Lesswrong2,Discordius/Telescope,Discordius/Lesswrong2,Discordius/Telescope,Discordius/Lesswrong2,Discordius/Telescope,Discordius/Telescope,Discordius/Lesswrong2 | ---
+++
@@ -17,8 +17,6 @@
return (
<Dialog
- title="Log In"
- modal={false}
open={true}
onClose={this.props.onClose}
> |
179d938497be42e0071477714407ab7bbeec4a2b | src/utils/iconFactory.jsx | src/utils/iconFactory.jsx | import React from 'react';
import PropTypes from 'prop-types';
export default function iconFactory(network, iconConfig) {
const Icon = (props) => {
const {
className,
iconBgStyle,
logoFillColor,
round,
size,
} = props;
const baseStyle = {
width: size,
height: size,
};
const classes = `social-icon social-icon--${network} ${className}`;
return (
<div style={baseStyle}>
<svg
viewBox="0 0 64 64"
width={size}
height={size}
className={classes}>
<g>
{(!round ? (
<rect
width="64"
height="64"
fill={iconConfig.color}
style={iconBgStyle} />
) : (
<circle
cx="32"
cy="32"
r="31"
fill={iconConfig.color}
style={iconBgStyle} />
))}
</g>
<g>
<path d={iconConfig.icon} fill={logoFillColor} />
</g>
</svg>
</div>
);
};
Icon.propTypes = {
className: PropTypes.string,
iconBgStyle: PropTypes.object,
logoFillColor: PropTypes.string,
round: PropTypes.bool,
size: PropTypes.number,
};
Icon.defaultProps = {
className: '',
iconBgStyle: {},
logoFillColor: 'white',
size: 64,
};
return Icon;
}
| import React from 'react';
import PropTypes from 'prop-types';
export default function iconFactory(network, iconConfig) {
const Icon = (props) => {
const {
className,
iconBgStyle,
logoFillColor,
borderRadius,
round,
size,
} = props;
const baseStyle = {
width: size,
height: size,
};
const classes = `social-icon social-icon--${network} ${className}`;
return (
<div style={baseStyle}>
<svg
viewBox="0 0 64 64"
width={size}
height={size}
className={classes}>
<g>
{(!round ? (
<rect
width="64"
height="64"
rx={borderRadius}
ry={borderRadius}
fill={iconConfig.color}
style={iconBgStyle} />
) : (
<circle
cx="32"
cy="32"
r="31"
fill={iconConfig.color}
style={iconBgStyle} />
))}
</g>
<g>
<path d={iconConfig.icon} fill={logoFillColor} />
</g>
</svg>
</div>
);
};
Icon.propTypes = {
className: PropTypes.string,
iconBgStyle: PropTypes.object,
logoFillColor: PropTypes.string,
round: PropTypes.bool,
size: PropTypes.number,
borderRadius: PropTypes.number,
};
Icon.defaultProps = {
className: '',
iconBgStyle: {},
logoFillColor: 'white',
size: 64,
borderRadius: 0,
};
return Icon;
}
| Allow rounded corners for rect icons | Allow rounded corners for rect icons
| JSX | mit | nygardk/react-share,nygardk/react-share | ---
+++
@@ -7,6 +7,7 @@
className,
iconBgStyle,
logoFillColor,
+ borderRadius,
round,
size,
} = props;
@@ -30,6 +31,8 @@
<rect
width="64"
height="64"
+ rx={borderRadius}
+ ry={borderRadius}
fill={iconConfig.color}
style={iconBgStyle} />
) : (
@@ -56,6 +59,7 @@
logoFillColor: PropTypes.string,
round: PropTypes.bool,
size: PropTypes.number,
+ borderRadius: PropTypes.number,
};
Icon.defaultProps = {
@@ -63,6 +67,7 @@
iconBgStyle: {},
logoFillColor: 'white',
size: 64,
+ borderRadius: 0,
};
return Icon; |
989b0c917cbd693967983d09a975545dde9a4369 | indico/modules/events/client/js/header.jsx | indico/modules/events/client/js/header.jsx | // This file is part of Indico.
// Copyright (C) 2002 - 2021 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.
import React from 'react';
import ReactDOM from 'react-dom';
import {IButton, ICSCalendarLink} from 'indico/react/components';
import {Translate} from 'indico/react/i18n';
document.addEventListener('DOMContentLoaded', () => {
const calendarContainer = document.querySelector('#event-calendar-link');
if (!calendarContainer) {
return;
}
const eventId = calendarContainer.dataset.eventId;
ReactDOM.render(
<ICSCalendarLink
endpoint="events.export_event_ical"
params={{event_id: eventId}}
renderButton={onClick => (
<IButton
icon="calendar"
classes={{'height-full': true, 'text-color': true, 'subtle': true}}
onClick={onClick}
/>
)}
dropdownPosition="top left"
popupPosition="bottom right"
options={[
{key: 'event', text: Translate.string('Event'), extraParams: {}},
{
key: 'event',
text: Translate.string('Detailed timetable'),
extraParams: {detail: 'contributions'},
},
]}
/>,
calendarContainer
);
});
| // This file is part of Indico.
// Copyright (C) 2002 - 2021 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.
import React from 'react';
import ReactDOM from 'react-dom';
import {IButton, ICSCalendarLink} from 'indico/react/components';
import {Translate} from 'indico/react/i18n';
document.addEventListener('DOMContentLoaded', () => {
const calendarContainer = document.querySelector('#event-calendar-link');
if (!calendarContainer) {
return;
}
const eventId = calendarContainer.dataset.eventId;
ReactDOM.render(
<ICSCalendarLink
endpoint="events.export_event_ical"
params={{event_id: eventId}}
renderButton={onClick => (
<IButton
icon="calendar"
classes={{'height-full': true, 'text-color': true, 'subtle': true}}
onClick={onClick}
/>
)}
dropdownPosition="top left"
popupPosition="bottom right"
options={[
{key: 'event', text: Translate.string('Event'), extraParams: {}},
{
key: 'contributions',
text: Translate.string('Detailed timetable'),
extraParams: {detail: 'contributions'},
},
]}
/>,
calendarContainer
);
});
| Fix react warning about duplicate key | Fix react warning about duplicate key
| JSX | mit | DirkHoffmann/indico,ThiefMaster/indico,ThiefMaster/indico,indico/indico,indico/indico,DirkHoffmann/indico,DirkHoffmann/indico,ThiefMaster/indico,ThiefMaster/indico,indico/indico,pferreir/indico,pferreir/indico,DirkHoffmann/indico,pferreir/indico,indico/indico,pferreir/indico | ---
+++
@@ -36,7 +36,7 @@
options={[
{key: 'event', text: Translate.string('Event'), extraParams: {}},
{
- key: 'event',
+ key: 'contributions',
text: Translate.string('Detailed timetable'),
extraParams: {detail: 'contributions'},
}, |
0acd20cb42c96ed58f11c979bdfba9faa8a8370a | views/components/Main.jsx | views/components/Main.jsx | 'use babel';
import React, { Component } from 'react';
import NavBar from './NavBar';
import Announcements from './Announcements/Container';
import Multimedia from './Multimedia/Container';
export default class Main extends Component {
constructor(props) {
super(props);
this.state = {
windowToRender: 'announcements'
};
this.switchView = this.switchView.bind(this);
}
switchView(view) {
this.setState({ windowToRender: view });
}
render() {
return (
<div>
<div id="aSide">
<NavBar switchView={this.switchView} windowToRender={this.state.windowToRender} />
</div>
<div id="content">
<Announcements />
</div>
</div>
);
}
}
| 'use babel';
import React, { Component } from 'react';
import NavBar from './NavBar';
import Announcements from './Announcements/Container';
import Multimedia from './Multimedia/Container';
export default class Main extends Component {
constructor(props) {
super(props);
this.state = {
windowToRender: 'announcements'
};
this.switchView = this.switchView.bind(this);
}
switchView(view) {
this.setState({ windowToRender: view });
}
render() {
return (
<div>
<div id="aSide">
<NavBar switchView={this.switchView} windowToRender={this.state.windowToRender} />
</div>
<div id="content">
{(() => {
switch (this.state.windowToRender) {
case 'announcements': return <Announcements />;
case 'multimedia': return <Multimedia />;
case 'forum': return <Announcements />;
default: return <Announcements />;
}
})()}
</div>
</div>
);
}
}
| Add switch case for different view | Add switch case for different view
| JSX | mit | amoshydra/nus-notify,amoshydra/nus-notify | ---
+++
@@ -26,7 +26,15 @@
<NavBar switchView={this.switchView} windowToRender={this.state.windowToRender} />
</div>
<div id="content">
- <Announcements />
+ {(() => {
+ switch (this.state.windowToRender) {
+ case 'announcements': return <Announcements />;
+ case 'multimedia': return <Multimedia />;
+ case 'forum': return <Announcements />;
+ default: return <Announcements />;
+ }
+ })()}
+
</div>
</div>
); |
7967b4386fac9cfc51080823b28c7a28ffb4a202 | src/components/vanilla/NoteFilter.jsx | src/components/vanilla/NoteFilter.jsx | import React from 'react'
import PropTypes from 'prop-types'
import style from './NoteFilter.css'
const NoteFilter = ({ onChange }) => (
<div className={style.root}>
<span>Find notes:</span>
<input type='text' className={style.input}
placeholder='Filter by text or tags'
onChange={event => { onChange(event.target.value) }} />
</div>
)
NoteFilter.propTypes = {
onChange: PropTypes.func.isRequired
}
export default NoteFilter
| import React from 'react'
import PropTypes from 'prop-types'
import style from './NoteFilter.css'
const NoteFilter = ({ onChange }) => {
function resetFilter (input) {
if (input.value) {
input.value = ''
onChange(input.value)
}
}
return (
<div className={style.root}>
<span>Find notes (ESC to reset):</span>
<input type='text' className={style.input}
placeholder='Filter by text or tags'
onChange={event => { onChange(event.target.value) }}
onKeyUp={event => { event.keyCode === 27 && resetFilter(event.target) }}/>
</div>
)
}
NoteFilter.propTypes = {
onChange: PropTypes.func.isRequired
}
export default NoteFilter
| Use ESC to reset filter | Use ESC to reset filter
Signed-off-by: Vojtech Szocs <[email protected]>
| JSX | mit | vojtechszocs/react-playground,vojtechszocs/react-playground | ---
+++
@@ -3,17 +3,27 @@
import style from './NoteFilter.css'
-const NoteFilter = ({ onChange }) => (
- <div className={style.root}>
+const NoteFilter = ({ onChange }) => {
+ function resetFilter (input) {
+ if (input.value) {
+ input.value = ''
+ onChange(input.value)
+ }
+ }
- <span>Find notes:</span>
+ return (
+ <div className={style.root}>
- <input type='text' className={style.input}
- placeholder='Filter by text or tags'
- onChange={event => { onChange(event.target.value) }} />
+ <span>Find notes (ESC to reset):</span>
- </div>
-)
+ <input type='text' className={style.input}
+ placeholder='Filter by text or tags'
+ onChange={event => { onChange(event.target.value) }}
+ onKeyUp={event => { event.keyCode === 27 && resetFilter(event.target) }}/>
+
+ </div>
+ )
+}
NoteFilter.propTypes = {
onChange: PropTypes.func.isRequired |
670a978795557c7eddc80eff68ff62c2ccce9297 | src/app/components/message_form.jsx | src/app/components/message_form.jsx | let React = require('react');
let Actions = require('../actions');
let mui = require('material-ui');
let IconButton = mui.IconButton;
let FontIcon = mui.FontIcon;
let Colors = mui.Styles.Colors;
let MessageForm = React.createClass({
getInitialState () {
return {
body: '',
};
},
handleChange (e) {
this.setState({
body: e.target.value,
});
},
handleKeyUp (e) {
if (e.keyCode === 13 && this.state.body.length > 0) {
this._commitMessage();
}
},
handleClick (e) {
this._commitMessage();
},
_commitMessage () {
Actions.sendMessage(this.props.user, this.state.body);
this.setState({
body: '',
});
},
render () {
return (
<div className="message-form form-compact">
<input type="text" value={this.state.body} onChange={this.handleChange} onKeyUp={this.handleKeyUp} />
<IconButton iconStyle={{fontSize: '18px'}} style={{width: '42px', height: '42px'}} onClick={this.handleClick}>
<FontIcon className="material-icons" color={Colors.green500}>send</FontIcon>
</IconButton>
</div>
);
},
});
module.exports = MessageForm;
| let React = require('react');
let Actions = require('../actions');
let mui = require('material-ui');
let IconButton = mui.IconButton;
let FontIcon = mui.FontIcon;
let Colors = mui.Styles.Colors;
let MessageForm = React.createClass({
getInitialState () {
return {
body: '',
};
},
handleChange (e) {
this.setState({
body: e.target.value,
});
},
handleKeyUp (e) {
if (e.keyCode === 13) {
this._commitMessage();
}
},
handleClick (e) {
this._commitMessage();
},
_commitMessage () {
if (this.state.body.length === 0) {
return;
}
Actions.sendMessage(this.props.user, this.state.body);
this.setState({
body: '',
});
},
render () {
return (
<div className="message-form form-compact">
<input type="text" value={this.state.body} onChange={this.handleChange} onKeyUp={this.handleKeyUp} />
<IconButton iconStyle={{fontSize: '18px'}} style={{width: '42px', height: '42px'}} onClick={this.handleClick}>
<FontIcon className="material-icons" color={Colors.green500}>send</FontIcon>
</IconButton>
</div>
);
},
});
module.exports = MessageForm;
| Fix empty message sending from MessageForm | Fix empty message sending from MessageForm
| JSX | mit | Gargron/xmpp-web,Gargron/xmpp-web | ---
+++
@@ -21,7 +21,7 @@
},
handleKeyUp (e) {
- if (e.keyCode === 13 && this.state.body.length > 0) {
+ if (e.keyCode === 13) {
this._commitMessage();
}
},
@@ -31,6 +31,10 @@
},
_commitMessage () {
+ if (this.state.body.length === 0) {
+ return;
+ }
+
Actions.sendMessage(this.props.user, this.state.body);
this.setState({ |
4a7c7542829dda358dd7128bbc704fe75c9ce6ca | src/context/ScreenClassProvider/index.jsx | src/context/ScreenClassProvider/index.jsx | /* global window */
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { getScreenClass } from '../../utils';
import { getConfiguration } from '../../config';
export const NO_PROVIDER_FLAG = 'NO_PROVIDER_FLAG';
export const ScreenClassContext = React.createContext(NO_PROVIDER_FLAG);
export default class ScreenClassProvider extends PureComponent {
static propTypes = {
/**
* Children of the ScreenClassProvider - this should be all your child React nodes.
*/
children: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = {
screenClass: getConfiguration().defaultScreenClass,
};
this.setScreenClass = this.setScreenClass.bind(this);
}
componentDidMount() {
this.setScreenClass();
window.addEventListener('resize', this.setScreenClass, false);
}
componentWillUnmount() {
window.addEventListener('resize', this.setScreenClass, false);
}
setScreenClass() {
const currScreenClass = getScreenClass();
if (currScreenClass !== this.state.screenClass) {
this.setState({ screenClass: currScreenClass });
}
}
render() {
const { screenClass } = this.state;
const { children } = this.props;
return (
<ScreenClassContext.Provider value={screenClass}>
{children}
</ScreenClassContext.Provider>
);
}
}
| /* global window */
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { getScreenClass } from '../../utils';
import { getConfiguration } from '../../config';
export const NO_PROVIDER_FLAG = 'NO_PROVIDER_FLAG';
export const ScreenClassContext = React.createContext(NO_PROVIDER_FLAG);
export default class ScreenClassProvider extends PureComponent {
static propTypes = {
/**
* Children of the ScreenClassProvider - this should be all your child React nodes.
*/
children: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = {
screenClass: getConfiguration().defaultScreenClass,
};
this.setScreenClass = this.setScreenClass.bind(this);
}
componentDidMount() {
this.setScreenClass();
window.addEventListener('resize', this.setScreenClass, false);
}
componentWillUnmount() {
window.removeEventListener('resize', this.setScreenClass, false);
}
setScreenClass() {
const currScreenClass = getScreenClass();
if (currScreenClass !== this.state.screenClass) {
this.setState({ screenClass: currScreenClass });
}
}
render() {
const { screenClass } = this.state;
const { children } = this.props;
return (
<ScreenClassContext.Provider value={screenClass}>
{children}
</ScreenClassContext.Provider>
);
}
}
| Remove event listener instead of add. | Remove event listener instead of add.
| JSX | isc | zoover/react-grid-system,zoover/react-grid-system,JSxMachina/react-grid-system | ---
+++
@@ -32,7 +32,7 @@
}
componentWillUnmount() {
- window.addEventListener('resize', this.setScreenClass, false);
+ window.removeEventListener('resize', this.setScreenClass, false);
}
setScreenClass() { |
89d8fde21c76d80496e30cc66e0c0869aa886bcd | src/js/ui/OverlaysContainer.jsx | src/js/ui/OverlaysContainer.jsx | import React from 'react';
import Shield from './Shield';
import FileDrop from '../file/FileDrop';
// Container to transition from old HTML-based #overlays-container element.
export default class OverlaysContainer extends React.Component {
render () {
return (
<div>
<Shield />
<FileDrop />
<div id='modal-container'></div>
</div>
);
}
}
| import React from 'react';
import Shield from './Shield';
import FileDrop from '../file/FileDrop';
// Container to transition from old HTML-based #overlays-container element.
export default class OverlaysContainer extends React.Component {
render () {
return (
<div>
<Shield />
<FileDrop />
<div id='modal-container' className='modal-container' />
</div>
);
}
}
| Add proper class to modals container | Add proper class to modals container
| JSX | mit | tangrams/tangram-play,tangrams/tangram-play | ---
+++
@@ -9,7 +9,7 @@
<div>
<Shield />
<FileDrop />
- <div id='modal-container'></div>
+ <div id='modal-container' className='modal-container' />
</div>
);
} |
ae534e3625bd6bff90fab7fa181f4db3980c75e9 | src/client/pages/Dashboard/ItemList.jsx | src/client/pages/Dashboard/ItemList.jsx | import React from 'react';
import PropTypes from 'prop-types';
import { DashboardCard } from '../shared/Cards';
const ItemList = ({ items }) => (
<div className="item-list">
{items.map(item => (
<DashboardCard item={item} key={item.name} />
))}
</div>
);
ItemList.propTypes = {
items: PropTypes.arrayOf(PropTypes.object).isRequired,
};
export default ItemList;
| import React from 'react';
import PropTypes from 'prop-types';
import AnimateVisibleChildren from '../shared/AnimateVisibleChildren';
import { DashboardCard } from '../shared/Cards';
const ItemList = ({ items }) => (
<div className="item-list">
<AnimateVisibleChildren className="flex flex-wrap margin-vertical-big justify-around">
{items.map(item => (
<DashboardCard item={item} key={item.name} />
))}
</AnimateVisibleChildren>
</div>
);
ItemList.propTypes = {
items: PropTypes.arrayOf(PropTypes.object).isRequired,
};
export default ItemList;
| Add AnimateVisibleChildren effect to Dashboard | Add AnimateVisibleChildren effect to Dashboard
| JSX | mit | Chingu-cohorts/devgaido | ---
+++
@@ -1,13 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
+import AnimateVisibleChildren from '../shared/AnimateVisibleChildren';
import { DashboardCard } from '../shared/Cards';
const ItemList = ({ items }) => (
<div className="item-list">
- {items.map(item => (
- <DashboardCard item={item} key={item.name} />
- ))}
+ <AnimateVisibleChildren className="flex flex-wrap margin-vertical-big justify-around">
+ {items.map(item => (
+ <DashboardCard item={item} key={item.name} />
+ ))}
+ </AnimateVisibleChildren>
</div>
);
|
129f0f2d60da6b79b103df07fec6e742abc4e5c8 | src/js/monsterblock.jsx | src/js/monsterblock.jsx | import React from 'react';
const MonsterBlock = React.createClass({
protypes: {
stats: React.PropTypes.array.isRequired,
title: React.PropTypes.string
},
render () {
let className = 'monster-block ' + this.props.className;
let header = this.props.title ? (<h2>{this.props.title}</h2>) : '';
return (
<section className={className}>
{header}
{this.props.stats.map(function(stat, index) {
let markup = marked(stat, {sanitize: false});
return (
<p key={index} dangerouslySetInnerHTML={{__html: markup}} />
);
})}
</section>
);
}
});
export default MonsterBlock;
| import React from 'react';
const MonsterBlock = React.createClass({
protypes: {
stats: React.PropTypes.array.isRequired,
title: React.PropTypes.string
},
render () {
let className = 'monster-block ' + this.props.className;
let header = this.props.title ? (<h2>{this.props.title}</h2>) : '';
return (
<section className={className}>
{header}
{this.props.stats.map(function(stat, index) {
let markup = marked(stat, {sanitize: false});
return (
<div key={index} dangerouslySetInnerHTML={{__html: markup}} />
);
})}
</section>
);
}
});
export default MonsterBlock;
| Fix markup problem caused by mardown | Fix markup problem caused by mardown
| JSX | mit | jkrayer/summoner,jkrayer/summoner | ---
+++
@@ -14,7 +14,7 @@
{this.props.stats.map(function(stat, index) {
let markup = marked(stat, {sanitize: false});
return (
- <p key={index} dangerouslySetInnerHTML={{__html: markup}} />
+ <div key={index} dangerouslySetInnerHTML={{__html: markup}} />
);
})}
</section> |
e2d03bd12d7ac627c092913076b30293a83fb744 | lib/GridItem.jsx | lib/GridItem.jsx | 'use strict';
import React from 'react';
export default class GridItem extends React.Component {
render() {
var itemStyle = this.props.style;
return <div style={itemStyle} className="gridItem">{this.props.item.name}</div>;
}
}
GridItem.propTypes = {
item: React.PropTypes.object,
style: React.PropTypes.object,
index: React.PropTypes.number
};
| 'use strict';
import React from 'react';
import BaseDisplayObject from './BaseDisplayObject.jsx';
export default class GridItem extends BaseDisplayObject{
constructor() {
super();
this.onDrag = super.onDrag.bind(this);
this.onMouseOver = super.onMouseOver.bind(this);
}
render() {
//IMPORTANT: Without the style, nothing happens :(
var itemStyle = super.getStyle.call(this);
return <div
onMouseDown={this.onDrag}
onMouseOver={this.onMouseOver}
style={itemStyle}
className="gridItem">{this.props.item.name}</div>;
}
}
| Update gridItem with new basedisplay | Update gridItem with new basedisplay
| JSX | mit | jrowny/react-absolute-grid,okonet/react-absolute-grid,rovolution/react-absolute-grid,Jonekee/react-absolute-grid,conorhastings/react-absolute-grid,ClouDesire/react-absolute-grid,Jonekee/react-absolute-grid,socialtables/react-absolute-grid,ClouDesire/react-absolute-grid,okonet/react-absolute-grid,rovolution/react-absolute-grid,conorhastings/react-absolute-grid | ---
+++
@@ -1,16 +1,24 @@
'use strict';
import React from 'react';
+import BaseDisplayObject from './BaseDisplayObject.jsx';
-export default class GridItem extends React.Component {
+export default class GridItem extends BaseDisplayObject{
+
+ constructor() {
+ super();
+ this.onDrag = super.onDrag.bind(this);
+ this.onMouseOver = super.onMouseOver.bind(this);
+ }
+
render() {
- var itemStyle = this.props.style;
- return <div style={itemStyle} className="gridItem">{this.props.item.name}</div>;
+ //IMPORTANT: Without the style, nothing happens :(
+ var itemStyle = super.getStyle.call(this);
+
+ return <div
+ onMouseDown={this.onDrag}
+ onMouseOver={this.onMouseOver}
+ style={itemStyle}
+ className="gridItem">{this.props.item.name}</div>;
}
}
-
-GridItem.propTypes = {
- item: React.PropTypes.object,
- style: React.PropTypes.object,
- index: React.PropTypes.number
-}; |
4e2cf81d15c6bdeeb3af3bb3e41fed078fc6c3fb | app/components/pages/Search.jsx | app/components/pages/Search.jsx | import React from 'react';
class Search extends React.Component {
render() {
// if (!process.env.BROWSER) return null; // rendering on server makes it dissapear on client
return (
<div>
{/*<iframe style={{width: "100%", height: "100vh", maxWidth: "800px"}} frameBorder="0" src="/static/search.html">
</iframe>*/}
<div>Site search if temporary unavailable. Sorry for the inconvenience.</div>
</div>
);
}
}
module.exports = {
path: 'search.html',
component: Search
};
| import React from 'react';
class Search extends React.Component {
render() {
// if (!process.env.BROWSER) return null; // rendering on server makes it dissapear on client
return (
<div>
{/*<iframe style={{width: "100%", height: "100vh", maxWidth: "800px"}} frameBorder="0" src="/static/search.html">
</iframe>*/}
<div className="row align-center">Site search is temporarily unavailable. Sorry for the inconvenience.</div>
</div>
);
}
}
module.exports = {
path: 'search.html',
component: Search
};
| Fix search disable message typo and center | Fix search disable message typo and center
| JSX | mit | GolosChain/tolstoy,steemit-intl/steemit.com,TimCliff/steemit.com,enisey14/platform,TimCliff/steemit.com,steemit/steemit.com,TimCliff/steemit.com,steemit/steemit.com,steemit-intl/steemit.com,steemit/steemit.com,GolosChain/tolstoy,enisey14/platform,GolosChain/tolstoy | ---
+++
@@ -7,7 +7,7 @@
<div>
{/*<iframe style={{width: "100%", height: "100vh", maxWidth: "800px"}} frameBorder="0" src="/static/search.html">
</iframe>*/}
- <div>Site search if temporary unavailable. Sorry for the inconvenience.</div>
+ <div className="row align-center">Site search is temporarily unavailable. Sorry for the inconvenience.</div>
</div>
);
} |
562733f5923c632959b119b1d33281aa5d2a2353 | samples/msal-react-samples/react-router-sample/src/pages/Logout.jsx | samples/msal-react-samples/react-router-sample/src/pages/Logout.jsx | import React, { useEffect } from "react";
import { useMsal } from "@azure/msal-react";
import { BrowserUtils } from "@azure/msal-browser";
export function Logout() {
const { instance } = useMsal();
useEffect(() => {
instance.logoutRedirect({
onRedirectNavigate: () => !BrowserUtils.isInIframe()
})
}, []);
return (
<div>Logout</div>
)
}
| import React, { useEffect } from "react";
import { useMsal } from "@azure/msal-react";
import { BrowserUtils } from "@azure/msal-browser";
export function Logout() {
const { instance } = useMsal();
useEffect(() => {
instance.logoutRedirect({
onRedirectNavigate: () => !BrowserUtils.isInIframe()
})
}, [ instance ]);
return (
<div>Logout</div>
)
}
| Fix react router lint error | Fix react router lint error
| JSX | mit | AzureAD/microsoft-authentication-library-for-js,AzureAD/microsoft-authentication-library-for-js,AzureAD/microsoft-authentication-library-for-js,AzureAD/microsoft-authentication-library-for-js,AzureAD/microsoft-authentication-library-for-js,AzureAD/microsoft-authentication-library-for-js,AzureAD/microsoft-authentication-library-for-js,AzureAD/microsoft-authentication-library-for-js | ---
+++
@@ -9,7 +9,7 @@
instance.logoutRedirect({
onRedirectNavigate: () => !BrowserUtils.isInIframe()
})
- }, []);
+ }, [ instance ]);
return (
<div>Logout</div> |
65d522903efcb34dd5250edb969e47f4e9c6d8f8 | src/mb/components/SearchBar.jsx | src/mb/components/SearchBar.jsx | import React from 'react';
import '../res/search-bar.less';
export default class SearchBar extends React.Component {
static propTypes = {
onKeywordChange: React.PropTypes.func.isRequired
}
handleChange(e) {
const value = e.target.value.trim();
this.clearChangingTimer();
this.changingTimer = setTimeout(() => {
this.props.onKeywordChange({ keyword: value !== '' ? value : null });
}, 360);
}
clearChangingTimer() {
if (this.changingTimer) {
clearTimeout(this.changingTimer);
}
this.changingTimer = null;
}
render() {
return (
<div className="mb-search-bar">
<input type="search" onChange={e => this.handleChange(e)} placeholder="影片搜索" />
<span className="octicon icon-search" />
</div>
);
}
}
| import React from 'react';
import '../res/search-bar.less';
export default class SearchBar extends React.Component {
static propTypes = {
onQueryChange: React.PropTypes.func.isRequired
}
handleChange(e) {
const value = e.target.value.trim();
this.clearChangingTimer();
this.changingTimer = setTimeout(() => {
this.props.onQueryChange({ query: value !== '' ? value : null });
}, 360);
}
clearChangingTimer() {
if (this.changingTimer) {
clearTimeout(this.changingTimer);
}
this.changingTimer = null;
}
render() {
return (
<div className="mb-search-bar">
<input type="search" onChange={e => this.handleChange(e)} placeholder="影片名或艺术家" />
<span className="octicon icon-search" />
</div>
);
}
}
| Rename keywordChange event to 'queryChange' | Rename keywordChange event to 'queryChange'
| JSX | mit | MagicCube/movie-board,MagicCube/movie-board,MagicCube/movie-board | ---
+++
@@ -4,14 +4,14 @@
export default class SearchBar extends React.Component {
static propTypes = {
- onKeywordChange: React.PropTypes.func.isRequired
+ onQueryChange: React.PropTypes.func.isRequired
}
handleChange(e) {
const value = e.target.value.trim();
this.clearChangingTimer();
this.changingTimer = setTimeout(() => {
- this.props.onKeywordChange({ keyword: value !== '' ? value : null });
+ this.props.onQueryChange({ query: value !== '' ? value : null });
}, 360);
}
@@ -25,7 +25,7 @@
render() {
return (
<div className="mb-search-bar">
- <input type="search" onChange={e => this.handleChange(e)} placeholder="影片搜索" />
+ <input type="search" onChange={e => this.handleChange(e)} placeholder="影片名或艺术家" />
<span className="octicon icon-search" />
</div>
); |
6487c98435a3c3b9fbb5a80f28b2c857f3b18741 | web/static/js/components/category_column.jsx | web/static/js/components/category_column.jsx | import React from "react"
import Idea from "./idea"
import * as AppPropTypes from "../prop_types"
import styles from "./css_modules/category_column.css"
function CategoryColumn(props) {
const categoryToEmoticonUnicodeMap = {
happy: "😊",
sad: "😥",
confused: "😕",
"action-item": "🚀",
}
const emoticonUnicode = categoryToEmoticonUnicodeMap[props.category]
const filteredIdeas = props.ideas.filter(idea => idea.category === props.category)
const filteredIdeasList = filteredIdeas.map(idea => (
<Idea
idea={idea}
key={idea.id}
currentPresence={props.currentPresence}
retroChannel={props.retroChannel}
/>
))
return (
<section className={`${props.category} ${styles.index} column`}>
<div className="ui center aligned basic segment">
<i className={styles.icon}>{emoticonUnicode}</i>
<p><strong>{props.category}</strong></p>
</div>
<div className="ui fitted divider" />
<ul className={`${props.category} ${styles.list} ideas`}>
{filteredIdeasList}
</ul>
</section>
)
}
CategoryColumn.propTypes = {
ideas: AppPropTypes.ideas.isRequired,
currentPresence: AppPropTypes.presence,
category: AppPropTypes.category.isRequired,
retroChannel: AppPropTypes.retroChannel.isRequired,
}
export default CategoryColumn
| import React from "react"
import Idea from "./idea"
import * as AppPropTypes from "../prop_types"
import styles from "./css_modules/category_column.css"
function CategoryColumn(props) {
const categoryToEmoticonUnicodeMap = {
happy: "😊",
sad: "😥",
confused: "🤔",
"action-item": "🚀",
}
const emoticonUnicode = categoryToEmoticonUnicodeMap[props.category]
const filteredIdeas = props.ideas.filter(idea => idea.category === props.category)
const filteredIdeasList = filteredIdeas.map(idea => (
<Idea
idea={idea}
key={idea.id}
currentPresence={props.currentPresence}
retroChannel={props.retroChannel}
/>
))
return (
<section className={`${props.category} ${styles.index} column`}>
<div className="ui center aligned basic segment">
<i className={styles.icon}>{emoticonUnicode}</i>
<p><strong>{props.category}</strong></p>
</div>
<div className="ui fitted divider" />
<ul className={`${props.category} ${styles.list} ideas`}>
{filteredIdeasList}
</ul>
</section>
)
}
CategoryColumn.propTypes = {
ideas: AppPropTypes.ideas.isRequired,
currentPresence: AppPropTypes.presence,
category: AppPropTypes.category.isRequired,
retroChannel: AppPropTypes.retroChannel.isRequired,
}
export default CategoryColumn
| Use thinking-face emoji for confused | Use thinking-face emoji for confused
| JSX | mit | tnewell5/remote_retro,samdec11/remote_retro,stride-nyc/remote_retro,tnewell5/remote_retro,stride-nyc/remote_retro,stride-nyc/remote_retro | ---
+++
@@ -7,7 +7,7 @@
const categoryToEmoticonUnicodeMap = {
happy: "😊",
sad: "😥",
- confused: "😕",
+ confused: "🤔",
"action-item": "🚀",
}
|
27404f1b5afee8b01d216c36ebeecba0bda02e0a | src/pages/components/ChangePasswordPage.jsx | src/pages/components/ChangePasswordPage.jsx | import Breadcrumb from 'reactstrap/lib/Breadcrumb';
import BreadcrumbItem from 'reactstrap/lib/BreadcrumbItem';
import Col from 'reactstrap/lib/Col';
import PropTypes from 'prop-types';
import React from 'react';
import Row from 'reactstrap/lib/Row';
import Container from '../../components/Container';
import HelmetTitle from '../../containers/HelmetTitle';
import Link from '../../containers/Link';
import Message from '../../containers/Message';
import ChangePasswordForm from '../../participants/containers/ChangePasswordForm';
const ChangePasswordPage = ({ translate }) => (
<Container>
<HelmetTitle title={translate('pages.changePassword')} />
<Row>
<Col md={{ size: 6, offset: 3 }}>
<h1><Message name="participants.changePassword" /></h1>
<p>
<Message name="participants.changePasswordHelp" />
</p>
<ChangePasswordForm />
</Col>
</Row>
<Breadcrumb>
<BreadcrumbItem>
<Link to="participantHome"><Message name="participants.home" /></Link>
</BreadcrumbItem>
<BreadcrumbItem active>
<Message name="orders.changeFood" />
</BreadcrumbItem>
</Breadcrumb>
</Container>
);
ChangePasswordPage.propTypes = {
translate: PropTypes.func.isRequired,
};
export default ChangePasswordPage;
| import Breadcrumb from 'reactstrap/lib/Breadcrumb';
import BreadcrumbItem from 'reactstrap/lib/BreadcrumbItem';
import Col from 'reactstrap/lib/Col';
import PropTypes from 'prop-types';
import React from 'react';
import Row from 'reactstrap/lib/Row';
import Container from '../../components/Container';
import HelmetTitle from '../../containers/HelmetTitle';
import Link from '../../containers/Link';
import Message from '../../containers/Message';
import ChangePasswordForm from '../../participants/containers/ChangePasswordForm';
const ChangePasswordPage = ({ translate }) => (
<Container>
<HelmetTitle title={translate('pages.changePassword')} />
<Row>
<Col md={{ size: 6, offset: 3 }}>
<h1><Message name="participants.changePassword" /></h1>
<p>
<Message name="participants.changePasswordHelp" />
</p>
<ChangePasswordForm />
</Col>
</Row>
<Breadcrumb>
<BreadcrumbItem>
<Link to="participantHome"><Message name="participants.home" /></Link>
</BreadcrumbItem>
<BreadcrumbItem active>
<Message name="participants.changePassword" />
</BreadcrumbItem>
</Breadcrumb>
</Container>
);
ChangePasswordPage.propTypes = {
translate: PropTypes.func.isRequired,
};
export default ChangePasswordPage;
| Fix password page breadcrumb label | Fix password page breadcrumb label
| JSX | mit | just-paja/improtresk-web,just-paja/improtresk-web | ---
+++
@@ -28,7 +28,7 @@
<Link to="participantHome"><Message name="participants.home" /></Link>
</BreadcrumbItem>
<BreadcrumbItem active>
- <Message name="orders.changeFood" />
+ <Message name="participants.changePassword" />
</BreadcrumbItem>
</Breadcrumb>
</Container> |
90bce29f3183d0f0bfd0987142c5581a7fc6173a | docs/src/Examples/Demo/KeyboardDatePicker.jsx | docs/src/Examples/Demo/KeyboardDatePicker.jsx | import React, { Fragment, PureComponent } from 'react';
import { DatePicker } from 'material-ui-pickers';
export default class BasicUsage extends PureComponent {
state = {
selectedDate: new Date(),
}
handleDateChange = (date) => {
this.setState({ selectedDate: date });
}
render() {
const { selectedDate } = this.state;
return (
<Fragment>
<div className="picker">
<DatePicker
keyboard
clearable
label="Uncontrolled input"
value={selectedDate}
onChange={this.handleDateChange}
animateYearScrolling={false}
/>
</div>
<div className="picker">
<DatePicker
keyboard
label="Masked input"
format="DD/MM/YYYY"
placeholder="10/10/2018"
mask={[/\d/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/]}
value={selectedDate}
onChange={this.handleDateChange}
animateYearScrolling={false}
/>
</div>
</Fragment>
);
}
}
| import React, { Fragment, PureComponent } from 'react';
import { DatePicker } from 'material-ui-pickers';
export default class BasicUsage extends PureComponent {
state = {
selectedDate: new Date(),
}
handleDateChange = (date) => {
this.setState({ selectedDate: date });
}
render() {
const { selectedDate } = this.state;
return (
<Fragment>
<div className="picker">
<DatePicker
keyboard
clearable
label="Uncontrolled input"
value={selectedDate}
onChange={this.handleDateChange}
animateYearScrolling={false}
/>
</div>
<div className="picker">
<DatePicker
keyboard
label="Masked input"
format="DD/MM/YYYY"
placeholder="10/10/2018"
// handle clearing outside => pass plain array if you are not controlling value outside
mask={value => (value ? [/\d/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/] : [])}
value={selectedDate}
onChange={this.handleDateChange}
animateYearScrolling={false}
/>
</div>
</Fragment>
);
}
}
| Add example of using mask as function to datepicker example | Add example of using mask as function to datepicker example
| JSX | mit | dmtrKovalenko/material-ui-pickers,callemall/material-ui,mbrookes/material-ui,mbrookes/material-ui,rscnt/material-ui,mbrookes/material-ui,oliviertassinari/material-ui,callemall/material-ui,mui-org/material-ui,rscnt/material-ui,callemall/material-ui,oliviertassinari/material-ui,mui-org/material-ui,dmtrKovalenko/material-ui-pickers,rscnt/material-ui,mui-org/material-ui,callemall/material-ui,oliviertassinari/material-ui | ---
+++
@@ -32,7 +32,8 @@
label="Masked input"
format="DD/MM/YYYY"
placeholder="10/10/2018"
- mask={[/\d/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/]}
+ // handle clearing outside => pass plain array if you are not controlling value outside
+ mask={value => (value ? [/\d/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/] : [])}
value={selectedDate}
onChange={this.handleDateChange}
animateYearScrolling={false} |
bf7c46834f27abd64d073b22a05c826f7fbe81d6 | client/src/components/HouseInventoryList.jsx | client/src/components/HouseInventoryList.jsx | import React from 'react';
import HouseInventoryListItem from './HouseInventoryListItem.jsx';
import { GridList, GridTile } from 'material-ui/GridList';
var HouseInventoryList = (props) => {
return (
<GridList cellHeight="auto" cols="4" padding={15}>
{props.items.map((item, index) =>
<HouseInventoryListItem
item = {item}
userId = {props.userId}
key = {index}
/>
)}
</GridList>
);
};
export default HouseInventoryList;
| import React from 'react';
import HouseInventoryListItem from './HouseInventoryListItem.jsx';
import { GridList, GridTile } from 'material-ui/GridList';
var HouseInventoryList = (props) => {
return (
<GridList cellHeight="auto" cols={4} padding={15}>
{props.items.map((item) =>
<HouseInventoryListItem
item={item}
userId={props.userId}
key={item.id}
submitItem={props.submitItem}
/>
)}
</GridList>
);
};
export default HouseInventoryList;
| Change key property to fix deletion bug | Change key property to fix deletion bug
| JSX | mit | SentinelsOfMagic/SentinelsOfMagic | ---
+++
@@ -4,12 +4,13 @@
var HouseInventoryList = (props) => {
return (
- <GridList cellHeight="auto" cols="4" padding={15}>
- {props.items.map((item, index) =>
+ <GridList cellHeight="auto" cols={4} padding={15}>
+ {props.items.map((item) =>
<HouseInventoryListItem
- item = {item}
- userId = {props.userId}
- key = {index}
+ item={item}
+ userId={props.userId}
+ key={item.id}
+ submitItem={props.submitItem}
/>
)}
</GridList> |
64dc6a90048090ffefdbdbf71ea3a0c069a04062 | src/components/Main.jsx | src/components/Main.jsx | import cx from 'classnames';
import React, {Component} from "react";
export default
class Main extends Component {
render () {
let {className} = this.props;
return <div {...this.props} className={cx('main', className)}/>;
}
}
| import cx from 'classnames';
import {Component, findDOMNode} from "react";
export default
class Main extends Component {
render () {
let {className} = this.props;
return <div {...this.props} className={cx('main', className)}/>;
}
componentDidUpdate() {
findDOMNode(this).scrollTop = 0;
}
}
| Reset scrollTop when change document | Reset scrollTop when change document
| JSX | mit | pirosikick/eslintrc-editor,pirosikick/eslintrc-editor | ---
+++
@@ -1,5 +1,5 @@
import cx from 'classnames';
-import React, {Component} from "react";
+import {Component, findDOMNode} from "react";
export default
class Main extends Component {
@@ -7,4 +7,8 @@
let {className} = this.props;
return <div {...this.props} className={cx('main', className)}/>;
}
+
+ componentDidUpdate() {
+ findDOMNode(this).scrollTop = 0;
+ }
} |
0901dc175d880d5c8b23221ec637b9e40b6e9598 | public/src/components/navigation.jsx | public/src/components/navigation.jsx | import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { ButtonToolbar, DropdownButton } from 'react-bootstrap';
class Navigation extends Component {
constructor(props) {
super(props);
// Bind
this.renderLinks = this.renderLinks.bind(this);
}
// Render all current links
renderLinks() {
return (
this.props.links.map((link) => {
return (
<li role="presentation" key={link.title}>
<Link tabIndex="-1" role="menuitem" to={link.href}>{link.title}</Link>
</li>
);
})
);
}
render() {
return (
<ButtonToolbar>
<DropdownButton title={this.props.title} id="menu">
{this.renderLinks()}
</DropdownButton>
</ButtonToolbar>
);
}
}
export default Navigation;
| import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { ButtonToolbar, DropdownButton } from 'react-bootstrap';
class Navigation extends Component {
constructor(props) {
super(props);
// Bind
this.renderLinks = this.renderLinks.bind(this);
}
// Render all current links
renderLinks() {
return (
this.props.links.map((link) => {
return (
<li role="presentation" key={link.title}>
<Link tabIndex="-1" role="menuitem" to={link.href}>{link.title}</Link>
</li>
);
})
);
}
render() {
return (
<ButtonToolbar>
<DropdownButton title={!!this.props.title ? this.props.title : ''} id="menu">
{this.renderLinks()}
</DropdownButton>
</ButtonToolbar>
);
}
}
export default Navigation;
| Fix null error for dropdown title | Fix null error for dropdown title
| JSX | mit | Twilio-org/phonebank,Twilio-org/phonebank | ---
+++
@@ -23,7 +23,7 @@
render() {
return (
<ButtonToolbar>
- <DropdownButton title={this.props.title} id="menu">
+ <DropdownButton title={!!this.props.title ? this.props.title : ''} id="menu">
{this.renderLinks()}
</DropdownButton>
</ButtonToolbar> |
5319bd55e409c1db428094378491731c111214e4 | imports/ui/components/events/index.jsx | imports/ui/components/events/index.jsx | import React from 'react'
import cloneChildren from '../cloneChildren'
export default (props) => (
<ol>
{props.events.map((event, idx) => (
<li key={idx} onClick={ev => props.onEventClick(ev, event)}>
<p>
<span className='bold'>{event.code}</span>
<span>{event.date && formatDate(new Date(event.date))}</span>
<span className='bold'>{event.home} X {event.away}</span>
{
!props.hideSport ? <span>{event.sport}</span> : ''
}
{
!props.hideCountry ? <span>{event.country}</span> : ''
}
<span>{event.competition}</span>
</p>
{cloneChildren(props.children, {
bets: event.bets
})}
</li>
))}
</ol>
)
function formatDate (date) {
return `${setTwoDigits(date.getDate())}/${setTwoDigits(date.getMonth() + 1)}/${date.getFullYear()}, ${setTwoDigits(date.getHours())}:${setTwoDigits(date.getMinutes())}`
}
function setTwoDigits (number) {
return number / 10 < 1 ? '0' + number : number
}
| import React from 'react'
import cloneChildren from '../cloneChildren'
export default (props) => (
<ol>
{props.events.map((event, idx) => (
<li key={idx} onClick={ev => props.onEventClick(ev, event)}>
<p>
<span className='bold'>{event.code}</span>
<span>{event.date && formatDate(new Date(event.date))}</span>
<span className='bold'>{event.home} X {event.away}</span>
{
!props.hideSport ? <span>{event.sport}</span> : ''
}
{
!props.hideCountry ? <span>{event.country}</span> : ''
}
<span>{event.competition}</span>
</p>
{cloneChildren(props.children, {
bets: event.bets
})}
</li>
))}
</ol>
)
function formatDate (date) {
return `${setTodayTomorrowOrDate(date)}, ${setTwoDigits(date.getHours())}:${setTwoDigits(date.getMinutes())}`
}
function setTodayTomorrowOrDate (date) {
const now = new Date()
if (now.getMonth() === date.getMonth() && now.getFullYear() === date.getFullYear()) {
const diff = now.getDate() - date.getDate()
if (diff === 0) {
return 'Hoje'
} else if (diff === -1) {
return 'Amanhã'
}
}
return `${setTwoDigits(date.getDate())}/${setTwoDigits(date.getMonth() + 1)}/${date.getFullYear()}`
}
function setTwoDigits (number) {
return number / 10 < 1 ? '0' + number : number
}
| Format events' date: show 'Today' or 'Tomorrow' if applicable. | Format events' date: show 'Today' or 'Tomorrow' if applicable.
| JSX | mit | LuisLoureiro/placard-wrapper | ---
+++
@@ -27,7 +27,23 @@
)
function formatDate (date) {
- return `${setTwoDigits(date.getDate())}/${setTwoDigits(date.getMonth() + 1)}/${date.getFullYear()}, ${setTwoDigits(date.getHours())}:${setTwoDigits(date.getMinutes())}`
+ return `${setTodayTomorrowOrDate(date)}, ${setTwoDigits(date.getHours())}:${setTwoDigits(date.getMinutes())}`
+}
+
+function setTodayTomorrowOrDate (date) {
+ const now = new Date()
+
+ if (now.getMonth() === date.getMonth() && now.getFullYear() === date.getFullYear()) {
+ const diff = now.getDate() - date.getDate()
+
+ if (diff === 0) {
+ return 'Hoje'
+ } else if (diff === -1) {
+ return 'Amanhã'
+ }
+ }
+
+ return `${setTwoDigits(date.getDate())}/${setTwoDigits(date.getMonth() + 1)}/${date.getFullYear()}`
}
function setTwoDigits (number) { |
831ae9a7779283ecc5695c81b7dcf89006a5544a | test/client/spec/components/ecology.spec.jsx | test/client/spec/components/ecology.spec.jsx | /**
* Client tests
*/
import React from "react/addons";
import Component from "src/components/ecology";
// Use `TestUtils` to inject into DOM, simulate events, etc.
// See: https://facebook.github.io/react/docs/test-utils.html
const TestUtils = React.addons.TestUtils;
describe("components/ecology", function () {
it("has expected content with shallow render", function () {
// This is a "shallow" render that renders only the current component
// without using the actual DOM.
//
// https://facebook.github.io/react/docs/test-utils.html#shallow-rendering
const renderer = TestUtils.createRenderer();
renderer.render(<Component />);
const output = renderer.getRenderOutput();
expect(output.type).to.equal("div");
});
});
| /**
* Client tests
*/
import React from "react/addons";
import Ecology from "src/components/ecology";
// Use `TestUtils` to inject into DOM, simulate events, etc.
// See: https://facebook.github.io/react/docs/test-utils.html
const TestUtils = React.addons.TestUtils;
describe("components/ecology", function () {
it("has expected content with shallow render", function () {
// This is a "shallow" render that renders only the current component
// without using the actual DOM.
//
// https://facebook.github.io/react/docs/test-utils.html#shallow-rendering
const renderer = TestUtils.createRenderer();
renderer.render(<Ecology />);
const output = renderer.getRenderOutput();
expect(output.type).to.equal("div");
});
});
| Rename Ecology component under test | Rename Ecology component under test
| JSX | mit | FormidableLabs/ecology,aurelienshz/ecology,FormidableLabs/ecology,aurelienshz/ecology | ---
+++
@@ -2,7 +2,7 @@
* Client tests
*/
import React from "react/addons";
-import Component from "src/components/ecology";
+import Ecology from "src/components/ecology";
// Use `TestUtils` to inject into DOM, simulate events, etc.
// See: https://facebook.github.io/react/docs/test-utils.html
@@ -16,7 +16,7 @@
//
// https://facebook.github.io/react/docs/test-utils.html#shallow-rendering
const renderer = TestUtils.createRenderer();
- renderer.render(<Component />);
+ renderer.render(<Ecology />);
const output = renderer.getRenderOutput();
expect(output.type).to.equal("div");
}); |
28421cfd127977e36a7fdeb26300ebba69b40902 | web/static/js/components/category_column.jsx | web/static/js/components/category_column.jsx | import React from "react"
import styles from "./css_modules/category_column.css"
function CategoryColumn(props) {
const categoryToEmoticonUnicodeMap = {
happy: "😊",
sad: "😥",
confused: "😕",
"action-item": "🚀",
}
const emoticonUnicode = categoryToEmoticonUnicodeMap[props.category]
const filteredIdeas = props.ideas.filter(idea => idea.category === props.category)
const filteredIdeasList = filteredIdeas.map(idea =>
<li className="item" title={idea.body} key={`${idea.body}`}>{idea.body}</li>,
)
return (
<section className="column">
<div className="ui center aligned basic segment">
<i className={styles.icon}>{emoticonUnicode}</i>
<p><a>@{props.category}</a></p>
</div>
<div className="ui divider" />
<ul className={`${props.category} ideas ui divided list`}>
{filteredIdeasList}
</ul>
</section>
)
}
CategoryColumn.propTypes = {
ideas: React.PropTypes.arrayOf(
React.PropTypes.shape({
category: React.PropTypes.string,
body: React.PropTypes.string,
}),
).isRequired,
category: React.PropTypes.string.isRequired,
}
export default CategoryColumn
| import React from "react"
import styles from "./css_modules/category_column.css"
function CategoryColumn(props) {
const categoryToEmoticonUnicodeMap = {
happy: "😊",
sad: "😥",
confused: "😕",
"action-item": "🚀",
}
const emoticonUnicode = categoryToEmoticonUnicodeMap[props.category]
const filteredIdeas = props.ideas.filter(idea => idea.category === props.category)
const filteredIdeasList = filteredIdeas.map(idea =>
<li className="item" title={idea.body} key={idea.id}>{idea.body}</li>,
)
return (
<section className="column">
<div className="ui center aligned basic segment">
<i className={styles.icon}>{emoticonUnicode}</i>
<p><a>@{props.category}</a></p>
</div>
<div className="ui divider" />
<ul className={`${props.category} ideas ui divided list`}>
{filteredIdeasList}
</ul>
</section>
)
}
CategoryColumn.propTypes = {
ideas: React.PropTypes.arrayOf(
React.PropTypes.shape({
category: React.PropTypes.string,
body: React.PropTypes.string,
}),
).isRequired,
category: React.PropTypes.string.isRequired,
}
export default CategoryColumn
| Use primary key as listItem's key attribute to allow ideas with duplicate body attributes | Use primary key as listItem's key attribute to allow ideas with duplicate body attributes
| JSX | mit | stride-nyc/remote_retro,stride-nyc/remote_retro,tnewell5/remote_retro,stride-nyc/remote_retro,samdec11/remote_retro,tnewell5/remote_retro | ---
+++
@@ -12,7 +12,7 @@
const emoticonUnicode = categoryToEmoticonUnicodeMap[props.category]
const filteredIdeas = props.ideas.filter(idea => idea.category === props.category)
const filteredIdeasList = filteredIdeas.map(idea =>
- <li className="item" title={idea.body} key={`${idea.body}`}>{idea.body}</li>,
+ <li className="item" title={idea.body} key={idea.id}>{idea.body}</li>,
)
return ( |
0fb81065fa9bb64b9e4cbc4374ceea60bad481ab | docs/components/EditableExample.jsx | docs/components/EditableExample.jsx | var React = require('react')
, ReactDOM = require('react-dom')
, Playground = require('@monastic.panic/component-playground/Playground')
, ReactWidgets = require('../../src/index')
, MultiselectTagList = require('react-widgets/MultiselectTagList')
, List = require('react-widgets/List')
, genData = require('./generate-data');
var scope = {
ReactWidgets: { ...ReactWidgets, MultiselectTagList, List },
listOfPeople(){
return genData(15)
},
React,
ReactDOM
}
module.exports = React.createClass({
render() {
return (
<Playground
{...this.props}
mode='jsx'
theme='oceanicnext'
scope={scope}
/>
);
}
});
| var React = require('react')
, ReactDOM = require('react-dom')
, Playground = require('@monastic.panic/component-playground/Playground')
, ReactWidgets = require('../../src/index')
, MultiselectTagList = require('react-widgets/MultiselectTagList')
, List = require('react-widgets/List')
, genData = require('./generate-data');
var scope = {
ReactWidgets: { ...ReactWidgets, MultiselectTagList, List },
listOfPeople(){
return genData(15)
},
React,
ReactDOM
}
module.exports = React.createClass({
render() {
let { codeText, ...props } = this.props;
return (
<Playground
{...props}
codeText={codeText.trim()}
mode='jsx'
theme='oceanicnext'
scope={scope}
/>
);
}
});
| Trim leading blank line from code examples | Trim leading blank line from code examples
| JSX | mit | haneev/react-widgets,jquense/react-widgets,haneev/react-widgets,jquense/react-widgets,jquense/react-widgets | ---
+++
@@ -18,9 +18,11 @@
module.exports = React.createClass({
render() {
+ let { codeText, ...props } = this.props;
return (
<Playground
- {...this.props}
+ {...props}
+ codeText={codeText.trim()}
mode='jsx'
theme='oceanicnext'
scope={scope} |
84c1b5c8deb20ed2b7d3ad62b2b307f5983c5a28 | waartaa/client/app/containers/login/LoginController.jsx | waartaa/client/app/containers/login/LoginController.jsx | import React, {Component, PropTypes} from 'react';
import ActionAndroid from 'material-ui/svg-icons/action/android';
import RaisedButton from 'material-ui/RaisedButton';
import userManager from '../../helpers/oidcHelpers.jsx';
import LoginForm from '../forms/LoginForm';
export default class LoginController extends Component {
onFASLoginButtonClick = (event) => {
event.preventDefault();
userManager.signinRedirect();
};
handleSubmit = (event) => {
event.preventDefault();
console.log('form submitted')
};
render() {
return (
<div>
<RaisedButton
label="Login with FAS"
icon={<ActionAndroid/>}
onMouseUp={this.onFASLoginButtonClick}
/>
<LoginForm handleSubmit={this.handleSubmit} submitting={false} />
</div>
);
}
}
| import React, {Component, PropTypes} from 'react';
import ActionAndroid from 'material-ui/svg-icons/action/android';
import RaisedButton from 'material-ui/RaisedButton';
import userManager from '../../helpers/oidcHelpers.jsx';
import LoginForm from '../forms/LoginForm';
export default class LoginController extends Component {
onFASLoginButtonClick = (event) => {
event.preventDefault();
userManager.signinRedirect();
};
handleSubmit = (event) => {
event.preventDefault();
console.log('form submitted')
};
render() {
return (
<div>
<LoginForm handleSubmit={this.handleSubmit} submitting={false} />
</div>
);
}
}
| Remove unused FAS login button from login container. | Remove unused FAS login button from login container.
| JSX | mit | waartaa/waartaa,waartaa/waartaa,waartaa/waartaa | ---
+++
@@ -20,11 +20,6 @@
render() {
return (
<div>
- <RaisedButton
- label="Login with FAS"
- icon={<ActionAndroid/>}
- onMouseUp={this.onFASLoginButtonClick}
- />
<LoginForm handleSubmit={this.handleSubmit} submitting={false} />
</div>
); |
3e52bc7fc520079fde91bef0c860de19904e5b4a | src/components/navigation/conference/2018/navigation.jsx | src/components/navigation/conference/2018/navigation.jsx | var React = require('react');
var NavigationBox = require('../../base/navigation.jsx');
require('./navigation.scss');
var Navigation = React.createClass({
type: 'Navigation',
render: function () {
return (
<NavigationBox>
<ul className="ul mod-2018">
<li className="li-left mod-logo mod-2018">
<a href="/conference" className="logo-a">
<img
src="/images/logo_sm.png"
alt="Scratch Logo"
className="logo-a-image"
/>
<p className="logo-a-title">Conferences</p>
</a>
</li>
</ul>
</NavigationBox>
);
}
});
module.exports = Navigation;
| var React = require('react');
var NavigationBox = require('../../base/navigation.jsx');
require('./navigation.scss');
var Navigation = React.createClass({
type: 'Navigation',
render: function () {
return (
<NavigationBox>
<ul className="ul mod-2018">
<li className="li-left mod-logo mod-2018">
<a href="/" className="logo-a">
<img
src="/images/logo_sm.png"
alt="Scratch Logo"
className="logo-a-image"
/>
<p className="logo-a-title">Conferences</p>
</a>
</li>
</ul>
</NavigationBox>
);
}
});
module.exports = Navigation;
| Make Conference logo button link to homepage. | Make Conference logo button link to homepage. | JSX | bsd-3-clause | LLK/scratch-www,LLK/scratch-www | ---
+++
@@ -11,7 +11,7 @@
<NavigationBox>
<ul className="ul mod-2018">
<li className="li-left mod-logo mod-2018">
- <a href="/conference" className="logo-a">
+ <a href="/" className="logo-a">
<img
src="/images/logo_sm.png"
alt="Scratch Logo" |
55016a4d7f87fa2d5209a2e30c84434558b27616 | app/assets/javascripts/components/common/rocket_chat.jsx | app/assets/javascripts/components/common/rocket_chat.jsx | import React from 'react';
const RocketChat = React.createClass({
displayName: 'RocketChat',
getInitialState() {
return { loggedIn: true };
},
render() {
let chatFrame;
if (this.state.loggedIn) {
chatFrame = <iframe style={{ display: 'block', width: '100%', height: '1000px' }} src="https://dashboardchat.wmflabs.org/" />;
}
return (
<div className="modal">
{chatFrame}
</div>
);
}
});
export default RocketChat;
| import React from 'react';
const RocketChat = React.createClass({
displayName: 'RocketChat',
getInitialState() {
return { showChat: false };
},
login() {
this.setState({ showChat: true });
// TODO:
// If possible, start by checking if the user is already logged in to RocketChat.
// If not, proceed with login flow.
// First, request auth token from dashboard server
// On success, use that token to log in:
document.querySelector('iframe').contentWindow.postMessage({
externalCommand: 'login-with-token',
token: 'TOKEN-FROM-SERVER'
}, '*');
// Verify login success
this.setState({ loggedIn: true });
},
render() {
let chatFrame;
// TODO: Hide chat until login succeeds.
if (this.state.showChat) {
chatFrame = <iframe id="chat" style={{ display: 'block', width: '100%', height: '1000px' }} src="https://dashboardchat.wmflabs.org/channel/general?layout=embedded" />;
}
return (
<div className="modal">
<button className="button dark" onClick={this.login} >Chat!</button>
{chatFrame}
</div>
);
}
});
export default RocketChat;
| Add chat login, sketch out next steps | Add chat login, sketch out next steps
| JSX | mit | WikiEducationFoundation/WikiEduDashboard,alpha721/WikiEduDashboard,WikiEducationFoundation/WikiEduDashboard,KarmaHater/WikiEduDashboard,majakomel/WikiEduDashboard,WikiEducationFoundation/WikiEduDashboard,alpha721/WikiEduDashboard,majakomel/WikiEduDashboard,sejalkhatri/WikiEduDashboard,sejalkhatri/WikiEduDashboard,WikiEducationFoundation/WikiEduDashboard,WikiEducationFoundation/WikiEduDashboard,KarmaHater/WikiEduDashboard,KarmaHater/WikiEduDashboard,alpha721/WikiEduDashboard,sejalkhatri/WikiEduDashboard,alpha721/WikiEduDashboard,KarmaHater/WikiEduDashboard,majakomel/WikiEduDashboard,sejalkhatri/WikiEduDashboard,majakomel/WikiEduDashboard,sejalkhatri/WikiEduDashboard | ---
+++
@@ -4,18 +4,36 @@
displayName: 'RocketChat',
getInitialState() {
- return { loggedIn: true };
+ return { showChat: false };
+ },
+
+ login() {
+ this.setState({ showChat: true });
+
+ // TODO:
+ // If possible, start by checking if the user is already logged in to RocketChat.
+ // If not, proceed with login flow.
+ // First, request auth token from dashboard server
+
+ // On success, use that token to log in:
+ document.querySelector('iframe').contentWindow.postMessage({
+ externalCommand: 'login-with-token',
+ token: 'TOKEN-FROM-SERVER'
+ }, '*');
+ // Verify login success
+ this.setState({ loggedIn: true });
},
render() {
let chatFrame;
- if (this.state.loggedIn) {
- chatFrame = <iframe style={{ display: 'block', width: '100%', height: '1000px' }} src="https://dashboardchat.wmflabs.org/" />;
+ // TODO: Hide chat until login succeeds.
+ if (this.state.showChat) {
+ chatFrame = <iframe id="chat" style={{ display: 'block', width: '100%', height: '1000px' }} src="https://dashboardchat.wmflabs.org/channel/general?layout=embedded" />;
}
return (
-
<div className="modal">
+ <button className="button dark" onClick={this.login} >Chat!</button>
{chatFrame}
</div>
); |
9f9e99686f4f798ef6ee30bf55c554137c1f15e6 | app/assets/javascripts/components/posts/posts_index.js.jsx | app/assets/javascripts/components/posts/posts_index.js.jsx | var PostList = require('./post_list.js.jsx');
var PostsStore = require('../../stores/posts_store');
var ProductStore = require('../../stores/product_store');
var PostsIndex = React.createClass({
displayName: 'PostsIndex',
propTypes: {
initialPosts: React.PropTypes.array.isRequired
},
componentDidMount: function() {
PostsStore.addChangeListener(this.getPosts);
},
getDefaultProps: function() {
var product = ProductStore.getProduct();
if (!product.slug) {
console.warn('No product slug found when initializing PostsIndex. Has the ProductStore been initialized?');
}
return {
initialPosts: PostsStore.getPosts(product.slug),
product: product
};
},
getInitialState: function() {
return {
posts: this.props.initialPosts
};
},
getPosts: function() {
this.setState({
posts: PostsStore.getPosts(this.props.product.slug)
});
},
render: function() {
return (
<div>
{this.renderPosts()}
</div>
);
},
renderPosts: function() {
var posts = this.state.posts;
var product = this.props.product;
if (!posts.length) {
return [
<h4 className="text-muted" key="heading">
There don't seem to be any posts here
</h4>,
<p key="explanation">
{"Blog posts by " + product.name + "'s partners will appear here just as soon as they're written."}
</p>
];
}
return <PostList posts={posts} />;
},
});
module.exports = window.PostsIndex = PostsIndex;
| var PostList = require('./post_list.js.jsx');
var PostsStore = require('../../stores/posts_store');
var ProductStore = require('../../stores/product_store');
var PostsIndex = React.createClass({
displayName: 'PostsIndex',
propTypes: {
initialPosts: React.PropTypes.array.isRequired
},
componentDidMount: function() {
PostsStore.addChangeListener(this.getPosts);
},
getDefaultProps: function() {
var product = ProductStore.getProduct();
if (!product) {
return {}
}
return {
initialPosts: PostsStore.getPosts(product.slug),
product: product
};
},
getInitialState: function() {
return {
posts: this.props.initialPosts
};
},
getPosts: function() {
this.setState({
posts: PostsStore.getPosts(this.props.product.slug)
});
},
render: function() {
return (
<div>
{this.renderPosts()}
</div>
);
},
renderPosts: function() {
var posts = this.state.posts;
var product = this.props.product;
if (!posts.length) {
return [
<h4 className="text-muted" key="heading">
There don't seem to be any posts here
</h4>,
<p key="explanation">
{"Blog posts by " + product.name + "'s partners will appear here just as soon as they're written."}
</p>
];
}
return <PostList posts={posts} />;
},
});
module.exports = window.PostsIndex = PostsIndex;
| Fix getDefaultProps for non product pages | Fix getDefaultProps for non product pages
| JSX | agpl-3.0 | lachlanjc/meta,assemblymade/meta,lachlanjc/meta,assemblymade/meta,assemblymade/meta,lachlanjc/meta,lachlanjc/meta,assemblymade/meta | ---
+++
@@ -15,8 +15,8 @@
getDefaultProps: function() {
var product = ProductStore.getProduct();
- if (!product.slug) {
- console.warn('No product slug found when initializing PostsIndex. Has the ProductStore been initialized?');
+ if (!product) {
+ return {}
}
return { |
f0eb141a384d953a8e14f641bc6946a414a1c81f | src/drive/web/modules/services/components/Embeder.jsx | src/drive/web/modules/services/components/Embeder.jsx | import React from 'react'
import { Spinner, IntentHeader } from 'cozy-ui/transpiled/react'
import FileOpener from 'drive/web/modules/viewer/FileOpenerExternal'
import { IconSprite } from 'cozy-ui/transpiled/react/'
class Embeder extends React.Component {
constructor(props) {
super(props)
this.state = {
loading: true
}
}
componentDidMount() {
this.fetchFileUrl()
}
async fetchFileUrl() {
const { service } = this.props
try {
const { id } = service.getData()
this.setState({ fileId: id, loading: false })
} catch (error) {
this.setState({ error, loading: false })
}
}
render() {
return (
<div>
<IntentHeader appName="Drive" appEditor="Cozy" />
{this.state.loading && (
<Spinner size="xxlarge" loadingType="message" middle />
)}
{this.state.error && (
<pre className="u-error">{this.state.error.toString()}</pre>
)}
{this.state.fileId && (
<FileOpener fileId={this.state.fileId} withCloseButtton={false} />
)}
<IconSprite />
</div>
)
}
}
export default Embeder
| import React from 'react'
import { Spinner, IntentHeader } from 'cozy-ui/transpiled/react'
import FileOpenerExternal from 'drive/web/modules/viewer/FileOpenerExternal'
import { IconSprite } from 'cozy-ui/transpiled/react/'
class Embeder extends React.Component {
constructor(props) {
super(props)
this.state = {
loading: true
}
}
componentDidMount() {
this.fetchFileUrl()
}
async fetchFileUrl() {
const { service } = this.props
try {
const { id } = service.getData()
this.setState({ fileId: id, loading: false })
} catch (error) {
this.setState({ error, loading: false })
}
}
render() {
return (
<div>
<IntentHeader appName="Drive" appEditor="Cozy" />
{this.state.loading && (
<Spinner size="xxlarge" loadingType="message" middle />
)}
{this.state.error && (
<pre className="u-error">{this.state.error.toString()}</pre>
)}
{this.state.fileId && (
<FileOpenerExternal
fileId={this.state.fileId}
withCloseButtton={false}
/>
)}
<IconSprite />
</div>
)
}
}
export default Embeder
| Rename component to avoid confusion with FileOpener | refactor: Rename component to avoid confusion with FileOpener
| JSX | agpl-3.0 | nono/cozy-files-v3,nono/cozy-files-v3,nono/cozy-files-v3,nono/cozy-files-v3 | ---
+++
@@ -1,6 +1,6 @@
import React from 'react'
import { Spinner, IntentHeader } from 'cozy-ui/transpiled/react'
-import FileOpener from 'drive/web/modules/viewer/FileOpenerExternal'
+import FileOpenerExternal from 'drive/web/modules/viewer/FileOpenerExternal'
import { IconSprite } from 'cozy-ui/transpiled/react/'
class Embeder extends React.Component {
@@ -38,7 +38,10 @@
<pre className="u-error">{this.state.error.toString()}</pre>
)}
{this.state.fileId && (
- <FileOpener fileId={this.state.fileId} withCloseButtton={false} />
+ <FileOpenerExternal
+ fileId={this.state.fileId}
+ withCloseButtton={false}
+ />
)}
<IconSprite />
</div> |
3913e5377bd9b417c9d075383248cc79e7b5cf91 | src/components/CLIWrapper/CLIWrapper.jsx | src/components/CLIWrapper/CLIWrapper.jsx | import React, { PureComponent } from 'react';
import { Link, routerShape } from 'react-router';
import docs from '../../docs';
import CLIDoc from '../CLIDoc';
import { PrimarySection, SubtronSection } from '../PageSections';
import styles from './CLIWrapper.scss';
export default class CLIWrapper extends PureComponent {
static propTypes = {
router: routerShape,
};
render() {
const { router: { params: { command } } } = this.props;
return (
<div>
<SubtronSection title="CLI Docs">
Documention for Electron Forge's CLI interface
</SubtronSection>
<PrimarySection>
<div className={styles.container}>
<div className={styles.commandList}>
<h3>Commands</h3>
{
docs.map(doc => (
<div key={doc.command} className={styles.commandLink}>
<Link to={`/cli/${doc.command}`}>
{doc.command}
</Link>
</div>
))
}
</div>
<div className={styles.commandDocs}>
{
command ?
<CLIDoc doc={docs.find(doc => doc.command === command)} /> :
<div className={styles.noCommand}>
<h1>Choose a Command</h1>
<p>To view the docs for a command, select it on the left</p>
</div>
}
</div>
</div>
</PrimarySection>
</div>
);
}
}
| import React, { PureComponent } from 'react';
import { Link, routerShape } from 'react-router';
import docs from '../../docs';
import CLIDoc from '../CLIDoc';
import { PrimarySection, SubtronSection } from '../PageSections';
import styles from './CLIWrapper.scss';
export default class CLIWrapper extends PureComponent {
static propTypes = {
router: routerShape,
};
render() {
const { router: { params: { command } } } = this.props;
const targetDoc = docs.find(doc => doc.command === command);
return (
<div>
<SubtronSection title="CLI Docs">
Documention for Electron Forge's CLI interface
</SubtronSection>
<PrimarySection>
<div className={styles.container}>
<div className={styles.commandList}>
<h3>Commands</h3>
{
docs.map(doc => (
<div key={doc.command} className={styles.commandLink}>
<Link to={`/cli/${doc.command}`}>
{doc.command}
</Link>
</div>
))
}
</div>
<div className={styles.commandDocs}>
{
targetDoc ?
<CLIDoc doc={targetDoc} /> :
<div className={styles.noCommand}>
<h1>Choose a Command</h1>
<p>To view the docs for a command, select it on the left</p>
</div>
}
</div>
</div>
</PrimarySection>
</div>
);
}
}
| Fix unknown CLI command page | Fix unknown CLI command page
| JSX | mit | MarshallOfSound/electronforge.io,MarshallOfSound/electronforge.io | ---
+++
@@ -14,6 +14,7 @@
render() {
const { router: { params: { command } } } = this.props;
+ const targetDoc = docs.find(doc => doc.command === command);
return (
<div>
@@ -36,8 +37,8 @@
</div>
<div className={styles.commandDocs}>
{
- command ?
- <CLIDoc doc={docs.find(doc => doc.command === command)} /> :
+ targetDoc ?
+ <CLIDoc doc={targetDoc} /> :
<div className={styles.noCommand}>
<h1>Choose a Command</h1>
<p>To view the docs for a command, select it on the left</p> |
5bb96541271db58f7def52692f53a0df81ccac12 | web/src/components/pages/User/UserView.jsx | web/src/components/pages/User/UserView.jsx | import React, { Component } from 'react';
import { PropTypes } from 'react';
export default class UserView extends Component {
constructor(props, context) {
super(props, context);
this.state = {
user: { username: "", age: "" }
};
this.onUserNameChange = this.onUserNameChange.bind(this);
this.onUserAgeChange = this.onUserAgeChange.bind(this);
this.onClickSave = this.onClickSave.bind(this);
}
onUserNameChange(event) {
const user = this.state.user;
user.username = event.target.value;
this.setState({ user: user });
}
onUserAgeChange(event) {
const user = this.state.user;
user.age = event.target.value;
this.setState({ user: user });
}
onClickSave() {
this.props.actions.saveUser(this.state.user);
}
render() {
return (
<div>
<h2>Add User</h2>
<input
type="text"
onChange={this.onUserNameChange}
value={this.state.user.username} />
<input
type="number"
onChange={this.onUserAgeChange}
value={this.state.user.age} />
<input
type="submit"
value="Save"
onClick={this.onClickSave} />
</div>
);
}
}
| import React, { Component } from 'react';
import { PropTypes } from 'react';
export default class UserView extends Component {
constructor(props, context) {
super(props, context);
this.state = {
user: { username: "", age: "" }
};
this.onUserNameChange = this.onUserNameChange.bind(this);
this.onUserAgeChange = this.onUserAgeChange.bind(this);
this.onClickSave = this.onClickSave.bind(this);
}
onUserNameChange(event) {
const user = this.state.user;
user.username = event.target.value;
this.setState({ user: user });
}
onUserAgeChange(event) {
const user = this.state.user;
user.age = event.target.value;
this.setState({ user: user });
}
onClickSave() {
this.props.actions.saveUser(this.state.user);
}
render() {
return (
<div>
<h2>Add User</h2>
<input
type="text"
onChange={this.onUserNameChange}
value={this.state.user.username} />
<input
type="number"
onChange={this.onUserAgeChange}
value={this.state.user.age} />
<input
type="submit"
value="Save"
onClick={this.onClickSave} />
</div>
);
}
}
| Replace 4 spaces with 2 spacees | Replace 4 spaces with 2 spacees
| JSX | mit | RailsRoading/wissle,RailsRoading/wissle,RailsRoading/wissle | ---
+++
@@ -2,49 +2,49 @@
import { PropTypes } from 'react';
export default class UserView extends Component {
- constructor(props, context) {
- super(props, context);
+ constructor(props, context) {
+ super(props, context);
- this.state = {
- user: { username: "", age: "" }
- };
+ this.state = {
+ user: { username: "", age: "" }
+ };
- this.onUserNameChange = this.onUserNameChange.bind(this);
- this.onUserAgeChange = this.onUserAgeChange.bind(this);
- this.onClickSave = this.onClickSave.bind(this);
- }
- onUserNameChange(event) {
- const user = this.state.user;
- user.username = event.target.value;
- this.setState({ user: user });
- }
- onUserAgeChange(event) {
- const user = this.state.user;
- user.age = event.target.value;
- this.setState({ user: user });
- }
- onClickSave() {
- this.props.actions.saveUser(this.state.user);
- }
- render() {
- return (
- <div>
- <h2>Add User</h2>
- <input
- type="text"
- onChange={this.onUserNameChange}
- value={this.state.user.username} />
+ this.onUserNameChange = this.onUserNameChange.bind(this);
+ this.onUserAgeChange = this.onUserAgeChange.bind(this);
+ this.onClickSave = this.onClickSave.bind(this);
+ }
+ onUserNameChange(event) {
+ const user = this.state.user;
+ user.username = event.target.value;
+ this.setState({ user: user });
+ }
+ onUserAgeChange(event) {
+ const user = this.state.user;
+ user.age = event.target.value;
+ this.setState({ user: user });
+ }
+ onClickSave() {
+ this.props.actions.saveUser(this.state.user);
+ }
+ render() {
+ return (
+ <div>
+ <h2>Add User</h2>
+ <input
+ type="text"
+ onChange={this.onUserNameChange}
+ value={this.state.user.username} />
- <input
- type="number"
- onChange={this.onUserAgeChange}
- value={this.state.user.age} />
+ <input
+ type="number"
+ onChange={this.onUserAgeChange}
+ value={this.state.user.age} />
- <input
- type="submit"
- value="Save"
- onClick={this.onClickSave} />
- </div>
- );
- }
+ <input
+ type="submit"
+ value="Save"
+ onClick={this.onClickSave} />
+ </div>
+ );
+ }
} |
a9fdac23e39c7f9a9fd7ba4c94f0abde847092cd | src/components/admin/article/components/ArticlePreview.jsx | src/components/admin/article/components/ArticlePreview.jsx | import ArticleBody from 'components/main/ArticleBody';
import React from 'react';
const ArticlePreview = props => (
<div className="article">
<ArticleBody {...props} />
</div>
);
ArticlePreview.propTypes = ArticleBody.propTypes;
export default ArticlePreview;
| import ArticleBody from 'components/main/ArticleBody';
import React from 'react';
const ArticlePreview = props => (
<div className="article" style={{ marginTop: '20px' }}>
<ArticleBody {...props} />
</div>
);
ArticlePreview.propTypes = ArticleBody.propTypes;
export default ArticlePreview;
| Increase top margin in preview | Increase top margin in preview
| JSX | mit | thegazelle-ad/gazelle-server,thegazelle-ad/gazelle-server,thegazelle-ad/gazelle-front-end,thegazelle-ad/gazelle-front-end,thegazelle-ad/gazelle-server,thegazelle-ad/gazelle-server,thegazelle-ad/gazelle-server | ---
+++
@@ -2,7 +2,7 @@
import React from 'react';
const ArticlePreview = props => (
- <div className="article">
+ <div className="article" style={{ marginTop: '20px' }}>
<ArticleBody {...props} />
</div>
); |
e9046cd448f57d035c9891dd40746b993cb0ec67 | app/scripts/modules/payments/components/payment-create.jsx | app/scripts/modules/payments/components/payment-create.jsx | 'use strict';
var React = require('react');
var PaymentHistory = React.createClass({
componentDidMount: function() {
this.props.model.on('change', function() {
// ???
});
},
componentWillUnmout: function() {
this.props.model.off('change');
},
render: function() {
return ();
}
});
module.exports = PaymentHistory;
| 'use strict';
var React = require('react');
var Navigation = require('react-router').Navigation;
var Input = require('react-bootstrap').Input;
var Button = require('react-bootstrap').Button;
var paymentActions = require('../actions');
var PaymentHistory = React.createClass({
mixins: [Navigation],
formatInput: function(rawInputRef, type) {
var formattedInput = rawInputRef.getValue().trim();
return type === 'number' ? formattedInput * 1 : formattedInput;
},
handleSubmit: function(e) {
e.preventDefault();
var payment = {
address: this.formatInput(this.refs.address, 'string'),
amount: this.formatInput(this.refs.amount, 'number'),
currency: this.formatInput(this.refs.currency, 'string'),
destinationTag: this.formatInput(this.refs.destinationTag, 'number') || null,
sourceTag: this.formatInput(this.refs.sourceTag, 'number') || null, // not implemented yet
invoiceId: this.formatInput(this.refs.invoiceId, 'string') || null, // not implemented yet
memo: this.formatInput(this.refs.memo, 'string') || null // not implemented yet
};
paymentActions.sendPayment(payment);
},
componentDidMount: function() {
var _this = this;
this.props.model.on('sync', function() {
_this.transitionTo('/payments/outgoing');
});
this.props.model.on('addNewSentPayment', function(payment) {
paymentActions.addNewSentPayment(payment);
});
},
render: function() {
return (
<div>
<h2>Send Payment</h2>
<form onSubmit={this.handleSubmit}>
<Input type="text" ref="address" label="Destination Address:" required />
<Input type="text" ref="destinationTag" label="Destination Tag:" />
<Input type="text" ref="sourceTag" label="Source Tag:" />
<Input type="text" ref="invoiceId" label="Invoice Id:" />
<Input type="text" ref="amount" label="Amount:" required />
<Input type="text" ref="currency" label="Currency:" required />
<Input type="textarea" ref="memo" label="Memo:" />
<Button bsStyle="primary" type="submit">Submit Payment</Button>
</form>
</div>
);
}
});
module.exports = PaymentHistory;
| Create form for sending payments | [TASK] Create form for sending payments
| JSX | isc | dabibbit/dream-stack-seed,dabibbit/dream-stack-seed | ---
+++
@@ -1,20 +1,64 @@
'use strict';
var React = require('react');
+var Navigation = require('react-router').Navigation;
+var Input = require('react-bootstrap').Input;
+var Button = require('react-bootstrap').Button;
+var paymentActions = require('../actions');
var PaymentHistory = React.createClass({
+ mixins: [Navigation],
+
+ formatInput: function(rawInputRef, type) {
+ var formattedInput = rawInputRef.getValue().trim();
+
+ return type === 'number' ? formattedInput * 1 : formattedInput;
+ },
+
+ handleSubmit: function(e) {
+ e.preventDefault();
+
+ var payment = {
+ address: this.formatInput(this.refs.address, 'string'),
+ amount: this.formatInput(this.refs.amount, 'number'),
+ currency: this.formatInput(this.refs.currency, 'string'),
+ destinationTag: this.formatInput(this.refs.destinationTag, 'number') || null,
+ sourceTag: this.formatInput(this.refs.sourceTag, 'number') || null, // not implemented yet
+ invoiceId: this.formatInput(this.refs.invoiceId, 'string') || null, // not implemented yet
+ memo: this.formatInput(this.refs.memo, 'string') || null // not implemented yet
+ };
+
+ paymentActions.sendPayment(payment);
+ },
+
componentDidMount: function() {
- this.props.model.on('change', function() {
- // ???
+ var _this = this;
+
+ this.props.model.on('sync', function() {
+ _this.transitionTo('/payments/outgoing');
+ });
+
+ this.props.model.on('addNewSentPayment', function(payment) {
+ paymentActions.addNewSentPayment(payment);
});
},
- componentWillUnmout: function() {
- this.props.model.off('change');
- },
-
render: function() {
- return ();
+ return (
+ <div>
+ <h2>Send Payment</h2>
+ <form onSubmit={this.handleSubmit}>
+ <Input type="text" ref="address" label="Destination Address:" required />
+ <Input type="text" ref="destinationTag" label="Destination Tag:" />
+ <Input type="text" ref="sourceTag" label="Source Tag:" />
+ <Input type="text" ref="invoiceId" label="Invoice Id:" />
+ <Input type="text" ref="amount" label="Amount:" required />
+ <Input type="text" ref="currency" label="Currency:" required />
+ <Input type="textarea" ref="memo" label="Memo:" />
+ <Button bsStyle="primary" type="submit">Submit Payment</Button>
+ </form>
+ </div>
+ );
}
});
|
75a85cf2195c1497130630ac7a42c2f1f84089f2 | src/js/components/MenuItemComponent.jsx | src/js/components/MenuItemComponent.jsx | import React from "react/addons";
import Util from "../helpers/Util";
var MenuItemComponent = React.createClass({
"displayName": "MenuItemComponent",
propTypes: {
children: React.PropTypes.node,
id: React.PropTypes.string,
name: React.PropTypes.string,
selected: React.PropTypes.bool,
value: React.PropTypes.string.isRequired
},
render: function () {
var {
children,
id="menu-item-" + Util.getUniqueId(),
name,
value,
selected
} = this.props;
return (
<li role="menu-item">
<input id={id} type="radio" name={name} value={value}
defaultChecked={selected} />
<label htmlFor={id}>
{children}
</label>
</li>
);
}
});
export default MenuItemComponent;
| import React from "react/addons";
import Util from "../helpers/Util";
var MenuItemComponent = React.createClass({
"displayName": "MenuItemComponent",
propTypes: {
children: React.PropTypes.node,
className: React.PropTypes.string,
id: React.PropTypes.string,
name: React.PropTypes.string,
selected: React.PropTypes.bool,
value: React.PropTypes.string.isRequired
},
render: function () {
var {
children,
className,
id="menu-item-" + Util.getUniqueId(),
name,
value,
selected
} = this.props;
return (
<li role="menu-item" className={className}>
<input id={id} type="radio" name={name} value={value}
defaultChecked={selected} />
<label htmlFor={id}>
{children}
</label>
</li>
);
}
});
export default MenuItemComponent;
| Allow custom menu item classes | Allow custom menu item classes
| JSX | apache-2.0 | mesosphere/marathon-ui,cribalik/marathon-ui,cribalik/marathon-ui,mesosphere/marathon-ui | ---
+++
@@ -6,6 +6,7 @@
propTypes: {
children: React.PropTypes.node,
+ className: React.PropTypes.string,
id: React.PropTypes.string,
name: React.PropTypes.string,
selected: React.PropTypes.bool,
@@ -15,6 +16,7 @@
render: function () {
var {
children,
+ className,
id="menu-item-" + Util.getUniqueId(),
name,
value,
@@ -22,7 +24,7 @@
} = this.props;
return (
- <li role="menu-item">
+ <li role="menu-item" className={className}>
<input id={id} type="radio" name={name} value={value}
defaultChecked={selected} />
<label htmlFor={id}> |
34c9ccb0308828a4cc88a90409fcb26522f9e641 | src/components/menu-bar/community-button.jsx | src/components/menu-bar/community-button.jsx | import classNames from 'classnames';
import {FormattedMessage} from 'react-intl';
import PropTypes from 'prop-types';
import React from 'react';
import Button from '../button/button.jsx';
import communityIcon from './icon--see-community.svg';
import styles from './community-button.css';
const CommunityButton = ({
className,
onClick
}) => (
<Button
className={classNames(
className,
styles.communityButton
)}
iconClassName={styles.communityButtonIcon}
iconSrc={communityIcon}
onClick={onClick}
>
<FormattedMessage
defaultMessage="See Community"
description="Label for see community button"
id="gui.menuBar.seeCommunity"
/>
</Button>
);
CommunityButton.propTypes = {
className: PropTypes.string,
onClick: PropTypes.func
};
CommunityButton.defaultProps = {
onClick: () => {}
};
export default CommunityButton;
| import classNames from 'classnames';
import {FormattedMessage} from 'react-intl';
import PropTypes from 'prop-types';
import React from 'react';
import Button from '../button/button.jsx';
import communityIcon from './icon--see-community.svg';
import styles from './community-button.css';
const CommunityButton = ({
className,
onClick
}) => (
<Button
className={classNames(
className,
styles.communityButton
)}
iconClassName={styles.communityButtonIcon}
iconSrc={communityIcon}
onClick={onClick}
>
<FormattedMessage
defaultMessage="See Project Page"
description="Label for see project page button"
id="gui.menuBar.seeProjectPage"
/>
</Button>
);
CommunityButton.propTypes = {
className: PropTypes.string,
onClick: PropTypes.func
};
CommunityButton.defaultProps = {
onClick: () => {}
};
export default CommunityButton;
| Change "See Community" to "See Project Page" | Change "See Community" to "See Project Page"
| JSX | bsd-3-clause | LLK/scratch-gui,LLK/scratch-gui | ---
+++
@@ -21,9 +21,9 @@
onClick={onClick}
>
<FormattedMessage
- defaultMessage="See Community"
- description="Label for see community button"
- id="gui.menuBar.seeCommunity"
+ defaultMessage="See Project Page"
+ description="Label for see project page button"
+ id="gui.menuBar.seeProjectPage"
/>
</Button>
); |
d664dcd49e7a1b0e6dd7e0d43f21b93cfaa50a07 | src/pickhost/static/assets/js/components/ResultDisplay.jsx | src/pickhost/static/assets/js/components/ResultDisplay.jsx | import {range} from 'underscore';
import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import {connect} from 'react-redux';
import MemberForm from './MemberForm';
import ResultDisplay from './ResultDisplay';
import * as actionCreators from '../action_creators';
export default React.createClass({
mixins: [PureRenderMixin],
/* props:
members
[
initial_forms
min_forms
max_forms
action
method
csrftoken
]
*/
render: function() {
if (this.props.best.get('waiting')){
return <div className="alert alert-info">
<span>Consulting the Citymapper API...</span>
</div>
} else if (this.props.best.get('address')){
return <div className="alert alert-success">
<span>{this.props.best.get('address')}</span>
</div>
} else {
return <div><span></span></div>
}
}
})
| import {range} from 'underscore';
import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import {connect} from 'react-redux';
import MemberForm from './MemberForm';
import ResultDisplay from './ResultDisplay';
import * as actionCreators from '../action_creators';
export default React.createClass({
mixins: [PureRenderMixin],
/* props:
members
[
initial_forms
min_forms
max_forms
action
method
csrftoken
]
*/
render: function() {
if (this.props.best.get('waiting')){
return <div className="alert alert-info">
<span>Consulting the Citymapper API...</span>
</div>
} else if (this.props.best.get('address')){
return <div className="alert alert-success">
<span>{this.props.best.get('address')}</span>
</div>
} else {
return <div><span><small>
Built with <a href="https://citymapper.com">Citymapper</a> API
</small> </span></div>
}
}
})
| Add note that this was built with CityMapper API. | Add note that this was built with CityMapper API.
| JSX | mit | amfarrell/pickhost,amfarrell/pickhost,amfarrell/pickhost | ---
+++
@@ -34,7 +34,9 @@
<span>{this.props.best.get('address')}</span>
</div>
} else {
- return <div><span></span></div>
+ return <div><span><small>
+ Built with <a href="https://citymapper.com">Citymapper</a> API
+ </small> </span></div>
}
}
}) |
43b99184f794cd5526b365995e658737c5d3a7a1 | packages/coinstac-ui/app/render/components/runs/effects/useStartDecentralizedRun.jsx | packages/coinstac-ui/app/render/components/runs/effects/useStartDecentralizedRun.jsx | import { useRef, useEffect } from 'react';
import { useQuery, useSubscription } from '@apollo/client';
import { get } from 'lodash';
import { useSelector, useDispatch } from 'react-redux';
import { FETCH_ALL_CONSORTIA_QUERY, RUN_STARTED_SUBSCRIPTION } from '../../../state/graphql/functions';
import { startRun } from '../../../state/ducks/runs';
/*
* This effect checks if there are runs that must be started locally when the app first starts.
*/
function useStartDecentralizedRun() {
const dispatch = useDispatch();
const auth = useSelector(state => state.auth);
const { data } = useQuery(FETCH_ALL_CONSORTIA_QUERY);
const { data: runSubData } = useSubscription(RUN_STARTED_SUBSCRIPTION, {
variables: {
userId: auth.user.id,
},
skip: !auth || !auth.user || !auth.user.id,
});
const consortia = get(data, 'fetchAllConsortia');
useEffect(() => {
const run = get(runSubData, 'runStarted');
if (!run || run.status !== 'started') return;
const consortium = consortia.find(c => c.id === run.consortiumId);
dispatch(startRun(run, consortium));
}, [runSubData]);
}
export default useStartDecentralizedRun;
| import { useEffect } from 'react';
import { useQuery, useSubscription } from '@apollo/client';
import { get } from 'lodash';
import { useSelector, useDispatch } from 'react-redux';
import { FETCH_ALL_CONSORTIA_QUERY, RUN_STARTED_SUBSCRIPTION } from '../../../state/graphql/functions';
import { startRun } from '../../../state/ducks/runs';
/**
* This effect starts decentralized runs based on the RUN_STARTED_SUBSCRIPTION.
*
* The RUN_STARTED_SUBSCRIPTION has new data when a new decentralized run (of which the
* current user is a part of) is started.
*/
function useStartDecentralizedRun() {
const dispatch = useDispatch();
const auth = useSelector(state => state.auth);
const { data } = useQuery(FETCH_ALL_CONSORTIA_QUERY);
const { data: runSubData } = useSubscription(RUN_STARTED_SUBSCRIPTION, {
variables: {
userId: auth.user.id,
},
skip: !auth || !auth.user || !auth.user.id,
});
const consortia = get(data, 'fetchAllConsortia');
useEffect(() => {
const run = get(runSubData, 'runStarted');
if (!run || run.status !== 'started') return;
const consortium = consortia.find(c => c.id === run.consortiumId);
dispatch(startRun(run, consortium));
}, [runSubData]);
}
export default useStartDecentralizedRun;
| Update comment on the component responsible for starting decentralized runs | Update comment on the component responsible for starting decentralized runs
| JSX | mit | MRN-Code/coinstac,MRN-Code/coinstac,MRN-Code/coinstac | ---
+++
@@ -1,4 +1,4 @@
-import { useRef, useEffect } from 'react';
+import { useEffect } from 'react';
import { useQuery, useSubscription } from '@apollo/client';
import { get } from 'lodash';
import { useSelector, useDispatch } from 'react-redux';
@@ -6,8 +6,11 @@
import { FETCH_ALL_CONSORTIA_QUERY, RUN_STARTED_SUBSCRIPTION } from '../../../state/graphql/functions';
import { startRun } from '../../../state/ducks/runs';
-/*
- * This effect checks if there are runs that must be started locally when the app first starts.
+/**
+ * This effect starts decentralized runs based on the RUN_STARTED_SUBSCRIPTION.
+ *
+ * The RUN_STARTED_SUBSCRIPTION has new data when a new decentralized run (of which the
+ * current user is a part of) is started.
*/
function useStartDecentralizedRun() {
const dispatch = useDispatch(); |
b07dfba2b52d87b7dd1ef1eb65039effeae10ccb | web/static/js/components/idea_list_item.jsx | web/static/js/components/idea_list_item.jsx | import React, { Component } from "react"
import * as AppPropTypes from "../prop_types"
import styles from "./css_modules/idea_list_item.css"
class IdeaListItem extends Component {
render() {
let { idea, currentPresence, handleDelete } = this.props
return (
<li className={styles.index} title={idea.body} key={idea.id}>
{ currentPresence.user.is_facilitator ?
<i
id={idea.id}
title="Delete Idea"
className={styles.actionIcon + ` remove circle icon`}
onClick={props.handleDelete}
>
</i> : null
}
{ currentPresence.user.is_facilitator ?
<i
title="Edit Idea"
className={styles.actionIcon + ` edit icon`}
>
</i> : null
}
<span className={styles.authorAttribution}>{idea.author}:</span> {idea.body}
</li>
)
}
}
IdeaListItem.propTypes = {
idea: AppPropTypes.idea.isRequired,
currentPresence: AppPropTypes.presence.isRequired,
handleDelete: PropTypes.func,
}
export default IdeaListItem
| import React, { Component } from "react"
import * as AppPropTypes from "../prop_types"
import styles from "./css_modules/idea_list_item.css"
class IdeaListItem extends Component {
render() {
let { idea, currentPresence, handleDelete } = this.props
return (
<li className={styles.index} title={idea.body} key={idea.id}>
{ currentPresence.user.is_facilitator ?
<span>
<i
id={idea.id}
title="Delete Idea"
className={styles.actionIcon + ` remove circle icon`}
onClick={handleDelete}
>
</i>
<i
title="Edit Idea"
className={styles.actionIcon + ` edit icon`}
>
</i>
</span> : null
}
<span className={styles.authorAttribution}>{idea.author}:</span> {idea.body}
</li>
)
}
}
IdeaListItem.propTypes = {
idea: AppPropTypes.idea.isRequired,
currentPresence: AppPropTypes.presence.isRequired,
handleDelete: PropTypes.func,
}
export default IdeaListItem
| Consolidate edit & delete icons under one conditional render | Consolidate edit & delete icons under one conditional render
| JSX | mit | stride-nyc/remote_retro,stride-nyc/remote_retro,tnewell5/remote_retro,stride-nyc/remote_retro,tnewell5/remote_retro,samdec11/remote_retro | ---
+++
@@ -9,20 +9,20 @@
return (
<li className={styles.index} title={idea.body} key={idea.id}>
{ currentPresence.user.is_facilitator ?
- <i
- id={idea.id}
- title="Delete Idea"
- className={styles.actionIcon + ` remove circle icon`}
- onClick={props.handleDelete}
- >
- </i> : null
- }
- { currentPresence.user.is_facilitator ?
- <i
- title="Edit Idea"
- className={styles.actionIcon + ` edit icon`}
- >
- </i> : null
+ <span>
+ <i
+ id={idea.id}
+ title="Delete Idea"
+ className={styles.actionIcon + ` remove circle icon`}
+ onClick={handleDelete}
+ >
+ </i>
+ <i
+ title="Edit Idea"
+ className={styles.actionIcon + ` edit icon`}
+ >
+ </i>
+ </span> : null
}
<span className={styles.authorAttribution}>{idea.author}:</span> {idea.body}
</li> |
53e08b8790d1860c8be6c04585bb0eb6d7db3a4f | app/assets/javascripts/components/subcategory_picker.es6.jsx | app/assets/javascripts/components/subcategory_picker.es6.jsx | class SubcategoryPicker extends React.Component {
subcategories () {
var categoryId = this.props.categoryId;
var subcategories = this.props.subcategories.filter( (subcategory) =>
subcategory.categoryId === categoryId
);
var selectedId = this.props.selectedId;
var component = this;
return subcategories.map( function(subcategory){
var selected = subcategory.id === selectedId;
var classNames = ['subcategory-' + subcategory.id];
if(selected){ classNames.push('selected'); }
return (
<li className={classNames.join(' ')}
key={subcategory.id}
onClick={() => component.select(subcategory)}>
{subcategory.name}
<div dangerouslySetInnerHTML={{__html: subcategory.description }}></div>
</li>
);
});
}
render () {
return (
<div className="subcategory-picker">
<label>{I18n.t("components.category_picker.subcategory.label")}</label>
<ul>
{this.subcategories()}
</ul>
</div>
);
}
select (subcategory) {
if (this.props.onSelect) {
this.props.onSelect(subcategory)
}
}
}
| class SubcategoryPicker extends React.Component {
subcategories () {
var categoryId = this.props.categoryId;
var subcategories = this.props.subcategories.filter( (subcategory) =>
subcategory.categoryId === categoryId
);
var selectedId = this.props.selectedId;
var component = this;
return subcategories.map( function(subcategory){
var selected = subcategory.id === selectedId;
var classNames = ['subcategory-' + subcategory.id];
if(selected){ classNames.push('selected'); }
return (
<li className={classNames.join(' ')}
key={subcategory.id}
onClick={() => component.select(subcategory)}>
{subcategory.name} <a href={`/categories#subcategory_${subcategory.id}`} target="_blank"><i className="fa fa-info-circle"></i></a>
</li>
);
});
}
render () {
return (
<div className="subcategory-picker">
<label>{I18n.t("components.category_picker.subcategory.label")}</label>
<ul>
{this.subcategories()}
</ul>
</div>
);
}
select (subcategory) {
if (this.props.onSelect) {
this.props.onSelect(subcategory)
}
}
}
| Remove description from subcategory picker and add info link | Remove description from subcategory picker and add info link
| JSX | agpl-3.0 | AjuntamentdeBarcelona/decidimbcn,AjuntamentdeBarcelona/decidimbcn,AjuntamentdeBarcelona/decidim.barcelona,AjuntamentdeBarcelona/barcelona-participa,AjuntamentdeBarcelona/barcelona-participa,AjuntamentdeBarcelona/decidim.barcelona,AjuntamentdeBarcelona/decidim.barcelona-legacy,AjuntamentdeBarcelona/decidim.barcelona-legacy,AjuntamentdeBarcelona/decidim.barcelona-legacy,AjuntamentdeBarcelona/decidim.barcelona,AjuntamentdeBarcelona/barcelona-participa,AjuntamentdeBarcelona/decidim.barcelona,AjuntamentdeBarcelona/decidimbcn,AjuntamentdeBarcelona/decidim.barcelona-legacy | ---
+++
@@ -18,8 +18,7 @@
<li className={classNames.join(' ')}
key={subcategory.id}
onClick={() => component.select(subcategory)}>
- {subcategory.name}
- <div dangerouslySetInnerHTML={{__html: subcategory.description }}></div>
+ {subcategory.name} <a href={`/categories#subcategory_${subcategory.id}`} target="_blank"><i className="fa fa-info-circle"></i></a>
</li>
);
}); |
73d13713a5af39483eee866f5427803c62858758 | app/action-creators/transition.jsx | app/action-creators/transition.jsx | export const MOVE_X_LEFT = 'MOVE_X_LEFT';
export const MOVE_X_RIGHT = 'MOVE_X_RIGHT';
export const MOVE_Y_UP = 'MOVE_Y_UP';
export const MOVE_Y_DOWN = 'MOVE_Y_DOWN';
export const ROTATE_SPRITE = 'ROTATE_SPRITE';
export const INCREMENT_STAR_COUNT = 'INCREMENT_STAR_COUNT';
export const RESET_TRANSITION = 'RESET_TRANSITION';
export const moveXLeft = (xCoord) => {
return {
type: MOVE_X_LEFT,
xCoord
}
}
export const moveXRight = (xCoord) => {
return {
type: MOVE_X_RIGHT,
xCoord
}
}
export const moveYUp = (yCoord) => {
return {
type: MOVE_Y_UP,
yCoord
}
}
export const moveYDown = (yCoord) => {
return {
type: MOVE_Y_DOWN,
yCoord
}
}
export const rotateSprite = (rotation) => {
return {
type: ROTATE_SPRITE,
rotation
}
}
export const incrementCollectedStars = () => {
return {
type: INCREMENT_STAR_COUNT,
numStars: 1
}
}
export const resetTransition = () => {
return {
type: RESET_TRANSITION
}
}
| export const MOVE_X_LEFT = 'MOVE_X_LEFT';
export const MOVE_X_RIGHT = 'MOVE_X_RIGHT';
export const MOVE_Y_UP = 'MOVE_Y_UP';
export const MOVE_Y_DOWN = 'MOVE_Y_DOWN';
export const ROTATE_SPRITE = 'ROTATE_SPRITE';
export const INCREMENT_STAR_COUNT = 'INCREMENT_STAR_COUNT';
export const RESET_TRANSITION = 'RESET_TRANSITION';
export const moveXLeft = (xCoord) => {
return {
type: MOVE_X_LEFT,
xCoord
}
}
export const moveXRight = (xCoord) => {
return {
type: MOVE_X_RIGHT,
xCoord
}
}
export const moveYUp = (yCoord) => {
return {
type: MOVE_Y_UP,
yCoord
}
}
export const moveYDown = (yCoord) => {
return {
type: MOVE_Y_DOWN,
yCoord
}
}
export const rotateSprite = (rotation) => {
return {
type: ROTATE_SPRITE,
rotation
}
}
export const incrementCollectedStars = () => {
return {
type: INCREMENT_STAR_COUNT,
numStars: 1
}
}
export const resetTransition = () => {
return {
type: RESET_TRANSITION
}
}
| Add red tile and red star to canvas. | Add red tile and red star to canvas.
| JSX | mit | donthedeveloper/kindercode,donthedeveloper/kindercode,donthedeveloper/kindercode | ---
+++
@@ -53,4 +53,3 @@
type: RESET_TRANSITION
}
}
- |
11aa22cffae01f3e291b7182b0d9c0eee63fcb90 | www_src/lib/router.jsx | www_src/lib/router.jsx | module.exports = {
android: window.Android,
getRouteParams: function () {
var r = {};
if (this.android) {
// Check to see if route params exist & create cache key
var routeParams = this.android.getRouteParams();
var key = 'state::route';
// If they do, save them. If not, fetch from SharedPreferences
if (routeParams !== '{}') {
r = JSON.parse(routeParams);
this.android.setSharedPreferences(key, routeParams, true);
} else {
var hit = this.android.getSharedPreferences(key, true);
try {
r = JSON.parse(hit);
} catch (e) {}
}
} else {
r = {
// mode: 'play',
user: 1,
project: 21,
page: 1,
element: 1
};
}
return r;
},
getInitialState: function () {
return {
params: this.getRouteParams()
};
}
};
| module.exports = {
android: window.Android,
getRouteParams: function () {
var r = {};
if (this.android) {
// Check to see if route params exist & create cache key
var routeParams = this.android.getRouteParams();
var key = 'route::params';
// If they do, save them. If not, fetch from SharedPreferences
if (routeParams !== '{}') {
r = JSON.parse(routeParams);
this.android.setMemStorage(key, routeParams, true);
} else {
var hit = this.android.getMemStorage(key, true);
try {
r = JSON.parse(hit);
} catch (e) {}
}
} else {
r = {
// mode: 'play',
user: 1,
project: 21,
page: 1,
element: 1
};
}
return r;
},
getInitialState: function () {
return {
params: this.getRouteParams()
};
}
};
| Use in-memory storage for route params | Use in-memory storage for route params | JSX | mpl-2.0 | alanmoo/webmaker-android,j796160836/webmaker-android,bolaram/webmaker-android,bolaram/webmaker-android,mozilla/webmaker-android,adamlofting/webmaker-android,alicoding/webmaker-android,gvn/webmaker-android,alanmoo/webmaker-android,mozilla/webmaker-android,alicoding/webmaker-android,k88hudson/webmaker-android,rodmoreno/webmaker-android,rodmoreno/webmaker-android,gvn/webmaker-android,j796160836/webmaker-android,k88hudson/webmaker-android | ---
+++
@@ -6,14 +6,14 @@
if (this.android) {
// Check to see if route params exist & create cache key
var routeParams = this.android.getRouteParams();
- var key = 'state::route';
+ var key = 'route::params';
// If they do, save them. If not, fetch from SharedPreferences
if (routeParams !== '{}') {
r = JSON.parse(routeParams);
- this.android.setSharedPreferences(key, routeParams, true);
+ this.android.setMemStorage(key, routeParams, true);
} else {
- var hit = this.android.getSharedPreferences(key, true);
+ var hit = this.android.getMemStorage(key, true);
try {
r = JSON.parse(hit);
} catch (e) {} |
7cbcd20dca8008d63ae9a51f73ef109e484a988c | client/components/InputForm.jsx | client/components/InputForm.jsx | import React from 'react';
export default class InputForm extends React.Component {
constructor(props) {
super(props);
this.state = {
inputValue: '',
};
}
handleInputChange(e) {
this.setState({
inputValue: e.target.value,
});
}
handleClick() {
this.props.analyzeText(this.state.inputValue);
}
render() {
const handleInputChange = this.handleInputChange.bind(this);
const handleClick = this.handleClick.bind(this);
return (
<div>
<textarea
className="inputForm"
placeholder="The doctor will see you now! Type or paste in your text sample here."
type="text"
rows="30"
cols="150"
onChange={handleInputChange}
value={this.state.inputValue}
/>
<div>
<button onClick={handleClick}>Analyze</button>
<button onClick={this.props.resetText}>Reset</button>
</div>
</div>
);
}
}
InputForm.propTypes = {
analyzeText: React.PropTypes.node,
resetText: React.PropTypes.node,
};
| import React from 'react';
export default class InputForm extends React.Component {
constructor(props) {
super(props);
this.state = {
inputValue: '',
};
}
handleInputChange(e) {
this.setState({
inputValue: e.target.value,
});
}
handleClick() {
this.props.analyzeText(this.state.inputValue);
}
clearTextForm() {
console.log('reset text got called with this value of ', this);
this.setState({
inputValue: '',
});
this.props.resetText();
}
render() {
const handleInputChange = this.handleInputChange.bind(this);
const handleClick = this.handleClick.bind(this);
const clearTextForm = this.clearTextForm.bind(this);
return (
<div>
<textarea
className="inputForm"
placeholder="The doctor will see you now! Type or paste in your text sample here."
type="text"
rows="30"
cols="150"
onChange={handleInputChange}
value={this.state.inputValue}
/>
<div>
<button onClick={handleClick}>Analyze</button>
<button onClick={clearTextForm}>Reset</button>
</div>
</div>
);
}
}
InputForm.propTypes = {
analyzeText: React.PropTypes.func,
resetText: React.PropTypes.func,
};
| Fix reset text button - clears text and analytics again | Fix reset text button - clears text and analytics again
| JSX | mit | nonchalantkettle/SpeechDoctor,alexxisroxxanne/SpeechDoctor,alexxisroxxanne/SpeechDoctor,nonchalantkettle/SpeechDoctor | ---
+++
@@ -18,9 +18,18 @@
this.props.analyzeText(this.state.inputValue);
}
+ clearTextForm() {
+ console.log('reset text got called with this value of ', this);
+ this.setState({
+ inputValue: '',
+ });
+ this.props.resetText();
+ }
+
render() {
const handleInputChange = this.handleInputChange.bind(this);
const handleClick = this.handleClick.bind(this);
+ const clearTextForm = this.clearTextForm.bind(this);
return (
<div>
@@ -35,7 +44,7 @@
/>
<div>
<button onClick={handleClick}>Analyze</button>
- <button onClick={this.props.resetText}>Reset</button>
+ <button onClick={clearTextForm}>Reset</button>
</div>
</div>
);
@@ -43,6 +52,6 @@
}
InputForm.propTypes = {
- analyzeText: React.PropTypes.node,
- resetText: React.PropTypes.node,
+ analyzeText: React.PropTypes.func,
+ resetText: React.PropTypes.func,
}; |
1fea29ff633bf9e44e4132d2c49297add4145aff | src/components/FeedItem.jsx | src/components/FeedItem.jsx | import React, { Component } from 'react'
import shouldPureComponentUpdate from 'react-pure-render'
import gravatar from 'gravatar'
import PropTypes from 'lib/PropTypes'
import {
Card,
CardHeader,
CardText
} from 'material-ui'
export default class FeedItem extends Component {
static propTypes = {
author: PropTypes.pk.user.isRequired,
createdAt: PropTypes.instanceOf(Date).isRequired,
text: PropTypes.string.isRequired
};
shouldComponentUpdate = shouldPureComponentUpdate;
render () {
const email = this.props.author.emails[0].address
const avatarUrl = gravatar.imageUrl(email)
return <Card>
<CardHeader
avatar={ avatarUrl }
subtitle={ this.props.createdAt.toLocaleString() }
title={ email }
/>
<CardText>
{ this.props.text }
</CardText>
</Card>
}
}
| import React, { Component } from 'react'
import shouldPureComponentUpdate from 'react-pure-render'
import gravatar from 'gravatar'
import PropTypes from 'lib/PropTypes'
import {
Card,
CardHeader,
CardText
} from 'material-ui'
export default class FeedItem extends Component {
static propTypes = {
author: PropTypes.pk.user.isRequired,
createdAt: PropTypes.instanceOf(Date).isRequired,
text: PropTypes.string.isRequired
};
shouldComponentUpdate = shouldPureComponentUpdate;
render () {
const author = this.props.author
const email = author.emails[0].address
const avatarUrl = gravatar.imageUrl(email)
let title = ''
if (author.profile && author.profile.title) {
title = author.profile.title
}
return <Card>
<CardHeader
avatar={ avatarUrl }
subtitle={
<div>
{ title }
<span style={{
position: 'absolute',
right: '16px',
top: '18px'
}}>{ this.props.createdAt.toLocaleString() }</span>
</div>
}
title={ email }
/>
<CardText>
{ this.props.text }
</CardText>
</Card>
}
}
| Add profile info to feed items. | Add profile info to feed items.
| JSX | mit | tvararu/peak-meteor,tvararu/peak-meteor | ---
+++
@@ -18,13 +18,27 @@
shouldComponentUpdate = shouldPureComponentUpdate;
render () {
- const email = this.props.author.emails[0].address
+ const author = this.props.author
+ const email = author.emails[0].address
const avatarUrl = gravatar.imageUrl(email)
+ let title = ''
+ if (author.profile && author.profile.title) {
+ title = author.profile.title
+ }
return <Card>
<CardHeader
avatar={ avatarUrl }
- subtitle={ this.props.createdAt.toLocaleString() }
+ subtitle={
+ <div>
+ { title }
+ <span style={{
+ position: 'absolute',
+ right: '16px',
+ top: '18px'
+ }}>{ this.props.createdAt.toLocaleString() }</span>
+ </div>
+ }
title={ email }
/>
<CardText> |
fcc9845b252b7f23a0e6645250343f770a04905e | src/client/app/components/TooltipHelpComponent.jsx | src/client/app/components/TooltipHelpComponent.jsx | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React from 'react';
import ReactTooltip from 'react-tooltip';
/**
* Component that renders a help icon that shows a tooltip when on hover
*/
export default function TooltipHelpComponent(props) {
const divStyle = {
display: 'inline-block'
};
return (
<div style={divStyle}>
<i data-tip={props.tip} className="fa fa-question-circle" />
<ReactTooltip />
</div>
);
}
| /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React from 'react';
import ReactTooltip from 'react-tooltip';
/**
* Component that renders a help icon that shows a tooltip on hover
*/
export default function TooltipHelpComponent(props) {
const divStyle = {
display: 'inline-block'
};
return (
<div style={divStyle}>
<i data-tip={props.tip} className="fa fa-question-circle" />
<ReactTooltip />
</div>
);
}
| Remove extraneous word in comment | Remove extraneous word in comment
| JSX | mpl-2.0 | beloitcollegecomputerscience/OED,beloitcollegecomputerscience/OED,OpenEnergyDashboard/OED,beloitcollegecomputerscience/OED,OpenEnergyDashboard/OED,OpenEnergyDashboard/OED,OpenEnergyDashboard/OED,beloitcollegecomputerscience/OED | ---
+++
@@ -6,7 +6,7 @@
import ReactTooltip from 'react-tooltip';
/**
- * Component that renders a help icon that shows a tooltip when on hover
+ * Component that renders a help icon that shows a tooltip on hover
*/
export default function TooltipHelpComponent(props) {
const divStyle = { |
833780aed725d5e0995ede485957aa417828fcca | snippets/datedialog.jsx | snippets/datedialog.jsx | import {DateDialog, Button, Stack, TextView, contentView} from 'tabris';
contentView.append(
<Stack stretch padding={16} spacing={16} alignment='stretchX'>
<Button onSelect={showSimpleDialog}>Simple date dialog</Button>
<Button onSelect={showSpecificDate}>Dialog with pre-set date</Button>
<Button onSelect={showMinMaxDate}>Dialog with min/max date</Button>
<TextView/>
</Stack>
);
const FIVE_DAYS = 432000000;
const textView = $(TextView).only();
async function showSimpleDialog() {
const {date} = await DateDialog.open().onClose.promise();
textView.text = date ? `Picked ${date.toDateString()}` : 'Canceled';
}
async function showSpecificDate() {
const {date} = await DateDialog.open(new Date(2012, 12, 12)).onClose.promise();
textView.text = date ? `Picked ${date.toDateString()}` : 'Canceled';
}
async function showMinMaxDate() {
const now = new Date().getTime();
DateDialog.open(
<DateDialog
minDate={new Date(now - FIVE_DAYS)}
maxDate={new Date(now + FIVE_DAYS)}
onClose={({date}) => textView.text = date ? `Picked ${date.toDateString()}` : 'Canceled'}/>
);
}
| import {DateDialog, Button, Stack, TextView, contentView} from 'tabris';
contentView.append(
<Stack stretch padding={16} spacing={16} alignment='stretchX'>
<Button onSelect={showSimpleDialog}>Simple date dialog</Button>
<Button onSelect={showSpecificDate}>Dialog with pre-set date</Button>
<Button onSelect={showMinMaxDate}>Dialog with min/max date</Button>
<TextView/>
</Stack>
);
const FIVE_DAYS = 432000000;
const textView = $(TextView).only();
async function showSimpleDialog() {
const {date} = await DateDialog.open().onClose.promise();
textView.text = date ? `Picked ${date.toDateString()}` : 'Canceled';
}
async function showSpecificDate() {
const {date} = await DateDialog.open(new Date(2022, 0, 25)).onClose.promise();
textView.text = date ? `Picked ${date.toDateString()}` : 'Canceled';
}
async function showMinMaxDate() {
const now = new Date().getTime();
DateDialog.open(
<DateDialog
minDate={new Date(now - FIVE_DAYS)}
maxDate={new Date(now + FIVE_DAYS)}
onClose={({date}) => textView.text = date ? `Picked ${date.toDateString()}` : 'Canceled'}/>
);
}
| Fix DateDialog snippet to have month in correct range | Fix DateDialog snippet to have month in correct range
The previously used initial date for the date dialog had the month at
index 12. This value is out of range since the month is index 0 based.
| JSX | bsd-3-clause | eclipsesource/tabris-js,eclipsesource/tabris-js,eclipsesource/tabris-js | ---
+++
@@ -18,7 +18,7 @@
}
async function showSpecificDate() {
- const {date} = await DateDialog.open(new Date(2012, 12, 12)).onClose.promise();
+ const {date} = await DateDialog.open(new Date(2022, 0, 25)).onClose.promise();
textView.text = date ? `Picked ${date.toDateString()}` : 'Canceled';
}
|
be62c038ec47af65c68443d2ecc2106342c83db4 | app/scripts/shared/components/nav-links/nav-links.jsx | app/scripts/shared/components/nav-links/nav-links.jsx | var React = require('react');
var Link = require('react-router').Link;
var NavLinks = React.createClass({
propTypes: {
links: React.PropTypes.array
},
//<ul className="nav navbar-nav navbar-right">
getDefaultProps: function() {
return {className: "nav navbar-nav"};
},
getLinks: function(links) {
var items = links.map(function(link, i) {
return(
<li>
<Link key={i++} to={link.href}>
{link.text}
</Link>
</li>
);
});
return items;
},
render: function() {
var links = this.getLinks(this.props.links);
return (
<ul className={this.props.className}>
{links}
</ul>
);
}
});
module.exports = NavLinks;
| var React = require('react');
var Link = require('react-router').Link;
var NavLinks = React.createClass({
propTypes: {
links: React.PropTypes.array
},
//<ul className="nav navbar-nav navbar-right">
getDefaultProps: function() {
return {className: "nav navbar-nav"};
},
getLinks: function(links) {
var items = links.map(function(link, i) {
return(
<li key={i++}>
<Link to={link.href}>
{link.text}
</Link>
</li>
);
});
return items;
},
render: function() {
var links = this.getLinks(this.props.links);
return (
<ul className={this.props.className}>
{links}
</ul>
);
}
});
module.exports = NavLinks;
| Add key to Nav List | [TASK] Add key to Nav List
| JSX | isc | dabibbit/dream-stack-seed,dabibbit/dream-stack-seed | ---
+++
@@ -14,8 +14,8 @@
getLinks: function(links) {
var items = links.map(function(link, i) {
return(
- <li>
- <Link key={i++} to={link.href}>
+ <li key={i++}>
+ <Link to={link.href}>
{link.text}
</Link>
</li> |
d9bc418cede729894b213b99ac24d60332796fda | app/assets/javascripts/components/initial_offer.js.jsx | app/assets/javascripts/components/initial_offer.js.jsx | /** @jsx React.DOM */
(function() {
var InitialOffer = React.createClass({
getDefaultProps: function() {
return {
user: app.currentUser()
}
},
getInitialState: function() {
return {
toggle: 'simple'
}
},
handleToggleClick: function() {
this.setState({
toggle: this.state.toggle == 'simple' ? 'advanced' : 'simple'
})
},
renderValueControl: function() {
if(this.state.toggle === 'simple') {
return this.transferPropsTo(<SimpleNewBountyOffer />)
} else {
return this.transferPropsTo(<AdvancedNewBountyOffer />)
}
},
render: function() {
return (
<div className="form-group">
<div className="btn-group right">
<a onClick={this.handleToggleClick} href="#">{this.state.toggle == 'simple' ? 'Advanced' : 'Simple'}</a>
</div>
<label className="control-label">
Value
</label>
<div style={{ height: 200 }}>
{this.renderValueControl()}
</div>
</div>
)
}
});
if (typeof module !== 'undefined') {
module.exports = InitialOffer;
}
window.InitialOffer = InitialOffer;
})();
| /** @jsx React.DOM */
(function() {
var InitialOffer = React.createClass({
getDefaultProps: function() {
return {
user: app.currentUser()
}
},
getInitialState: function() {
return {
toggle: 'simple'
}
},
handleToggleClick: function() {
this.setState({
toggle: this.state.toggle == 'simple' ? 'advanced' : 'simple'
})
},
renderValueControl: function() {
if(this.state.toggle === 'simple') {
return this.transferPropsTo(<SimpleNewBountyOffer />)
} else {
return this.transferPropsTo(<AdvancedNewBountyOffer />)
}
},
render: function() {
return (
<div className="form-group">
<div className="btn-group right">
<a onClick={this.handleToggleClick} href="#">{this.state.toggle == 'simple' ? 'Custom' : 'Simple'}</a>
</div>
<label className="control-label">
Value
</label>
<div style={{ height: 200 }}>
{this.renderValueControl()}
</div>
</div>
)
}
});
if (typeof module !== 'undefined') {
module.exports = InitialOffer;
}
window.InitialOffer = InitialOffer;
})();
| Use the word Custom instead of Advanced | Use the word Custom instead of Advanced
| JSX | agpl-3.0 | lachlanjc/meta,assemblymade/meta,assemblymade/meta,lachlanjc/meta,lachlanjc/meta,lachlanjc/meta,assemblymade/meta,assemblymade/meta | ---
+++
@@ -32,7 +32,7 @@
return (
<div className="form-group">
<div className="btn-group right">
- <a onClick={this.handleToggleClick} href="#">{this.state.toggle == 'simple' ? 'Advanced' : 'Simple'}</a>
+ <a onClick={this.handleToggleClick} href="#">{this.state.toggle == 'simple' ? 'Custom' : 'Simple'}</a>
</div>
<label className="control-label"> |
5b03009ff1ab70e40c529a8439bed0364a45445b | common/components/componentsBySection/FindProjects/SplashScreen.jsx | common/components/componentsBySection/FindProjects/SplashScreen.jsx | // @flow
import React from 'react';
import {Button} from 'react-bootstrap';
import Section from "../../enums/Section.js";
import url from "../../utils/url.js";
import cdn from "../../utils/cdn.js";
type Props = {|
onClickFindProjects: () => void
|};
class SplashScreen extends React.PureComponent<Props> {
_onClickFindProjects(): void {
this.props.onClickFindProjects();
}
render(): React$Node {
return (
<div className="SplashScreen-root" style={{backgroundImage: 'url(' + cdn.image("dl_splash.jpg")+ ')' }}>
<div className="SplashScreen-content">
<h1>We connect skilled volunteers and tech-for-good projects</h1>
<div className="SplashScreen-section">
<Button className="SplashScreen-find-projects-btn" onClick={this._onClickFindProjects.bind(this)}>
Find Projects
</Button>
<Button className="SplashScreen-create-project-btn" href={url.sectionOrLogIn(Section.CreateProject)}>
Create A Project
</Button>
</div>
</div>
<div className="SplashScreen-mission">
<p>DemocracyLab is a 501(c)(3) nonprofit organization. Our mission is to empower a community of people and projects that use technology to advance the public good.</p>
</div>
</div>
);
}
}
export default SplashScreen;
| // @flow
import React from 'react';
import {Button} from 'react-bootstrap';
import Section from "../../enums/Section.js";
import url from "../../utils/url.js";
import cdn from "../../utils/cdn.js";
type Props = {|
onClickFindProjects: () => void
|};
class SplashScreen extends React.PureComponent<Props> {
_onClickFindProjects(): void {
this.props.onClickFindProjects();
}
render(): React$Node {
return (
<div className="SplashScreen-root" style={{backgroundImage: 'url(' + cdn.image("dl_splash.jpg")+ ')' }}>
<div className="SplashScreen-content">
<h1>We connect skilled volunteers and tech-for-good projects</h1>
<div className="SplashScreen-section">
<Button className="SplashScreen-find-projects-btn" onClick={this._onClickFindProjects.bind(this)}>
Find Projects
</Button>
<Button className="SplashScreen-create-project-btn" href={url.sectionOrLogIn(Section.CreateProject)}>
Create A Project
</Button>
</div>
</div>
<div className="SplashScreen-mission">
<p>DemocracyLab is a nonprofit organization.</p>
<p>Our mission is to empower people who use technology to advance the public good.</p>
</div>
</div>
);
}
}
export default SplashScreen;
| Change splash screen mission statement | Change splash screen mission statement
| JSX | mit | DemocracyLab/CivicTechExchange,DemocracyLab/CivicTechExchange,DemocracyLab/CivicTechExchange,DemocracyLab/CivicTechExchange | ---
+++
@@ -30,7 +30,8 @@
</div>
</div>
<div className="SplashScreen-mission">
- <p>DemocracyLab is a 501(c)(3) nonprofit organization. Our mission is to empower a community of people and projects that use technology to advance the public good.</p>
+ <p>DemocracyLab is a nonprofit organization.</p>
+ <p>Our mission is to empower people who use technology to advance the public good.</p>
</div>
</div>
); |
66f953bfffd4b227406291e48a396889ee004355 | ditto/static/flux-chat/js/components/RoomSection.jsx | ditto/static/flux-chat/js/components/RoomSection.jsx | var React = require('react');
var ThreadStore = require('../stores/ThreadStore');
var ChatThreadActionCreators = require('../actions/ChatThreadActionCreators');
var cx = require('react/lib/cx');
var urls = require('../utils/urlUtils');
import { Link } from 'react-router';
function getStateFromStores() {
return {
rooms: ThreadStore.getRooms(),
currentRoomJID: ThreadStore.getCurrentRoomJID(),
};
}
var RoomSection = React.createClass({
getInitialState: function() {
return getStateFromStores();
},
componentDidMount: function() {
ThreadStore.addChangeListener(this._onChange);
},
componentWillUnmount: function() {
ThreadStore.removeChangeListener(this._onChange);
},
render: function() {
var roomListItems = this.state.rooms.map(room => {
var roomID = room.split('@')[0];
return (
<Link key={roomID} className="list-group-item" to={urls.chatroom(roomID)}>{room}</Link>
);
});
return (
<div>
<div className="list-group">
{roomListItems}
</div>
</div>
);
},
/**
* Event handler for 'change' events coming from the stores
*/
_onChange: function() {
this.setState(getStateFromStores());
},
});
module.exports = RoomSection;
| var React = require('react');
var ThreadStore = require('../stores/ThreadStore');
var ChatThreadActionCreators = require('../actions/ChatThreadActionCreators');
var cx = require('react/lib/cx');
var urls = require('../utils/urlUtils');
import { Link } from 'react-router';
function getStateFromStores() {
return {
rooms: ThreadStore.getRooms(),
currentRoomJID: ThreadStore.getCurrentRoomJID(),
};
}
var RoomSection = React.createClass({
getInitialState: function() {
return getStateFromStores();
},
componentDidMount: function() {
ThreadStore.addChangeListener(this._onChange);
},
componentWillUnmount: function() {
ThreadStore.removeChangeListener(this._onChange);
},
render: function() {
var roomListItems = this.state.rooms.map(room => {
var roomID = room.split('@')[0];
return (
<Link key={roomID} className="list-group-item" to={urls.chatroom(roomID)}>{Strophe.getNodeFromJid(room)}</Link>
);
});
return (
<div>
<div className="list-group">
{roomListItems}
</div>
</div>
);
},
/**
* Event handler for 'change' events coming from the stores
*/
_onChange: function() {
this.setState(getStateFromStores());
},
});
module.exports = RoomSection;
| Remove jabber domain from names in 'Other chatrooms' | Remove jabber domain from names in 'Other chatrooms'
| JSX | bsd-3-clause | Kvoti/ditto,Kvoti/ditto,Kvoti/ditto,Kvoti/ditto,Kvoti/ditto | ---
+++
@@ -31,7 +31,7 @@
var roomListItems = this.state.rooms.map(room => {
var roomID = room.split('@')[0];
return (
- <Link key={roomID} className="list-group-item" to={urls.chatroom(roomID)}>{room}</Link>
+ <Link key={roomID} className="list-group-item" to={urls.chatroom(roomID)}>{Strophe.getNodeFromJid(room)}</Link>
);
});
return ( |
487f2b5569634b80f301ed6f5cc4a7844b322c5b | src/components/HighlightOnHover.jsx | src/components/HighlightOnHover.jsx | import React from 'react';
import EventTypes from '../update/EventTypes.js';
import Colors from '../styles/Colors.js';
import {makeArtListener} from './utils/DrawingUtils.js';
/**
* @example
* import handleHover from '...HighlightOnHover.jsx';
* const myHoveringElem = handlerHover(MyCircuitElement);
*
* @param {CircuitElement}
*/
export default CircuitElement => {
class Highlighter extends React.Component {
constructor(props) {
super(props);
this.push = this.push.bind(this);
}
push(event) {
this.props.pushEvent({
event,
type: event.type === 'mouseover' ? EventTypes.ElemMouseOver : EventTypes.ElemMouseLeave,
elemID: this.refs.elem.props.id
});
}
render() {
const handlers = {
mouseOver: makeArtListener(this.push),
mouseOut: makeArtListener(this.push)
},
color = this.props.hover ? Colors.highlight : Colors.base;
return (
<CircuitElement ref='elem'
{...this.props}
color={color}
handlers={handlers}
/>
);
}
}
Highlighter.propTypes = {
hover: React.PropTypes.bool,
pushEvent: React.PropTypes.func.isRequired
};
Highlighter.defaultProps = {
hover: false
};
return Highlighter;
};
| import React from 'react';
import EventTypes from '../update/EventTypes.js';
import Colors from '../styles/Colors.js';
import {makeArtListener} from './utils/DrawingUtils.js';
/**
* @example
* import handleHover from '...HighlightOnHover.jsx';
* const myHoveringElem = handlerHover(MyCircuitElement);
*
* @param {CircuitElement}
*/
export default CircuitElement => {
class Highlighter extends React.Component {
constructor(props) {
super(props);
this.push = this.push.bind(this);
}
push(event) {
this.props.pushEvent({
event,
type: event.type === 'mouseover' ? EventTypes.ElemMouseOver : EventTypes.ElemMouseLeave,
elemID: this.refs.elem.props.id
});
}
render() {
const handlers = {
mouseOver: makeArtListener(this.push),
mouseOut: makeArtListener(this.push)
},
color = this.props.hover ? Colors.highlight : Colors.base;
return (
<CircuitElement ref='elem'
{...this.props}
color={color}
handlers={handlers}
/>
);
}
}
Highlighter.propTypes = {
hover: React.PropTypes.bool,
pushEvent: React.PropTypes.func.isRequired
};
Highlighter.defaultProps = {
hover: false
};
Highlighter.displayName = `Highlighted ${CircuitElement.model.get('type')}`;
return Highlighter;
};
| Add displayName for Highlighter to help debugging | Add displayName for Highlighter to help debugging
| JSX | epl-1.0 | circuitsim/circuit-simulator,circuitsim/circuit-simulator,circuitsim/circuit-simulator | ---
+++
@@ -53,5 +53,7 @@
hover: false
};
+ Highlighter.displayName = `Highlighted ${CircuitElement.model.get('type')}`;
+
return Highlighter;
}; |
131148762812038c80f82a4a77cd1aef89d1cade | app/assets/javascripts/views/input_preview.js.jsx | app/assets/javascripts/views/input_preview.js.jsx | /** @jsx React.DOM */
//= require views/form_group
var InputPreview = React.createClass({
getInitialState: function() {
return {
inputPreview: '',
transform: this.props.transform || this.transform
};
},
render: function() {
return (
<FormGroup>
<div className="input-group" style={{ width: '35%' }}>
<input type="text"
name={this.props.inputName}
className="form-control"
value={this.state.inputPreview}
placeholder={this.props.placeholder}
onChange={this.onChange} />
<span className="input-group-btn">
<button type="submit" onSubmit={this.onSubmit} className="btn btn-primary">{this.props.buttonText}</button>
</span>
</div>
<p className="text-muted omega" style={{ 'margin-top': '5px', 'margin-left': '1px' }}>
Preview: <strong>{this.props.addonText + this.state.inputPreview}</strong>
</p>
</FormGroup>
);
},
onChange: function(e) {
var value = e.target.value;
this.setState({
inputPreview: this.state.transform(value)
});
},
transform: function(text) {
return text.replace(/[^\w-\.]+/g, '-').toLowerCase();
},
onSubmit: function(e) {
e.preventDefault();
}
});
| /** @jsx React.DOM */
//= require views/form_group
var InputPreview = React.createClass({
getInitialState: function() {
return {
inputPreview: '',
transform: this.props.transform || this.transform
};
},
render: function() {
return (
<FormGroup>
<div className="input-group" style={{ width: '35%' }}>
<input type="text"
name={this.props.inputName}
className="form-control"
value={this.state.inputPreview}
placeholder={this.props.placeholder}
onChange={this.onChange} />
<span className={"input-group-btn"}>
<button type="submit" onSubmit={this.onSubmit} className="btn btn-primary" disabled={this.buttonState()}>{this.props.buttonText}</button>
</span>
</div>
<p className="text-muted omega" style={{ 'margin-top': '5px', 'margin-left': '1px' }}>
Preview: <strong>{this.props.addonText + this.state.inputPreview}</strong>
</p>
</FormGroup>
);
},
onChange: function(e) {
var value = e.target.value;
this.setState({
inputPreview: this.state.transform(value)
});
},
buttonState: function() {
return this.state.inputPreview.length >= 2 ? false : true;
},
transform: function(text) {
return text.replace(/[^\w-\.]+/g, '-').toLowerCase();
},
onSubmit: function(e) {
e.preventDefault();
}
});
| Disable repos create button until input >= 2 | Disable repos create button until input >= 2
| JSX | agpl-3.0 | lachlanjc/meta,assemblymade/meta,assemblymade/meta,lachlanjc/meta,lachlanjc/meta,lachlanjc/meta,assemblymade/meta,assemblymade/meta | ---
+++
@@ -20,8 +20,8 @@
value={this.state.inputPreview}
placeholder={this.props.placeholder}
onChange={this.onChange} />
- <span className="input-group-btn">
- <button type="submit" onSubmit={this.onSubmit} className="btn btn-primary">{this.props.buttonText}</button>
+ <span className={"input-group-btn"}>
+ <button type="submit" onSubmit={this.onSubmit} className="btn btn-primary" disabled={this.buttonState()}>{this.props.buttonText}</button>
</span>
</div>
<p className="text-muted omega" style={{ 'margin-top': '5px', 'margin-left': '1px' }}>
@@ -39,6 +39,10 @@
});
},
+ buttonState: function() {
+ return this.state.inputPreview.length >= 2 ? false : true;
+ },
+
transform: function(text) {
return text.replace(/[^\w-\.]+/g, '-').toLowerCase();
}, |
cbef4636e2ab7ec6f122836b03060978e2fe2594 | src/app/components/Sidebar/ScriptList.jsx | src/app/components/Sidebar/ScriptList.jsx | import React, { Component, PropTypes } from 'react';
import Script from './Script';
import ReactDOM from 'react-dom';
export default class ScriptList extends Component {
static propTypes = {
onScriptClick: PropTypes.func.isRequired,
scripts: PropTypes.objectOf(React.PropTypes.object.isRequired).isRequired,
}
constructor (props) {
super(props);
};
render () {
let renderScripts = [];
for(var script in this.props.scripts) {
renderScripts.push({...this.props.scripts[script], src: script});
}
let scripts = renderScripts.map((script) => {
return (<Script src={script.src || ''}
name={script.name || ''}
key={script.src || ''}
onClick={this.props.onScriptClick || ''}
status={script.status || ''}/>);
});
if(!this.props.show) {
return null;
}
return (
<div id="scriptList" key={0}>
<ul>
{scripts}
</ul>
</div>
);
}
} | import React, { Component, PropTypes } from 'react';
import Script from './Script';
import ReactDOM from 'react-dom';
export default class ScriptList extends Component {
static propTypes = {
onScriptClick: PropTypes.func.isRequired,
scripts: PropTypes.objectOf(React.PropTypes.object.isRequired).isRequired,
}
constructor (props) {
super(props);
};
render () {
let renderScripts = [];
for(var script in this.props.scripts) {
renderScripts.push({...this.props.scripts[script], src: script});
}
let scripts = renderScripts.map((script) => {
return (<Script src={script.src || ''}
name={script.name || ''}
key={script.src || ''}
onClick={this.props.onScriptClick || ''}
status={script.status || ''}/>);
});
if(!this.props.show) {
return null;
}
return (
<div id="scriptList" className="container flex" key={0}>
<div className="flex">
<h4 className="flex"> Scripts </h4>
<button className="flex" onClick={() => {this.props.onAddScriptClick()}}> + </button>
</div>
<ul>
{scripts}
</ul>
</div>
);
}
} | Change view of the scriptList | Change view of the scriptList
| JSX | mit | simonlovesyou/AutoRobot | ---
+++
@@ -33,7 +33,11 @@
return null;
}
return (
- <div id="scriptList" key={0}>
+ <div id="scriptList" className="container flex" key={0}>
+ <div className="flex">
+ <h4 className="flex"> Scripts </h4>
+ <button className="flex" onClick={() => {this.props.onAddScriptClick()}}> + </button>
+ </div>
<ul>
{scripts}
</ul> |
4968289ac2fd2f4e659cbb673becf5d70d148b6e | BlazarUI/app/scripts/components/sidebar/Module.jsx | BlazarUI/app/scripts/components/sidebar/Module.jsx | /*global config*/
import React, {Component, PropTypes} from 'react';
import BuildingIcon from '../shared/BuildingIcon.jsx';
let Link = require('react-router').Link;
class Module extends Component {
render() {
let {inProgressBuild, gitInfo, module} = this.props.repo;
let moduleLink = '';
if (inProgressBuild) {
moduleLink = `${config.appRoot}/builds/${gitInfo.host}/${gitInfo.organization}/${gitInfo.repository}/${gitInfo.branch}/${module.name + '_' + module.id}/${inProgressBuild.buildNumber}`;
} else {
moduleLink = `${config.appRoot}/builds/${gitInfo.host}/${gitInfo.organization}/${gitInfo.repository}/${gitInfo.branch}/${module.name + '_' + module.id}`;
}
let icon = '';
if (inProgressBuild) {
icon = <BuildingIcon result={inProgressBuild.state} size='small' />;
}
return (
<Link to={moduleLink} className='sidebar__repo-module'>
{icon}
{module.name}
</Link>
);
}
}
Module.propTypes = {
repo: PropTypes.object,
name: PropTypes.string,
link: PropTypes.string
};
export default Module;
| /*global config*/
import React, {Component, PropTypes} from 'react';
import BuildingIcon from '../shared/BuildingIcon.jsx';
let Link = require('react-router').Link;
class Module extends Component {
render() {
let {inProgressBuild, gitInfo, module} = this.props.repo;
let moduleLink = '';
if (inProgressBuild) {
moduleLink = `${config.appRoot}/builds/${gitInfo.host}/${gitInfo.organization}/${gitInfo.repository}/${gitInfo.branch}/${module.name + '_' + module.id}/${inProgressBuild.id}`;
} else {
moduleLink = `${config.appRoot}/builds/${gitInfo.host}/${gitInfo.organization}/${gitInfo.repository}/${gitInfo.branch}/${module.name + '_' + module.id}`;
}
let icon = '';
if (inProgressBuild) {
icon = <BuildingIcon result={inProgressBuild.state} size='small' />;
}
return (
<Link to={moduleLink} className='sidebar__repo-module'>
{icon}
{module.name}
</Link>
);
}
}
Module.propTypes = {
repo: PropTypes.object,
name: PropTypes.string,
link: PropTypes.string
};
export default Module;
| Fix in progress build link for sidebar | Fix in progress build link for sidebar
| JSX | apache-2.0 | HubSpot/Blazar,HubSpot/Blazar,HubSpot/Blazar,cgvarela/Blazar,cgvarela/Blazar,HubSpot/Blazar,cgvarela/Blazar,cgvarela/Blazar | ---
+++
@@ -10,7 +10,7 @@
let moduleLink = '';
if (inProgressBuild) {
- moduleLink = `${config.appRoot}/builds/${gitInfo.host}/${gitInfo.organization}/${gitInfo.repository}/${gitInfo.branch}/${module.name + '_' + module.id}/${inProgressBuild.buildNumber}`;
+ moduleLink = `${config.appRoot}/builds/${gitInfo.host}/${gitInfo.organization}/${gitInfo.repository}/${gitInfo.branch}/${module.name + '_' + module.id}/${inProgressBuild.id}`;
} else {
moduleLink = `${config.appRoot}/builds/${gitInfo.host}/${gitInfo.organization}/${gitInfo.repository}/${gitInfo.branch}/${module.name + '_' + module.id}`;
} |
4ca03795876cdbdbd39538cbff397c7a4c2aa750 | src/components/UserProfile/UserProfileContainer.jsx | src/components/UserProfile/UserProfileContainer.jsx | import React, { Component } from 'react';
import firebase, { auth, db } from '../../javascripts/firebase';
import UserProfile from './UserProfile';
import store from '../../store/configureStore';
class UserProfileContainer extends Component {
constructor(props) {
super(props);
this.state = {
sightings: []
};
}
componentDidMount() {
let sightings;
let ref = db.ref().child('sightings');
var that = this;
ref.once('value').then(function(snap) {
sightings = Object.values(snap.val());
that.setState({
sightings: sightings
});
});
}
render() {
return (
<div>
<UserProfile
user={store.getState().user}
sightings={this.state.sightings}
/>
</div>
);
}
}
export default UserProfileContainer;
| import React, { Component } from 'react';
import firebase, { auth, db } from '../../javascripts/firebase';
import UserProfile from './UserProfile';
import store from '../../store/configureStore';
class UserProfileContainer extends Component {
constructor(props) {
super(props);
this.state = {
sightings: []
};
}
componentDidMount() {
let sightings;
let ref = db
.ref()
.child('sightings')
.child(firebase.auth().currentUser.uid);
var that = this;
ref.once('value').then(function(snap) {
sightings = Object.values(snap.val());
that.setState({
sightings: sightings
});
});
}
render() {
return (
<div>
<UserProfile user={store.getState().user} sightings={this.state.sightings} />
</div>
);
}
}
export default UserProfileContainer;
| Add current user uid as child to firebase db reference | Add current user uid as child to firebase db reference
| JSX | mit | omarcodex/butterfly-pinner,omarcodex/butterfly-pinner | ---
+++
@@ -13,7 +13,10 @@
componentDidMount() {
let sightings;
- let ref = db.ref().child('sightings');
+ let ref = db
+ .ref()
+ .child('sightings')
+ .child(firebase.auth().currentUser.uid);
var that = this;
ref.once('value').then(function(snap) {
sightings = Object.values(snap.val());
@@ -26,10 +29,7 @@
render() {
return (
<div>
- <UserProfile
- user={store.getState().user}
- sightings={this.state.sightings}
- />
+ <UserProfile user={store.getState().user} sightings={this.state.sightings} />
</div>
);
} |
918346158ea8c4baade4711b084367ce51facbc1 | app/scripts/components/card_list.jsx | app/scripts/components/card_list.jsx | import React from 'react'
class CardList extends React.Component {
render() {
return (
<ul>
{this.props.cards.map(card => <li>{card.url}</li>)}
</ul>
)
}
}
export default CardList
| import React from 'react'
import Card from './card'
class CardList extends React.Component {
render() {
return (
<ul>
{this.props.cards.map(card => {
return <li>
<Card {...card} />
</li>
})}
</ul>
)
}
}
export default CardList
| Use Card instead of text inside CardList | Use Card instead of text inside CardList | JSX | mit | adelgado/linkbag,adelgado/linkbag | ---
+++
@@ -1,11 +1,16 @@
import React from 'react'
+import Card from './card'
class CardList extends React.Component {
render() {
return (
<ul>
- {this.props.cards.map(card => <li>{card.url}</li>)}
+ {this.props.cards.map(card => {
+ return <li>
+ <Card {...card} />
+ </li>
+ })}
</ul>
)
} |
a02c054dbc1bc56af3f6edf94acddc0baac89e3b | web/components/common/PressAndHoldButton/index.jsx | web/components/common/PressAndHoldButton/index.jsx | import React from 'react';
export default class PressAndHoldButton extends React.Component {
componentWillMount() {
this.timeout = null;
this.interval = null;
}
componentWillUnmount() {
this.handleRelease();
}
handleHoldDown() {
let that = this;
let delay = Number(this.props.delay) || 500;
let throttle = Number(this.props.throttle) || 50;
this.timeout = setTimeout(function() {
that.handleRelease();
that.interval = setInterval(function() {
if (that.interval) {
that.props.onClick();
}
}, throttle);
}, delay);
}
handleRelease() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
if (this.interval) {
clearInterval(this.interval);
this.interval = null;
}
}
render() {
let { type, className, onClick } = this.props;
type = type || 'button';
className = className || 'btn';
return (
<button
type={type}
className={className}
onClick={onClick}
onMouseDown={::this.handleHoldDown}
onMouseUp={::this.handleRelease}
onMouseLeave={::this.handleRelease}
>
{this.props.children}
</button>
);
}
}
| import React from 'react';
import joinClasses from 'react/lib/joinClasses';
export default class PressAndHoldButton extends React.Component {
componentWillMount() {
this.timeout = null;
this.interval = null;
}
componentWillUnmount() {
this.handleRelease();
}
handleHoldDown() {
let that = this;
let delay = Number(this.props.delay) || 500;
let throttle = Number(this.props.throttle) || 50;
this.timeout = setTimeout(function() {
that.handleRelease();
that.interval = setInterval(function() {
if (that.interval) {
that.props.onClick();
}
}, throttle);
}, delay);
}
handleRelease() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
if (this.interval) {
clearInterval(this.interval);
this.interval = null;
}
}
render() {
let { type, className, onClick } = this.props;
type = type || 'button';
className = joinClasses('btn', className);
return (
<button
type={type}
className={className}
onClick={onClick}
onMouseDown={::this.handleHoldDown}
onMouseUp={::this.handleRelease}
onMouseLeave={::this.handleRelease}
>
{this.props.children}
</button>
);
}
}
| Use joinClasses() to join class with this.props.className | Use joinClasses() to join class with this.props.className
| JSX | mit | cheton/cnc.js,cheton/cnc,cncjs/cncjs,cncjs/cncjs,cheton/piduino-grbl,cheton/cnc.js,cheton/piduino-grbl,cheton/cnc.js,cncjs/cncjs,cheton/cnc,cheton/piduino-grbl,cheton/cnc | ---
+++
@@ -1,4 +1,5 @@
import React from 'react';
+import joinClasses from 'react/lib/joinClasses';
export default class PressAndHoldButton extends React.Component {
componentWillMount() {
@@ -36,7 +37,7 @@
render() {
let { type, className, onClick } = this.props;
type = type || 'button';
- className = className || 'btn';
+ className = joinClasses('btn', className);
return (
<button |
87ba36e1854866e9496c66d6105b2e8cff4b63fd | src/components/atoms/ReloadButton/ReloadButton.jsx | src/components/atoms/ReloadButton/ReloadButton.jsx | /*
Copyright (C) 2017 Cloudbase Solutions SRL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import styled from 'styled-components'
import reloadImage from './images/reload.svg'
const Wrapper = styled.div`
width: 16px;
height: 16px;
background: url('${reloadImage}') no-repeat center;
cursor: pointer;
`
class ReloadButton extends React.Component {
render() {
return (
<Wrapper {...this.props} />
)
}
}
export default ReloadButton
| /*
Copyright (C) 2017 Cloudbase Solutions SRL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import styled, { injectGlobal } from 'styled-components'
import PropTypes from 'prop-types'
import reloadImage from './images/reload.svg'
const Wrapper = styled.div`
width: 16px;
height: 16px;
background: url('${reloadImage}') no-repeat center;
cursor: pointer;
`
injectGlobal`
.reload-animation {
transform: rotate(360deg);
transition: transform 1s cubic-bezier(0, 1.4, 1, 1);
}
`
class ReloadButton extends React.Component {
static propTypes = {
onClick: PropTypes.func,
}
onClick() {
if (this.timeout) {
return
}
if (this.props.onClick) {
this.props.onClick()
}
this.wrapper.className += ' reload-animation'
this.timeout = setTimeout(() => {
this.wrapper.className = this.wrapper.className.substr(0, this.wrapper.className.indexOf(' reload-animation'))
this.timeout = null
}, 1000)
}
render() {
return (
<Wrapper innerRef={div => { this.wrapper = div }} {...this.props} onClick={() => { this.onClick() }} />
)
}
}
export default ReloadButton
| Add `Reload` button animation to lists | Add `Reload` button animation to lists
| JSX | agpl-3.0 | aznashwan/coriolis-web,aznashwan/coriolis-web | ---
+++
@@ -13,7 +13,8 @@
*/
import React from 'react'
-import styled from 'styled-components'
+import styled, { injectGlobal } from 'styled-components'
+import PropTypes from 'prop-types'
import reloadImage from './images/reload.svg'
@@ -24,10 +25,37 @@
cursor: pointer;
`
+injectGlobal`
+ .reload-animation {
+ transform: rotate(360deg);
+ transition: transform 1s cubic-bezier(0, 1.4, 1, 1);
+ }
+`
+
class ReloadButton extends React.Component {
+ static propTypes = {
+ onClick: PropTypes.func,
+ }
+
+ onClick() {
+ if (this.timeout) {
+ return
+ }
+
+ if (this.props.onClick) {
+ this.props.onClick()
+ }
+
+ this.wrapper.className += ' reload-animation'
+ this.timeout = setTimeout(() => {
+ this.wrapper.className = this.wrapper.className.substr(0, this.wrapper.className.indexOf(' reload-animation'))
+ this.timeout = null
+ }, 1000)
+ }
+
render() {
return (
- <Wrapper {...this.props} />
+ <Wrapper innerRef={div => { this.wrapper = div }} {...this.props} onClick={() => { this.onClick() }} />
)
}
} |
2fd15799dd81bee5fce425c8a949a80634ce8f5e | client/src/js/components/Main/options/Jobs/Task.jsx | client/src/js/components/Main/options/Jobs/Task.jsx | /**
* @license
* The MIT License (MIT)
* Copyright 2015 Government of Canada
*
* @author
* Ian Boyes
*
* @exports Task
*/
'use strict';
var _ = require('lodash');
var React = require('react');
var Row = require('react-bootstrap/lib/Row');
var Col = require('react-bootstrap/lib/Col');
var ListGroupItem = require('react-bootstrap/lib/ListGroupItem');
var TaskField = require('./TaskField.jsx');
/**
* A ListGroupItem-based form component that allows editing of task-specific resource limits in form child components.
*/
var Task = React.createClass({
propTypes: {
taskPrefix: React.PropTypes.string.isRequired
},
render: function () {
var readOnly = _.includes(['add_host', 'rebuild'], this.props.taskPrefix);
return (
<ListGroupItem>
<h5><strong>{_.startCase(this.props.taskPrefix)}</strong></h5>
<Row>
<Col md={4}>
<TaskField {...this.props} resource='proc' readOnly={readOnly} />
</Col>
<Col md={4}>
<TaskField {...this.props} resource='mem' readOnly={readOnly} />
</Col>
<Col md={4}>
<TaskField {...this.props} resource='inst' readOnly={this.props.taskPrefix === 'rebuild'} />
</Col>
</Row>
</ListGroupItem>
);
}
});
module.exports = Task; | /**
* @license
* The MIT License (MIT)
* Copyright 2015 Government of Canada
*
* @author
* Ian Boyes
*
* @exports Task
*/
'use strict';
var _ = require('lodash');
var React = require('react');
var Row = require('react-bootstrap/lib/Row');
var Col = require('react-bootstrap/lib/Col');
var ListGroupItem = require('react-bootstrap/lib/ListGroupItem');
var TaskField = require('./TaskField.jsx');
/**
* A ListGroupItem-based form component that allows editing of task-specific resource limits in form child components.
*/
var Task = React.createClass({
propTypes: {
taskPrefix: React.PropTypes.string.isRequired
},
render: function () {
var readOnly = _.includes(['add_host', 'rebuild'], this.props.taskPrefix);
var displayName = this.props.taskPrefix === 'nuvs' ? 'NuVs': _.startCase(this.props.taskPrefix);
return (
<ListGroupItem>
<h5><strong>{displayName}</strong></h5>
<Row>
<Col md={4}>
<TaskField {...this.props} resource='proc' readOnly={readOnly} />
</Col>
<Col md={4}>
<TaskField {...this.props} resource='mem' readOnly={readOnly} />
</Col>
<Col md={4}>
<TaskField {...this.props} resource='inst' readOnly={this.props.taskPrefix === 'rebuild'} />
</Col>
</Row>
</ListGroupItem>
);
}
});
module.exports = Task; | Make nuvs show as NuVs instead of Nuvs in task-specific limits | Make nuvs show as NuVs instead of Nuvs in task-specific limits
| JSX | mit | virtool/virtool,virtool/virtool,igboyes/virtool,igboyes/virtool | ---
+++
@@ -31,9 +31,11 @@
render: function () {
var readOnly = _.includes(['add_host', 'rebuild'], this.props.taskPrefix);
+ var displayName = this.props.taskPrefix === 'nuvs' ? 'NuVs': _.startCase(this.props.taskPrefix);
+
return (
<ListGroupItem>
- <h5><strong>{_.startCase(this.props.taskPrefix)}</strong></h5>
+ <h5><strong>{displayName}</strong></h5>
<Row>
<Col md={4}>
<TaskField {...this.props} resource='proc' readOnly={readOnly} /> |
6527704462a001f79597292c344a6c16ef1cc603 | src/request/components/request-user-list-view.jsx | src/request/components/request-user-list-view.jsx | var React = require('react'),
ReactCSSTransitionGroup = React.addons.CSSTransitionGroup,
UserItem = require('./request-user-list-item-view.jsx');
module.exports = React.createClass({
render: function() {
var users = [];
for (var key in this.props.allUsers) {
var user = this.props.allUsers[key];
users.push(<UserItem key={user.id} user={user} />);
}
var message = (users.length === 0) ? <em>No found users.</em> : '';
return (
<div className="request-user-list-holder">
<ReactCSSTransitionGroup component={React.DOM.div} transitionName="request-user-item-holder" transitionLeave={false}>
{users}
</ReactCSSTransitionGroup>
{message}
</div>
);
}
});
| var React = require('react'),
ReactCSSTransitionGroup = React.addons.CSSTransitionGroup,
UserItem = require('./request-user-list-item-view.jsx');
module.exports = React.createClass({
render: function() {
var users = [];
for (var key in this.props.allUsers) {
var user = this.props.allUsers[key];
users.push(<UserItem key={user.details.id} user={user} />);
}
var message = (users.length === 0) ? <em>No found users.</em> : '';
return (
<div className="request-user-list-holder">
<ReactCSSTransitionGroup component={React.DOM.div} transitionName="request-user-item-holder" transitionLeave={false}>
{users}
</ReactCSSTransitionGroup>
{message}
</div>
);
}
});
| Fix the id being used for the key in the user list | Fix the id being used for the key in the user list
| JSX | unknown | Glimpse/Glimpse.Client.Prototype,avanderhoorn/Glimpse.Client.Prototype,Glimpse/Glimpse.Client.Prototype,avanderhoorn/Glimpse.Client.Prototype,Glimpse/Glimpse.Client.Prototype | ---
+++
@@ -8,7 +8,7 @@
for (var key in this.props.allUsers) {
var user = this.props.allUsers[key];
- users.push(<UserItem key={user.id} user={user} />);
+ users.push(<UserItem key={user.details.id} user={user} />);
}
var message = (users.length === 0) ? <em>No found users.</em> : ''; |
06a69b52b71c44f9b15d658c3ad23402ec71227d | src/pages/home/components/add-note-form/components/field-error/field-error.jsx | src/pages/home/components/add-note-form/components/field-error/field-error.jsx | // @flow
import React from 'react';
import PropTypes from 'prop-types';
import { Field } from 'react-final-form';
import './field-error.scss';
const FieldError = ({ name }) => (
<Field
name={name}
subscription={{ touched: true, error: true }}
render={({ meta: { touched, error } }) =>
touched && error ? <div className="field-error">{error}</div> : null
}
/>
);
FieldError.propTypes = {
name: PropTypes.string.isRequired
};
export default FieldError;
| // @flow
import React from 'react';
import PropTypes from 'prop-types';
import { Field } from 'react-final-form';
import { toClass } from 'recompose';
import './field-error.scss';
const FieldError = ({ name }) => (
<Field
name={name}
subscription={{ touched: true, error: true }}
render={({ meta: { touched, error } }) =>
touched && error ? <div className="field-error">{error}</div> : null
}
/>
);
FieldError.propTypes = {
name: PropTypes.string.isRequired
};
export default toClass(FieldError);
| Fix broken <FieldError /> (by unknown reason preact is ignoring functional components) | Fix broken <FieldError /> (by unknown reason preact is ignoring functional components)
| JSX | mit | ArturJS/ArturJS.github.io,ArturJS/ArturJS.github.io | ---
+++
@@ -2,6 +2,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Field } from 'react-final-form';
+import { toClass } from 'recompose';
import './field-error.scss';
const FieldError = ({ name }) => (
@@ -18,4 +19,4 @@
name: PropTypes.string.isRequired
};
-export default FieldError;
+export default toClass(FieldError); |
cdabcd44552b1363b289277fb9212b0058890e2f | packages/lesswrong/components/search/UsersSearchInput.jsx | packages/lesswrong/components/search/UsersSearchInput.jsx | import { Components, registerComponent} from 'meteor/vulcan:core';
import React, { PureComponent } from 'react';
import Input from '@material-ui/core/Input';
import InputAdornment from '@material-ui/core/InputAdornment';
import Icon from '@material-ui/core/Icon'
import { withStyles } from '@material-ui/core/styles';
const styles = theme => ({
input: {
// this needs to be here because of Bootstrap. I am sorry :(
padding: "6px 0 7px !important",
fontSize: "13px !important",
width: 120,
}
})
const UsersSearchInput = ({ inputProps, classes }) => <Input
{ ...inputProps}
classes={{input: classes.input}}
startAdornment={
<InputAdornment position="start">
<Icon>person_add</Icon>
</InputAdornment>}
/>
registerComponent("UsersSearchInput", UsersSearchInput,
withStyles(styles, { name: "UsersSearchInput" })
);
| import { Components, registerComponent} from 'meteor/vulcan:core';
import React, { PureComponent } from 'react';
import Input from '@material-ui/core/Input';
import InputAdornment from '@material-ui/core/InputAdornment';
import Icon from '@material-ui/core/Icon'
import { withStyles } from '@material-ui/core/styles';
const styles = theme => ({
input: {
// this needs to be here because of Bootstrap. I am sorry :(
padding: "6px 0 7px !important",
fontSize: "13px !important",
width: 120,
}
})
const UsersSearchInput = ({ inputProps, classes }) => {
return <Input
inputProps={inputProps}
className={classes.input}
startAdornment={
<InputAdornment position="start">
<Icon>person_add</Icon>
</InputAdornment>
}
/>
};
registerComponent("UsersSearchInput", UsersSearchInput,
withStyles(styles, { name: "UsersSearchInput" })
);
| Fix 'input.focus is not a function' console error | Fix 'input.focus is not a function' console error
| JSX | mit | Discordius/Lesswrong2,Discordius/Lesswrong2,Discordius/Lesswrong2,Discordius/Telescope,Discordius/Telescope,Discordius/Telescope,Discordius/Telescope,Discordius/Lesswrong2 | ---
+++
@@ -14,14 +14,17 @@
}
})
-const UsersSearchInput = ({ inputProps, classes }) => <Input
- { ...inputProps}
- classes={{input: classes.input}}
- startAdornment={
- <InputAdornment position="start">
- <Icon>person_add</Icon>
- </InputAdornment>}
- />
+const UsersSearchInput = ({ inputProps, classes }) => {
+ return <Input
+ inputProps={inputProps}
+ className={classes.input}
+ startAdornment={
+ <InputAdornment position="start">
+ <Icon>person_add</Icon>
+ </InputAdornment>
+ }
+ />
+};
registerComponent("UsersSearchInput", UsersSearchInput,
withStyles(styles, { name: "UsersSearchInput" }) |
4963e37de2f466255d6c0061be3f061f2c912900 | app/assets/javascripts/components/edit-player-selection-row.jsx | app/assets/javascripts/components/edit-player-selection-row.jsx | import HeroSelect from './hero-select.jsx'
import PlayerSelect from './player-select.jsx'
class EditPlayerSelectionRow extends React.Component {
render() {
const { inputID, selectedPlayer, nameLabel, onHeroSelection,
mapSegments, onPlayerSelection, players, heroes,
selections } = this.props
return (
<tr>
<td className="player-cell">
<PlayerSelect
inputID={inputID}
label={nameLabel}
selectedPlayer={selectedPlayer}
players={players}
onChange={(playerID, name) => onPlayerSelection(playerID, name)}
/>
</td>
{mapSegments.map(segment => (
<td key={segment.id} className="hero-select-cell">
<HeroSelect
heroes={heroes}
disabled={typeof selectedPlayer.id !== 'number'}
selectedHeroID={selections[segment.id]}
onChange={heroID => onHeroSelection(heroID, segment.id)}
/>
</td>
))}
</tr>
)
}
}
EditPlayerSelectionRow.propTypes = {
inputID: React.PropTypes.string.isRequired,
selectedPlayer: React.PropTypes.object.isRequired,
players: React.PropTypes.array.isRequired,
onPlayerSelection: React.PropTypes.func.isRequired,
nameLabel: React.PropTypes.string.isRequired,
onHeroSelection: React.PropTypes.func.isRequired,
mapSegments: React.PropTypes.array.isRequired,
heroes: React.PropTypes.array.isRequired,
selections: React.PropTypes.object.isRequired
}
export default EditPlayerSelectionRow
| import HeroSelect from './hero-select.jsx'
import PlayerSelect from './player-select.jsx'
const EditPlayerSelectionRow = function(props) {
const { inputID, selectedPlayer, nameLabel, onHeroSelection,
mapSegments, onPlayerSelection, players, heroes,
selections } = props
return (
<tr>
<td className="player-cell">
<PlayerSelect
inputID={inputID}
label={nameLabel}
selectedPlayer={selectedPlayer}
players={players}
onChange={(playerID, name) => onPlayerSelection(playerID, name)}
/>
</td>
{mapSegments.map(segment => (
<td key={segment.id} className="hero-select-cell">
<HeroSelect
heroes={heroes}
disabled={typeof selectedPlayer.id !== 'number'}
selectedHeroID={selections[segment.id]}
onChange={heroID => onHeroSelection(heroID, segment.id)}
/>
</td>
))}
</tr>
)
}
EditPlayerSelectionRow.propTypes = {
inputID: React.PropTypes.string.isRequired,
selectedPlayer: React.PropTypes.object.isRequired,
players: React.PropTypes.array.isRequired,
onPlayerSelection: React.PropTypes.func.isRequired,
nameLabel: React.PropTypes.string.isRequired,
onHeroSelection: React.PropTypes.func.isRequired,
mapSegments: React.PropTypes.array.isRequired,
heroes: React.PropTypes.array.isRequired,
selections: React.PropTypes.object.isRequired
}
export default EditPlayerSelectionRow
| Fix style linter error about pure stateless function | Fix style linter error about pure stateless function
| JSX | mit | cheshire137/overwatch-team-comps,cheshire137/overwatch-team-comps,cheshire137/overwatch-team-comps | ---
+++
@@ -1,35 +1,33 @@
import HeroSelect from './hero-select.jsx'
import PlayerSelect from './player-select.jsx'
-class EditPlayerSelectionRow extends React.Component {
- render() {
- const { inputID, selectedPlayer, nameLabel, onHeroSelection,
- mapSegments, onPlayerSelection, players, heroes,
- selections } = this.props
- return (
- <tr>
- <td className="player-cell">
- <PlayerSelect
- inputID={inputID}
- label={nameLabel}
- selectedPlayer={selectedPlayer}
- players={players}
- onChange={(playerID, name) => onPlayerSelection(playerID, name)}
+const EditPlayerSelectionRow = function(props) {
+ const { inputID, selectedPlayer, nameLabel, onHeroSelection,
+ mapSegments, onPlayerSelection, players, heroes,
+ selections } = props
+ return (
+ <tr>
+ <td className="player-cell">
+ <PlayerSelect
+ inputID={inputID}
+ label={nameLabel}
+ selectedPlayer={selectedPlayer}
+ players={players}
+ onChange={(playerID, name) => onPlayerSelection(playerID, name)}
+ />
+ </td>
+ {mapSegments.map(segment => (
+ <td key={segment.id} className="hero-select-cell">
+ <HeroSelect
+ heroes={heroes}
+ disabled={typeof selectedPlayer.id !== 'number'}
+ selectedHeroID={selections[segment.id]}
+ onChange={heroID => onHeroSelection(heroID, segment.id)}
/>
</td>
- {mapSegments.map(segment => (
- <td key={segment.id} className="hero-select-cell">
- <HeroSelect
- heroes={heroes}
- disabled={typeof selectedPlayer.id !== 'number'}
- selectedHeroID={selections[segment.id]}
- onChange={heroID => onHeroSelection(heroID, segment.id)}
- />
- </td>
- ))}
- </tr>
- )
- }
+ ))}
+ </tr>
+ )
}
EditPlayerSelectionRow.propTypes = { |
46c194c20ab433e53ec969337cfff29e7698a981 | src/FormsyText.jsx | src/FormsyText.jsx | import React from 'react';
import Formsy from 'formsy-react';
import TextField from 'material-ui/lib/text-field';
let FormsyText = React.createClass({
mixins: [ Formsy.Mixin ],
propTypes: {
name: React.PropTypes.string.isRequired,
value: React.PropTypes.string
},
handleChange: function handleChange(event) {
if(this.getErrorMessage() != null){
this.setValue(event.currentTarget.value);
}
else{
if (this.isValidValue(event.target.value)) {
this.setValue(event.target.value);
}
else{
this.setState({
_value: event.currentTarget.value,
_isPristine: false
});
}
}
},
handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
},
handleEnterKeyDown: function handleEnterKeyDown(event) {
this.setValue(event.currentTarget.value);
},
render: function () {
return (
<TextField
{...this.props}
defaultValue={this.props.value}
onChange={this.handleChange}
onBlur={this.handleBlur}
onEnterKeyDown={this.handleEnterKeyDown}
errorText={this.getErrorMessage()}
value={this.getValue()}
/>
);
}
});
module.exports = FormsyText;
| import React from 'react';
import Formsy from 'formsy-react';
import TextField from 'material-ui/lib/text-field';
let FormsyText = React.createClass({
mixins: [ Formsy.Mixin ],
propTypes: {
name: React.PropTypes.string.isRequired,
value: React.PropTypes.string,
onFocus: React.PropTypes.func,
onBlur: React.PropTypes.func
},
handleChange: function handleChange(event) {
if(this.getErrorMessage() != null){
this.setValue(event.currentTarget.value);
}
else{
if (this.isValidValue(event.target.value)) {
this.setValue(event.target.value);
}
else{
this.setState({
_value: event.currentTarget.value,
_isPristine: false
});
}
}
},
handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
if (this.props.onBlur) this.props.onBlur(event);
},
handleEnterKeyDown: function handleEnterKeyDown(event) {
this.setValue(event.currentTarget.value);
},
render: function () {
return (
<TextField
{...this.props}
defaultValue={this.props.value}
onChange={this.handleChange}
onBlur={this.handleBlur}
onFocus={this.props.onFocus}
onEnterKeyDown={this.handleEnterKeyDown}
errorText={this.getErrorMessage()}
value={this.getValue()}
/>
);
}
});
module.exports = FormsyText;
| Add custom onBlur and onFocus handler support | Add custom onBlur and onFocus handler support
Pass event to onBlur
| JSX | mit | rojobuffalo/formsy-material-ui,Aweary/formsy-material-ui,alan-cruz2/formsy-material-ui,mbrookes/formsy-material-ui | ---
+++
@@ -7,7 +7,9 @@
propTypes: {
name: React.PropTypes.string.isRequired,
- value: React.PropTypes.string
+ value: React.PropTypes.string,
+ onFocus: React.PropTypes.func,
+ onBlur: React.PropTypes.func
},
handleChange: function handleChange(event) {
@@ -29,6 +31,7 @@
handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
+ if (this.props.onBlur) this.props.onBlur(event);
},
handleEnterKeyDown: function handleEnterKeyDown(event) {
@@ -42,6 +45,7 @@
defaultValue={this.props.value}
onChange={this.handleChange}
onBlur={this.handleBlur}
+ onFocus={this.props.onFocus}
onEnterKeyDown={this.handleEnterKeyDown}
errorText={this.getErrorMessage()}
value={this.getValue()} |
f11127b209031c93e73dc97dd441337411950d04 | packages/vulcan-accounts/imports/ui/components/EnrollAccount.jsx | packages/vulcan-accounts/imports/ui/components/EnrollAccount.jsx | import { Components, registerComponent, withCurrentUser } from 'meteor/vulcan:core';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { intlShape } from 'meteor/vulcan:i18n';
import { STATES } from '../../helpers.js';
class AccountsEnrollAccount extends PureComponent {
componentDidMount() {
const token = this.props.params.token;
Accounts._loginButtonsSession.set('enrollAccountToken', token);
}
render() {
if (!this.props.currentUser) {
return (
<Components.AccountsLoginForm
formState={ STATES.ENROLL_ACCOUNT }
/>
);
} else {
return (
<div className='password-reset-form'>
<div>{this.context.intl.formatMessage({id: 'accounts.info_password_changed'})}!</div>
</div>
);
}
}
}
AccountsEnrollAccount.contextTypes = {
intl: intlShape
}
AccountsEnrollAccount.propsTypes = {
currentUser: PropTypes.object,
params: PropTypes.object,
};
AccountsEnrollAccount.displayName = 'AccountsEnrollAccount';
registerComponent('AccountsEnrollAccount', AccountsEnrollAccount, withCurrentUser);
| import { Components, registerComponent, withCurrentUser } from 'meteor/vulcan:core';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { intlShape } from 'meteor/vulcan:i18n';
import { STATES } from '../../helpers.js';
class AccountsEnrollAccount extends PureComponent {
componentDidMount() {
const token = this.props.params.token;
Accounts._loginButtonsSession.set('enrollAccountToken', token);
}
render() {
if (!this.props.currentUser) {
return (
<Components.AccountsLoginForm
formState={ STATES.ENROLL_ACCOUNT }
/>
);
} else {
return (
<div className='password-reset-form'>
<div>{this.context.intl.formatMessage({id: 'accounts.info_password_changed'})}</div>
</div>
);
}
}
}
AccountsEnrollAccount.contextTypes = {
intl: intlShape
}
AccountsEnrollAccount.propsTypes = {
currentUser: PropTypes.object,
params: PropTypes.object,
};
AccountsEnrollAccount.displayName = 'AccountsEnrollAccount';
registerComponent('AccountsEnrollAccount', AccountsEnrollAccount, withCurrentUser);
| Fix punctuation glitch on password reset page | Fix punctuation glitch on password reset page
The localizations of `accounts.info_password_changed` all end in a
period, so adding an exclamation point after it results in "Password
changed.!" which is incorrect punctuation.
| JSX | mit | Discordius/Telescope,Discordius/Lesswrong2,Discordius/Telescope,Discordius/Telescope,Discordius/Telescope,Discordius/Lesswrong2,Discordius/Lesswrong2,Discordius/Lesswrong2 | ---
+++
@@ -20,7 +20,7 @@
} else {
return (
<div className='password-reset-form'>
- <div>{this.context.intl.formatMessage({id: 'accounts.info_password_changed'})}!</div>
+ <div>{this.context.intl.formatMessage({id: 'accounts.info_password_changed'})}</div>
</div>
);
} |
Subsets and Splits