path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
actor-apps/app-web/src/app/components/DialogSection.react.js | vanloswang/actor-platform | import _ from 'lodash';
import React from 'react';
import { PeerTypes } from 'constants/ActorAppConstants';
import MessagesSection from 'components/dialog/MessagesSection.react';
import TypingSection from 'components/dialog/TypingSection.react';
import ComposeSection from 'components/dialog/ComposeSection.react';
import ConnectionState from 'components/common/ConnectionState.react';
import DialogStore from 'stores/DialogStore';
import MessageStore from 'stores/MessageStore';
import GroupStore from 'stores/GroupStore';
import DialogActionCreators from 'actions/DialogActionCreators';
// On which scrollTop value start loading older messages
const LoadMessagesScrollTop = 100;
const initialRenderMessagesCount = 20;
const renderMessagesStep = 20;
let renderMessagesCount = initialRenderMessagesCount;
let lastPeer = null;
let lastScrolledFromBottom = 0;
const getStateFromStores = () => {
const messages = MessageStore.getAll();
let messagesToRender;
if (messages.length > renderMessagesCount) {
messagesToRender = messages.slice(messages.length - renderMessagesCount);
} else {
messagesToRender = messages;
}
return {
peer: DialogStore.getSelectedDialogPeer(),
messages: messages,
messagesToRender: messagesToRender
};
};
class DialogSection extends React.Component {
constructor(props) {
super(props);
this.state = getStateFromStores();
DialogStore.addSelectListener(this.onSelectedDialogChange);
MessageStore.addChangeListener(this.onMessagesChange);
}
componentWillUnmount() {
DialogStore.removeSelectListener(this.onSelectedDialogChange);
MessageStore.removeChangeListener(this.onMessagesChange);
}
componentDidUpdate() {
this.fixScroll();
this.loadMessagesByScroll();
}
render() {
const peer = this.state.peer;
if (peer) {
let isMember = true,
memberArea;
if (peer.type === PeerTypes.GROUP) {
const group = GroupStore.getGroup(peer.id);
isMember = DialogStore.isGroupMember(group);
}
if (isMember) {
memberArea = (
<div>
<TypingSection/>
<ComposeSection peer={this.state.peer}/>
</div>
);
} else {
memberArea = (
<section className="compose compose--disabled row center-xs middle-xs">
<h3>You are not a member</h3>
</section>
);
}
return (
<section className="dialog" onScroll={this.loadMessagesByScroll}>
<ConnectionState/>
<div className="messages">
<MessagesSection messages={this.state.messagesToRender}
peer={this.state.peer}
ref="MessagesSection"/>
</div>
{memberArea}
</section>
);
} else {
return (
<section className="dialog dialog--empty row center-xs middle-xs">
<ConnectionState/>
<h2>Select dialog or start a new one.</h2>
</section>
);
}
}
fixScroll = () => {
if (lastPeer !== null ) {
let node = React.findDOMNode(this.refs.MessagesSection);
node.scrollTop = node.scrollHeight - lastScrolledFromBottom;
}
};
onSelectedDialogChange = () => {
renderMessagesCount = initialRenderMessagesCount;
if (lastPeer != null) {
DialogActionCreators.onConversationClosed(lastPeer);
}
lastPeer = DialogStore.getSelectedDialogPeer();
DialogActionCreators.onConversationOpen(lastPeer);
};
onMessagesChange = _.debounce(() => {
this.setState(getStateFromStores());
}, 10, {maxWait: 50, leading: true});
loadMessagesByScroll = _.debounce(() => {
if (lastPeer !== null ) {
let node = React.findDOMNode(this.refs.MessagesSection);
let scrollTop = node.scrollTop;
lastScrolledFromBottom = node.scrollHeight - scrollTop;
if (node.scrollTop < LoadMessagesScrollTop) {
DialogActionCreators.onChatEnd(this.state.peer);
if (this.state.messages.length > this.state.messagesToRender.length) {
renderMessagesCount += renderMessagesStep;
if (renderMessagesCount > this.state.messages.length) {
renderMessagesCount = this.state.messages.length;
}
this.setState(getStateFromStores());
}
}
}
}, 5, {maxWait: 30});
}
export default DialogSection;
|
src/containers/code-split-chunk/index.js | btoo/btoo.github.io | import React from 'react'
import { push } from 'react-router-redux'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import {
increment,
incrementAsync,
decrement,
decrementAsync
} from '../../modules/counter'
const Home = props => (
<div>
<h1>dat code split doe</h1>
<p>Count: {props.count}</p>
<p>
<button onClick={props.increment} disabled={props.isIncrementing}>Increment</button>
<button onClick={props.incrementAsync} disabled={props.isIncrementing}>Increment Async</button>
</p>
<p>
<button onClick={props.decrement} disabled={props.isDecrementing}>Decrementing</button>
<button onClick={props.decrementAsync} disabled={props.isDecrementing}>Decrement Async</button>
</p>
<p><button onClick={() => props.changePage()}>Go to about page via redux</button></p>
</div>
)
const mapStateToProps = state => ({
count: state.counter.count,
isIncrementing: state.counter.isIncrementing,
isDecrementing: state.counter.isDecrementing
})
const mapDispatchToProps = dispatch => bindActionCreators({
increment,
incrementAsync,
decrement,
decrementAsync,
changePage: () => push('/about-us')
}, dispatch)
export default connect(
mapStateToProps,
mapDispatchToProps
)(Home)
|
src/js/components/MaskedInput/stories/Filtered.js | grommet/grommet | import React from 'react';
import { Box, MaskedInput } from 'grommet';
const data = {
Cummings: [
'a pretty day',
'i carry your heart with me',
'if you like my poems let them',
],
Chaucer: ["The Knight's Tale", 'The General Prologue', "The Friar's Tale"],
Neruda: ['If You Forget Me', 'Love Sonnet XVII'],
Poe: ['The Raven', 'Romance', 'Song'],
Whitman: ['To You', 'O Captain! My Captain!', 'O Me! O Life!'],
};
export const Filtered = () => {
const [value, setValue] = React.useState('');
const [first, second] = value.split(':');
const poets = first
? Object.keys(data).filter((k) =>
k.toLowerCase().startsWith(first.toLowerCase()),
)
: Object.keys(data);
const poems =
data[first] && second
? data[first].filter((k) =>
k.toLowerCase().startsWith(second.toLowerCase()),
)
: data[first] || [];
let longestPoemLength = 0;
poems.forEach((p) => {
longestPoemLength = Math.max(longestPoemLength, p.length);
});
return (
// Uncomment <Grommet> lines when using outside of storybook
// <Grommet theme={...}>
<Box fill align="center" justify="start" pad="large">
<Box width="medium">
<MaskedInput
mask={[
{
options: poets,
placeholder: 'poet',
},
{ fixed: ':' },
{
options: poems,
length: longestPoemLength,
placeholder: 'poem',
},
]}
value={value}
onChange={(event) => setValue(event.target.value)}
/>
</Box>
</Box>
// </Grommet>
);
};
Filtered.parameters = {
chromatic: { disable: true },
};
Filtered.args = {
full: true,
};
export default {
title: 'Input/MaskedInput/Filtered',
};
|
src/views/components/RegisterForm.js | physiii/open-automation | import React from 'react';
import PropTypes from 'prop-types';
import TextField from './TextField.js';
import Actions from './Actions.js';
import Button from './Button.js';
import {default as FormValidator, minLength, mustMatch, email} from '../form-validation.js';
import {connect} from 'react-redux';
import * as session from '../../state/ducks/session';
const PASSWORD_MIN_LENGTH = 8;
export class RegisterForm extends React.Component {
constructor (props) {
super(props);
this.state = {
email: '',
password: '',
confirm_password: '',
validation_errors: {}
};
this.validator = new FormValidator(this.state)
.field('email', 'Email', email)
.field('password', 'Password', minLength(PASSWORD_MIN_LENGTH))
.field('confirm_password', 'Password Confirmation', mustMatch('password', 'Password'));
this.handleFieldChange = this.handleFieldChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
componentDidUpdate () {
this.validator.setState(this.state);
}
handleFieldChange (event) {
const newValue = event.target.value;
this.setState({
[event.target.name]: newValue,
validation_errors: this.validator.validateField(event.target.name, newValue, event.type)
});
}
handleSubmit (event) {
event.preventDefault();
const errors = this.validator.validateForm();
if (this.validator.hasErrors()) {
this.setState({validation_errors: errors});
return;
}
this.props.register(this.state.email, this.state.password);
}
render () {
return (
<form onSubmit={this.handleSubmit}>
<TextField
name="email"
label="Email"
type="email"
autoComplete="email"
value={this.state.email}
error={this.state.validation_errors.email}
onChange={this.handleFieldChange}
onBlur={this.handleFieldChange} />
<TextField
name="password"
label="Password"
type="password"
autoComplete="new-password"
value={this.state.password}
error={this.state.validation_errors.password}
onChange={this.handleFieldChange}
onBlur={this.handleFieldChange} />
<TextField
name="confirm_password"
label="Confirm Password"
type="password"
autoComplete="new-password"
value={this.state.confirm_password}
error={this.state.validation_errors.confirm_password}
onChange={this.handleFieldChange}
onBlur={this.handleFieldChange} />
<Actions>
<Button type="filled" submitForm={true}>Create Account</Button>
</Actions>
</form>
);
}
}
RegisterForm.propTypes = {
register: PropTypes.func
};
const mapDispatchToProps = (dispatch) => ({
register: (username, password) => {
dispatch(session.operations.register(username, password));
}
});
export default connect(null, mapDispatchToProps)(RegisterForm);
|
pages/blog/test-article-one.js | alexpalombaro/react-static | /**
* React Static Boilerplate
* https://github.com/koistya/react-static-boilerplate
* Copyright (c) Konstantin Tarkus (@koistya) | MIT license
*/
import React, { Component } from 'react';
export default class extends Component {
render() {
return (
<div>
<h1>Test Article 1</h1>
<p>Coming soon.</p>
</div>
);
}
}
|
node_modules/react-bootstrap/es/Col.js | joekay/awebb | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import elementType from 'react-prop-types/lib/elementType';
import { bsClass, prefix, splitBsProps } from './utils/bootstrapUtils';
import { DEVICE_SIZES } from './utils/StyleConfig';
var propTypes = {
componentClass: elementType,
/**
* The number of columns you wish to span
*
* for Extra small devices Phones (<768px)
*
* class-prefix `col-xs-`
*/
xs: PropTypes.number,
/**
* The number of columns you wish to span
*
* for Small devices Tablets (≥768px)
*
* class-prefix `col-sm-`
*/
sm: PropTypes.number,
/**
* The number of columns you wish to span
*
* for Medium devices Desktops (≥992px)
*
* class-prefix `col-md-`
*/
md: PropTypes.number,
/**
* The number of columns you wish to span
*
* for Large devices Desktops (≥1200px)
*
* class-prefix `col-lg-`
*/
lg: PropTypes.number,
/**
* Hide column
*
* on Extra small devices Phones
*
* adds class `hidden-xs`
*/
xsHidden: PropTypes.bool,
/**
* Hide column
*
* on Small devices Tablets
*
* adds class `hidden-sm`
*/
smHidden: PropTypes.bool,
/**
* Hide column
*
* on Medium devices Desktops
*
* adds class `hidden-md`
*/
mdHidden: PropTypes.bool,
/**
* Hide column
*
* on Large devices Desktops
*
* adds class `hidden-lg`
*/
lgHidden: PropTypes.bool,
/**
* Move columns to the right
*
* for Extra small devices Phones
*
* class-prefix `col-xs-offset-`
*/
xsOffset: PropTypes.number,
/**
* Move columns to the right
*
* for Small devices Tablets
*
* class-prefix `col-sm-offset-`
*/
smOffset: PropTypes.number,
/**
* Move columns to the right
*
* for Medium devices Desktops
*
* class-prefix `col-md-offset-`
*/
mdOffset: PropTypes.number,
/**
* Move columns to the right
*
* for Large devices Desktops
*
* class-prefix `col-lg-offset-`
*/
lgOffset: PropTypes.number,
/**
* Change the order of grid columns to the right
*
* for Extra small devices Phones
*
* class-prefix `col-xs-push-`
*/
xsPush: PropTypes.number,
/**
* Change the order of grid columns to the right
*
* for Small devices Tablets
*
* class-prefix `col-sm-push-`
*/
smPush: PropTypes.number,
/**
* Change the order of grid columns to the right
*
* for Medium devices Desktops
*
* class-prefix `col-md-push-`
*/
mdPush: PropTypes.number,
/**
* Change the order of grid columns to the right
*
* for Large devices Desktops
*
* class-prefix `col-lg-push-`
*/
lgPush: PropTypes.number,
/**
* Change the order of grid columns to the left
*
* for Extra small devices Phones
*
* class-prefix `col-xs-pull-`
*/
xsPull: PropTypes.number,
/**
* Change the order of grid columns to the left
*
* for Small devices Tablets
*
* class-prefix `col-sm-pull-`
*/
smPull: PropTypes.number,
/**
* Change the order of grid columns to the left
*
* for Medium devices Desktops
*
* class-prefix `col-md-pull-`
*/
mdPull: PropTypes.number,
/**
* Change the order of grid columns to the left
*
* for Large devices Desktops
*
* class-prefix `col-lg-pull-`
*/
lgPull: PropTypes.number
};
var defaultProps = {
componentClass: 'div'
};
var Col = function (_React$Component) {
_inherits(Col, _React$Component);
function Col() {
_classCallCheck(this, Col);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Col.prototype.render = function render() {
var _props = this.props,
Component = _props.componentClass,
className = _props.className,
props = _objectWithoutProperties(_props, ['componentClass', 'className']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = [];
DEVICE_SIZES.forEach(function (size) {
function popProp(propSuffix, modifier) {
var propName = '' + size + propSuffix;
var propValue = elementProps[propName];
if (propValue != null) {
classes.push(prefix(bsProps, '' + size + modifier + '-' + propValue));
}
delete elementProps[propName];
}
popProp('', '');
popProp('Offset', '-offset');
popProp('Push', '-push');
popProp('Pull', '-pull');
var hiddenPropName = size + 'Hidden';
if (elementProps[hiddenPropName]) {
classes.push('hidden-' + size);
}
delete elementProps[hiddenPropName];
});
return React.createElement(Component, _extends({}, elementProps, {
className: classNames(className, classes)
}));
};
return Col;
}(React.Component);
Col.propTypes = propTypes;
Col.defaultProps = defaultProps;
export default bsClass('col', Col); |
App/ui/components/Footer.js | CaipiLabs/caipi | /*
* Copyright (c) 2018. Wise Wild Web
*
* This File is part of Caipi and under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
* Full license at https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
*
* @author : Nathanael Braun
* @contact : [email protected]
*/
'use strict';
import React from 'react';
import { Menu } from 'App/ui/View';
import LoginBox from './LoginBox';
class Footer extends React.Component {
render() {
return (
<footer>
<LoginBox/>
</footer>
);
}
};
export default Footer;
|
client/src/components/Nav.js | BrianMehrman/rails_probe | import React, { Component } from 'react';
class Nav extends Component {
renderSideList(data) {
return (
<div className="sidebar-nav navbar-collapse">
<ul className="nav" id="side-menu">
<li className="sidebar-search">
<div className="input-group custom-search-form">
<input type="text" className="form-control" placeholder="Search..." />
<span className="input-group-btn">
<button className="btn btn-default" type="button">
<i className="fa fa-search"></i>
</button>
</span>
</div>
</li>
<li>
<a href="index.html"><i className="fa fa-dashboard fa-fw"></i> Dashboard</a>
</li>
<li>
<a href="#"><i className="fa fa-bar-chart-o fa-fw"></i> Charts<span className="fa arrow"></span></a>
<ul className="nav nav-second-level">
<li>
<a href="flot.html">Flot Charts</a>
</li>
<li>
<a href="morris.html">Morris.js Charts</a>
</li>
</ul>
</li>
<li>
<a href="tables.html"><i className="fa fa-table fa-fw"></i> Tables</a>
</li>
<li>
<a href="forms.html"><i className="fa fa-edit fa-fw"></i> Forms</a>
</li>
<li>
<a href="#"><i className="fa fa-wrench fa-fw"></i> UI Elements<span className="fa arrow"></span></a>
<ul className="nav nav-second-level">
<li>
<a href="panels-wells.html">Panels and Wells</a>
</li>
<li>
<a href="buttons.html">Buttons</a>
</li>
<li>
<a href="notifications.html">Notifications</a>
</li>
<li>
<a href="typography.html">Typography</a>
</li>
<li>
<a href="icons.html"> Icons</a>
</li>
<li>
<a href="grid.html">Grid</a>
</li>
</ul>
</li>
<li>
<a href="#"><i className="fa fa-sitemap fa-fw"></i> Multi-Level Dropdown<span className="fa arrow"></span></a>
<ul className="nav nav-second-level">
<li>
<a href="#">Second Level Item</a>
</li>
<li>
<a href="#">Second Level Item</a>
</li>
<li>
<a href="#">Third Level <span className="fa arrow"></span></a>
<ul className="nav nav-third-level">
<li>
<a href="#">Third Level Item</a>
</li>
<li>
<a href="#">Third Level Item</a>
</li>
<li>
<a href="#">Third Level Item</a>
</li>
<li>
<a href="#">Third Level Item</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#"><i className="fa fa-files-o fa-fw"></i> Sample Pages<span className="fa arrow"></span></a>
<ul className="nav nav-second-level">
<li>
<a href="blank.html">Blank Page</a>
</li>
<li>
<a href="login.html">Login Page</a>
</li>
</ul>
</li>
</ul>
</div>
)
}
renderList(data) {
return (
<div>
<ul className="dropdown-menu dropdown-messages">
{
data.forEach((datum) => {
(
<li>
<a href="#">
<div>
<strong>{datum.title}</strong>
<span className="pull-right text-muted">
<em>{datum.note}</em>
</span>
</div>
<div className={datum.className} >{datum.body}</div>
</a>
</li>
<li className="divider"></li>
)
});
}
<li></li>
</ul>
</div>
)
}
renderButton(data, iconType) {
return (
<div>
<a className="dropdown-toggle" data-toggle="dropdown" href="#">
<i className="fa {iconType} fa-fw"></i> <i className="fa fa-caret-down"></i>
</a>
{ renderList(data) }
</div>
);
}
render() {
const messageData = [
{
title: 'John Smith',
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...',
note: 'Yesterday'
},
{
title: 'John Smith',
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...',
note: 'Yesterday'
},
{
title: 'John Smith',
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...',
note: 'Yesterday'
}
];
const taskData = [
{
title: 'Task 1',
body: (
<div className="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style={{width: '40%'}}>
<span className="sr-only">40% Complete (success)</span>
</div>
),
note: '40% Complete'
},
{
title: 'Task 2',
body: (
<div className="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style={{width: '20%'}}>
<span className="sr-only">20% Complete (success)</span>
</div>
),
note: '20% Complete'
},
{
title: 'Task 3',
body: (
<div className="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style={{width: '60%'}}>
<span className="sr-only">60% Complete (warning)</span>
</div>
),
note: '60% Complete',
classNames: 'progress progress-striped active'
}
]
return (
<nav className="navbar navbar-default navbar-static-top" role="navigation" style={{marginBottom: 0}}>
<div className="navbar-header">
<button type="button" className="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span className="sr-only">Toggle navigation</span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
</button>
<a className="navbar-brand" href="index.html">Timeliner</a>
</div>
<ul className="nav navbar-top-links navbar-right">
<li className="dropdown">
{ renderButton(message, 'fa-envelope') }
</li>
<li className="dropdown">
{ renderButton( taskData, 'fa-tasks') }
</li>
<li className="dropdown">
<a className="dropdown-toggle" data-toggle="dropdown" href="#">
<i className="fa fa-user fa-fw"></i> <i className="fa fa-caret-down"></i>
</a>
<ul className="dropdown-menu dropdown-user">
<li><a href="#"><i className="fa fa-user fa-fw"></i> User Profile</a>
</li>
<li><a href="#"><i className="fa fa-gear fa-fw"></i> Settings</a>
</li>
<li className="divider"></li>
<li><a href="login.html"><i className="fa fa-sign-out fa-fw"></i> Logout</a>
</li>
</ul>
</li>
</ul>
<div className="navbar-default sidebar" role="navigation">
{ renderSideList() }
</div>
</nav>
)
}
}
|
src/svg-icons/editor/vertical-align-center.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorVerticalAlignCenter = (props) => (
<SvgIcon {...props}>
<path d="M8 19h3v4h2v-4h3l-4-4-4 4zm8-14h-3V1h-2v4H8l4 4 4-4zM4 11v2h16v-2H4z"/>
</SvgIcon>
);
EditorVerticalAlignCenter = pure(EditorVerticalAlignCenter);
EditorVerticalAlignCenter.displayName = 'EditorVerticalAlignCenter';
EditorVerticalAlignCenter.muiName = 'SvgIcon';
export default EditorVerticalAlignCenter;
|
packages/wix-style-react/src/FilePicker/test/FilePicker.visual.js | wix/wix-style-react | import React from 'react';
import { storiesOf } from '@storybook/react';
import FilePicker from '../FilePicker';
const defaultProps = {
mainLabel: 'Choose File',
};
const tests = [
{
describe: '',
its: [
{
it: 'default',
props: {},
},
{
it: 'header',
props: {
header: 'Header',
},
},
{
it: 'error',
props: {
error: true,
errorMessage: 'ERROR',
},
},
],
},
];
tests.forEach(({ describe, its }) => {
its.forEach(({ it, props }) => {
storiesOf(`FilePicker${describe ? '/' + describe : ''}`, module).add(
it,
() => <FilePicker {...defaultProps} {...props} />,
);
});
});
|
src/svg-icons/action/work.js | hwo411/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionWork = (props) => (
<SvgIcon {...props}>
<path d="M20 6h-4V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-6 0h-4V4h4v2z"/>
</SvgIcon>
);
ActionWork = pure(ActionWork);
ActionWork.displayName = 'ActionWork';
ActionWork.muiName = 'SvgIcon';
export default ActionWork;
|
src/components/Footer/Footer.js | Nexapp/react-starter-kit | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Footer.css';
import { Link } from 'react-router';
function Footer() {
return (
<div className={s.root}>
<div className={s.container}>
<span className={s.text}>© Your Company</span>
<span className={s.spacer}>·</span>
<Link className={s.link} to="/">Home</Link>
<span className={s.spacer}>·</span>
<Link className={s.link} to="/privacy">Privacy</Link>
<span className={s.spacer}>·</span>
<Link className={s.link} to="/not-found">Not Found</Link>
</div>
</div>
);
}
export default withStyles(s)(Footer);
|
js/components/card/index.js | LetsBuildSomething/vmag_mobile |
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { actions } from 'react-native-navigation-redux-helpers';
import { Container, Header, Title, Content, Button, Icon, Text, Left, Body, Right, List, ListItem } from 'native-base';
import { Actions } from 'react-native-router-flux';
import { openDrawer, closeDrawer } from '../../actions/drawer';
import styles from './styles';
const {
pushRoute,
} = actions;
const datas = [
{
route: 'basic',
text: 'Basic Card',
},
{
route: 'cardList',
text: 'Card List',
},
{
route: 'cardImage',
text: 'Card Image',
},
{
route: 'cardShowcase',
text: 'Card Showcase',
},
{
route: 'cardHeaderAndFooter',
text: 'Card Header & Footer',
},
];
class NHCard extends Component {
static propTypes = {
openDrawer: React.PropTypes.func,
pushRoute: React.PropTypes.func,
navigation: React.PropTypes.shape({
key: React.PropTypes.string,
}),
}
pushRoute(route) {
this.props.pushRoute({ key: route, index: 1 }, this.props.navigation.key);
}
render() {
return (
<Container style={styles.container}>
<Header>
<Left>
<Button transparent onPress={this.props.openDrawer}>
<Icon name="menu" />
</Button>
</Left>
<Body>
<Title>Card</Title>
</Body>
<Right />
</Header>
<Content>
<List
dataArray={datas} renderRow={data =>
<ListItem button onPress={() => { Actions[data.route](); this.props.closeDrawer() }} >
<Text>{data.text}</Text>
<Right>
<Icon name="arrow-forward" style={{ color: '#999' }} />
</Right>
</ListItem>
}
/>
</Content>
</Container>
);
}
}
function bindAction(dispatch) {
return {
openDrawer: () => dispatch(openDrawer()),
closeDrawer: () => dispatch(closeDrawer()),
pushRoute: (route, key) => dispatch(pushRoute(route, key)),
};
}
const mapStateToProps = state => ({
navigation: state.cardNavigation,
themeState: state.drawer.themeState,
});
export default connect(mapStateToProps, bindAction)(NHCard);
|
dist/src/index.js | radiovisual/radiovisual.github.io | import React from 'react';
import ReactDOM from 'react-dom';
import FontFaceObserver from 'fontfaceobserver';
import SideBar from './components/SideBar';
import ThumbContainer from './components/ThumbContainer';
// Observe loading of Lato
const openSansObserver = new FontFaceObserver('Lato', {});
// When Lato is loaded, add a font-family using Lato to the body
openSansObserver.load().then(() => {
document.body.classList.add(styles.fontLoaded);
}, () => {
document.body.classList.remove(styles.fontLoaded);
});
function NumetricLabs() {
return (
<div className="wrapper">
<SideBar />
<ThumbContainer />
</div>
);
}
ReactDOM.render(<NumetricLabs />, document.querySelector('#app'));
|
combine-bak/index.js | lizichen0403/201704slider | import React from 'react';
import ReactDOM from 'react-dom';
import Counter from "./components/Counter";
import Todos from "./components/Todos";
ReactDOM.render(<div>
<Counter/>
<Todos/>
</div>,document.querySelector('#root')); |
demo/component/PolarAngleAxis.js | sdoomz/recharts | import React from 'react';
import {Surface, PolarAngleAxis} from 'recharts';
const ticks = [
{ value: '100', angle: 20 },
{ value: '200', angle: 80 },
{ value: '300', angle: 120 },
{ value: '400', angle: 180 },
{ value: '500', angle: 240 },
{ value: '600', angle: 290 },
];
export default React.createClass({
render () {
return (
<Surface width={500} height={500}>
<PolarAngleAxis
cx={250}
cy={250}
radius={200}
ticks={ticks}
/>
</Surface>
);
}
});
|
app/views/AdditionalFilterView.js | hippothesis/Recipezy | /*
* Copyright 2017-present, Hippothesis, 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.
*/
'use strict';
import React, { Component } from 'react';
import { View, ScrollView, Image, StatusBar, TextInput} from 'react-native';
import { connect } from 'react-redux';
import {
Container,
Content,
Text,
Item,
Input,
Thumbnail,
Icon,
InputGroup,
Left,
Right,
Button,
Grid,
Row,
Col,
List,
ListItem,
Picker
} from 'native-base';
import Images from '../constants/Images';
import { searchRecipes } from '../actions/RecipeSearchResultsActions'; //TODO: Remove
import { updateAllergies, updateCuisines, updateDiets, updateNutrition, updateTypes } from '../actions/FilterActions';
class additionalFilterView extends Component {
constructor(props) {
super(props);
console.log("ALLERGIES: ", this.props.allergies);
console.log("cuisines: ", this.props.cuisines);
console.log("diets: ", this.props.diets);
console.log("nutrition: ", this.props.nutrition);
console.log("types: ", this.props.types);
this.state = {
selectedItem: undefined,
selected1: this.props.allergies,
selected2: this.props.cuisines,
selected3: this.props.diets,
selected4: this.props.nutrition,
selected5: this.props.types,
results: {
items: []
}
}
}
onAllergiesValueChange (value: string) {
this.setState({
selected1 : value
});
console.log("We are updatingAllergies value: ", value);
this.props.updateAllergies(value);
}
onCuisineValueChange (value: string) {
this.setState({
selected2 : value
});
this.props.updateCuisines(value);
}
onDietValueChange (value: string) {
this.setState({
selected3 : value
});
this.props.updateDiets(value);
}
onNutritionValueChange (value: string) {
this.setState({
selected4 : value
});
this.props.updateNutrition(value);
}
onTypeValueChange (value: string) {
this.setState({
selected5 : value
});
this.props.updateTypes(value);
}
update() {
this.props.navigation.goBack();
}
newIngredient() {
this.props.addIngredient("");
}
updateIngredient(id, name) {
this.props.editIngredient(id, name);
}
deleteIngredient(id) {
this.props.removeIngredient(id);
}
render() {
let emptyState =
<ScrollView style={styles.emptyState} scrollEnabled={false}>
<Image style={styles.emptyStateImg} source={Images.food.pot}/>
<Text style={styles.emptyStateText}>What Filters do you wanna apply?</Text>
<Text style={styles.emptyStateText}>Add some tasty ingredients!</Text>
</ScrollView>;
let ingredientList =
<List
style={{marginTop: -50, zIndex: 0}}
dataArray={this.props.ingredients}
renderRow={ (data) =>
<ListItem style={{margin: 0, padding: 4, paddingLeft: 10, paddingRight: 10}}>
<Item style={styles.ingredientInput}>
<Input placeholder="New ingredient" defaultValue={data.name}
onChangeText={(text) => this.updateIngredient(data.id, text)}
/>
<Button transparent style={styles.trashButton} onPress={() => this.deleteIngredient(data.id)}>
<Icon style={styles.trashIcon} name="trash"/>
</Button>
</Item>
</ListItem>}
/>
let content = emptyState;
console.log(this.props.ingredients);
if (this.props.ingredients.length > 0) {
content = ingredientList
}
var dummyVal = '';
return (
<Container>
<View>
<StatusBar barStyle="light-content"/>
<Image style={styles.background} source={Images.backgrounds.filter}>
<Text style={styles.header}>Filters</Text>
</Image>
</View>
<Content>
<Image style={styles.pickerHeader} source={Images.backgrounds.allergies}>
<Text style={{fontSize: 16, color: 'white', fontWeight: 'bold'}}> Allergies/Intolerances </Text>
<Picker
iosHeader="Allergies or Intolerances"
styles={styles.picker}
mode="dropdown"
color="white"
selectedValue={this.state.selected1}
onValueChange={this.onAllergiesValueChange.bind(this)}
iconColor="white">
<Item label="None" value="None" />
<Item label="Dairy" value="Dairy" />
<Item label="Egg" value="Egg" />
<Item label="Gluten" value="Gluten" />
<Item label="Peanut" value="Peanut" />
<Item label="Sesame" value="Sesame" />
<Item label="Seafood" value="Seafood" />
<Item label="Shellfish" value="Shellfish" />
<Item label="Soy" value="Soy" />
<Item label="Sulfite" value="Sulfite" />
<Item label="Tree Nut" value="Tree Nut" />
<Item label="Wheat" value="Wheat" />
</Picker>
</Image>
<Image style={styles.pickerHeader} source={Images.backgrounds.cuisines}>
<Text style={{fontSize: 16, color: 'white', fontWeight: 'bold'}}>Cuisines</Text>
<Picker
iosHeader="Cuisines"
mode="dropdown"
selectedValue={this.state.selected2}
onValueChange={this.onCuisineValueChange.bind(this)}>
<Item label="None" value="None" />
<Item label="American" value="American" />
<Item label="Chinese" value="Chinese" />
<Item label="Japanese" value="Japanese" />
<Item label="Korean" value="Korean" />
<Item label="Vietnamese" value="Vietnamese" />
<Item label="Thai" value="Thai" />
<Item label="Indian" value="Indian" />
<Item label="French" value="French" />
<Item label="Italian" value="Italian" />
<Item label="Mexican" value="Mexican" />
<Item label="Middle Eastern" value="Middle Eastern" />
</Picker>
</Image>
<Image style={styles.pickerHeader} source={Images.backgrounds.diets}>
<Text style={{fontSize: 16, color: 'white', fontWeight: 'bold'}}>Diets</Text>
<Picker
iosHeader="Diets"
mode="dropdown"
selectedValue={this.state.selected3}
onValueChange={this.onDietValueChange.bind(this)}>
<Item label="None" value="None" />
<Item label="Vegetarian" value="Vegetarian" />
<Item label="Vegan" value="Vegan" />
<Item label="Paleo" value="Paleo" />
<Item label="Primal" value="Primal" />
<Item label="Pescetarian" value="Pescetarian" />
<Item label="Lacto Vegetarian" value="Lacto Vegetarian" />
<Item label="Ovo Vegetarian" value="Ovo Vegetarian" />
</Picker>
</Image>
<Image style={styles.pickerHeader} source={Images.backgrounds.nutritions}>
<Text style={{fontSize: 16, color: 'white', fontWeight: 'bold'}}>Max Calories: </Text>
<Picker
iosHeader="Max Calories"
mode="dropdown"
selectedValue={this.state.selected4}
onValueChange={this.onNutritionValueChange.bind(this)}>
<Item label="None" value="None" />
<Item label="100 Calories" value="100 Calories" />
<Item label="500 Calories" value="500 Calories" />
<Item label="1500 Calories" value="1500 Calories" />
<Item label="2500 Calories" value="2500 Calories" />
</Picker>
</Image>
<Image style={styles.pickerHeader} source={Images.backgrounds.types}>
<Text style={{fontSize: 16, color: 'white', fontWeight: 'bold'}}>Types: </Text>
<Picker
iosHeader="Types"
mode="dropdown"
selectedValue={this.state.selected5}
onValueChange={this.onTypeValueChange.bind(this)}>
<Item label="None" value="None" />
<Item label="Main Course" value="Main Course" />
<Item label="Side Dish" value="Side Dish" />
<Item label="Dessert" value="Dessert" />
<Item label="Appetizer" value="Appetizer" />
<Item label="Salad" value="Salad" />
<Item label="Bread" value="Bread" />
<Item label="Breakfast" value="Breakfast" />
<Item label="Soup" value="Soup" />
<Item label="Beverage" value="Beverage" />
<Item label="Sauce" value="Sauce" />
<Item label="Drink" value="Drink" />
<Item label="Lunch" value="Lunch" />
<Item label="Dinner" value="Dinner" />
</Picker>
</Image>
</Content>
<Button full style={styles.updateButton} onPress={() => this.update()}>
<Text>Back</Text>
</Button>
</Container>
);
}
}
const styles = {
background: {
height: 175,
width: null,
resizeMode: 'cover',
justifyContent: 'center'
},
picker: {
color: 'white'
},
pickerHeader: {
height: 75,
width: null,
resizeMode: 'cover',
justifyContent: 'center'
},
header: {
backgroundColor: 'transparent',
color: 'white',
fontSize: 40,
marginLeft: 20,
marginTop: 10,
fontFamily: 'Avenir-Light',
letterSpacing: 2
},
headerButton: {
alignSelf: 'flex-end',
top: -25,
marginRight: 40,
height: 50,
width: 50,
padding: 0,
borderRadius: 25,
justifyContent: 'center',
backgroundColor: '#48abf2',
zIndex: 10,
},
headerButtonIcon: {
fontSize: 40,
backgroundColor: 'transparent',
},
updateButton: {
backgroundColor: '#48abf2'
},
emptyState: {
//justifyContent: 'center'
},
emptyStateImg: {
height: 175,
width: null,
resizeMode: 'contain',
marginBottom: 20,
},
emptyStateText: {
textAlign: 'center',
fontSize: 20,
color: '#999999',
},
ingredientInput: {
borderWidth: 0,
},
trashButton: {
paddingRight: 0,
paddingTop: 10,
},
trashIcon: {
color: '#707070'
}
}
function mapStateToProps(state) {
return {
ingredients: state.recipeSearchIngredientsList,
recipeSearchResults: state.recipeSearchResults,
recipes: state.recipes,
allergies: state.filters.allergies,
cuisines: state.filters.cuisines,
diets: state.filters.diets,
nutrition: state.filters.nutrition,
types: state.filters.types
};
}
function mapDispatchToProps(dispatch) {
return {
searchRecipes: (parameters) => dispatch(searchRecipes(parameters)),
updateAllergies: (name) => dispatch(updateAllergies(name)),
updateCuisines: (name) => dispatch(updateCuisines(name)),
updateDiets: (name) => dispatch(updateDiets(name)),
updateNutrition: (name) => dispatch(updateNutrition(name)),
updateTypes: (name) => dispatch(updateTypes(name))
};
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(additionalFilterView);
|
docs/app/Examples/elements/Segment/Groups/SegmentExamplePiledSegments.js | shengnian/shengnian-ui-react | import React from 'react'
import { Segment } from 'shengnian-ui-react'
const SegmentExamplePiledSegments = () => (
<Segment.Group piled>
<Segment>Top</Segment>
<Segment>Middle</Segment>
<Segment>Bottom</Segment>
</Segment.Group>
)
export default SegmentExamplePiledSegments
|
src/About.js | davertron/react-spa | import React from 'react';
export default props => {
return <div>
<h2>About</h2>
<p>A simple example of a React single page application.</p>
</div>;
}
|
src/components/ModalForm.js | bostonjukebox/boston-jukebox-reactjs | import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
const Container = styled.section`
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
background: rgba(0, 0, 0, 0.6);
`
const Content = styled.section`
position: absolute;
z-index: 10;
top: 50%;
left: 50%;
border-radius: 10px;
padding: 0 1em;
transform: translate(-50%, -50%);
width: 30%;
height: 15em;
background-color: #fff;
color: #000;
box-shadow: 5px 5px 5px rgba(68, 68, 68, 0.6);
`
const Title = styled.h1`
color: #F44336;
font-size: 1.2rem;
`
const TextArea = styled.textarea`
display: block;
height: 6em;
width: 100%;
margin-bottom: 1em;
font-size: 1rem;
`
const ButtonForm = styled.button`
appearance: none;
background-color: #000;
color: #fff;
border: 0;
outline: 0;
font-size: 1rem;
padding: .31em .62em;
cursor: pointer;
`
const Button = styled.button`
appearance: none;
background-color: transparent;
color: #F44336;
border: none;
outline: none;
font-size: 1rem;
position: absolute;
top: .6em;
right: .6em;
cursor: pointer;
`
const ModalForm = ({ title, handleModal }) =>
<Container>
<Content>
<Button onClick={handleModal}>close</Button>
<Title>{title}</Title>
<TextArea />
<ButtonForm>Send</ButtonForm>
</Content>
</Container>
ModalForm.propTypes = {
title: PropTypes.string.isRequired,
handleModal: PropTypes.func.isRequired,
}
export default ModalForm
|
src/component/dashboard-container/index.js | arn1313/kritter-frontend | import React from 'react';
import { connect } from 'react-redux';
import { userFetchRequest } from '../../action/auth-actions';
import { postCreateRequest, postFetchAllRequest } from '../../action/post-actions';
import { Button } from 'react-bootstrap';
import PostForm from '../post-form';
import PostList from '../post-list-container';
import PopupDialog from '../PopupDialog'
import Aside from '../aside';
class DashboardContainer extends React.Component {
constructor(props) {
super(props);
this.state = {
};
}
componentDidMount() {
}
//THERES A BUG HERE WITH REDUX PERSIST THAT IS CAUSING THIS TO RERENDER THREE TIMES! THIS NEEDS TO BE ADDRESSED LATER.
render() {
console.log('__USER__', this.props.user, '__USER__');
return (
<div className="container">
{this.props.user.avatar == "" && this.props.user.persistedState ? <PopupDialog user={this.props.user} /> : undefined}
<Aside />
<section className="nine columns container">
<PostForm
buttonText={'submit'}
onComplete={this.props.postCreate}
user={this.props.user ? this.props.user : { lulwat: 'hahahah' }} />
<PostList />
</section>
</div>
);
}
}
let mapStateToProps = state => ({
auth: state.auth,
user: state.user,
});
let mapDispatchToProps = dispatch => ({
userFetch: () => dispatch(userFetchRequest()),
postCreate: (post) => dispatch(postCreateRequest(post)),
postFetchAll: () => dispatch(postFetchAllRequest()),
});
export default connect(mapStateToProps, mapDispatchToProps)(DashboardContainer);
|
src/components/SocketTerminal.js | williamcabrera4/chrome-app-websocket-tester | import React from 'react';
import PropTypes from 'prop-types';
import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
import SocketTerminalList from '../containers/SocketTerminalList';
import { ConnectionStatus } from '../constant/Constants';
import { SocketContainerAction } from '../actions/ActionsType';
import Row from './Row';
import Column from './Column';
class SocketTerminal extends React.Component {
componentDidUpdate() {
const terminalComponent = this.terminalList;
if (typeof terminalComponent !== 'undefined') {
const terminalNode = terminalComponent.querySelector('.full-height');
terminalNode.scrollTop = terminalNode.scrollHeight;
}
}
sendMessage() {
const messageInput = this.messageText.input;
this.props.webSocket.send(messageInput.value);
messageInput.value = '';
}
clearMessages() {
this.props.dispatch({
type: SocketContainerAction.DELETE_TERMINAL_MESSAGES,
});
}
messageTextFieldListener(event) {
if (event.keyCode === 13) {
this.sendMessage();
}
}
render() {
const disableChanges = this.props.status === ConnectionStatus.DISCONNECTED;
const clearDisable = this.props.terminalData.length < 1;
const connectionType = this.props.parameters.type;
return (
<div>
<Row className="relative-container">
<Column xs={8}>
<TextField
ref={(input) => { this.messageText = input; }}
disabled={disableChanges}
hint="Hello world"
fullWidth
floatingLabelText="Message"
onKeyUp={event => this.messageTextFieldListener(event)}
/>
</Column>
<Column xs={4} className="form-bottom-element">
<RaisedButton
disabled={disableChanges}
label="Send"
primary
onClick={() => this.sendMessage()}
/>
<RaisedButton
disabled={clearDisable}
label="Clear"
className="margin-left-5"
primary
onClick={() => this.clearMessages()}
/>
</Column>
</Row>
<SocketTerminalList
ref={(input) => { this.terminalList = input; }}
connectionType={connectionType}
terminalData={this.props.terminalData}
/>
</div>
);
}
}
SocketTerminal.propTypes = {
dispatch: PropTypes.func.isRequired,
terminalData: PropTypes.array.isRequired,
parameters: PropTypes.object.isRequired,
status: PropTypes.string.isRequired,
webSocket: PropTypes.object.isRequired,
};
export default SocketTerminal;
|
techCurriculum/ui/solutions/5.2/src/components/TextInput.js | AnxChow/EngineeringEssentials-group | /**
* Copyright 2017 Goldman Sachs.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
import React from 'react';
class TextInput extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
const value = event.target.value;
this.props.onChange(value);
}
render() {
return (
<div className='form-group'>
<label className='control-label'>{this.props.label}</label>
<input type='text' className='form-control' name={this.props.name} value={this.props.value} onChange={this.handleChange} />
</div>
)
}
}
export default TextInput;
|
node_modules/@material-ui/core/es/NativeSelect/NativeSelect.js | pcclarke/civ-techs | import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import React from 'react';
import PropTypes from 'prop-types';
import NativeSelectInput from './NativeSelectInput';
import withStyles from '../styles/withStyles';
import formControlState from '../FormControl/formControlState';
import withFormControlContext from '../FormControl/withFormControlContext';
import ArrowDropDownIcon from '../internal/svg-icons/ArrowDropDown';
import Input from '../Input';
export const styles = theme => ({
/* Styles applied to the `Input` component `root` class. */
root: {
position: 'relative',
width: '100%'
},
/* Styles applied to the `Input` component `select` class. */
select: {
'-moz-appearance': 'none',
// Reset
'-webkit-appearance': 'none',
// Reset
// When interacting quickly, the text can end up selected.
// Native select can't be selected either.
userSelect: 'none',
paddingRight: 32,
borderRadius: 0,
// Reset
width: 'calc(100% - 32px)',
minWidth: 16,
// So it doesn't collapse.
cursor: 'pointer',
'&:focus': {
// Show that it's not an text input
backgroundColor: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.05)',
borderRadius: 0 // Reset Chrome style
},
// Remove IE 11 arrow
'&::-ms-expand': {
display: 'none'
},
'&$disabled': {
cursor: 'default'
},
'&[multiple]': {
height: 'auto'
},
'&:not([multiple]) option, &:not([multiple]) optgroup': {
backgroundColor: theme.palette.background.paper
}
},
/* Styles applied to the `Input` component if `variant="filled"`. */
filled: {
width: 'calc(100% - 44px)'
},
/* Styles applied to the `Input` component if `variant="outlined"`. */
outlined: {
width: 'calc(100% - 46px)',
borderRadius: theme.shape.borderRadius
},
/* Styles applied to the `Input` component `selectMenu` class. */
selectMenu: {
width: 'auto',
// Fix Safari textOverflow
height: 'auto',
// Reset
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden'
},
/* Styles applied to the `Input` component `disabled` class. */
disabled: {},
/* Styles applied to the `Input` component `icon` class. */
icon: {
// We use a position absolute over a flexbox in order to forward the pointer events
// to the input.
position: 'absolute',
right: 0,
top: 'calc(50% - 12px)',
// Center vertically
color: theme.palette.action.active,
'pointer-events': 'none' // Don't block pointer events on the select under the icon.
}
});
const defaultInput = React.createElement(Input, null);
/**
* An alternative to `<Select native />` with a much smaller bundle size footprint.
*/
const NativeSelect = React.forwardRef(function NativeSelect(props, ref) {
const {
children,
classes,
IconComponent = ArrowDropDownIcon,
input = defaultInput,
inputProps,
muiFormControl
} = props,
other = _objectWithoutPropertiesLoose(props, ["children", "classes", "IconComponent", "input", "inputProps", "muiFormControl", "variant"]);
const fcs = formControlState({
props,
muiFormControl,
states: ['variant']
});
return React.cloneElement(input, _extends({
// Most of the logic is implemented in `NativeSelectInput`.
// The `Select` component is a simple API wrapper to expose something better to play with.
inputComponent: NativeSelectInput,
inputProps: _extends({
children,
classes,
IconComponent,
variant: fcs.variant,
type: undefined
}, inputProps, input ? input.props.inputProps : {}),
ref
}, other));
});
process.env.NODE_ENV !== "production" ? NativeSelect.propTypes = {
/**
* The option elements to populate the select with.
* Can be some `<option>` elements.
*/
children: PropTypes.node,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: PropTypes.object.isRequired,
/**
* The icon that displays the arrow.
*/
IconComponent: PropTypes.elementType,
/**
* An `Input` element; does not have to be a material-ui specific `Input`.
*/
input: PropTypes.element,
/**
* Attributes applied to the `select` element.
*/
inputProps: PropTypes.object,
/**
* @ignore
*/
muiFormControl: PropTypes.object,
/**
* Callback function fired when a menu item is selected.
*
* @param {object} event The event source of the callback.
* You can pull out the new value by accessing `event.target.value`.
*/
onChange: PropTypes.func,
/**
* The input value.
*/
value: PropTypes.any,
/**
* The variant to use.
*/
variant: PropTypes.oneOf(['standard', 'outlined', 'filled'])
} : void 0;
NativeSelect.muiName = 'Select';
export default withStyles(styles, {
name: 'MuiNativeSelect'
})(withFormControlContext(NativeSelect)); |
src/components/Header/Header.js | utkdigitalinitiatives/ibu |
import React, { Component } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Header.scss';
import Link from '../Link';
import Navigation from '../Navigation';
class Header extends Component {
render() {
return (
<div className={s.root}>
<div className={s.container}>
<Navigation className={s.nav} />
<Link className={s.brand} to="/">
<img src="./hops.png" width="38" height="38" alt="ibu" />
<span className={s.brandTxt}>UTK</span>
</Link>
<div className={s.banner}>
<h1 className={s.bannerTitle}>Ingestion Batch Utility</h1>
<p className={s.bannerDesc}>Sprint to Ingestion Batch Utility for automating, validating Objects and ingestion</p>
</div>
</div>
</div>
);
}
}
export default withStyles(Header, s);
|
pootle/static/js/admin/components/Language/LanguageAdd.js | pavels/pootle | /*
* Copyright (C) Pootle contributors.
*
* This file is a part of the Pootle project. It is distributed under the GPL3
* or later license. See the LICENSE file for a copy of the license and the
* AUTHORS file for copyright and authorship information.
*/
import React from 'react';
import LanguageForm from './LanguageForm';
const LanguageAdd = React.createClass({
propTypes: {
collection: React.PropTypes.object.isRequired,
model: React.PropTypes.func.isRequired,
onCancel: React.PropTypes.func.isRequired,
onSuccess: React.PropTypes.func.isRequired,
},
render() {
const Model = this.props.model;
return (
<div className="item-add">
<div className="hd">
<h2>{gettext('Add Language')}</h2>
<button
onClick={this.props.onCancel}
className="btn btn-primary"
>
{gettext('Cancel')}
</button>
</div>
<div className="bd">
<LanguageForm
model={new Model()}
collection={this.props.collection}
onSuccess={this.props.onSuccess}
/>
</div>
</div>
);
},
});
export default LanguageAdd;
|
fixtures/dom/src/components/fixtures/input-change-events/RadioClickFixture.js | AlmeroSteyn/react | import React from 'react';
import Fixture from '../../Fixture';
class RadioClickFixture extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
changeCount: 0,
};
}
handleChange = () => {
this.setState(({ changeCount }) => {
return {
changeCount: changeCount + 1
}
})
}
handleReset = () => {
this.setState({
changeCount: 0,
})
}
render() {
const { changeCount } = this.state;
const color = changeCount === 0 ? 'green' : 'red';
return (
<Fixture>
<label>
<input
defaultChecked
type='radio'
onChange={this.handleChange}
/>
Test case radio input
</label>
{' '}
<p style={{ color }}>
<code>onChange</code>{' calls: '}<strong>{changeCount}</strong>
</p>
<button onClick={this.handleReset}>Reset count</button>
</Fixture>
)
}
}
export default RadioClickFixture;
|
Hackathon-111/SecurityController/react_test/frontend/src/App.js | kimjinyong/i2nsf-framework | import React, { Component } from 'react';
import { BrowserRouter, Route,Switch } from 'react-router-dom';
import { Table1,Table2 } from './';
class App extends Component {
render() {
return (
<BrowserRouter>
<Switch>
<Route exact path="/" component={Table1}/>
<Route path="/time" component={Table2}/>
</Switch>
</BrowserRouter>
);
}
}
export default App;
|
app/jsx/files/UsageRightsSelectBox.js | venturehive/canvas-lms | /*
* Copyright (C) 2015 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import I18n from 'i18n!react_files'
import UsageRightsSelectBox from 'compiled/react_files/components/UsageRightsSelectBox'
var CONTENT_OPTIONS = [{
display: I18n.t('Choose usage rights...'),
value: 'choose'
}, {
display: I18n.t('I hold the copyright'),
value: 'own_copyright'
}, {
display: I18n.t('I have obtained permission to use this file.'),
value: 'used_by_permission'
}, {
display: I18n.t('The material is in the public domain'),
value: 'public_domain'
}, {
display: I18n.t('The material is subject to fair use exception'),
value: 'fair_use'
}, {
display: I18n.t('The material is licensed under Creative Commons'),
value: 'creative_commons'
}
];
UsageRightsSelectBox.renderContentOptions = function () {
return CONTENT_OPTIONS.map((contentOption) => {
return (<option key={contentOption.value} value={contentOption.value}>{contentOption.display}</option>);
});
};
UsageRightsSelectBox.renderCreativeCommonsOptions = function () {
var onlyCC = this.state.licenseOptions.filter((license) => {
return license.id.indexOf('cc') === 0;
});
return onlyCC.map((license) => {
return (<option key={license.id} value={license.id}>{license.name}</option>);
});
};
UsageRightsSelectBox.renderShowCreativeCommonsOptions = function () {
var renderShowCreativeCommonsOptions = (
<div className='control-group'>
<label
className='control-label'
htmlFor='creativeCommonsSelection'
>
{I18n.t('Creative Commons License:')}
</label>
<div className='control'>
<select
id='creativeCommonsSelection'
className='UsageRightsSelectBox__creativeCommons'
ref='creativeCommons'
defaultValue={this.props.cc_value}
>
{this.renderCreativeCommonsOptions()}
</select>
</div>
</div>
);
return this.state.showCreativeCommonsOptions ? renderShowCreativeCommonsOptions : null;
};
UsageRightsSelectBox.renderShowMessage = function () {
var renderShowMessage = (
<div
ref='showMessageAlert'
className='alert'
>
<span>
<i className='icon-warning' ></i>
<span style={{paddingLeft: '10px'}}>
{I18n.t("If you do not select usage rights now, this file will be unpublished after it's uploaded.")}
</span>
</span>
</div>
);
return this.state.showMessage ? renderShowMessage : null;
};
UsageRightsSelectBox.render = function () {
return (
<div
className='UsageRightsSelectBox__container'
>
<div className='control-group'>
<label
className='control-label'
htmlFor='usageRightSelector'
>
{I18n.t('Usage Right:')}
</label>
<div className='controls'>
<select
id='usageRightSelector'
className='UsageRightsSelectBox__select'
onChange={this.handleChange}
onKeyUp={this.handleChooseKeyPress}
ref='usageRightSelection'
value={this.state.usageRightSelectionValue}
>
{this.renderContentOptions()}
</select>
</div>
</div>
{this.renderShowCreativeCommonsOptions()}
<div className='control-group'>
<label
className='control-label'
htmlFor='copyrightHolder'
>
{I18n.t('Copyright Holder:')}
</label>
<div className='controls'>
<input
id='copyrightHolder'
type='text'
ref='copyright'
defaultValue={this.props.copyright && this.props.copyright}
placeholder={I18n.t('(c) 2001 Acme Inc.')}
>
</input>
</div>
</div>
{this.renderShowMessage()}
</div>
);
};
export default React.createClass(UsageRightsSelectBox)
|
src/EventRow.js | jquense/react-big-calendar | import PropTypes from 'prop-types'
import clsx from 'clsx'
import React from 'react'
import EventRowMixin from './EventRowMixin'
class EventRow extends React.Component {
render() {
let {
segments,
slotMetrics: { slots },
className,
} = this.props
let lastEnd = 1
return (
<div className={clsx(className, 'rbc-row')}>
{segments.reduce((row, { event, left, right, span }, li) => {
let key = '_lvl_' + li
let gap = left - lastEnd
let content = EventRowMixin.renderEvent(this.props, event)
if (gap) row.push(EventRowMixin.renderSpan(slots, gap, `${key}_gap`))
row.push(EventRowMixin.renderSpan(slots, span, key, content))
lastEnd = right + 1
return row
}, [])}
</div>
)
}
}
EventRow.propTypes = {
segments: PropTypes.array,
...EventRowMixin.propTypes,
}
EventRow.defaultProps = {
...EventRowMixin.defaultProps,
}
export default EventRow
|
examples/with-apollo/lib/withData.js | dizlexik/next.js | import 'isomorphic-fetch'
import React from 'react'
import { ApolloProvider, getDataFromTree } from 'react-apollo'
import { initClient } from './initClient'
export default (Component) => (
class extends React.Component {
static async getInitialProps (ctx) {
const headers = ctx.req ? ctx.req.headers : {}
const client = initClient(headers)
const props = {
url: { query: ctx.query, pathname: ctx.pathname },
...await (Component.getInitialProps ? Component.getInitialProps(ctx) : {})
}
if (!process.browser) {
const app = (
<ApolloProvider client={client}>
<Component {...props} />
</ApolloProvider>
)
await getDataFromTree(app)
}
return {
initialState: {
apollo: {
data: client.getInitialState().data
}
},
headers,
...props
}
}
constructor (props) {
super(props)
this.client = initClient(this.props.headers, this.props.initialState)
}
render () {
return (
<ApolloProvider client={this.client}>
<Component {...this.props} />
</ApolloProvider>
)
}
}
)
|
public/js/components/profile/activityfeed/activityComp1.react.js | IsuruDilhan/Coupley | // import React from 'react';
// import Card from 'material-ui/lib/card/card';
// import CardActions from 'material-ui/lib/card/card-actions';
// import CardHeader from 'material-ui/lib/card/card-header';
// import CardMedia from 'material-ui/lib/card/card-media';
// import CardTitle from 'material-ui/lib/card/card-title';
// import FlatButton from 'material-ui/lib/flat-button';
// import CardText from 'material-ui/lib/card/card-text';
// import IconMenu from 'material-ui/lib/menus/icon-menu';
// import MenuItem from 'material-ui/lib/menus/menu-item';
// import IconButton from 'material-ui/lib/icon-button';
// import MoreVertIcon from 'material-ui/lib/svg-icons/navigation/more-vert';
// const AvatarExampleSimple = () => (
// <div>
// <IconMenu
// iconButtonElement={<IconButton>
// <MoreVertIcon />
// </IconButton>}
// anchorOrigin={{horizontal: 'left', vertical: 'top'}}
// targetOrigin={{horizontal: 'left', vertical: 'top'}}
// >
// <MenuItem primaryText="Edit" />
// <MenuItem primaryText="Remove" />
// <MenuItem primaryText="Block" />
// </IconMenu>
// </div>
// );
// const style = {
// width: 800,
// margin: 40,
// };
// var CardWithAvatar = React.createClass({
// render: function () {
// return (
// <div style={style}>
// <Card>
// <CardHeader
// title="Diylon"
// subtitle="2016.01.20"
// avatar="http://all4desktop.com/data_images/original/4237684-images.jpg" />
// <div>
// <AvatarExampleSimple />
// </div>
// <CardText>
// :o ;)
// </CardText>
// <CardMedia>
// <img src="http://all4desktop.com/data_images/original/4237684-images.jpg" />
// </CardMedia>
// <CardActions>
// <FlatButton label="Like" />
// <FlatButton label="Comment" />
// <FlatButton label="Share" />
// </CardActions>
// </Card>
// </div>
// );
// }
// });
// export default CardWithAvatar;
|
src/demos/building-a-geospatial-app/5-interaction/src/controls.js | uber-common/vis-academy | import React, { Component } from 'react';
import { mapStylePicker, layerControl } from './style';
export const HEXAGON_CONTROLS = {
showHexagon: {
displayName: 'Show Hexagon',
type: 'boolean',
value: true
},
radius: {
displayName: 'Hexagon Radius',
type: 'range',
value: 100,
step: 50,
min: 50,
max: 1000
},
coverage: {
displayName: 'Hexagon Coverage',
type: 'range',
value: 1,
step: 0.1,
min: 0,
max: 1
},
upperPercentile: {
displayName: 'Hexagon Upper Percentile',
type: 'range',
value: 100,
step: 0.1,
min: 80,
max: 100
},
showScatterplot: {
displayName: 'Show Scatterplot',
type: 'boolean',
value: true
},
radiusScale: {
displayName: 'Scatterplot Radius',
type: 'range',
value: 5,
step: 5,
min: 1,
max: 200
}
};
export const SCATTERPLOT_CONTROLS = {
showScatterplot: {
displayName: 'Show Scatterplot',
type: 'boolean',
value: true
},
radiusScale: {
displayName: 'Scatterplot Radius',
type: 'range',
value: 30,
step: 10,
min: 10,
max: 200
}
};
const MAPBOX_DEFAULT_MAPSTYLES = [
{ label: 'Streets V10', value: 'mapbox://styles/mapbox/streets-v10' },
{ label: 'Outdoors V10', value: 'mapbox://styles/mapbox/outdoors-v10' },
{ label: 'Light V9', value: 'mapbox://styles/mapbox/light-v9' },
{ label: 'Dark V9', value: 'mapbox://styles/mapbox/dark-v9' },
{ label: 'Satellite V9', value: 'mapbox://styles/mapbox/satellite-v9' },
{
label: 'Satellite Streets V10',
value: 'mapbox://styles/mapbox/satellite-streets-v10'
},
{
label: 'Navigation Preview Day V4',
value: 'mapbox://styles/mapbox/navigation-preview-day-v4'
},
{
label: 'Navitation Preview Night V4',
value: 'mapbox://styles/mapbox/navigation-preview-night-v4'
},
{
label: 'Navigation Guidance Day V4',
value: 'mapbox://styles/mapbox/navigation-guidance-day-v4'
},
{
label: 'Navigation Guidance Night V4',
value: 'mapbox://styles/mapbox/navigation-guidance-night-v4'
}
];
export function MapStylePicker({ currentStyle, onStyleChange }) {
return (
<select
className="map-style-picker"
style={mapStylePicker}
value={currentStyle}
onChange={e => onStyleChange(e.target.value)}
>
{MAPBOX_DEFAULT_MAPSTYLES.map(style => (
<option key={style.value} value={style.value}>
{style.label}
</option>
))}
</select>
);
}
export class LayerControls extends Component {
_onValueChange(settingName, newValue) {
const { settings } = this.props;
// Only update if we have a confirmed change
if (settings[settingName] !== newValue) {
// Create a new object so that shallow-equal detects a change
const newSettings = {
...this.props.settings,
[settingName]: newValue
};
this.props.onChange(newSettings);
}
}
render() {
const { title, settings, propTypes = {} } = this.props;
return (
<div className="layer-controls" style={layerControl}>
{title && <h4>{title}</h4>}
{Object.keys(settings).map(key => (
<div key={key}>
<label>{propTypes[key].displayName}</label>
<div style={{ display: 'inline-block', float: 'right' }}>
{settings[key]}
</div>
<Setting
settingName={key}
value={settings[key]}
propType={propTypes[key]}
onChange={this._onValueChange.bind(this)}
/>
</div>
))}
</div>
);
}
}
const Setting = props => {
const { propType } = props;
if (propType && propType.type) {
switch (propType.type) {
case 'range':
return <Slider {...props} />;
case 'boolean':
return <Checkbox {...props} />;
default:
return <input {...props} />;
}
}
};
const Checkbox = ({ settingName, value, onChange }) => {
return (
<div key={settingName}>
<div className="input-group">
<input
type="checkbox"
id={settingName}
checked={value}
onChange={e => onChange(settingName, e.target.checked)}
/>
</div>
</div>
);
};
const Slider = ({ settingName, value, propType, onChange }) => {
const { max = 100 } = propType;
return (
<div key={settingName}>
<div className="input-group">
<div>
<input
type="range"
id={settingName}
min={0}
max={max}
step={max / 100}
value={value}
onChange={e => onChange(settingName, Number(e.target.value))}
/>
</div>
</div>
</div>
);
};
|
src/scripts/components/header.js | brandly/ss15-queso | /** @jsx REACT.DOM */
import React from 'react';
import {classSet} from 'react-addons';
import keymaster from 'keymaster';
export default React.createClass({
componentWillMount: function () {
this.state.queso.on('STATE_CHANGED', this._onChange);
keymaster('space', this.onSpace);
},
getInitialState: function () {
return {queso: this.props.queso};
},
_onChange: function () {
this.setState({queso: this.props.queso});
},
onSpace: function (event) {
event.preventDefault();
this.togglePlayback();
},
play: function () {
this.state.queso.setPlaying(true);
},
stop: function () {
this.state.queso.setPlaying(false);
},
togglePlayback: function () {
const {queso} = this.state;
queso.setPlaying(!queso.isPlaying);
},
record: function () {
const {queso} = this.state;
queso.setRecording(!queso.isRecording);
},
lastTap: null,
tapBpm: function () {
const tapTime = tsw.context().currentTime;
if (this.lastTap) {
const difference = tapTime - this.lastTap;
if (difference < 2) {
this.state.queso.setBpm(Math.round(60 / difference));
}
}
this.lastTap = tsw.context().currentTime;
},
toBeginning: function () {
this.state.queso.setCurrentTime(0);
},
render: function () {
const {queso} = this.state;
const playingClasses = classSet({
'button': true,
'active': queso.isPlaying
});
const recordingClasses = classSet({
'button': true,
'active': queso.isRecording
});
return (
<header className="header">
{
// TODO: probably use some icons
}
<button className={playingClasses} onClick={this.play}>Play</button>
<button className="button" onClick={this.stop} onDoubleClick={this.toBeginning}>Stop</button>
<button className={recordingClasses} onClick={this.record}>Record</button>
<div className="header-right">
<p className="bpm">{this.state.queso.bpm} BPM</p>
<p className="bpm tap-bpm button" onClick={this.tapBpm}>Tap</p>
</div>
</header>
);
}
});
|
codes/chapter05/react-router-v4/basic/demo01/app/index.js | atlantis1024/react-step-by-step | import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
ReactDOM.render(<App/>, document.getElementById("root"));
|
ui/js/pages/event/EventSectionEdit.js | ericsoderberg/pbc-web | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import moment from 'moment-timezone';
import FormField from '../../components/FormField';
import SelectSearch from '../../components/SelectSearch';
import FormState from '../../utils/FormState';
import SectionEdit from '../../components/SectionEdit';
import TextHelp from '../../components/TextHelp';
const Suggestion = props => (
<div className="box--between">
<span>{props.item.name}</span>
<span className="secondary">
{moment(props.item.start).format('MMM YYYY')}
</span>
</div>
);
Suggestion.propTypes = {
item: PropTypes.shape({
start: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
name: PropTypes.string,
}).isRequired,
};
export default class EventSectionEdit extends Component {
constructor(props) {
super(props);
const { section, onChange } = props;
this.state = { formState: new FormState(section, onChange) };
}
componentWillReceiveProps(nextProps) {
this.setState({
formState: new FormState(nextProps.section, nextProps.onChange),
});
}
render() {
const { formState } = this.state;
const section = formState.object;
return (
<SectionEdit formState={formState} allowBackgroundImage={false}>
<FormField label="Event">
<SelectSearch category="events"
options={{ select: 'name start', sort: '-start' }}
Suggestion={Suggestion}
value={(section.eventId || {}).name || ''}
onChange={suggestion =>
formState.change('eventId')({
_id: suggestion._id, name: suggestion.name })} />
</FormField>
<FormField name="summary" label="Summary" help={<TextHelp />}>
<textarea name="summary"
value={section.summary || ''}
rows={4}
onChange={formState.change('summary')} />
</FormField>
<FormField>
<input name="includeMap"
type="checkbox"
checked={section.includeMap || false}
onChange={formState.toggle('includeMap')} />
<label htmlFor="includeMap">Map?</label>
</FormField>
<FormField>
<input name="navigable"
type="checkbox"
checked={(section.navigable === false ? section.navigable : true)}
onChange={formState.toggle('navigable')} />
<label htmlFor="navigable">Navigable?</label>
</FormField>
</SectionEdit>
);
}
}
EventSectionEdit.propTypes = {
onChange: PropTypes.func.isRequired,
section: PropTypes.object.isRequired,
};
|
front/app/js/components/controls/TiltCover.js | nudoru/React-Starter-3 | import React from 'react';
import PropTypes from 'prop-types';
import { TweenMax, Back, Expo } from 'gsap';
import { css } from 'emotion';
import { MouseWatch } from './common/MouseWatch';
import { joinClasses } from '../../utils/componentUtils';
import {ThreeDEl, ThreeDWrapper} from './common/Atoms';
/*
This was ultimately inspired by Union's work on the Discovery Place site.
MB 10/19/17
I wanted to use my Animation component for this, but being able to change the props
of a tween mid-motion (when the mouse moves) isn't working properly yet. Using a
CSS tween is still ok!
TODO
Whole card surface is a link
Keep using the "shine" layer as a mask?
*/
const containerStyle = props => css`
overflow: hidden;
width: 100%;
height: 100%;
width:${props.width}px;
height:${props.height}px;
transition: transform 250ms ease-out, box-shadow 500ms ease-out;
`;
const shineContainerStyle = props => css`
position: absolute;
top: 0;
left: 0;
width:${props.width}px;
height:${props.height}px;
background: linear-gradient(0deg, rgba(255, 255, 255, 0) 0%,rgba(255, 255, 255, 0) 80%);
transition: background 250ms linear, transform 250ms linear;
`;
export class TiltCover extends React.PureComponent {
static defaultProps = {
width : 200,
height: 200,
extent: 20
};
static propTypes = {
width : PropTypes.number,
height: PropTypes.number,
extent: PropTypes.number
};
render () {
const {children, className} = this.props;
return (
<ThreeDWrapper>
<MouseWatch render={({x, y}) => {
let mMidX = x - (this.props.width / 2), // - left of center + right of center
mMidY = y - (this.props.height / 2), // - left of center + right of center
rotX = 0,
rotY = 0,
scale = '1, 1, 1',
shadow = '0 0 0 rgba(0,0,0,0)';
if (x > 0 && y > 0) {
rotX = -(0.5 - (y / this.props.width)) * this.props.extent;
rotY = (0.5 - (x / this.props.width)) * this.props.extent;
scale = '1.05, 1.05, 1.05';
shadow = '0 2px 4px rgba(0,0,0,0.05), 4px 8px 15px -7px rgba(0,0,0,0.1), 4px 8px 20px rgba(0,0,0,0.10)' // .paper-shadow-xl
}
let angle = Math.atan2(mMidY, mMidX) * 180 / Math.PI - 90;
if (angle < 0) {
angle = angle + 360;
}
let containerDynamicStyle = {
boxShadow: shadow,
transform: `rotateX(${rotX}deg) rotateY(${rotY}deg) scale3d(${scale})`
};
let shineDynamicStyle = {
background: `linear-gradient(${angle}deg, rgba(255, 255, 255, ${y / this.props.height * 0.4}) 0%,rgba(255, 255, 255, 0) 80%)`,
transform : `translateX(${(x / this.props.width)}px) translateY(${(y / this.props.height)}px)`
};
return (
<ThreeDEl
style={containerDynamicStyle}
className={joinClasses(containerStyle(this.props), className)}>
{children}
<div style={shineDynamicStyle} className={shineContainerStyle(this.props)}
ref={shine => this.shineRef = shine}/>
</ThreeDEl>
);
}}/>
</ThreeDWrapper>
);
}
} |
client/common/components/link.js | jaketrent/gratigoose | import { connect } from 'react-redux'
import React from 'react'
import styleable from 'react-styleable'
import css from './link.css'
import * as urlUtil from '../url'
const { bool, string } = React.PropTypes
class Link extends React.Component {
render() {
const { href, basePath, ...props } = this.props
return (
<a className={props.css.isActive ? props.css.rootActive : props.css.root}
href={urlUtil.formatUrl(href, basePath)}
ref="link">{this.props.children}</a>
)
}
}
Link.propTypes = {
basePath: string,
href: string.isRequired,
isActive: bool
}
Link.defaultProps = {
basePath: ''
}
const StyledLink = styleable(css)(Link)
function mapStateToProps(state) {
return {
routing: state.routing
}
}
class LinkContainer extends React.Component {
render() {
const isRouteMatch = urlUtil.routesMatch(this.props.routing.path, this.props.href, this.props.routing.basePath)
return (
<StyledLink {...this.props}
basePath={this.props.routing.basePath}
isActive={isRouteMatch}>
{this.props.children}
</StyledLink>
)
}
}
export default connect(mapStateToProps)(LinkContainer)
|
node_modules/react-router/es6/IndexRoute.js | rblin081/drafting-client | import React from 'react';
import warning from './routerWarning';
import invariant from 'invariant';
import { createRouteFromReactElement as _createRouteFromReactElement } from './RouteUtils';
import { component, components, falsy } from './InternalPropTypes';
var func = React.PropTypes.func;
/**
* An <IndexRoute> is used to specify its parent's <Route indexRoute> in
* a JSX route config.
*/
var IndexRoute = React.createClass({
displayName: 'IndexRoute',
statics: {
createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) {
/* istanbul ignore else: sanity check */
if (parentRoute) {
parentRoute.indexRoute = _createRouteFromReactElement(element);
} else {
process.env.NODE_ENV !== 'production' ? warning(false, 'An <IndexRoute> does not make sense at the root of your route config') : void 0;
}
}
},
propTypes: {
path: falsy,
component: component,
components: components,
getComponent: func,
getComponents: func
},
/* istanbul ignore next: sanity check */
render: function render() {
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, '<IndexRoute> elements are for router configuration only and should not be rendered') : invariant(false) : void 0;
}
});
export default IndexRoute; |
app/javascript/mastodon/components/column_header.js | pointlessone/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';
const messages = defineMessages({
show: { id: 'column_header.show_settings', defaultMessage: 'Show settings' },
hide: { id: 'column_header.hide_settings', defaultMessage: 'Hide settings' },
moveLeft: { id: 'column_header.moveLeft_settings', defaultMessage: 'Move column to the left' },
moveRight: { id: 'column_header.moveRight_settings', defaultMessage: 'Move column to the right' },
});
export default @injectIntl
class ColumnHeader extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
intl: PropTypes.object.isRequired,
title: PropTypes.node,
icon: PropTypes.string,
active: PropTypes.bool,
multiColumn: PropTypes.bool,
extraButton: PropTypes.node,
showBackButton: PropTypes.bool,
children: PropTypes.node,
pinned: PropTypes.bool,
onPin: PropTypes.func,
onMove: PropTypes.func,
onClick: PropTypes.func,
};
state = {
collapsed: true,
animating: false,
};
handleToggleClick = (e) => {
e.stopPropagation();
this.setState({ collapsed: !this.state.collapsed, animating: true });
}
handleTitleClick = () => {
this.props.onClick();
}
handleMoveLeft = () => {
this.props.onMove(-1);
}
handleMoveRight = () => {
this.props.onMove(1);
}
handleBackClick = () => {
if (window.history && window.history.length === 1) this.context.router.history.push('/');
else this.context.router.history.goBack();
}
handleTransitionEnd = () => {
this.setState({ animating: false });
}
render () {
const { title, icon, active, children, pinned, onPin, multiColumn, extraButton, showBackButton, intl: { formatMessage } } = this.props;
const { collapsed, animating } = this.state;
const wrapperClassName = classNames('column-header__wrapper', {
'active': active,
});
const buttonClassName = classNames('column-header', {
'active': active,
});
const collapsibleClassName = classNames('column-header__collapsible', {
'collapsed': collapsed,
'animating': animating,
});
const collapsibleButtonClassName = classNames('column-header__button', {
'active': !collapsed,
});
let extraContent, pinButton, moveButtons, backButton, collapseButton;
if (children) {
extraContent = (
<div key='extra-content' className='column-header__collapsible__extra'>
{children}
</div>
);
}
if (multiColumn && pinned) {
pinButton = <button key='pin-button' className='text-btn column-header__setting-btn' onClick={onPin}><i className='fa fa fa-times' /> <FormattedMessage id='column_header.unpin' defaultMessage='Unpin' /></button>;
moveButtons = (
<div key='move-buttons' className='column-header__setting-arrows'>
<button title={formatMessage(messages.moveLeft)} aria-label={formatMessage(messages.moveLeft)} className='text-btn column-header__setting-btn' onClick={this.handleMoveLeft}><i className='fa fa-chevron-left' /></button>
<button title={formatMessage(messages.moveRight)} aria-label={formatMessage(messages.moveRight)} className='text-btn column-header__setting-btn' onClick={this.handleMoveRight}><i className='fa fa-chevron-right' /></button>
</div>
);
} else if (multiColumn) {
pinButton = <button key='pin-button' className='text-btn column-header__setting-btn' onClick={onPin}><i className='fa fa fa-plus' /> <FormattedMessage id='column_header.pin' defaultMessage='Pin' /></button>;
}
if (!pinned && (multiColumn || showBackButton)) {
backButton = (
<button onClick={this.handleBackClick} className='column-header__back-button'>
<i className='fa fa-fw fa-chevron-left column-back-button__icon' />
<FormattedMessage id='column_back_button.label' defaultMessage='Back' />
</button>
);
}
const collapsedContent = [
extraContent,
];
if (multiColumn) {
collapsedContent.push(moveButtons);
collapsedContent.push(pinButton);
}
if (children || multiColumn) {
collapseButton = <button className={collapsibleButtonClassName} title={formatMessage(collapsed ? messages.show : messages.hide)} aria-label={formatMessage(collapsed ? messages.show : messages.hide)} aria-pressed={collapsed ? 'false' : 'true'} onClick={this.handleToggleClick}><i className='fa fa-sliders' /></button>;
}
const hasTitle = icon && title;
return (
<div className={wrapperClassName}>
<h1 className={buttonClassName}>
{hasTitle && (
<button onClick={this.handleTitleClick}>
<i className={`fa fa-fw fa-${icon} column-header__icon`} />
{title}
</button>
)}
{!hasTitle && backButton}
<div className='column-header__buttons'>
{hasTitle && backButton}
{extraButton}
{collapseButton}
</div>
</h1>
<div className={collapsibleClassName} tabIndex={collapsed ? -1 : null} onTransitionEnd={this.handleTransitionEnd}>
<div className='column-header__collapsible-inner'>
{(!collapsed || animating) && collapsedContent}
</div>
</div>
</div>
);
}
}
|
src/components/UserList.js | cuebrick/TypeWriter | import React from 'react';
class UserList extends React.Component{
handleItemClick(userId){
this.props.selectUser(userId);
}
handleDeleteUser(userId){
this.props.deleteUser(userId);
}
render(){
let userList = Object.keys(this.props.users).map((key) => {
return this.props.users[key];
});
return(
<ul className="user-list">
{
userList.map((data) => {
let isCurrentUser = (this.props.currentUserId === data.id);
if(isCurrentUser){
return(
<li key={data.id} className="current-user">
<img src={"./images/checked.svg"} className="checked" width="15" />
<div className="user-inner">
<div className="user-image">
<img src={"./images/icon/profile-icon-"+ data.icon +".svg"}/>
</div>
<div className="user-grade">{data.grade}</div>
<div className="user-name">{data.name}</div>
</div>
</li>
)
} else {
return(
<li key={data.id}>
<img src={"./images/delete.svg"} className="delete" width="15" onClick={() => this.handleDeleteUser(data.id)} />
<div className="user-inner" onClick={() => this.handleItemClick(data.id)}>
<div className="user-image">
<img src={"./images/icon/profile-icon-"+ data.icon +".svg"}/>
</div>
<div className="user-grade">{data.grade}</div>
<div className="user-name">{data.name}</div>
</div>
</li>
)
}
})
}
</ul>
)
}
}
export default UserList; |
staticfiles/js/components/SocialMediaLink/SocialMediaLink.js | alemneh/negativity-purger | import React from 'react';
import styles from './SocialMediaLink.css';
const SocialMediaLink = ({ name, url }) => {
return (
<li className={styles.twitterBtn}>
<a href={url}>{name}</a>
</li>
)
};
export default SocialMediaLink;
|
src/common/Notification/NotificationCloseButton.js | Syncano/syncano-dashboard | import React from 'react';
const NotificationCloseButton = ({ isVisible, onClick }) => {
const styles = {
root: {
position: 'absolute',
top: 4,
right: 8,
cursor: 'pointer',
fontWeight: 700
}
};
if (isVisible) {
return (
<div
style={styles.root}
onClick={onClick}
>
x
</div>
);
}
return null;
};
export default NotificationCloseButton;
|
src/product/AmountSelectionContainer.js | eldavojohn/myRetail-practice-app | import React from 'react'
import { connect } from 'react-redux'
import { incrementAmount, decrementAmount } from '../actions/ProductActions'
import AmountSelection from './AmountSelection'
let AmountSelectionContainer = ({ amountSelected, dispatch }) => {
return (
<AmountSelection amount={amountSelected} incFunc={incrementByOne} decFunc={decrementByOne} />
)
function incrementByOne() {
dispatch(incrementAmount(amountSelected))
}
function decrementByOne() {
dispatch(decrementAmount(amountSelected))
}
}
export default connect()(AmountSelectionContainer)
|
ui/src/pages/DataSourcePage/ExportManager/ExportForm/ExportOutputPreview.js | LearningLocker/learninglocker | /* eslint-disable react/jsx-indent */
import { isString } from 'lodash';
import React from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';
import { Map } from 'immutable';
import { withProps, compose, setPropTypes, shouldUpdate, defaultProps } from 'recompose';
import { MultiGrid, AutoSizer } from 'react-virtualized';
import { withModels } from 'ui/utils/hocs';
const Cell = styled.div`
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: baseline;
text-align: left;
padding: 0 1em 0 0;
white-space: nowrap;
`;
const CellWrapper = styled.div`
overflow: hidden;
width: 100%;
`;
const HeaderCell = styled(Cell)`
border-bottom: 2px solid #ddd;
font-weight: bold;
`;
const enhance = compose(
setPropTypes({
filter: PropTypes.instanceOf(Map).isRequired,
project: PropTypes.instanceOf(Map).isRequired,
}),
defaultProps({
filter: new Map(),
project: new Map()
}),
withProps(() => ({
schema: 'statement',
first: 1,
sort: new Map({ timestamp: -1, _id: 1 }),
})),
withModels,
withProps(({ models, project }) => {
const results = models.map(model =>
project.map((value, key) => (
isString(value) ?
model.getIn(value.replace('$', '').split('.')) :
model.getIn(key.split('.'))
))
).toList();
const headings = project.keySeq();
return { results, headings };
}),
shouldUpdate((props, nextProps) => !(
props.results.equals(nextProps.results) &&
props.headings.equals(nextProps.headings)
)),
// Generates a date to pass to the MultiGrid in order to force a re-render when props change.
// This needs to be a function not an object so that the date gets re-generated each time.
withProps(() =>
({
updated: (new Date()),
})
),
);
const renderHeading = headings =>
({ columnIndex, style, key }) => {
const heading = headings.get(columnIndex);
return (
<HeaderCell style={style} key={key}>
{heading}
</HeaderCell>
);
};
const renderResultContent = (results, headings) =>
({ columnIndex, rowIndex, style, key }) => {
const heading = headings.get(columnIndex);
const result = results.get(rowIndex);
const value = result.get(heading);
const display = value && value.toJS ? JSON.stringify(value.toJS()) : value;
return (
<Cell key={key} style={style}>
<CellWrapper title={display}>
{display}
</CellWrapper>
</Cell>
);
};
const renderCell = (results, headings) => {
const renderHeadingCell = renderHeading(headings);
const renderResultContentCell = renderResultContent(results, headings);
return ({ columnIndex, rowIndex, key, style }) =>
(
rowIndex === 0
? renderHeadingCell({ columnIndex, style, key })
: renderResultContentCell({ columnIndex, rowIndex: rowIndex - 1, style, key })
);
};
const render = ({ results, headings, updated }) =>
(
<AutoSizer>
{({ width, height }) =>
(
<MultiGrid
updated={updated}
cellRenderer={renderCell(results, headings)}
columnWidth={200}
columnCount={headings.size}
fixedRowCount={1}
rowHeight={40}
rowCount={results.size + 1}
width={width}
height={height} />
)
}
</AutoSizer>
);
export default enhance(render);
|
src/containers/TimetableDay.js | Dennitz/Timetable | // @flow
import React from 'react';
import { connect } from 'react-redux';
import CourseAppointment from '../components/CourseAppointment';
import DayBorder from '../components/DayBorder';
/* eslint-disable react/no-unused-prop-types, because of false positive */
type Props = {
courses: CoursesState,
day: string,
appointmentsOfDay: Array<Appointment>,
};
/* eslint-enable react/no-unused-prop-types */
function renderCoursesOfDay(props: Props) {
const { courses, appointmentsOfDay } = props;
return appointmentsOfDay.map(appointment => {
const course = courses[appointment.course];
if (!course) {
throw new Error(
`The course of appointment ${appointment.id} does not exist`,
);
}
return (
<CourseAppointment
name={course.name}
starttime={appointment.starttime}
endtime={appointment.endtime}
location={appointment.location}
type={appointment.type}
key={appointment.id}
/>
);
});
}
// exported for tests
export function TimetableDay(props: Props) {
const { appointmentsOfDay, day } = props;
if (appointmentsOfDay.length !== 0) {
return <DayBorder date={day}>{renderCoursesOfDay(props)}</DayBorder>;
}
return null;
}
function mapStateToProps(state) {
return {
courses: state.courses,
};
}
export default connect(mapStateToProps)(TimetableDay);
|
examples/hot-reloading/src/main.js | adisuryadi/nuclear-js | import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'nuclear-js-react-addons'
import App from './containers/App'
import reactor from './reactor'
render(
<Provider reactor={reactor}>
<App />
</Provider>,
document.getElementById('root')
)
|
src/containers/Signin.js | Seeingu/medium-demo | import React, { Component } from 'react';
import styled from 'styled-components';
import { Link, Redirect } from 'react-router-dom';
import { PrimaryButton } from '../styles';
import { InputValidation, Header } from '../components';
import { notifyFailed } from 'see-common-components';
import { connect } from 'react-redux';
import {
getUser,
getIsVerifying,
getMessageOfUserValidation
} from '../reducers';
import { signIn } from '../actions';
import { rootPath } from '../utils';
export const Container = styled.div`
display: flex;
flex: 1;
max-width: 100vw;
box-sizing: border-box;
flex-direction: column;
justify-content: center;
height: 100vh;
align-items: center;
padding: 10px 10px;
`;
export const MyLink = styled(Link)`color: #5cb85c;`;
class SignIn extends Component {
constructor(props) {
super(props);
this.state = {
email: '',
password: ''
};
}
handleSubmit = e => {
const { signIn } = this.props;
e.preventDefault();
signIn(this.state.email, this.state.password);
};
componentWillUpdate(nextProps) {
const nextMessage = nextProps.message;
// 错误
if (nextMessage) {
notifyFailed('username or password wrong');
}
}
handleEmailChange = e => {
this.setState({ email: e.target.value });
};
handlePasswordChange = e => {
this.setState({ password: e.target.value });
};
render() {
const { user, isFetching } = this.props;
if (user) {
return <Redirect to={`${rootPath}/`} replace />;
}
return (
<Container>
<Header />
<h2>Sign in</h2>
<MyLink to={`${rootPath}/signup`}>Need an account?</MyLink>
<span />
<form onSubmit={this.handleSubmit}>
<InputValidation
validateType="email"
onChange={this.handleEmailChange}
value={this.state.email}
required
placeholder="Email"
/>
<InputValidation
type="password"
validateType="password"
value={this.state.password}
onChange={this.handlePasswordChange}
required
placeholder="Password"
/>
<PrimaryButton type="submit" disabled={isFetching}>
Sign in
</PrimaryButton>
</form>
</Container>
);
}
}
const mapStateToProps = state => ({
user: getUser(state),
isFetching: getIsVerifying(state),
message: getMessageOfUserValidation(state)
});
export default connect(mapStateToProps, { signIn })(SignIn);
|
src/js/components/icons/base/Eject.js | linde12/grommet | // (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import CSSClassnames from '../../../utils/CSSClassnames';
import Intl from '../../../utils/Intl';
import Props from '../../../utils/Props';
const CLASS_ROOT = CSSClassnames.CONTROL_ICON;
const COLOR_INDEX = CSSClassnames.COLOR_INDEX;
export default class Icon extends Component {
render () {
const { className, colorIndex } = this.props;
let { a11yTitle, size, responsive } = this.props;
let { intl } = this.context;
const classes = classnames(
CLASS_ROOT,
`${CLASS_ROOT}-eject`,
className,
{
[`${CLASS_ROOT}--${size}`]: size,
[`${CLASS_ROOT}--responsive`]: responsive,
[`${COLOR_INDEX}-${colorIndex}`]: colorIndex
}
);
a11yTitle = a11yTitle || Intl.getMessage(intl, 'eject');
const restProps = Props.omit(this.props, Object.keys(Icon.propTypes));
return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fill="none" stroke="#000" strokeWidth="2" d="M21,14 L12,2 L3,14 L21,14 Z M2,22 L22,22 L22,18 L2,18 L2,22 Z"/></svg>;
}
};
Icon.contextTypes = {
intl: PropTypes.object
};
Icon.defaultProps = {
responsive: true
};
Icon.displayName = 'Eject';
Icon.icon = true;
Icon.propTypes = {
a11yTitle: PropTypes.string,
colorIndex: PropTypes.string,
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']),
responsive: PropTypes.bool
};
|
src/components/AccountInfo.js | jperez10/RobinHoodAutoTrader | import React from 'react';
const AccountInfo = (props) => {
return(
<div className="accountInfo">
<div> Account Number: {props.state.accountNumber} </div>
</div>
);
}
export default AccountInfo;
|
src/client/components/component.react.js | sljuka/portfolio-este | import React from 'react';
import shallowEqual from 'react-pure-render/shallowEqual';
/**
* Purified React.Component. Goodness.
* http://facebook.github.io/react/docs/advanced-performance.html
*/
export default class Component extends React.Component {
static contextTypes = {
router: React.PropTypes.func
}
shouldComponentUpdate(nextProps, nextState) {
// This hack will be removed with react-router 1.0.0.
if (this.context.router) {
const changed = this.pureComponentLastPath !== this.context.router.getCurrentPath();
this.pureComponentLastPath = this.context.router.getCurrentPath();
if (changed) return true;
}
const shouldUpdate =
!shallowEqual(this.props, nextProps) ||
!shallowEqual(this.state, nextState);
// TODO: Dev tools.
// if (shouldUpdate)
// const name = this.constructor.displayName || this.constructor.name
// console.log(`${name} shouldUpdate`)
return shouldUpdate;
}
}
|
client/index.js | DonPage/TelePlay | // Import NPM dependencies like this:
import React from 'react';
import ReactDOM from 'react-dom';
// Import styles like this:
import './styles/main.scss';
// Import dependencies like this:
import Goat from './components/goat-component';
import Player from './components/player-component';
class App extends React.Component {
render() {
return (
<div><Player /></div>
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));
ReactDOM.render(<App />, document.getElementById('player'));
|
packages/react-server-examples/bike-share/components/footer.js | szhou8813/react-server | import React from 'react';
import {logging} from 'react-server';
const logger = logging.getLogger(__LOGGER__);
export default () => {
logger.info('rendering the footer');
return (<div className="footer">
<span>Brought to you by </span>
<a href="http://github.com/redfin/react-server">React Server</a>
<span> and </span>
<a href="http://api.citybik.es/v2/">citybik.es</a>
</div>);
};
|
src/components/menu/Navigation.js | mBeierl/Better-Twitch-Chat | import React from 'react';
import AppBar from 'material-ui/AppBar';
import IconButton from 'material-ui/IconButton';
import SVGNavMenu from 'material-ui/svg-icons/navigation/menu';
import FlatButton from 'material-ui/FlatButton';
import FontIcon from 'material-ui/FontIcon';
import Avatar from 'material-ui/Avatar';
import ListItem from 'material-ui/List/ListItem';
const Navigation = props => {
const RightArea = !props.userData
? <FlatButton
label="Login"
secondary={true}
icon={<FontIcon className="fa fa-twitch" />}
/>
: <ListItem
disabled={false}
leftAvatar={
<Avatar src={props.userData.image} />
}
>
{props.userData.name}
</ListItem>;
return (
<AppBar
title={props.title}
onLeftIconButtonTouchTap={props.onLeftIconClicked}
onRightIconButtonTouchTap={props.onRightIconClicked}
iconElementLeft={<IconButton><SVGNavMenu /></IconButton>}
iconElementRight={RightArea}
/>
);
};
export default Navigation;
|
src/components/IngestionWizard/WizardDataSchema.js | giux78/daf-dataportal | import React from 'react';
import {render} from 'react-dom';
import {getJsonCatalog} from './inputform_reader.js'
import {processInputFile, getFlatSchema} from './avroschema.js'
import DataInputForm from './data_form.js'
import $ from 'jquery';
import FormSectionDataSchema from './WizardFormCommon.js'
const data_dcatap = DataInputForm.getDcatap()
const data_dataschema = DataInputForm.getDataschema()
const data_dataschema_field = DataInputForm.getDataschemaField()
const data_dataschema_field_metadata = DataInputForm.getDataschemaFieldMetadata()
const data_operational = DataInputForm.getOperational()
class WizardDataSchema extends React.Component {
render () {
return <FormSectionDataSchema struct={this.props.dataschema} data="" />
}
}
export default WizardDataSchema
|
app/javascript/mastodon/features/reblogs/index.js | abcang/mastodon | import React from 'react';
import { connect } from 'react-redux';
import ImmutablePureComponent from 'react-immutable-pure-component';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import LoadingIndicator from '../../components/loading_indicator';
import { fetchReblogs } from '../../actions/interactions';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import AccountContainer from '../../containers/account_container';
import Column from '../ui/components/column';
import ScrollableList from '../../components/scrollable_list';
import Icon from 'mastodon/components/icon';
import ColumnHeader from '../../components/column_header';
const messages = defineMessages({
refresh: { id: 'refresh', defaultMessage: 'Refresh' },
});
const mapStateToProps = (state, props) => ({
accountIds: state.getIn(['user_lists', 'reblogged_by', props.params.statusId]),
});
export default @connect(mapStateToProps)
@injectIntl
class Reblogs extends ImmutablePureComponent {
static propTypes = {
params: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
accountIds: ImmutablePropTypes.list,
multiColumn: PropTypes.bool,
intl: PropTypes.object.isRequired,
};
componentWillMount () {
if (!this.props.accountIds) {
this.props.dispatch(fetchReblogs(this.props.params.statusId));
}
}
componentWillReceiveProps(nextProps) {
if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
this.props.dispatch(fetchReblogs(nextProps.params.statusId));
}
}
handleRefresh = () => {
this.props.dispatch(fetchReblogs(this.props.params.statusId));
}
render () {
const { intl, accountIds, multiColumn } = this.props;
if (!accountIds) {
return (
<Column>
<LoadingIndicator />
</Column>
);
}
const emptyMessage = <FormattedMessage id='status.reblogs.empty' defaultMessage='No one has boosted this toot yet. When someone does, they will show up here.' />;
return (
<Column bindToDocument={!multiColumn}>
<ColumnHeader
showBackButton
multiColumn={multiColumn}
extraButton={(
<button className='column-header__button' title={intl.formatMessage(messages.refresh)} aria-label={intl.formatMessage(messages.refresh)} onClick={this.handleRefresh}><Icon id='refresh' /></button>
)}
/>
<ScrollableList
scrollKey='reblogs'
emptyMessage={emptyMessage}
bindToDocument={!multiColumn}
>
{accountIds.map(id =>
<AccountContainer key={id} id={id} withNote={false} />,
)}
</ScrollableList>
</Column>
);
}
}
|
browser/react/BugReportForm.js | Bombanauts/Bombanauts | import React, { Component } from 'react';
import { connect } from 'redux';
import TextField from 'material-ui/TextField'
export default class BugReportForm extends Component {
constructor(props) {
super(props)
this.state = {
show: false,
title: '',
name: '',
email: '',
description: ''
}
this.updateTitle = this.updateTitle.bind(this);
this.updateName = this.updateName.bind(this);
this.updateEmail = this.updateEmail.bind(this);
this.updateDescription = this.updateDescription.bind(this);
this.submitForm = this.submitForm.bind(this);
this.clearForm = this.clearForm.bind(this);
this.handleButtonClick = this.handleButtonClick.bind(this);
}
updateTitle(evt) {
this.setState({ title: evt.target.value });
}
updateName(evt) {
this.setState({ name: evt.target.value });
}
updateEmail(evt) {
this.setState({ email: evt.target.value });
}
updateDescription(evt) {
this.setState({ description: evt.target.value });
}
submitForm() { // ADD TO GITHUB ISSUES
this.clearForm()
}
clearForm() {
this.setState({
title: '',
name: '',
email: '',
description: ''
})
}
handleButtonClick() {
this.setState({ show: true })
}
render() {
return (
<div>
<form onSubmit={this.submitForm}>
<TextField name="name" label="Name" hintText="Name" floatingLabelText="Name" onChange={this.updateName} />
<TextField name="email" label="Email" hintText="Email" floatingLabelText="Email" onChange={this.updateEmail} />
<TextField name="description" label="Description" multiLine={true} rows={10} hintText="Description" floatingLabelText="Description" onChange={this.updateDescription} />
<div>
<button type="submit" onClick={this.submitForm}>Submit</button>
<button type="button" onClick={this.clearForm}>Clear Values</button>
</div>
</form>
</div>
)
}
}
|
example/index.js | travi/hapi-react-router | // #### Dependencies:
import React from 'react';
import {IndexRoute, Route} from 'react-router';
import {createStore} from 'redux';
import {Provider} from 'react-redux';
// #### Register with the Hapi server
// remark-usage-ignore-next 5
function Wrap() {
return null;
}
function Index() {
return null;
}
function Foo() {
return null;
}
function Bar() {
return null;
}
function NotFound() {
return null;
}
export default {
server: {port: process.env.PORT},
register: {
plugins: [
{plugin: '@travi/hapi-html-request-router'},
{
plugin: '@travi/hapi-react-router',
options: {
respond: (reply, {renderedContent}) => {
reply.view('layout', {renderedContent});
},
routes: (
<Route path="/" component={Wrap}>
<IndexRoute component={Index} />
<Route path="/foo" component={Foo} />
<Route path="/bar" component={Bar} />
<Route path="*" component={NotFound} />
</Route>
),
Root: ({store, children}) => (
<Provider store={store}>
{children}
</Provider>
),
configureStore: ({session}) => createStore(reducer, composeMiddlewares(session)),
// ##### Optional custom renderer that passes blankie (optional to provide yourself) nonces as a prop
render: (defaultRender, request) => ({html: defaultRender({nonces: request.plugins.blankie.nonces})})
}
}
]
}
};
|
src/components/CardButton.js | nunoblue/ts-react | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Tooltip } from 'antd';
class CardButton extends Component {
static propTypes = {
content: PropTypes.string,
iconClassName: PropTypes.string,
}
static defaultProps = {
content: '',
iconClassName: '',
}
render() {
return (
<Tooltip title={this.props.content}>
<div id="add" className="footer-buttons">
<button className="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored">
<i className="material-icons">{this.props.iconClassName}</i>
</button>
</div>
</Tooltip>
);
}
}
export default CardButton;
|
installer/frontend/trail.js | joshix/tectonic-installer | import _ from 'lodash';
import React from 'react';
import { Map as ImmutableMap, Set as ImmutableSet } from 'immutable';
import { commitPhases } from './actions';
import { PLATFORM_TYPE, DRY_RUN } from './cluster-config';
import { CertificateAuthority } from './components/certificate-authority';
import { ClusterInfo } from './components/cluster-info';
import { ClusterType } from './components/cluster-type';
import { DryRun } from './components/dry-run';
import { Etcd } from './components/etcd';
import { SubmitDefinition } from './components/submit-definition';
import { Success } from './components/success';
import { TF_PowerOn } from './components/tf-poweron';
import { Users } from './components/users';
import { BM_Controllers, BM_Workers } from './components/bm-nodeforms';
import { BM_Credentials } from './components/bm-credentials';
import { BM_Hostname } from './components/bm-hostname';
import { BM_Matchbox } from './components/bm-matchbox';
import { KubernetesCIDRs } from './components/k8s-cidrs';
import { BM_SSHKeys } from './components/bm-sshkeys';
import { AWS_CloudCredentials } from './components/aws-cloud-credentials';
import { AWS_ClusterInfo } from './components/aws-cluster-info';
import { AWS_DefineNodes } from './components/aws-define-nodes';
import { AWS_SubmitKeys } from './components/aws-submit-keys';
import { AWS_VPC } from './components/aws-vpc';
import {
AWS_TF,
BARE_METAL_TF,
isSupported,
} from './platforms';
// Common pages
const certificateAuthorityPage = {
path: '/define/certificate-authority',
component: CertificateAuthority,
title: 'Certificate Authority',
};
const clusterTypePage = {
path: '/define/cluster-type',
component: ClusterType,
title: 'Platform',
hideSave: true,
showRestore: true,
};
const dryRunPage = {
path: '/define/advanced',
component: DryRun,
title: 'Download Assets',
canReset: true,
};
const etcdPage = {
path: '/define/etcd',
component: Etcd,
title: 'etcd Connection',
};
const submitDefinitionPage = {
path: '/define/submit',
component: SubmitDefinition,
title: 'Submit',
hidePager: true,
};
const successPage = {
path: '/boot/complete',
component: Success,
title: 'Installation Complete',
hidePager: true,
hideSave: true,
};
const TFPowerOnPage = {
path: '/boot/tf/poweron',
component: TF_PowerOn,
title: 'Start Installation',
canReset: true,
};
const usersPage = {
path: '/define/users',
component: Users,
title: 'Console Login',
};
// Baremetal pages
const bmClusterInfoPage = {
path: '/define/cluster-info',
component: ClusterInfo,
title: 'Cluster Info',
};
const bmControllersPage = {
path: '/define/controllers',
component: BM_Controllers,
title: 'Define Masters',
};
const bmCredentialsPage = {
path: '/define/credentials',
component: BM_Credentials,
title: 'Matchbox Credentials',
};
const bmHostnamePage = {
path: '/define/hostname',
component: BM_Hostname,
title: 'Cluster DNS',
};
const bmMatchboxPage = {
path: '/define/matchbox',
component: BM_Matchbox,
title: 'Matchbox Address',
};
const bmNetworkConfigPage = {
path: '/define/network-config',
component: KubernetesCIDRs,
title: 'Network Configuration',
};
const bmSshKeysPage = {
path: '/define/ssh-keys',
component: BM_SSHKeys,
title: 'SSH Key',
};
const bmWorkersPage = {
path: '/define/workers',
component: BM_Workers,
title: 'Define Workers',
};
// AWS pages
const awsClusterInfoPage = {
path: '/define/aws/cluster-info',
component: AWS_ClusterInfo,
title: 'Cluster Info',
};
const awsCloudCredentialsPage = {
path: '/define/aws/cloud-credentials',
component: AWS_CloudCredentials,
title: 'AWS Credentials',
};
const awsDefineNodesPage = {
path: '/define/aws/nodes',
component: AWS_DefineNodes,
title: 'Define Nodes',
};
const awsSubmitKeysPage = {
path: '/define/aws/keys',
component: AWS_SubmitKeys,
title: 'SSH Key',
};
const awsVPCPage = {
path: '/define/aws/vpc',
component: AWS_VPC,
title: 'Networking',
};
// This component is never visible!
const loadingPage = {
path: '/',
component: React.createElement('div'),
title: 'Tectonic',
};
export const sections = new Map([
['loading', [
loadingPage,
]],
['choose', [
clusterTypePage,
]],
['defineBaremetal', [
bmClusterInfoPage,
bmHostnamePage,
certificateAuthorityPage,
bmMatchboxPage,
bmCredentialsPage,
bmControllersPage,
bmWorkersPage,
bmNetworkConfigPage,
etcdPage,
bmSshKeysPage,
usersPage,
submitDefinitionPage,
]],
['defineAWS', [
awsCloudCredentialsPage,
awsClusterInfoPage,
certificateAuthorityPage,
awsSubmitKeysPage,
awsDefineNodesPage,
awsVPCPage,
usersPage,
submitDefinitionPage,
]],
['bootBaremetalTF', [
TFPowerOnPage,
successPage,
]],
['bootAWSTF', [
TFPowerOnPage,
successPage,
]],
['bootDryRun', [
dryRunPage,
]],
]);
// Lets us do 'sections.defineAWS' instead of using sections.get('defineAWS')
sections.forEach((v, k) => {
sections[k] = v;
});
// A Trail is an immutable representation of the navigation options available to a user.
// Navigation involves
// - moving from one page to the next page
// - moving from one page to some previous pages
// - presenting a (possibly disabled) list of all pages
export class Trail {
constructor(trailSections, whitelist) {
this.sections = trailSections;
const sectionPages = this.sections.reduce((ls, l) => ls.concat(l), []);
sectionPages.forEach(p => {
if (!p.component) {
throw new Error(`${p.title} has no component`);
}
});
this._pages = !whitelist ? sectionPages : sectionPages.filter(p => whitelist.includes(p));
this.ixByPage = this._pages.reduce((m, v, ix) => m.set(v, ix), ImmutableMap());
this.pageByPath = this._pages.reduce((m, v) => m.set(v.path, v), ImmutableMap());
}
sectionFor(page) {
return _.find(this.sections, s => s.includes(page));
}
navigable(page) {
return this.ixByPage.has(page);
}
// Given a path, return a "better" path for this trail. Will not navigate to that path.
fixPath(path, state) {
const page = this.pageByPath.get(path);
if (!page) {
return this._pages[0].path;
}
// If the NEXT button on a previous page is disabled, you
// shouldn't be able to see this page. Show the first page, before
// or including this one, that won't allow forward navigation.
const pred = this._pages.find(p => {
return p === page || !(p.component.canNavigateForward ? p.component.canNavigateForward(state) : true);
});
return pred.path;
}
// Returns -1, 0, or 1, if a is before, the same as, or after b in the trail
cmp(a, b) {
return this.ixByPage.get(a) - this.ixByPage.get(b);
}
canNavigateForward(pageA, pageB, state) {
const a = this.ixByPage.get(pageA);
const b = this.ixByPage.get(pageB);
if (!_.isFinite(a) || !_.isFinite(b)) {
return false;
}
const start = Math.min(a, b);
const end = Math.max(a, b);
for (let i = start; i < end; i++) {
const component = this._pages[i].component;
if (!component.canNavigateForward) {
continue;
}
if (!component.canNavigateForward(state)) {
return false;
}
}
return true;
}
// Returns the previous page in the trail if that page exists
previousFrom(page) {
const myIx = this.ixByPage.get(page);
return this._pages[myIx - 1];
}
// Returns the next page in the trail if that exists
nextFrom(page) {
const myIx = this.ixByPage.get(page);
return this._pages[myIx + 1];
}
}
const doingStuff = ImmutableSet([commitPhases.REQUESTED, commitPhases.WAITING]);
const platformToSection = {
[AWS_TF]: {
choose: new Trail([sections.choose, sections.defineAWS]),
define: new Trail([sections.defineAWS], [submitDefinitionPage]),
boot: new Trail([sections.bootAWSTF]),
},
[BARE_METAL_TF]: {
choose: new Trail([sections.choose, sections.defineBaremetal]),
define: new Trail([sections.defineBaremetal], [submitDefinitionPage]),
boot: new Trail([sections.bootBaremetalTF]),
},
};
export const trail = ({cluster, clusterConfig, commitState}) => {
const platform = clusterConfig[PLATFORM_TYPE];
const { ready } = cluster;
if (platform === '') {
return new Trail([sections.loading]);
}
if (!isSupported(platform)) {
return new Trail([sections.choose]);
}
const { phase } = commitState;
const submitted = ready || (phase === commitPhases.SUCCEEDED);
if (submitted) {
if (clusterConfig[DRY_RUN]) {
return new Trail([sections.bootDryRun]);
}
return platformToSection[platform].boot;
}
if (doingStuff.has(phase)) {
return platformToSection[platform].define;
}
return platformToSection[platform].choose;
};
|
src/routes/authority/endpoint/List.js | muidea/magicSite | import React from 'react'
import PropTypes from 'prop-types'
import { Table, Modal, Tag } from 'antd'
import { DropOption, Status } from '../../../components'
const { confirm } = Modal
const List = ({ onUpdateItem, onDeleteItem, ...tableProps }) => {
const handleMenuClick = (record, e) => {
if (e.key === '1') {
onUpdateItem(record.id)
}
if (e.key === '2') {
confirm({
title: '确认删除终端?',
onOk() {
onDeleteItem(record.id)
},
})
}
}
const columns = [
{
title: '终端名',
dataIndex: 'endpoint',
key: 'endpoint',
}, {
title: '标识ID',
dataIndex: 'identifyID',
key: 'identifyID',
}, {
title: '权限组',
dataIndex: 'privateGroup',
key: 'privateGroup',
render: (text, record) => {
let tag = { name: '-' }
if (record.privateGroup) {
tag = record.privateGroup
}
return <Tag> {tag.name} </Tag>
},
}, {
title: '状态',
dataIndex: 'status',
key: 'status',
render: (text, record) => {
return <Status value={record.status} />
},
}, {
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
}, {
title: '操作',
key: 'operation',
width: 80,
render: (text, record) => {
return <DropOption onMenuClick={e => handleMenuClick(record, e)} menuOptions={[{ key: '1', name: '更新' }, { key: '2', name: '删除' }]} />
},
},
]
return (
<div>
<Table
{...tableProps}
scroll={{ x: '100%' }}
columns={columns}
simple
rowKey={record => record.id}
/>
</div>
)
}
List.propTypes = {
onUpdateItem: PropTypes.func,
onDeleteItem: PropTypes.func,
}
export default List
|
docs/examples/Form/Example6.js | romagny13/react-form-validation | import React from 'react';
import { Label } from 'romagny13-react-form-validation';
/** Customization with a CSS Framework */
const Example6 = () => {
return <iframe width="100%" height="800" frameBorder={false} src="./custom/demo.html" />;
};
export default Example6;
|
src/esm/components/form/date-picker/components/navbar.js | KissKissBankBank/kitten | import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React, { Component } from 'react';
import styled, { css } from 'styled-components';
import { ArrowIcon } from '../../../graphics/icons/arrow-icon';
import { pxToRem } from '../../../../helpers/utils/typography';
var StyledArrowIcon = styled.div.withConfig({
displayName: "navbar__StyledArrowIcon",
componentId: "sc-19zp3yg-0"
})(["width:", ";height:", ";cursor:pointer;position:absolute;top:-", ";display:flex;align-items:center;justify-content:center;transition:transform 0.3s ease-in-out;", " ", ""], pxToRem(70), pxToRem(70), pxToRem(2), function (_ref) {
var left = _ref.left;
return left && css(["left:-", ";&:hover{transform:translate(-", ");}"], pxToRem(2), pxToRem(8));
}, function (_ref2) {
var right = _ref2.right;
return right && css(["right:-", ";&:hover{transform:translate(", ");}"], pxToRem(2), pxToRem(8));
});
export var Navbar = /*#__PURE__*/function (_Component) {
_inheritsLoose(Navbar, _Component);
function Navbar() {
return _Component.apply(this, arguments) || this;
}
var _proto = Navbar.prototype;
_proto.render = function render() {
var _this$props = this.props,
onPreviousClick = _this$props.onPreviousClick,
onNextClick = _this$props.onNextClick,
className = _this$props.className,
iconColor = _this$props.iconColor,
labels = _this$props.labels;
return /*#__PURE__*/React.createElement("div", {
className: className
}, /*#__PURE__*/React.createElement(StyledArrowIcon, {
"aria-label": labels.previoustMonth,
onClick: function onClick() {
return onPreviousClick();
},
left: true
}, /*#__PURE__*/React.createElement(ArrowIcon, {
color: iconColor,
direction: "left"
})), /*#__PURE__*/React.createElement(StyledArrowIcon, {
"aria-label": labels.nextMonth,
onClick: function onClick() {
return onNextClick();
},
right: true
}, /*#__PURE__*/React.createElement(ArrowIcon, {
color: iconColor
})));
};
return Navbar;
}(Component); |
docs/src/components/nav.js | usirin/nuclear-js | import React from 'react'
import { BASE_URL } from '../globals'
function urlize(uri) {
return BASE_URL + uri
}
export default React.createClass({
render() {
const logo = this.props.includeLogo
? <a href={BASE_URL} className="brand-logo">NuclearJS</a>
: null
const homeLink = this.props.includeLogo
? <li className="hide-on-large-only"><a href={urlize("")}>Home</a></li>
: null
return <div className="navbar-fixed">
<nav className="nav">
<div className="hide-on-large-only">
<ul className="right">
{homeLink}
<li><a href={urlize("docs/01-getting-started.html")}>Docs</a></li>
<li><a href={urlize("docs/07-api.html")}>API</a></li>
<li><a href="https://github.com/optimizely/nuclear-js">Github</a></li>
</ul>
</div>
<div className="nav-wrapper hide-on-med-and-down">
{logo}
<ul className="right">
<li><a href={urlize("docs/01-getting-started.html")}>Docs</a></li>
<li><a href={urlize("docs/07-api.html")}>API</a></li>
<li><a href="https://github.com/optimizely/nuclear-js">Github</a></li>
</ul>
</div>
</nav>
</div>
}
})
|
ReactNativeApp/react-native-starter-app/src/components/ui/TabIcon.js | jjhyu/hackthe6ix2017 | /**
* Tabbar Icon
*
<TabIcon icon={'search'} selected={false} />
*
* React Native Starter App
* https://github.com/mcnamee/react-native-starter-app
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Icon } from 'react-native-elements';
import { AppColors } from '@theme/';
/* Component ==================================================================== */
const TabIcon = ({ icon, selected }) => (
<Icon
name={icon}
size={26}
color={selected ? AppColors.tabbar.iconSelected : AppColors.tabbar.iconDefault}
/>
);
TabIcon.propTypes = { icon: PropTypes.string.isRequired, selected: PropTypes.bool };
TabIcon.defaultProps = { icon: 'search', selected: false };
/* Export Component ==================================================================== */
export default TabIcon;
|
src/components/Communicator/CommunicatorDialog/CommunicatorDialogButtons.component.js | shayc/cboard | import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import TextField from '@material-ui/core/TextField';
import SearchIcon from '@material-ui/icons/Search';
import IconButton from '../../UI/IconButton';
import MenuIcon from '@material-ui/icons/MoreVert';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import { intlShape, FormattedMessage } from 'react-intl';
import messages from './CommunicatorDialog.messages';
class CommunicatorDialogButtons extends React.Component {
constructor(props) {
super(props);
this.state = {
menu: null
};
}
componentDidUpdate(prevProps) {
if (
prevProps.isSearchOpen !== this.props.isSearchOpen &&
this.props.isSearchOpen
) {
document.getElementById('communicator-dialog-buttons-search').focus();
}
}
openMenu(e) {
this.setState({ menu: e.currentTarget });
}
closeMenu() {
this.setState({ menu: null });
}
onSearch(event) {
const searchValue = event.target.value;
this.props.onSearch(searchValue);
}
render() {
const { intl, searchValue, isSearchOpen, openSearchBar, dark } = this.props;
return (
<div
className={classNames(
'CommunicatorDialogButtons__container',
dark ? 'is-dark' : ''
)}
>
{isSearchOpen && (
<div className="CommunicatorDialogButtons__searchInput">
<TextField
id="communicator-dialog-buttons-search"
value={searchValue}
onChange={this.onSearch.bind(this)}
margin="dense"
variant="outlined"
/>
</div>
)}
{!isSearchOpen && (
<div className="CommunicatorDialogButtons__searchButton">
<IconButton
id="communicator-dialog-buttons-search-button"
label={intl.formatMessage(messages.search)}
onClick={openSearchBar}
>
<SearchIcon />
</IconButton>
</div>
)}
<div className="CommunicatorDialogButtons__menu">
<IconButton
id="communicator-dialog-buttons-menu-button"
label={intl.formatMessage(messages.menu)}
onClick={this.openMenu.bind(this)}
>
<MenuIcon />
</IconButton>
<Menu
id="communicator-dialog-buttons-menu"
anchorEl={this.state.menu}
open={Boolean(this.state.menu)}
onClose={this.closeMenu.bind(this)}
>
<MenuItem>
<a
href="https://www.cboard.io/help/"
target="_blank"
rel="noopener noreferrer"
>
<FormattedMessage {...messages.helpAndSupport} />
</a>
</MenuItem>
<MenuItem>
<a
href="https://www.cboard.io/terms-of-use/"
target="_blank"
rel="noopener noreferrer"
>
<FormattedMessage {...messages.termsOfService} />
</a>
</MenuItem>
</Menu>
</div>
</div>
);
}
}
CommunicatorDialogButtons.propTypes = {
onSearch: PropTypes.func.isRequired,
intl: intlShape.isRequired,
dark: PropTypes.bool
};
export default CommunicatorDialogButtons;
|
src/js/components/nav/NavMoreLinks.js | getblank/blank-web-app | /**
* Created by kib357 on 28/02/16.
*/
import React from 'react';
import BsLink from './BsLink';
class NavMoreLinks extends React.Component {
constructor(props) {
super(props);
this.state = {};
this.toggle = this.toggle.bind(this);
this.handleLinkClick = this.handleLinkClick.bind(this);
this.handleDocumentClick = this.handleDocumentClick.bind(this);
}
toggle(e) {
if (e) {
e.preventDefault();
e.stopPropagation();
}
this.setState({"opened": !this.state.opened}, this.manageListeners);
}
handleLinkClick() {
this.setState({"opened": false}, this.manageListeners);
}
render() {
return (
<div className="more-link relative" ref="root">
{this.props.links.length > 0 && <a href="#" onClick={this.toggle}>
<i className="material-icons text md-16">more_horiz</i>
</a>}
<ul className={"pd-dropdown-menu left-side" + ((this.props.links.length > 0) && this.state.opened ? " open" : "")}>
{this.props.links.map((linkDesc) => {
return (<BsLink key={linkDesc.to + "-" + linkDesc.name}
to={linkDesc.to}
style={linkDesc.style}
activeStyle={linkDesc.activeStyle}
hoverStyle={linkDesc.hoverStyle}
onClick={this.handleLinkClick}>
{linkDesc.name}
</BsLink>)
})}
</ul>
</div>
);
}
handleDocumentClick(e) {
var root = this.refs['root'];
if (root == null) {
this.toggle();
return;
}
if (e.target === root || root.contains(e.target)) {
return;
}
this.toggle();
}
manageListeners() {
if (this.state.opened) {
document.addEventListener('click', this.handleDocumentClick);
} else {
document.removeEventListener('click', this.handleDocumentClick);
}
}
}
NavMoreLinks.propTypes = {};
NavMoreLinks.defaultProps = {};
export default NavMoreLinks;
|
examples/todomvc/index.js | Jyrno42/redux | import 'babel-core/polyfill';
import React from 'react';
import { Provider } from 'react-redux';
import App from './containers/App';
import configureStore from './store/configureStore';
import 'todomvc-app-css/index.css';
const store = configureStore();
React.render(
<Provider store={store}>
{() => <App />}
</Provider>,
document.getElementById('root')
);
|
packages/react-scripts/fixtures/kitchensink/src/index.js | in2core/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />, document.getElementById('root'));
|
app/templates/server.js | v2018z/generator-fluxible | /**
* This leverages Express to create and run the http server.
* A Fluxible context is created and executes the navigateAction
* based on the URL. Once completed, the store state is dehydrated
* and the application is rendered via React.
*/
import express from 'express';
import compression from 'compression';
import path from 'path';
import serialize from 'serialize-javascript';
import {navigateAction} from 'fluxible-router';
import debugLib from 'debug';
import React from 'react';
import app from './app';
import HtmlComponent from './components/Html';
import { createElementWithContext } from 'fluxible-addons-react';
const htmlComponent = React.createFactory(HtmlComponent);
const env = process.env.NODE_ENV;
const debug = debugLib('<%= name %>');
const server = express();
server.use('/public', express.static(path.join(__dirname, '/build')));
server.use(compression());
server.use((req, res, next) => {
let context = app.createContext();
debug('Executing navigate action');
context.getActionContext().executeAction(navigateAction, {
url: req.url
}, (err) => {
if (err) {
if (err.statusCode && err.statusCode === 404) {
next();
} else {
next(err);
}
return;
}
debug('Exposing context state');
const exposed = 'window.App=' + serialize(app.dehydrate(context)) + ';';
debug('Rendering Application component into html');
const html = React.renderToStaticMarkup(htmlComponent({
clientFile: env === 'production' ? 'main.min.js' : 'main.js',
context: context.getComponentContext(),
state: exposed,
markup: React.renderToString(createElementWithContext(context))
}));
debug('Sending markup');
res.type('html');
res.write('<!DOCTYPE html>' + html);
res.end();
});
});
const port = process.env.PORT || 3000;
server.listen(port);
console.log('Application listening on port ' + port);
export default server;
|
src/app.js | tykarol/redux-isomorphic-starter-kit | import React from 'react';
import ReactDOM from 'react-dom';
import { reduxReactRouter } from 'redux-router';
import createHistory from 'history/lib/createBrowserHistory';
import injectTapEventPlugin from 'react-tap-event-plugin';
import { Root } from 'containers';
import configureStore from 'stores/configureStore';
import { loggedUserTokenSave } from 'actions';
import routes from 'routes';
import { Cookie } from 'helpers';
injectTapEventPlugin();
const history = reduxReactRouter({ routes, createHistory });
const store = configureStore(history, window.__INITIAL_STATE__);
const token = Cookie.get('token');
if (token !== null) {
store.dispatch(loggedUserTokenSave(token));
}
ReactDOM.render(
<Root store={store} />,
document.getElementById('root')
);
|
client/src/components/Public/EntitySearchAutocomplete/EntitySearchAutocomplete.js | verejnedigital/verejne.digital | // @flow
import React from 'react'
import {compose, withHandlers} from 'recompose'
import {Form, InputGroup, InputGroupAddon, Button} from 'reactstrap'
import {connect} from 'react-redux'
import {
setEntitySearchValue,
setEntitySearchFor,
toggleModalOpen,
setDrawer,
setEntitySearchOpen,
closeAddressDetail,
setEntitySearchLoaded,
} from '../../../actions/publicActions'
import {
entitySearchValueSelector,
entitySearchLoadedSelector,
entitySearchForSelector,
} from '../../../selectors'
import AutoComplete from '../../shared/AutoComplete/AutoComplete'
import {FaSearch, FaClone} from 'react-icons/fa'
import {FIND_ENTITY_TITLE, OPEN_MODAL_TOOLTIP} from '../../../constants'
import type {State} from '../../../state'
import './EntitySearchAutocomplete.css'
type EntitySearchAutocompleteProps = {
entitySearchValue: string,
entitySearchFor: string,
setEntitySearchValue: (value: string) => void,
setEntitySearchFor: (value: string) => void,
toggleModalOpen: () => void,
setDrawer: (open: boolean) => void,
setEntitySearchOpen: (open: boolean) => void,
closeAddressDetail: () => void,
findEntities: (e: Event) => void,
setEntitySearchLoaded: (loaded: boolean) => void,
onChangeHandler: (e: Event) => void,
onSelectHandler: (value: string) => void,
}
const EntitySearchAutocomplete = ({
entitySearchValue,
setEntitySearchValue,
setEntitySearchFor,
toggleModalOpen,
setDrawer,
setEntitySearchOpen,
closeAddressDetail,
findEntities,
setEntitySearchLoaded,
onChangeHandler,
onSelectHandler,
}: EntitySearchAutocompleteProps) => (
<Form onSubmit={findEntities}>
<InputGroup className="autocomplete-holder">
<AutoComplete
value={entitySearchValue}
onChangeHandler={onChangeHandler}
onSelectHandler={onSelectHandler}
menuClassName="publicly-autocomplete-menu"
inputProps={{
className: 'form-control publicly-autocomplete-input',
placeholder: FIND_ENTITY_TITLE,
}}
/>
<InputGroupAddon title={FIND_ENTITY_TITLE} addonType="append">
<Button className="addon-button" color="primary" onClick={findEntities}>
<FaSearch />
</Button>
</InputGroupAddon>
<InputGroupAddon title={OPEN_MODAL_TOOLTIP} addonType="append">
<Button className="addon-button" color="primary" onClick={toggleModalOpen}>
<FaClone />
</Button>
</InputGroupAddon>
</InputGroup>
</Form>
)
export default compose(
connect(
(state: State) => ({
entitySearchValue: entitySearchValueSelector(state),
entitySearchLoaded: entitySearchLoadedSelector(state),
entitySearchFor: entitySearchForSelector(state),
}),
{
setEntitySearchValue,
setEntitySearchFor,
toggleModalOpen,
setDrawer,
setEntitySearchOpen,
closeAddressDetail,
setEntitySearchLoaded,
}
),
withHandlers({
findEntities: ({
entitySearchValue,
setEntitySearchFor,
closeAddressDetail,
setEntitySearchOpen,
setDrawer,
setEntitySearchLoaded,
entitySearchFor,
}) => (e) => {
e.preventDefault()
if (entitySearchValue.trim() === '') {
return
}
entitySearchFor !== entitySearchValue && setEntitySearchLoaded(false)
setEntitySearchFor(entitySearchValue)
closeAddressDetail()
setEntitySearchOpen(true)
setDrawer(true)
},
onChangeHandler: ({setEntitySearchValue}) => (e) => setEntitySearchValue(e.target.value),
onSelectHandler: ({
setEntitySearchValue,
entitySearchValue,
setEntitySearchFor,
closeAddressDetail,
setEntitySearchOpen,
setDrawer,
setEntitySearchLoaded,
entitySearchFor,
}) => (value) => {
setEntitySearchValue(value)
if (entitySearchValue.trim() === '') {
return
}
entitySearchFor !== entitySearchValue && setEntitySearchLoaded(false)
setEntitySearchFor(value)
closeAddressDetail()
setEntitySearchOpen(true)
setDrawer(true)
},
})
)(EntitySearchAutocomplete)
|
commands/init/templates/src/home/index.js | garbas/neo | import React from 'react';
export default function Home() {
return (
<div>
<h1>Home</h1>
</div>
);
}
Home.displayName = 'Home';
|
rest-ui-scripts/template/src/resources/Comment/crud/list/Filter.js | RestUI/create-rest-ui-app | import React from 'react';
import { Filter as CrudFilter, ReferenceInput, SelectInput } from 'rest-ui/lib/mui';
const Filter = ({ ...props }) => (
<CrudFilter {...props}>
<ReferenceInput source="post_id" reference="posts">
<SelectInput optionText="title" />
</ReferenceInput>
</CrudFilter>
);
export default Filter; |
node_modules/bs-recipes/recipes/webpack.react-hot-loader/app/js/main.js | JackSSS/plo | 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'));
|
newclient/scripts/components/editor/block-style-controls/index.js | kuali/research-coi | /*
The Conflict of Interest (COI) module of Kuali Research
Copyright © 2005-2016 Kuali, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
import React from 'react';
import styles from './style.css';
import EditorButton from '../editor-button';
const BLOCK_TYPES = [
{icon: 'fa-list-ul', style: 'unordered-list-item'},
{icon: 'fa-list-ol', style: 'ordered-list-item'}
];
export default function BlockStyleControls(props) {
const {editorState} = props;
const selection = editorState.getSelection();
const blockType = editorState
.getCurrentContent()
.getBlockForKey(selection.getStartKey())
.getType();
return (
<div className={styles.controls}>
{BLOCK_TYPES.map((type) =>
<EditorButton
key={type.icon}
active={type.style === blockType}
icon={type.icon}
onToggle={props.onToggle}
style={type.style}
/>
)}
</div>
);
} |
webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableSchema.js | jlsherrill/katello | /* eslint-disable import/prefer-default-export */
import React from 'react';
import { Icon } from 'patternfly-react';
import { Link } from 'react-router-dom';
import helpers from '../../../../move_to_foreman/common/helpers';
import { entitlementsInlineEditFormatter } from './EntitlementsInlineEditFormatter';
import {
headerFormatter,
cellFormatter,
selectionHeaderCellFormatter,
collapseableAndSelectionCellFormatter,
} from '../../../../move_to_foreman/components/common/table';
export const createSubscriptionsTableSchema = (
inlineEditController,
selectionController,
groupingController,
) => [
{
property: 'select',
header: {
label: __('Select all rows'),
formatters: [label => selectionHeaderCellFormatter(selectionController, label)],
},
cell: {
formatters: [
(value, additionalData) =>
collapseableAndSelectionCellFormatter(
groupingController,
selectionController,
additionalData,
),
],
},
},
{
property: 'id',
header: {
label: __('Name'),
formatters: [headerFormatter],
},
cell: {
formatters: [
(value, { rowData }) => (
<td>
<Link to={helpers.urlBuilder('subscriptions', '', rowData.id)}>{rowData.name}</Link>
</td>
),
],
},
},
{
property: 'product_id',
header: {
label: __('SKU'),
formatters: [headerFormatter],
},
cell: {
formatters: [cellFormatter],
},
},
{
property: 'contract_number',
header: {
label: __('Contract'),
formatters: [headerFormatter],
},
cell: {
formatters: [cellFormatter],
},
}, // TODO: use date formatter from tomas' PR
{
property: 'start_date',
header: {
label: __('Start Date'),
formatters: [headerFormatter],
},
cell: {
formatters: [cellFormatter],
},
},
{
property: 'end_date',
header: {
label: __('End Date'),
formatters: [headerFormatter],
},
cell: {
formatters: [cellFormatter],
},
},
{
property: 'virt_who',
header: {
label: __('Requires Virt-Who'),
formatters: [headerFormatter],
},
cell: {
formatters: [
cell => (
<td>
<Icon type="fa" name={cell.virt_who ? 'check' : 'minus'} />
</td>
),
],
},
},
{
property: 'consumed',
header: {
label: __('Consumed'),
formatters: [headerFormatter],
},
cell: {
formatters: [cellFormatter],
},
},
{
property: 'quantity',
header: {
label: __('Entitlements'),
formatters: [headerFormatter],
},
cell: {
formatters: [entitlementsInlineEditFormatter(inlineEditController)],
},
},
];
|
src/components/Snake/Head.js | nataly87s/rx-snake | import React from 'react';
import glamorous from 'glamorous';
import { SOLUTO_BLUE } from '../../resources/colors';
const Line = glamorous.line({
fill: '#FFFFFF',
strokeWidth: 8,
strokeLinecap: 'round',
strokeMiterlimit: 10,
});
const TransparentPath = glamorous.path({
opacity: 0.4,
});
const HeadSvg = ({ style, direction: [x = 0, y = 0], color = SOLUTO_BLUE }) => (
<svg x="0px" y="0px" viewBox="0 0 89 77"
style={{ ...style, transform: `${style.transform} rotate(${x === -1 ? 180 : y * 90}deg)` }}>
<Line stroke={color} x1="85.1" y1="57.2" x2="67.7" y2="47.2"/>
<Line stroke={color} x1="85.1" y1="21" x2="67.7" y2="31"/>
<path fill="#FFFFFF" d="M49.4,76.7H26.9c-14.9,0-27-12.2-27-27V27.3c0-14.8,12.1-27,27-27h22.5c14.9,0,27,12.2,27,27v22.5
C76.4,64.6,64.3,76.7,49.4,76.7z"/>
<TransparentPath fill={color} d="M38.2,72.2c0-6.6,5.3-11.9,11.9-11.9s11.9,5.3,11.9,11.9"/>
<TransparentPath fill={color} d="M38.2,7.8c0,6.6,5.3,11.9,11.9,11.9s11.9-5.3,11.9-11.9"/>
<path fill={color} d="M49.4,8.3c10.5,0,19,8.5,19,19v22.5c0,10.5-8.5,19-19,19H26.9c-10.5,0-19-8.5-19-19V27.3c0-10.5,8.5-19,19-19H49.4
M49.4,0.3H26.9c-14.8,0-27,12.1-27,27v22.5c0,14.9,12.2,27,27,27h22.5c14.8,0,27-12.1,27-27V27.3C76.4,12.4,64.3,0.3,49.4,0.3
L49.4,0.3z"/>
</svg>
);
export default HeadSvg;
|
component/projectOverview.js | jstogether/jstogether | import React from 'react'
import Component from './component';
import _ from 'lodash';
import marked from 'react-marked';
import moment from 'moment-timezone';
import Team from './team';
import AppActions from '../action/app';
import SessionStore from '../store/session';
import TeamStore from '../store/team';
const dateFormat = 'Do MMM YYYY HH:mm:ss';
const scopes = ['solo', 'peer', 'group'];
export default class ProjectOverview extends Component {
/**
*
*/
constructor () {
super();
this._bind(
'renderProjectTitle',
'renderProjectScope',
'renderButtons',
'renderDescription',
'renderProjectSummary',
'renderJoinProjectDialog',
'renderTeams',
'onNumberChange',
'onNameChange',
'onScopeClick',
'toggleEditing',
'onDescriptionChange',
'onDeadlineChange',
'onRequirementChange',
'onExtensionChange',
'onHelpChange',
'onAddRequirementClick',
'onAddExtensionClick',
'onAddHelpClick',
'onDeleteRequirementClick',
'onDeleteExtensionClick',
'onDeleteHelpClick',
'onCreateTeamClick',
'onSaveEditsClick',
'onDeleteProjectClick',
'onCancelEditClick',
'onTeamStoreChange'
);
this.state = {
editing: false,
};
}
/**
*
*/
componentDidMount () {
TeamStore.addChangeListener(this.onTeamStoreChange);
}
/**
*
*/
componentWillUnmount () {
TeamStore.removeChangeListener(this.onTeamStoreChange);
}
/**
*
*/
getClassName () {
return 'projectOverview' + (this.state.editing ? ' editing' : '');
}
/**
*
*/
render () {
const editing = this.state.editing;
const project = editing ? this.state.project : this.props.project;
return (
<div className={this.getClassName()}>
{this.renderProjectTitle(editing, project)}
{this.renderDescription(editing, project)}
{this.renderProjectSummary(editing, project)}
{this.renderTeams(editing, project)}
</div>
);
}
/**
*
*/
renderProjectTitle (editing, project) {
const scope = this.renderProjectScope(editing, project);
const buttons = this.renderButtons(editing, project);
if (editing) {
return (
<div className='projectTitle'>
<h2 className='title editing'>
{'Project '}
<input
type='text'
className='number textStyle'
value={project.number}
onChange={this.onNumberChange} />
<span>{': '}</span>
<input
type='text'
className='name textStyle'
value={project.name}
onChange={this.onNameChange} />
</h2>
{scope}
{buttons}
</div>
);
}
return (
<div className='projectTitle'>
<h2 className='title'>
{'Project ' + project.number + ': ' + project.name}
</h2>
{scope}
{buttons}
</div>
);
}
/**
*
*/
renderProjectScope (editing, project) {
if (editing) {
return (
<span
className='scope editing'
onClick={this.onScopeClick}>
{'(' + project.scope + ')'}
</span>
);
}
return (
<span
className='scope'>
{'(' + project.scope + ')'}
</span>
);
}
/**
*
*/
renderButtons (editing, project) {
if (!SessionStore.isAdmin()) return null;
const buttons = [];
const text = editing ? 'Cancel Edit' : 'Edit';
const editButtonHandler = editing ? this.onCancelEditClick : this.toggleEditing;
buttons.push(<button className='editBtn' onClick={editButtonHandler}>{text}</button>);
if (editing) {
buttons.push(<button onClick={this.onSaveEditsClick}>{'Save'}</button>);
buttons.push(<button onClick={this.onDeleteProjectClick}>{'Delete Project'}</button>);
}
return buttons;
}
/**
*
*/
renderDescription (editing, project) {
const content = [(
<div className='description'>
{marked(project.description)}
</div>
)];
if (editing) {
content.push(
<textarea
ref='descriptionMarkdown'
className={'markdown editing'}
value={project.description}
onChange={this.onDescriptionChange} />
);
}
return content;
}
/**
*
*/
renderProjectSummary (editing, project) {
let deadline;
let requirements;
let extensions;
let help;
if (editing) {
deadline = (
<input type='text' value={project.deadline} onChange={this.onDeadlineChange} />
);
requirements = project.requirements.map((requirement, i) => {
return (
<li>
<input type='text' value={requirement} onChange={this.onRequirementChange(i)} />
<span className='delete' onClick={this.onDeleteRequirementClick(i)}>{'-'}</span>
</li>
);
});
extensions = project.extensions.map((extension, i) => {
return (
<li>
<input type='text' value={extension} onChange={this.onExtensionChange(i)} />
<span className='delete' onClick={this.onDeleteExtensionClick(i)}>{'-'}</span>
</li>
);
});
help = project.help.map((help, i) => {
return (
<li>
<input type='text' value={help} onChange={this.onHelpChange(i)} />
<span className='delete' onClick={this.onDeleteHelpClick(i)}>{'-'}</span>
</li>
);
});
}
else {
deadline = (
<span>{moment(project.deadline).tz('utc').format(dateFormat)}</span>
);
requirements = project.requirements.map((requirement, i) => {
return (
<li>
<span>{requirement}</span>
</li>
);
});
extensions = project.extensions.map((extension, i) => {
return (
<li>
<span>{extension}</span>
</li>
);
});
help = project.help.map((help, i) => {
return (
<li>
<span>{help}</span>
</li>
);
});
}
return (
<table className='keyvalue'>
<tbody>
<tr>
<th>{'Due'}</th>
<td>{deadline}</td>
</tr><tr>
<th>
{'Base Requirements'}
<span className='addNew' onClick={this.onAddRequirementClick}>{'+'}</span>
</th>
<td>
<ol>{requirements}</ol>
</td>
</tr><tr>
<th>
{'Extra Credit Extensions'}
<span className='addNew' onClick={this.onAddExtensionClick}>{'+'}</span>
</th>
<td>
<ol start={requirements.length}>{extensions}</ol>
</td>
</tr><tr>
<th>
{'Helpful Links'}
<span className='addNew' onClick={this.onAddHelpClick}>{'+'}</span>
</th>
<td>
<ul>{help}</ul>
</td>
</tr>
</tbody>
</table>
);
}
/**
*
*/
renderJoinProjectDialog (editing, project) {
if (!this.props.userTeam || SessionStore.isAdmin()) {
return (
<div className='join'>
<span>{'To get onboard with this project, either create a new Team or join an existing one!'}</span>
<br />
<input type='text' ref='teamName' name='teamName' placeholder='Team Name' />
<br />
<button onClick={this.onCreateTeamClick}>{'Create New Team'}</button>
</div>
);
}
}
/**
*
*/
renderTeams (editing, project) {
let teams = TeamStore.getByProjectId(project.id);
teams = teams.map(team => <Team team={team} canJoin={!this.props.userTeam} isMyTeam={team === this.props.userTeam} />);
const joinProjectDialog = this.renderJoinProjectDialog(editing, project);
return [
<h3 key='teamTitle'>{'Teams'}</h3>,
{joinProjectDialog},
<div key='teams' className='teams'>
{teams}
</div>
];
}
/**
*
*/
toggleEditing () {
const editing = !this.state.editing;
this.setState({
project: editing ? _.cloneDeep(this.props.project) : null,
editing
});
}
/**
*
*/
onNumberChange (e) {
const number = e.target.value;
const project = this.state.project;
project.number = number;
this._forceUpdate();
}
/**
*
*/
onNameChange (e) {
const name = e.target.value;
const project = this.state.project;
project.name = name;
this._forceUpdate();
}
/**
*
*/
onScopeClick () {
const project = this.state.project;
const index = scopes.indexOf(project.scope);
const newScope = scopes[(index + 1) % scopes.length];
project.scope = newScope;
this._forceUpdate();
}
/**
*
*/
onDescriptionChange (e) {
const description = e.target.value;
const project = this.state.project;
project.description = description;
this._forceUpdate();
}
/**
*
*/
onDeadlineChange (e) {
console.log('Deadline Change', arguments);
}
/**
*
*/
onRequirementChange (index) {
return (e) => {
let project = this.state.project;
project.requirements[index] = e.target.value;
console.log(e.target.value);
this._forceUpdate();
};
}
/**
*
*/
onExtensionChange (index) {
return (e) => {
let project = this.state.project;
project.extensions[index] = e.target.value;
this._forceUpdate();
};
}
/**
*
*/
onHelpChange (index) {
return (e) => {
let project = this.state.project;
project.help[index] = e.target.value;
this._forceUpdate();
};
}
/**
*
*/
onAddRequirementClick () {
this.state.project.requirements.push('');
this._forceUpdate();
}
/**
*
*/
onAddExtensionClick () {
this.state.project.extensions.push('');
this._forceUpdate();
}
/**
*
*/
onAddHelpClick () {
this.state.project.help.push('');
this._forceUpdate();
}
/**
*
*/
onDeleteRequirementClick (i) {
return () => {
this.state.project.requirements.splice(i, 1);
this._forceUpdate();
};
}
/**
*
*/
onDeleteExtensionClick (i) {
return () => {
this.state.project.extensions.splice(i, 1);
this._forceUpdate();
};
}
/**
*
*/
onDeleteHelpClick (i) {
return () => {
this.state.project.help.splice(i, 1);
this._forceUpdate();
};
}
/**
*
*/
onSaveEditsClick () {
const project = this.props.project;
const clone = this.state.project;
const update = {};
if (clone.number !== project.number) {
update.number = project.number = clone.number;
}
if (clone.name !== project.name) {
update.name = project.name = clone.name;
}
if (clone.scope !== project.scope) {
update.scope = project.scope = clone.scope;
}
if (clone.deadline !== project.deadline) {
update.deadline = project.deadline = clone.deadline;
}
if (clone.description !== project.description) {
update.description = project.description = clone.description;
}
clone.requirements.forEach((requirement, i) => {
if (project.requirements[i] !== requirement) {
update.requirements = clone.requirements;
return false;
}
});
clone.extensions.forEach((extension, i) => {
if (project.extensions[i] !== extension) {
update.extensions = clone.extensions;
return false;
}
});
clone.help.forEach((help, i) => {
if (project.help[i] !== help) {
update.help = clone.help;
}
});
if (Object.keys(update).length > 0) {
AppActions.updateProject(project.id, update);
}
this.toggleEditing();
}
/**
*
*/
onDeleteProjectClick () {
AppActions.deleteProject(this.props.project.id);
}
/**
*
*/
onCancelEditClick () {
this.toggleEditing();
}
/**
*
*/
onCreateTeamClick () {
const teamNameInput = React.findDOMNode(this.refs.teamName);
const team = {
name: teamNameInput.value,
users: [SessionStore.getUser().username],
projectId: this.props.project.id
};
teamNameInput.value = '';
AppActions.createTeam(team);
}
/**
*
*/
onTeamStoreChange () {
this._forceUpdate();
}
}
|
src/svg-icons/notification/vibration.js | IsenrichO/mui-with-arrows | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NotificationVibration = (props) => (
<SvgIcon {...props}>
<path d="M0 15h2V9H0v6zm3 2h2V7H3v10zm19-8v6h2V9h-2zm-3 8h2V7h-2v10zM16.5 3h-9C6.67 3 6 3.67 6 4.5v15c0 .83.67 1.5 1.5 1.5h9c.83 0 1.5-.67 1.5-1.5v-15c0-.83-.67-1.5-1.5-1.5zM16 19H8V5h8v14z"/>
</SvgIcon>
);
NotificationVibration = pure(NotificationVibration);
NotificationVibration.displayName = 'NotificationVibration';
NotificationVibration.muiName = 'SvgIcon';
export default NotificationVibration;
|
web-admin/src/components/Motion.js | llqgit/pi | import React from 'react';
import ReactAccelerometer from 'react-accelerometer';
import { Motion, spring } from 'react-motion';
/* Combining React-Accelerometer with React-Motion */
const ReactAccelerometerMotion = () => (
<ReactAccelerometer>
{(position) => {
if (position) {
const { x, y } = position;
return (
<Motion style={{ x: spring(x), y: spring(y) }}>
{pos => (
<div>
<img
src='image.jpg'
style={{ transform: `translate3d(${pos.x * 10}px, ${pos.y * 10}px, 0)` }}
/>
<div>x: {pos.x}</div>
<div>y: {pos.y}</div>
</div>
)}
</Motion>
);
}
return (<div></div>);
}}
</ReactAccelerometer>
);
const AwesomeComponent = () => (
<ReactAccelerometerMotion>
{({ x, y }) => (
<img
src='image.jpg'
style={{ transform: `translate3d(${x}px, ${y}px, 0)` }}
/>
)}
</ReactAccelerometerMotion>
);
export default ReactAccelerometerMotion;
|
packages/bootstrap-shell/src/providers/Theme/Context.js | TarikHuber/react-most-wanted | import React from 'react'
export const Context = React.createContext(null)
export default Context
|
docs/src/examples/modules/Progress/Content/ProgressExampleBar.js | Semantic-Org/Semantic-UI-React | import React from 'react'
import { Progress } from 'semantic-ui-react'
const ProgressExampleBar = () => <Progress percent={33} />
export default ProgressExampleBar
|
examples/query-params/app.js | maksad/react-router | import React from 'react';
import { Router, Route, Link } from 'react-router';
var User = React.createClass({
render() {
var { query } = this.props.location;
var age = query && query.showAge ? '33' : '';
var { userID } = this.props.params;
return (
<div className="User">
<h1>User id: {userID}</h1>
{age}
</div>
);
}
});
var App = React.createClass({
render() {
return (
<div>
<ul>
<li><Link to="/user/bob">Bob</Link></li>
<li><Link to="/user/bob" query={{showAge: true}}>Bob With Query Params</Link></li>
<li><Link to="/user/sally">Sally</Link></li>
</ul>
{this.props.children}
</div>
);
}
});
React.render((
<Router>
<Route path="/" component={App}>
<Route path="user/:userID" component={User} />
</Route>
</Router>
), document.getElementById('example'));
|
blueocean-material-icons/src/js/components/svg-icons/action/pan-tool.js | kzantow/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const ActionPanTool = (props) => (
<SvgIcon {...props}>
<path d="M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z"/>
</SvgIcon>
);
ActionPanTool.displayName = 'ActionPanTool';
ActionPanTool.muiName = 'SvgIcon';
export default ActionPanTool;
|
src/views/components/Square.js | john-d-pelingo/tic-tac-toe | /* eslint-disable jsx-a11y/no-static-element-interactions */
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
columnIndex: PropTypes.number.isRequired,
rowIndex: PropTypes.number.isRequired,
handleSquareClick: PropTypes.func.isRequired
};
class Square extends React.Component {
constructor(props) {
super(props);
this._handleSquareClick = this._handleSquareClick.bind(this);
}
_handleSquareClick() {
const { columnIndex, rowIndex, handleSquareClick } = this.props;
return handleSquareClick(columnIndex, rowIndex);
}
render() {
return (
<div className="symbol -square" onClick={ this._handleSquareClick }>
</div>
);
}
}
Square.propTypes = propTypes;
export default Square;
|
app/main.js | ElijahDolskij/random_app | import 'babel-polyfill'
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import App from './components/App/App.jsx'
import configureStore from './store/configureStore'
const store = configureStore() // Вынес stor в отдельный файл
ReactDOM.render((
<Provider store={store}>
<App />
</Provider>
), document.getElementById('root'))
module.hot.accept() |
app/react-icons/fa/beer.js | scampersand/sonos-front | import React from 'react';
import IconBase from 'react-icon-base';
export default class FaBeer extends React.Component {
render() {
return (
<IconBase viewBox="0 0 40 40" {...this.props}>
<g><path d="m14.8 20v-8.6h-5.7v5.7q0 1.2 0.8 2.1t2 0.8h2.9z m22.8 10v4.3h-25.7v-4.3l2.9-4.3h-2.9q-3.5 0-6-2.5t-2.5-6.1v-7.1l-1.5-1.4 0.7-2.9h10.8l0.7-2.8h21.4l0.7 4.2-1.4 0.8v17.8z"/></g>
</IconBase>
);
}
}
|
client/src/components/Draftail/decorators/Document.js | wagtail/wagtail | import PropTypes from 'prop-types';
import React from 'react';
import { gettext } from '../../../utils/gettext';
import Icon from '../../Icon/Icon';
import TooltipEntity from '../decorators/TooltipEntity';
const documentIcon = <Icon name="doc-full" />;
const missingDocumentIcon = <Icon name="warning" />;
const Document = (props) => {
const { entityKey, contentState } = props;
const data = contentState.getEntity(entityKey).getData();
const url = data.url || null;
let icon;
let label;
if (!url) {
icon = missingDocumentIcon;
label = gettext('Missing document');
} else {
icon = documentIcon;
label = data.filename || '';
}
return <TooltipEntity {...props} icon={icon} label={label} url={url} />;
};
Document.propTypes = {
entityKey: PropTypes.string.isRequired,
contentState: PropTypes.object.isRequired,
};
export default Document;
|
app/react-icons/fa/expeditedssl.js | scampersand/sonos-front | import React from 'react';
import IconBase from 'react-icon-base';
export default class FaExpeditedssl extends React.Component {
render() {
return (
<IconBase viewBox="0 0 40 40" {...this.props}>
<g><path d="m20 1.4q-3.8 0-7.2 1.5t-5.9 4-4 5.9-1.5 7.2 1.5 7.2 4 5.9 5.9 4 7.2 1.5 7.2-1.5 5.9-4 4-5.9 1.5-7.2-1.5-7.2-4-5.9-5.9-4-7.2-1.5z m0-1.4q4.1 0 7.8 1.6t6.4 4.2 4.2 6.4 1.6 7.8-1.6 7.8-4.2 6.4-6.4 4.2-7.8 1.6-7.8-1.6-6.4-4.2-4.2-6.4-1.6-7.8 1.6-7.8 4.2-6.4 6.4-4.2 7.8-1.6z m-8.9 18.6q0.3 0 0.3 0.3v10.7q0 0.4-0.3 0.4h-0.7q-0.4 0-0.4-0.4v-10.7q0-0.3 0.4-0.3h0.7z m8.9 1.4q1.2 0 2 0.8t0.9 2.1q0 0.7-0.4 1.4t-1.1 1v2.6q0 0.3-0.2 0.5t-0.5 0.2h-1.4q-0.3 0-0.5-0.2t-0.2-0.5v-2.6q-0.7-0.4-1.1-1t-0.4-1.4q0-1.2 0.9-2.1t2-0.8z m0-17.1q4.7 0 8.6 2.3t6.2 6.2 2.3 8.6-2.3 8.6-6.2 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3z m-7.9 10.7v2.1q0 0.3 0.2 0.5t0.6 0.2h1.4q0.3 0 0.5-0.2t0.2-0.5v-2.1q0-2.1 1.5-3.6t3.5-1.4 3.5 1.4 1.5 3.6v2.1q0 0.3 0.2 0.5t0.5 0.2h1.4q0.4 0 0.6-0.2t0.2-0.5v-2.1q0-3.3-2.3-5.6t-5.6-2.3-5.6 2.3-2.3 5.6z m19.3 16.4v-11.4q0-0.6-0.4-1t-1-0.5h-20q-0.6 0-1 0.5t-0.4 1v11.4q0 0.6 0.4 1t1 0.4h20q0.6 0 1-0.4t0.4-1z"/></g>
</IconBase>
);
}
}
|
src/svg-icons/social/person.js | hwo411/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let SocialPerson = (props) => (
<SvgIcon {...props}>
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
</SvgIcon>
);
SocialPerson = pure(SocialPerson);
SocialPerson.displayName = 'SocialPerson';
SocialPerson.muiName = 'SvgIcon';
export default SocialPerson;
|
src/app/components/AppBar.js | lili668668/lili668668.github.io | import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import { withStyles } from '@material-ui/core/styles'
import MuiAppBar from '@material-ui/core/AppBar'
import Toolbar from '@material-ui/core/Toolbar'
const styles = theme => ({
root: {
background: theme.palette.primary.dark,
boxShadow: theme.shadows[3]
}
})
function AppBar (props) {
const { classes, children, className, style } = props
const root = classnames(classes.root, className)
return (
<MuiAppBar position="fixed" className={root} style={style}>
<Toolbar>
{children}
</Toolbar>
</MuiAppBar>
)
}
AppBar.propTypes = {
children: PropTypes.any,
className: PropTypes.string,
style: PropTypes.object
}
export default withStyles(styles)(AppBar)
|
src/js/components/Anchor/stories/Weight.js | HewlettPackard/grommet | import React from 'react';
import { Anchor, Box } from 'grommet';
const WeightAnchor = () => (
<Box align="center" pad="large" gap="xsmall">
<Anchor href="#" label="Anchor default weight" />
<Anchor href="#" label="Anchor weight Normal" weight="normal" />
<Anchor href="#" label="Anchor weight Bold" weight="bold" />
<Anchor href="#" label="Anchor weight 200" weight={200} />
<Anchor href="#" label="Anchor weight 400" weight={400} />
<Anchor href="#" label="Anchor weight 600" weight={600} />
<Anchor href="#" label="Anchor weight Lighter" weight="lighter" />
<Anchor href="#" label="Anchor weight Bolder" weight="bolder" />
<Anchor href="#" label="Anchor weight Inherit" weight="inherit" />
<Anchor href="#" label="Anchor weight Initial" weight="initial" />
<Anchor href="#" label="Anchor weight Revert" weight="revert" />
<Anchor href="#" label="Anchor weight Unset" weight="unset" />
</Box>
);
export const Weight = () => <WeightAnchor />;
export default {
title: 'Controls/Anchor/Weight',
};
|
src/index.js | jma921/movie-collector | import React from 'react';
import ReactDOM from 'react-dom';
import App from './components';
import './index.css';
ReactDOM.render(<App />, document.getElementById('root'));
|
javascript/book-list/src/containers/book_list.js | sandislonjsak/react-learning-projects | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { selectBook } from '../actions/index';
import { bindActionCreators } from 'redux';
class BookList extends Component {
render() {
return(
<ul className="list-group col-sm-4">
{this.renderList()}
</ul>
);
}
renderList() {
return this.props.books.map(book => {
return (
<li
key={book.title}
onClick={() => this.props.selectBook(book)}
className="list-group-item">
{book.title}
</li>
);
});
}
}
function mapStateToProps(state) {
return {
books: state.books
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators({ selectBook: selectBook }, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(BookList);
|
client/src/views/VCalls/VCalls.js | dmod/fdcallstats.com | import React, { Component } from 'react';
import { Card, CardBody, Col, Row, Table } from 'reactstrap';
class VCalls extends Component {
constructor(props) {
super(props);
this.state = {
message: null,
fetching: true
};
}
componentDidMount() {
fetch('/api/v1/all_calls')
.then(response => {
if (!response.ok) {
throw new Error(`status ${response.status}`);
}
return response.json();
})
.then(json => {
this.setState({
message: json,
fetching: false
});
}).catch(e => {
this.setState({
message: `API call failed: ${e}`,
fetching: false
});
})
}
render() {
return (
<div className="animated fadeIn">
<Row>
<Col>
<Card>
<CardBody>
<Table hover bordered striped responsive size="sm">
<thead>
<tr>
<th>ID</th>
<th>Address</th>
</tr>
</thead>
<tbody>
{!this.state.fetching && this.state.message.map((listValue, index) => {
return (
<tr key={index}>
<td>{listValue.id}</td>
<td>{listValue.address}</td>
</tr>
);
})}
</tbody>
</Table>
</CardBody>
</Card>
</Col>
</Row>
</div>
);
}
}
export default VCalls;
|
packages/material-ui-icons/legacy/BatteryCharging50TwoTone.js | lgollut/material-ui | import React from 'react';
import createSvgIcon from './utils/createSvgIcon';
export default createSvgIcon(
<React.Fragment><path d="M14.47 13.5L11 20v-5.5H9l.53-1H7v7.17C7 21.4 7.6 22 8.33 22h7.33c.74 0 1.34-.6 1.34-1.33V13.5h-2.53z" /><path fillOpacity=".3" d="M15.67 4H14V2h-4v2H8.33C7.6 4 7 4.6 7 5.33v8.17h2.53L13 7v5.5h2l-.53 1H17V5.33C17 4.6 16.4 4 15.67 4z" /></React.Fragment>
, 'BatteryCharging50TwoTone');
|
src/routes/notFound/index.js | KantanGroup/zuzu-sites | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import Layout from '../../components/Layout';
import NotFound from './NotFound';
const title = 'Page Not Found';
export default {
path: '*',
action() {
return {
title,
component: <Layout><NotFound title={title} /></Layout>,
status: 404,
};
},
};
|
blueprints/dumb/files/__root__/components/__name__/__name__.js | thanhiro/techmatrix | import React from 'react'
type Props = {
};
export class <%= pascalEntityName %> extends React.Component {
props: Props;
render () {
return (
<div></div>
)
}
}
export default <%= pascalEntityName %>
|
client/page/home/debug.js | johngodley/redirection | /**
* External dependencies
*/
import React from 'react';
import { translate as __ } from 'i18n-calypso';
import { ExternalLink } from 'wp-plugin-components';
function DebugReport( debug ) {
const email =
'mailto:[email protected]?subject=Redirection%20Error&body=' + encodeURIComponent( debug );
const github =
'https://github.com/johngodley/redirection/issues/new?title=Redirection%20Error&body=' +
encodeURIComponent( '```\n' + debug.trim() + '\n```\n\n' );
return (
<>
<p className="wpl-error__highlight">
{ __( 'Please check the {{link}}support site{{/link}} before proceeding further.', {
components: {
link: <ExternalLink url="https://redirection.me/support/" />,
},
} ) }
</p>
<p>
{ __(
'If that did not help then {{strong}}create an issue{{/strong}} or send it in an {{strong}}email{{/strong}}.',
{
components: {
strong: <strong />,
},
}
) }
</p>
<p>
<a href={ github } className="button-primary">
{ __( 'Create An Issue' ) }
</a>{' '}
<a href={ email } className="button-secondary">
{ __( 'Email' ) }
</a>
</p>
<p>
{ __(
'Include these details in your report along with a description of what you were doing and a screenshot.'
) }
</p>
</>
);
}
export default DebugReport;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.