path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
src/order/index.js | Wenqer/food-proto | import React from 'react'
import Item from './item2'
document.body.style.margin = 0
const ordersMock = [
{
// title: 'Жареная курица в панировке Торикацу',
title: 'Жареная курица в япoнской панировке Торикацу',
price: 87,
},
{
title: 'Лимонад классический с мятой',
price: 20.02,
},
{
title: 'Каліфорнія зі свіжим лососем в ікрі',
price: 69,
},
{
title: 'Жареная курица в панировке Торикацу',
// title: 'Жареная курица в япoнской панировке Торикацу',
price: 87,
},
{
title: 'Лимонад классический с мятой',
price: 20.02,
},
{
title: 'Каліфорнія зі свіжим лососем в ікрі',
price: 69,
},
]
const containerStyles = {
listStyle: 'none',
// margin: '10px',
overflow: 'hidden',
margin: 0,
padding: 0,
display: 'block',
fontSize: '90%',
fontFamily: 'Lato, Helvetica, Arial, sans-serif',
// width: '400px',
width: '100vw',
}
class Order extends React.Component {
constructor(...args) {
super(...args)
this.state = {
orders: ordersMock,
}
this.remove = this.remove.bind(this)
}
remove(pos) {
this.setState({
orders: this.state.orders.filter((o, i) => i !== pos),
})
}
render() {
return (
<section style={containerStyles}>
{this.state.orders.map((data, pos) => <Item {...data} remove={this.remove} pos={pos} />)}
</section>
)
}
}
// Order.propTypes = {
// children: React.PropTypes.string.isRequired,
// onClick: React.PropTypes.func,
// style: React.PropTypes.object,
// }
export default Order
|
src/components/LoginForm/LoginForm.js | cyberid41/simple-blog-react | import React, { Component } from 'react';
import { reduxForm, Field, propTypes } from 'redux-form';
import loginValidation from './loginValidation';
@reduxForm({
form: 'login',
validate: loginValidation
})
export default class LoginForm extends Component {
static propTypes = {
...propTypes
}
renderInput = ({ input, label, type, meta: { touched, error } }) =>
<div className={`form-group ${error && touched ? 'has-error' : ''}`}>
<label htmlFor={input.name} className="col-sm-2">{label}</label>
<div className="col-sm-10">
<input {...input} type={type} className="form-control" />
{error && touched && <span className="glyphicon glyphicon-remove form-control-feedback"></span>}
{error && touched && <div className="text-danger"><strong>{error}</strong></div>}
</div>
</div>;
render() {
const { handleSubmit, error } = this.props;
return (
<form className="form-horizontal" onSubmit={handleSubmit}>
<Field name="email" type="text" component={this.renderInput} label="Email" />
<Field name="password" type="password" component={this.renderInput} label="Password" />
{error && <p className="text-danger"><strong>{error}</strong></p>}
<button className="btn btn-success" type="submit">
<i className="fa fa-sign-in" />{' '}Log In
</button>
</form>
);
}
}
|
src/client/pages/tocheckitem.react.js | jaegerpicker/GLDice | import Component from '../components/component.react';
import React from 'react';
import {FormattedHTMLMessage} from 'react-intl';
class ToCheckItem extends Component {
static propTypes = {
item: React.PropTypes.object.isRequired
};
render() {
return (
<li>
<FormattedHTMLMessage message={this.props.item.get('txt')} />
</li>
);
}
}
export default ToCheckItem;
|
app/javascript/mastodon/components/icon_button.js | unarist/mastodon | import React from 'react';
import Motion from '../features/ui/util/optional_motion';
import spring from 'react-motion/lib/spring';
import PropTypes from 'prop-types';
import classNames from 'classnames';
export default class IconButton extends React.PureComponent {
static propTypes = {
className: PropTypes.string,
title: PropTypes.string.isRequired,
icon: PropTypes.string.isRequired,
onClick: PropTypes.func,
size: PropTypes.number,
active: PropTypes.bool,
pressed: PropTypes.bool,
expanded: PropTypes.bool,
style: PropTypes.object,
activeStyle: PropTypes.object,
disabled: PropTypes.bool,
inverted: PropTypes.bool,
animate: PropTypes.bool,
overlay: PropTypes.bool,
tabIndex: PropTypes.string,
};
static defaultProps = {
size: 18,
active: false,
disabled: false,
animate: false,
overlay: false,
tabIndex: '0',
};
handleClick = (e) => {
e.preventDefault();
if (!this.props.disabled) {
this.props.onClick(e);
}
}
render () {
const style = {
fontSize: `${this.props.size}px`,
width: `${this.props.size * 1.28571429}px`,
height: `${this.props.size * 1.28571429}px`,
lineHeight: `${this.props.size}px`,
...this.props.style,
...(this.props.active ? this.props.activeStyle : {}),
};
const {
active,
animate,
className,
disabled,
expanded,
icon,
inverted,
overlay,
pressed,
tabIndex,
title,
} = this.props;
const classes = classNames(className, 'icon-button', {
active,
disabled,
inverted,
overlayed: overlay,
});
if (!animate) {
// Perf optimization: avoid unnecessary <Motion> components unless
// we actually need to animate.
return (
<button
aria-label={title}
aria-pressed={pressed}
aria-expanded={expanded}
title={title}
className={classes}
onClick={this.handleClick}
style={style}
tabIndex={tabIndex}
>
<i className={`fa fa-fw fa-${icon}`} aria-hidden='true' />
</button>
);
}
return (
<Motion defaultStyle={{ rotate: active ? -360 : 0 }} style={{ rotate: animate ? spring(active ? -360 : 0, { stiffness: 120, damping: 7 }) : 0 }}>
{({ rotate }) => (
<button
aria-label={title}
aria-pressed={pressed}
aria-expanded={expanded}
title={title}
className={classes}
onClick={this.handleClick}
style={style}
tabIndex={tabIndex}
>
<i style={{ transform: `rotate(${rotate}deg)` }} className={`fa fa-fw fa-${icon}`} aria-hidden='true' />
</button>
)}
</Motion>
);
}
}
|
components/tree/demo/line.js | TDFE/td-ui | import React from 'react';
import Tree from '../index';
const TreeNode = Tree.TreeNode;
export default class Line extends React.Component {
onSelect = (selectedKeys, info) => {
console.log('selected', selectedKeys, info);
}
render() {
return (
<Tree
showLine
defaultExpandedKeys={['0-0-0']}
onSelect={this.onSelect}
checkable
>
<TreeNode title="parent 1" key="0-0">
<TreeNode title="parent 1-0" key="0-0-0">
<TreeNode title="leaf" key="0-0-0-0" />
<TreeNode title="leaf" key="0-0-0-1" />
<TreeNode title="leaf" key="0-0-0-2" />
</TreeNode>
<TreeNode title="parent 1-1" key="0-0-1">
<TreeNode title="leaf" key="0-0-1-0" />
</TreeNode>
<TreeNode title="parent 1-2" key="0-0-2">
<TreeNode title="leaf" key="0-0-2-0" />
<TreeNode title="leaf" key="0-0-2-1" />
</TreeNode>
</TreeNode>
</Tree>
);
}
}
|
src/svg-icons/places/room-service.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let PlacesRoomService = (props) => (
<SvgIcon {...props}>
<path d="M2 17h20v2H2zm11.84-9.21c.1-.24.16-.51.16-.79 0-1.1-.9-2-2-2s-2 .9-2 2c0 .28.06.55.16.79C6.25 8.6 3.27 11.93 3 16h18c-.27-4.07-3.25-7.4-7.16-8.21z"/>
</SvgIcon>
);
PlacesRoomService = pure(PlacesRoomService);
PlacesRoomService.displayName = 'PlacesRoomService';
PlacesRoomService.muiName = 'SvgIcon';
export default PlacesRoomService;
|
frontend/src/components/Home.js | mqklin/results | import React from 'react';
class ArticleRow extends React.Component {
render() {
return (
<tr>
<td>{this.props.article.author}</td>
<td><a href={this.props.article.url} target="_blank">{this.props.article.description}</a></td>
<td>{this.props.article.categories.join(', ')}</td>
<td>{this.props.article.tags.join(', ')}</td>
<td>{`${this.props.article.rating}/10`}</td>
</tr>
);
}
}
class ArticlesTable extends React.Component {
render() {
let rows = [];
for (let article of this.props.articles) {
for (let [k, v] of Object.entries(article)) {
if (k === "url") continue;
if (Object.prototype.toString.call(v) === '[object Array]'){
v = v.join(", ");
}
if (~v.indexOf(this.props.searchValue)) {
rows.push(<ArticleRow article={article}/>);
break;
}
}
}
return (
<table className="main__tableData">
<thead>
<tr>
<th>Шарер</th>
<th>Название и ссылка</th>
<th>Категории</th>
<th>Ключевые слова</th>
<th>Рейтинг</th>
</tr>
</thead>
<tbody>
{rows}
</tbody>
</table>
);
}
}
export default class extends React.Component {
constructor(options){
super(options);
this.state = {
"articles": [],
"searchValue": ""
};
}
handleChange(event) {
this.setState({"searchValue": event.target.value});
}
async componentWillMount() {
let articles = await this.props.controller.getArticles();
this.setState({"articles": articles});
this.props.controller.getArticles();
}
componentDidUpdate() {
let tds = document
.getElementsByClassName("main__tableData")[0]
.getElementsByTagName("tbody")[0]
.getElementsByTagName("td");
let {searchValue} = this.state;
for (let text_container of tds){
if (text_container.childNodes[0] && text_container.childNodes[0].tagName === "A") {
continue;
}
text_container.innerHTML = text_container.innerHTML.replace(/<\/?mark>/g, '');
if (searchValue &&~text_container.innerHTML.indexOf(searchValue)) {
text_container.innerHTML = text_container.innerHTML.replace(new RegExp(searchValue, 'g'), `<mark>${searchValue}</mark>`);
}
}
}
render() {
return (
<div className="main">
<a href="#add">Добавить статью</a>
<div className="main__search-div">
<input autoFocus type="text" placeholder="Поиск статьи" onChange={this.handleChange.bind(this)}/>
{/*<button type="button" onClick={this.makeSearch}/>*/}
</div>
<ArticlesTable articles={this.state.articles} searchValue={this.state.searchValue}/>
</div>
);
}
} |
client/lib/clickableItem.js | VoiSmart/Rocket.Chat | import { css } from '@rocket.chat/css-in-js';
import colors from '@rocket.chat/fuselage-tokens/colors';
import React from 'react';
const clickable = css`
cursor: pointer;
border-bottom: 2px solid ${colors.n300} !important;
&:hover,
&:focus {
background: ${colors.n100};
}
`;
// TODO remove border from here
export function clickableItem(Component) {
const WrappedComponent = (props) => <Component className={clickable} tabIndex={0} {...props} />;
WrappedComponent.displayName = `clickableItem(${
Component.displayName ?? Component.name ?? 'Component'
})`;
return WrappedComponent;
}
|
client/src/app/redux/rootView.js | Einsteinish/DumbNode | import React from 'react';
import { Provider } from 'react-redux'
import Routes from '../routes'
import Debug from 'debug';
let debug = new Debug("rootView");
export default function RootView(store, parts){
debug('init');
const routes = Routes(store, parts)
const Intl = parts.core.containers.intl();
const Router = parts.core.createRouter(store, routes);
return (
<Provider store={store}>
<Intl>
<div style={{ height: '100%' }}>
{Router}
</div>
</Intl>
</Provider>
)
}
|
node_modules/bs-recipes/recipes/webpack.react-transform-hmr/app/js/main.js | BerniceChua/landr | import React from 'react';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
React.render(<HelloWorld />, document.getElementById('react-root'));
|
src/components/AddPeer.js | awentzonline/doppelchat | import React from 'react';
import {TextField} from 'material-ui';
import PeerActions from 'peers/PeerActions';
class AddPeerComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
peerId: ''
};
}
render() {
return (
<div className="addPeer">
<form onSubmit={this.onSubmit.bind(this)}>
<TextField
hintText="Peer ID"
floatingLabelText="Add a peer"
multiLine={false}
value={this.state.peerId}
onChange={this.onTextChanged.bind(this)}
fullWidth={true}
/>
</form>
</div>
);
}
onTextChanged(event) {
this.setState({peerId: event.target.value});
}
onSubmit(event) {
event.preventDefault();
var peerId = this.state.peerId;
if (peerId) {
PeerActions.makeCall(peerId);
}
this.setState({peerId: ''});
}
}
AddPeerComponent.defaultProps = {
};
export default AddPeerComponent;
|
index.ios.js | Matzielab/imagination-react-native | // @flow
import React, { Component } from 'react';
import {AppRegistry} from 'react-native';
import Start from './components/Start'
export default class Imagination extends Component {
render() {
return (
<Start />
);
}
}
AppRegistry.registerComponent('Imagination', () => Imagination);
|
app/user/profile/EditableProfileSkillListItem.js | sagnikm95/internship-portal | import React from 'react';
import { Label, Icon } from 'semantic-ui-react';
import PropTypes from 'prop-types';
export default class EditableProfileSkillListItem extends React.Component {
constructor() {
super();
this.handleClick = (event, data) => {
console.log(data.children[1]);
this.props.removeSkill(data.children[1]);
};
}
render() {
return (
<Label as="a" onClick={this.handleClick} style={{ margin: 10 }} ><Icon name="remove" />{this.props.skill}</Label>
);
}
}
EditableProfileSkillListItem.propTypes = {
skill: PropTypes.string.isRequired,
removeSkill: PropTypes.func.isRequired,
};
|
examples/react-es6/CheckboxWithLabel.js | createbang/jest | import React from 'react';
class CheckboxWithLabel extends React.Component {
constructor(props) {
super(props);
this.state = {isChecked: false};
// since auto-binding is disabled for React's class model
// we can prebind methods here
// http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding
this.onChange = this.onChange.bind(this);
}
onChange() {
this.setState({isChecked: !this.state.isChecked});
}
render() {
return (
<label>
<input
type="checkbox"
checked={this.state.isChecked}
onChange={this.onChange}
/>
{this.state.isChecked ? this.props.labelOn : this.props.labelOff}
</label>
);
}
}
export default CheckboxWithLabel;
|
codes/chapter06/src/containers/AddTodo.js | atlantis1024/react-step-by-step | import React from 'react'
import { connect } from 'react-redux'
import { addTodo } from '../actions'
let AddTodo = ({ dispatch }) => {
let input
return (
<div>
<form onSubmit={e => {
e.preventDefault()
if (!input.value.trim()) {
return
}
dispatch(addTodo(input.value))
input.value = ''
}}>
<input ref={node => {
input = node
}} />
<button type="submit">
Add Todo
</button>
</form>
</div>
)
}
AddTodo = connect()(AddTodo)
export default AddTodo
|
src/components/app.js | mdunnegan/ReactFrontEndAuthentication | import React, { Component } from 'react';
import Header from './header';
export default class App extends Component {
render() {
return (
<div>
<Header />
{this.props.children}
</div>
);
}
}
|
src/components/Root.js | guiconti/Buildev | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
import routes from '../routes';
import { Router } from 'react-router';
export default class Root extends Component {
render() {
const { store, history } = this.props;
return (
<Provider store={store}>
<Router history={history} routes={routes} />
</Provider>
);
}
}
Root.propTypes = {
store: PropTypes.object.isRequired,
history: PropTypes.object.isRequired
};
|
frontend/components/statistics/BigStatistics.js | datoszs/czech-lawyers | import React from 'react';
import PropTypes from 'prop-types';
import {Statistics} from '../../model';
import StatisticsColumn from './StatisticsColumn';
import styles from './BigStatistics.less';
const BigStatistics = ({statistics, msgPositive, msgNegative, msgNeutral}) => {
const max = Math.max(statistics.positive, statistics.negative, statistics.neutral);
const createColumn = (property, legend) => (
<StatisticsColumn scale={5} max={max} type={property} number={statistics[property]}>
<div className={styles.text}>{legend}</div>
</StatisticsColumn>
);
return (
<div className={styles.main}>
{createColumn('positive', msgPositive)}
{createColumn('negative', msgNegative)}
{createColumn('neutral', msgNeutral)}
</div>
);
};
BigStatistics.propTypes = {
statistics: PropTypes.instanceOf(Statistics),
msgPositive: PropTypes.string.isRequired,
msgNegative: PropTypes.string.isRequired,
msgNeutral: PropTypes.string.isRequired,
};
BigStatistics.defaultProps = {
statistics: new Statistics(),
};
export default BigStatistics;
|
src/components/TodoList.js | SaKKo/react-redux-todo-boilerplate | import React from 'react';
import { connect } from 'react-redux';
import Todo from './Todo';
import { toggleTodo } from '../actions/actions';
import { SHOW_ALL, SHOW_COMPLETED, SHOW_ACTIVE } from '../constants/ActionTypes';
const TodoList = ({
todos,
onTodoClick
}) => (
<ul>
{todos.map(todo =>
<Todo
key={todo.id}
{...todo}
onClick={() => onTodoClick(todo.id)}
/>
)}
</ul>
);
const getVisibleTodos = (
todos,
filter
) => {
switch (filter) {
case SHOW_ALL:
return todos;
case SHOW_COMPLETED:
return todos.filter(
t => t.completed
);
case SHOW_ACTIVE:
return todos.filter(
t => !t.completed
);
}
};
const mapStateToProps = (
state
) => {
return {
todos: getVisibleTodos(
state.todos,
state.visibilityFilter
)
};
};
const mapDispatchToProps = (
dispatch
) => {
return {
onTodoClick: (id) => {
dispatch(toggleTodo(id));
}
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(TodoList);
|
docs/src/SupportPage.js | bvasko/react-bootstrap | import React from 'react';
import NavMain from './NavMain';
import PageHeader from './PageHeader';
import PageFooter from './PageFooter';
export default class Page extends React.Component {
render() {
return (
<div>
<NavMain activePage="support" />
<PageHeader
title="Need help?"
subTitle="Community resources for answering your React-Bootstrap questions." />
<div className="container bs-docs-container">
<div className="row">
<div className="col-md-9" role="main">
<div className="bs-docs-section">
<p className="lead">Stay up to date on the development of React-Bootstrap and reach out to the community with these helpful resources.</p>
<h3>Stack Overflow</h3>
<p><a href="http://stackoverflow.com/questions/ask">Ask questions</a> about specific problems you have faced, including details about what exactly you are trying to do. Make sure you tag your question with <code className="js">react-bootstrap</code>. You can also read through <a href="http://stackoverflow.com/questions/tagged/react-bootstrap">existing React-Bootstrap questions</a>.</p>
<h3>Live help</h3>
<p>Bring your questions and pair with other react-bootstrap users in a <a href="http://start.thinkful.com/react/?utm_source=github&utm_medium=badge&utm_campaign=react-bootstrap">live Thinkful hangout</a>. Hear about the challenges other developers are running into, or screenshare your own code with the group for feedback.</p>
<h3>Chat rooms</h3>
<p>Discuss questions in the <code className="js">#react-bootstrap</code> channel on the <a href="http://www.reactiflux.com/">Reactiflux Slack</a> or on <a href="https://gitter.im/react-bootstrap/react-bootstrap">Gitter</a>.</p>
<h3>GitHub issues</h3>
<p>The issue tracker is the preferred channel for bug reports, features requests and submitting pull requests. See more about how we use issues in the <a href="https://github.com/react-bootstrap/react-bootstrap/blob/master/CONTRIBUTING.md#issues">contribution guidelines</a>.</p>
</div>
</div>
</div>
</div>
<PageFooter />
</div>
);
}
shouldComponentUpdate() {
return false;
}
}
|
src/components/routes/Author/Author.js | sievins/sarahs-footsteps | import React from 'react'
import profile from 'images/profile.png'
import ImageAndTextTemplate from '../ImageAndTextTemplate'
import AboutTheAuthor from './AboutTheAuthor'
const Author = () => (
<ImageAndTextTemplate img={{ src: profile, alt: 'author' }} Text={AboutTheAuthor} />
)
export default Author
|
docs/src/app/components/pages/components/LinearProgress/ExampleSimple.js | frnk94/material-ui | import React from 'react';
import LinearProgress from 'material-ui/LinearProgress';
const LinearProgressExampleSimple = () => (
<LinearProgress mode="indeterminate" />
);
export default LinearProgressExampleSimple;
|
src/svg-icons/social/notifications-none.js | tan-jerene/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let SocialNotificationsNone = (props) => (
<SvgIcon {...props}>
<path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6z"/>
</SvgIcon>
);
SocialNotificationsNone = pure(SocialNotificationsNone);
SocialNotificationsNone.displayName = 'SocialNotificationsNone';
SocialNotificationsNone.muiName = 'SvgIcon';
export default SocialNotificationsNone;
|
packages/shared/forks/object-assign.umd.js | chenglou/react | /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import React from 'react';
const ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
export default ReactInternals.assign;
|
js/webui/src/columns_settings.js | hyperblast/beefweb | import React from 'react';
import PropTypes from 'prop-types'
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
import { bindHandlers } from './utils';
import { Button, Icon } from './elements';
import ReactModal from 'react-modal';
import { ConfirmDialog, DialogButton } from './dialogs';
import cloneDeep from 'lodash/cloneDeep'
import ModelBinding from './model_binding';
import ColumnsSettingsModel from './columns_settings_model';
import { Visibility } from './columns';
import { MediaSize } from './settings_model';
class ColumnEditorDialog extends React.PureComponent
{
constructor(props)
{
super(props);
this.state = { };
bindHandlers(this);
}
update(patch)
{
this.props.onUpdate(patch);
}
handleTitleChange(e)
{
this.update({ title: e.target.value });
}
handleExpressionChange(e)
{
this.update({ expression: e.target.value });
}
handleSizeChange(e)
{
const value = Number(e.target.value);
if (!isNaN(value) && value >= 0)
this.update({ size: value });
}
handleOptionsMenuRequestOpen(value)
{
this.setState({ optionsMenuOpen: value });
}
setVisibility(e, size)
{
const { visibility } = this.props.column;
const newVisibility = Object.assign({}, visibility, { [size]: e.target.checked });
this.update({ visibility: newVisibility });
}
render()
{
const { isOpen, column, onOk, onCancel } = this.props;
const { visibility } = column;
const visibilityControls = [MediaSize.small, MediaSize.medium, MediaSize.large].map(size => (
<div key={size} className='dialog-row'>
<label className='dialog-label'>
<input
type='checkbox'
checked={visibility[size]}
onChange={e => this.setVisibility(e, size)} />
<span>Show in {size} layout</span>
</label>
</div>
));
return (
<ReactModal
isOpen={isOpen}
onRequestClose={onCancel}
className='dialog column-editor-dialog'
overlayClassName='dialog-overlay'
ariaHideApp={false}>
<form className='dialog-content'>
<div className='dialog-header'>Edit column</div>
<div className='dialog-body'>
<div className='dialog-row'>
<label className='dialog-label' htmlFor='title'>Title:</label>
<input
className='dialog-input'
type='text'
name='title'
value={column.title}
onChange={this.handleTitleChange} />
</div>
<div className='dialog-row'>
<label className='dialog-label' htmlFor='expr'>Expression:</label>
<input
className='dialog-input'
type='text'
name='expr'
value={column.expression}
onChange={this.handleExpressionChange} />
</div>
<div className='dialog-row'>
<label className='dialog-label' htmlFor='size'>Size:</label>
<input
className='dialog-input'
type='text'
name='size'
value={column.size}
onChange={this.handleSizeChange} />
</div>
{ visibilityControls }
</div>
<div className='dialog-footer'>
<DialogButton type='ok' onClick={onOk} />
<DialogButton type='cancel' onClick={onCancel} />
</div>
</form>
</ReactModal>
);
}
}
ColumnEditorDialog.propTypes = {
isOpen: PropTypes.bool.isRequired,
column: PropTypes.object.isRequired,
onOk: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
onUpdate: PropTypes.func.isRequired,
};
function ColumnEditorDragHandleInner()
{
return <Icon name='ellipses' className='column-editor-drag-handle' />;
}
const ColumnEditorDragHandle = SortableHandle(ColumnEditorDragHandleInner);
class ColumnEditorInner extends React.PureComponent
{
constructor(props)
{
super(props);
this.state = Object.assign(
{ deleteDialogOpen: false }, ColumnEditorInner.editDialogClosed());
bindHandlers(this);
}
static editDialogClosed()
{
return {
editDialogOpen: false,
editedColumn: {
title: '',
expression: '',
size: 1,
visibility: Visibility.never
}
};
}
handleEdit()
{
this.setState({
editDialogOpen: true,
editedColumn: cloneDeep(this.props.column),
});
}
handleEditOk(patch)
{
this.props.onUpdate(this.props.columnIndex, this.state.editedColumn);
this.setState(ColumnEditorInner.editDialogClosed);
}
handleEditCancel()
{
this.setState(ColumnEditorInner.editDialogClosed);
}
handleEditUpdate(patch)
{
this.setState(state => ({ editedColumn: Object.assign({}, state.editedColumn, patch) }));
}
handleDelete()
{
this.setState({ deleteDialogOpen: true });
}
handleDeleteOk()
{
this.props.onDelete(this.props.columnIndex);
this.setState({ deleteDialogOpen: false });
}
handleDeleteCancel()
{
this.setState({ deleteDialogOpen: false });
}
render()
{
const { column } = this.props;
const { deleteDialogOpen, editDialogOpen, editedColumn } = this.state;
return (
<div className='column-editor'>
<div className='column-editor-side'>
<ColumnEditorDragHandle />
</div>
<div className='column-editor-main'>
<span className='column-info-title'>{ column.title }</span>
<span className='column-info-expression'>{ column.expression }</span>
</div>
<div className='column-editor-side'>
<div className='button-bar'>
<Button name='cog' onClick={this.handleEdit} title='Edit' />
<Button name='minus' onClick={this.handleDelete} title='Delete' />
</div>
</div>
<ColumnEditorDialog
isOpen={editDialogOpen}
column={editedColumn}
onOk={this.handleEditOk}
onCancel={this.handleEditCancel}
onUpdate={this.handleEditUpdate} />
<ConfirmDialog
isOpen={deleteDialogOpen}
title='Delete column'
message={`Do you want to delete column ${column.title}?`}
onOk={this.handleDeleteOk}
onCancel={this.handleDeleteCancel} />
</div>
);
}
}
ColumnEditorInner.propTypes = {
columnIndex: PropTypes.number.isRequired,
column: PropTypes.object.isRequired,
onUpdate: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
};
const ColumnEditor = SortableElement(ColumnEditorInner);
class ColumnEditorListInner extends React.PureComponent
{
constructor(props)
{
super(props);
this.state = this.getStateFromModel();
bindHandlers(this);
}
getStateFromModel()
{
const { columns } = this.props.columnsSettingsModel;
return { columns };
}
handleUpdate(index, patch)
{
this.props.columnsSettingsModel.updateColumn(index, patch);
}
handleDelete(index)
{
this.props.columnsSettingsModel.removeColumn(index);
}
render()
{
const editors = this.state.columns.map((c, i) => (
<ColumnEditor
key={i}
index={i}
columnIndex={i}
column={c}
onUpdate={this.handleUpdate}
onDelete={this.handleDelete} />
));
return (
<div className='column-editor-list'>
{editors}
</div>
);
}
}
ColumnEditorListInner.propTypes = {
columnsSettingsModel: PropTypes.instanceOf(ColumnsSettingsModel).isRequired,
};
const ColumnEditorList = SortableContainer(ModelBinding(ColumnEditorListInner, { columnsSettingsModel: 'change' }));
export default class ColumnsSettings extends React.PureComponent
{
constructor(props)
{
super(props);
this.state = {};
bindHandlers(this);
}
handleSortEnd(e)
{
this.props.columnsSettingsModel.moveColumn(e.oldIndex, e.newIndex);
}
componentWillUnmount()
{
this.props.columnsSettingsModel.apply();
}
render()
{
return (
<ColumnEditorList
columnsSettingsModel={this.props.columnsSettingsModel}
axis='y'
lockAxis='y'
useDragHandle={true}
onSortEnd={this.handleSortEnd} />
);
}
}
ColumnsSettings.propTypes = {
columnsSettingsModel: PropTypes.instanceOf(ColumnsSettingsModel).isRequired,
};
|
app/containers/LanguageProvider/index.js | adityaanupindi/reactapp | /*
*
* LanguageProvider
*
* this component connects the redux state language locale to the
* IntlProvider component and i18n messages (loaded from `app/translations`)
*/
import React from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { IntlProvider } from 'react-intl';
import { makeSelectLocale } from './selectors';
export class LanguageProvider extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<IntlProvider locale={this.props.locale} key={this.props.locale} messages={this.props.messages[this.props.locale]}>
{React.Children.only(this.props.children)}
</IntlProvider>
);
}
}
LanguageProvider.propTypes = {
locale: React.PropTypes.string,
messages: React.PropTypes.object,
children: React.PropTypes.element.isRequired,
};
const mapStateToProps = createSelector(
makeSelectLocale(),
(locale) => ({ locale })
);
function mapDispatchToProps(dispatch) {
return {
dispatch,
};
}
export default connect(mapStateToProps, mapDispatchToProps)(LanguageProvider);
|
modules/frontend/src/js/components/widgets/Paginator.js | fleximaps/fleximaps | import styles from './Paginator.css';
import React from 'react';
import CSSModules from 'react-css-modules';
class Paginator extends React.Component {
render() {
return (
<div styleName='paginator'>
<ol styleName='paginatorList'>
{this._getNumbers()}
</ol>
</div>
);
}
_getNumbers(){
const elms = [];
const pagesNum = this._getPagesNum();
for(let i=1; i<=pagesNum; i++){
const elm = this.props.createNumberCb(i, this.props.page);
elms.push(<li key={i} styleName='paginatorListItem'>{elm}</li>);
}
return elms;
}
_getPagesNum(){
return Math.ceil(this.props.totalCount / this.props.pageSize);
}
}
Paginator.propTypes = {
pageSize: React.PropTypes.number.isRequired,
totalCount: React.PropTypes.number.isRequired,
page: React.PropTypes.number.isRequired,
createNumberCb: React.PropTypes.func.isRequired
};
export default CSSModules(Paginator, styles); |
server/src/main/components/shelves.react.js | madureira/hybrid-frontend | import React from 'react';
import Shelf from './shelf.react';
class Shelves extends React.Component {
constructor(props) {
super(props);
this.items = props.items;
this.addToOrder = props.addToOrder;
}
render() {
let shelves = this.items.map((shelf, index) => {
return (<Shelf key={index} product={shelf} addToOrder={this.addToOrder} />);
});
return (
<div className="shelves">
<div className="row">
{shelves}
</div>
</div>
);
}
}
export default Shelves;
|
front/js/containers/History/index.js | henrypoon/stockoverflow | import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import RecordTable from '../../components/RecordTable';
import { bounce } from 'react-animations';
import Radium, {StyleRoot} from 'radium';
import { Header, Icon } from 'semantic-ui-react';
import './History.css';
@connect((store) => {
return {
user: store.user,
};
})
export default class History extends React.Component {
constructor (props) {
super(props);
}
render () {
console.log(this.props);
return (
<div className='center'>
<StyleRoot>
<div style={styles.bounce}>
<Header as='h2' icon textAlign='center'>
<Icon name='tasks' circular />
<Header.Content>
History
</Header.Content>
</Header>
</div>
</StyleRoot>
<RecordTable records={this.props.user.record} />
</div>
);
}
}
History.propTypes = {
record: PropTypes.array,
user: PropTypes.object,
};
const styles = {
bounce: {
animation: 'x 1s',
animationName: Radium.keyframes(bounce, 'bounce')
}
};
|
src/views/HomeView/HomeView.js | Rkiouak/react-redux-python-stocks | /* @flow */
import React from 'react'
export class HomeView extends React.Component {
render () {
return (
<div>
<h1>Your New Project</h1>
</div>
)
}
}
export default HomeView
|
src/svg-icons/action/rowing.js | kasra-co/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionRowing = (props) => (
<SvgIcon {...props}>
<path d="M8.5 14.5L4 19l1.5 1.5L9 17h2l-2.5-2.5zM15 1c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 20.01L18 24l-2.99-3.01V19.5l-7.1-7.09c-.31.05-.61.07-.91.07v-2.16c1.66.03 3.61-.87 4.67-2.04l1.4-1.55c.19-.21.43-.38.69-.5.29-.14.62-.23.96-.23h.03C15.99 6.01 17 7.02 17 8.26v5.75c0 .84-.35 1.61-.92 2.16l-3.58-3.58v-2.27c-.63.52-1.43 1.02-2.29 1.39L16.5 18H18l3 3.01z"/>
</SvgIcon>
);
ActionRowing = pure(ActionRowing);
ActionRowing.displayName = 'ActionRowing';
ActionRowing.muiName = 'SvgIcon';
export default ActionRowing;
|
src/components/Home/banner.js | pritchardtw/ReactPersonalSite | import React, { Component } from 'react';
export default class Banner extends Component {
render() {
return(
<div className="Banner">
Thomas Pritchard
</div>
)
}
}
|
src/svg-icons/device/signal-cellular-connected-no-internet-2-bar.js | kittyjumbalaya/material-components-web | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceSignalCellularConnectedNoInternet2Bar = (props) => (
<SvgIcon {...props}>
<path fillOpacity=".3" d="M22 8V2L2 22h16V8z"/><path d="M14 22V10L2 22h12zm6-12v8h2v-8h-2zm0 12h2v-2h-2v2z"/>
</SvgIcon>
);
DeviceSignalCellularConnectedNoInternet2Bar = pure(DeviceSignalCellularConnectedNoInternet2Bar);
DeviceSignalCellularConnectedNoInternet2Bar.displayName = 'DeviceSignalCellularConnectedNoInternet2Bar';
DeviceSignalCellularConnectedNoInternet2Bar.muiName = 'SvgIcon';
export default DeviceSignalCellularConnectedNoInternet2Bar;
|
tasks/scaffolding/templates/app/frontend/page.js | latteware/marble-seed | import React from 'react'
import PageComponent from '~base/page-component'
class {{ reactClassName }} extends PageComponent {
constructor (props) {
super(props)
this.state = {
...this.baseState
}
}
render () {
const basicStates = super.getBasicStates()
if (basicStates) { return basicStates }
return (
<div className='{{ cssClassName }}'>
<h2>{{ name }}</h2>
</div>
)
}
}
{{ reactClassName }}.config({
path: '{{ path }}',
title: '{{ title }}',
exact: true
})
export default {{ reactClassName }}
|
utils/typography.js | conversataal/conversataal.github.io | // import ReactDOM from 'react-dom/server';
// import React from 'react';
// import Typography from 'typography';
// import { GoogleFont } from 'react-typography';
// import CodePlugin from 'typography-plugin-code';
//
// const options = {
// googleFonts: [
// {
// name: 'Roboto',
// styles: [
// '700',
// ],
// },
// ],
// headerFontFamily: ['Roboto', 'sans-serif'],
// bodyFontFamily: ['Roboto', 'sans-serif'],
// // headerFontFamily: ['Century Gothic', 'sans-serif'],
// // bodyFontFamily: ['Century Gothic', 'sans-serif'],
// baseFontSize: '18px',
// baseLineHeight: 1.65,
// scaleRatio: 2.25,
// plugins: [
// new CodePlugin(),
// ],
// };
//
// const typography = new Typography(options);
//
// // Hot reload typography in development.
// if (process.env.NODE_ENV !== 'production') {
// typography.injectStyles();
// if (typeof document !== 'undefined') {
// const googleFonts = ReactDOM.renderToStaticMarkup(
// React.createFactory(GoogleFont)({typography})
// );
// const head = document.getElementsByTagName('head')[0];
// head.insertAdjacentHTML('beforeend', googleFonts)
// }
// }
//
// export default typography;
|
src/assets/scripts/routes/About.js | SnowShock/Runew0lf | import React from 'react';
export default class About extends React.Component {
render () {
return(
<div className="about">
<section id="about" className='section'>
<div className="container">
<h3 className="section-heading">Who's This Handsome Fella?</h3>
<div className="row">
<div className="col-50">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit minus, sequi hic tempore corporis a quidem eveniet tenetur similique qui quos quaerat eius tempora provident consectetur vero dolorem rerum dignissimos consequatur dolor temporibus vel doloribus laudantium illum. Eveniet dolore laboriosam beatae adipisci, ex consequatur velit, quia temporibus pariatur, saepe officiis esse? Labore, natus, maxime. Dolores facilis ex fugit aliquid suscipit sapiente laborum possimus inventore quas iste, eius quaerat obcaecati et tempora molestiae ea soluta reprehenderit!</p>
</div>
<div className="col-50">
<div className="img"></div>
</div>
</div>
</div>
</section>
<section id="faq" className="section">
<div className="container">
<h3 className="section-heading">Frequently Asked Questions</h3>
<div className="row">
<div className="accordian-wrapper">
<ul className="accordian">
<li className="accordian-item">
<div className="accordian-header clearfix">
<h4>What does Runew0lf like to eat?</h4>
<i className="fa fa-plus"></i>
</div>
<div className="accordian-content">
<p className="accordian-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque saepe a, quod sit. Et at sed fuga quia accusantium molestias voluptatum odit eum error vel tempore molestiae cupiditate numquam libero quae quis, ab saepe iste veniam? Illum velit praesentium fugit at maiores dolores, officia sunt aut non. Quo, ipsum, animi.</p>
</div>
</li>
<li className="accordian-item">
<div className="accordian-header clearfix">
<h4>What does Runew0lf like to drink?</h4>
<i className="fa fa-plus"></i>
</div>
<div className="accordian-content">
<p className="accordian-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque saepe a, quod sit. Et at sed fuga quia accusantium molestias voluptatum odit eum error vel tempore molestiae cupiditate numquam libero quae quis, ab saepe iste veniam? Illum velit praesentium fugit at maiores dolores, officia sunt aut non. Quo, ipsum, animi.</p>
</div>
</li>
<li className="accordian-item">
<div className="accordian-header clearfix">
<h4>What is Runew0lf's favorite video game?</h4>
<i className="fa fa-plus"></i>
</div>
<div className="accordian-content">
<p className="accordian-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque saepe a, quod sit. Et at sed fuga quia accusantium molestias voluptatum odit eum error vel tempore molestiae cupiditate numquam libero quae quis, ab saepe iste veniam? Illum velit praesentium fugit at maiores dolores, officia sunt aut non. Quo, ipsum, animi.</p>
</div>
</li>
</ul>
</div>
</div>
</div>
</section>
</div>
)
}
}; |
src/tests.js | Sawtaytoes/Ghadyani-Framework-Webpack-React-Redux | import React from 'react'
import { AppContainer } from 'react-hot-loader'
import { render } from 'react-dom'
import getTestFiles, { isValidTestFile } from 'utils/getTestFiles'
import TestsRoot from 'components/root/TestsRoot'
const testFiles = getTestFiles()
const testName = window.__TESTNAME__
const isWildcard = testName.match(/\*$/)
const allTests = isValidTestFile
const specificTests = testName => fileName => (
isWildcard && isValidTestFile(fileName)
? (
fileName.match(
new RegExp(`${testName.replace('*', '')}.*\\.test\\.js`)
)
)
: fileName.includes(`/${testName}.test.js`)
)
const runTests = isTestFile => (
testFiles
.keys()
.filter(isTestFile)
.forEach(testFiles)
)
runTests(
testName !== 'undefined'
? specificTests(testName)
: allTests
)
const rootElement = document.getElementById('root')
render(
<AppContainer>
<TestsRoot />
</AppContainer>,
document.getElementById('root')
)
const onHotReload = () => {
const TestsRootHotReload = require('./components/root/TestsRoot').default
render(
(
<AppContainer>
<TestsRootHotReload />
</AppContainer>
),
rootElement
)
}
module.hot
&& module.hot.accept('./components/root/TestsRoot', onHotReload)
|
app/javascript/mastodon/components/loading_indicator.js | riku6460/chikuwagoddon | import React from 'react';
import { FormattedMessage } from 'react-intl';
const LoadingIndicator = () => (
<div className='loading-indicator'>
<div className='loading-indicator__figure' />
<FormattedMessage id='loading_indicator.label' defaultMessage='Loading...' />
</div>
);
export default LoadingIndicator;
|
client/app/Upgrade.js | li-cai/folio2 | import React, { Component } from 'react';
import classnames from 'classnames';
class Upgrade extends Component {
constructor() {
super();
this.state = {
accountType: 'Basic',
};
}
componentDidMount() {
sendAjax('GET', '/accountType', null, function(data) {
if (data.accountType) {
this.setState({ accountType: data.accountType });
}
}.bind(this));
}
handleSubmit(e) {
e.preventDefault();
return false;
}
render() {
return (
<div className="container">
<div className="header">
Upgrade Account
</div>
<div className="ui secondary segment">
<p>You are currently on the {this.state.accountType} plan.</p>
</div>
<h3 className="portalHeader">Please select a plan to upgrade to:</h3>
<div className="ui yellow segment upgradeSegment">
<div className="upgradeHeader">Basic</div>
<div className="upgradeFolios">2 Portals</div>
<div className="upgradePricing">Free</div>
</div>
<div className="ui teal segment upgradeSegment">
<div className="upgradeHeader">Business</div>
<div className="upgradeFolios">10 Portals</div>
<div className="upgradePricing">$49.99</div>
</div>
<div className="ui purple segment upgradeSegment">
<div className="upgradeHeader">Enterprise</div>
<div className="upgradeFolios">Unlimited Portals</div>
<div className="upgradePricing">$9.99 / month</div>
</div>
<button className="large ui blue button createButton" onClick={this.handleSubmit}>
Upgrade Account
</button>
</div>
);
}
}
export default Upgrade;
|
ui/js/components/ImageField.js | ericsoderberg/pbc-web | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import FormField from './FormField';
export default class ImageField extends Component {
render() {
const { formState, help, label, name, property } = this.props;
const image = formState.object[property];
let result;
if (image) {
const darkName = `${name}-dark`;
result = (
<FormField label={label} help={help}>
<div>
<img className="image-field__image" alt="" src={image.data} />
</div>
<div className="image-field__controls">
<span>
<input id={darkName}
name={darkName}
type="checkbox"
checked={image.dark}
onChange={() => formState.set(property,
{ ...image, dark: !image.dark })} />
<label htmlFor={darkName}>Dark</label>
</span>
<span>
<input id={name}
name={name}
type="checkbox"
checked={false}
onChange={() => formState.set(property, undefined)} />
<label htmlFor={name}>Clear</label>
</span>
</div>
</FormField>
);
} else {
const imageHelp = help || (
<span>
{"Don't forget to "}
<a href="https://tinyjpg.com" target="_blank" rel="noreferrer noopener">
optimize
</a>!
</span>
);
result = (
<FormField label={label}
help={imageHelp}
onDrop={formState.dropImageFile(property)}>
<input name={name}
type="file"
onChange={formState.changeImageFile(property)} />
</FormField>
);
}
return result;
}
}
ImageField.propTypes = {
formState: PropTypes.object.isRequired,
help: PropTypes.string,
label: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
property: PropTypes.string.isRequired,
};
ImageField.defaultProps = {
help: undefined,
};
|
actor-apps/app-web/src/app/components/modals/CreateGroup.react.js | liqk2014/actor-platform | import React from 'react';
import CreateGroupActionCreators from 'actions/CreateGroupActionCreators';
import CreateGroupStore from 'stores/CreateGroupStore';
import CreateGroupForm from './create-group/Form.react';
import Modal from 'react-modal';
import { KeyCodes } from 'constants/ActorAppConstants';
const appElement = document.getElementById('actor-web-app');
Modal.setAppElement(appElement);
const getStateFromStores = () => {
return {
isShown: CreateGroupStore.isModalOpen()
};
};
class CreateGroup extends React.Component {
constructor(props) {
super(props);
this.state = getStateFromStores();
CreateGroupStore.addChangeListener(this.onChange);
document.addEventListener('keydown', this.onKeyDown, false);
}
componentWillUnmount() {
CreateGroupStore.removeChangeListener(this.onChange);
document.removeEventListener('keydown', this.onKeyDown, false);
}
render() {
const isShown = this.state.isShown;
return (
<Modal className="modal-new modal-new--create-group" closeTimeoutMS={150} isOpen={isShown}>
<header className="modal-new__header">
<a className="modal-new__header__close modal-new__header__icon material-icons" onClick={this.onClose}>clear</a>
<h3 className="modal-new__header__title">Create group</h3>
</header>
<CreateGroupForm/>
</Modal>
);
}
onChange = () => {
this.setState(getStateFromStores());
}
onClose = () => {
CreateGroupActionCreators.closeModal();
}
onKeyDown = (event) => {
if (event.keyCode === KeyCodes.ESC) {
event.preventDefault();
this.onClose();
}
}
}
CreateGroup.displayName = 'CreateGroup';
export default CreateGroup;
|
src/main/resources/static/bower_components/jqwidgets/jqwidgets-react/react_jqxrating.js | dhawal9035/WebPLP | /*
jQWidgets v4.5.0 (2017-Jan)
Copyright (c) 2011-2017 jQWidgets.
License: http://jqwidgets.com/license/
*/
import React from 'react';
let jqxRating = React.createClass ({
getInitialState: function () {
return { value: '' };
},
componentDidMount: function () {
let options = this.manageAttributes();
this.createComponent(options);
},
manageAttributes: function () {
let properties = ['count','disabled','height','itemHeight','itemWidth','precision','singleVote','value','width'];
let options = {};
for(let item in this.props) {
if(item === 'settings') {
for(let itemTwo in this.props[item]) {
options[itemTwo] = this.props[item][itemTwo];
}
} else {
if(properties.indexOf(item) !== -1) {
options[item] = this.props[item];
}
}
}
return options;
},
createComponent : function (options) {
if(!this.style) {
for (let style in this.props.style) {
$('#' +this.componentSelector).css(style, this.props.style[style]);
}
}
if(this.props.className !== undefined) {
let classes = this.props.className.split(' ');
for (let i = 0; i < classes.length; i++ ) {
$('#' +this.componentSelector).addClass(classes[i]);
}
}
if(!this.template) {
$('#' +this.componentSelector).html(this.props.template);
}
$('#' +this.componentSelector).jqxRating(options);
},
generateID : function () {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
},
setOptions: function (options) {
$('#' +this.componentSelector).jqxRating('setOptions', options);
},
getOptions: function () {
if(arguments.length === 0) {
throw Error('At least one argument expected in getOptions()!');
}
let resultToReturn = {};
for(let i = 0; i < arguments.length; i++) {
resultToReturn[arguments[i]] = $('#' +this.componentSelector).jqxRating(arguments[i]);
}
return resultToReturn;
},
on: function (name,callbackFn) {
$('#' +this.componentSelector).on(name,callbackFn);
},
off: function (name) {
$('#' +this.componentSelector).off(name);
},
count: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("count", arg)
} else {
return $("#" +this.componentSelector).jqxRating("count");
}
},
disabled: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("disabled", arg)
} else {
return $("#" +this.componentSelector).jqxRating("disabled");
}
},
height: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("height", arg)
} else {
return $("#" +this.componentSelector).jqxRating("height");
}
},
itemHeight: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("itemHeight", arg)
} else {
return $("#" +this.componentSelector).jqxRating("itemHeight");
}
},
itemWidth: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("itemWidth", arg)
} else {
return $("#" +this.componentSelector).jqxRating("itemWidth");
}
},
precision: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("precision", arg)
} else {
return $("#" +this.componentSelector).jqxRating("precision");
}
},
singleVote: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("singleVote", arg)
} else {
return $("#" +this.componentSelector).jqxRating("singleVote");
}
},
value: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("value", arg)
} else {
return $("#" +this.componentSelector).jqxRating("value");
}
},
width: function (arg) {
if (arg !== undefined) {
$("#" +this.componentSelector).jqxRating("width", arg)
} else {
return $("#" +this.componentSelector).jqxRating("width");
}
},
disable: function () {
$("#" +this.componentSelector).jqxRating("disable");
},
enable: function () {
$("#" +this.componentSelector).jqxRating("enable");
},
getValue: function () {
return $("#" +this.componentSelector).jqxRating("getValue");
},
setValue: function (value) {
$("#" +this.componentSelector).jqxRating("setValue", value);
},
val: function (value) {
if (value !== undefined) {
$("#" +this.componentSelector).jqxRating("val", value)
} else {
return $("#" +this.componentSelector).jqxRating("val");
}
},
render: function () {
let id = 'jqxRating' + this.generateID() + this.generateID();
this.componentSelector = id; return (
<div id={id}>{this.value ? null : this.props.value}{this.props.children}</div>
)
}
});
module.exports = jqxRating;
|
actor-apps/app-web/src/app/components/modals/CreateGroup.react.js | JamesWatling/actor-platform | import React from 'react';
import CreateGroupActionCreators from '../../actions/CreateGroupActionCreators';
import CreateGroupStore from '../../stores/CreateGroupStore';
import CreateGroupForm from './create-group/Form.react';
import Modal from 'react-modal';
import { KeyCodes } from '../../constants/ActorAppConstants';
const appElement = document.getElementById('actor-web-app');
Modal.setAppElement(appElement);
const getStateFromStores = () => {
return {
isShown: CreateGroupStore.isModalOpen()
};
};
class CreateGroup extends React.Component {
constructor(props) {
super(props);
this.state = getStateFromStores();
CreateGroupStore.addChangeListener(this.onChange);
document.addEventListener('keydown', this.onKeyDown, false);
}
componentWillUnmount() {
CreateGroupStore.removeChangeListener(this.onChange);
document.removeEventListener('keydown', this.onKeyDown, false);
}
render() {
const isShown = this.state.isShown;
return (
<Modal className="modal-new modal-new--create-group" closeTimeoutMS={150} isOpen={isShown}>
<header className="modal-new__header">
<a className="modal-new__header__close material-icons" onClick={this.onClose}>clear</a>
<h3 className="modal-new__header__title">Create group</h3>
</header>
<CreateGroupForm/>
</Modal>
);
}
onChange = () => {
this.setState(getStateFromStores());
}
onClose = () => {
CreateGroupActionCreators.closeModal();
}
onKeyDown = (event) => {
if (event.keyCode === KeyCodes.ESC) {
event.preventDefault();
this.onClose();
}
}
}
CreateGroup.displayName = 'CreateGroup';
export default CreateGroup;
|
src/svg-icons/editor/insert-emoticon.js | mit-cml/iot-website-source | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorInsertEmoticon = (props) => (
<SvgIcon {...props}>
<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"/>
</SvgIcon>
);
EditorInsertEmoticon = pure(EditorInsertEmoticon);
EditorInsertEmoticon.displayName = 'EditorInsertEmoticon';
EditorInsertEmoticon.muiName = 'SvgIcon';
export default EditorInsertEmoticon;
|
src/client/components/smalllogo.react.js | sljuka/portfulio | import Component from '../components/component.react'
import React from 'react'
export default class SmallLogo extends Component {
render() {
return (
<div className='small-logo'>
<span className='light-text'>David Šljukić - </span>
<span className='mediterano'>portfolio</span>
</div>
);
}
}
|
app/components/views/room-list.js | erisalke/react-playground | import React from 'react';
import CreateRoomButton from './create-room-button'
import { Link } from 'react-router';
import { emitEvent } from '../../api/websockets';
export default function(props) {
return (
<div>
<h2>Available game rooms</h2>
<ul className="list-group">
{
props.rooms.map(room => {
return (
<li key={room.id} className="list-group-item">
<Link
to={ "/room/"+room.id }
className="details">
{ room.name || room.id }
</Link>
<br/>
<span> {room.id} </span>
</li>
);
})}
</ul>
</div>
);
}
|
client/modules/Kanban/Kanban.js | mraq1234/mod11 | import React from 'react';
import propTypes from 'prop-types';
import Lanes from '../Lane/Lanes';
import styles from '../Kanban/Kanban.css';
import DevTools from '../App/components/DevTools';
const Kanban = (props) =>
<div>
<DevTools />
<div>
<button
className={styles.AddLane}
onClick={
() => {
props.createLaneServ({
name: 'New lane',
}); }}
>
Add lane
</button>
<Lanes lanes={props.lanes} notes={props.notes} />
</div>
</div>;
Kanban.propTypes = {
createLaneServ: propTypes.func,
lanes: propTypes.array,
notes: propTypes.array,
};
export default Kanban;
|
app/src/components/Tag/RenameModal.js | GetStream/Winds | import React from 'react';
import PropTypes from 'prop-types';
import ReactModal from 'react-modal';
import { Img } from 'react-image';
import { renameTag } from '../../api/tagAPI';
import saveIcon from '../../images/icons/save.svg';
import exitIcon from '../../images/buttons/exit.svg';
class RenameModal extends React.Component {
constructor(props) {
super(props);
this.state = {
error: false,
submitting: false,
success: false,
};
}
closeModal = () => {
this.setState({ error: false, submitting: false, success: false });
this.props.toggleModal();
};
handleSubmit = (e) => {
e.preventDefault();
const name = new FormData(e.target).get('name');
this.setState({ submitting: true });
renameTag(
this.props.dispatch,
this.props.tagId,
name,
(res) => {
if (res.data) {
this.setState({ success: true, submitting: false });
setTimeout(() => this.closeModal(), 500);
}
},
() => this.setState({ error: true, submitting: false }),
);
};
render() {
let buttonText = 'SAVE';
if (this.state.submitting) buttonText = 'Submitting...';
else if (this.state.success) buttonText = 'Success!';
return (
<ReactModal
className="modal add-new-content-modal"
isOpen={this.props.isOpen}
onRequestClose={() => this.closeModal()}
overlayClassName="modal-overlay"
shouldCloseOnOverlayClick={true}
>
<header>
<h1>Rename Tag</h1>
<Img
className="exit"
onClick={() => this.closeModal()}
src={exitIcon}
/>
</header>
<form onSubmit={this.handleSubmit}>
<div className="input-box">
<input
autoComplete="false"
defaultValue={this.props.defVal}
name="name"
placeholder="Enter new name"
type="text"
/>
</div>
{this.state.error && (
<div className="error-message">
Oops, something went wrong. Please try again later.
</div>
)}
<div className="buttons">
<button
className="btn primary alt with-circular-icon"
disabled={this.state.submitting}
type="submit"
>
<Img src={saveIcon} />
{buttonText}
</button>
<button
className="btn link cancel"
onClick={(e) => {
e.preventDefault();
this.closeModal();
}}
type="cancel"
>
Cancel
</button>
</div>
</form>
</ReactModal>
);
}
}
RenameModal.defaultProps = {
isOpen: false,
};
RenameModal.propTypes = {
isOpen: PropTypes.bool,
toggleModal: PropTypes.func.isRequired,
defVal: PropTypes.string,
tagId: PropTypes.string,
dispatch: PropTypes.func.isRequired,
};
export default RenameModal;
|
app/containers/TodoInput/index.js | iPhaeton/todo-list | /*
*
* TodoInput
*
*/
import React from 'react';
import { connect } from 'react-redux';
import selectTodoInput from './selectors';
import { defaultAction } from './actions';
export class TodoInput extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<div>
<form onSubmit={this.props.onSubmitForm}>
<div className="input-group">
<input id="todoInput" type="text" className="form-control" placeholder="Enter a task"/>
<span className="input-group-btn">
<input type="submit" className="btn btn-default" value="Add task"/>
</span>
</div>
</form>
</div>
);
}
}
TodoInput.propTypes = {
onSubmitForm: React.PropTypes.func
};
const mapStateToProps = selectTodoInput();
function mapDispatchToProps(dispatch) {
return {
onSubmitForm: (event) => {
event.preventDefault();
var task = event.target.elements.todoInput.value;
if (task) {
dispatch(defaultAction(task));
};
}
};
}
export default connect(mapStateToProps, mapDispatchToProps)(TodoInput);
|
react/features/authentication/components/native/WaitForOwnerDialog.js | gpolitis/jitsi-meet | // @flow
import React, { Component } from 'react';
import type { Dispatch } from 'redux';
import { ConfirmDialog } from '../../../base/dialog';
import { translate } from '../../../base/i18n';
import { connect } from '../../../base/redux';
import { cancelWaitForOwner } from '../../actions.native';
import LoginDialog from './LoginDialog';
/**
* The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
*/
type Props = {
/**
* Redux store dispatch function.
*/
dispatch: Dispatch<any>,
/**
* Invoked to obtain translated strings.
*/
t: Function
};
/**
* The dialog is display in XMPP password + guest access configuration, after
* user connects from anonymous domain and the conference does not exist yet.
*
* See {@link LoginDialog} description for more details.
*/
class WaitForOwnerDialog extends Component<Props> {
/**
* Initializes a new WaitForWonderDialog instance.
*
* @param {Object} props - The read-only properties with which the new
* instance is to be initialized.
*/
constructor(props) {
super(props);
this.state = {
showLoginDialog: false
};
// Bind event handlers so they are only bound once per instance.
this._onCancel = this._onCancel.bind(this);
this._onLogin = this._onLogin.bind(this);
this._onLoginDialogCancel = this._onLoginDialogCancel.bind(this);
}
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
return (
<ConfirmDialog
cancelLabel = 'dialog.Cancel'
confirmLabel = 'dialog.IamHost'
descriptionKey = 'dialog.WaitForHostMsg'
onCancel = { this._onCancel }
onSubmit = { this._onLogin }>
<LoginDialog
// eslint-disable-next-line react/jsx-handler-names
_onCancel = { this._onLoginDialogCancel }
visible = { this.state.showLoginDialog } />
</ConfirmDialog>
);
}
_onCancel: () => void;
/**
* Called when the cancel button is clicked.
*
* @private
* @returns {void}
*/
_onCancel() {
this.props.dispatch(cancelWaitForOwner());
}
_onLogin: () => void;
/**
* Called when the OK button is clicked.
*
* @private
* @returns {void}
*/
_onLogin() {
this.setState({ showLoginDialog: true });
}
/**
* Called when the nested login dialog is cancelled.
*
* @private
* @returns {void}
*/
_onLoginDialogCancel() {
this.setState({ showLoginDialog: false });
}
}
export default translate(connect()(WaitForOwnerDialog));
|
docs/src/app/pages/components/ColorPicker/ExampleColorPickerSelected.js | GetAmbassador/react-ions | import React from 'react'
import ColorPicker from 'react-ions/lib/components/ColorPicker'
const ExampleColorPickerSelected = () => (
<div>
<ColorPicker value='#3c97d3'/>
</div>
)
export default ExampleColorPickerSelected
|
demo/components/textarea/TextAreaOptions.js | ctco/rosemary-ui | import React from 'react';
import {TextArea} from '../../../src';
import OptionsTable from '../../helper/OptionsTable';
export default () => {
let propDescription = {
};
return (
<OptionsTable component={TextArea} propDescription={propDescription} />
);
};
|
src/views/exams/edit.js | foysalit/react-mcq | import React, { Component } from 'react';
import AuthActions from '../../actions/auth';
import AppActions from '../../actions/app';
import QuestionStore from '../../stores/question';
import QuestionActions from '../../actions/question';
import ExamActions from '../../actions/exam';
import ExamStore from '../../stores/exam';
import AuthStore from '../../stores/auth';
import ChoiceForm from '../choices/form';
import ExamForm from './form';
import {
ClearFix, Styles, Paper,
List, ListItem,
IconMenu, MenuItem,
TextField,
IconButton, RaisedButton, FloatingActionButton, FontIcon
} from 'material-ui';
import { Link } from 'react-router';
const { Colors } = Styles;
function _getDataState(examId) {
return {
answers: [],
exam: ExamStore.getOne(examId),
editingQuestion: null
};
}
export default class ExamEdit extends Component {
constructor(props) {
super(props);
this.state = _getDataState();
this.loadState = this.loadState.bind(this);
}
addAnswer() {
const { title } = this.refs;
QuestionActions.create({title});
}
getStyles() {
return {
wrapper: {
margin: '20px auto',
width: '50%'
},
field: {
width: '100%'
},
fieldWrapper: {
marginBottom: '20px'
},
header: {
padding: '5% 1.5%',
backgroundColor: Colors.indigo500,
color: Colors.white,
position: 'relative'
}
};
}
loadState() {
this.setState(_getDataState(this.props.params.examId));
}
componentDidMount() {
QuestionStore.addChangeListener(this.loadState);
ExamStore.addChangeListener(this.loadState);
AppActions.changeTitle('Edit Exam');
ExamActions.loadOne(this.props.params.examId).then(() => {
ExamActions.loadQuestions(this.props.params.examId);
});
}
componentWillUnmount() {
QuestionStore.removeChangeListener(this.loadState);
ExamStore.removeChangeListener(this.loadState);
}
choiceUpdated(e, data) {
}
updateExamTitle(e) {
let {exam} = this.state;
if (!exam) return;
exam.title = e.target.value;
this.setState({exam: exam});
}
updateExam() {
ExamActions.save(this.state.exam);
}
render() {
let styles = this.getStyles();
let { exam, editingQuestion } = this.state;
return (
<div>
<ExamForm
exam={exam}
onTitleChange={this.updateExamTitle.bind(this)}
completeAction={this.updateExam.bind(this)}
type="edit"/>
{(editingQuestion) ?
<Paper style={styles.wrapper}>
<div style={ styles.header }>
<div style={ styles.fieldWrapper }>
<TextField
ref='title'
inputStyle={{ color: Colors.white }}
style={ styles.field }
type='text'
value={editingQuestion.title}
hintText="What is the question?" />
</div>
<div style={{float: 'right', marginTop: '25px'}}>
<FloatingActionButton
style={{marginRight: '10px'}}
secondary={true}
label="Add Question"
labelPosition="after"
onTouchTap={this.addQuestion}
mini={true}>
<FontIcon className="material-icons">add</FontIcon>
</FloatingActionButton>
<FloatingActionButton
style={{marginRight: '10px'}}
label="Save"
labelPosition="after"
onTouchTap={this.saveQuestion}
mini={true}>
<FontIcon className="material-icons">done</FontIcon>
</FloatingActionButton>
</div>
</div>
{ (editingQuestion.choices && editingQuestion.choices.length > 0) ?
<div style={{padding: '2% 3%'}}>
<h3>Choices</h3>
{ editingQuestion.choices.map((choice) => {
return <ChoiceForm
choice={choice}
updateChoice={this.choiceUpdated.bind(this)}
onChange={this.choiceUpdated.bind(this)}/>;
})}
</div>
: null }
</Paper>
: null }
</div>
);
}
}
|
src/Affix.js | xsistens/react-bootstrap | import React from 'react';
import classNames from 'classnames';
import AffixMixin from './AffixMixin';
const Affix = React.createClass({
mixins: [AffixMixin],
render() {
let holderStyle = {
top: this.state.affixPositionTop,
// we don't want to expose the `style` property
...this.props.style // eslint-disable-line react/prop-types
};
return (
<div {...this.props}
className={classNames(this.props.className, this.state.affixClass)}
style={holderStyle}>
{this.props.children}
</div>
);
}
});
export default Affix;
|
src/svg-icons/navigation/fullscreen-exit.js | kittyjumbalaya/material-components-web | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NavigationFullscreenExit = (props) => (
<SvgIcon {...props}>
<path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>
</SvgIcon>
);
NavigationFullscreenExit = pure(NavigationFullscreenExit);
NavigationFullscreenExit.displayName = 'NavigationFullscreenExit';
NavigationFullscreenExit.muiName = 'SvgIcon';
export default NavigationFullscreenExit;
|
webapp/imports/ui/components/AuthenticatedNavigation.js | clinical-meteor/meteor-on-fhir | import {ToolbarGroup, ToolbarTitle} from 'material-ui/Toolbar';
import ActionAccountCircle from 'material-ui/svg-icons/action/account-circle';
import ActionExitToApp from 'material-ui/svg-icons/action/exit-to-app';
import AvVideoCall from 'material-ui/svg-icons/av/video-call';
import { CardText } from 'material-ui/Card';
import { Glass } from 'meteor/clinical:glass-ui';
import IconButton from 'material-ui/IconButton';
import IconMenu from 'material-ui/IconMenu';
import MenuItem from 'material-ui/MenuItem';
import { Meteor } from 'meteor/meteor';
import React from 'react';
import { ReactMeteorData } from 'meteor/react-meteor-data';
import ReactMixin from 'react-mixin';
import { Session } from 'meteor/session';
import { browserHistory } from 'react-router';
import { get } from 'lodash';
import MenuButton from '/imports/ui/components/MenuButton';
import NorthEastMenu from '/imports/ui/components/NorthEastMenu';
Session.get('showNotificationMenu', true);
let style = {
username: {
userSelect: 'none',
WebkitUserSelect: 'none',
MozUserSelect: 'none',
msUserSelect: 'none',
top: '-5px',
cursor: 'pointer'
}
};
export class AuthenticatedNavigation extends React.Component {
getMeteorData() {
let data = {
style: {
position: 'fixed',
top: '0px',
width: '100%',
display: 'flex',
alignItems: 'center',
padding: '0 2.4rem',
opacity: Session.get('globalOpacity')
},
listItem: {
display: 'inline-block',
position: 'relative'
},
state: {
showNotificationMenu: Session.get('showNotificationMenu')
},
glassText : Glass.darkroom({
userSelect: 'none',
WebkitUserSelect: 'none',
MozUserSelect: 'none',
msUserSelect: 'none',
top: '-5px',
cursor: 'pointer'
}),
glassTextIcon : Glass.darkroom({
userSelect: 'none',
WebkitUserSelect: 'none',
MozUserSelect: 'none',
msUserSelect: 'none',
cursor: 'pointer'
}),
notifications: [],
notificationCount: 0,
notificationColor: 'green',
isIncomingCall: false
};
if (Meteor.user()) {
data.user = Meteor.user().fullName();
if(get(Meteor.user(), 'profile.notifications')){
data.notifications = get(Meteor.user(), 'profile.notifications', []);
data.notificationCount = data.notifications.length;
}
} else {
data.user = '';
}
// data.style.glassText = Glass.blur(data.style.glassText);
if (Session.get('glassBlurEnabled')) {
data.glassText.filter = 'blur(3px)';
data.glassText.WebkitFilter = 'blur(3px)';
}
if(data.notificationCount > 0){
data.notificationColor = 'orange';
if(data.notifications){
data.notifications.forEach(function(notification){
if(notification.type == 'videocall'){
data.isIncomingCall = true;
}
});
}
}
(process.env.NODE_ENV === 'test') && console.log("AuthenticatedNavigation[data]", data);
return data;
}
userName() {
return this.data.user;
}
openNotifications(){
// not every wants the notification menu, so we make sure it's configurable in the Meteor.settings file
if(get(Meteor, 'settings.public.defaults.notificationMenu')){
browserHistory.push('/notifications');
}
}
render () {
var currentIcon;
if(this.data.isIncomingCall){
currentIcon = <AvVideoCall onClick={this.openNotifications} style={{color: this.data.notificationColor}} />
} else {
currentIcon = <ActionAccountCircle onClick={this.openNotifications} style={{color: this.data.notificationColor}} />
}
return(
<div id='authenticatedUserMenuToggle' onClick={this.toggleNotificationMenu } style={this.data.glassText}>
<ToolbarGroup >
<IconMenu
id='authenticatedUserMenu'
anchorOrigin={{horizontal: 'right', vertical: 'bottom'}}
targetOrigin={{horizontal: 'right', vertical: 'top'}}
open={false}
iconButtonElement={
<NorthEastMenu>
<ToolbarTitle
id='notificationCount'
text={ this.data.notificationCount.toString() }
style={this.data.glassText}
/>
<IconButton touch={true} style={this.data.glassTextIcon} onClick={this.toggleSearch}>
{ currentIcon }
</IconButton>
<ToolbarTitle
id='authenticatedUsername'
text={ this.data.user }
style={this.data.glassText}
onClick={this.showProfile }
/>
</NorthEastMenu>
}
>
</IconMenu>
</ToolbarGroup>
</div>
);
}
handleLogout() {
Meteor.logout(function(){
browserHistory.push('/signin');
});
}
toggleSearch(){
console.log('toggleSearch')
}
showProfile() {
browserHistory.push('/myprofile');
}
toggleNotificationMenu(){
// console.log("showNotificationMenu", Session.get('showNotificationMenu'));
Session.toggle('showNotificationMenu');
}
}
ReactMixin(AuthenticatedNavigation.prototype, ReactMeteorData);
export default AuthenticatedNavigation; |
src/components/Main.js | wbhniwanl/generator-react-webpack | 'use strict';
require('normalize.css/normalize.css');
require('styles/App.scss');
import React from 'react';
import ReactDOM from 'react-dom';
//获取图片相关的数据
var imageDatas = require('../data/imageData.json');
//利用自执行函数,将图片信息转化为URl信息
imageDatas = ((imageDatasArr)=>{
for (var i = 0; i < imageDatasArr.length; i++) {
var singleImageData = imageDatasArr[i];
singleImageData.imageURL = require('../images/' + singleImageData.fileName);
imageDatasArr[i] = singleImageData;
}
return imageDatasArr;
})(imageDatas);
//ES6写法
var getRangeRandom=(low ,high)=>Math.ceil(Math.random() * (high - low) + low);
//获取0-30度之间的任意正负值
var get30DegRandom = () =>{
return ((Math.random() > 0.5 ? '': '-' ) + Math.ceil(Math.random() * 30))
};
class ImgFigur extends React.Component{
constructor(props){
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e){
if (this.props.arrange.isCenter){
this.props.inverse();
}else {
this.props.center();
}
e.stopPropagation();
e.preventDefault();
}
render(){
var styleObj = {};
//如果props属性中指定了这张图片的位置 则使用
if(this.props.arrange.pos){
styleObj = this.props.arrange.pos;
}
//如果图片的旋转角度有值并且不为0 则添加旋转角度
if(this.props.arrange.rotate){
//生产一个厂商前缀的数组 用于解决个个版本的兼容性问题
(['MozTransform', 'msTransform', 'WebTransform', 'transform']).forEach((value)=>{
styleObj[value] = 'rotate(' + this.props.arrange.rotate +
'deg)';
});
}
if(this.props.arrange.isCenter){
styleObj.zIndex = 11;
}
let imgFigureClassName = "ima-figure";
imgFigureClassName += this.props.arrange.isInverse ? ' is-inverse' : '';
return(
//规定自包含的单个单元内容 (单元内容:单独拿出来放到哪里都是有意义的,并且伴有figuretion标题说明)
//如果一个方法里面还有其他方法这直接调用它函数对于的名字就可以不用加()
<figure className={imgFigureClassName} style={styleObj} onClick={this.handleClick}>
<img src={this.props.data.imageURL} alt={this.props.data.title}/>
<figcaption>
<h2 className="ima-title">{this.props.data.title}</h2>
<div className='img-back' onClick={this.handleClick}>
<p>
{this.props.data.desc}
</p>
</div>
</figcaption>
</figure>
)
}
}
class ControllerUnit extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e){
if (this.props.arrange.isCenter){
this.props.inverse();
}else {
this.props.center();
}
e.stopPropagation();
e.preventDefault();
}
render() {
let controlelrUnitClassName = "controller-unit";
if (this.props.arrange.isCenter){
controlelrUnitClassName += ' is-center';
if (this.props.arrange.isInverse){
controlelrUnitClassName += ' is-inverse';
}
}
return (
<span className={controlelrUnitClassName} onClick={this.handleClick}></span>
);
}
}
class AppComponent extends React.Component {
constructor(props) {
super(props);
this.Constant = {
//中心方向
centerPos: {
left: 0,
right: 0
},
//水平方向的取值范围
hPosRange: {
leftSecX: [0, 0],
rightSecX: [0, 0],
y: [0, 0]
},
//垂直方向的取值范围
vPosRange: {
x: [0, 0],
topY: [0, 0]
}
};
this.state ={
imgsArragenArr:[
/*{
//pos == position
pos: {
left: '0',
top : '0'
}
rotate :0 ;//旋转角度
isInverse :false //表示图片正反面
isCenter ; false //表示开启居中的图片
}*/
]
};
}
/*
翻转图片
@param index 输入当前被执行inverse操作的图片对应的图片信息数组的index值
@return {function} 这是一个闭包函数 ,其内return一个真正待被执行的函数
在js中只要函数内部的子函数才可以读取局部变量:即函数内部的函数 就是函数内容和外部的链接起来的一个桥梁
*/
inverse(index){
return () =>{
//使用闭包函数是因为在imgfigures组件使用inserve函数时,[index]已经被定下来了所以直接调用时其实是在调用return的函数
var imgsArragenArr = this.state.imgsArragenArr;
imgsArragenArr[index].isInverse=!imgsArragenArr[index].isInverse;
this.setState({
imgsArragenArr : imgsArragenArr
});
}
}
/*
获取区间内的一个随机值
*/
/*
重新布局所以图片
指定centetIndex 指定居中布局的哪个图片
*/
rearragen(centerIndex){
var imgsArragenArr = this.state.imgsArragenArr,
Constant=this.Constant,
centerPos =Constant.centerPos,
hPosRange =Constant.hPosRange,
vPosRange = Constant.vPosRange,
hPosRangeleftSecX =hPosRange.leftSecX,
hPosRangerightSecX= hPosRange.rightSecX,
hPosRangeY = hPosRange.y,
vPosRangeX= vPosRange.x,
vPosRangeTopY = vPosRange.topY,
imgsArragenTopArr = [], //定义一个数组用来存放图片上侧区域的状态信息
topImgNum = Math.floor(Math.random() * 2),//取一个或不取
topImgSpliceIndex = 0, //用来标记我们存放在上侧的图片是从数组的哪个位置拿出来的
imgsArrangenCenterArr = imgsArragenArr.splice(centerIndex, 1);//获取中心图片的信息
//首先居中centerIndex的图片
imgsArrangenCenterArr[0]={
pos: centerPos,
rotate : 0,
isCenter: true
};
//居中的centerIndex的图片不需要旋转
//取出要布局上侧的状态信息
topImgSpliceIndex = Math.ceil(Math.random(imgsArragenArr.length - topImgNum)); //-topImgNum是因为我们是从索引位置往后取的
imgsArragenTopArr = imgsArragenArr.splice(topImgSpliceIndex,topImgNum);
//布局位于上侧的图片
imgsArragenTopArr.forEach(function (value,index) {
imgsArragenTopArr[index] = {
pos :{
top : getRangeRandom(vPosRangeTopY[0],vPosRangeTopY[1]),//使用一个范围所以要封装一个函数
left : getRangeRandom(vPosRangeX[0],vPosRangeX[1])
},
rotate : get30DegRandom(),
isCenter:false
}
});
//布局左侧的图片信息
for (var i = 0 , j = imgsArragenArr.length , k = j / 2;i<j; i++){
var hPosRangeLORX = null ; //临时变量获取左右区域的X值的变量
//前半部分布局左边 , 右半部分布局右边
if(i < k){
hPosRangeLORX = hPosRangeleftSecX;
}else {
hPosRangeLORX = hPosRangerightSecX;
}
imgsArragenArr[i] ={
pos :{
top: getRangeRandom(hPosRangeY[0],hPosRangeY[1]),
left:getRangeRandom(hPosRangeLORX[0],hPosRangeLORX[1])
},
rotate : get30DegRandom(),
isCenter:false
}
}
//如果有图像上侧信息给塞回补全
if (imgsArragenTopArr && imgsArragenTopArr[0]){
imgsArragenArr.splice(topImgSpliceIndex , 0 ,imgsArragenTopArr[0]);
}
//塞回中间部分的信息
imgsArragenArr.splice(centerIndex,0,imgsArrangenCenterArr[0]);
//重新渲染Conponent
this.setState({
imgsArragenArr:imgsArragenArr
});
}
/*
//利用rearrange函数,居中对应index的图片
@param index需要被居中的图片对应的图片信息数组的index值
return {function}
*/
center(index){
return()=>{
this.rearragen(index);
}
}
//组件加载以后对每张图片加载范围
componentDidMount(){
//拿到舞台大小
var stageDOM =ReactDOM.findDOMNode(this.refs.stage),
stageW = stageDOM.scrollWidth,
stageH = stageDOM.scrollHeight,
halfStageW = Math.ceil(stageW / 2),
halfStageH = Math.ceil(stageH / 2);
//拿到一个imgfigure的大小
var imgFigureDOM= ReactDOM.findDOMNode(this.refs.imgFigure0),
imgW = imgFigureDOM.scrollWidth,
imgH = imgFigureDOM.scrollHeight,
halfImgW = Math.ceil(imgW / 2),
halfImgH = Math.ceil(imgH / 2);
//计算中心图片的位置
this.Constant.centerPos={
left : halfStageW - halfImgW,
top :halfStageH - halfImgH
};
//计算左侧和右侧位置点取值范围
this.Constant.hPosRange.leftSecX[0] = -halfImgW;
this.Constant.hPosRange.leftSecX[1] = halfStageW - halfImgW * 3;
this.Constant.hPosRange.rightSecX[0] = halfStageW + halfImgW;
this.Constant.hPosRange.rightSecX[1] = stageW - halfImgW;
this.Constant.hPosRange.y[0] = -halfImgH;
this.Constant.hPosRange.y[1] = stageH - halfImgH;
//上侧区域的位置点取值范围
this.Constant.vPosRange.x[0] = halfStageW - imgW;
this.Constant.vPosRange.x[1] = halfStageW;
this.Constant.vPosRange.topY[0] = -halfImgH;
this.Constant.vPosRange.topY[1] = halfStageH - halfImgH * 3;
this.rearragen(0);
}
//定义产量
render() {
var conterllerUnits =[],
imgFigures =[];
imageDatas.forEach((value,index)=> {
//如果没有绑定imgsArragenArr对象则给其赋初始值
if (!this .state.imgsArragenArr[index]){
this.state.imgsArragenArr[index]={
pos:{
left:0 ,
top :0
},
rotate : 0, //填充旋转角度
isInverse : false,
isCenter : false
};
}
imgFigures.push(<ImgFigur data={value} key={index} ref={'imgFigure'+index} arrange ={this.state.imgsArragenArr[index]} inverse={this.inverse(index)}
center={this.center(index)}/>);
conterllerUnits.push(<ControllerUnit
key={index}
arrange ={this.state.imgsArragenArr[index]}
inverse ={this.inverse(index)}
center ={this.center(index)}
/>);
});
return (
//搭建舞台sesion(部件块的意思)
<section className="stage" ref="stage">
<section className="image-sec">
{imgFigures}
{}
</section>
<nav className="controller-nav">
{conterllerUnits}
</nav>
</section>
);
}
}
AppComponent.defaultProps = {
};
export default AppComponent;
|
src/routes/index.js | mauphes/own-git-project | import React from 'react';
import App from '../components/App';
// Child routes
import home from './home';
import learn from './learn';
import content from './content';
import error from './error';
export default {
path: '/',
// keep in mind, routes are evaluated in order
children: [
home,
learn,
// place new routes before...
content,
error,
],
async action({ next, render, context }) {
const component = await next();
if (component === undefined) return component;
return render(
<App context={context}>{component}</App>
);
},
};
|
o2web/source/x_component_appstore_application/src/App.js | o2oa/o2oa | import './App.css';
import React from 'react';
import AppBase from './components/AppBase.js';
import AppDescribe from './components/AppDescribe.js';
import AppInstallSteps from './components/AppInstallSteps.js';
import AppVideo from './components/AppVideo.js';
import {o2, component, lp} from '@o2oa/component';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
navi: 'describe',
isVip: false,
playVideo: false
};
}
componentDidMount() {
const action = o2.Actions.load('x_program_center').MarketAction;
action.get(component.options.appId).then((json)=>{
component.setTitle(lp.title+'-'+json.data.name);
this.setState({data:json.data});
});
action.cloudUnitIsVip().then((json)=>{
this.setState({isVip: json.data.value});
});
}
changeNavi(navi){
this.setState({navi});
}
getClassName(type){
return this.state.navi===type ? 'application-navi-item mainColor_color mainColor_border' : 'application-navi-item';
}
playVideo(){
this.setState({playVideo: true});
this.changeNavi('video');
}
getContent(){
const contents = {
describe: <AppDescribe data={this.state.data} setLinkTargetFun={this.setLinkTarget}/>,
installSteps: <AppInstallSteps data={this.state.data} setLinkTargetFun={this.setLinkTarget}/>,
video:(this.state.data && this.state.data.video) ? <AppVideo data={this.state.data} playVideo={this.state.playVideo}/> : ''
}
return contents[this.state.navi];
}
setLinkTarget(node){
if (node){
const nodes = node.querySelectorAll('a');
nodes.forEach((a)=>{
a.set('target', '_blank');
});
}
}
render() {
const appBase = (this.state.data) ? <AppBase data={this.state.data} isVip={this.state.isVip} parent={this} /> : '';
const videoNavi = (this.state.data && this.state.data.video) ? <div className={this.getClassName('video')} onClick={()=>{this.changeNavi('video')}}>{lp.video}</div> : '';
return (
<div className="application-content application-root">
{appBase}
<div className="application-navi">
<div className={this.getClassName('describe')} onClick={()=>{this.changeNavi('describe')}}>{lp.describe}</div>
<div className={this.getClassName('installSteps')} onClick={()=>{this.changeNavi('installSteps')}}>{lp.installSteps}</div>
{videoNavi}
</div>
{this.getContent()}
</div>
);
}
}
|
client/modules/questions/components/newSession.js | johngonzalez/abcdapp | import React from 'react';
import {Button} from 'react-bootstrap';
const NewSession = ({error, create, classId}) => (
<div>
{error ? <p style={{color: 'red'}}>{error}</p> : null}
<Button bsStyle="default" bsSize="large" block onClick={e => create(e, classId)}>
Inicia esta clase!
</Button>
</div>
);
NewSession.propTypes = {
error: React.PropTypes.string,
create: React.PropTypes.func.isRequired,
classId: React.PropTypes.string.isRequired
};
export default NewSession;
|
src/index.js | kristingreenslit/react-redux-weather-browser | import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import ReduxPromise from 'redux-promise';
import App from './components/app';
import reducers from './reducers';
const createStoreWithMiddleware = applyMiddleware(ReduxPromise)(createStore);
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<App />
</Provider>
, document.querySelector('.container'));
|
docs/src/app/components/pages/components/Stepper/VerticalNonLinearStepper.js | pradel/material-ui | import React from 'react';
import {
Step,
Stepper,
StepButton,
StepContent,
} from 'material-ui/Stepper';
import RaisedButton from 'material-ui/RaisedButton';
import FlatButton from 'material-ui/FlatButton';
/**
* A basic vertical non-linear implementation
*/
class VerticalNonLinear extends React.Component {
state = {
stepIndex: 0,
};
handleNext = () => {
const {stepIndex} = this.state;
if (stepIndex < 2) {
this.setState({stepIndex: stepIndex + 1});
}
};
handlePrev = () => {
const {stepIndex} = this.state;
if (stepIndex > 0) {
this.setState({stepIndex: stepIndex - 1});
}
};
renderStepActions(step) {
return (
<div style={{margin: '12px 0'}}>
<RaisedButton
label="Next"
disableTouchRipple={true}
disableFocusRipple={true}
primary={true}
onTouchTap={this.handleNext}
style={{marginRight: 12}}
/>
{step > 0 && (
<FlatButton
label="Back"
disableTouchRipple={true}
disableFocusRipple={true}
onTouchTap={this.handlePrev}
/>
)}
</div>
);
}
render() {
const {stepIndex} = this.state;
return (
<div style={{width: 380, height: 400, margin: 'auto'}}>
<Stepper
activeStep={stepIndex}
linear={false}
orientation="vertical"
>
<Step>
<StepButton onClick={() => this.setState({stepIndex: 0})}>
Select campaign settings
</StepButton>
<StepContent>
<p>
For each ad campaign that you create, you can control how much
you're willing to spend on clicks and conversions, which networks
and geographical locations you want your ads to show on, and more.
</p>
{this.renderStepActions(0)}
</StepContent>
</Step>
<Step>
<StepButton onClick={() => this.setState({stepIndex: 1})}>
Create an ad group
</StepButton>
<StepContent>
<p>An ad group contains one or more ads which target a shared set of keywords.</p>
{this.renderStepActions(1)}
</StepContent>
</Step>
<Step>
<StepButton onClick={() => this.setState({stepIndex: 2})}>
Create an ad
</StepButton>
<StepContent>
<p>
Try out different ad text to see what brings in the most customers,
and learn how to enhance your ads using features like ad extensions.
If you run into any problems with your ads, find out how to tell if
they're running and how to resolve approval issues.
</p>
{this.renderStepActions(2)}
</StepContent>
</Step>
</Stepper>
</div>
);
}
}
export default VerticalNonLinear;
|
src/utils/children.js | subjectix/material-ui | import React from 'react';
import createFragment from 'react-addons-create-fragment';
export default {
create(fragments) {
let newFragments = {};
let validChildrenCount = 0;
let firstKey;
//Only create non-empty key fragments
for (let key in fragments) {
const currentChild = fragments[key];
if (currentChild) {
if (validChildrenCount === 0) firstKey = key;
newFragments[key] = currentChild;
validChildrenCount++;
}
}
if (validChildrenCount === 0) return undefined;
if (validChildrenCount === 1) return newFragments[firstKey];
return createFragment(newFragments);
},
extend(children, extendedProps, extendedChildren) {
return React.isValidElement(children) ?
React.Children.map(children, (child) => {
const newProps = typeof (extendedProps) === 'function' ?
extendedProps(child) : extendedProps;
const newChildren = typeof (extendedChildren) === 'function' ?
extendedChildren(child) : extendedChildren ?
extendedChildren : child.props.children;
return React.cloneElement(child, newProps, newChildren);
}) : children;
},
};
|
fixtures/packaging/systemjs-builder/dev/input.js | cpojer/react | import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
React.createElement('h1', null, 'Hello World!'),
document.getElementById('container')
);
|
src/svg-icons/device/airplanemode-active.js | nathanmarks/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceAirplanemodeActive = (props) => (
<SvgIcon {...props}>
<path d="M10.18 9"/><path d="M21 16v-2l-8-5V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5l8 2.5z"/>
</SvgIcon>
);
DeviceAirplanemodeActive = pure(DeviceAirplanemodeActive);
DeviceAirplanemodeActive.displayName = 'DeviceAirplanemodeActive';
DeviceAirplanemodeActive.muiName = 'SvgIcon';
export default DeviceAirplanemodeActive;
|
client/components/WebRating.js | Jakeyrob/chill | import React from 'react';
import ReactDOM from 'react-dom';
const WebRating = ({rating}) => {
let stars = "";
if (rating > 0) {
for (var i = 0; i < rating; i++) {
stars += "*";
}
}
return <div classname='stars'>{stars}</div>;
};
module.exports = WebRating; |
src/components/MultiTrack.js | bostonjukebox/boston-jukebox-reactjs | import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import Track from './Track'
import vocals from '../img/icon-vocals.svg'
import guitar from '../img/icon-guitar.svg'
import drums from '../img/icon-drums.svg'
const Container = styled.section`
margin-top: 1em;
display: flex;
flex-direction: column;
justify-content: center;
`
const MultiTrack = ({ playing }) =>
<Container>
<Track name="vocal" icon={vocals} playing={playing} />
<Track name="guitar" icon={guitar} playing={playing} />
<Track name="drums" icon={drums} playing={playing} />
</Container>
MultiTrack.propTypes = {
playing: PropTypes.bool,
}
export default MultiTrack
|
src/svg-icons/device/location-disabled.js | pancho111203/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceLocationDisabled = (props) => (
<SvgIcon {...props}>
<path d="M20.94 11c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06c-1.13.12-2.19.46-3.16.97l1.5 1.5C10.16 5.19 11.06 5 12 5c3.87 0 7 3.13 7 7 0 .94-.19 1.84-.52 2.65l1.5 1.5c.5-.96.84-2.02.97-3.15H23v-2h-2.06zM3 4.27l2.04 2.04C3.97 7.62 3.25 9.23 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c1.77-.2 3.38-.91 4.69-1.98L19.73 21 21 19.73 4.27 3 3 4.27zm13.27 13.27C15.09 18.45 13.61 19 12 19c-3.87 0-7-3.13-7-7 0-1.61.55-3.09 1.46-4.27l9.81 9.81z"/>
</SvgIcon>
);
DeviceLocationDisabled = pure(DeviceLocationDisabled);
DeviceLocationDisabled.displayName = 'DeviceLocationDisabled';
DeviceLocationDisabled.muiName = 'SvgIcon';
export default DeviceLocationDisabled;
|
src/components/App.js | Daweo93/weather-forecast-app | import React, { Component } from 'react';
import SearchBar from '../containers/searchBar';
import WeatherList from '../containers/weatherList';
class App extends Component {
render() {
return (
<div>
<SearchBar />
<WeatherList />
</div>
);
}
}
export default App;
|
app/javascript/mastodon/features/ui/components/media_modal.js | summoners-riftodon/mastodon | import React from 'react';
import ReactSwipeableViews from 'react-swipeable-views';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import Video from '../../video';
import ExtendedVideoPlayer from '../../../components/extended_video_player';
import classNames from 'classnames';
import { defineMessages, injectIntl } from 'react-intl';
import IconButton from '../../../components/icon_button';
import ImmutablePureComponent from 'react-immutable-pure-component';
import ImageLoader from './image_loader';
const messages = defineMessages({
close: { id: 'lightbox.close', defaultMessage: 'Close' },
previous: { id: 'lightbox.previous', defaultMessage: 'Previous' },
next: { id: 'lightbox.next', defaultMessage: 'Next' },
});
export const previewState = 'previewMediaModal';
@injectIntl
export default class MediaModal extends ImmutablePureComponent {
static propTypes = {
media: ImmutablePropTypes.list.isRequired,
index: PropTypes.number.isRequired,
onClose: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
static contextTypes = {
router: PropTypes.object,
};
state = {
index: null,
navigationHidden: false,
};
handleSwipe = (index) => {
this.setState({ index: index % this.props.media.size });
}
handleNextClick = () => {
this.setState({ index: (this.getIndex() + 1) % this.props.media.size });
}
handlePrevClick = () => {
this.setState({ index: (this.props.media.size + this.getIndex() - 1) % this.props.media.size });
}
handleChangeIndex = (e) => {
const index = Number(e.currentTarget.getAttribute('data-index'));
this.setState({ index: index % this.props.media.size });
}
handleKeyDown = (e) => {
switch(e.key) {
case 'ArrowLeft':
this.handlePrevClick();
e.preventDefault();
e.stopPropagation();
break;
case 'ArrowRight':
this.handleNextClick();
e.preventDefault();
e.stopPropagation();
break;
}
}
componentDidMount () {
window.addEventListener('keydown', this.handleKeyDown, false);
if (this.context.router) {
const history = this.context.router.history;
history.push(history.location.pathname, previewState);
this.unlistenHistory = history.listen(() => {
this.props.onClose();
});
}
}
componentWillUnmount () {
window.removeEventListener('keydown', this.handleKeyDown);
if (this.context.router) {
this.unlistenHistory();
if (this.context.router.history.location.state === previewState) {
this.context.router.history.goBack();
}
}
}
getIndex () {
return this.state.index !== null ? this.state.index : this.props.index;
}
toggleNavigation = () => {
this.setState(prevState => ({
navigationHidden: !prevState.navigationHidden,
}));
};
render () {
const { media, intl, onClose } = this.props;
const { navigationHidden } = this.state;
const index = this.getIndex();
let pagination = [];
const leftNav = media.size > 1 && <button tabIndex='0' className='media-modal__nav media-modal__nav--left' onClick={this.handlePrevClick} aria-label={intl.formatMessage(messages.previous)}><i className='fa fa-fw fa-chevron-left' /></button>;
const rightNav = media.size > 1 && <button tabIndex='0' className='media-modal__nav media-modal__nav--right' onClick={this.handleNextClick} aria-label={intl.formatMessage(messages.next)}><i className='fa fa-fw fa-chevron-right' /></button>;
if (media.size > 1) {
pagination = media.map((item, i) => {
const classes = ['media-modal__button'];
if (i === index) {
classes.push('media-modal__button--active');
}
return (<li className='media-modal__page-dot' key={i}><button tabIndex='0' className={classes.join(' ')} onClick={this.handleChangeIndex} data-index={i}>{i + 1}</button></li>);
});
}
const content = media.map((image) => {
const width = image.getIn(['meta', 'original', 'width']) || null;
const height = image.getIn(['meta', 'original', 'height']) || null;
if (image.get('type') === 'image') {
return (
<ImageLoader
previewSrc={image.get('preview_url')}
src={image.get('url')}
width={width}
height={height}
alt={image.get('description')}
key={image.get('url')}
onClick={this.toggleNavigation}
/>
);
} else if (image.get('type') === 'video') {
const { time } = this.props;
return (
<Video
preview={image.get('preview_url')}
src={image.get('url')}
width={image.get('width')}
height={image.get('height')}
startTime={time || 0}
onCloseVideo={onClose}
detailed
description={image.get('description')}
key={image.get('url')}
/>
);
} else if (image.get('type') === 'gifv') {
return (
<ExtendedVideoPlayer
src={image.get('url')}
muted
controls={false}
width={width}
height={height}
key={image.get('preview_url')}
alt={image.get('description')}
onClick={this.toggleNavigation}
/>
);
}
return null;
}).toArray();
// you can't use 100vh, because the viewport height is taller
// than the visible part of the document in some mobile
// browsers when it's address bar is visible.
// https://developers.google.com/web/updates/2016/12/url-bar-resizing
const swipeableViewsStyle = {
width: '100%',
height: '100%',
};
const containerStyle = {
alignItems: 'center', // center vertically
};
const navigationClassName = classNames('media-modal__navigation', {
'media-modal__navigation--hidden': navigationHidden,
});
return (
<div className='modal-root__modal media-modal'>
<div
className='media-modal__closer'
role='presentation'
onClick={onClose}
>
<ReactSwipeableViews
style={swipeableViewsStyle}
containerStyle={containerStyle}
onChangeIndex={this.handleSwipe}
onSwitching={this.handleSwitching}
index={index}
>
{content}
</ReactSwipeableViews>
</div>
<div className={navigationClassName}>
<IconButton className='media-modal__close' title={intl.formatMessage(messages.close)} icon='times' onClick={onClose} size={40} />
{leftNav}
{rightNav}
<ul className='media-modal__pagination'>
{pagination}
</ul>
</div>
</div>
);
}
}
|
components/forms/LoginForm.js | jebeck/nefelion | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { Field, propTypes as reduxFormPropTypes, reduxForm } from 'redux-form';
import { Form, Message, Segment } from 'semantic-ui-react';
import styled from 'styled-components';
import { clearLoginFailure, makeLoginRequester } from 'atomic/login';
import Input from 'components/forms/Input';
import Link from 'components/utils/Link';
function validate(values) {
const errors = {};
if (values.email) {
if (values.email.search('@') === -1) {
errors.email = 'an e-mail needs an @ somewhere...';
}
} else {
errors._error = 'A required field is missing';
}
if (!values.password) {
errors._error = 'A required field is missing';
}
return errors;
}
const PaddedGroup = styled(Form.Group)`
padding-top: 0.5rem;
`;
class LoginForm extends Component {
static propTypes = {
firebase: PropTypes.shape({
auth: PropTypes.func.isRequired,
}).isRequired,
handleSubmit: PropTypes.func.isRequired,
loginError: PropTypes.object,
onNavigate: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
...reduxFormPropTypes,
};
handleReset = () => {
const { clearLoginFailure, reset } = this.props;
reset();
clearLoginFailure();
};
render() {
const {
handleSubmit,
invalid,
onNavigate,
onSubmit,
pristine,
loginError,
submitting,
submitSucceeded,
} = this.props;
return (
<Form
as={Segment}
attached
error={submitSucceeded && Boolean(loginError)}
size="large"
success={submitSucceeded && !loginError}
warning={!submitSucceeded}
>
<Form.Group>
<Field component={Input} label="e-mail" name="email" type="email" />
<Field
component={Input}
label="password"
name="password"
type="password"
/>
</Form.Group>
<PaddedGroup>
<Form.Button
color="teal"
content="submit"
disabled={invalid || pristine || submitting}
onClick={handleSubmit(onSubmit)}
/>
<Form.Button
content="reset"
disabled={pristine || submitting}
onClick={this.handleReset}
/>
</PaddedGroup>
{submitSucceeded ? (
loginError ? (
<Message content={loginError.message} size="tiny" error />
) : (
<Message content="Submitted!" size="tiny" success />
)
) : (
<Message size="tiny" warning>
<Message.Content>
don't have an account?{' '}
<Link
context="form"
onClick={onNavigate}
text="sign up"
to="/signup"
/>{' '}
instead
</Message.Content>
</Message>
)}
</Form>
);
}
}
function mapStateToProps(state) {
return {
loginError: state.app.loginError,
};
}
function mapDispatchToProps(dispatch, ownProps) {
const { firebase } = ownProps;
const signupRequest = makeLoginRequester(firebase);
return bindActionCreators(
{ clearLoginFailure, onSubmit: signupRequest },
dispatch
);
}
export default reduxForm({
form: 'signup',
validate,
})(connect(mapStateToProps, mapDispatchToProps)(LoginForm));
|
src/components/app.js | SRosenshein/react-auth-client | import React, { Component } from 'react';
import Header from './header';
export default class App extends Component {
render() {
return (
<div>
<Header />
{this.props.children}
</div>
);
}
}
|
docs/src/app/components/pages/components/Card/ExampleExpandable.js | hwo411/material-ui | import React from 'react';
import {Card, CardActions, CardHeader, CardText} from 'material-ui/Card';
import FlatButton from 'material-ui/FlatButton';
const CardExampleExpandable = () => (
<Card>
<CardHeader
title="Without Avatar"
subtitle="Subtitle"
actAsExpander={true}
showExpandableButton={true}
/>
<CardActions>
<FlatButton label="Action1" />
<FlatButton label="Action2" />
</CardActions>
<CardText expandable={true}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi.
Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque.
Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio.
</CardText>
</Card>
);
export default CardExampleExpandable;
|
src/svg-icons/maps/directions-bus.js | rscnt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsDirectionsBus = (props) => (
<SvgIcon {...props}>
<path d="M4 16c0 .88.39 1.67 1 2.22V20c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-1h8v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-1.78c.61-.55 1-1.34 1-2.22V6c0-3.5-3.58-4-8-4s-8 .5-8 4v10zm3.5 1c-.83 0-1.5-.67-1.5-1.5S6.67 14 7.5 14s1.5.67 1.5 1.5S8.33 17 7.5 17zm9 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm1.5-6H6V6h12v5z"/>
</SvgIcon>
);
MapsDirectionsBus = pure(MapsDirectionsBus);
MapsDirectionsBus.displayName = 'MapsDirectionsBus';
export default MapsDirectionsBus;
|
app/src/components/Intro/Intro.js | RyanCCollins/ryancollins.io | import React from 'react';
import './Intro.scss';
import DownChevron from '../DownChevron/DownChevron';
import IntroImage from './IntroImage';
import * as Constants from '../../constants';
const Intro = () => (
<section className="intro">
<div className="intro-header">
<div className="intro-header__content">
<IntroImage />
<h1 className="intro-header__headline">{Constants.IntroHeadline}</h1>
<h4 className="intro-header__subheadline">{Constants.IntroSubHeadline}</h4>
<DownChevron scrollToSection="aboutSection" />
</div>
</div>
</section>
);
export default Intro;
|
lib/login-fb/index.js | andyfen/react-native-UIKit | import React from 'react';
import {
StyleSheet,
TouchableOpacity,
Image,
} from 'react-native';
import { gutter } from '../variables';
const LoginFb = ({ onPress, style }) => (
<TouchableOpacity onPress={onPress} style={[ styles.outer, style ]}>
<Image source={require('./assets/fb-login-button.png')}/>
</TouchableOpacity>
);
const styles = StyleSheet.create({
outer: {
alignItems: 'center',
marginBottom: gutter,
},
});
LoginFb.defaultProps = {
style: {},
};
LoginFb.propTypes = {
onPress: React.PropTypes.func,
};
export default LoginFb;
|
src/components/Login/Login.js | Angular-Toast/habitat | import React, { Component } from 'react';
import{ StyleSheet, View, Image, Text, TouchableOpacity, Button, AsyncStorage } from 'react-native';
import axios from 'axios';
import LoginForm from './LoginForm';
import { onSignIn } from '../auth.js'
export default class Login extends Component {
constructor(props) {
super(props);
this.state = {
username: "",
password: ""
}
this.handleUserInput = this.handleUserInput.bind(this);
this.handlePasswordInput = this.handlePasswordInput.bind(this);
}
handleUserInput(event) {
this.setState({ username: event })
}
handlePasswordInput(event) {
this.setState({ password: event})
}
handleRegularLogin() {
axios.get(`http://10.16.1.152:3000/login`, {
params: {
username: this.state.username,
password: this.state.password
}
})
.then(userData => {
this.props.screenProps.handleLogIn(userData.data.user);
AsyncStorage.setItem(`user_token`, userData.data.token);
})
}
login = async () => {
const APP_ID = "1729141044061993"
const options = {
permissions: ['public_profile', 'email', 'user_friends', 'user_photos', 'user_location'],
}
const {type, token} = await Expo.Facebook.logInWithReadPermissionsAsync(APP_ID, options)
if (type === 'success') {
const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`)
const user = await response.json();
// let user_fb_pic = null;
// this.getFBPic().then(pic => user_fb_pic = pic)
const response2 = await fetch(`https://graph.facebook.com/${user.id}/friends?access_token=${token}`)
const friends= await response2.json();
axios.post(`http://10.16.1.152:3000/token`, {
name: user.name,
username: user.id,
token: token
})
.then(res => {
this.getFBPic(user.id).then(pic => {
this.props.screenProps.handleLogIn(res.data.user, pic);
})
AsyncStorage.setItem(`user_token`, token);
friends.data.forEach(friend => {
this.getFBPic(friend.id).then(pic => {
axios.post('http://10.16.1.152:3000/friends', {
user: res.data.user,
username: user.name,
userfbID: user.id,
friend: friend,
pic: pic
})
.then(res => console.log('success'))
.catch(err => console.error(err))
})
})
})
}
}
getFBPic = async (id) => {
const response3 = await fetch(`https://graph.facebook.com/${id}/picture?type=normal`)
let pic = await response3.url;
return pic
}
checkAsyncStorage = async () => {
const tokenInPhone = await AsyncStorage.getItem(`user_token`)
return tokenInPhone;
}
render() {
return (
<View style={styles.container}>
<View style={styles.logoContainer}>
<Image
style={styles.logo}
source={require("../assets/toastlogo.png")}
/>
<Text>Build Habitats by keeping Good Habits</Text>
</View>
<View style={styles.formContainer}>
<LoginForm
handleUserInput={this.handleUserInput}
handlePasswordInput={this.handlePasswordInput}
/>
</View>
<TouchableOpacity
onPress={() => {
username = this.state.username
password = this.state.password
this.handleRegularLogin()
}}
style={styles.buttonContainer}
>
<Text style={styles.buttonText}>LOGIN</Text>
</TouchableOpacity>
<Button
onPress={this.login}
title='Login with facebook' />
<TouchableOpacity
onPress={() => this.props.navigation.navigate("SignUp")}
style={styles.buttonContainer}
>
<Text style={styles.buttonText}>SIGNUP</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center'
},
logoContainer: {
alignItems: 'center',
justifyContent: 'center'
},
logo: {
width: 100,
height: 100,
},
formContainer: {
},
buttonContainer: {
alignItems: 'center',
justifyContent: 'center',
height: 40,
borderWidth: 1,
borderColor: 'black',
paddingVertical: 10
},
buttonText: {
textAlign: 'center',
fontWeight: '700',
paddingHorizontal: 10
}
});
|
src/components/spaces/cards/index.js | getguesstimate/guesstimate-app | import React from 'react'
import Icon from'react-fa'
import * as navigationActions from 'gModules/navigation/actions'
import * as Space from 'gEngine/space'
import * as User from 'gEngine/user'
import * as Organization from 'gEngine/organization'
import {formatDescription, formatDate} from 'gComponents/spaces/shared'
import arrowsVisibleImage from '../../../assets/metric-icons/blue/arrows-visible.png'
import './style.css'
const BlankScreenshot = () => (
<div className='snapshot blank'>
<img src={arrowsVisibleImage}/>
</div>
)
const SingleButton = ({isPrivate}) => (
<div className='tag'>
<Icon name={isPrivate ? 'lock' : 'globe'}/>
</div>
)
const ButtonArea = ({owner, ownerUrl, isPrivate, showPrivacy}) => (
<div className='hover-row'>
{owner &&
<a href={ownerUrl} className='owner-tag'>
{!!owner.picture &&
<img
className='avatar'
src={owner.picture}
/>
}
<div className='name'>
{owner.name}
</div>
</a>
}
{showPrivacy && <SingleButton isPrivate={isPrivate}/>}
</div>
)
export const NewSpaceCard = ({onClick}) => (
<div className='col-xs-12 col-md-4 SpaceCard new' onClick={onClick}>
<div className='SpaceCard--inner'>
<div className='section-middle'>
<Icon name='plus'/>
<h3>New Model</h3>
</div>
</div>
</div>
)
export const SpaceCard = ({space, showPrivacy, size, urlParams = {}}) => {
const hasName = !_.isEmpty(space.name)
const hasOrg = _.has(space, 'organization.name')
const owner = hasOrg ? space.organization : space.user
const ownerUrl = hasOrg ? Organization.url(space.organization) : User.url(space.user)
const spaceUrl = Space.spaceUrlById(space.id, urlParams)
const navigateToSpace = navigationActions.navigateFn(spaceUrl)
return (
<div className={`SpaceCard ${size === 'SMALL' ? 'SMALL' : 'col-xs-12 col-md-4'}`}>
<div className='SpaceCard--inner' onClick={navigateToSpace}>
<div className={`header ${hasName ? '' : 'default-name'}`}>
<a href={spaceUrl}><h3>{hasName ? space.name : 'Untitled Model'}</h3></a>
{size !== 'SMALL' &&
<div className='changed-at'>Updated {formatDate(space.updated_at)}</div>
}
</div>
<div className='image'>
<BlankScreenshot/>
<a href={spaceUrl}><img src={space.big_screenshot}/></a>
<ButtonArea
owner={owner}
ownerUrl={ownerUrl}
isPrivate={space.is_private}
showPrivacy={showPrivacy}
/>
</div>
{size !== 'SMALL' &&
<div className='body'>
<p> {formatDescription(space.description)} </p>
</div>
}
</div>
</div>
)
}
const SpaceCards = ({spaces, showPrivacy}) => (
<div className='row'>
{_.map(spaces, (s) =>
<SpaceCard
key={s.id}
space={s}
showPrivacy={showPrivacy}
/>
)}
</div>
)
export default SpaceCards
|
web/src/components/home/Navbar.js | fmiglianico/HaveYouMet | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { withRouter, Redirect, Link } from 'react-router-dom';
import FacebookLogin from '../FacebookLogin';
import FacebookPicture from '../FacebookPicture';
import FacebookLogout from "../FacebookLogout";
import ProfileActionCreator from '../../actions/ProfileActionCreator';
import store from '../../stores/Store';
class Navbar extends Component {
constructor(props) {
super(props);
this.state = {
facebookAuth: props.facebookAuth,
facebookPicture: props.facebookPicture,
profile: props.profile
}
}
componentWillReceiveProps(nextProps) {
if (!nextProps.profile.fetched && !nextProps.profile.fetching && !nextProps.profile.error
&& nextProps.facebookAuth.fetched) {
store.dispatch(ProfileActionCreator.getMyProfile(nextProps.facebookAuth.data.userID));
}
}
render() {
return (
<nav className="navbar nav-down" data-fullwidth="true" data-menu-style={this.props.location.pathname === "/" ? "transparent-to-dark" : "dark"} data-animation="shrink">
<div className="container">
<div className="navbar-header">
<div className="container">
<Link className="navbar-brand to-top" to="/">
<img src="/wunderkind/img/assets/logo-light.png" className="logo-light" alt="#"/>
<img src="/wunderkind/img/assets/logo-dark.png" className="logo-dark" alt="#"/>
</Link>
</div>
</div>
<div id="navbar" className="navbar-collapse collapse">
<div className="container">
<ul className="nav navbar-nav menu-right">
<li><Link to={{
pathname: '/',
hash: '#root'
}}>Home</Link></li>
{
this.props.profile.fetched ?
<li><Link to={{
pathname: '/dashboard',
hash: '#root'
}}>Dashboard</Link></li> :
null
}
<li className="nav-separator"/>
<li className="dropdown myprofilemenu">
<a className="dropdown-toggle">
<div className="fb-login">
{!this.props.facebookAuth.fetched || this.props.profile.fetching ?
<FacebookLogin /> :
(this.props.profile.error ?
<Redirect to="/register"/> :
<FacebookPicture facebookPictureUrl={this.props.facebookPicture.data} />
)
}
</div>
</a>
{this.props.profile.fetched ? (
<ul className="dropdown-menu fullwidth">
<li className="myprofilemenu-content withdesc">
<div className="col-md-3 mg-col">
<ul>
<li><a href="#">My Profile</a></li>
<li>
<FacebookLogout/>
</li>
</ul>
</div>
</li>
</ul>) : null}
</li>
</ul>
</div>
</div>
</div>
</nav>
);
}
};
const mapStateToProps = (state) => {
return {
facebookAuth: state.facebook.facebookAuth,
facebookPicture: state.facebook.facebookPicture,
profile: state.profile.profile
};
};
export default withRouter(connect(mapStateToProps)(Navbar));
|
src/work/components/ProjectCardLinks.js | elailai94/elailai94.github.io | import React, { Component } from 'react';
import { Button } from 'semantic-ui-react';
import PropTypes from 'prop-types';
import ProjectCardLinkItem from './ProjectCardLinkItem';
class ProjectCardLinks extends Component {
render() {
const { links } = this.props;
return (
<Button.Group fluid>
{links.map(link => {
const { name } = link;
return (
<ProjectCardLinkItem key={name} link={link} />
);
})}
</Button.Group>
);
}
}
ProjectCardLinks.propTypes = {
links: PropTypes.array.isRequired,
};
export default ProjectCardLinks;
|
src/client/components/footer.js | fk1blow/repeak | import React from 'react';
export default class Footer extends React.Component {
render() {
return (
<footer id="footer" className="w-100 center phl dn-xs pvm-ns bt b--light-gray gray bg-white">
<div className="f5 db tc lh-copy">
footer contents here
</div>
</footer>
);
}
}
|
app/containers/DevTools.js | q191201771/chef_blog | import React from 'react'
import { createDevTools } from 'redux-devtools'
import LogMonitor from 'redux-devtools-log-monitor'
import DockMonitor from 'redux-devtools-dock-monitor'
export default createDevTools(
<DockMonitor
toggleVisibilityKey="H"
changePositionKey="W"
>
<LogMonitor />
</DockMonitor>
)
|
app/shared/availability-view/timeline-groups/timeline-group/availability-timeline/ReservationSlot.js | fastmonkeys/respa-ui | import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import moment from 'moment';
import injectT from '../../../../../i18n/injectT';
import ReservationPopover from '../../../../reservation-popover/ReservationPopover';
import utils from '../utils';
export class UninjectedReservationSlot extends React.Component {
static propTypes = {
begin: PropTypes.string.isRequired,
end: PropTypes.string.isRequired,
isSelectable: PropTypes.bool.isRequired,
itemIndex: PropTypes.number,
onClick: PropTypes.func,
onMouseEnter: PropTypes.func,
onMouseLeave: PropTypes.func,
onSelectionCancel: PropTypes.func,
resourceId: PropTypes.string.isRequired,
selection: PropTypes.shape({
begin: PropTypes.string.isRequired,
end: PropTypes.string.isRequired,
hover: PropTypes.bool,
resourceId: PropTypes.string.isRequired,
}),
slotSize: PropTypes.string,
};
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
this.handleMouseEnter = this.handleMouseEnter.bind(this);
this.handleMouseLeave = this.handleMouseLeave.bind(this);
}
shouldComponentUpdate(nextProps) {
const isSelected = this.getIsSelected(nextProps.selection);
const wasSelected = this.getIsSelected(this.props.selection);
const isSelectableChanged = this.props.isSelectable !== nextProps.isSelectable;
return (
isSelectableChanged
|| isSelected !== wasSelected
|| this.shouldShowPopover(wasSelected, nextProps)
);
}
getIsSelected(selection = this.props.selection) {
return (
selection
&& ((!selection.resourceId || selection.resourceId === this.props.resourceId)
&& this.props.begin >= selection.begin
&& this.props.end <= selection.end)
);
}
getSlotInfo() {
const { end, slotSize } = this.props;
const slotDuration = moment.duration(slotSize).hours();
const slotDivider = moment.duration(slotSize).hours() * 2 - 1;
const slotEnd = slotDuration < 1 ? end : moment(end).add(30 * slotDivider, 'minutes').format('YYYY-MM-DDTHH:mm:ss');
return {
begin: this.props.begin,
end: slotEnd,
resourceId: this.props.resourceId,
};
}
shouldShowPopover(isSelected, props = this.props) {
return isSelected && !props.selection.hover && props.selection.begin === props.begin;
}
handleClick(event) {
if (this.props.onClick && this.props.isSelectable) {
event.preventDefault();
this.props.onClick(this.getSlotInfo());
} else if (this.props.onSelectionCancel && !this.props.isSelectable) {
event.preventDefault();
this.props.onSelectionCancel();
}
}
handleMouseEnter() {
if (this.props.onMouseEnter && this.props.isSelectable) {
this.props.onMouseEnter(this.getSlotInfo());
}
}
handleMouseLeave() {
if (this.props.onMouseLeave && this.props.isSelectable) {
this.props.onMouseLeave(this.getSlotInfo());
}
}
render() {
const { itemIndex, slotSize } = this.props;
const slotDuration = moment.duration(slotSize).hours();
const divideIndex = slotDuration * 2;
const isSelected = this.getIsSelected();
const slot = (
<button
className={classNames('reservation-slot', {
'reservation-slot-selected': isSelected,
'reservation-slot-selectable': this.props.isSelectable,
})}
onClick={this.handleClick}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
style={{ width: slotDuration < 1 ? utils.getTimeSlotWidth() : utils.getTimeSlotWidth() * divideIndex }}
type="button"
>
<span className="a11y-text" />
</button>
);
if (this.shouldShowPopover(isSelected)) {
return (
<ReservationPopover
begin={this.props.selection.begin}
end={this.props.selection.end}
onCancel={this.props.onSelectionCancel}
>
{slot}
</ReservationPopover>
);
}
return (
<React.Fragment>
{slotDuration > 0 && itemIndex % divideIndex === 0 && slot}
{slotDuration > 0 && itemIndex % divideIndex > 0 && <span />}
{slotDuration < 1 && slot}
</React.Fragment>
);
}
}
export default injectT(UninjectedReservationSlot);
|
app/plugins/core/settings/index.js | KELiON/cerebro | import React from 'react'
import { search } from 'cerebro-tools'
import Settings from './Settings'
import icon from '../icon.png'
// Settings plugin name
const NAME = 'Cerebro Settings'
// Settings plugins in the end of list
const order = 9
// Phrases that used to find settings plugins
const KEYWORDS = [
NAME,
'Cerebro Preferences',
'cfg',
'config',
'params'
]
/**
* Plugin to show app settings in results list
*
* @param {String} options.term
* @param {Function} options.display
*/
const settingsPlugin = ({ term, display, config, actions }) => {
const found = search(KEYWORDS, term).length > 0
if (found) {
const results = [{
order,
icon,
title: NAME,
term: NAME,
getPreview: () => (
<Settings
set={(key, value) => config.set(key, value)}
get={(key) => config.get(key)}
/>
),
onSelect: (event) => {
event.preventDefault()
actions.replaceTerm(NAME)
}
}]
display(results)
}
}
export default {
name: NAME,
fn: settingsPlugin
}
|
packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js | sigmacomputing/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
function load(users) {
return [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
...users,
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = { users: [] };
}
async componentDidMount() {
const users = load([{ id: 42, name: '42' }]);
this.setState({ users });
}
componentDidUpdate() {
this.props.onReady();
}
render() {
return (
<div id="feature-array-spread">
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}
}
|
src/components/ArticleActions.js | feedreaderco/web | import React from 'react';
import LabelButton from './LabelButton';
import style from '../styles/articleActions';
function isLabelled(labels, hash, label) {
return labels[label] && labels[label].indexOf(hash) > -1;
}
export default ({ labels, hash }) => <div style={style}>
<LabelButton
hash={hash}
label={'favorites'}
isSelectedInitially={isLabelled(labels, hash, 'favorites')}
/>
<LabelButton
hash={hash}
label={'reading-list'}
isSelectedInitially={isLabelled(labels, hash, 'reading-list')}
/>
</div>;
|
blueocean-material-icons/src/js/components/svg-icons/notification/confirmation-number.js | kzantow/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const NotificationConfirmationNumber = (props) => (
<SvgIcon {...props}>
<path d="M22 10V6c0-1.11-.9-2-2-2H4c-1.1 0-1.99.89-1.99 2v4c1.1 0 1.99.9 1.99 2s-.89 2-2 2v4c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-4c-1.1 0-2-.9-2-2s.9-2 2-2zm-9 7.5h-2v-2h2v2zm0-4.5h-2v-2h2v2zm0-4.5h-2v-2h2v2z"/>
</SvgIcon>
);
NotificationConfirmationNumber.displayName = 'NotificationConfirmationNumber';
NotificationConfirmationNumber.muiName = 'SvgIcon';
export default NotificationConfirmationNumber;
|
src/components/CircleWidget/CircleWidget.js | marinbgd/coolbeer | import React from 'react';
import PropTypes from 'prop-types';
import Paper from 'material-ui/Paper';
import './CircleWidget.scss';
import ReactTooltip from 'react-tooltip';
const style = {
display: 'inline-block',
position: 'relative',
height: 150,
width: 150,
margin: 20,
};
const CircleWidget = (props) => (
<Paper style={{...style, backgroundColor: props.color}} zDepth={3} circle={true}>
<div className="circle-widget" data-tip={props.tooltip}>
<span className="circle-widget__title">{props.title}</span>
<span className="circle-widget__text">{props.text}</span>
</div>
<ReactTooltip />
</Paper>
);
CircleWidget.propTypes = {
text: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
title: PropTypes.string,
tooltip: PropTypes.string,
color: PropTypes.string,
};
export default CircleWidget;
|
src/components/ChatApp/Settings/Settings.react.js | madhavrathi/chat.susi.ai | import React, { Component } from 'react';
import Paper from 'material-ui/Paper';
import FlatButton from 'material-ui/FlatButton';
import RaisedButton from 'material-ui/RaisedButton';
import DropDownMenu from 'material-ui/DropDownMenu';
import MenuItem from 'material-ui/MenuItem';
import PropTypes from 'prop-types';
import UserPreferencesStore from '../../../stores/UserPreferencesStore';
import MessageStore from '../../../stores/MessageStore';
import Cookies from 'universal-cookie';
import Toggle from 'material-ui/Toggle';
import Dialog from 'material-ui/Dialog';
import TextToSpeechSettings from './TextToSpeechSettings.react';
import Close from 'material-ui/svg-icons/navigation/close';
import * as Actions from '../../../actions/';
import HardwareComponent from '../HardwareComponent';
import CustomServer from '../CustomServer.react';
import ChangePassword from '../../Auth/ChangePassword/ChangePassword.react';
import AppBar from 'material-ui/AppBar';
import IconButton from 'material-ui/IconButton';
import IconMenu from 'material-ui/IconMenu';
import MoreVertIcon from 'material-ui/svg-icons/navigation/more-vert';
import Popover from 'material-ui/Popover';
import { Link } from 'react-router-dom';
import Exit from 'material-ui/svg-icons/action/exit-to-app';
import SignUpIcon from 'material-ui/svg-icons/action/account-circle';
import SignUp from '../../Auth/SignUp/SignUp.react';
import Login from '../../Auth/Login/Login.react';
import ForgotPassword from '../../Auth/ForgotPassword/ForgotPassword.react';
import susiWhite from '../../../images/susi-logo-white.png';
import Info from 'material-ui/svg-icons/action/info';
import Dashboard from 'material-ui/svg-icons/action/dashboard';
import Chat from 'material-ui/svg-icons/communication/chat';
import SettingsIcon from 'material-ui/svg-icons/action/settings';
import './Settings.css';
const cookies = new Cookies();
let Logged = (props) => (
<div>
<MenuItem primaryText="About"
containerElement={<Link to="/overview" />}
rightIcon={<Info/>}
/>
<MenuItem primaryText="Chat"
containerElement={<Link to="/" />}
rightIcon={<Chat/>}
/>
<MenuItem
rightIcon={<Dashboard/>}
><a
style={{
color: 'rgba(0, 0, 0, 0.87)',
width: '140px',
display:'block'
}}
href="http://skills.susi.ai">Skills</a>
</MenuItem>
<MenuItem primaryText="Settings"
containerElement={<Link to="/settings" />}
rightIcon={<SettingsIcon/>} />
<MenuItem
primaryText="Login"
onTouchTap={this.handleLogin}
rightIcon={<SignUpIcon/>} />
</div>
)
class Settings extends Component {
constructor(props) {
super(props);
let defaults = UserPreferencesStore.getPreferences();
let defaultServer = defaults.Server;
let defaultTheme = defaults.Theme;
let defaultEnterAsSend = defaults.EnterAsSend;
let defaultMicInput = defaults.MicInput;
let defaultSpeechOutput = defaults.SpeechOutput;
let defaultSpeechOutputAlways = defaults.SpeechOutputAlways;
let defaultSpeechRate = defaults.SpeechRate;
let defaultSpeechPitch = defaults.SpeechPitch;
let defaultTTSLanguage = defaults.TTSLanguage;
let defaultPrefLanguage = defaults.PrefLanguage;
let TTSBrowserSupport;
if ('speechSynthesis' in window) {
TTSBrowserSupport = true;
} else {
TTSBrowserSupport = false;
console.warn('The current browser does not support the SpeechSynthesis API.')
}
let STTBrowserSupport;
const SpeechRecognition = window.SpeechRecognition
|| window.webkitSpeechRecognition
|| window.mozSpeechRecognition
|| window.msSpeechRecognition
|| window.oSpeechRecognition
if (SpeechRecognition != null) {
STTBrowserSupport = true;
} else {
STTBrowserSupport = false;
console.warn('The current browser does not support the SpeechRecognition API.');
}
console.log(STTBrowserSupport);
this.state = {
theme: defaultTheme,
enterAsSend: defaultEnterAsSend,
micInput: defaultMicInput,
speechOutput: defaultSpeechOutput,
speechOutputAlways: defaultSpeechOutputAlways,
server: defaultServer,
serverUrl: '',
serverFieldError: false,
checked: false,
validForm: true,
showLanguageSettings: false,
speechRate: defaultSpeechRate,
speechPitch: defaultSpeechPitch,
ttsLanguage: defaultTTSLanguage,
PrefLanguage: defaultPrefLanguage,
showServerChangeDialog: false,
showHardwareChangeDialog: false,
showChangePasswordDialog: false,
showLogin: false,
showSignUp: false,
showForgotPassword: false,
showOptions: false,
anchorEl: null,
voiceList: MessageStore.getTTSVoiceList()
};
this.customServerMessage = '';
this.TTSBrowserSupport = TTSBrowserSupport;
this.STTBrowserSupport = STTBrowserSupport;
}
handleServer = () => {
this.setState({
showServerChangeDialog: true
});
}
handleChangePassword = () => {
this.setState({
showChangePasswordDialog: true,
});
}
handleHardware = () => {
this.setState({
showHardwareChangeDialog: true
});
}
handleClose = () => {
this.setState({
showLanguageSettings: false,
showServerChangeDialog: false,
showHardwareChangeDialog: false,
showChangePasswordDialog: false,
showOptions: false,
showLogin: false,
showSignUp: false,
showForgotPassword: false,
})
}
handleSubmit = () => {
let newTheme = this.state.theme;
let newDefaultServer = this.state.server;
let newEnterAsSend = this.state.enterAsSend;
let newMicInput = this.state.micInput;
let newSpeechOutput = this.state.speechOutput;
let newSpeechOutputAlways = this.state.speechOutputAlways;
let newSpeechRate = this.state.speechRate;
let newSpeechPitch = this.state.speechPitch;
let newTTSLanguage = this.state.ttsLanguage;
let newPrefLanguage = this.state.PrefLanguage;
if(newDefaultServer.slice(-1)==='/'){
newDefaultServer = newDefaultServer.slice(0,-1);
}
let vals = {
theme: newTheme,
server: newDefaultServer,
enterAsSend: newEnterAsSend,
micInput: newMicInput,
speechOutput: newSpeechOutput,
speechOutputAlways: newSpeechOutputAlways,
rate: newSpeechRate,
pitch: newSpeechPitch,
lang: newTTSLanguage,
PrefLanguage: newPrefLanguage
}
console.log(newPrefLanguage);
let settings = Object.assign({}, vals);
settings.LocalStorage = true;
// Store in cookies for anonymous user
cookies.set('settings',settings);
console.log(settings);
// Trigger Actions to save the settings in stores and server
this.implementSettings(vals);
}
implementSettings = (values) => {
console.log(values);
let currSettings = UserPreferencesStore.getPreferences();
let settingsChanged = {};
let resetVoice = false;
if(currSettings.Theme !== values.theme){
settingsChanged.Theme = values.theme;
}
if(currSettings.EnterAsSend !== values.enterAsSend){
settingsChanged.EnterAsSend = values.enterAsSend;
}
if(currSettings.MicInput !== values.micInput){
settingsChanged.MicInput = values.micInput;
}
if(currSettings.SpeechOutput !== values.speechOutput){
settingsChanged.SpeechOutput = values.speechOutput;
resetVoice = true;
}
if(currSettings.SpeechOutputAlways !== values.speechOutputAlways){
settingsChanged.SpeechOutputAlways = values.speechOutputAlways;
resetVoice = true;
}
if(currSettings.SpeechRate !== values.rate){
settingsChanged.SpeechRate = values.rate;
}
if(currSettings.SpeechPitch !== values.pitch){
settingsChanged.SpeechPitch = values.pitch;
}
if(currSettings.TTSLanguage !== values.lang){
settingsChanged.TTSLanguage = values.lang;
}
if(currSettings.PrefLanguage !== values.PrefLanguage){
settingsChanged.PrefLanguage = values.PrefLanguage;
}
Actions.settingsChanged(settingsChanged);
if(resetVoice){
Actions.resetVoice();
}
this.props.history.push('/');
window.location.reload();
}
handleSelectChange= (event, index, value) => {
this.setState({theme:value});
}
handleEnterAsSend = (event, isInputChecked) => {
this.setState({
enterAsSend: isInputChecked,
});
}
handleMicInput = (event, isInputChecked) => {
this.setState({
micInput: isInputChecked,
});
}
handleSpeechOutput = (event, isInputChecked) => {
this.setState({
speechOutput: isInputChecked,
});
}
handleSpeechOutputAlways = (event, isInputChecked) => {
this.setState({
speechOutputAlways: isInputChecked,
});
}
handleLanguage = (toShow) => {
this.setState({
showLanguageSettings: toShow,
});
}
handleTextToSpeech = (settings) => {
this.setState({
speechRate: settings.rate,
speechPitch: settings.pitch,
ttsLanguage: settings.lang,
showLanguageSettings: false,
});
}
handleServeChange=(event)=>{
let state = this.state;
let serverUrl
if (event.target.value === 'customServer') {
state.checked = !state.checked;
let defaults = UserPreferencesStore.getPreferences();
state.serverUrl = defaults.StandardServer;
state.serverFieldError = false;
}
else if (event.target.name === 'serverUrl'){
serverUrl = event.target.value;
let validServerUrl =
/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:~+#-]*[\w@?^=%&~+#-])?/i
.test(serverUrl);
state.serverUrl = serverUrl;
state.serverFieldError = !(serverUrl && validServerUrl);
}
this.setState(state);
if (this.state.serverFieldError) {
this.customServerMessage = 'Enter a valid URL';
}
else{
this.customServerMessage = '';
}
if(this.state.serverFieldError && this.state.checked){
this.setState({validForm: false});
}
else{
this.setState({validForm: true});
}
}
handleServerToggle = (changeServer) => {
if(changeServer){
// Logout the user and show the login screen again
this.props.history.push('/logout');
this.setState({
showLogin:true
});
}
else{
// Go back to settings dialog
this.setState({
showServerChangeDialog: false,
showHardwareChangeDialog: false
});
}
}
onRequestClose = () => {
this.props.history.push('/');
window.location.reload();
}
handleLogin = () => {
this.setState({
showLogin: true,
showSignUp: false,
showForgotPassword: false,
showOptions: false,
});
}
handleSignUp = () => {
this.setState({
showSignUp: true,
showLogin: false,
showForgotPassword: false,
showOptions: false,
});
}
handleForgotPassword = () => {
this.setState({
showForgotPassword: true,
showLogin: false,
showOptions: false,
});
}
showOptions = (event) => {
this.setState({
showOptions: true,
anchorEl: event.currentTarget,
});
}
handlePrefLang = (event, index, value) => {
this.setState({
PrefLanguage: value,
});
}
closeOptions = () => {
this.setState({
showOptions: false,
});
}
componentWillMount() {
document.body.className = 'white-body';
}
componentWillUnmount() {
MessageStore.removeChangeListener(this._onChange.bind(this));
}
_onChange() {
this.setState({
voiceList: MessageStore.getTTSVoiceList()
});
}
componentDidMount() {
MessageStore.addChangeListener(this._onChange.bind(this));
this.setState({
search: false,
});
// Check Logged in
if (cookies.get('loggedIn')) {
Logged = (props) => (
<div>
<MenuItem primaryText="About"
containerElement={<Link to="/overview" />}
rightIcon={<Info/>}
/>
<MenuItem primaryText="Chat"
containerElement={<Link to="/" />}
rightIcon={<Chat/>}
/>
<MenuItem
rightIcon={<Dashboard/>}
href="http://skills.susi.ai"
>Skills
</MenuItem>
<MenuItem primaryText="Settings"
containerElement={<Link to="/settings" />}
rightIcon={<SettingsIcon/>}/>
<MenuItem primaryText="Logout"
containerElement={<Link to="/logout" />}
rightIcon={<Exit />}/>
</div>
)
return <Logged />
}
Logged = (props) => (
<div>
<MenuItem primaryText="About"
containerElement={<Link to="/overview" />}
rightIcon={<Info/>}
/>
<MenuItem primaryText="Chat"
containerElement={<Link to="/" />}
rightIcon={<Chat/>}
/>
<MenuItem
rightIcon={<Dashboard/>}
href="http://skills.susi.ai"
>Skills
</MenuItem>
<MenuItem primaryText="Settings"
containerElement={<Link to="/settings" />}
rightIcon={<SettingsIcon/>} />
<MenuItem
primaryText="Login"
onTouchTap={this.handleLogin}
rightIcon={<SignUpIcon/>} />
</div>
)
return <Logged />
}
populateVoiceList = () => {
let voices = this.state.voiceList;
let langCodes = [];
let voiceMenu = voices.map((voice,index) => {
langCodes.push(voice.lang);
return(
<MenuItem value={voice.lang} key={index}
primaryText={voice.name+' ('+voice.lang+')'} />
);
});
let currLang = this.state.PrefLanguage;
let voiceOutput = {
voiceMenu: voiceMenu,
voiceLang: currLang
}
// `-` and `_` replacement check of lang codes
if(langCodes.indexOf(currLang) === -1){
if(currLang.indexOf('-') > -1 && langCodes.indexOf(currLang.replace('-','_')) > -1){
voiceOutput.voiceLang = currLang.replace('-','_');
}
else if(currLang.indexOf('_') > -1 && langCodes.indexOf(currLang.replace('_','-')) > -1){
voiceOutput.voiceLang = currLang.replace('_','-');
}
}
console.log(voiceOutput);
return voiceOutput;
}
render() {
const bodyStyle = {
'padding': 0,
textAlign: 'center'
}
const Buttonstyles = {
marginBottom: 16,
}
const subHeaderStyle = {
color: UserPreferencesStore.getTheme()==='light'
? '#4285f4' : '#19314B',
margin: '20px 0 0 0',
fontSize: '15px'
}
const closingStyle ={
position: 'absolute',
zIndex: 1200,
fill: '#444',
width: '26px',
height: '26px',
right: '10px',
top: '10px',
cursor:'pointer'
}
const serverDialogActions = [
<RaisedButton
key={'Cancel'}
label="Cancel"
backgroundColor={
UserPreferencesStore.getTheme()==='light' ? '#4285f4' : '#19314B'}
labelColor="#fff"
width='200px'
keyboardFocused={false}
onTouchTap={this.handleServerToggle.bind(this,false)}
style={{margin: '6px'}}
/>,
<RaisedButton
key={'OK'}
label="OK"
backgroundColor={
UserPreferencesStore.getTheme()==='light' ? '#4285f4' : '#19314B'}
labelColor="#fff"
width='200px'
keyboardFocused={false}
onTouchTap={this.handleServerToggle.bind(this,true)}
/>];
let hardwareDivStyle = {
paddingTop:'55px'
};
if(cookies.get('loggedIn')){
hardwareDivStyle = {};
}
let backgroundCol;
let topBackground = UserPreferencesStore.getTheme();
switch(topBackground){
case 'light':{
backgroundCol = '#4285f4';
break;
}
case 'dark':{
backgroundCol = '#19324c';
break;
}
default: {
// do nothing
}
}
let TopRightMenu = (props) => (
<div>
<IconMenu
{...props}
iconButtonElement={
<IconButton
iconStyle={{ fill: 'white' }}><MoreVertIcon /></IconButton>
}
targetOrigin={{ horizontal: 'right', vertical: 'top' }}
anchorOrigin={{ horizontal: 'right', vertical: 'top' }}
onTouchTap={this.showOptions}
>
</IconMenu>
<Popover
{...props}
style={{ float: 'right', position: 'relative', right: '0px', margin: '46px 20px 0 0' }}
open={this.state.showOptions}
anchorEl={this.state.anchorEl}
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
targetOrigin={{ horizontal: 'right', vertical: 'top' }}
onRequestClose={this.closeOptions}
>
<Logged />
</Popover>
</div>
);
let voiceOutput = this.populateVoiceList();
return (
<div className={topBackground}>
<header className='message-thread-heading'
style={{ backgroundColor: backgroundCol }}>
<AppBar
className='topAppBar'
title={<div style={{ float: 'left', marginTop: '-10px' }}><Link to="/" >
<img src={susiWhite} alt="susi-logo" className="siteTitle" /></Link></div>}
style={{backgroundColor: backgroundCol, height: '46px',
boxShadow: 'none' }}
iconStyleRight={{marginTop: '-2px'}}
iconElementRight={<TopRightMenu />}
/>
</header>
<div className="settingsForm">
<Paper zDepth={0}>
<div className='settingsDialog'>
<h3 className='settingsHeader'>Chat Settings</h3>
<h3 style={subHeaderStyle}>ChatApp Settings</h3>
<div>
<h4 style={{float:'left'}}>Select Theme</h4>
<DropDownMenu
label='Default Theme'
value={this.state.theme}
onChange={this.handleSelectChange}>
<MenuItem value={'light'} primaryText="Light" />
<MenuItem value={'dark'} primaryText="Dark" />
<MenuItem value={'custom'} primaryText="Custom" />
</DropDownMenu>
</div>
<div>
<h4 style={{'marginBottom':'0px'}}>Enter As Send</h4>
<Toggle
className='settings-toggle'
label='Send message by pressing ENTER'
onToggle={this.handleEnterAsSend}
toggled={this.state.enterAsSend}/>
</div>
<h3 style={subHeaderStyle}>Mic Settings</h3>
<div>
<h4 style={{'marginBottom':'0px'}}>Mic Input</h4>
<Toggle
className='settings-toggle'
label='Enable mic to give voice input'
disabled={!this.STTBrowserSupport}
onToggle={this.handleMicInput}
toggled={this.state.micInput}/>
</div>
<h3 style={subHeaderStyle}>Speech Settings</h3>
<div>
<h4 style={{'marginBottom':'0px'}}>Speech Output</h4>
<Toggle
className='settings-toggle'
label='Enable speech output only for speech input'
disabled={!this.TTSBrowserSupport}
onToggle={this.handleSpeechOutput}
toggled={this.state.speechOutput}/>
</div>
<div>
<h4 style={{'marginBottom':'0px'}}>Speech Output Always ON</h4>
<Toggle
className='settings-toggle'
label='Enable speech output regardless of input type'
disabled={!this.TTSBrowserSupport}
onToggle={this.handleSpeechOutputAlways}
toggled={this.state.speechOutputAlways}/>
</div>
<div>
<h4 style={{'marginBottom':'0px'}}>Language</h4>
<FlatButton
className='settingsBtns'
style={Buttonstyles}
label="Select a Language"
disabled={!this.TTSBrowserSupport}
onClick={this.handleLanguage.bind(this,true)} />
</div>
<div>
<h3 style={subHeaderStyle}>Language Settings</h3>
<div>
<h4 style={{'marginBottom':'0px'}}>Select Language</h4>
<DropDownMenu
value={voiceOutput.voiceLang}
disabled={!this.TTSBrowserSupport}
onChange={this.handlePrefLang}>
{voiceOutput.voiceMenu}
</DropDownMenu>
</div>
</div>
{cookies.get('loggedIn') ?
<div>
<div>
<h3 style={subHeaderStyle}>Server Settings</h3>
<FlatButton
className='settingsBtns'
style={Buttonstyles}
label="Select backend server for the app"
onClick={this.handleServer} />
</div>
<div>
<h3 style={subHeaderStyle}>Account Settings</h3>
<FlatButton
className='settingsBtns'
style={Buttonstyles}
label="Change Password"
onClick={this.handleChangePassword} />
</div>
</div>
:
<div>
<h3 style={subHeaderStyle}>Server Settings</h3>
<div style={{position: 'absolute',align:'left'}}>
<CustomServer
checked={this.state.checked}
serverUrl={this.state.serverUrl}
customServerMessage={this.customServerMessage}
onServerChange={this.handleServeChange}/>
</div>
</div>
}
<div style={hardwareDivStyle}>
<h3 style={subHeaderStyle}>Connect to SUSI Hardware:</h3>
<FlatButton
className='settingsBtns'
style={Buttonstyles}
label="Add address to connect to Hardware"
onClick={this.handleHardware} />
</div>
</div>
<div className='settingsSubmit'>
<RaisedButton
label="Save"
disabled={!this.state.validForm}
backgroundColor={
UserPreferencesStore.getTheme()==='light'
? '#4285f4' : '#19314B'}
labelColor="#fff"
onClick={this.handleSubmit}
/>
</div>
</Paper>
<Dialog
modal={false}
autoScrollBodyContent={true}
open={this.state.showLanguageSettings}
onRequestClose={this.handleLanguage.bind(this,false)}>
<TextToSpeechSettings
rate={this.state.speechRate}
pitch={this.state.speechPitch}
lang={this.state.ttsLanguage}
ttsSettings={this.handleTextToSpeech}/>
<Close style={closingStyle} onTouchTap={this.handleClose} />
</Dialog>
{/* Hardware Connection */}
<Dialog
modal={false}
open={this.state.showHardwareChangeDialog}
autoScrollBodyContent={true}
bodyStyle={bodyStyle}
onRequestClose={this.handleClose}>
<div>
<HardwareComponent {...this.props} />
<Close style={closingStyle}
onTouchTap={this.handleClose} />
</div>
</Dialog>
{/* Change Server */}
<Dialog
actions={serverDialogActions}
modal={false}
open={this.state.showServerChangeDialog}
autoScrollBodyContent={true}
bodyStyle={bodyStyle}
onRequestClose={this.handleServerToggle.bind(this,false)}>
<div>
<h3>Change Server</h3>
Please login again to change SUSI server
<Close style={closingStyle}
onTouchTap={this.handleServerToggle.bind(this,false)} />
</div>
</Dialog>
{/* Change Password */}
<Dialog
className='dialogStyle'
modal={false}
open={this.state.showChangePasswordDialog}
autoScrollBodyContent={true}
bodyStyle={bodyStyle}
contentStyle={{width: '35%',minWidth: '300px'}}
onRequestClose={this.handleClose}>
<ChangePassword {...this.props} />
<Close style={closingStyle} onTouchTap={this.handleClose} />
</Dialog>
{/* Login */}
<Dialog
className='dialogStyle'
modal={true}
open={this.state.showLogin}
autoScrollBodyContent={true}
bodyStyle={bodyStyle}
contentStyle={{ width: '35%', minWidth: '300px' }}
onRequestClose={this.handleClose}>
<Login {...this.props}
handleForgotPassword={this.handleForgotPassword}
handleSignUp={this.handleSignUp}/>
<Close style={closingStyle} onTouchTap={this.handleClose} />
</Dialog>
{/* SignUp */}
<Dialog
className='dialogStyle'
modal={true}
open={this.state.showSignUp}
autoScrollBodyContent={true}
bodyStyle={bodyStyle}
contentStyle={{ width: '35%', minWidth: '300px' }}
onRequestClose={this.handleClose}>
<SignUp {...this.props}
onRequestClose={this.handleClose}
onLoginSignUp={this.handleLogin}/>
<Close style={closingStyle}
onTouchTap={this.handleClose} />
</Dialog>
{/* ForgotPassword */}
<Dialog
className='dialogStyle'
modal={false}
open={this.state.showForgotPassword}
autoScrollBodyContent={true}
contentStyle={{width: '35%',minWidth: '300px'}}
onRequestClose={this.handleClose}>
<ForgotPassword {...this.props}
showForgotPassword={this.handleForgotPassword}/>
<Close style={closingStyle}
onTouchTap={this.handleClose}/>
</Dialog>
</div>
</div>);
}
}
Settings.propTypes = {
history: PropTypes.object,
onSettingsSubmit: PropTypes.func,
onServerChange: PropTypes.func,
onHardwareSettings: PropTypes.func
};
export default Settings;
|
src/docs/examples/TextInput/ExampleError.js | ebirito/ps-react-ebirito | import React from 'react';
import TextInput from 'ps-react-ebirito/TextInput';
/** Required TextBox with error */
export default class ExampleError extends React.Component {
render() {
return (
<TextInput
htmlId="example-optional"
label="First Name"
name="firstname"
onChange={() => {}}
required
error="First name is required."
/>
)
}
} |
node-siebel-rest/siebel_claims_demo/src/Component/Data/FilterClaims.js | Pravici/node-siebel | import React, { Component } from 'react';
import Claims from './Claims';
import SearchBar from './SearchBar';
class FilterClaims extends Component {
constructor(props) {
super(props);
this.state = {
filterText: ''
};
this.onFilterTextChange = this.onFilterTextChange.bind(this);
}
onFilterTextChange(filterText) {
this.setState({filterText: filterText});
}
render() {
return (
<div>
<SearchBar
filterText={this.state.filterText}
onFilterTextChange={this.onFilterTextChange}
/>
<Claims
claims={this.props.claims}
filterText={this.state.filterText}
/>
</div>
);
}
}
export default FilterClaims;
|
src/svg-icons/maps/tram.js | spiermar/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsTram = (props) => (
<SvgIcon {...props}>
<path d="M19 16.94V8.5c0-2.79-2.61-3.4-6.01-3.49l.76-1.51H17V2H7v1.5h4.75l-.76 1.52C7.86 5.11 5 5.73 5 8.5v8.44c0 1.45 1.19 2.66 2.59 2.97L6 21.5v.5h2.23l2-2H14l2 2h2v-.5L16.5 20h-.08c1.69 0 2.58-1.37 2.58-3.06zm-7 1.56c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5-4.5H7V9h10v5z"/>
</SvgIcon>
);
MapsTram = pure(MapsTram);
MapsTram.displayName = 'MapsTram';
MapsTram.muiName = 'SvgIcon';
export default MapsTram;
|
src/components/slider/SliderSwatch.js | socialtables/react-color | 'use strict' /* @flow */
import React from 'react'
import ReactCSS from 'reactcss'
import shallowCompare from 'react-addons-shallow-compare'
export class SliderSwatch extends ReactCSS.Component {
shouldComponentUpdate = shallowCompare.bind(this, this, arguments[0], arguments[1])
classes(): any {
return {
'default': {
swatch: {
height: '12px',
background: 'hsl(' + this.props.hsl.h + ', 50%, ' + (this.props.offset * 100) + '%)',
cursor: 'pointer',
},
},
'first': {
swatch: {
borderRadius: '2px 0px 0px 2px',
},
},
'last': {
swatch: {
borderRadius: '0px 2px 2px 0px',
},
},
active: {
swatch: {
transform: 'scaleY(1.8)',
borderRadius: '3.6px/2px',
},
},
}
}
handleClick = () => {
this.props.onClick({
h: this.props.hsl.h,
s: .5,
l: this.props.offset,
source: 'hsl',
})
}
render(): any {
return (
<div is="swatch" ref="swatch" onClick={ this.handleClick } />
)
}
}
export default SliderSwatch
|
app/javascript/mastodon/features/account_timeline/components/header.js | pinfort/mastodon | import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import InnerHeader from '../../account/components/header';
import ImmutablePureComponent from 'react-immutable-pure-component';
import MovedNote from './moved_note';
import { FormattedMessage } from 'react-intl';
import { NavLink } from 'react-router-dom';
export default class Header extends ImmutablePureComponent {
static propTypes = {
account: ImmutablePropTypes.map,
identity_proofs: ImmutablePropTypes.list,
onFollow: PropTypes.func.isRequired,
onBlock: PropTypes.func.isRequired,
onMention: PropTypes.func.isRequired,
onDirect: PropTypes.func.isRequired,
onReblogToggle: PropTypes.func.isRequired,
onReport: PropTypes.func.isRequired,
onMute: PropTypes.func.isRequired,
onBlockDomain: PropTypes.func.isRequired,
onUnblockDomain: PropTypes.func.isRequired,
onEndorseToggle: PropTypes.func.isRequired,
onAddToList: PropTypes.func.isRequired,
hideTabs: PropTypes.bool,
domain: PropTypes.string.isRequired,
};
static contextTypes = {
router: PropTypes.object,
};
handleFollow = () => {
this.props.onFollow(this.props.account);
}
handleBlock = () => {
this.props.onBlock(this.props.account);
}
handleMention = () => {
this.props.onMention(this.props.account, this.context.router.history);
}
handleDirect = () => {
this.props.onDirect(this.props.account, this.context.router.history);
}
handleReport = () => {
this.props.onReport(this.props.account);
}
handleReblogToggle = () => {
this.props.onReblogToggle(this.props.account);
}
handleNotifyToggle = () => {
this.props.onNotifyToggle(this.props.account);
}
handleMute = () => {
this.props.onMute(this.props.account);
}
handleBlockDomain = () => {
const domain = this.props.account.get('acct').split('@')[1];
if (!domain) return;
this.props.onBlockDomain(domain);
}
handleUnblockDomain = () => {
const domain = this.props.account.get('acct').split('@')[1];
if (!domain) return;
this.props.onUnblockDomain(domain);
}
handleEndorseToggle = () => {
this.props.onEndorseToggle(this.props.account);
}
handleAddToList = () => {
this.props.onAddToList(this.props.account);
}
handleEditAccountNote = () => {
this.props.onEditAccountNote(this.props.account);
}
render () {
const { account, hideTabs, identity_proofs } = this.props;
if (account === null) {
return null;
}
return (
<div className='account-timeline__header'>
{account.get('moved') && <MovedNote from={account} to={account.get('moved')} />}
<InnerHeader
account={account}
identity_proofs={identity_proofs}
onFollow={this.handleFollow}
onBlock={this.handleBlock}
onMention={this.handleMention}
onDirect={this.handleDirect}
onReblogToggle={this.handleReblogToggle}
onNotifyToggle={this.handleNotifyToggle}
onReport={this.handleReport}
onMute={this.handleMute}
onBlockDomain={this.handleBlockDomain}
onUnblockDomain={this.handleUnblockDomain}
onEndorseToggle={this.handleEndorseToggle}
onAddToList={this.handleAddToList}
onEditAccountNote={this.handleEditAccountNote}
domain={this.props.domain}
/>
{!hideTabs && (
<div className='account__section-headline'>
<NavLink exact to={`/accounts/${account.get('id')}`}><FormattedMessage id='account.posts' defaultMessage='Toots' /></NavLink>
<NavLink exact to={`/accounts/${account.get('id')}/with_replies`}><FormattedMessage id='account.posts_with_replies' defaultMessage='Toots and replies' /></NavLink>
<NavLink exact to={`/accounts/${account.get('id')}/media`}><FormattedMessage id='account.media' defaultMessage='Media' /></NavLink>
</div>
)}
</div>
);
}
}
|
src/components/RadioField.js | founderlab/fl-react-utils | import _ from 'lodash' // eslint-disable-line
import React from 'react'
import PropTypes from 'prop-types'
import Inflection from 'inflection'
import {Field} from 'redux-form'
import {FormGroup, ControlLabel, HelpBlock} from 'react-bootstrap'
import {validationState} from '../validation'
export default class RadioField extends React.Component {
static propTypes = {
name: PropTypes.string,
label: PropTypes.string,
helpTop: PropTypes.bool,
help: PropTypes.string,
validationState: PropTypes.string,
options: PropTypes.oneOfType([
PropTypes.array,
PropTypes.object,
]),
}
render() {
const {name, label, help, validationState, helpTop} = this.props
const id = Inflection.dasherize((label || '').toLowerCase())
return (
<FormGroup controlId={id} validationState={validationState}>
{label && <ControlLabel>{label}</ControlLabel>}
{help && helpTop && (<HelpBlock>{help}</HelpBlock>)}
<div>
{this.props.options.map((opt, i) => (
<label key={i} className="radio-inline">
<Field
name={name}
value={opt.value}
component="input"
type="radio"
/>
{opt.label}
</label>
))}
</div>
{help && !helpTop && (<HelpBlock>{help}</HelpBlock>)}
</FormGroup>
)
}
}
|
react-starter/examples/UnigridExample4.js | yoonka/unigrid | /*
Copyright (c) 2018, Grzegorz Junka
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import React from 'react';
import { tableData } from './data/Resp1';
import {
Unigrid,
getSorter,
sort,
isDefined
} from '../unigrid';
export class UnigridExample4 extends React.Component {
clickHandler(field) {
return () => sort(this.unigrid, field);
}
render() {
const ucFormatter = (attr) =>
(props) => props.item[attr].toUpperCase();
const columnToFields = (column) => {
if (column === 'name') {
return [ucFormatter('name')];
}
return column === 'number' ? [column] : ['name'];
}
const props = {
data: tableData,
box: { column: 'agent', order: 'asc' },
table: {
className: 'unigrid-main-class',
$do: [
{
section: 'header',
className: 'unigrid-header',
cells: [
{ show: 'hAgent', onClick: this.clickHandler('agent') },
{ show: 'hDate', onClick: this.clickHandler('date') },
{ show: 'hStreet', onClick: this.clickHandler('street') },
{ show: 'hName', onClick: this.clickHandler('name') },
{ show: 'hNumber', onClick: this.clickHandler('number') }
],
rowAs: 'header'
},
{
process: getSorter(),
select: 'all',
$do: [
{
section: 'body',
className: 'unigrid-segment',
$do: [
{
condition: { ifDoes: 'exist', property: 'list' },
fromProperty: 'list',
cells: [
'hCategory',
{ as: 'empty', colSpan: 3 },
'hNumber'
],
rowAs: 'header'
},
{
className: 'some-row-class',
cells: ['agent', 'date', 'street', ucFormatter('name'),
{
show: 'number',
as: 'string',
className: 'number-cell'
}]
},
{
condition: { ifDoes: 'exist', property: 'list' },
fromProperty: 'list',
process: getSorter(columnToFields),
select: 'all',
cells: [{ as: 'empty', colSpan: 3 }, 'name', 'number']
}
]
}
]
},
{
section: 'footer',
className: 'unigrid-footer',
$do: [
{ cells: [null, null, null, 'fSum', 'fTotal'] },
{ cells: [null, null, null, 'sum', 'total'] }
]
}
]
}
};
return (
<div>
<p>Example 4 : Sortable Multitable (no JSX)</p>
<Unigrid {...props} ref={(ref) => { this.unigrid = ref; }} />
</div>
);
}
}
|
src/svg-icons/device/bluetooth-searching.js | hwo411/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceBluetoothSearching = (props) => (
<SvgIcon {...props}>
<path d="M14.24 12.01l2.32 2.32c.28-.72.44-1.51.44-2.33 0-.82-.16-1.59-.43-2.31l-2.33 2.32zm5.29-5.3l-1.26 1.26c.63 1.21.98 2.57.98 4.02s-.36 2.82-.98 4.02l1.2 1.2c.97-1.54 1.54-3.36 1.54-5.31-.01-1.89-.55-3.67-1.48-5.19zm-3.82 1L10 2H9v7.59L4.41 5 3 6.41 8.59 12 3 17.59 4.41 19 9 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM11 5.83l1.88 1.88L11 9.59V5.83zm1.88 10.46L11 18.17v-3.76l1.88 1.88z"/>
</SvgIcon>
);
DeviceBluetoothSearching = pure(DeviceBluetoothSearching);
DeviceBluetoothSearching.displayName = 'DeviceBluetoothSearching';
DeviceBluetoothSearching.muiName = 'SvgIcon';
export default DeviceBluetoothSearching;
|
components/Revue.js | vasco3/Apollo | /**
* Created by cuadraman on 11/12/16.
*/
/* @flow */
import React from 'react'
export default () => {
return (
<div id="revue-embed">
<form action="https://www.getrevue.co/profile/cuadraman/add_subscriber"
method="post" id="revue-form" name="revue-form" target="_blank">
<div className="revue-form-group">
<label htmlFor="member_email">Email address</label>
<input className="revue-form-field" placeholder="Your email address..."
type="email" name="member[email]" id="member_email" />
</div>
<div className="revue-form-group">
<label htmlFor="member_first_name">First name <span className="optional">(Optional)</span></label>
<input className="revue-form-field" placeholder="First name... (Optional)"
type="text" name="member[first_name]" id="member_first_name" />
</div>
<div className="revue-form-group">
<label htmlFor="member_last_name">Last name <span className="optional">(Optional)</span></label>
<input className="revue-form-field" placeholder="Last name... (Optional)"
type="text" name="member[last_name]" id="member_last_name" />
</div>
<div className="revue-form-actions">
<input className="btn green darken-3" type="submit" value="Subscribe" name="member[subscribe]" id="member_submit" />
</div>
</form>
</div>
)
}
|
js/ClientApp.js | daninmotion/react-02 | import React from 'react'
import {render} from 'react-dom'
import {BrowserRouter} from 'react-router'
import App from './App'
render(<BrowserRouter><App /></BrowserRouter>, document.getElementById('app')) |
app/components/LotGDNavigator.js | lotgd/client-react-native | // @flow
'use strict';
import React, { Component } from 'react';
import { View } from 'react-native';
import { StackNavigator } from 'react-navigation';
import util from 'util';
import Login from './Login';
import CharacterCreate from './CharacterCreate';
import UserCreate from './UserCreate';
import Home from './Home';
import RealmAdd from './RealmAdd';
import Settings from './Settings';
import Gameplay from './Gameplay';
// For options to pass as StackNavigatorConfig, see
// https://reactnavigation.org/docs/navigators/stack
export default (stackNavigatorConfig: Object) => {
return StackNavigator({
Home: { screen: Home },
UserCreate: { screen: UserCreate },
CharacterCreate: { screen: CharacterCreate },
RealmAdd: { screen: RealmAdd },
Login: { screen: Login },
Settings: { screen: Settings },
Gameplay: { screen: Gameplay },
},
stackNavigatorConfig);
};
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.