path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
examples/huge-apps/routes/Course/components/Dashboard.js | emmenko/react-router | import React from 'react';
class Dashboard extends React.Component {
render () {
return (
<div>
<h3>Course Dashboard</h3>
</div>
);
}
}
export default Dashboard;
|
components/object-inspector/object-description.js | scriptit/github-api-gui | import React, { Component } from 'react';
/**
* A short description of the object
*/
export default function ObjectDescription(props) {
const object = props.object;
switch (typeof object){
case 'number':
return (<span className="ObjectInspector-object-value-number">{object}</span>);
case 'string':
return (<span className="ObjectInspector-object-value-string">"{object}"</span>);
case 'boolean':
return (
object
? <span className="ObjectInspector-object-value-boolean">true</span>
: <span className="ObjectInspector-object-value-boolean">false</span>
);
case 'undefined':
return (<span className="ObjectInspector-object-value-undefined">undefined</span>);
case 'object':
if(object === null){
return (<span className="ObjectInspector-object-value-null">null</span>)
}
if(object instanceof Date){
return (<span>{object.toString()}</span>);
}
if(Array.isArray(object)){
return (<span>{`Array[${props.overrideLength || object.length}]`}</span>);
}
return (<span className="ObjectInspector-object-value-object">Object</span>);
case 'function':
return (<span>
<span className="ObjectInspector-object-value-function-keyword">function</span>
<span className="ObjectInspector-object-value-function-name"> {object.name}()</span>
</span>);
case 'symbol':
return (<span className="ObjectInspector-object-value-symbol">Symbol()</span>)
default:
return (<span></span>);
}
}
|
test/test_helper.js | yuvalroth/readux-simple-started-probable-meme | import _$ from 'jquery';
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import jsdom from 'jsdom';
import chai, { expect } from 'chai';
import chaiJquery from 'chai-jquery';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from '../src/reducers';
global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
global.window = global.document.defaultView;
global.navigator = global.window.navigator;
const $ = _$(window);
chaiJquery(chai, chai.util, $);
function renderComponent(ComponentClass, props = {}, state = {}) {
const componentInstance = TestUtils.renderIntoDocument(
<Provider store={createStore(reducers, state)}>
<ComponentClass {...props} />
</Provider>
);
return $(ReactDOM.findDOMNode(componentInstance));
}
$.fn.simulate = function(eventName, value) {
if (value) {
this.val(value);
}
TestUtils.Simulate[eventName](this[0]);
};
export {renderComponent, expect};
|
lens-ui/app/components/QueryParamsComponent.js | guptapuneet/lens | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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';
import { Button, Input } from 'react-bootstrap';
import _ from 'lodash';
import QueryParamRow from './QueryParamRowComponent';
class QueryParams extends React.Component {
constructor (props) {
super(props);
this.state = {
paramChanges: [],
runImmediately: false,
description: props.description
};
this.close = this.close.bind(this);
this.save = this.save.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleCheck = this.handleCheck.bind(this);
this.saveParamChanges = this.saveParamChanges.bind(this);
}
componentWillReceiveProps (props) {
this.setState({description: props.description, paramChanges: []});
}
render () {
let propParams = this.props.params;
if (!propParams) return null;
let changedParams = this.state.paramChanges;
let params = this.mergeParamChanges(propParams, changedParams)
.map(param => {
return (
<QueryParamRow key={param.name} param={param}
saveParamChanges={this.saveParamChanges} />
);
});
return (
<form onSubmit={this.save} style={{padding: '10px', boxShadow: '2px 2px 2px 2px grey',
marginTop: '6px', backgroundColor: 'rgba(255, 255, 0, 0.1)'}}>
<h3>
Query Parameters
</h3>
<table className='table table-striped'>
<thead>
<tr>
<th>Parameter</th>
<th>Display Name</th>
<th>Data Type</th>
<th>Collection Type</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{params}
</tbody>
</table>
<div className='form-group'>
<label className='sr-only' htmlFor='queryDescription'>Description</label>
<input type='text' className='form-control' style={{fontWeight: 'normal'}}
onChange={this.handleChange} id='queryDescription' value={this.state.description}
placeholder='(Optional description) e.g. This awesome query does magic along with its job.'
/>
</div>
<div>
<Input type='checkbox' label='Run after saving'
onChange={this.handleCheck} />
</div>
<Button bsStyle='primary' type='submit'>Save</Button>
<Button onClick={this.close} style={{marginLeft: '4px'}}>Cancel</Button>
</form>
);
}
close () {
this.props.close();
}
save (e) {
e.preventDefault();
// merges the initial props and the delta changes done by child components
var parameters = this.mergeParamChanges(this.props.params, this.state.paramChanges);
this.props.saveParams({
parameters: parameters,
description: this.state.description,
runImmediately: this.state.runImmediately
});
}
handleChange (e) {
this.setState({ description: e.target.value });
}
handleCheck (e) {
this.setState({ runImmediately: e.target.checked });
}
mergeParamChanges (original = [], changes = []) {
return original.map(originalParam => {
let change = changes.filter(changedParam => {
return changedParam.name === originalParam.name;
});
return _.assign({}, originalParam, change[0]);
});
}
saveParamChanges (changedParam) {
// getting the param from the paramChanges state.
var param = this.state.paramChanges.filter(param => {
return param.name === changedParam.name;
})[0];
// apply the changedParam over the above param.
var newParam = _.assign({}, param, changedParam);
// getting all the other changes except the current as
// we want to over-write it
var newChangedParams = this.state.paramChanges.filter(param => {
return param.name !== newParam.name;
});
this.setState({paramChanges: [...newChangedParams, newParam]});
}
}
QueryParams.propTypes = {
params: React.PropTypes.array.isRequired,
close: React.PropTypes.func.isRequired,
saveParams: React.PropTypes.func.isRequired
};
export default QueryParams;
|
ui/src/main/js/components/UpdateDiff.js | crashlytics/aurora | import React from 'react';
import Diff from 'components/Diff';
import PanelGroup, { Container, StandardPanelTitle } from 'components/Layout';
import { instanceRangeToString } from 'utils/Task';
export default class UpdateDiff extends React.Component {
constructor(props) {
super(props);
this.state = {groupIdx: 0};
}
diffNavigation() {
const that = this;
const { initialState } = this.props.update.update.instructions;
const currentGroup = initialState[this.state.groupIdx];
if (initialState.length < 2) {
return '';
} else {
const otherOptions = initialState.map((g, i) => i).filter((i) => i !== that.state.groupIdx);
return (<div className='update-diff-picker'>
Current Instances:
<select onChange={(e) => this.setState({groupIdx: parseInt(e.target.value, 10)})}>
<option key='current'>{instanceRangeToString(currentGroup.instances)}</option>
{otherOptions.map((i) => (<option key={i} value={i}>
{instanceRangeToString(initialState[i].instances)}
</option>))}
</select>
</div>);
}
}
render() {
const { initialState, desiredState } = this.props.update.update.instructions;
return (<Container>
<PanelGroup noPadding title={<StandardPanelTitle title='Update Diff' />}>
<div className='task-diff'>
{this.diffNavigation()}
<Diff left={initialState[this.state.groupIdx].task} right={desiredState.task} />
</div>
</PanelGroup>
</Container>);
}
}
|
app/javascript/mastodon/features/notifications/components/notification.js | SerCom-KC/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import StatusContainer from '../../../containers/status_container';
import AccountContainer from '../../../containers/account_container';
import { injectIntl, FormattedMessage } from 'react-intl';
import Permalink from '../../../components/permalink';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { HotKeys } from 'react-hotkeys';
const notificationForScreenReader = (intl, message, timestamp) => {
const output = [message];
output.push(intl.formatDate(timestamp, { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' }));
return output.join(', ');
};
export default @injectIntl
class Notification extends ImmutablePureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
notification: ImmutablePropTypes.map.isRequired,
hidden: PropTypes.bool,
onMoveUp: PropTypes.func.isRequired,
onMoveDown: PropTypes.func.isRequired,
onMention: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
handleMoveUp = () => {
const { notification, onMoveUp } = this.props;
onMoveUp(notification.get('id'));
}
handleMoveDown = () => {
const { notification, onMoveDown } = this.props;
onMoveDown(notification.get('id'));
}
handleOpen = () => {
const { notification } = this.props;
if (notification.get('status')) {
this.context.router.history.push(`/statuses/${notification.get('status')}`);
} else {
this.handleOpenProfile();
}
}
handleOpenProfile = () => {
const { notification } = this.props;
this.context.router.history.push(`/accounts/${notification.getIn(['account', 'id'])}`);
}
handleMention = e => {
e.preventDefault();
const { notification, onMention } = this.props;
onMention(notification.get('account'), this.context.router.history);
}
getHandlers () {
return {
moveUp: this.handleMoveUp,
moveDown: this.handleMoveDown,
open: this.handleOpen,
openProfile: this.handleOpenProfile,
mention: this.handleMention,
reply: this.handleMention,
};
}
renderFollow (notification, account, link) {
const { intl } = this.props;
return (
<HotKeys handlers={this.getHandlers()}>
<div className='notification notification-follow focusable' tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage({ id: 'notification.follow', defaultMessage: '{name} followed you' }, { name: account.get('acct') }), notification.get('created_at'))}>
<div className='notification__message'>
<div className='notification__favourite-icon-wrapper'>
<i className='fa fa-fw fa-user-plus' />
</div>
<FormattedMessage id='notification.follow' defaultMessage='{name} followed you' values={{ name: link }} />
</div>
<AccountContainer id={account.get('id')} withNote={false} hidden={this.props.hidden} />
</div>
</HotKeys>
);
}
renderMention (notification) {
return (
<StatusContainer
id={notification.get('status')}
withDismiss
hidden={this.props.hidden}
onMoveDown={this.handleMoveDown}
onMoveUp={this.handleMoveUp}
contextType='notifications'
/>
);
}
renderFavourite (notification, link) {
const { intl } = this.props;
return (
<HotKeys handlers={this.getHandlers()}>
<div className='notification notification-favourite focusable' tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage({ id: 'notification.favourite', defaultMessage: '{name} favourited your status' }, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}>
<div className='notification__message'>
<div className='notification__favourite-icon-wrapper'>
<i className='fa fa-fw fa-star star-icon' />
</div>
<FormattedMessage id='notification.favourite' defaultMessage='{name} favourited your status' values={{ name: link }} />
</div>
<StatusContainer id={notification.get('status')} account={notification.get('account')} muted withDismiss hidden={!!this.props.hidden} />
</div>
</HotKeys>
);
}
renderReblog (notification, link) {
const { intl } = this.props;
return (
<HotKeys handlers={this.getHandlers()}>
<div className='notification notification-reblog focusable' tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage({ id: 'notification.reblog', defaultMessage: '{name} boosted your status' }, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}>
<div className='notification__message'>
<div className='notification__favourite-icon-wrapper'>
<i className='fa fa-fw fa-retweet' />
</div>
<FormattedMessage id='notification.reblog' defaultMessage='{name} boosted your status' values={{ name: link }} />
</div>
<StatusContainer id={notification.get('status')} account={notification.get('account')} muted withDismiss hidden={this.props.hidden} />
</div>
</HotKeys>
);
}
render () {
const { notification } = this.props;
const account = notification.get('account');
const displayNameHtml = { __html: account.get('display_name_html') };
const link = <bdi><Permalink className='notification__display-name' href={account.get('url')} title={account.get('acct')} to={`/accounts/${account.get('id')}`} dangerouslySetInnerHTML={displayNameHtml} /></bdi>;
switch(notification.get('type')) {
case 'follow':
return this.renderFollow(notification, account, link);
case 'mention':
return this.renderMention(notification);
case 'favourite':
return this.renderFavourite(notification, link);
case 'reblog':
return this.renderReblog(notification, link);
}
return null;
}
}
|
wawhfd/static/src/js/components/calendar.js | calebrash/wawhfd | import React, { Component } from 'react';
import api from '../api';
export default class CalendarList extends Component {
getCalendarItems () {
return this.props.data.map((d) => <CalendarItem data={d} key={d.key} />);
}
render () {
return <div className="calendar">{this.getCalendarItems()}</div>;
}
}
class CalendarItem extends Component {
constructor (props) {
super(props);
this.state = props.data;
this.state.over = false;
this.onDragEnter = this.onDragEnter.bind(this);
this.onDragLeave = this.onDragLeave.bind(this);
this.onDrop = this.onDrop.bind(this);
this.onClickDelete = this.onClickDelete.bind(this);
this.dragCounter = 0;
}
componentWillReceiveProps (props) {
let data = props.data;
if (!props.data.recipe) {
data.recipe = null;
}
this.setState(data);
}
onDragEnter (e) {
e.preventDefault();
this.dragCounter ++;
this.setState({
over: true
});
}
onDragLeave (e) {
this.dragCounter --;
if (this.dragCounter === 0) {
this.setState({
over: false
});
}
}
onDragOver (e) {
e.preventDefault();
}
onDrop (e) {
let recipe = JSON.parse(e.dataTransfer.getData('text/plain'));
api.post(`dates/${this.state.date}/edit`, recipe).then(this.setState({
over: false,
recipe: recipe
}));
}
onClickDelete (e) {
e.preventDefault();
api.post(`dates/${this.state.date}/delete`).then(this.setState({
recipe: null
}));
}
getClassNames () {
let classes = 'calendar-item row';
if (!this.state.recipe || this.state.over) {
classes += ' droppable';
}
if (this.state.over) {
classes += ' drag-over';
}
return classes;
}
renderRecipe () {
if (this.state.recipe) {
return (
<p>
{this.state.recipe.name}
<a href="#" onClick={this.onClickDelete}>×</a>
</p>
);
}
return '';
}
render () {
return (
<div className={this.getClassNames()} onDragEnter={this.onDragEnter} onDragLeave={this.onDragLeave}>
<h2 title={this.state.date_string}>{this.state.title}</h2>
<div className="drop-target" onDragOver={this.onDragOver} onDrop={this.onDrop}>
Drop recipe here
</div>
<div className="recipe">
{this.renderRecipe()}
</div>
</div>
);
}
}
|
src/pages/Application/NeedToConfirmEmailDialog.js | BoilerMake/frontend | import React from 'react';
const NeedToConfirmEmailDialog = () => {
return (
<p>
Hey! <br/><br/>
Check your inbox for an email from hello@boilermake.org. Click the
link to verify your email then you can continue your application.
</p>
);
};
export default NeedToConfirmEmailDialog;
|
tp-3/sebareverso/src/components/pages/alumnos/components/form/AlumnoForm.js | jpgonzalezquinteros/sovos-reactivo-2017 | import React from 'react';
import Paper from 'material-ui/Paper';
import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
import '../../../../app.scss';
class AlumnoForm extends React.Component {
constructor(){
super();
this.alumno = {
apellido: "",
nombre: "",
dni: "",
fechaNac: "",
estado: ""
};
}
componentDidUpdate(){
this.alumno = {};
}
handleApellidoChange =(evt)=>{
this.alumno.apellido = evt.target.value;
}
handleNombreChange =(evt)=>{
this.alumno.nombre = evt.target.value;
}
handleDniChange =(evt)=>{
this.alumno.dni = evt.target.value;
}
handleFechaNacChange =(evt)=>{
this.alumno.fechaNac = evt.target.value;
}
handleEstadoChange =(evt)=>{
this.alumno.estado = evt.target.value;
}
handleSaveClick =()=>{
this.props.onNewAlumno(this.alumno);
this.alumno={};
}
render() {
return (
<div>
<Paper zDepth={2} className="paperStyle" id={"alumno-form"}>
<br/>
<h2 className="alt-header">Formulario Alumno </h2>
<br/>
<TextField floatingLabelText={"Apellido"} onChange={this.handleApellidoChange}/><br/>
<TextField floatingLabelText={"Nombre"} onChange={this.handleNombreChange}/><br/>
<TextField floatingLabelText={"DNI"} onChange={this.handleDniChange}/><br/>
<TextField floatingLabelText={"Fecha de Nacimiento"} onChange={this.handleFechaNacChange}/><br/>
<TextField floatingLabelText={"Estado"} onChange={this.handleEstadoChange}/><br/><br/>
<RaisedButton label={"Guardar"} primary={true} className="buttonStyle" onClick={this.handleSaveClick}/>
<br/>
</Paper>
</div>
);
}
}
export default AlumnoForm;
|
src/frontend/components/forms/GCPasswordField.js | Bernie-2016/ground-control | import React from 'react';
import {TextField} from 'material-ui';
import {BernieText} from '../styles/bernie-css';
import GCFormField from './GCFormField';
export default class GCPasswordField extends GCFormField {
render() {
return <TextField
{...this.props}
floatingLabelText={this.floatingLabelText()}
type='password'
errorStyle={BernieText.inputError}
hintText={this.props.label}
onChange={(event) => {this.props.onChange(event.target.value)}}
/>
}
} |
src/providers/PopupProvider.js | talibasya/redux-store-ancillary | import React from 'react'
class PopupProvider extends React.Component {
render () {
const { children, popup } = this.props
const Parent = React.cloneElement(children)
let modifiedChildren = []
React.Children.forEach(children, child => {
React.Children.forEach(child.props.children, child2 => {
const currentPopup = popup.find(popup => popup.name === child2.props.name)
const params = currentPopup ? currentPopup.params : undefined
const open = !!currentPopup
const clonedElement = React.cloneElement(child2, { open, params });
modifiedChildren.push(clonedElement)
})
})
// console.log('children2', modifiedChildren[0]);
return (
<Parent.type {...Parent.props} >
{modifiedChildren.map(Component => <Component.type {...Component.props} key={Component.props.name} />) }
</Parent.type>
)
}
}
export default PopupProvider
|
src/MessagePanel/index.js | oneteam-dev/react-oneteam | import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import styles from './index.css';
const MessagePanel = props => {
return (
<div {...props} className={classNames(styles.root, props.className)}>
{props.children}
</div>
);
};
MessagePanel.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
};
export const Body = props => {
return (
<div {...props} className={classNames(styles.body, props.className)}>
{props.children}
</div>
);
};
Body.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
};
export const Footer = props => {
return (
<div {...props} className={classNames(styles.footer, props.className)}>
{props.children}
</div>
);
};
Footer.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
};
MessagePanel.Footer = Footer;
MessagePanel.Body = Body;
export default MessagePanel;
|
src/components/Canvas/Canvas.js | dotlouis/reactive-show | import './Canvas.css';
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import { SvgNode } from '../SvgNode/SvgNode';
import Action from '../Action/Action';
const mapStateToProps = state => ({
nodes: state.nodes,
});
class Canvas extends React.Component {
static propTypes = {
nodes: PropTypes.array.isRequired,
};
constructor(props) {
super(props);
this.state = {};
}
onOpenControlsHandler = node => {
this.setState({
node,
isActionOpen: true,
});
};
onCloseControlsHandler = () => {
this.setState({ isActionOpen: false });
};
render() {
const { nodes } = this.props;
return (
<div className="CanvasWrapper">
<svg className="SvgCanvas">
{nodes.map(node => (
<SvgNode
key={node.id}
node={node}
onOpenControls={this.onOpenControlsHandler}
/>
))}
</svg>
<div className="HtmlCanvas">
<Action
node={this.state.node}
opened={this.state.isActionOpen}
onCloseControls={this.onCloseControlsHandler}
/>
</div>
</div>
);
}
}
export default connect(mapStateToProps, null)(Canvas);
|
src/components/App.js | joynal/flashcard | import React from 'react'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import AppBar from 'material-ui/AppBar'
import Tabs from './AppTabs'
import AddCard from './CardAction'
const App = () => (
<MuiThemeProvider>
<div>
<AppBar title='Flashcard'/>
<Tabs/>
<AddCard/>
</div>
</MuiThemeProvider>
)
export default App
|
packages/react-scripts/fixtures/kitchensink/src/index.js | ro-savage/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'));
|
src/index.js | yarikgenza/gainster | import React, { Component } from 'react';
import { Provider } from 'mobx-react';
import { StackNavigator } from 'react-navigation';
import { StyleSheet } from 'react-native';
import { Container, Content, Text, StyleProvider } from 'native-base';
import stores from './stores';
import getTheme from './themes/components';
import { screens } from './screens';
// Define navigator
const Navigator = StackNavigator(screens, { headerMode: 'none', initialRouteName: 'Start', });
class App extends Component {
render = () => (
<StyleProvider style={getTheme()}>
<Provider {...stores}>
<Navigator />
</Provider>
</StyleProvider>
);
}
export { App }; |
components/modal/src/Modal.js | fi11/uikit | 'use strict';
import React from 'react';
import PropTypes from 'prop-types';
import Teleport, { TeleportContext } from '@uikit/teleport';
import Transition from '@uikit/transition';
import AutoClosable from '@uikit/autoclosable';
const rootStyles = {
position: 'fixed',
top: 0,
right: 0,
left: 0,
bottom: 0,
zIndex: 9999,
background: 'transparent',
overflow: 'auto',
};
const getParentDOMNodeWithScroll = parentDOMNode => {
if (!parentDOMNode) {
return null;
}
const clientWidth = parentDOMNode.clientWidth;
const clientHeight = parentDOMNode.clientHeight;
const scrollWidth = parentDOMNode.scrollWidth;
const scrollHeight = parentDOMNode.scrollHeight;
if (clientWidth === undefined) {
return null;
}
if (clientWidth || clientHeight) {
const isCanScroll = ['overflow', 'overflow-x', 'overflow-y'].some(key => {
return /auto|scroll/.test(window.getComputedStyle(parentDOMNode)[key]);
});
if (
isCanScroll &&
(clientWidth !== scrollWidth || clientHeight !== scrollHeight)
) {
return parentDOMNode;
}
}
return getParentDOMNodeWithScroll(parentDOMNode.parentNode);
};
export default class Modal extends React.Component {
static propTypes = {
isShown: PropTypes.bool,
onDidClose: PropTypes.func,
onDidShow: PropTypes.func,
isAutoClosable: PropTypes.bool,
onRequestClose: PropTypes.func,
};
constructor(props, ...args) {
super(props, ...args);
this.state = {
isShown: false,
};
this._onShowHandler = this._onShowHandler.bind(this);
this._onCloseHandler = this._onCloseHandler.bind(this);
this._onDidLeaveHandler = this._onDidLeaveHandler.bind(this);
this._isBodyScrollDisabled = null;
this._prevBodyOverflow = null;
this._onDidShowCallbacks = [];
this._onDidHideCallbacks = [];
}
componentDidMount() {
this.props.isShown && this.show();
}
componentWillUnmount() {
this._enableRootScroll();
}
componentWillReceiveProps(nextProps) {
if (nextProps.isShown !== this.props.isShown) {
nextProps.isShown ? this.show() : this.hide();
}
}
show(callback: () => void) {
callback && this._onDidShowCallbacks.push(callback);
this.setState({ isShown: true }, () => this._disableRootScroll());
}
hide(callback: () => void) {
callback && this._onDidHideCallbacks.push(callback);
this.setState({ isShown: false });
}
_renderChildren() {
const props = this.props;
return React.Children.map(props.children, child => {
if (child && child.type && child.type.__MODAL_HEADER__) {
return React.cloneElement(child, {
onClose: props.onClose,
});
}
return child;
});
}
_disableRootScroll() {
if (typeof document !== 'undefined' && !this._isBodyScrollDisabled) {
let parentDOMNodeWithScroll = this._getParentDOMNodeWithScroll();
this._isBodyScrollDisabled = true;
this._prevBodyOverflow = parentDOMNodeWithScroll.style.overflow;
parentDOMNodeWithScroll.style.overflow = 'hidden';
}
}
_enableRootScroll() {
if (typeof document !== 'undefined' && this._isBodyScrollDisabled) {
this._isBodyScrollDisabled = false;
this._getParentDOMNodeWithScroll().style.overflow = this._prevBodyOverflow;
}
}
_onShowHandler() {
const callbacks = this._onDidShowCallbacks;
this._onDidShowCallbacks = [];
callbacks.forEach(callback => callback());
this.props.onDidShow && this.props.onDidShow();
}
_onCloseHandler() {
const { isAutoClosable, onRequestClose } = this.props;
isAutoClosable && onRequestClose && onRequestClose();
}
_onDidLeaveHandler() {
const callbacks = this._onDidHideCallbacks;
this._onDidHideCallbacks = [];
callbacks.forEach(callback => callback());
this._enableRootScroll();
this.props.onDidClose && this.props.onDidClose();
}
_getParentDOMNodeWithScroll() {
if (!this._parentDOMNodeWithScroll) {
const rootDOMNode = this._getRootDOMNode();
this._parentDOMNodeWithScroll =
(rootDOMNode && getParentDOMNodeWithScroll(rootDOMNode)) ||
document.getElementsByTagName('body')[0];
}
return this._parentDOMNodeWithScroll;
}
_getRootDOMNode() {
if (!this._teleport) {
return null;
}
if (!this._rootDOMNode) {
this._rootDOMNode = this._teleport.getRootDOMNode();
}
return this._rootDOMNode;
}
_renderOverlay = props => {
const { overlayRenderer } = this.props;
return typeof overlayRenderer === 'function'
? overlayRenderer({ ...props })
: null;
};
_renderBody = props => {
const { bodyRenderer, children } = this.props;
return typeof bodyRenderer === 'function'
? bodyRenderer({ ...props, children })
: children;
};
render() {
const { enterTimeout, leaveTimeout, updateTimeout, timeout } = this.props;
const { isShown } = this.state;
return (
<Teleport ref={c => (this._teleport = c)}>
<Transition
timeout={timeout}
enterTimeout={enterTimeout}
leaveTimeout={leaveTimeout}
updateTimeout={updateTimeout}
isImmediatelyUpdate={true}
onDidEnter={this._onShowHandler}
onDidLeave={this._onDidLeaveHandler}
>
{isShown ? (
({ isEnter, isLeave, isUpdate, isAppear, isInit }) => (
<div style={rootStyles}>
{this._renderOverlay({
isEnter,
isLeave,
isUpdate,
isAppear,
isInit,
})}
<AutoClosable onRequestClose={this._onCloseHandler}>
{this._renderBody({
isEnter,
isLeave,
isUpdate,
isAppear,
isInit,
})}
</AutoClosable>
</div>
)
) : null}
</Transition>
</Teleport>
);
}
}
|
node_modules/react-native/local-cli/templates/HelloNavigation/views/welcome/WelcomeText.ios.js | hpdmitriy/Bjj4All | 'use strict';
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native';
export default class WelcomeText extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
This app shows the basics of navigating between a few screens,
working with ListView and handling text input.
</Text>
<Text style={styles.instructions}>
Modify any files to get started. For example try changing the
file{'\n'}views/welcome/WelcomeText.ios.js.
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu.
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
padding: 20,
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 16,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 12,
},
});
|
bdocker/bnodejs/gatsby/web/pages/postcss.js | waterbolik/prestudy | import React from 'react'
import './example.css'
import Helmet from 'react-helmet'
import { config } from 'config'
export default class PostCSS extends React.Component {
render () {
return (
<div>
<Helmet
title={`${config.siteTitle} | Hi PostCSSy friends`}
/>
<h1 className="the-postcss-class">
Hi PostCSSy friends
</h1>
<div className="postcss-nav-example">
<h2>Nav example</h2>
<ul>
<li>
<a href="#">Store</a>
</li>
<li>
<a href="#">Help</a>
</li>
<li>
<a href="#">Logout</a>
</li>
</ul>
</div>
</div>
)
}
}
|
app/containers/ChatPage/index.js | dvm4078/dvm-blog | /**
*
* ChatPage
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { compose } from 'redux';
import injectSaga from 'utils/injectSaga';
import injectReducer from 'utils/injectReducer';
import makeSelectChatPage from './selectors';
import reducer from './reducer';
import saga from './saga';
export class ChatPage extends React.Component { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<div className="container-fluid">
<div className="row page-titles">
<div className="col-md-5 align-self-center">
<h3 className="text-themecolor">Chats</h3>
</div>
<div className="col-md-7 align-self-center">
<ol className="breadcrumb">
<li className="breadcrumb-item"><a>Home</a></li>
<li className="breadcrumb-item">Apps</li>
<li className="breadcrumb-item active">Chats</li>
</ol>
</div>
<div className="">
<button className="right-side-toggle waves-effect waves-light btn-inverse btn btn-circle btn-sm pull-right m-l-10">
<i className="ti-settings text-white"></i>
</button>
</div>
</div>
<div className="row">
<div className="col-12">
<div className="card m-b-0">
<div className="chat-main-box">
<div className="chat-left-aside">
<div className="open-panel"><i className="ti-angle-right"></i></div>
<div className="chat-left-inner">
<div className="form-material">
<input className="form-control p-20" type="text" placeholder="Search Contact" />
</div>
<ul className="chatonline style-none ">
<li>
<a>
<img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/1.jpg" alt="user-img" className="img-circle" />
<span>Varun Dhavan <small className="text-success">online</small></span>
</a>
</li>
<li>
<a className="active">
<img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/2.jpg" alt="user-img" className="img-circle" />
<span>Genelia Deshmukh <small className="text-warning">Away</small></span>
</a>
</li>
<li>
<a>
<img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/3.jpg" alt="user-img" className="img-circle" />
<span>Ritesh Deshmukh <small className="text-danger">Busy</small></span>
</a>
</li>
<li>
<a>
<img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/4.jpg" alt="user-img" className="img-circle" />
<span>Arijit Sinh <small className="text-muted">Offline</small></span>
</a>
</li>
<li>
<a>
<img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/5.jpg" alt="user-img" className="img-circle" />
<span>Govinda Star <small className="text-success">online</small></span>
</a>
</li>
<li>
<a>
<img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/6.jpg" alt="user-img" className="img-circle" />
<span>John Abraham<small className="text-success">online</small></span>
</a>
</li>
<li>
<a>
<img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/7.jpg" alt="user-img" className="img-circle" />
<span>Hritik Roshan<small className="text-success">online</small></span>
</a>
</li>
<li>
<a>
<img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/8.jpg" alt="user-img" className="img-circle" />
<span>Pwandeep rajan <small className="text-success">online</small></span>
</a>
</li>
<li className="p-20"></li>
</ul>
</div>
</div>
<div className="chat-right-aside">
<div className="chat-main-header">
<div className="p-20 b-b">
<h3 className="box-title">Chat Message</h3>
</div>
</div>
<div className="chat-rbox">
<ul className="chat-list p-20">
<li>
<div className="chat-img"><img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/1.jpg" alt="user" /></div>
<div className="chat-content">
<h5>James Anderson</h5>
<div className="box bg-light-info">Lorem Ipsum is simply dummy text of the printing & type setting industry.</div>
</div>
<div className="chat-time">10:56 am</div>
</li>
<li>
<div className="chat-img"><img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/2.jpg" alt="user" /></div>
<div className="chat-content">
<h5>Bianca Doe</h5>
<div className="box bg-light-info">It’s Great opportunity to work.</div>
</div>
<div className="chat-time">10:57 am</div>
</li>
<li className="reverse">
<div className="chat-content">
<h5>Steave Doe</h5>
<div className="box bg-light-inverse">It’s Great opportunity to work.</div>
</div>
<div className="chat-img"><img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/5.jpg" alt="user" /></div>
<div className="chat-time">10:57 am</div>
</li>
<li className="reverse">
<div className="chat-content">
<h5>Steave Doe</h5>
<div className="box bg-light-inverse">It’s Great opportunity to work.</div>
</div>
<div className="chat-img"><img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/5.jpg" alt="user" /></div>
<div className="chat-time">10:57 am</div>
</li>
<li>
<div className="chat-img"><img src="https://wrappixel.com/demos/admin-templates/admin-pro/assets/images/users/3.jpg" alt="user" /></div>
<div className="chat-content">
<h5>Angelina Rhodes</h5>
<div className="box bg-light-info">Well we have good budget for the project</div>
</div>
<div className="chat-time">11:00 am</div>
</li>
</ul>
</div>
<div className="card-body b-t">
<div className="row">
<div className="col-8">
<textarea placeholder="Type your message here" className="form-control b-0"></textarea>
</div>
<div className="col-4 text-right">
<button type="button" className="btn btn-info btn-circle btn-lg"><i className="fa fa-paper-plane-o"></i> </button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
}
}
ChatPage.propTypes = {
dispatch: PropTypes.func.isRequired,
};
const mapStateToProps = createStructuredSelector({
chatpage: makeSelectChatPage(),
});
function mapDispatchToProps(dispatch) {
return {
dispatch,
};
}
const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withReducer = injectReducer({ key: 'chatPage', reducer });
const withSaga = injectSaga({ key: 'chatPage', saga });
export default compose(
withReducer,
withSaga,
withConnect,
)(ChatPage);
|
client/pages/campaign.js | quarterto/almanac | import React from 'react'
import { withTracker } from 'meteor/react-meteor-data'
import { compose, withHandlers } from 'recompact'
import _ from 'lodash'
import { withCampaignData } from '../data/campaign'
import { CampaignSplash } from '../visual/splash'
import Title from '../utils/title'
import CardList from '../collection/card-list'
import { SplashToolbar, MenuLink, Space, Center } from '../visual/menu'
import Icon from '../visual/icon'
import Search from '../collection/card-search'
import HistoryList from '../collection/card-history'
import { Main, Aside } from '../visual/grid'
import { Card } from '../../shared/methods'
import { go, state, history } from '../utils/router'
import { withState } from 'recompact'
import { withPropsOnChange } from 'recompact'
const withSearchState = withState('_search', '_setSearch', '')
const setSearch = search => go(history.get(), { search })
const debouncedSetSearch = _.debounce(setSearch, 300)
const withCampaignSearch = withTracker(({ _setSearch }) => ({
search: (state.get() || {}).search,
setSearch(search) {
_setSearch(search)
debouncedSetSearch(search)
},
}))
const withCreateCardSearchAction = withHandlers({
searchAction: ({ search, setSearch, campaign }) => async () => {
const { _id } = await Card.create({
title: search,
campaignId: campaign._id,
})
setSearch('')
go(`/${campaign._id}/${_id}`)
},
})
const connectCampaignPage = compose(
withCampaignData,
withSearchState,
withCampaignSearch,
withCreateCardSearchAction,
withPropsOnChange('search', ({ search, _setSearch }) => {
_setSearch(search)
}),
)
export default connectCampaignPage(
({ campaign, search, _search, setSearch, searchAction }) => (
<>
<Title>{campaign.title}</Title>
<CampaignSplash />
<SplashToolbar>
<Center>
<Search
value={_search}
searchAction={searchAction}
onChange={setSearch}
/>
<Space />
<MenuLink href={`/${campaign._id}/new`}>
<Icon icon='file-text-o' /> New
</MenuLink>
</Center>
</SplashToolbar>
<Main left>
<CardList search={search} />
</Main>
<Aside>
<HistoryList />
</Aside>
</>
),
)
|
index.js | alekhurst/react-native-elevated-view | import React from 'react';
import PropTypes from 'prop-types';
import { View, Platform } from 'react-native';
export default class ElevatedView extends React.Component {
static propTypes = {
elevation: PropTypes.number,
};
static defaultProps = {
elevation: 0
};
render() {
const { elevation, style, ...otherProps } = this.props;
if (Platform.OS === 'android') {
return (
<View elevation={elevation} style={[{ elevation, backgroundColor: 'white' }, style ]} {...otherProps}>
{this.props.children}
</View>
);
}
if (elevation === 0) {
return (
<View style={style} {...otherProps}>
{this.props.children}
</View>
)
}
//calculate iosShadows here
const iosShadowElevation = {
shadowOpacity: 0.0015 * elevation + 0.18,
shadowRadius: 0.54 * elevation,
shadowOffset: {
height: 0.6 * elevation,
},
};
return (
<View style={[iosShadowElevation, style]} {...otherProps}>
{this.props.children}
</View>
);
}
}
|
src/common/components/MarkdownEditor.js | dillonliang224/React-CMS | import React from 'react';
var ReactMarkdown = require('react-markdown');
var input = '# This is a header\n\nAnd this is a paragraph';
class MarkdownEditor extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h2>Edit Article Page</h2>
<ReactMarkdown source={ input } />
</div>
);
}
}
export default MarkdownEditor;
/*
use https://www.npmjs.com/package/react-markdown
use markdown to edit article.
*/
|
Console/app/node_modules/rc-calendar/es/MonthCalendar.js | RisenEsports/RisenEsports.github.io | import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import KeyCode from 'rc-util/es/KeyCode';
import MonthPanel from './month/MonthPanel';
import CalendarMixin from './mixin/CalendarMixin';
import CommonMixin from './mixin/CommonMixin';
var MonthCalendar = createReactClass({
displayName: 'MonthCalendar',
propTypes: {
monthCellRender: PropTypes.func,
dateCellRender: PropTypes.func
},
mixins: [CommonMixin, CalendarMixin],
onKeyDown: function onKeyDown(event) {
var keyCode = event.keyCode;
var ctrlKey = event.ctrlKey || event.metaKey;
var stateValue = this.state.value;
var disabledDate = this.props.disabledDate;
var value = stateValue;
switch (keyCode) {
case KeyCode.DOWN:
value = stateValue.clone();
value.add(3, 'months');
break;
case KeyCode.UP:
value = stateValue.clone();
value.add(-3, 'months');
break;
case KeyCode.LEFT:
value = stateValue.clone();
if (ctrlKey) {
value.add(-1, 'years');
} else {
value.add(-1, 'months');
}
break;
case KeyCode.RIGHT:
value = stateValue.clone();
if (ctrlKey) {
value.add(1, 'years');
} else {
value.add(1, 'months');
}
break;
case KeyCode.ENTER:
if (!disabledDate || !disabledDate(stateValue)) {
this.onSelect(stateValue);
}
event.preventDefault();
return 1;
default:
return undefined;
}
if (value !== stateValue) {
this.setValue(value);
event.preventDefault();
return 1;
}
},
render: function render() {
var props = this.props;
var children = React.createElement(MonthPanel, {
locale: props.locale,
disabledDate: props.disabledDate,
style: { position: 'relative' },
value: this.state.value,
cellRender: props.monthCellRender,
contentRender: props.monthCellContentRender,
rootPrefixCls: props.prefixCls,
onChange: this.setValue,
onSelect: this.onSelect
});
return this.renderRoot({
children: children
});
}
});
export default MonthCalendar; |
entry/components/musiclistitem.js | xiaololo/react-music-player | import React from 'react'
import './musiclistitem.less'
import Pubsub from 'pubsub-js'
let MusicListItem = React.createClass({
playMusic(musicItem) {
Pubsub.publish('PLAY_MUSIC', musicItem);
},
deleteMusic(musicItem, e) {
e.stopPropagation();
Pubsub.publish('DELETE_MUSIC', musicItem);
},
render() {
let musicItem = this.props.musicItem;
return (
<li onClick={this.playMusic.bind(this,musicItem)} className={`components-musiclistitem row ${this.props.focus ?'focus':''}`}>
<p><strong>{musicItem.title}</strong>-{musicItem.artist}</p>
<p onClick={this.deleteMusic.bind(this,musicItem)} className="-col-auto delete"></p>
</li>
)
}
})
export default MusicListItem; |
hw5/src/components/main/main.js | MinZhou2016/comp531 | import React, { Component } from 'react';
import HeadLine from './headline';
import Followers from './following';
import ArticlesView from '../article/articlesView';
const Main = () =>{
return (
<div className="main container-fluid">
<div className="row">
<div className="col-md-3">
<HeadLine />
<Followers />
</div>
<div className="col-md-8">
<ArticlesView />
</div>
</div>
</div>
)
}
export default Main;
|
lib/server.js | kodyl/react-document-meta | import DocumentMeta, { render } from './index';
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
function rewindAsStaticMarkup() {
const tags = render(DocumentMeta.rewind());
return renderToStaticMarkup(<div>{tags}</div>)
.replace(/(^<div>|<\/div>$)/g, '')
.replace(/data-rdm="true"/g, 'data-rdm');
}
export default DocumentMeta;
DocumentMeta.renderToStaticMarkup = rewindAsStaticMarkup;
DocumentMeta.renderAsHTML = rewindAsStaticMarkup;
|
src/js/sections/Title1.js | lianwangtao/shanelian.com | import React from 'react';
import scrollToElement from 'scroll-to-element';
import classnames from 'classnames';
import Headline from 'grommet/components/Headline';
import Anchor from 'grommet/components/Anchor';
import Paragraph from 'grommet/components/Paragraph';
import Box from 'grommet/components/Box';
import Value from 'grommet/components/Value';
import Image from 'grommet/components/Image';
import InfographicSection from '../components/InfographicSection';
const CLASS_ROOT = "title-section";
export default function Title1 () {
const classes = classnames([
CLASS_ROOT,
`${CLASS_ROOT}--left-align`,
`${CLASS_ROOT}--column-reverse`
]);
return (
<InfographicSection
className={classes}
id="AboutMe"
direction="row"
colorIndex="neutral-4-t"
style={{
backgroundImage: "#7f00ff", /* fallback for old browsers */
backgroundImage: "-webkit-linear-gradient(to right, #7f00ff, #e100ff)", /* Chrome 10-25, Safari 5.1-6 */
backgroundImage: "linear-gradient(to right, #7f00ff, #e100ff)" /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}}
>
<Box className={`${CLASS_ROOT}__col-2`} direction="column" alignContent="start">
<Headline className={`${CLASS_ROOT}__title`} size="large" strong={true} style={{fontFamily: 'Product Sans'}}>Who is Shane?</Headline>
<Paragraph size='large' style={{fontFamily: 'Roboto'}}>
Shane (Wangtao) Lian was born in <Value value={1995} size="small" responsive style={{paddingLeft: 3}}/> in Haining, China. He spent most of his life (16 years to be exact) in
<Anchor href='https://www.lonelyplanet.com/china/zhejiang/hangzhou'><Value value={"Hangzhou, China"} size="small" responsive style={{paddingLeft: 3}}/></Anchor>,
a beautiful city with a growing high-tech industry.
</Paragraph>
<Paragraph
size='large'
style={{fontFamily: 'Roboto'}}
>
From
<Value
value={2014}
size="small"
responsive
style={{paddingLeft: 3}}
/>
, he started studying at the University of Wisconsin-Madison majoring
<Anchor
href='https://www.cs.wisc.edu/'
>
<Value
value={"Computer Sciences"}
size="small"
responsive
style={{paddingLeft: 3}}
/>
</Anchor>.
During college, he fell in love with web development and mobile development.
</Paragraph>
<Paragraph
size='large'
style={{fontFamily: 'Roboto'}}
>
Shane enjoys taking pictures with his Sony A7 and DJI Mavic Pro. You can check out some of his works in the
<a
onClick={()=> {
scrollToElement('#gallery', {
offset: 0,
ease: 'inOutQuad',
duration: 800
});
}}> Gallery
</a>
{/* Some of them are <Anchor href='https://www.cs.wisc.edu/' >here</Anchor> on the page. */}
</Paragraph>
</Box>
<Box
pad={{vertical: "medium", between: "medium"}}
direction="column"
className={`${CLASS_ROOT}__col-1`}
justify="center"
>
<Image
src='/img/shane.jpg'
alt='Shane Lian Profile'
size='large'
style={{
borderRadius: '50%'
}}
/>
</Box>
</InfographicSection>
);
};
|
src/ContentBlocks/BlockQuote/BlockQuote.js | grommet/grommet-cms-content-blocks | import PropTypes from 'prop-types';
import React from 'react';
import Heading from 'grommet/components/Heading';
import Quote from 'grommet/components/Quote';
import Label from 'grommet/components/Label';
import Anchor from 'grommet/components/Anchor';
import Paragraph from 'grommet/components/Paragraph';
import Box from 'grommet/components/Box';
import unescape from 'unescape';
export default function BlockQuote({
content,
source,
colorIndex,
borderSize,
label,
linkUrl,
linkText,
}) {
const color = colorIndex || 'accent-3';
const size = borderSize || 'medium';
const unescapedContent = unescape(content || '');
return (
<Quote
style={{ width: 'inherit' }}
size={size}
borderColorIndex={color}
credit={
source && <Box pad="none">
<Label uppercase margin="small">
{source}
</Label>
</Box>
}
>
<Box>
{label &&
<Label margin="small" uppercase size="small" style={{ fontWeight: 700 }}>
{label}
</Label>
}
<Box pad={{ vertical: 'small' }}>
<Heading tag="h2" margin="none">
{unescapedContent}
</Heading>
</Box>
{linkUrl && linkText &&
<Anchor label={linkText} path={linkUrl} />
}
</Box>
</Quote>
);
}
BlockQuote.propTypes = {
content: PropTypes.string,
source: PropTypes.string,
colorIndex: PropTypes.string,
borderSize: PropTypes.string,
label: PropTypes.string,
linkUrl: PropTypes.string,
linkText: PropTypes.string,
};
|
src/server/frontend/render.js | stephengfriend/cmsbl-este | import Helmet from 'react-helmet';
import Html from './Html.react';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import config from '../config';
import configureStore from '../../common/configureStore';
import createRoutes from '../../browser/createRoutes';
import serialize from 'serialize-javascript';
import {IntlProvider} from 'react-intl';
import {Provider} from 'react-redux';
import {RouterContext, match} from 'react-router';
import {createMemoryHistory} from 'history';
const fetchComponentDataAsync = async (dispatch, renderProps) => {
const {components, location, params} = renderProps;
const promises = components
.reduce((actions, component) =>
actions.concat(component.fetchActions || [])
, [])
.map(action =>
// Server side fetching can use only router location and params props.
// There is no easy way how to support custom component props.
dispatch(action({location, params})).payload.promise
);
await Promise.all(promises);
};
const getAppHtml = (store, renderProps) =>
ReactDOMServer.renderToString(
<Provider store={store}>
<IntlProvider>
<RouterContext {...renderProps} />
</IntlProvider>
</Provider>
);
const getScriptHtml = (state, headers, hostname, appJsFilename) =>
// Note how app state is serialized. JSON.stringify is anti-pattern.
// https://github.com/yahoo/serialize-javascript#user-content-automatic-escaping-of-html-characters
// Note how we use cdn.polyfill.io, en is default, but can be changed later.
`
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.en"></script>
<script>
window.__INITIAL_STATE__ = ${serialize(state)};
</script>
<script src="${appJsFilename}"></script>
`;
const renderPage = (store, renderProps, req) => {
const state = store.getState();
const {headers, hostname} = req;
const appHtml = getAppHtml(store, renderProps);
const helmet = Helmet.rewind();
const {
styles: {app: appCssFilename},
javascript: {app: appJsFilename}
} = webpackIsomorphicTools.assets();
const scriptHtml = getScriptHtml(state, headers, hostname, appJsFilename);
if (!config.isProduction) {
webpackIsomorphicTools.refresh();
}
const docHtml = ReactDOMServer.renderToStaticMarkup(
<Html
appCssFilename={appCssFilename}
bodyHtml={`<div id="app">${appHtml}</div>${scriptHtml}`}
googleAnalyticsId={config.googleAnalyticsId}
helmet={helmet}
isProduction={config.isProduction}
/>
);
return `<!DOCTYPE html>${docHtml}`;
};
export default function render(req, res, next) {
const initialState = {
device: {
isMobile: ['phone', 'tablet'].indexOf(req.device.type) > -1
}
};
const store = configureStore({initialState});
GLOBAL.navigator = {
userAgent: req.headers['user-agent']
};
// Fetch logged in user here because routes may need it. Remember we can use
// store.dispatch method.
const routes = createRoutes(() => store.getState());
const location = createMemoryHistory().createLocation(req.url);
match({routes, location}, async (error, redirectLocation, renderProps) => {
if (redirectLocation) {
res.redirect(301, redirectLocation.pathname + redirectLocation.search);
return;
}
if (error) {
next(error);
return;
}
try {
await fetchComponentDataAsync(store.dispatch, renderProps);
const html = renderPage(store, renderProps, req);
// renderProps are always defined with * route.
// https://github.com/rackt/react-router/blob/master/docs/guides/advanced/ServerRendering.md
const status = renderProps.routes.some(route => route.path === '*')
? 404
: 200;
res.status(status).send(html);
} catch (e) {
next(e);
}
});
}
|
react-app/src/components/forms/Hidden.js | floodfx/gma-village | import React, { Component } from 'react';
class Hidden extends Component {
render() {
const { input, label, meta: { touched, error, warning } } = this.props;
return (
<div>
<label className="fw7 f3">{label}</label>
<div>
{touched && ((error && <span className="dark-red">{error}</span>) || (warning && <span className="gold">{warning}</span>))}
</div>
<input
type="hidden"
{...input} />
</div>
)
}
}
export default Hidden |
docs/src/app/components/pages/components/RaisedButton/ExampleComplex.js | lawrence-yu/material-ui | import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';
import ActionAndroid from 'material-ui/svg-icons/action/android';
import FontIcon from 'material-ui/FontIcon';
const styles = {
button: {
margin: 12,
},
exampleImageInput: {
cursor: 'pointer',
position: 'absolute',
top: 0,
bottom: 0,
right: 0,
left: 0,
width: '100%',
opacity: 0,
},
};
const RaisedButtonExampleComplex = () => (
<div>
<RaisedButton
label="Choose an Image"
labelPosition="before"
style={styles.button}
containerElement="label"
>
<input type="file" style={styles.exampleImageInput} />
</RaisedButton>
<RaisedButton
label="Label before"
labelPosition="before"
primary={true}
icon={<ActionAndroid />}
style={styles.button}
/>
<RaisedButton
href="https://github.com/callemall/material-ui"
target="_blank"
label="Github Link"
secondary={true}
style={styles.button}
icon={<FontIcon className="muidocs-icon-custom-github" />}
/>
</div>
);
export default RaisedButtonExampleComplex;
|
src/svg-icons/editor/border-style.js | pomerantsev/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorBorderStyle = (props) => (
<SvgIcon {...props}>
<path d="M15 21h2v-2h-2v2zm4 0h2v-2h-2v2zM7 21h2v-2H7v2zm4 0h2v-2h-2v2zm8-4h2v-2h-2v2zm0-4h2v-2h-2v2zM3 3v18h2V5h16V3H3zm16 6h2V7h-2v2z"/>
</SvgIcon>
);
EditorBorderStyle = pure(EditorBorderStyle);
EditorBorderStyle.displayName = 'EditorBorderStyle';
EditorBorderStyle.muiName = 'SvgIcon';
export default EditorBorderStyle;
|
index.android.js | WPDreamMelody/NavigatorBarRN | /**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
class NavigatorDemo extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Shake or press menu button for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('NavigatorDemo', () => NavigatorDemo);
|
src/components/library/Table/index.js | jfilter/frag-den-staat-app | import { Text, View } from 'react-native';
import PropTypes from 'prop-types';
import React from 'react';
import { styles } from './styles';
const Table = ({ data }) => {
return (
<View style={styles.table}>
{data.map(({ label, value }) => (
<View key={label} style={styles.row}>
<View style={styles.item1}>
<Text>{`${label}:`}</Text>
</View>
<View style={styles.item2}>{value}</View>
</View>
))}
</View>
);
};
Table.propTypes = {
data: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
value: PropTypes.element.isRequired,
}).isRequired
).isRequired,
};
export default Table;
|
app/react-icons/fa/bullhorn.js | scampersand/sonos-front | import React from 'react';
import IconBase from 'react-icon-base';
export default class FaBullhorn extends React.Component {
render() {
return (
<IconBase viewBox="0 0 40 40" {...this.props}>
<g><path d="m37.1 14.3q1.2 0 2.1 0.8t0.8 2-0.8 2.1-2.1 0.8v8.6q0 1.1-0.8 2t-2 0.8q-9.3-7.7-18.1-8.5-1.3 0.5-2.1 1.5t-0.7 2.3 0.9 2q-0.4 0.8-0.5 1.5t0.2 1.3 0.7 1.2 1.1 1.1 1.3 1.2q-0.6 1.2-2.4 1.8t-3.8 0.3-2.9-1.3q-0.2-0.5-0.7-1.9t-0.7-2.1-0.5-2-0.4-2.3 0.1-2.2 0.5-2.4h-2.7q-1.5 0-2.5-1.1t-1.1-2.5v-4.3q0-1.5 1.1-2.5t2.5-1.1h10.7q9.7 0 20-8.5 1.1 0 2 0.8t0.8 2v8.6z m-2.8 13.5v-21.3q-8.8 6.7-17.2 7.6v6.1q8.5 0.9 17.2 7.6z"/></g>
</IconBase>
);
}
}
|
client/pages/Main.js | Luzgan/checklist-v2-graphql-apollo | /**
* Created by luzga_000 on 06/07/2017.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { gql, graphql } from 'react-apollo';
import { propType } from 'graphql-anywhere';
import TasksList from '../components/TasksList';
class Main extends Component {
static defaultProps = {
data: {
},
};
render() {
const { userRepositoryQuery, taskRepositoryQuery, loading, error } = this.props.data;
if (loading) {
return (<div>Loading...</div>);
}
if (error) {
console.log(error);
return (<div>Error: {error.message}</div>);
}
return (
<div className="row">
<div className="col-lg-10">
{userRepositoryQuery.user.name} {taskRepositoryQuery.tasksCount}
<TasksList />
</div>
</div>
);
}
}
Main.fragments = {
userRepositoryQuery: gql`
fragment Main_userRepositoryQuery on UserRepositoryQuery {
user {
name
}
}
`,
taskRepositoryQuery: gql`
fragment Main_taskRepositoryQuery on TaskRepositoryQuery {
tasksCount
}
`,
};
Main.propTypes = {
data: PropTypes.shape({
userRepositoryQuery: propType(Main.fragments.userRepositoryQuery),
taskRepositoryQuery: propType(Main.fragments.taskRepositoryQuery),
loading: PropTypes.bool,
error: PropTypes.object,
}),
};
const MainQuery = gql`
query Main {
userRepositoryQuery {
...Main_userRepositoryQuery
}
taskRepositoryQuery {
...Main_taskRepositoryQuery
}
}
${Main.fragments.userRepositoryQuery}
${Main.fragments.taskRepositoryQuery}
`;
const QueriedMain = graphql(MainQuery, {
options: {
reducer: (previousResults, action) => {
switch (action.operationName) {
case 'TaskAdd_AddMutation':
const newResultAdd = { ...previousResults };
newResultAdd.taskRepositoryQuery.tasksCount += 1;
return newResultAdd;
case 'Task_DeleteTaskMutation':
const newResultDelete = { ...previousResults };
newResultDelete.taskRepositoryQuery.tasksCount -= 1;
return newResultDelete;
default:
return previousResults;
}
},
},
})(Main);
QueriedMain.Query = MainQuery;
export default QueriedMain;
|
src/platform/site-wide/banners/components/MaintenanceBanner/index.js | department-of-veterans-affairs/vets-website | // Node modules.
import React from 'react';
import ReusableMaintenanceBanner from '@department-of-veterans-affairs/component-library/MaintenanceBanner';
// Relative imports.
import config from '../../config/maintenanceBanner';
export const MaintenanceBanner = () => (
<ReusableMaintenanceBanner
content={config.content}
expiresAt={config.expiresAt}
id={config.id}
localStorage={localStorage}
startsAt={config.startsAt}
title={config.title}
warnContent={config.warnContent}
warnStartsAt={config.warnStartsAt}
warnTitle={config.warnTitle}
/>
);
export default MaintenanceBanner;
|
src/svg-icons/hardware/sim-card.js | pancho111203/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let HardwareSimCard = (props) => (
<SvgIcon {...props}>
<path d="M19.99 4c0-1.1-.89-2-1.99-2h-8L4 8v12c0 1.1.9 2 2 2h12.01c1.1 0 1.99-.9 1.99-2l-.01-16zM9 19H7v-2h2v2zm8 0h-2v-2h2v2zm-8-4H7v-4h2v4zm4 4h-2v-4h2v4zm0-6h-2v-2h2v2zm4 2h-2v-4h2v4z"/>
</SvgIcon>
);
HardwareSimCard = pure(HardwareSimCard);
HardwareSimCard.displayName = 'HardwareSimCard';
HardwareSimCard.muiName = 'SvgIcon';
export default HardwareSimCard;
|
assets/src/js/index.js | cleverframework/clever-users-admin | 'use strict'
import 'babel-polyfill'
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { ReduxRouter } from 'redux-router'
import Cookies from 'cookies-js'
import { JWT_COOKIE_NAME } from './constants/settings.js'
import configureStore from './store/configureStore'
import { loginSuccess } from './actions'
const store = configureStore()
const token = Cookies.get(JWT_COOKIE_NAME)
if (token) store.dispatch(loginSuccess({ token }))
render(
<Provider store={store}>
<ReduxRouter />
</Provider>,
document.getElementById('root')
)
|
src/components/UI/Spacer.js | mcnamee/react-native-starter-app | import React from 'react';
import PropTypes from 'prop-types';
import { View } from 'native-base';
const Spacer = ({ size }) => <View style={{ flex: 1, height: size }} />;
Spacer.propTypes = {
size: PropTypes.number,
};
Spacer.defaultProps = {
size: 20,
};
export default Spacer;
|
App/node_modules/react-native/local-cli/templates/HelloNavigation/components/KeyboardSpacer.js | Dagers/React-Native-Differential-Updater | 'use strict';
/* @flow */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
Platform,
View,
Keyboard,
LayoutAnimation,
UIManager,
} from 'react-native';
type Props = {
offset?: number,
}
type State = {
keyboardHeight: number
}
// Consider contributing this to the popular library:
// https://github.com/Andr3wHur5t/react-native-keyboard-spacer
/**
* On iOS, the software keyboard covers the screen by default.
* This is not desirable if there are TextInputs near the bottom of the screen -
* they would be covered by the keyboard and the user cannot see what they
* are typing.
* To get around this problem, place a `<KeyboardSpacer />` at the bottom
* of the screen, after your TextInputs. The keyboard spacer has size 0 and
* when the keyboard is shown it will grow to the same size as the keyboard,
* shifting all views above it and therefore making them visible.
*
* On Android, this component is not needed because resizing the UI when
* the keyboard is shown is supported by the OS.
* Simply set the `android:windowSoftInputMode="adjustResize"` attribute
* on the <activity> element in your AndroidManifest.xml.
*
* How is this different from KeyboardAvoidingView?
* The KeyboardAvoidingView doesn't work when used together with
* a ScrollView/ListView.
*/
const KeyboardSpacer = () => (
Platform.OS === 'ios' ? <KeyboardSpacerIOS /> : null
);
class KeyboardSpacerIOS extends Component<Props, Props, State> {
static propTypes = {
offset: PropTypes.number,
};
static defaultProps = {
offset: 0,
};
state: State = {
keyboardHeight: 0,
};
componentWillMount() {
this._registerEvents();
}
componentWillUnmount() {
this._unRegisterEvents();
}
_keyboardWillShowSubscription: { remove: Function };
_keyboardWillHideSubscription: { remove: Function };
_registerEvents = () => {
this._keyboardWillShowSubscription = Keyboard.addListener(
'keyboardWillShow',
this._keyboardWillShow
);
this._keyboardWillHideSubscription = Keyboard.addListener(
'keyboardWillHide',
this._keyboardWillHide
);
};
_unRegisterEvents = () => {
this._keyboardWillShowSubscription.remove();
this._keyboardWillHideSubscription.remove();
};
_configureLayoutAnimation = () => {
// Any duration is OK here. The `type: 'keyboard defines the animation.
LayoutAnimation.configureNext({
duration: 100,
update: {
type: 'keyboard',
}
});
}
_keyboardWillShow = (e: any) => {
this._configureLayoutAnimation();
this.setState({
keyboardHeight: e.endCoordinates.height - (this.props.offset || 0),
});
};
_keyboardWillHide = () => {
this._configureLayoutAnimation();
this.setState({
keyboardHeight: 0,
});
};
render() {
return <View style={{ height: this.state.keyboardHeight }} />;
}
}
export default KeyboardSpacer;
|
src/Topics.js | rdwrcode/myreact-demo | import React from 'react'
import { Link, Match } from 'react-router';
import Topic from './Topic'
const Topics = ({ pathname }) => (
<div>
<h2>Topics</h2>
<ul>
<li><Link to={`${pathname}/components`}>Everything is a component!</Link></li>
<li><Link to={`${pathname}/render`}>Let React render.</Link></li>
<li><Link to={`${pathname}/props-state`}>Props and states are friends.</Link></li>
</ul>
<Match pattern={`${pathname}/:topicId`} component={Topic}/>
<Match pattern={pathname} exactly render={() => (
<h3>Please select a topic</h3>
)}/>
</div>
)
export default Topics
|
pages/index.js | poeti8/findrap.xyz | import React from 'react';
import Head from 'next/head';
import axios from 'axios';
import Homepage from '../components/Homepage';
const Index = (props) => {
const data = props.data ? props.data : props.url.query;
return (
<div>
<meta name="description" content="Find the best Hip-Hop/Rap songs and albums of the history." />
<meta name="twitter:card" value="Discover the Best Hip-Hop Songs and Albums" />
<meta property="og:title" content="FindRap" />
<meta property="og:url" content="https://findrap.xyz/" />
<meta property="og:image" content="https://findrap.xyz/static/og.jpg" />
<meta property="og:description" content="Discover the Best Hip-Hop Songs and Albums." />
<Homepage
tags={data.tags}
artists={data.artists}
/>
</div>
);
};
Index.getInitialProps = async ({ req, query }) => {
if (!req) {
const tags = await axios.get('/api/tag/all', { responseType: 'json' });
const artists = await axios.get('/api/artist/all', { responseType: 'json' });
return { data: { tags: tags.data.data, artists: artists.data.data } };
}
return query;
}
export default Index; |
src/parser/druid/feral/modules/core/Snapshot.js | ronaldpereira/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import SpellIcon from 'common/SpellIcon';
import { formatNumber, formatPercentage } from 'common/format';
import { TooltipElement } from 'common/Tooltip';
import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
import Events from 'parser/core/Events';
import { encodeTargetString } from 'parser/shared/modules/EnemyInstances';
import calculateEffectiveDamage from 'parser/core/calculateEffectiveDamage';
import StatisticsListBox from 'interface/others/StatisticsListBox';
import { PANDEMIC_FRACTION, PROWL_RAKE_DAMAGE_BONUS, TIGERS_FURY_DAMAGE_BONUS, BLOODTALONS_DAMAGE_BONUS } from '../../constants';
const debug = false;
/**
* Feral has a snapshotting mechanic which means the effect of some buffs are maintained over the duration of
* some DoTs even after the buff has worn off.
* Players should follow a number of rules with regards when they refresh a DoT and when they do not, depending
* on what buffs the DoT has snapshot and what buffs are currently active.
*
* The Snapshot class is 'abstract', and shouldn't be directly instantiated. Instead classes should extend
* it to examine how well the combatant is making use of the snapshot mechanic.
*/
/**
* leeway in ms after loss of bloodtalons/prowl buff to count a cast as being buffed.
* Danger of false positives from buffs fading due to causes other than being used to buff a DoT.
*/
const BUFF_WINDOW_TIME = 60;
// leeway in ms between a cast event and debuff apply/refresh for them to be associated
const CAST_WINDOW_TIME = 300;
/**
* Leeway in ms between when a debuff was expected to wear off and when damage events will no longer be counted
* Largest found in logs is 149ms:
* https://www.warcraftlogs.com/reports/8Ddyzh9nRjrxv3JA/#fight=16&source=21
* Moonfire DoT tick at 8:13.300, expected to expire at 8:13.151
*/
const DAMAGE_AFTER_EXPIRE_WINDOW = 200;
class Snapshot extends Analyzer {
// extending class should fill these in:
static spell = null;
static debuff = null;
static isProwlAffected = false;
static isTigersFuryAffected = false;
static isBloodtalonsAffected = false;
static durationOfFresh = null;
stateByTarget = {};
lastDoTCastEvent;
castCount = 0;
ticks = 0;
ticksWithProwl = 0;
ticksWithTigersFury = 0;
ticksWithBloodtalons = 0;
damageFromProwl = 0;
damageFromTigersFury = 0;
damageFromBloodtalons = 0;
static wasStateFreshlyApplied(state) {
if (!state) {
return false;
}
if (!state.prev) {
// no previous state, so must be fresh
return true;
}
const previous = state.prev;
if (previous.expireTime < state.startTime) {
// there was a previous state but it wore off before this was applied
return true;
}
return false;
}
static wasStatePowerUpgrade(state) {
if (!state) {
return false;
}
if (Snapshot.wasStateFreshlyApplied(state)) {
// a fresh application isn't the same as an upgrade
return false;
}
if (state.power > state.prev.power) {
return true;
}
return false;
}
constructor(...args) {
super(...args);
if (!this.constructor.spell || !this.constructor.debuff) {
this.active = false;
throw new Error('Snapshot should be extended and provided with spellCastId and debuffId.');
}
this.addEventListener(Events.cast.by(SELECTED_PLAYER).spell(this.constructor.spell), this._castSnapshotSpell);
this.addEventListener(Events.damage.by(SELECTED_PLAYER).spell(this.constructor.debuff), this._damageFromDebuff);
}
_castSnapshotSpell(event) {
this.castCount += 1;
this.lastDoTCastEvent = event;
event.debuffEvents.forEach(event => this._debuffApplied(event));
}
_damageFromDebuff(event) {
if (event.targetIsFriendly || !event.tick) {
// ignore damage on friendlies and any non-DoT damage
return;
}
if ((event.amount || 0) + (event.absorbed || 0) === 0) {
// what buffs a zero-damage tick has doesn't matter, so don't count them (usually means target is currently immune to damage)
return;
}
const state = this.stateByTarget[encodeTargetString(event.targetID, event.targetInstance)];
if (!state || event.timestamp > state.expireTime + DAMAGE_AFTER_EXPIRE_WINDOW) {
debug && this.warn(`Damage detected from DoT ${this.constructor.debuff.name} but no active state recorded for the target. Previous state expired: ${state ? this.owner.formatTimestamp(state.expireTime, 3) : 'n/a'}`);
return;
}
// how much damage is coming from the snapshot buffs combined
const bonusDamage = calculateEffectiveDamage(event, this.calcPowerFromSnapshot(state) - 1);
const additiveBonus = this.additivePowerSum(state);
this.ticks += 1;
if (state.prowl) {
this.ticksWithProwl += 1;
const fractionOfBonus = PROWL_RAKE_DAMAGE_BONUS / additiveBonus;
this.damageFromProwl += bonusDamage * fractionOfBonus;
}
if (state.tigersFury) {
this.ticksWithTigersFury += 1;
const fractionOfBonus = TIGERS_FURY_DAMAGE_BONUS / additiveBonus;
this.damageFromTigersFury += bonusDamage * fractionOfBonus;
}
if (state.bloodtalons) {
this.ticksWithBloodtalons += 1;
const fractionOfBonus = BLOODTALONS_DAMAGE_BONUS / additiveBonus;
this.damageFromBloodtalons += bonusDamage * fractionOfBonus;
}
}
_debuffApplied(event) {
const targetString = encodeTargetString(event.targetID, event.targetInstance);
const stateOld = this.stateByTarget[targetString];
const stateNew = this.makeNewState(event, stateOld);
this.stateByTarget[targetString] = stateNew;
debug && this.log(`DoT ${this.constructor.debuff.name} applied at ${this.owner.formatTimestamp(event.timestamp, 3)} on ${targetString} Prowl:${stateNew.prowl}, TF: ${stateNew.tigersFury}, BT: ${stateNew.bloodtalons}. Expires at ${this.owner.formatTimestamp(stateNew.expireTime, 3)}`);
this.checkRefreshRule(stateNew);
}
makeNewState(debuffEvent, stateOld) {
const timeRemainOnOld = stateOld ? (stateOld.expireTime - debuffEvent.timestamp) : 0;
const durationNew = this.getDurationOfFresh(debuffEvent);
let expireNew = debuffEvent.timestamp + durationNew;
if (timeRemainOnOld > 0) {
expireNew += Math.min(durationNew * PANDEMIC_FRACTION, timeRemainOnOld);
}
const combatant = this.selectedCombatant;
const stateNew = {
expireTime: expireNew,
pandemicTime: expireNew - durationNew * PANDEMIC_FRACTION,
tigersFury: this.constructor.isTigersFuryAffected &&
combatant.hasBuff(SPELLS.TIGERS_FURY.id),
prowl: this.constructor.isProwlAffected && (
combatant.hasBuff(SPELLS.INCARNATION_KING_OF_THE_JUNGLE_TALENT.id) ||
combatant.hasBuff(SPELLS.PROWL.id, null, BUFF_WINDOW_TIME) ||
combatant.hasBuff(SPELLS.PROWL_INCARNATION.id, null, BUFF_WINDOW_TIME) ||
combatant.hasBuff(SPELLS.SHADOWMELD.id, null, BUFF_WINDOW_TIME)
),
bloodtalons: this.constructor.isBloodtalonsAffected &&
combatant.hasBuff(SPELLS.BLOODTALONS_BUFF.id, null, BUFF_WINDOW_TIME),
power: 1,
startTime: debuffEvent.timestamp,
castEvent: this.lastDoTCastEvent,
// undefined if the first application of this debuff on this target
prev: stateOld,
};
stateNew.power = this.calcPower(stateNew);
if (!stateNew.castEvent ||
stateNew.startTime > stateNew.castEvent.timestamp + CAST_WINDOW_TIME) {
debug && this.warn(`DoT ${this.constructor.debuff.name} applied debuff doesn't have a recent matching cast event.`);
} else {
// store a reference to this state on the cast event which we'll be able to display on the timeline (or use elsewhere)
stateNew.castEvent.feralSnapshotState = stateNew;
}
return stateNew;
}
calcPower(stateNew) {
return this.calcPowerFromSnapshot(stateNew);
}
calcPowerFromSnapshot(stateNew) {
let power = 1.0;
if (stateNew.prowl) {
power *= (PROWL_RAKE_DAMAGE_BONUS + 1);
}
if (stateNew.tigersFury) {
power *= (TIGERS_FURY_DAMAGE_BONUS + 1);
}
if (stateNew.bloodtalons) {
power *= (BLOODTALONS_DAMAGE_BONUS + 1);
}
return power;
}
additivePowerSum(stateNew) {
let additive = 0;
if (stateNew.prowl) {
additive += PROWL_RAKE_DAMAGE_BONUS;
}
if (stateNew.tigersFury) {
additive += TIGERS_FURY_DAMAGE_BONUS;
}
if (stateNew.bloodtalons) {
additive += BLOODTALONS_DAMAGE_BONUS;
}
return additive;
}
checkRefreshRule(state) {
debug && this.warn('Expected checkRefreshRule function to be overridden.');
}
getDurationOfFresh(debuffEvent) {
return this.constructor.durationOfFresh;
}
// TODO: Bring this statistic and tooltip stuff up to standard
subStatistic(ticksWithBuff, damageIncrease, buffId, buffName, spellName) {
const info = (
// subStatistics for this DoT will be combined, so each should have a unique key
<div className="flex" key={buffId}>
<div className="flex-main">
<SpellLink id={buffId} />
</div>
<div className="flex-sub text-right">
<TooltipElement content={`${formatNumber(damageIncrease / this.owner.fightDuration * 1000)} DPS contributed by ${buffName} on your ${spellName} DoT`}>
{formatPercentage(this.ticks === 0 ? 0 : ticksWithBuff / this.ticks)}%
</TooltipElement>
</div>
</div>
);
return info;
}
generateStatistic(spellName, statisticPosition) {
const subStats = [];
const buffNames = [];
if (this.constructor.isProwlAffected) {
const buffName = 'Prowl';
buffNames.push(buffName);
subStats.push(this.subStatistic(this.ticksWithProwl, this.damageFromProwl, SPELLS.PROWL.id, buffName, spellName));
}
if (this.constructor.isTigersFuryAffected) {
const buffName = 'Tiger\'s Fury';
buffNames.push(buffName);
subStats.push(this.subStatistic(this.ticksWithTigersFury, this.damageFromTigersFury, SPELLS.TIGERS_FURY.id, buffName, spellName));
}
if (this.constructor.isBloodtalonsAffected && this.selectedCombatant.hasTalent(SPELLS.BLOODTALONS_TALENT.id)) {
const buffName = 'Bloodtalons';
buffNames.push(buffName);
subStats.push(this.subStatistic(this.ticksWithBloodtalons, this.damageFromBloodtalons, SPELLS.BLOODTALONS_TALENT.id, buffName, spellName));
}
let buffsComment = '';
buffNames.forEach((name, index) => {
const hasComma = (buffNames.length > 2 && index < buffNames.length - 1);
const hasAnd = (index === buffNames.length - 2);
buffsComment = `${buffsComment}${name}${hasComma ? ', ' : ''}${hasAnd ? ' and ' : ''}`;
});
const isPlural = buffNames.length > 1;
return (
<StatisticsListBox
title={(
<>
<SpellIcon id={this.constructor.spell.id} noLink /> {spellName} Snapshot
</>
)}
tooltip={`${spellName} maintains the damage bonus from ${buffsComment} if ${isPlural ? 'they were' : 'it was'} present when the DoT was applied. This lists how many of your ${spellName} ticks benefited from ${isPlural ? 'each' : 'the'} buff. ${isPlural ? 'As a tick can benefit from multiple buffs at once these percentages can add up to more than 100%.' : ''}`}
position={statisticPosition}
>
{subStats}
</StatisticsListBox>
);
}
}
export default Snapshot;
|
renderer/components/Channels/Channels.js | LN-Zap/zap-desktop | import React from 'react'
import PropTypes from 'prop-types'
import debounce from 'lodash/debounce'
import styled from 'styled-components'
import { Panel } from 'components/UI'
import PersistentTabControl from 'components/TabControl/PersistentTabControl'
import ChannelsHeader from 'containers/Channels/ChannelsHeader'
import ChannelCardList from './ChannelCardList'
import ChannelSummaryList from './ChannelSummaryList'
import { CHANNEL_LIST_VIEW_MODE_CARD } from './constants'
const StyledPersistentTabControl = styled(PersistentTabControl)`
height: 100%;
`
class Channels extends React.Component {
/* eslint-disable react/destructuring-assignment */
updateChannelSearchQuery = debounce(this.props.updateChannelSearchQuery, 300)
static propTypes = {
channels: PropTypes.array,
channelViewMode: PropTypes.string.isRequired,
cryptoUnitName: PropTypes.string.isRequired,
networkInfo: PropTypes.shape({
id: PropTypes.string,
name: PropTypes.string,
}),
openModal: PropTypes.func.isRequired,
setSelectedChannel: PropTypes.func.isRequired,
updateChannelSearchQuery: PropTypes.func.isRequired,
}
static defaultProps = {
channels: [],
}
render() {
const {
channels,
channelViewMode,
cryptoUnitName,
networkInfo,
openModal,
setSelectedChannel,
updateChannelSearchQuery,
...rest
} = this.props
return (
<Panel {...rest}>
<Panel.Header>
<ChannelsHeader
currentChannelCount={channels.length}
updateChannelSearchQuery={this.updateChannelSearchQuery}
/>
</Panel.Header>
<Panel.Body overflow="hidden">
<StyledPersistentTabControl
activeTab={channelViewMode === CHANNEL_LIST_VIEW_MODE_CARD ? 0 : 1}
>
<ChannelCardList
channels={channels}
cryptoUnitName={cryptoUnitName}
networkInfo={networkInfo}
openModal={openModal}
setSelectedChannel={setSelectedChannel}
/>
<ChannelSummaryList
channels={channels}
cryptoUnitName={cryptoUnitName}
networkInfo={networkInfo}
openModal={openModal}
setSelectedChannel={setSelectedChannel}
/>
</StyledPersistentTabControl>
</Panel.Body>
</Panel>
)
}
}
export default Channels
|
src/decorators/withViewport.js | hanwencheng/SeekDev | /*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
import React, { Component } from 'react'; // eslint-disable-line no-unused-vars
import EventEmitter from 'eventemitter3';
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
let EE;
let viewport = {width: 1366, height: 768}; // Default size for server-side rendering
const RESIZE_EVENT = 'resize';
function handleWindowResize() {
if (viewport.width !== window.innerWidth || viewport.height !== window.innerHeight) {
viewport = {width: window.innerWidth, height: window.innerHeight};
EE.emit(RESIZE_EVENT, viewport);
}
}
function withViewport(ComposedComponent) {
return class WithViewport extends Component {
constructor() {
super();
this.state = {
viewport: canUseDOM ? {width: window.innerWidth, height: window.innerHeight} : viewport,
};
}
componentDidMount() {
if (!EE) {
EE = new EventEmitter();
window.addEventListener('resize', handleWindowResize);
window.addEventListener('orientationchange', handleWindowResize);
}
EE.on(RESIZE_EVENT, this.handleResize, this);
}
componentWillUnmount() {
EE.removeListener(RESIZE_EVENT, this.handleResize, this);
if (!EE.listeners(RESIZE_EVENT, true)) {
window.removeEventListener('resize', handleWindowResize);
window.removeEventListener('orientationchange', handleWindowResize);
EE = null;
}
}
render() {
return <ComposedComponent {...this.props} viewport={this.state.viewport}/>;
}
handleResize(value) {
this.setState({viewport: value}); // eslint-disable-line react/no-set-state
}
};
}
export default withViewport;
|
js/components/Card.js | matthewbdaly/react-kanban | import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
export default React.createClass({
mixins: [PureRenderMixin],
render() {
return (
<div className="card" ref="card">
<h4>{this.props.title}</h4>
<p>{this.props.description}</p>
</div>
);
}
});
|
src/icons/Sad.js | fbfeix/react-icons | import React from 'react';
import IconBase from './../components/IconBase/IconBase';
export default class Sad extends React.Component {
render() {
if(this.props.bare) {
return <g>
<g>
<path d="M256,32C132.288,32,32,132.288,32,256s100.288,224,224,224s224-100.288,224-224S379.712,32,256,32z M145.062,291.696
c-1.551,4.952-5.62,8.724-10.693,10.606c-3.358,1.246-6.816,1.774-10.236,0.938c-8.866-2.185-13.916-10.907-11.255-19.443
c5.101-16.379,14.22-29.995,33.802-37.263s35.265-2.877,49.868,6.15c7.615,4.707,10.029,14.019,4.214,22.123
c-2.049,2.854-5.019,4.717-8.376,5.963c-5.059,1.876-10.584,1.678-14.965-1.036c-4.778-2.957-10.643-6.526-19.607-3.199
C148.805,279.878,146.712,286.374,145.062,291.696z M345.156,381.454c-2.789,1.946-5.982,2.881-9.144,2.881
c-5.053,0-10.023-2.388-13.134-6.845C322.703,377.239,304,352,256,352c-47.98,0-66.704,25.239-66.879,25.49
c-3.111,4.457-8.083,6.845-13.135,6.845c-3.161,0-6.354-0.935-9.143-2.881c-7.246-5.058-9.021-15.031-3.963-22.278
C163.986,357.59,190.739,320,256,320c65,0,92.013,37.59,93.119,39.176C354.177,366.423,352.402,376.396,345.156,381.454z
M388.029,303.24c-3.42,0.837-6.879,0.309-10.236-0.938c-5.073-1.883-9.143-5.654-10.693-10.606
c-1.649-5.322-3.742-11.818-12.752-15.161c-8.964-3.327-14.829,0.242-19.607,3.199c-4.381,2.714-9.906,2.912-14.965,1.036
c-3.357-1.246-6.327-3.108-8.376-5.963c-5.815-8.104-3.401-17.416,4.214-22.123c14.604-9.027,30.286-13.418,49.868-6.15
s28.702,20.884,33.802,37.263C401.944,292.333,396.895,301.056,388.029,303.24z"></path>
</g>
</g>;
} return <IconBase>
<g>
<path d="M256,32C132.288,32,32,132.288,32,256s100.288,224,224,224s224-100.288,224-224S379.712,32,256,32z M145.062,291.696
c-1.551,4.952-5.62,8.724-10.693,10.606c-3.358,1.246-6.816,1.774-10.236,0.938c-8.866-2.185-13.916-10.907-11.255-19.443
c5.101-16.379,14.22-29.995,33.802-37.263s35.265-2.877,49.868,6.15c7.615,4.707,10.029,14.019,4.214,22.123
c-2.049,2.854-5.019,4.717-8.376,5.963c-5.059,1.876-10.584,1.678-14.965-1.036c-4.778-2.957-10.643-6.526-19.607-3.199
C148.805,279.878,146.712,286.374,145.062,291.696z M345.156,381.454c-2.789,1.946-5.982,2.881-9.144,2.881
c-5.053,0-10.023-2.388-13.134-6.845C322.703,377.239,304,352,256,352c-47.98,0-66.704,25.239-66.879,25.49
c-3.111,4.457-8.083,6.845-13.135,6.845c-3.161,0-6.354-0.935-9.143-2.881c-7.246-5.058-9.021-15.031-3.963-22.278
C163.986,357.59,190.739,320,256,320c65,0,92.013,37.59,93.119,39.176C354.177,366.423,352.402,376.396,345.156,381.454z
M388.029,303.24c-3.42,0.837-6.879,0.309-10.236-0.938c-5.073-1.883-9.143-5.654-10.693-10.606
c-1.649-5.322-3.742-11.818-12.752-15.161c-8.964-3.327-14.829,0.242-19.607,3.199c-4.381,2.714-9.906,2.912-14.965,1.036
c-3.357-1.246-6.327-3.108-8.376-5.963c-5.815-8.104-3.401-17.416,4.214-22.123c14.604-9.027,30.286-13.418,49.868-6.15
s28.702,20.884,33.802,37.263C401.944,292.333,396.895,301.056,388.029,303.24z"></path>
</g>
</IconBase>;
}
};Sad.defaultProps = {bare: false} |
app/containers/details/components/realtime-weather.js | 7kfpun/TWAQIReactNative | import React from 'react';
import { number, shape, string } from 'prop-types';
import { StyleSheet, Text, View } from 'react-native';
import { iOSColors } from 'react-native-typography';
import I18n from '../../../utils/i18n';
const styles = StyleSheet.create({
container: {
marginBottom: 10,
backgroundColor: iOSColors.white,
padding: 15,
flexDirection: 'row',
},
item: {
flex: 1,
flexDirection: 'column',
justifyContent: 'space-between',
alignItems: 'flex-start',
height: 50,
},
labelText: {
fontSize: 12,
fontWeight: '300',
color: 'black',
},
valueText: {
fontSize: 14,
color: 'black',
textAlign: 'center',
},
});
const RealtimeWeather = ({ data }) => (
<View style={styles.container}>
<View style={styles.item}>
<Text style={styles.labelText}>{I18n.t('realtime_weather.rain')}</Text>
<Text style={styles.valueText}>
{data.Rain ? `${data.Rain} mm` : '--'}
</Text>
</View>
<View style={styles.item}>
<Text style={styles.labelText}>{I18n.t('realtime_weather.rh')}</Text>
<Text style={styles.valueText}>{data.RH ? `${data.RH} %` : '--'}</Text>
</View>
<View style={styles.item}>
<Text style={styles.labelText}>
{I18n.t('realtime_weather.visibility')}
</Text>
<Text style={styles.valueText}>
{data.Visibility ? `${data.Visibility} km` : '--'}
</Text>
</View>
<View style={styles.item}>
<Text style={styles.labelText}>{I18n.t('realtime_weather.cloud')}</Text>
<Text style={styles.valueText}>
{data.Cloud ? `${data.Cloud} %` : '--'}
</Text>
</View>
</View>
);
RealtimeWeather.propTypes = {
data: shape({
Temp: number,
WeatherIcon: string,
RH: number,
Rain: number,
Cloud: number,
Visibility: number,
}).isRequired,
};
export default RealtimeWeather;
|
src/svg-icons/image/filter-drama.js | barakmitz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageFilterDrama = (props) => (
<SvgIcon {...props}>
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.61 5.64 5.36 8.04 2.35 8.36 0 10.9 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4h2c0-2.76-1.86-5.08-4.4-5.78C8.61 6.88 10.2 6 12 6c3.03 0 5.5 2.47 5.5 5.5v.5H19c1.65 0 3 1.35 3 3s-1.35 3-3 3z"/>
</SvgIcon>
);
ImageFilterDrama = pure(ImageFilterDrama);
ImageFilterDrama.displayName = 'ImageFilterDrama';
ImageFilterDrama.muiName = 'SvgIcon';
export default ImageFilterDrama;
|
src/feed/Page.js | Sekhmet/busy | import React from 'react';
import { connect } from 'react-redux';
import { Helmet } from 'react-helmet';
import MenuFeed from '../app/Menu/MenuFeed';
import Hero from '../app/Hero';
import Feed from './Feed';
import PageHOC from './PageHOC';
import {
getFeedContent,
getMoreFeedContent,
getUserFeedContent,
getMoreUserFeedContent,
} from './feedActions';
import {
getFeedContentFromState,
getFeedLoadingFromState,
getUserFeedContentFromState,
getUserFeedLoadingFromState,
} from '../helpers/stateHelpers';
import FavoriteButton from '../favorites/FavoriteButton';
import * as favoriteActions from '../favorites/favoritesActions';
import EmptyFeed from '../statics/EmptyFeed';
@PageHOC
@connect(
state => ({
feed: state.feed,
posts: state.posts,
favorites: state.favorites.categories,
}),
(dispatch, ownProps) => {
const { sortBy, category, auth, limit } = ownProps;
return {
getFeedContent: () => dispatch(
getFeedContent({ sortBy, category, limit })
),
getMoreFeedContent: () => dispatch(
getMoreFeedContent({ sortBy, category, limit })
),
getUserFeedContent: () => dispatch(
getUserFeedContent({ username: auth.user.name, limit })
),
getMoreUserFeedContent: () => dispatch(
getMoreUserFeedContent({ username: auth.user.name, limit })
),
addCategoryFavorite: () => dispatch(
favoriteActions.addCategoryFavorite(category)
),
removeCategoryFavorite: () => dispatch(
favoriteActions.removeCategoryFavorite(category)
),
};
}
)
export default class Page extends React.Component {
isFavorited() {
const { category, favorites } = this.props;
return category && favorites.includes(category);
}
render() {
const { notify, category, sortBy, path, auth, feed, posts } = this.props;
let content, isFetching, hasMore, loadContentAction, loadMoreContentAction;
if (!path && auth.isAuthenticated) {
content = getUserFeedContentFromState(auth.user.name, feed, posts);
isFetching = getUserFeedLoadingFromState(auth.user.name, feed);
hasMore = feed[sortBy][auth.user.name] ? feed[sortBy][auth.user.name].hasMore : true;
loadContentAction = this.props.getUserFeedContent;
loadMoreContentAction = this.props.getMoreUserFeedContent;
} else {
content = getFeedContentFromState(sortBy, category, feed, posts);
isFetching = getFeedLoadingFromState(sortBy, category, feed);
hasMore = feed[sortBy][category] ? feed[sortBy][category].hasMore : true;
loadContentAction = this.props.getFeedContent;
loadMoreContentAction = this.props.getMoreFeedContent;
}
return (
<div className="main-panel">
<Helmet>
<title>Busy</title>
</Helmet>
{!auth.isFetching && !auth.isAuthenticated && !category &&
<Hero />
}
{!auth.isFetching &&
<MenuFeed
auth={auth}
category={category}
/>
}
{category &&
<h2 className="mt-3 text-center">
<span className="text-info">#</span>
{' '}{category}{' '}
<FavoriteButton
isFavorited={this.isFavorited()}
onClick={this.isFavorited()
? this.props.removeCategoryFavorite
: this.props.addCategoryFavorite
}
/>
</h2>
}
<Feed
content={content}
isFetching={isFetching}
hasMore={hasMore}
loadContent={loadContentAction}
loadMoreContent={loadMoreContentAction}
notify={notify}
route={this.props.route}
/>
{(content.length === 0 && !isFetching) &&
<EmptyFeed />
}
</div>
);
}
}
Page.propTypes = {
category: React.PropTypes.string,
sortBy: React.PropTypes.string,
path: React.PropTypes.string,
limit: React.PropTypes.number,
};
|
blueocean-material-icons/src/js/components/svg-icons/image/photo-size-select-small.js | kzantow/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const ImagePhotoSizeSelectSmall = (props) => (
<SvgIcon {...props}>
<path d="M23 15h-2v2h2v-2zm0-4h-2v2h2v-2zm0 8h-2v2c1 0 2-1 2-2zM15 3h-2v2h2V3zm8 4h-2v2h2V7zm-2-4v2h2c0-1-1-2-2-2zM3 21h8v-6H1v4c0 1.1.9 2 2 2zM3 7H1v2h2V7zm12 12h-2v2h2v-2zm4-16h-2v2h2V3zm0 16h-2v2h2v-2zM3 3C2 3 1 4 1 5h2V3zm0 8H1v2h2v-2zm8-8H9v2h2V3zM7 3H5v2h2V3z"/>
</SvgIcon>
);
ImagePhotoSizeSelectSmall.displayName = 'ImagePhotoSizeSelectSmall';
ImagePhotoSizeSelectSmall.muiName = 'SvgIcon';
export default ImagePhotoSizeSelectSmall;
|
src/Dialog/DialogFooter.js | kradio3/react-mdc-web | import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';
import { FOOTER, FOOTER_BUTTON, FOOTER_BUTTON_CANCEL, FOOTER_BUTTON_ACCEPT } from './constants';
const propTypes = {
className: PropTypes.string,
children: PropTypes.node,
};
const DialogFooter = ({ className, children }) => {
const last = children.length - 1;
const actions = React.Children.map(children, (action, index) => {
const isLastAction = last === index;
const actionClasses = action.props.className;
const classes = classnames(actionClasses, FOOTER_BUTTON, {
[FOOTER_BUTTON_CANCEL]: !isLastAction,
[FOOTER_BUTTON_ACCEPT]: isLastAction,
});
return React.cloneElement(action, { key: index, className: classes });
});
return (
<footer
className={classnames(FOOTER, className)}
>
{actions}
</footer>
);
};
DialogFooter.propTypes = propTypes;
export default DialogFooter;
|
react-ui/src/containers/MyBooksContainer.js | simmco/trading-book-store | import React from 'react'
import axios from 'axios'
import styled from 'styled-components'
import { connect } from 'react-redux';
import * as actions from '../actions'
import BookOverview from '../components/BookOverview'
import InfoField from '../components/InfoField'
class MyBooksContainer extends React.Component {
componentDidMount = () => {
this.props.getMyBooks()
}
render() {
return (
<Wrapper>
<Books>
<h2>My Books:</h2>
<BookOverview books={this.props.books} />
</Books>
<Info>
<InfoField />
</Info>
</Wrapper>
)
}
}
function mapStateToProps(state) {
return { books: state.myBooks };
}
export default connect(mapStateToProps, actions)(MyBooksContainer)
const Wrapper = styled.div`
display: flex;
flex-wrap: wrap-reverse;
`
const Books = styled.div`
flex: 3;
`
const Info = styled.div`
flex: 1;
border-left: 1px solid #ccc;
padding: 1rem;
@media (max-width: 475px) {
border-left: none;
border-bottom: 1px solid #ccc;
}
` |
imports/ui/pages/Index.js | lizihan021/SAA-Website | import React from 'react';
import { Link } from 'react-router';
import { Grid, Row, Col, FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap';
import Gallery from './Photo.js';
const IMAGES = [
{id: 'img/theGroup',caption:"Our group", orientation: 'square', useForDemo: true },
{id: 'img/last',caption:"Michigan China Forum", orientation: 'square', useForDemo: true },
{id: 'img/graduate',caption:"Graduation ceremony", orientation: 'square', useForDemo: true },
];
var styles = {
fontWeight:'light'
};
const oriimage = function(str){
return str + '.jpg'
}
const thum = function(str){
return str + 'thum.jpg'
}
const Index = () => (
<div className="Index">
<div className="sectionOne">
<Grid>
<div className="row sectionOne-info wow fadeIn">
<div className="col-sm-10 col-sm-offset-1 text-center">
<h1 className="wow fadeIn title-one">WELCOME TO SJTU-SAA</h1>
<br />
<div className="wow fadeIn" data-wow-delay="0.5s">
<p className="lead" >SJTU STUDENT & ALUMNI ASSOCIATION AT UM</p>
</div>
</div>
</div>
</Grid>
</div>
<section id="be-the-first" className="pad-lg" >
<div className="container fourimage">
<div className="row">
<div className="col-sm-8 col-sm-offset-2 text-center margin-30 wow fadeIn">
<h2 className="aboutus" style={{color: '#FFFFFF'}}>ABOUT US</h2>
</div>
</div>
<div className="row">
<div className="first">
<div className="col-sm-6 wow fadeInUp text-center" data-wow-delay="0.1s">
<img id="fourimage" src="img/first.png" alt="Responsive image"/>
<h3 style={{color: '#FFFFFF'}}>The first</h3>
<p style={{color: '#FFFFFF'}}>We are an official student organization,<br/> recognized by both UM and SJTU.</p>
</div>
</div>
<div className="second">
<div className="col-sm-6 wow fadeInUp text-center second" data-wow-delay="0.2s">
<img id="fourimage" src="img/second.png" alt="Responsive image"/>
<h3 style={{color: '#FFFFFF'}}>The second</h3>
<p style={{color: '#FFFFFF'}}>SAA is completely run by students.</p>
</div>
</div>
</div>
<div className="row">
<div className="third">
<div className="col-sm-6 wow fadeInUp text-center third" data-wow-delay="0.3s">
<img id="fourimage" src="img/fourth.png" alt="Responsive image"/>
<h3 style={{color: '#FFFFFF'}}>The third</h3>
<p style={{color: '#FFFFFF'}}>We aims at serving the SJTU students, alumni,<br/> and the broader UM community.</p>
</div>
</div>
<div className="fourth">
<div className="col-sm-6 wow fadeInUp text-center fourth" data-wow-delay="0.3s">
<img id="fourimage" src="img/third.png" alt="Responsive image"/>
<h3 style={{color: '#FFFFFF'}}>The fourth</h3>
<p style={{color: '#FFFFFF'}}>We work closely with university departments,<br/> industry partners, and alumni.</p>
</div>
</div>
</div>
</div>
</section>
<div className="thirdrow" style={styles}>
<Gallery images={IMAGES.map(({ caption, id, orientation, useForDemo }) => ({
src: oriimage(id),
thumbnail: thum(id),
caption,
orientation,
useForDemo,
}))} />
</div>
</div>
);
export default Index; |
src/App.js | baherami/bookapp | import React, { Component } from 'react';
import {Route,Link } from 'react-router-dom';
import './App.css';
import Library from './library'
import * as BooksAPI from './BooksAPI'
import Search from './search'
class App extends Component {
state={
books:[]
}
componentDidMount() {
BooksAPI.getAll().then((data) => this.setState({
books:data
}))
}
moveBooktoAnotherShelf=(book,shelf)=>{
BooksAPI.update(book,shelf).then(
()=>{
console.log("books updated")
BooksAPI.getAll().then(
(data) => this.setState(
{
books:data
})
)
}
)
}
render() {
return (
<div className="App">
<Route exact path="/" render={()=>(
<div>
<Library onBookChange={this.moveBooktoAnotherShelf} books={this.state.books}/>
<Link to="/search" className="open-search">
<p>Add a book</p>
</Link>
</div>
)}/>
<Route path="/search" render={()=><Search onBookChange={this.moveBooktoAnotherShelf}/>}/>
</div>
);
}
}
export default App;
|
screens/RicohTouchDetailScreen/index.js | nattatorn-dev/expo-with-realworld | import React from 'react'
import PropTypes from 'prop-types'
import { nav } from 'utilities'
import Touch from './TouchContainer'
import { HeaderNavigation } from '@components'
const RicohTouchDetailScreen = ( { navigation } ) => (
<Touch navigation={navigation} />
)
RicohTouchDetailScreen.navigationOptions = ( { navigation } ) => ( {
header: (
<HeaderNavigation
navigation={navigation}
title={nav.getNavigationParam( navigation, 'title' )}
/>
),
} )
RicohTouchDetailScreen.propTypes = {
navigation: PropTypes.object.isRequired,
}
export default RicohTouchDetailScreen
|
client/modules/Post/__tests__/components/PostList.spec.js | eantler/google | import React from 'react';
import test from 'ava';
import { shallow } from 'enzyme';
import PostList from '../../components/PostList';
const posts = [
{ name: 'Prashant', title: 'Hello Mern', slug: 'hello-mern', cuid: 'f34gb2bh24b24b2', content: "All cats meow 'mern!'" },
{ name: 'Mayank', title: 'Hi Mern', slug: 'hi-mern', cuid: 'f34gb2bh24b24b3', content: "All dogs bark 'mern!'" },
];
test('renders the list', t => {
const wrapper = shallow(
<PostList posts={posts} handleShowPost={() => {}} handleDeletePost={() => {}} />
);
t.is(wrapper.find('PostListItem').length, 2);
});
|
examples/todomvc/index.js | peteruithoven/redux | import React from 'react';
import App from './containers/App';
import 'todomvc-app-css/index.css';
React.render(
<App />,
document.getElementById('root')
);
|
websites/skraning.vefverdlaun.is/src/app/middlewares/react-router/index.js | svef/www | import React from 'react'
import { BrowserRouter, StaticRouter } from 'react-router-dom'
const router = () => session => {
const context = {}
session.on('server', next => {
next()
if (context.url) {
session.req.redirect(context.status || 302, context.url)
} else if (context.status) {
session.req.status(context.status)
}
})
return async next => {
const children = await next()
if (!process.env.BROWSER && session.req) {
return (
<StaticRouter location={session.req.url} context={context}>
{children}
</StaticRouter>
)
}
return <BrowserRouter>{children}</BrowserRouter>
}
}
export default router
|
app/javascript/plugins/email_pension/SuggestFund.js | SumOfUs/Champaign | import $ from 'jquery';
import React, { Component } from 'react';
import { FormattedMessage } from 'react-intl';
import Input from '../../components/SweetInput/SweetInput';
import Button from '../../components/Button/Button';
export default class SuggestFund extends Component {
constructor() {
super();
this.state = {
showForm: false,
newPensionFundName: '',
isSubmittingNewPensionFundName: false,
newPensionFundNameError: false,
};
}
postSuggestedFund(fund) {
const url = '/api/pension_funds/suggest_fund';
this.setState({ isSubmittingNewPensionFundName: true });
$.post(url, {
'email_target[name]': fund,
})
.done(() => {
this.setState({
showForm: false,
isSubmittingNewPensionFundName: false,
newPensionFundName: '',
newPensionFundNameError: false,
});
})
.fail(() => {
console.log('err');
});
}
toggle = () => {
this.setState(state => ({
...state,
showForm: !state.showForm,
}));
};
onChange = newPensionFundName => {
this.setState(state => ({
...state,
newPensionFundName,
}));
};
submit = e => {
e.preventDefault();
if (this.state.newPensionFundName.trim() === '') {
this.setState({ newPensionFundNameError: true });
} else {
this.postSuggestedFund(this.state.newPensionFundName);
}
};
render() {
const errorMessage = this.state.newPensionFundNameError ? (
<FormattedMessage
id="email_tool.form.errors.suggest_fund"
defaultMessage="Name of pension fund can't be blank"
/>
) : (
''
);
return (
<div className="email-target-action">
<div className="email__target-suggest-fund">
<p>
<a onClick={this.toggle}>
<FormattedMessage
id="email_pension.form.other_pension_fund_text"
defaultMessage="Can't find your pension fund?"
/>
</a>
</p>
</div>
{this.state.showForm && (
<div className="email-target_box">
<h3>
<span>
<FormattedMessage
id="email_tool.form.errors.fund_not_found"
defaultMessage="We're sorry you couldn't find your pension fund. Send us its
name and we'll update our records."
/>
</span>
</h3>
<div className="form__group">
<Input
name="new_pension_fund"
label={
<FormattedMessage
id="email_tool.form.name_of_your_pension_fund"
defaultMessage="Name of your pension fund"
/>
}
value={this.state.newPensionFundName}
onChange={this.onChange}
errorMessage={errorMessage}
/>
</div>
<div className="form__group">
<Button
disabled={this.state.isSubmittingNewPensionFundName}
className="button action-form__submit-button"
onClick={this.submit}
>
<FormattedMessage
id="email_tool.form.send_button_text"
defaultMessage="Send"
/>
</Button>
</div>
</div>
)}
</div>
);
}
}
|
src/client/components/human/view.js | boris91/vendor | import React from 'react';
import { Product } from 'components/index';
import './style.less';
export default class Human extends React.Component {
static defaultProps = {
currencyFormatter: {format: value => value},
purchasedProducts: [],
cash: 0
};
render() {
const { purchasedProducts, currencyFormatter, cash } = this.props;
return (
<div className='human'>
<div className='cash'>Cash: {currencyFormatter.format(cash)}</div>
<div className='purchased-products'>
{purchasedProducts.map(product => (
<Product {...product} notForSale={true} currencyFormatter={currencyFormatter} key={product.name}/>
))}
</div>
</div>
);
}
}; |
src/index.js | jlianphoto/react-auto-dialog | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.jsx';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
|
src/Parser/MistweaverMonk/Modules/Talents/ChiBurst.js | Yuyz0112/WoWAnalyzer | import React from 'react';
import Module from 'Parser/Core/Module';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import SpellLink from 'common/SpellLink';
import { formatPercentage, formatNumber } from 'common/format';
import StatisticBox, { STATISTIC_ORDER } from 'Main/StatisticBox';
const debug = false;
class ChiBurst extends Module {
castChiBurst = 0;
healing = 0;
targetsChiBurst = 0;
avgChiBurstTargets = 0;
raidSize = 0;
on_initialized(){
if(!this.owner.error) {
this.active = this.owner.selectedCombatant.hasTalent(SPELLS.CHI_BURST_TALENT.id);
this.raidSize = Object.entries(this.owner.combatants.players).length;
}
}
on_byPlayer_cast(event) {
const spellId = event.ability.guid;
if(spellId === SPELLS.CHI_BURST_TALENT.id) {
this.castChiBurst++;
}
}
on_byPlayer_heal(event) {
const spellId = event.ability.guid;
const targetId = event.targetID;
if (!this.owner.combatants.players[targetId]) {
return;
}
if(spellId === SPELLS.CHI_BURST_HEAL.id) {
this.healing += (event.amount || 0) + (event.absorbed || 0);
this.targetsChiBurst++;
}
}
suggestions(when) {
when(this.avgChiBurstTargets).isLessThan(this.raidSize * .3)
.addSuggestion((suggest, actual, recommended) => {
return suggest(<span>You are not utilizing your <SpellLink id={SPELLS.CHI_BURST_TALENT.id} /> talent as effectively as you should. You should work on both your positioning and aiming of the spell. Always aim for the highest concentration of players, which is normally melee.</span>)
.icon(SPELLS.CHI_BURST_TALENT.icon)
.actual(`${this.avgChiBurstTargets.toFixed(2)} targets hit per Chi Burst cast - ${formatPercentage(this.avgChiBurstTargets / this.raidSize)}% of raid hit`)
.recommended(`30% of the raid hit is recommended`)
.regular(recommended - .05).major(recommended - .1);
});
}
statistic() {
return (
<StatisticBox
icon={<SpellIcon id={SPELLS.CHI_BURST_TALENT.id} />}
value={`${formatNumber(this.healing)}`}
label={(
<dfn data-tip={`You healed an average of ${this.avgChiBurstTargets.toFixed(2)} targets per Chi Burst cast over your ${this.castChiBurst} casts.`}>
Total Healing
</dfn>
)}
/>
);
}
statisticOrder = STATISTIC_ORDER.OPTIONAL();
on_finished() {
this.avgChiBurstTargets = this.targetsChiBurst / this.castChiBurst || 0;
if(debug) {
console.log('ChiBurst Casts: ' + this.castChiBurst);
console.log('Total Chi Burst Healing: ' + this.healing);
console.log('Chi Burst Targets Hit: ' + this.targetsChiBurst);
}
}
}
export default ChiBurst;
|
src/pages/VerifyEmailPage.js | mDinner/musicansAssistant | import React from 'react';
import DocumentTitle from 'react-document-title';
import { VerifyEmailView } from 'react-stormpath';
export default class VerifyEmailPage extends React.Component {
render() {
var spToken = this.props.location.query.sptoken;
return (
<DocumentTitle title={`Verify Email`}>
<div className="container">
<div className="row">
<div className="col-xs-12">
<h3>Verify Your Account</h3>
<hr />
</div>
</div>
<VerifyEmailView spToken={spToken} />
</div>
</DocumentTitle>
);
}
}
|
src/index.js | cosminseceleanu/react-sb-admin-bootstrap4 | import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/app';
import './css/index.css';
ReactDOM.render(<App />, document.getElementById('root'));
|
app/components/feedback/feedback.js | ritishgumber/dashboard-ui | import React from 'react';
import Popover from 'material-ui/Popover';
import {ToolbarTitle} from 'material-ui/Toolbar';
import Badge from 'material-ui/Badge';
import NotificationsIcon from 'material-ui/svg-icons/social/notifications';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
import IconMenu from 'material-ui/IconMenu';
import IconButton from 'material-ui/IconButton';
import axios from 'axios'
require('./style.css')
class Notifications extends React.Component {
constructor(props) {
super(props)
this.state = {
open: false,
disableSendBtn: true,
value: ''
}
}
handleTouchTap = (event) => {
event.preventDefault();
this.setState({open: true, anchorEl: event.currentTarget, feedbackSent: false})
this.props.updateBeacon(this.props.beacons, 'dashboardFeedback');
}
handleRequestClose = () => {
this.setState({open: false})
}
handleChange(e) {
let value = e.target.value
if (value) {
this.setState({disableSendBtn: false, value: value});
} else {
this.setState({disableSendBtn: true, value: ''});
}
}
sendFeedback() {
console.log(this.props.user);
if (this.state.value) {
// post to slack webhook, make chages here for updating webhook
axios({
url: "https://hooks.slack.com/services/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",
method: 'post',
withCredentials: false,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: {
name: this.props.user.user.name,
email: this.props.user.user.email,
text: this.state.value
}
}).then((res) => {
this.setState({value: ''});
}, (err) => {
this.setState({value: ''});
})
this.setState({feedbackSent: true, value: ''});
}
}
render() {
const disabledBtnStyle = {
fontSize: 10,
marginTop: -1,
background: '#eff1f5',
height: 24,
display: 'block',
paddingTop: 6,
borderRadius: 3,
color: '#b2b1b1'
};
const sendBtnStyle = {
fontSize: 10,
marginTop: -1,
background: '#549afc',
height: 24,
display: 'block',
paddingTop: 6,
borderRadius: 3,
color: 'white'
}
return (
<div >
<IconButton onClick={this.handleTouchTap.bind(this)}>
<svg xmlns="http://www.w3.org/2000/svg" width="29" height="29" viewBox="0 -4 26 26">
<g fill="none" fillRule="evenodd"><path fill="#9e9e9e" d="M2.666 11.995a304.44 304.44 0 0 1-1.841-.776s-.41-.14-.558-.638c-.148-.498-.187-1.058 0-1.627.187-.57.558-.735.558-.735s9.626-4.07 13.64-5.43c.53-.179 1.18-.156 1.18-.156C17.607 2.702 19 6.034 19 9.9c0 3.866-1.62 6.808-3.354 6.84 0 0-.484.1-1.18-.135-2.189-.733-5.283-1.946-7.971-3.035-.114-.045-.31-.13-.338.177v.589c0 .56-.413.833-.923.627l-1.405-.566c-.51-.206-.923-.822-.923-1.378v-.63c.018-.29-.162-.362-.24-.394zM15.25 15.15c1.367 0 2.475-2.462 2.475-5.5s-1.108-5.5-2.475-5.5-2.475 2.462-2.475 5.5 1.108 5.5 2.475 5.5z"/></g>
</svg>
</IconButton>
<span className={this.props.beacons.dashboardFeedback
? 'hide'
: "gps_ring feedback_beacon"} onClick={this.handleTouchTap.bind(this)}></span>
<Popover open={this.state.open} anchorEl={this.state.anchorEl} anchorOrigin={{
horizontal: 'right',
vertical: 'bottom'
}} targetOrigin={{
horizontal: 'right',
vertical: 'top'
}} onRequestClose={this.handleRequestClose} className="feedbackpopover">
<p className="headingpop">Feedback
</p>
<textarea cols="30" rows="4" placeholder="Your thoughts?" className={!this.state.feedbackSent
? "feedback-textarea"
: 'hide'} onChange={this.handleChange.bind(this)} value={this.state.value}></textarea>
<br/>
<div className={!this.state.feedbackSent
? ''
: 'hide'}>
<button className="feedback-sendbtn" onTouchTap={this.sendFeedback.bind(this)} disabled={this.state.disableSendBtn}>Send Feedback</button>
</div>
<div className={this.state.feedbackSent
? 'feedbackSent'
: 'hide'}>
<IconButton touch={true} style={{
marginLeft: '37%',
marginTop: -30
}}>
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 -4 26 26">
<g fill="none" fillRule="evenodd"><path fill="#549afc" d="M2.666 11.995a304.44 304.44 0 0 1-1.841-.776s-.41-.14-.558-.638c-.148-.498-.187-1.058 0-1.627.187-.57.558-.735.558-.735s9.626-4.07 13.64-5.43c.53-.179 1.18-.156 1.18-.156C17.607 2.702 19 6.034 19 9.9c0 3.866-1.62 6.808-3.354 6.84 0 0-.484.1-1.18-.135-2.189-.733-5.283-1.946-7.971-3.035-.114-.045-.31-.13-.338.177v.589c0 .56-.413.833-.923.627l-1.405-.566c-.51-.206-.923-.822-.923-1.378v-.63c.018-.29-.162-.362-.24-.394zM15.25 15.15c1.367 0 2.475-2.462 2.475-5.5s-1.108-5.5-2.475-5.5-2.475 2.462-2.475 5.5 1.108 5.5 2.475 5.5z"/></g>
</svg>
</IconButton>
<span className="thanks-text">Thanks</span>
<span className="note-text">We really appreciate your feedback!</span>
</div>
</Popover>
</div>
)
}
}
export default Notifications;
|
app/javascript/flavours/glitch/containers/mastodon.js | im-in-space/mastodon | import React from 'react';
import { Provider } from 'react-redux';
import PropTypes from 'prop-types';
import configureStore from 'flavours/glitch/store/configureStore';
import { BrowserRouter, Route } from 'react-router-dom';
import { ScrollContext } from 'react-router-scroll-4';
import UI from 'flavours/glitch/features/ui';
import { fetchCustomEmojis } from 'flavours/glitch/actions/custom_emojis';
import { hydrateStore } from 'flavours/glitch/actions/store';
import { connectUserStream } from 'flavours/glitch/actions/streaming';
import { IntlProvider, addLocaleData } from 'react-intl';
import { getLocale } from 'locales';
import initialState from 'flavours/glitch/util/initial_state';
import ErrorBoundary from 'flavours/glitch/components/error_boundary';
const { localeData, messages } = getLocale();
addLocaleData(localeData);
export const store = configureStore();
const hydrateAction = hydrateStore(initialState);
store.dispatch(hydrateAction);
// load custom emojis
store.dispatch(fetchCustomEmojis());
const createIdentityContext = state => ({
signedIn: !!state.meta.me,
accountId: state.meta.me,
accessToken: state.meta.access_token,
});
export default class Mastodon extends React.PureComponent {
static propTypes = {
locale: PropTypes.string.isRequired,
};
static childContextTypes = {
identity: PropTypes.shape({
signedIn: PropTypes.bool.isRequired,
accountId: PropTypes.string,
accessToken: PropTypes.string,
}).isRequired,
};
identity = createIdentityContext(initialState);
getChildContext() {
return {
identity: this.identity,
};
}
componentDidMount() {
if (this.identity.signedIn) {
this.disconnect = store.dispatch(connectUserStream());
}
}
componentWillUnmount () {
if (this.disconnect) {
this.disconnect();
this.disconnect = null;
}
}
shouldUpdateScroll (_, { location }) {
return !(location.state?.mastodonModalKey);
}
render () {
const { locale } = this.props;
return (
<IntlProvider locale={locale} messages={messages}>
<Provider store={store}>
<ErrorBoundary>
<BrowserRouter basename='/web'>
<ScrollContext shouldUpdateScroll={this.shouldUpdateScroll}>
<Route path='/' component={UI} />
</ScrollContext>
</BrowserRouter>
</ErrorBoundary>
</Provider>
</IntlProvider>
);
}
}
|
src/svg-icons/communication/location-on.js | pancho111203/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationLocationOn = (props) => (
<SvgIcon {...props}>
<path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>
</SvgIcon>
);
CommunicationLocationOn = pure(CommunicationLocationOn);
CommunicationLocationOn.displayName = 'CommunicationLocationOn';
CommunicationLocationOn.muiName = 'SvgIcon';
export default CommunicationLocationOn;
|
src/routes/Dashboard/components/sales.js | pmg1989/dva-admin | import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import { color } from 'utils'
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'
import styles from './sales.less'
function Sales ({ data }) {
return (
<div className={styles.sales}>
<div className={styles.title}>Yearly Sales</div>
<ResponsiveContainer minHeight={360}>
<LineChart data={data}>
<Legend verticalAlign="top"
content={(prop) => {
const { payload } = prop
return (<ul className={classnames({ [styles.legend]: true, clearfix: true })}>
{payload.map((item, key) => <li key={key}><span className={styles.radiusdot} style={{ background: item.color }} />{item.value}</li>)}
</ul>)
}}
/>
<XAxis dataKey="name" axisLine={{ stroke: color.borderBase, strokeWidth: 1 }} tickLine={false} />
<YAxis axisLine={false} tickLine={false} />
<CartesianGrid vertical={false} stroke={color.borderBase} strokeDasharray="3 3" />
<Tooltip
wrapperStyle={{ border: 'none', boxShadow: '4px 4px 40px rgba(0, 0, 0, 0.05)' }}
content={(content) => {
const list = content.payload.map((item, key) => <li key={key} className={styles.tipitem}><span className={styles.radiusdot} style={{ background: item.color }} />{`${item.name}:${item.value}`}</li>)
return <div className={styles.tooltip}><p className={styles.tiptitle}>{content.label}</p><ul>{list}</ul></div>
}}
/>
<Line type="monotone" dataKey="Food" stroke={color.purple} strokeWidth={3} dot={{ fill: color.purple }} activeDot={{ r: 5, strokeWidth: 0 }} />
<Line type="monotone" dataKey="Clothes" stroke={color.red} strokeWidth={3} dot={{ fill: color.red }} activeDot={{ r: 5, strokeWidth: 0 }} />
<Line type="monotone" dataKey="Electronics" stroke={color.green} strokeWidth={3} dot={{ fill: color.green }} activeDot={{ r: 5, strokeWidth: 0 }} />
</LineChart>
</ResponsiveContainer>
</div>
)
}
Sales.propTypes = {
data: PropTypes.array,
}
export default Sales
|
tools/public-components.js | deerawan/react-bootstrap | import React from 'react';
import * as index from '../src/index';
let components = [];
Object.keys(index).forEach(function(item) {
if (index[item] instanceof React.Component.constructor) {
components.push(item);
}
});
export default components;
|
docs/app/Examples/modules/Dropdown/Types/DropdownExamplePointing.js | aabustamante/Semantic-UI-React | import React from 'react'
import { Dropdown, Icon, Menu } from 'semantic-ui-react'
const DropdownExamplePointing = () => (
<Menu>
<Menu.Item>
Home
</Menu.Item>
<Dropdown text='Shopping' pointing className='link item'>
<Dropdown.Menu>
<Dropdown.Header>Categories</Dropdown.Header>
<Dropdown.Item>
<Icon name='dropdown' />
<span className='text'>Clothing</span>
<Dropdown.Menu>
<Dropdown.Header>Mens</Dropdown.Header>
<Dropdown.Item>Shirts</Dropdown.Item>
<Dropdown.Item>Pants</Dropdown.Item>
<Dropdown.Item>Jeans</Dropdown.Item>
<Dropdown.Item>Shoes</Dropdown.Item>
<Dropdown.Divider />
<Dropdown.Header>Womens</Dropdown.Header>
<Dropdown.Item>Dresses</Dropdown.Item>
<Dropdown.Item>Shoes</Dropdown.Item>
<Dropdown.Item>Bags</Dropdown.Item>
</Dropdown.Menu>
</Dropdown.Item>
<Dropdown.Item>Home Goods</Dropdown.Item>
<Dropdown.Item>Bedroom</Dropdown.Item>
<Dropdown.Divider />
<Dropdown.Header>Order</Dropdown.Header>
<Dropdown.Item>Status</Dropdown.Item>
<Dropdown.Item>Cancellations</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
<Menu.Item>
Forums
</Menu.Item>
<Menu.Item>
Contact Us
</Menu.Item>
</Menu>
)
export default DropdownExamplePointing
|
src/components/dock/index.js | manweill/dna-ebook | import React from 'react'
import PropTypes from 'prop-types'
import { StyleSheet } from 'react-native'
import Item from './Item'
import { View } from 'react-native-animatable'
class Dock extends React.PureComponent {
static Item = Item
ref = null
componentDidUpdate = (prevProps, prevState) => {
if (this.props.visible !== prevProps.visible && this.props.visible) {
this.ref.animate('fadeInUp', 300)
}
}
componentWillUpdate = (nextProps, nextState) => {
if (this.props.visible !== nextProps.visible && !nextProps.visible) {
this.ref.animate('fadeOut', 300)
}
}
render() {
const { children, visible, renderItemView } = this.props
return visible ? (
<View
style={styles.container}
ref={ref => {
this.ref = ref
}}
>
<View>{renderItemView}</View>
<View style={styles.dock}>{children}</View>
</View>
) : null
}
}
Dock.propTypes = {
visible: PropTypes.bool
}
Dock.defaultProps = {
visible: null
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#000000',
bottom: 0,
position: 'absolute',
width: '100%',
zIndex: 100
},
dock: {
alignItems: 'center',
flex: 1,
flexDirection: 'row',
height: 50
},
dockItem: {
alignItems: 'center',
flex: 1
},
dockText: {
color: '#ffffff'
}
})
export default Dock
|
src/components/inputLabel/InputLabel.js | DaveOrDead/react-dnd-character-generator | import React from 'react';
import getClassNameString from '../../utils/getClassNameString';
/**
* InputLabel component. Accompanies a form input to describe it.
*/
const InputLabel = ({labelText, inputId, isHidden}) => {
const classList = getClassNameString({
'c-input-label': true,
'h-hide-visually': isHidden
});
return (
<label
className={classList}
htmlFor={inputId}>
{labelText}
</label>
);
};
/**
* propTypes
* @property {boolean} isHidden - Hide the label.
* @property {boolean} inputId - Id attribute for the accompanying input.
* @property {string} [labelText] - The text for the label.
*/
InputLabel.propTypes = {
inputId: React.PropTypes.string,
isHidden: React.PropTypes.bool,
labelText: React.PropTypes.string.isRequired
};
export default InputLabel;
|
src/desktop/components/fair_week_marketing/PageScaffold.js | kanaabe/force | import PropTypes from 'prop-types'
import React from 'react'
import styled, { ThemeProvider } from 'styled-components'
import colors from 'reaction/Assets/Colors'
import { Row, Col } from 'reaction/Components/Grid'
import Text from 'reaction/Components/Text'
import Title from 'reaction/Components/Title'
const Container = styled.div`
margin: 0 auto;
max-width: 1192px;
padding-top: 25px;
@media (max-width: 48em) {
padding: 10px 20px 0;
}
`
const SectionTitle = Title.extend`
margin-top: 0;
line-height: 1;
`
const IntroductionText = Text.extend`
line-height: 31px;
margin-bottom: 20px;
color: ${colors.grayDark};
@media (max-width: 24em) {
font-size: 20px;
line-height: 26px;
}
`
const FairLogo = styled.img`
width: 100%;
display: inline;
@media (min-width: 48em) {
max-width: 160px;
}
`
const ResponsiveRow = styled(Row)`
${props =>
props.paddingBottom &&
`padding-bottom: ${props.paddingBottom}px;`} @media (max-width: 48em) {
margin-left: -8px;
margin-right: -8px;
}
`
const ReveredColumnOnMobile = styled.div`
@media (max-width: 48em) {
display: flex;
flex-direction: column-reverse;
img {
margin-left: auto;
margin-right: auto;
}
}
`
const theme = {
flexboxgrid: {
breakpoints: {
// em, not pixels
xs: 0,
sm: 24,
md: 48,
lg: 64,
},
},
}
export const FairWeekPageScaffold = ({
introduction,
fair_coverage,
event,
prepare_for_fairs,
displayStickyFooter,
}) => (
<ThemeProvider theme={theme}>
<Container>
<ResponsiveRow paddingBottom={50}>
<Col lg={4} md={4} sm={12} xs={12}>
<SectionTitle
titleSize="large"
dangerouslySetInnerHTML={{ __html: introduction.title }}
/>
</Col>
<Col lg={8} md={8} sm={12} xs={12}>
<ReveredColumnOnMobile>
<IntroductionText textSize="xlarge">
{introduction.description}
</IntroductionText>
<img
style={{ marginTop: 30, marginBottom: 20, maxWidth: '100%' }}
src={introduction.image}
/>
</ReveredColumnOnMobile>
</Col>
</ResponsiveRow>
<ResponsiveRow paddingBottom={50}>
<Col lg={4} md={4} sm={12} xs={12}>
<SectionTitle titleSize="large">{fair_coverage.title}</SectionTitle>
</Col>
<Col lg={8} md={8} sm={12} xs={12}>
<ResponsiveRow paddingBottom={20}>
{fair_coverage.fairs.map(fair => (
<Col lg={3} md={3} sm={3} xs={6} key={fair.logo_url}>
{fair.site_url && fair.site_url.startsWith('http') ? (
<a href={fair.site_url} target="_blank">
<FairLogo src={fair.logo_url} />
</a>
) : (
<FairLogo src={fair.logo_url} />
)}
</Col>
))}
</ResponsiveRow>
</Col>
</ResponsiveRow>
{event && (
<ResponsiveRow paddingBottom={45}>
<Col lg={4} md={4} sm={12} xs={12}>
<SectionTitle titleSize="large">{event.title}</SectionTitle>
</Col>
<Col lg={8} md={8} sm={12} xs={12}>
<img
style={{ marginBottom: 10, width: '100%' }}
src={event.banner_image_url}
/>
<ResponsiveRow>
<Col lg={7} md={8} sm={12} xs={12} style={{ marginBottom: 25 }}>
<Text textSize="medium">{event.description}</Text>
</Col>
<Col lg={5} md={12} sm={12} xs={12} style={{ marginBottom: 25 }}>
<Text
textSize="medium"
color={colors.grayDark}
dangerouslySetInnerHTML={{
__html: event.public_viewing_date,
}}
/>
</Col>
</ResponsiveRow>
</Col>
</ResponsiveRow>
)}
<ResponsiveRow>
<Col lg={4} md={4} sm={12} xs={12}>
<SectionTitle titleSize="large">
{prepare_for_fairs.title}
</SectionTitle>
</Col>
<Col lg={8} md={8} sm={12} xs={12}>
{prepare_for_fairs.articles.map(article => (
<ResponsiveRow paddingBottom={25} key={article.title}>
<Col lg={7} md={7} sm={6} xs={12}>
<a href={article.article_url} target="_blank">
<img
style={{ marginBottom: 10, width: '100%' }}
src={article.image_url}
/>
</a>
</Col>
<Col lg={5} md={5} sm={6} xs={12}>
<a
href={article.article_url}
style={{ textDecoration: 'none' }}
target="_blank"
>
<Title
titleSize="small"
style={{ margin: '0 0 5px', lineHeight: 1 }}
>
{article.title}
</Title>
<Text textStyle="primary" textSize="small">
{article.author}
</Text>
</a>
</Col>
</ResponsiveRow>
))}
</Col>
</ResponsiveRow>
{displayStickyFooter && <div id="react-root-for-cta" />}
</Container>
</ThemeProvider>
)
FairWeekPageScaffold.propTypes = {
introduction: PropTypes.object,
fair_coverage: PropTypes.object,
event: PropTypes.object,
prepare_for_fairs: PropTypes.object,
displayStickyFooter: PropTypes.bool,
}
|
src/svg-icons/communication/speaker-phone.js | hai-cea/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationSpeakerPhone = (props) => (
<SvgIcon {...props}>
<path d="M7 7.07L8.43 8.5c.91-.91 2.18-1.48 3.57-1.48s2.66.57 3.57 1.48L17 7.07C15.72 5.79 13.95 5 12 5s-3.72.79-5 2.07zM12 1C8.98 1 6.24 2.23 4.25 4.21l1.41 1.41C7.28 4 9.53 3 12 3s4.72 1 6.34 2.62l1.41-1.41C17.76 2.23 15.02 1 12 1zm2.86 9.01L9.14 10C8.51 10 8 10.51 8 11.14v9.71c0 .63.51 1.14 1.14 1.14h5.71c.63 0 1.14-.51 1.14-1.14v-9.71c.01-.63-.5-1.13-1.13-1.13zM15 20H9v-8h6v8z"/>
</SvgIcon>
);
CommunicationSpeakerPhone = pure(CommunicationSpeakerPhone);
CommunicationSpeakerPhone.displayName = 'CommunicationSpeakerPhone';
CommunicationSpeakerPhone.muiName = 'SvgIcon';
export default CommunicationSpeakerPhone;
|
src/app/d3components/utilities/axis.js | cox-auto-kc/react-d3-responsive | 'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import d3 from 'd3';
class Axis extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
this.renderAxis();
}
componentDidUpdate() {
this.renderAxis();
}
renderAxis() {
const node = ReactDOM.findDOMNode(this);
d3.select(node)
.call(this.props.axis);
}
render(){
const translate = "translate(0,"+(this.props.h)+")";
return (
<g className="axis" transform={this.props.axisType === 'x' ? translate:""} />
);
}
}
Axis.propTypes = {
h:React.PropTypes.number,
axis:React.PropTypes.func,
axisType:React.PropTypes.oneOf(['x','y'])
};
export default Axis;
|
src/svg-icons/action/autorenew.js | spiermar/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionAutorenew = (props) => (
<SvgIcon {...props}>
<path d="M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"/>
</SvgIcon>
);
ActionAutorenew = pure(ActionAutorenew);
ActionAutorenew.displayName = 'ActionAutorenew';
ActionAutorenew.muiName = 'SvgIcon';
export default ActionAutorenew;
|
node_modules/react-bootstrap/es/Breadcrumb.js | Chen-Hailin/iTCM.github.io | 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 BreadcrumbItem from './BreadcrumbItem';
import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
var Breadcrumb = function (_React$Component) {
_inherits(Breadcrumb, _React$Component);
function Breadcrumb() {
_classCallCheck(this, Breadcrumb);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Breadcrumb.prototype.render = function render() {
var _props = this.props;
var className = _props.className;
var props = _objectWithoutProperties(_props, ['className']);
var _splitBsProps = splitBsProps(props);
var bsProps = _splitBsProps[0];
var elementProps = _splitBsProps[1];
var classes = getClassSet(bsProps);
return React.createElement('ol', _extends({}, elementProps, {
role: 'navigation',
'aria-label': 'breadcrumbs',
className: classNames(className, classes)
}));
};
return Breadcrumb;
}(React.Component);
Breadcrumb.Item = BreadcrumbItem;
export default bsClass('breadcrumb', Breadcrumb); |
node_modules/react-router/es/IndexLink.js | aalpgiray/react-hot-boilerplate-ts | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
import React from 'react';
import Link from './Link';
/**
* An <IndexLink> is used to link to an <IndexRoute>.
*/
var IndexLink = React.createClass({
displayName: 'IndexLink',
render: function render() {
return React.createElement(Link, _extends({}, this.props, { onlyActiveOnIndex: true }));
}
});
export default IndexLink; |
src/components/Weui/panel/panel.js | ynu/res-track-wxe | /**
* Created by n7best.
*/
import React from 'react';
import classNames from 'classnames';
export default class Panel extends React.Component {
static propTypes = {
access: React.PropTypes.bool,
};
static defaultProps = {
access: false,
};
render() {
const {children, className, access, ...others} = this.props;
const cls = classNames({
'weui-panel': true,
weui_panel_access: access,
[className]: className
});
return (
<div className={cls} {...others}>{children}</div>
);
}
};
|
1_simple_server_render/browserEntry.js | chkui/react-server-demo | 'use strict';
import React from 'react'
import {render} from 'react-dom'
import App from './app'
render(<App />, document.getElementById('root')) |
src/views/Home/Home.js | okoala/react-redux-antd | import React from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import Action from '../../store/actions'
import { QueueAnim, Table } from 'antd'
import { Link } from 'react-router'
import Nodebar from '../../components/Nodebar/Nodebar'
import TopicList from '../../components/TopicList/TopicList'
import './Home.less'
@connect(
state => ({...state}),
dispatch => bindActionCreators(Action, dispatch)
)
export default class HomeView extends React.Component {
constructor () {
super()
}
componentWillMount () {
}
render () {
return (
<div className="content">
<Nodebar/>
<TopicList dataSource={this.props.topic.current}/>
</div>
)
}
}
|
browser/src/index.js | powellquiring/bigimage | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<App />,
document.getElementById('root')
);
|
information/blendle-frontend-react-source/app/components/navigation/LocaleDropdown.js | BramscoChill/BlendleParser | import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import { find } from 'lodash';
import dropdownMixin from 'components/mixins/DropdownMixin';
import classNames from 'classnames';
import i18n from 'instances/i18n';
import { getExceptionForCountry } from 'helpers/countryExceptions';
const locales = [
{ code: 'nl_NL', label: 'Nederland' },
{ code: 'de_DE', label: 'Deutschland' },
{ code: 'en_US', label: 'USA' },
{ code: 'fr_FR', label: 'Français' },
];
const LocaleDropdown = createReactClass({
displayName: 'LocaleDropdown',
propTypes: {
// should be a locale code like `nl_NL`
selected: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
},
mixins: [dropdownMixin()],
_onChange(code, ev) {
ev.preventDefault();
this.toggleDropdown();
this.props.onChange(code);
},
_renderOptions() {
return i18n.supportedCountryLocales
.filter(
locale => !getExceptionForCountry(locale.split('_')[1], 'hideFromCountrySelector', false),
)
.map(locale => find(locales, { code: locale }))
.filter(x => x)
.map(locale => (
<a
key={locale.code}
href="#"
className={`lang-${locale.code}`}
onClick={this._onChange.bind(this, locale.code)}
>
{locale.label}
</a>
));
},
_renderSelected() {
const lang = find(locales, { code: this.props.selected });
return (
<div className={`lang-${lang.code}`}>
<label>{lang.label}</label>
</div>
);
},
render() {
const className = classNames('v-locale-dropdown', { 's-active': this.state.open });
return (
<div className={className}>
<div className="handle" onClick={this.toggleDropdown}>
{this._renderSelected()}
</div>
<div className="v-locale-list">{this._renderOptions()}</div>
</div>
);
},
});
export default LocaleDropdown;
// WEBPACK FOOTER //
// ./src/js/app/components/navigation/LocaleDropdown.js |
app/react-icons/fa/yahoo.js | scampersand/sonos-front | import React from 'react';
import IconBase from 'react-icon-base';
export default class FaYahoo extends React.Component {
render() {
return (
<IconBase viewBox="0 0 40 40" {...this.props}>
<g><path d="m22.2 21.4l0.3 15.7q-1.4-0.2-2.4-0.2-0.9 0-2.3 0.2l0.3-15.7q-0.9-1.6-3.8-6.6t-4.8-8.4-4.1-6.4q1.3 0.3 2.4 0.3 1 0 2.5-0.3 1.4 2.5 3 5.1t3.7 6.2 3.1 5.1q0.8-1.4 2.5-4t2.6-4.2 2.3-4 2.4-4.2q1.2 0.3 2.4 0.3 1.3 0 2.6-0.3-0.7 0.9-1.4 2t-1.1 1.7-1.3 2.2-1 1.8q-3.3 5.6-7.9 13.7z"/></g>
</IconBase>
);
}
}
|
packages/react/components/subnavbar.js | iamxiaoma/Framework7 | import React from 'react';
import Utils from '../utils/utils';
import Mixins from '../utils/mixins';
import __reactComponentSlots from '../runtime-helpers/react-component-slots.js';
import __reactComponentSetProps from '../runtime-helpers/react-component-set-props.js';
class F7Subnavbar extends React.Component {
constructor(props, context) {
super(props, context);
}
render() {
const self = this;
const props = self.props;
const {
inner,
title,
style,
id,
className,
sliding
} = props;
const classes = Utils.classNames(className, 'subnavbar', {
sliding
}, Mixins.colorClasses(props));
return React.createElement('div', {
className: classes,
id: id,
style: style
}, inner ? React.createElement('div', {
className: 'subnavbar-inner'
}, title && React.createElement('div', {
className: 'subnavbar-title'
}, title), this.slots['default']) : this.slots['default']);
}
get slots() {
return __reactComponentSlots(this.props);
}
}
__reactComponentSetProps(F7Subnavbar, Object.assign({
id: [String, Number],
className: String,
style: Object,
sliding: Boolean,
title: String,
inner: {
type: Boolean,
default: true
}
}, Mixins.colorProps));
F7Subnavbar.displayName = 'f7-subnavbar';
export default F7Subnavbar; |
packages/xo-web/src/xo-app/xoa/support/index.js | vatesfr/xo-web | import _ from 'intl'
import ActionButton from 'action-button'
import AnsiUp from 'ansi_up'
import decorate from 'apply-decorators'
import React from 'react'
import { addSubscriptions, adminOnly, getXoaPlan } from 'utils'
import { Card, CardBlock, CardHeader } from 'card'
import { Container, Row, Col } from 'grid'
import { injectState, provideState } from 'reaclette'
import { closeTunnel, openTunnel, subscribeTunnelState } from 'xo'
import { reportOnSupportPanel } from 'report-bug-button'
const ansiUp = new AnsiUp()
const COMMUNITY = getXoaPlan() === 'Community'
const Support = decorate([
adminOnly,
addSubscriptions({
tunnelState: subscribeTunnelState,
}),
provideState({
computed: {
stdoutSupportTunnel: (_, { tunnelState }) =>
tunnelState === undefined ? undefined : { __html: ansiUp.ansi_to_html(tunnelState.stdout) },
},
}),
injectState,
({
effects,
state: { stdoutSupportTunnel, xoaStatus },
tunnelState: { open, stdout } = { open: false, stdout: '' },
}) => (
<Container>
{COMMUNITY && (
<Row className='mb-2'>
<Col>
<span className='text-info'>{_('supportCommunity')}</span>
</Col>
</Row>
)}
<Row className='mb-1'>
<Col>
<ActionButton btnStyle='primary' disabled={COMMUNITY} handler={reportOnSupportPanel} icon='ticket'>
{_('createSupportTicket')}
</ActionButton>
</Col>
</Row>
<Row>
<Col mediumSize={6}>
<Card>
<CardHeader>{_('xoaCheck')}</CardHeader>
<CardBlock>
<ActionButton
btnStyle='success'
disabled={COMMUNITY}
handler={effects.forceRefreshXoaStatus}
icon='diagnosis'
>
{_('checkXoa')}
</ActionButton>
<hr />
<pre
dangerouslySetInnerHTML={{
__html: ansiUp.ansi_to_html(xoaStatus),
}}
/>
</CardBlock>
</Card>
</Col>
<Col mediumSize={6}>
<Card>
<CardHeader>{_('supportTunnel')}</CardHeader>
<CardBlock>
<Row>
<Col>
{open ? (
<ActionButton btnStyle='primary' disabled={COMMUNITY} handler={closeTunnel} icon='remove'>
{_('closeTunnel')}
</ActionButton>
) : (
<ActionButton btnStyle='success' disabled={COMMUNITY} handler={openTunnel} icon='open-tunnel'>
{_('openTunnel')}
</ActionButton>
)}
</Col>
</Row>
<hr />
{open || stdout !== '' ? (
<pre
className={!open && stdout !== '' && 'text-danger'}
dangerouslySetInnerHTML={stdoutSupportTunnel}
/>
) : (
<span>{_('supportTunnelClosed')}</span>
)}
</CardBlock>
</Card>
</Col>
</Row>
</Container>
),
])
export default Support
|
frontend/src/app/containers/ErrorPage.js | mathjazz/testpilot | import React from 'react';
import Copter from '../components/Copter';
import LayoutWrapper from '../components/LayoutWrapper';
import View from '../components/View';
export default class ErrorPage extends React.Component {
render() {
return (
<View spaceBetween={true} showNewsletterFooter={false} {...this.props}>
<LayoutWrapper flexModifier="column-center">
<div id="four-oh-four" className="modal centered">
<header className="modal-header-wrapper neutral-modal">
<h1 data-l10n-id="errorHeading" className="modal-header">Whoops!</h1>
</header>
<div className="modal-content">
<p data-l10n-id="errorMessage">Looks like we broke something. <br /> Maybe try again later.</p>
</div>
</div>
<Copter animation="fade-in-fly-up" />
</LayoutWrapper>
</View>
);
}
}
ErrorPage.propTypes = {
uninstallAddon: React.PropTypes.func,
sendToGA: React.PropTypes.func,
openWindow: React.PropTypes.func
};
|
src/svg-icons/action/flip-to-front.js | kasra-co/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionFlipToFront = (props) => (
<SvgIcon {...props}>
<path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm2 4v-2H3c0 1.1.89 2 2 2zM3 9h2V7H3v2zm12 12h2v-2h-2v2zm4-18H9c-1.11 0-2 .9-2 2v10c0 1.1.89 2 2 2h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12H9V5h10v10zm-8 6h2v-2h-2v2zm-4 0h2v-2H7v2z"/>
</SvgIcon>
);
ActionFlipToFront = pure(ActionFlipToFront);
ActionFlipToFront.displayName = 'ActionFlipToFront';
ActionFlipToFront.muiName = 'SvgIcon';
export default ActionFlipToFront;
|
src/PerfViewJS/spa/src/components/ProcessList.js | vancem/perfview | import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import base64url from 'base64url';
export class ProcessList extends Component {
static displayName = ProcessList.name;
constructor(props) {
super(props);
this.state = { processes: [], loading: true };
fetch('/api/processlist?filename=' + this.props.match.params.dataFile + '&stacktype=' + this.props.match.params.stackType, { method: 'GET', headers: { 'Content-Type': 'application/json' } })
.then(res => res.json())
.then(data => {
this.setState({ processes: data, loading: false });
});
}
static renderProcessListTable(processes, dataFile, stackType) {
return (
<table className='table table-striped'>
<thead>
<tr>
<th>Process Name</th>
<th>CPU MSec</th>
</tr>
</thead>
<tbody>
{processes.map(process =>
<tr key={`${process.id}`}>
<td><Link to={`/ui/hotspots/${base64url.encode(JSON.stringify({ a: dataFile, b: stackType, c: process.id, d: '', e: '', f: '', g: '', h: process.id === -1 ? '' : 'Process% ' + process.name, i: '', j: '', k: '' }), "utf8")}`}>{process.name}</Link></td>
<td>{process.cpumSec}</td>
</tr>
)}
</tbody>
</table>
);
}
render() {
let contents = this.state.loading ? <p><em>Loading...</em></p> : ProcessList.renderProcessListTable(this.state.processes, this.props.match.params.dataFile, this.props.match.params.stackType);
return (
<div>
<h1>Process List</h1>
{contents}
</div>
);
}
}
|
lib/index.js | RemeJuan/react-balloon.css | import React from 'react';
import styled, { css } from 'styled-components';
import { prop, ifProp } from 'styled-tools';
const animation = ({ always, message }) => (
(!always && message) ? css`
animation-name: fadeIn;
animation-duration: 0.2s;
` : null
);
const top = css`
bottom: 100%;
left: 50%;
transform: translate(-50%, 10px);
transform-origin: top;
`;
const topHover = css`
transform: translate(-50%, 0);
`;
const bottom = css`
left: 50%;
top: 100%;
transform: translate(-50%, -10px);
`;
const bottomHover = topHover;
const left = css`
right: 100%;
top: 50%;
transform: translate(10px, -50%);
`;
const leftHover = css`
transform: translate(0, -50%);
`;
const right = css`
left: 100%;
top: 50%;
transform: translate(10px, -50%);
`;
const rightHover = leftHover;
const always = ({ position }) => {
if (position === 'left' || position === 'right') {
return css`${leftHover}`;
}
return css`${topHover}`;
};
const TooltipWrapper = styled.span`
@keyframes fadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
overflow: visible;
position: relative;
&:before {
${ifProp({ position: 'top' }, css`
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(0)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
height: 6px;
width: 18px;
${top};
margin-bottom: 5px;
`)};
${ifProp({ position: 'bottom' }, css`
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
height: 6px;
width: 18px;
${bottom};
margin-top: 5px;
`)};
${ifProp({ position: 'left' }, css`
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(-90 18 18)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
width: 6px;
height: 18px;
${left};
margin-right: 5px;
`)};
${ifProp({ position: 'right' }, css`
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(90 6 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
width: 6px;
height: 18px;
${right};
margin-left: 5px;
`)};
background-size: 100% auto;
content: " ";
opacity: ${ifProp('always', 1, 0)};
transform: translate(-50%,0);
position: absolute;
${ifProp('always', always)}
}
&:after {
${ifProp({ position: 'top' }, css`
${top};
margin-bottom: 11px;
`)}
${ifProp({ position: 'bottom' }, css`
${bottom};
margin-top: 11px;
`)}
${ifProp({ position: 'left' }, css`
${left};
margin-right: 11px;
`)}
${ifProp({ position: 'right' }, css`
${right};
margin-left: 11px;
`)}
background: rgba(17, 17, 17, 0.9);
border-radius: 4px;
color: #fff;
font-size: 12px;
padding: .5em 1em;
white-space: normal;
margin-bottom: 11px;
width: ${ifProp({ length: 'small' }, '80px', ifProp({ length: 'medium' }, '150', ifProp({ length: 'large' }, '260px', ifProp({ length: 'xlarge' }, '380px', '100%'))))};
opacity: ${ifProp('always', 1, 0)};
pointer-events: none;
position: absolute;
z-index: 10;
background-size: 100% auto;
content: "${prop('message')}";
${ifProp('always', always)}
}
&:hover {
display: ${ifProp('blockChild', 'block')};
&:after {
${animation};
opacity: ${ifProp('message', 1, 0)};
pointer-events: auto;
${ifProp({ position: 'top' }, topHover)}
${ifProp({ position: 'bottom' }, bottomHover)}
${ifProp({ position: 'left' }, leftHover)}
${ifProp({ position: 'right' }, rightHover)}
}
&:before {
${animation};
opacity: ${ifProp('message', 1, 0)};
pointer-events: auto;
${ifProp({ position: 'top' }, topHover)}
${ifProp({ position: 'bottom' }, bottomHover)}
${ifProp({ position: 'left' }, leftHover)}
${ifProp({ position: 'right' }, rightHover)}
}
}
`;
const Tooltip = ({ children, ...rest }) => (
<TooltipWrapper
{...rest}
>
{children}
</TooltipWrapper>
);
Tooltip.defaultProps = {
message: undefined,
length: 'fit',
blockChild: false,
always: false,
position: 'top',
};
export default Tooltip;
|
webpack/move_to_pf/LoadingState/LoadingState.js | johnpmitsch/katello | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { translate as __ } from 'foremanReact/common/I18n';
import { Spinner } from 'patternfly-react';
import './LoadingState.scss';
class LoadingState extends Component {
constructor(props) {
super(props);
this.state = {
render: false,
};
}
componentDidMount() {
setTimeout(() => {
this.setState({ render: true });
}, this.props.timeout);
}
render() {
const { loading, loadingText, children } = this.props;
const spinner = (
<div className="loading-state">
<Spinner loading={loading} size="lg" />
<p>{loadingText}</p>
</div>);
if (loading) {
return this.state.render ? spinner : null;
}
return children;
}
}
LoadingState.propTypes = {
loading: PropTypes.bool,
loadingText: PropTypes.string,
children: PropTypes.node,
timeout: PropTypes.number,
};
LoadingState.defaultProps = {
loading: false,
loadingText: __('Loading'),
children: null,
timeout: 300,
};
export default LoadingState;
|
src/templates/blog-post.js | JacobPrice/jacobprice.io | import React from 'react';
import Helmet from 'react-helmet';
import BackIcon from 'react-icons/lib/fa/chevron-left';
import ForwardIcon from 'react-icons/lib/fa/chevron-right';
import Link from '../components/Link';
import Tags from '../components/tags';
import '../css/blog-post.css';
export default function Template({ data, pathContext }) {
const { markdownRemark: post } = data;
const { next, prev } = pathContext;
return (
<div className="blog-post-container">
<Helmet title={`Gatsby Blog - ${post.frontmatter.title}`} />
<div className="blog-post">
<h1 className="title">
{post.frontmatter.title}
</h1>
<h2 className="date">
{post.frontmatter.date}
</h2>
<div
className="blog-post-content"
dangerouslySetInnerHTML={{ __html: post.html }}
/>
<Tags list={post.frontmatter.tags || []} />
<div className="navigation">
{prev &&
<Link className="link prev" to={prev.frontmatter.path}>
<BackIcon /> {prev.frontmatter.title}
</Link>}
{next &&
<Link className="link next" to={next.frontmatter.path}>
{next.frontmatter.title} <ForwardIcon />
</Link>}
</div>
</div>
</div>
);
}
export const pageQuery = graphql`
query BlogPostByPath($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
html
frontmatter {
date(formatString: "MMMM DD, YYYY")
path
tags
title
}
}
}
`;
|
app/client/src/scenes/ManageCampaignSettings/ManageCampaignSettings.js | uprisecampaigns/uprise-app | import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { compose, graphql } from 'react-apollo';
import { connect } from 'react-redux';
import FontIcon from 'material-ui/FontIcon';
import camelCase from 'camelcase';
import CampaignSettingsForm from 'components/CampaignSettingsForm';
import Link from 'components/Link';
import formWrapper from 'lib/formWrapper';
import {
validateString,
validateWebsiteUrl,
validateState,
validateZipcode,
validateZipcodeList,
validateEmail,
validatePhoneNumber,
} from 'lib/validateComponentForms';
import CampaignQuery from 'schemas/queries/CampaignQuery.graphql';
import MeQuery from 'schemas/queries/MeQuery.graphql';
import EditCampaignMutation from 'schemas/mutations/EditCampaignMutation.graphql';
import s from 'styles/Organize.scss';
const WrappedCampaignSettingsForm = formWrapper(CampaignSettingsForm);
export class ManageCampaignSettings extends Component {
static propTypes = {
campaign: PropTypes.object,
user: PropTypes.object.isRequired,
editCampaignMutation: PropTypes.func.isRequired,
// eslint-disable-next-line react/no-unused-prop-types
graphqlLoading: PropTypes.bool.isRequired,
// eslint-disable-next-line react/no-unused-prop-types
campaignSlug: PropTypes.string.isRequired,
};
static defaultProps = {
campaign: undefined,
};
constructor(props) {
super(props);
const initialState = {
formData: {
title: '',
profileSubheader: '',
description: '',
profileImageUrl: '',
streetAddress: '',
streetAddress2: '',
websiteUrl: '',
phoneNumber: '',
email: '',
city: '',
state: '',
zipcode: '',
legalOrg: false,
orgWebsite: '',
orgName: '',
orgStatus: '',
orgContactName: '',
orgContactPosition: '',
orgContactEmail: '',
orgContactPhone: '',
tags: [],
zipcodeList: '',
locationType: null,
legislativeDistrictType: null,
locationDistrictNumber: '',
locationState: '',
},
};
this.state = Object.assign({}, initialState);
}
componentWillMount() {
this.handleCampaignProps(this.props);
}
componentWillReceiveProps(nextProps) {
this.handleCampaignProps(nextProps);
}
handleCampaignProps = (nextProps) => {
if (nextProps.campaign && !nextProps.graphqlLoading) {
// Just camel-casing property keys and checking for null/undefined
const campaign = Object.assign(
...Object.keys(nextProps.campaign).map((k) => {
if (nextProps.campaign[k] !== null) {
return { [camelCase(k)]: nextProps.campaign[k] };
}
return undefined;
}),
);
Object.keys(campaign).forEach((k) => {
if (!Object.keys(this.state.formData).includes(camelCase(k))) {
delete campaign[k];
}
});
campaign.zipcodeList = typeof campaign.zipcodeList === 'object' ? campaign.zipcodeList.join(',') : '';
this.setState((prevState) => ({
formData: Object.assign({}, prevState.formData, campaign),
}));
}
};
defaultErrorText = {
titleErrorText: null,
streetAddressErrorText: null,
websiteUrlErrorText: null,
phoneNumberErrorText: null,
cityErrorText: null,
stateErrorText: null,
zipcodeErrorText: null,
orgNameErrorText: null,
orgWebsiteErrorText: null,
orgStatusErrorText: null,
orgContactPositionErrorText: null,
orgContactEmailErrorText: null,
orgContactPhoneErrorText: null,
zipcodeListErrorText: null,
locationDistrictNumberErrorText: null,
};
formSubmit = async (data) => {
// A little hackish to avoid an annoying rerender with previous form data
// If I could figure out how to avoid keeping state here
// w/ the componentWillReceiveProps/apollo/graphql then
// I might not need this
this.setState({
formData: Object.assign({}, data),
});
const formData = Object.assign({}, data);
formData.id = this.props.campaign.id;
formData.zipcodeList = formData.zipcodeList.split(',').map((zip) => zip.trim());
try {
await this.props.editCampaignMutation({
variables: {
data: formData,
},
// TODO: decide between refetch and update
refetchQueries: ['CampaignQuery', 'CampaignsQuery', 'MyCampaignsQuery'],
});
return { success: true, message: 'Changes Saved' };
} catch (e) {
console.error(e);
return { success: false, message: e.message };
}
};
render() {
if (this.props.campaign) {
const { state, formSubmit, defaultErrorText } = this;
const { campaign, user } = this.props;
const { formData } = state;
const validators = [
(component) => validateString(component, 'title', 'titleErrorText', 'Campaign Name is Required'),
(component) => validateString(component, 'phoneNumber', 'phoneNumberErrorText', 'Phone Number is Required'),
(component) => validateZipcode(component),
(component) => validateWebsiteUrl(component),
(component) => validatePhoneNumber(component),
(component) => validateState(component),
(component) => {
if (component.state.formData.legalOrg) {
validateString(component, 'orgWebsite', 'orgWebsiteErrorText', 'Organization Website is required');
validateString(component, 'orgName', 'orgNameErrorText', 'Organization Name is required');
validateString(component, 'orgStatus', 'orgStatusErrorText', 'Organization Status is required');
validateWebsiteUrl(component, 'orgWebsite', 'orgWebsiteErrorText');
validateString(component, 'orgContactPhone', 'orgContactPhoneErrorText', 'Phone Number is Required');
validatePhoneNumber(component, 'orgContactPhone', 'orgContactPhoneErrorText');
validateEmail(component, 'orgContactEmail', 'orgContactEmailErrorText');
}
},
(component) => {
validateState(component, 'locationState', 'locationStateErrorText');
},
validateZipcodeList,
];
return (
<div className={s.outerContainer}>
<div className={[s.innerContainer, s.bareContainer].join(' ')}>
{/*
<Link to={`/organize/${campaign.slug}`}>
<div className={s.navHeader}>
<FontIcon className={['material-icons', s.backArrow].join(' ')}>arrow_back</FontIcon>
{campaign.title}
</div>
</Link>
*/}
<div className={s.sectionHeaderContainer}>
<div className={s.pageHeader}>{campaign.title}</div>
{campaign.profile_subheader && <div className={s.sectionSubheader}>{campaign.profile_subheader}</div>}
</div>
<div className={s.crumbs}>
<div className={s.navHeader}>
<Link to={`/organize/${campaign.slug}`}>{campaign.title}</Link>
<FontIcon className={['material-icons', 'arrowRight'].join(' ')}>keyboard_arrow_right</FontIcon>
Campaign Settings
</div>
</div>
<WrappedCampaignSettingsForm
initialState={formData}
initialErrors={defaultErrorText}
validators={validators}
submit={formSubmit}
submitText="Save Profile"
user={user}
campaign={campaign}
campaignId={campaign.id}
/>
</div>
</div>
);
}
return null;
}
}
const withMeQuery = graphql(MeQuery, {
props: ({ data }) => ({
user:
!data.loading && data.me
? data.me
: {
email: '',
},
}),
});
const withCampaignQuery = graphql(CampaignQuery, {
options: (ownProps) => ({
variables: {
search: {
slug: ownProps.campaignSlug,
},
},
fetchPolicy: 'cache-and-network',
}),
props: ({ data }) => ({
campaign: data.campaign,
graphqlLoading: data.loading,
}),
});
export default compose(
connect(),
withMeQuery,
withCampaignQuery,
graphql(EditCampaignMutation, { name: 'editCampaignMutation' }),
)(ManageCampaignSettings);
|
app/boards/motec-d153/components/modes/fuel-level-lap.js | fermio/motorsport-display | import React from 'react';
const FuelLevelLap = React.createClass({
propTypes: {
dash: React.PropTypes.object.isRequired,
fuel: React.PropTypes.object.isRequired,
game: React.PropTypes.object.isRequired
},
shouldComponentUpdate: function(nextProps, nextState) {
return true;
},
render: function() {
return (
<div id="fuel-level-lap" className="column">
<span className="label">FUEL</span>
<span className="value">{this.props.game.FuelLevel}</span>
<span className="label">AVG</span>
<span className="value"></span>
</div>
);
}
});
export default FuelLevelLap;
|
src/AntdComp.js | ShaneKing/sk-antd | import PropTypes from 'prop-types';
import React from 'react';
import {Proxy0, SK} from 'sk-js';
import {Comp, Model, Reacts, SKDiv} from 'sk-react';
import {SIZE} from './AntdConst';
/**
* 1.The defaultProps and propTypes of AntD just can be use in wrapper Comp or non-Comp
* 2.if origin exist, must be use origin
*/
export default class AntdComp extends Comp {
static SK_COMP_NAME = 'AntdComp';
static SK_PROPS = SK.extends(true, {}, Comp.SK_PROPS, {
SIZE: 'size',
});
static defaultProps = SK.extends(true, {}, Comp.defaultProps, {});
static propTypes = SK.extends(true, {}, Comp.propTypes, {
size: PropTypes.oneOf(Object.values(SIZE)),
skSize: PropTypes.oneOf(Object.values(SIZE)),
});
constructor(...args) {
super(...args);
this.SK_COMP_NAME = AntdComp.SK_COMP_NAME;
}
// react
componentDidMount() {
super.componentDidMount();
this.addAllErroredMonitor();
this.addExtendErroredMonitor();
}
componentWillUpdate() {
this.rmvAllErroredMonitor();
this.rmvExtendErroredMonitor();
super.componentWillUpdate();
}
componentDidUpdate() {
super.componentDidUpdate();
this.addAllErroredMonitor();
this.addExtendErroredMonitor();
}
componentWillUnmount() {
this.rmvAllErroredMonitor();
this.rmvExtendErroredMonitor();
super.componentWillUnmount();
}
// monitor
addAllErroredMonitor() {
Model.parseSao(this.props.monitor).forEach((idOrReg) => {
this.addErroredMonitor(idOrReg);
});
//Self value monitor
if (this.getModelId()) {
this.addErroredMonitor(this.getModelId());
}
}
addErroredMonitor(idOrReg) {
if (this.monitors.indexOf(idOrReg) < 0) {
this.monitors.push(idOrReg);
}
if (Proxy0._.isRegExp(idOrReg)) {
this.skModel().addRegErroredListener(idOrReg, this.updateUI);
} else {
this.skModel().addIdErroredListener(idOrReg, this.updateUI);
}
}
addExtendErroredMonitor() {
}
rmvAllErroredMonitor() {
this.monitors.forEach((idOrReg) => {
this.rmvErroredMonitor(idOrReg);
});
}
rmvErroredMonitor(idOrReg) {
if (Proxy0._.isRegExp(idOrReg)) {
this.skModel().rmvRegErroredListener(idOrReg, this.updateUI);
} else {
this.skModel().rmvIdErroredListener(idOrReg, this.updateUI);
}
this.monitors.skRmv(idOrReg);
}
rmvExtendErroredMonitor() {
}
//@Deprecated
hasSpecialChild(specialChildName) {
return Reacts.some(this.props.children, $child => $child.type && $child.type.name === specialChildName, this);
}
renderAntdCompPreview() {
return (<SKDiv>{this.m2v()}</SKDiv>);
}
}
|
app/components/message-history.js | vladimirgamalian/TheTurkBot | import React from 'react';
var Message = React.createClass({
render: function () {
return (
<div className={this.props.message.own ? 'message-container-own':'message-container'}>
<div className='message'>{this.props.message.text}</div>
</div>
);
}
});
var MessageHistory = React.createClass({
render: function () {
var data = this.props.data;
var messageTemplate = data.map(function(item, index) {
return (
<Message message={item} key={index}>This is one comment</Message>
)
});
return (
<div className="messages">
{messageTemplate}
</div>
);
}
});
export default MessageHistory;
|
app/main.js | zhangmingkai4315/webpack-react-es6-starter | import React from 'react';
import ReactDOM from 'react-dom';
import Component from './src/Component_1.js';
class Hello extends React.Component {
render() {
return (< div >
< h1 > HELLO WORLD < /h1> < Component / >
< /div>);
}
}
ReactDOM.render(<Hello/>, document.getElementById('container'));
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.