path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
components/scenes/stairs.js | dbow/89-steps | import React from 'react';
class Stairs extends React.Component {
render() {
return (
<div>
<h2>The Stairs</h2>
<p>This will be good!!</p>
</div>
);
}
}
export default Stairs;
|
src/components/AnimatedWrapper/AnimatedWrapper.js | denichodev/personal-web | import React, { Component } from 'react';
import * as Animated from 'animated/lib/targets/react-dom';
const AnimatedWrapper = WrappedComponent =>
class AnimatedWrapper extends Component {
constructor(props) {
super(props);
this.state = {
animate: new Animated.Value(0)
};
}
componentWillAppear(cb) {
Animated.spring(this.state.animate, { toValue: 1 }).start();
cb();
}
componentWillEnter(cb) {
setTimeout(
() => Animated.spring(this.state.animate, { toValue: 1 }).start(),
250
);
cb();
}
componentWillLeave(cb) {
Animated.spring(this.state.animate, { toValue: 0 }).start();
setTimeout(() => cb(), 175);
}
render() {
const style = {
opacity: Animated.template`${this.state.animate}`,
transform: Animated.template`
translate3d(0,${this.state.animate.interpolate({
inputRange: [0, 1],
outputRange: ['12px', '0px']
})},0)
`
};
return (
<Animated.div style={style} className="animated-page-wrapper">
<WrappedComponent {...this.props} />
</Animated.div>
);
}
};
export default AnimatedWrapper;
|
cm19/ReactJS/your-first-react-app-exercises-master/exercise-16/shared/Card.js | Brandon-J-Campbell/codemash | import React from 'react';
import classNames from 'classnames';
import theme from '../theme/static';
import styles from './Card.css';
export default function Card({ children }) {
return (
<div className={classNames(styles.card, styles[theme])}>{children}</div>
);
}
|
client/views/room/components/MessageTemplate/Header.js | VoiSmart/Rocket.Chat | import { Box, Margins } from '@rocket.chat/fuselage';
import React from 'react';
function Header({ children }) {
return (
<Box rcx-message__header display='flex' flexGrow={0} flexShrink={1} withTruncatedText>
<Box
mi='neg-x2'
display='flex'
flexDirection='row'
alignItems='baseline'
withTruncatedText
flexGrow={1}
flexShrink={1}
>
<Margins inline='x2'> {children} </Margins>
</Box>
</Box>
);
}
export default Header;
|
src/routes.js | dorono/wecansavedemocracy | import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './containers/app';
import ActivitiesList from './containers/ActivitiesList/activities_index';
import ActivitiesNew from './containers/ActivitiesNew/activities_new';
import FindRep from './containers/FindRep/findRepresentative';
export default (
<Route path="/" component={App}>
<IndexRoute component={ActivitiesList} />
<Route path="actions/new" component={ActivitiesNew} />
<Route path="find-representative" component={FindRep} />
</Route>
);
|
src/views/DashboardManager/components/widgets/BtnControlWidget.js | giux78/daf-dataportal | import React from 'react';
import {Modal} from 'react-modal-bootstrap';
import App from '../InfinityScrollWidgets/App.js'
class BtnControlWidget extends React.Component {
constructor() {
super();
this.state = {
isModalAddOpen: false,
isModalOpen: false
}
this.addWidgetOpenModal = this.addWidgetOpenModal.bind(this)
this.addWidget = this.addWidget.bind(this)
this.openModal = this.openModal.bind(this)
this.closeModal = this.closeModal.bind(this)
}
moveDown = function(index) {
let rows = this.props.layout.rows;
let from = index;
let to = index + 1;
rows.splice(to, 0, rows.splice(from, 1)[0]);
this.props.setLayout(this.props.layout);
}
moveUp = function(index) {
let rows = this.props.layout.rows;
let from = index;
let to = index - 1;
rows.splice(to, 0, rows.splice(from, 1)[0]);
this.props.setLayout(this.props.layout);
}
removeCol = function () {
let rows = this.props.layout.rows;
let row = rows[this.props.index]
let columns = row.columns;
for(let i=0; i < columns.length; i++) {
let column = columns[i];
if(column.widgets){
for(let j=0; j < column.widgets.length; j++) {
let widget = column.widgets[j];
if(widget.key !='BtnControlWidget_0'){
let widgetsArr = this.props.dashboardWidgets;
if(widgetsArr[widget.key]){
delete widgetsArr[widget.key];
}
}
}
}
}
rows.splice(this.props.index, 1);
this.props.setLayout(this.props.layout, true);
}
openModal = function(e){
e.stopPropagation();
e.preventDefault();
e.nativeEvent.stopImmediatePropagation();
this.setState({
isModalOpen: true
})
}
closeModal = function (){
this.setState({
isModalOpen: false
})
}
addWidgetOpenModal = function() {
this.setState({
isModalAddOpen: true
});
}
addWidget = function(widgetName) {
this.props.addWidget(widgetName, this.props.index);
this.onRequestClose();
}
onRequestClose = () => {
this.setState({
isModalAddOpen: false,
});
}
setCol = function (size, index, align) {
let sizeClass = "col-xs-12";
//set size class
if (size == 1) {
sizeClass = "col-lg-12 col-md-12 col-sm-12 col-xs-12";
} else if (size == 2) {
sizeClass = "col-lg-6 col-md-6 col-sm-6 col-xs-6";
} else if (size == 3) {
sizeClass = "col-lg-4 col-md-4 col-sm-4 col-xs-4";
} else if (size == 4) {
sizeClass = "col-lg-3 col-md-3 col-sm-3 col-xs-3";
}
//add or remove columns on row
let max = size;
if (max < this.props.layout.rows[index].columns.length) {
max = this.props.layout.rows[index].columns.length;
}
let control = this.props.layout.rows[index].columns.pop();
for(let i=0; i < max; i++) {
//set column 30/70
if (size == 2 && align == 1 && i == 0) {
sizeClass = "col-lg-4 col-md-4 col-sm-4 col-xs-4";
}
if (size == 2 && align == 1 && i == 1) {
sizeClass = "col-lg-8 col-md-8 col-sm-8 col-xs-8";
}
//set column 70/30
if (size == 2 && align == 2 && i == 1) {
sizeClass = "col-lg-4 col-md-4 col-sm-4 col-xs-4";
}
if (size == 2 && align == 2 && i == 0) {
sizeClass = "col-lg-8 col-md-8 col-sm-8 col-xs-8";
}
if (i <= size) {
//crea colonna
if (!this.props.layout.rows[index].columns[i]) {
this.props.layout.rows[index].columns[i] = {
className: sizeClass,
widgets: []
}
} else {
//update size col
this.props.layout.rows[index].columns[i].className=sizeClass;
}
}
//rimuovi colonna
if (i >= size && this.props.layout.rows[index].columns[i]) {
this.props.layout.rows[index].columns.splice(i);
}
}
this.props.layout.rows[index].columns.push(control);
this.props.setLayout(this.props.layout, true);
this.closeModal();
}
render() {
return (
<div className="btn-control-widget">
<button type="button" className="btn btn-sm btn-gray-200" aria-label="Add Widget"
onClick={this.addWidgetOpenModal}>
<span className="fa fa-plus" aria-hidden="true"></span>
</button>
{ this.props.index != 0 &&
<button type="button" className="btn btn-sm btn-gray-200" aria-label="Move Up"
onClick={() => this.moveUp(this.props.index)}>
<span className="fa fa-chevron-up" aria-hidden="true"></span>
</button>
}
{ this.props.index != this.props.layout.rows.length - 1 &&
<button type="button" className="btn btn-sm btn-gray-200" aria-label="Move Down"
onClick={() => this.moveDown(this.props.index)}>
<span className="fa fa-chevron-down" aria-hidden="true"></span>
</button>
}
<button type="button" className="btn btn-sm btn-gray-200" aria-label="Remove"
onClick={() => this.removeCol()}>
<span className="fa fa-trash" aria-hidden="true"></span>
</button>
<button type="button" className="btn btn-sm btn-gray-200" aria-label="Change witdh"
onClick={this.openModal}>
<span className="fa fa-edit" aria-hidden="true"></span>
</button>
<App
widgets={this.props.widgets}
isModalOpen={this.state.isModalAddOpen}
onWidgetSelect={this.addWidget}
onRequestClose={this.onRequestClose}
/>
<Modal
contentLabel="Set width columns"
className="Modal__Bootstrap modal-dialog"
isOpen={this.state.isModalOpen}>
<div className="modal-content">
<div className="modal-header">
<button type="button" className="close" onClick={this.closeModal}>
<span aria-hidden="true">×</span>
<span className="sr-only">Close</span>
</button>
<h4 className="modal-title">Scegli il layout</h4>
</div>
<div className="modal-body">
<div className="row p-s-10">
<div className="layout-container col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div className="row layout-box" onClick={() => this.setCol(1, this.props.index)}>
<div className="col-xs-12 col-sm-12 col-md-12 col-lg-12">
100%
</div>
</div>
</div>
<div className="layout-container col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div className="row layout-box" onClick={() => this.setCol(3, this.props.index)}>
<div className="col-xs-4 col-sm-4 col-md-4 col-lg-4">
33%
</div>
<div className="col-xs-4 col-sm-4 col-md-4 col-lg-4">
33%
</div>
<div className="col-xs-4 col-sm-4 col-md-4 col-lg-4">
33%
</div>
</div>
</div>
<div className="layout-container col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div className="row layout-box" onClick={() => this.setCol(4, this.props.index)}>
<div className="col-xs-3 col-sm-3 col-md-3 col-lg-3">
25%
</div>
<div className="col-xs-3 col-sm-3 col-md-3 col-lg-3">
25%
</div>
<div className="col-xs-3 col-sm-3 col-md-3 col-lg-3">
25%
</div>
<div className="col-xs-3 col-sm-3 col-md-3 col-lg-3">
25%
</div>
</div>
</div>
</div>
<div className="row p-s-10">
<div className="layout-container col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div className="row layout-box" onClick={() => this.setCol(2, this.props.index, 1)}>
<div className="col-xs-4 col-sm-4 col-md-4 col-lg-4">
30%
</div>
<div className="col-xs-8 col-sm-8 col-md-8 col-lg-8">
70%
</div>
</div>
</div>
<div className="layout-container col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div className="row layout-box" onClick={() => this.setCol(2, this.props.index)}>
<div className="col-xs-6 col-sm-6 col-md-6 col-lg-6">
50%
</div>
<div className="col-xs-6 col-sm-6 col-md-6 col-lg-6">
50%
</div>
</div>
</div>
<div className="layout-container col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div className="row layout-box" onClick={() => this.setCol(2, this.props.index, 2)}>
<div className="col-xs-8 col-sm-8 col-md-8 col-lg-8">
70%
</div>
<div className="col-xs-4 col-sm-4 col-md-4 col-lg-4">
30%
</div>
</div>
</div>
</div>
</div>
<div className="modal-footer">
<button onClick={this.closeModal} type="button" className="btn btn-gray-200" >Chiudi</button>
</div>
</div>
</Modal>
</div>
);
}
}
export default BtnControlWidget; |
src/routes.js | yangli1990/Isomorphic-Universal-React-Template | import React from 'react';
import App from './Components/App';
import { Route } from 'react-router';
import Counter from './Components/Counter/Counter';
export default <Route path="/" component={App}>
<Route path="counter" component={Counter} />
</Route>;
|
src/components/AbstractSystemComponent.js | brochington/Akkad | import React from 'react';
import _ from 'lodash';
// import Immutable from 'immutable';
class AbstractSystemComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.id = Math.floor((1 + Math.random()) * 10000000000).toString(16);
this._propsChanged = true;
}
static abstractType = "AbstractSystemComponent";
static contextTypes = {
appState: React.PropTypes.object,
actions: React.PropTypes.object,
entityID: React.PropTypes.string
}
/**
* Accepts a non-complex map of props, and compares it to the previous batch.
* Needed because hot reloading doesn't always trigger shouldComponentUpdate().
*/
/* eslint-disable */
propsChanged = (nextProps) => {
// const InextProps = Immutable.Map(nextProps);
// const areSame = Immutable.is(this.oldProps, InextProps);
//
// this.oldProps = InextProps;
//
// return areSame;
this._propsChanged = !_.isEqual(nextProps, this.props);
return this._propsChanged;
}
/* eslint-enable */
render() {
// return this.props.children ? this.props.children : null;
return this.props.children ? (
<div>
{this.props.children}
</div>
) : null;
}
}
export default AbstractSystemComponent;
|
client/components/error/ServerError.js | andela-jmacharia/hati-DMS | import React from 'react';
import { Route } from 'react-router';
import AppError from './AppError';
const ServerError = () => (
<AppError>
<center>
<h2 className="title">The Proverbial Internal Server Error :/</h2>
<div className="container-fluid">
<p>The minions broke something :(</p>
<p>Go back maybe? <i className="material-icons">mood</i></p>
<button type="button" className="btn btn-block"><Route path="/">HOME</Route></button>
</div>
</center>
</AppError>
);
export default ServerError;
|
src/parser/rogue/shared/azeritetraits/SharpenedBlades.js | FaideWW/WoWAnalyzer | import React from 'react';
import { formatNumber } from 'common/format';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import SPECS from 'game/SPECS';
import Analyzer from 'parser/core/Analyzer';
class SharpenedBlades extends Analyzer {
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTrait(SPELLS.SHARPENED_BLADES.id);
this.wastedStacks = 0;
if(this.selectedCombatant.spec === SPECS.ASSASSINATION_ROGUE) {
this.sharpenedBladesConsumer = SPELLS.POISONED_KNIFE;
} else {
this.sharpenedBladesConsumer = SPELLS.SHURIKEN_TOSS;
}
}
on_byPlayer_cast(event) {
if (event.ability.guid !== SPELLS.MELEE.id) {
return;
}
const buff = this.selectedCombatant.getBuff(SPELLS.SHARPENED_BLADES_BUFF.id);
if(buff !== undefined && buff.stacks === 30) {
this.wastedStacks++;
}
}
get wastedStacksPm() {
return this.wastedStacks / (this.owner.fightDuration / 1000) * 60;
}
get suggestionThresholds() {
return {
actual: this.wastedStacksPm,
isGreaterThan: {
minor: 10,
average: 20,
major: 30,
},
};
}
suggestions(when) {
when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
return suggest(<>You are wasting <SpellLink id={SPELLS.SHARPENED_BLADES.id} icon /> stacks. Try to cast <SpellLink id={this.sharpenedBladesConsumer.id} icon /> at 29+ stacks.</>)
.icon(SPELLS.SHARPENED_BLADES.icon)
.actual(`${formatNumber(this.wastedStacksPm)} stacks wasted per minute.`)
.recommended(`<10 is recommended`);
});
}
}
export default SharpenedBlades;
|
node_modules/babel-plugin-react-transform/test/fixtures/code-class-extends-component-with-render-method/expected.js | lzm854676408/big-demo | import _transformLib from 'transform-lib';
const _components = {
Foo: {
displayName: 'Foo'
}
};
const _transformLib2 = _transformLib({
filename: '%FIXTURE_PATH%',
components: _components,
locals: [],
imports: []
});
function _wrapComponent(id) {
return function (Component) {
return _transformLib2(Component, id);
};
}
import React, { Component } from 'react';
const Foo = _wrapComponent('Foo')(class Foo extends Component {
render() {}
});
|
src/ButtonInput.js | xiaoking/react-bootstrap | import React from 'react';
import Button from './Button';
import FormGroup from './FormGroup';
import InputBase from './InputBase';
import childrenValueValidation from './utils/childrenValueInputValidation';
class ButtonInput extends InputBase {
renderFormGroup(children) {
let {bsStyle, value, ...other} = this.props;
return <FormGroup {...other}>{children}</FormGroup>;
}
renderInput() {
let {children, value, ...other} = this.props;
let val = children ? children : value;
return <Button {...other} componentClass="input" ref="input" key="input" value={val} />;
}
}
ButtonInput.types = ['button', 'reset', 'submit'];
ButtonInput.defaultProps = {
type: 'button'
};
ButtonInput.propTypes = {
type: React.PropTypes.oneOf(ButtonInput.types),
bsStyle() {
// defer to Button propTypes of bsStyle
return null;
},
children: childrenValueValidation,
value: childrenValueValidation
};
export default ButtonInput;
|
scripts/components/App.js | LulzAugusto/catch-of-the-day | /*
App
*/
import React from 'react';
import Rebase from 're-base';
const base = Rebase.createClass('https://catch-of-the-day-lulz.firebaseio.com/');
import Catalyst from 'react-catalyst';
import sampleFishes from '../sample-fishes';
import Inventory from './Inventory';
import Order from './Order';
import Header from './Header';
import Fish from './Fish';
var App = React.createClass({
mixins: [Catalyst.LinkedStateMixin],
getInitialState: function() {
return {
fishes: {},
order: {}
};
},
componentDidMount: function() {
base.syncState(this.props.params.storeId + '/fishes', {
context: this,
state: 'fishes'
});
var state = localStorage.getItem('order-' + this.props.params.storeId);
if (state) {
this.setState({ order: JSON.parse(state) });
}
},
componentWillUpdate: function(nextProps, nextState) {
localStorage.setItem('order-' + this.props.params.storeId, JSON.stringify(nextState.order));
},
addToOrder: function(key) {
this.state.order[key] = this.state.order[key] + 1 || 1;
this.setState({ order: this.state.order });
},
removeFromOrder: function(key) {
delete this.state.order[key];
this.setState({ order: this.state.order });
},
addFish: function(fish) {
var timestamp = new Date().getTime();
this.state.fishes['fish-' + timestamp] = fish;
this.setState({ fishes: this.state.fishes });
},
removeFish: function(key) {
if (confirm('Are you sure you wanto to remove this fish?!')) {
this.state.fishes[key] = null;
this.setState({ fishes: this.state.fishes });
}
},
loadSamples: function() {
this.setState({ fishes: sampleFishes });
},
renderFish: function(key) {
return <Fish key={key} index={key} details={this.state.fishes[key]} addToOrder={this.addToOrder}/>
},
render: function() {
return (
<div className="catch-of-the-day">
<div className="menu">
<Header tagline="Fresh Seafod Market"/>
<ul className="list-of-fishes">
{Object.keys(this.state.fishes).map(this.renderFish)}
</ul>
</div>
<Order order={this.state.order} fishes={this.state.fishes} removeFromOrder={this.removeFromOrder}/>
<Inventory fishes={this.state.fishes} addFish={this.addFish} loadSamples={this.loadSamples} linkState={this.linkState} removeFish={this.removeFish} />
</div>
)
}
});
export default App;
|
modules/Redirect.js | leeric92/react-router | import React from 'react';
import invariant from 'invariant';
import { createRouteFromReactElement } from './RouteUtils';
import { formatPattern } from './URLUtils';
import { falsy } from './PropTypes';
var { string, object } = React.PropTypes;
export var Redirect = React.createClass({
statics: {
createRouteFromReactElement(element) {
var route = createRouteFromReactElement(element);
if (route.from)
route.path = route.from;
route.onEnter = function (nextState, transition) {
var { location, params } = nextState;
var pathname = route.to ? formatPattern(route.to, params) : location.pathname;
transition.to(
pathname,
route.query || location.query,
route.state || location.state
);
};
return route;
}
},
propTypes: {
path: string,
from: string, // Alias for path
to: string.isRequired,
query: object,
state: object,
onEnter: falsy,
children: falsy
},
render() {
invariant(
false,
'<Redirect> elements are for router configuration only and should not be rendered'
);
}
});
export default Redirect;
|
local-cli/templates/HelloWorld/App.js | Bhullnatik/react-native | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
export default class App 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 App.js
</Text>
<Text style={styles.instructions}>
{instructions}
</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,
},
});
|
src/Navigation.js | wangliguang/myRNTools | import React, { Component } from 'react';
import { StackNavigator } from 'react-navigation';
import { useAPIWeaver } from './tools/API/API.js';
import {
initNetEventListener,
} from './tools/API/NetManager.js';
import {
registerNavigator,
unRegisterNavigator,
InitailRoute,
getRouteMap,
} from './Route';
initNetEventListener();
// HomePage: { screen: HomePage, navigationOptions: ({navigation}) => StackOptions({navigation}) },
// GGTimer: { screen: GGTimerScene, navigationOptions: ({navigation}) => StackOptions({navigation})},
// GGLimitDoubleClickBtn: { screen: GGLimitDoubleClickBtnScene, navigationOptions: ({navigation}) => StackOptions({navigation}) },
// Storage: { screen: StorageScene, navigationOptions: ({navigation}) => StackOptions({navigation})},
// keyBoard: { screen: KeyBoardScene, navigationOptions: ({navigation}) => StackOptions({navigation})},
// TypeTab: { screen: TypeTabScene, navigationOptions: ({navigation}) => StackOptions({navigation})},
// FirstScene: { screen: FirstScene, navigationOptions: ({navigation}) => StackOptions({navigation})},
// ScendScene: { screen: ScendScene, navigationOptions: ({navigation}) => StackOptions({navigation})},
// ThirdScene: { screen: ThirdScene, navigationOptions: ({navigation}) => StackOptions({navigation})},
// StackOptions = (navigator) => {
// registerNavigator(navigator);
// }
// 注册导航
const AppNavigator = StackNavigator(
getRouteMap(),
{
initialRouteName: InitailRoute.routeName, // 默认显示界面
navigationOptions: { header: null },
mode: 'card', // 页面切换模式, 左右是card(相当于iOS中的push效果), 上下是modal(相当于iOS中的modal效果)
headerMode: 'screen', // 导航栏的显示模式, screen: 有渐变透明效果, float: 无透明效果, none: 隐藏导航栏
onTransitionEnd: (() => {
if (global.scenes) {
const currentScene = global.scenes[global.scenes.length - 1];
if (currentScene.componentWillAppear) {
currentScene.componentWillAppear();
}
}
}),
});
class App extends React.Component {
componentDidMount(){
registerNavigator(this.navigator);
}
componentWillUnmount() {
unRegisterNavigator();
}
render() {
return (
<AppNavigator
ref={nav => { this.navigator = nav; }}
/>
);
}
}
export default App; |
fields/types/html/HtmlField.js | BlakeRxxk/keystone | import _ from 'underscore';
import Field from '../Field';
import React from 'react';
import tinymce from 'tinymce';
import { FormInput } from 'elemental';
/**
* TODO:
* - Remove dependency on underscore
*/
var lastId = 0;
function getId() {
return 'keystone-html-' + lastId++;
}
module.exports = Field.create({
displayName: 'HtmlField',
getInitialState () {
return {
id: getId(),
isFocused: false
};
},
initWysiwyg () {
if (!this.props.wysiwyg) return;
var self = this;
var opts = this.getOptions();
opts.setup = function (editor) {
self.editor = editor;
editor.on('change', self.valueChanged);
editor.on('focus', self.focusChanged.bind(self, true));
editor.on('blur', self.focusChanged.bind(self, false));
};
this._currentValue = this.props.value;
tinymce.init(opts);
},
componentDidUpdate (prevProps, prevState) {
if (prevState.isCollapsed && !this.state.isCollapsed) {
this.initWysiwyg();
}
if (_.isEqual(this.props.dependsOn, this.props.currentDependencies)
&& !_.isEqual(this.props.currentDependencies, prevProps.currentDependencies)) {
var instance = tinymce.get(prevState.id);
if (instance) {
tinymce.EditorManager.execCommand('mceRemoveEditor', true, prevState.id);
this.initWysiwyg();
} else {
this.initWysiwyg();
}
}
},
componentDidMount () {
this.initWysiwyg();
},
componentWillReceiveProps (nextProps) {
if (this.editor && this._currentValue !== nextProps.value) {
this.editor.setContent(nextProps.value);
}
},
focusChanged (focused) {
this.setState({
isFocused: focused
});
},
valueChanged () {
var content;
if (this.editor) {
content = this.editor.getContent();
} else if (this.refs.editor) {
content = this.refs.editor.getDOMNode().value;
} else {
return;
}
this._currentValue = content;
this.props.onChange({
path: this.props.path,
value: content
});
},
getOptions () {
var plugins = ['code', 'link'],
options = _.defaults(
{},
this.props.wysiwyg,
Keystone.wysiwyg.options
),
toolbar = options.overrideToolbar ? '' : 'bold italic | alignleft aligncenter alignright | bullist numlist | outdent indent | link',
i;
if (options.enableImages) {
plugins.push('image');
toolbar += ' | image';
}
if (options.enableCloudinaryUploads || options.enableS3Uploads) {
plugins.push('uploadimage');
toolbar += options.enableImages ? ' uploadimage' : ' | uploadimage';
}
if (options.additionalButtons) {
var additionalButtons = options.additionalButtons.split(',');
for (i = 0; i < additionalButtons.length; i++) {
toolbar += (' | ' + additionalButtons[i]);
}
}
if (options.additionalPlugins) {
var additionalPlugins = options.additionalPlugins.split(',');
for (i = 0; i < additionalPlugins.length; i++) {
plugins.push(additionalPlugins[i]);
}
}
if (options.importcss) {
plugins.push('importcss');
var importcssOptions = {
content_css: options.importcss,
importcss_append: true,
importcss_merge_classes: true
};
_.extend(options.additionalOptions, importcssOptions);
}
if (!options.overrideToolbar) {
toolbar += ' | code';
}
var opts = {
selector: '#' + this.state.id,
toolbar: toolbar,
plugins: plugins,
menubar: options.menubar || false,
skin: options.skin || 'keystone'
};
if (this.shouldRenderField()) {
opts.uploadimage_form_url = options.enableS3Uploads ? '/keystone/api/s3/upload' : '/keystone/api/cloudinary/upload';
} else {
_.extend(opts, {
mode: 'textareas',
readonly: true,
menubar: false,
toolbar: 'code',
statusbar: false
});
}
if (options.additionalOptions){
_.extend(opts, options.additionalOptions);
}
return opts;
},
getFieldClassName () {
var className = this.props.wysiwyg ? 'wysiwyg' : 'code';
return className;
},
renderField () {
var className = this.state.isFocused ? 'is-focused' : '';
var style = {
height: this.props.height
};
return (
<div className={className}>
<FormInput multiline ref='editor' style={style} onChange={this.valueChanged} id={this.state.id} className={this.getFieldClassName()} name={this.props.path} value={this.props.value} />
</div>
);
},
renderValue () {
return <FormInput multiline noedit value={this.props.value} />;
}
});
|
packages/icons/src/md/image/SlideShow.js | suitejs/suitejs | import React from 'react';
import IconBase from '@suitejs/icon-base';
function MdSlideShow(props) {
return (
<IconBase viewBox="0 0 48 48" {...props}>
<path d="M20 16v16l10-8-10-8zM38 6c2.21 0 4 1.79 4 4v28c0 2.21-1.79 4-4 4H10c-2.21 0-4-1.79-4-4V10c0-2.21 1.79-4 4-4h28zm0 32V10H10v28h28z" />
</IconBase>
);
}
export default MdSlideShow;
|
home/app.js | trisys3/combook | import io from 'socket.io-client';
import React from 'react';
import ReactDOM from 'react-dom';
import {prevPage, nextPage, opened} from './app.css';
const Book = window.comBook.default;
const socket = io(__dirname);
const book = {
author: {
full: 'S. O. Meone',
first: 's',
last: 'meone',
},
title: 'The Home-Bound Hero',
shortTitle: 'home-bound-hero',
pages: [
{
start: 1,
end: 2,
},
{
start: -2,
end: -1,
},
],
};
if(module.hot) {
module.hot.accept();
socket.once('hot-update', () => module.hot.check(true));
}
class Home extends React.Component {
constructor() {
super();
this.state = {
startPage: 1,
endPage: 1,
};
this.isBookend = this.isBookend.bind(this);
}
render() {
let openedClass;
if(!this.state.isFirstPage && !this.state.isLastPage) {
openedClass = opened;
}
const {startPage, endPage = startPage} = this.state;
return <home-comp>
<page-changer class={prevPage} onClick={() => this.getPrevPage()} disabled={this.state.isFirstPage} />
<book className={openedClass}>
<Book book={book} startPage={startPage} endPage={endPage} isBookend={this.isBookend} />
</book>
<page-changer class={nextPage} onClick={() => this.getNextPage()} disabled={this.state.isLastPage} />
</home-comp>;
}
isBookend({isFirst, isLast} = {}) {
let isFirstPage;
let isLastPage;
if(isFirst) {
isFirstPage = 'disabled';
}
if(isLast) {
isLastPage = 'disabled';
}
this.setState({isFirstPage, isLastPage});
}
getPrevPage() {
if(this.state.isFirstPage) {
return;
}
const newEnd = this.state.startPage - 1;
const newStart = newEnd - 1;
this.setState({startPage: newStart, endPage: newEnd});
}
getNextPage() {
if(this.state.isLastPage) {
return;
}
const newStart = this.state.endPage + 1;
const newEnd = newStart + 1;
this.setState({startPage: newStart, endPage: newEnd});
}
}
ReactDOM.render(<Home />, document.querySelector('home-page'));
|
src/Parser/Warlock/Destruction/Modules/Features/DimensionalRift.js | enragednuke/WoWAnalyzer | import React from 'react';
import Analyzer from 'Parser/Core/Analyzer';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import SpellLink from 'common/SpellLink';
import { formatNumber, formatPercentage } from 'common/format';
import { STATISTIC_ORDER } from 'Main/StatisticBox';
import StatisticsListBox from 'Main/StatisticsListBox';
const FLAME_RIFT = 'Flame Rift';
const CHAOS_TEAR = 'Chaos Tear';
const SHADOWY_TEAR = 'Shadowy Tear';
const UNSTABLE_TEAR = 'Unstable Tear';
class DimensionalRift extends Analyzer {
_riftDetails = {
[FLAME_RIFT]: {
...SPELLS.SEARING_BOLT_RIFT,
},
[CHAOS_TEAR]: {
...SPELLS.CHAOS_BOLT_RIFT,
},
[SHADOWY_TEAR]: {
...SPELLS.SHADOW_BOLT_RIFT,
},
[UNSTABLE_TEAR]: {
...SPELLS.CHAOS_BARRAGE_RIFT,
},
};
_rifts = {};
on_initialized() {
this.owner.playerPets.filter(pet => this._riftDetails[pet.name]).forEach((pet) => {
this._rifts[pet.id] = {
...this._riftDetails[pet.name],
damage: 0,
};
});
}
on_damage(event) {
if (!this._rifts[event.sourceID]) {
return;
}
this._rifts[event.sourceID].damage += (event.amount || 0) + (event.absorbed || 0);
}
statistic() {
const rifts = Object.keys(this._rifts).map(id => this._rifts[id]);
const totalDmg = rifts.reduce((sum, rift) => sum + rift.damage, 0);
return (
<StatisticsListBox
title={<span><SpellIcon id={SPELLS.DIMENSIONAL_RIFT_CAST.id} /> Dimensional Rift</span>}
tooltip={`Your Dimensional Rifts did ${formatNumber(totalDmg)} total damage (${this.owner.formatItemDamageDone(totalDmg)}).`}
>
{rifts.map(rift => (
<div className="flex">
<div className="flex-main">
<SpellLink id={rift.id}>
<SpellIcon id={rift.id} noLink /> {rift.name}
</SpellLink>
</div>
<div className="flex-sub text-right">
{formatNumber(rift.damage)} ({formatPercentage(rift.damage / totalDmg)} %)
</div>
</div>
))}
</StatisticsListBox>
);
}
statisticOrder = STATISTIC_ORDER.OPTIONAL(6);
}
export default DimensionalRift;
|
examples/with-loading/components/Header.js | kevmannn/next.js | import React from 'react'
import Head from 'next/head'
import Link from 'next/link'
import NProgress from 'nprogress'
import Router from 'next/router'
Router.onRouteChangeStart = (url) => {
console.log(`Loading: ${url}`)
NProgress.start()
}
Router.onRouteChangeComplete = () => NProgress.done()
Router.onRouteChangeError = () => NProgress.done()
const linkStyle = {
margin: '0 10px 0 0'
}
export default () => (
<div style={{ marginBottom: 20 }}>
<Head>
{/* Import CSS for nprogress */}
<link rel='stylesheet' type='text/css' href='/static/nprogress.css' />
</Head>
<Link href='/'><a style={linkStyle}>Home</a></Link>
<Link href='/about'><a style={linkStyle}>About</a></Link>
<Link href='/forever'><a style={linkStyle}>Forever</a></Link>
<Link href='/non-existing'><a style={linkStyle}>Non Existing Page</a></Link>
</div>
)
|
src/svg-icons/social/public.js | mit-cml/iot-website-source | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let SocialPublic = (props) => (
<SvgIcon {...props}>
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/>
</SvgIcon>
);
SocialPublic = pure(SocialPublic);
SocialPublic.displayName = 'SocialPublic';
SocialPublic.muiName = 'SvgIcon';
export default SocialPublic;
|
react/pages/Signup.js | Seanskiver/b2b_application | import React from 'react';
//import { Table } from 'react-bootstrap';
import {Form, FormControl, FormGroup, ControlLabel, Button, Table, Carousel, Jumbotron, Panel, Col} from 'react-bootstrap';
import { HashRouter as Router, Route, Link, Redirect } from 'react-router-dom';
class Signup extends React.Component {
constructor(props) {
super(props);
this.state = {
email: '',
businessName: '',
businessType: '',
businessCategory: '',
phone: '',
address: '',
country: 'Senegal',
city: '',
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
const target = event.target;
const value = target.type === 'checkbox' ? target.checked : target.value;
const name = target.name;
this.setState({
[name]: value
});
}
//handlesubmit
handleSubmit(event) {
event.preventDefault();
$.ajax({
type: 'post',
url: '/signup',
data: {
'_token': $('input[name=_token]').val(),
...this.email,
...this.businessName,
...this.businessType,
...this.businessCategory,
...this.phone,
...this.address,
...this.country,
...this.city,
},
success: function(data) {
alert('Form was submited');
location.reload();
}
});
}
render() {
const style = {
width: '450px'
};
return (
<div className="register" id="custom-container">
<Col xsHidden>
<div class="container" style={style}>
<div class="panel panel-default">
<div class="panel-heading" align="center"><b>Business Information</b></div>
<div class="panel-body">
<form onSubmit={this.handleSubmit}>
<div class="form-group col-md-12">
<label for="businessName">Business Name</label>
<input type="text" class="form-control" id="businessName" name="businessName" placeholder="Business Name" onChange={this.handleChange}/>
</div>
<div class="form-group col-md-12">
<label class="control-label">Email</label>
<input type="email" class="form-control" id="email" name="email" placeholder="[email protected]" onChange={this.handleChange}/>
</div>
<div class="form-group col-md-12">
<label class="control-label">Phone</label>
<input type="text" required="required" class="form-control" id="phone" name="phone" placeholder="Enter Phone" onChange={this.handleChange}/>
</div>
<div class="form-group col-md-12">
<label for="businessType">Business Type</label>
<select class="form-control" id="businessType" name="businessType" onChange={this.handleChange}>
<option>Supplier</option>
<option>Buyer</option>
<option>Both</option>
</select>
</div>
<div class="form-group col-md-12">
<label for="businessCategory">Business Category</label>
<select class="form-control" id="businessCategory" name="businessCategory" onChange={this.handleChange}>
<option>Electronics & Appliance</option>
<option>Sport</option>
<option>Fashion</option>
<option>Food & Beverage</option>
<option>Automotive</option>
<option>Home Appliance</option>
<option>Furniture</option>
</select>
</div>
<div class="form-group col-md-12">
<label for="streetAddress">Street Address</label>
<input type="text" class="form-control" id="address" name="address" placeholder="Street Address" onChange={this.handleChange}/>
</div>
<div class="form-group col-md-12">
<label for="city">City</label>
<select class="form-control" id="exampleFormControlSelect1" name="city" onChange={this.handleChange}>
<option>Dakar</option>
<option>Touba</option>
<option>Thiès</option>
<option>Rufisque</option>
<option>Kaolack</option>
<option>M'Bour</option>
<option>Ziguinchor</option>
<option>Saint-Louis</option>
<option>Diourbel</option>
<option>Louga</option>
<option>Tambacounda</option>
<option>Richard Toll</option>
<option>Kolda</option>
<option>Mbacké</option>
<option>Tivaouane</option>
<option>Joal-Fadiouth</option>
<option>Kaffrine</option>
<option>Dahra</option>
<option>Bignona</option>
<option>Fatick</option>
<option>Dagana</option>
<option>Bambey</option>
<option>Vélingara</option>
<option>Sédhiou</option>
<option>Sébikhotane</option>
<option>Kédougou</option>
<option>Nguékhokh</option>
<option>Kayar</option>
<option>Pout</option>
<option>Mékhé</option>
<option>Matam</option>
<option>Ouro Sogui</option>
<option>Nioro du Rip</option>
<option>Kébémer</option>
<option>Koungheul</option>
<option>Guinguinéo</option>
<option>Bakel</option>
<option>Mboro</option>
<option>Linguère</option>
<option>Sokone</option>
<option>Goudomp</option>
<option>Thiadiaye</option>
<option>Ndioum</option>
<option>Damniadio</option>
<option>Khombole</option>
<option>Gossas</option>
<option>Kanel</option>
</select>
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary pull-right">Continue</button>
</div>
</form>
</div>
</div>
</div>
</Col>
{/*Mobile Form*/}
<Col smHidden mdHidden lgHidden>
<form onSubmit={this.handleSubmit}>
<div class="form-group col-md-12">
<label for="businessName">Business Name</label>
<input type="text" class="form-control" id="businessName" name="businessName" placeholder="Business Name" onChange={this.handleChange}/>
</div>
<div class="form-group col-md-12">
<label class="control-label">Email</label>
<input type="email" class="form-control" id="email" name="email" placeholder="[email protected]" onChange={this.handleChange}/>
</div>
<div class="form-group col-md-12">
<label class="control-label">Phone</label>
<input type="text" required="required" class="form-control" id="phone" name="phone" placeholder="Enter Phone" onChange={this.handleChange}/>
</div>
<div class="form-group col-md-12">
<label for="businessType">Business Type</label>
<select class="form-control" id="businessType" name="businessType" onChange={this.handleChange}>
<option>Supplier</option>
<option>Buyer</option>
<option>Both</option>
</select>
</div>
<div class="form-group col-md-12">
<label for="businessCategory">Business Category</label>
<select class="form-control" id="businessCategory" name="businessCategory" onChange={this.handleChange}>
<option>Electronics & Appliance</option>
<option>Sport</option>
<option>Fashion</option>
<option>Food & Beverage</option>
<option>Automotive</option>
<option>Home Appliance</option>
<option>Furniture</option>
</select>
</div>
<div class="form-group col-md-12">
<label for="streetAddress">Street Address</label>
<input type="text" class="form-control" id="address" name="address" placeholder="Street Address" onChange={this.handleChange}/>
</div>
<div class="form-group col-md-12">
<label for="city">City</label>
<select class="form-control" id="exampleFormControlSelect1" name="city" onChange={this.handleChange}>
<option>Dakar</option>
<option>Touba</option>
<option>Thiès</option>
<option>Rufisque</option>
<option>Kaolack</option>
<option>M'Bour</option>
<option>Ziguinchor</option>
<option>Saint-Louis</option>
<option>Diourbel</option>
<option>Louga</option>
<option>Tambacounda</option>
<option>Richard Toll</option>
<option>Kolda</option>
<option>Mbacké</option>
<option>Tivaouane</option>
<option>Joal-Fadiouth</option>
<option>Kaffrine</option>
<option>Dahra</option>
<option>Bignona</option>
<option>Fatick</option>
<option>Dagana</option>
<option>Bambey</option>
<option>Vélingara</option>
<option>Sédhiou</option>
<option>Sébikhotane</option>
<option>Kédougou</option>
<option>Nguékhokh</option>
<option>Kayar</option>
<option>Pout</option>
<option>Mékhé</option>
<option>Matam</option>
<option>Ouro Sogui</option>
<option>Nioro du Rip</option>
<option>Kébémer</option>
<option>Koungheul</option>
<option>Guinguinéo</option>
<option>Bakel</option>
<option>Mboro</option>
<option>Linguère</option>
<option>Sokone</option>
<option>Goudomp</option>
<option>Thiadiaye</option>
<option>Ndioum</option>
<option>Damniadio</option>
<option>Khombole</option>
<option>Gossas</option>
<option>Kanel</option>
</select>
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary pull-right">Continue</button>
</div>
</form>
<br/>
</Col>
{/*//Mobile Form*/}
</div>
);
}
}
export default Signup; |
src/svg-icons/toggle/star.js | ichiohta/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ToggleStar = (props) => (
<SvgIcon {...props}>
<path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/>
</SvgIcon>
);
ToggleStar = pure(ToggleStar);
ToggleStar.displayName = 'ToggleStar';
ToggleStar.muiName = 'SvgIcon';
export default ToggleStar;
|
src/dummy-component.js | macropodhq/axolotl | import React from 'react';
export default class DummyComponent extends React.Component {
render() {
throw 'this test has no visual component';
}
}
|
src/components/Loading.js | mangal49/HORECA | import React from 'react';
import RefreshIndicator from 'material-ui/RefreshIndicator';
const style = {
container: {
position: 'relative',
marginTop: 30,
},
refresh: {
display: 'inline-block',
position: 'relative',
},
};
const Loading = () => (
<div style={style.container}>
<RefreshIndicator
size={40}
left={10}
top={0}
status="loading"
style={style.refresh}
/>
</div>
);
export default Loading; |
src/components/Row/Row.js | aaronvanston/react-flexa | import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { themeProvider } from '../../theme';
import { filterProps, mediaQuery, gutter, CSSProperty } from '../../helpers';
const Row = styled(props =>
React.createElement(props.elementType, filterProps(props, Row.propTypes)),
)`
// Initial component property
box-sizing: border-box;
${props => themeProvider.breakpointsKeys(props).map(breakpoint => mediaQuery(props)[breakpoint]`
// Generate gutter
${gutter.row(props, breakpoint)}
// Responsive Flexbox properties
${CSSProperty(props, breakpoint, 'display')}
${CSSProperty(props, breakpoint, 'flex-direction')}
${CSSProperty(props, breakpoint, 'flex-wrap')}
${CSSProperty(props, breakpoint, 'justify-content')}
${CSSProperty(props, breakpoint, 'align-items')}
${CSSProperty(props, breakpoint, 'align-content')}
`)}
`;
Row.defaultProps = {
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'flex-start',
alignItems: 'stretch',
alignContent: 'stretch',
elementType: 'div',
};
const displayOptions = ['flex', 'inline-flex'];
const flexDirectionOptions = ['row', 'row-reverse', 'column', 'column-reverse'];
const flexWrapOptions = ['nowrap', 'wrap', 'wrap-reverse'];
const justifyContentOptions = ['flex-start', 'flex-end', 'center', 'space-between', 'space-around'];
const alignItemsOptions = ['flex-start', 'flex-end', 'center', 'baseline', 'stretch'];
const alignContentOptions = ['flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'stretch'];
Row.propTypes = {
gutter: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.shape({
xs: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
sm: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
md: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
lg: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
}),
]),
display: PropTypes.oneOfType([
PropTypes.oneOf(displayOptions),
PropTypes.shape({
xs: PropTypes.oneOf(displayOptions),
sm: PropTypes.oneOf(displayOptions),
md: PropTypes.oneOf(displayOptions),
lg: PropTypes.oneOf(displayOptions),
}),
]),
flexDirection: PropTypes.oneOfType([
PropTypes.oneOf(flexDirectionOptions),
PropTypes.shape({
xs: PropTypes.oneOf(flexDirectionOptions),
sm: PropTypes.oneOf(flexDirectionOptions),
md: PropTypes.oneOf(flexDirectionOptions),
lg: PropTypes.oneOf(flexDirectionOptions),
}),
]),
flexWrap: PropTypes.oneOfType([
PropTypes.oneOf(flexWrapOptions),
PropTypes.shape({
xs: PropTypes.oneOf(flexWrapOptions),
sm: PropTypes.oneOf(flexWrapOptions),
md: PropTypes.oneOf(flexWrapOptions),
lg: PropTypes.oneOf(flexWrapOptions),
}),
]),
justifyContent: PropTypes.oneOfType([
PropTypes.oneOf(justifyContentOptions),
PropTypes.shape({
xs: PropTypes.oneOf(justifyContentOptions),
sm: PropTypes.oneOf(justifyContentOptions),
md: PropTypes.oneOf(justifyContentOptions),
lg: PropTypes.oneOf(justifyContentOptions),
}),
]),
alignItems: PropTypes.oneOfType([
PropTypes.oneOf(alignItemsOptions),
PropTypes.shape({
xs: PropTypes.oneOf(alignItemsOptions),
sm: PropTypes.oneOf(alignItemsOptions),
md: PropTypes.oneOf(alignItemsOptions),
lg: PropTypes.oneOf(alignItemsOptions),
}),
]),
alignContent: PropTypes.oneOfType([
PropTypes.oneOf(alignContentOptions),
PropTypes.shape({
xs: PropTypes.oneOf(alignContentOptions),
sm: PropTypes.oneOf(alignContentOptions),
md: PropTypes.oneOf(alignContentOptions),
lg: PropTypes.oneOf(alignContentOptions),
}),
]),
elementType: PropTypes.string,
children: PropTypes.node,
};
Row.displayName = 'Row';
export default Row;
|
static/src/components/AirhornCounter.js | hammerandchisel/airhornbot | // @flow
import React from 'react';
import Constants from '../Constants';
export default (): React.Element => (
<object data={Constants.Image.AIRHORN_COUNTER} />
);
|
app/src/pages/SignUp/index.js | fikrimuhal/animated-potato | import React from 'react'
import {Link} from 'react-router'
import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
const styles = {
button: {
marginRight: 12,
}, contente: {
width: '100%',
marginLeft: 200
},
container: {
display: 'flex',
height: '100%',
},
};
export default React.createClass({
render() {
return (
<div style={styles.contente}>
<br/><br/>
?Lütfen aşağıdaki bilgileri eksiksiz bir şekilde doldurunuz.
<div>
<h3>Kayıt Ol</h3>
<div>
<TextField hintText="Ad" floatingLabelText="Ad"/>
<TextField hintText="Soyad" floatingLabelText="Soyad"/> <br/>
<TextField hintText="E mail" floatingLabelText="E mail"/>
<TextField hintText="Telefon" floatingLabelText="Telefon"/><br/>
</div>
</div>
<div style={styles.button}>
<Link to="/adminpanel"><RaisedButton label="Kayıt Ol" primary={true}/></Link>
<RaisedButton label="Temizle" secondary={true}/>
</div>
</div>
)
}
})
|
node_modules/bs-recipes/recipes/webpack.react-hot-loader/app/js/main.js | info5900groupG/dataishumantool | import React from 'react';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
React.render(<HelloWorld />, document.getElementById('react-root'));
|
redux-todos/index.js | stoepszli/js-demos | import 'todomvc-app-css/index.css';
import React from 'react';
import { render } from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import configureStore from './store/configureStore';
import Root from './containers/Root';
const store = configureStore();
render(
<AppContainer>
<Root
store={ store }
/>
</AppContainer>,
document.getElementById('root')
);
if (module.hot) {
module.hot.accept('./containers/Root', () => {
const RootContainer = require('./containers/Root').default;
render(
<AppContainer>
<RootContainer
store={ store }
/>
</AppContainer>,
document.getElementById('root')
);
});
}
|
app/containers/AthleteSchedule/AthleteTrainingList.js | kdprojects/nichesportapp | import React from 'react';
import H3 from 'components/H3';
import RaisedButton from 'material-ui/RaisedButton';
import CenteredSection from '../../containers/HomePage/CenteredSection';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
import {
Table,
TableBody,
TableHeader,
TableHeaderColumn,
TableRow,
TableRowColumn,
} from 'material-ui/Table';
import Loading from 'components/LoadingIndicator';
export class AthleteTrainingList extends React.Component { // eslint-disable-line react/prefer-stateless-function
shouldComponentUpdate() {
return true;
}
calculateTime(dateTime){
let time = dateTime.toTimeString();
let timeString = time.substring(0,9);
let H = +timeString.substr(0, 2);
let h = H % 12 || 12;
let ampm = H < 12 ? "AM" : "PM";
timeString = h + timeString.substr(2, 3) + ampm;
let date = dateTime.toDateString();
let formattedDateTime = date + ', ' + timeString;
return formattedDateTime;
}
render() {
if (this.props.data.loading) {
return (<Loading />)
}
if (this.props.data.error) {
console.log(this.props.data.error)
return (<div>An unexpected error occurred</div>)
}
return (
<CenteredSection>
<Table
fixedHeader={true}
selectable={false}
multiSelectable={false}>
>
<TableHeader
displaySelectAll={false}
adjustForCheckbox={false}
enableSelectAll={false}
>
<TableRow>
<TableHeaderColumn style={{fontSize:"18px",textAlign: 'center'}}>Training Session</TableHeaderColumn>
<TableHeaderColumn style={{fontSize:"18px",textAlign: 'center'}}>Date</TableHeaderColumn>
<TableHeaderColumn style={{fontSize:"18px",textAlign: 'center'}}>Time</TableHeaderColumn>
<TableHeaderColumn style={{fontSize:"18px",textAlign: 'center'}}>Team</TableHeaderColumn>
<TableHeaderColumn style={{fontSize:"18px",textAlign: 'center'}}>Location</TableHeaderColumn>
</TableRow>
</TableHeader>
<TableBody
displayRowCheckbox={false}
deselectOnClickaway={false}
showRowHover={true}
>
{this.props.data.allTrainings.map((team, index)=>(
<TableRow key={team.id}>
<TableRowColumn style={{textAlign: 'center'}}>{index+1}</TableRowColumn>
<TableRowColumn style={{textAlign: 'center'}}>
{team.trainingDates.length > 0 ?
team.trainingDates.map(trainingDate =>
<div key={trainingDate.id}>{this.calculateTime(new Date(trainingDate.date))}</div>) : ''}
</TableRowColumn>
<TableRowColumn style={{textAlign: 'center'}}>
{team.trainingDates.length > 0 ?
team.trainingDates.map(trainingDate =>
<div key={trainingDate.id}>{this.calculateTime(new Date(trainingDate.date))}</div>) : ''}
</TableRowColumn>
<TableRowColumn style={{textAlign: 'center'}}>{team.address}</TableRowColumn>
<TableRowColumn style={{textAlign: 'center'}}>{team.address}</TableRowColumn>
</TableRow>
))
}
</TableBody>
</Table>
</CenteredSection>
);
}
}
const TrainingsListQuery = gql`query TrainingsListQuery ($userId: ID) {
allTrainings(
filter:{
trainingTeams_some:{
team:{
atheletTeams_some:{
status_in:[APPROVEDBYATHLETE APPROVEDBYCOACH APPROVEDBYINSTITUTE]
athlete:{
user:{
id: $userId
}
}
}
}
}
}
){
id
dateTime
address
numberOfSessions
coach{ id user{ id email firstName lastName } }
institute{ id name }
trainingTeams{ team{ id name atheletTeams{athlete{ user{id}} status }} }
trainingDates{ id date }
}
}`
const TrainingData = graphql(TrainingsListQuery, {
options: (props) => ({ variables: { userId: props.userId } }),
})(AthleteTrainingList);
export default TrainingData;
|
src/components/tracks/individual/_someAnimal/index.js | cannoneyed/tmm-glare | /* eslint-disable quotes */
import React from 'react'
// const timeline = [{
// time: 0,
// fact: ''
// }]
//
export default function Voyeur() {
return (
<div className="track-info-page">
<div className="track-text voyeur" />
</div>
)
}
|
packages/website/builder/pages/docs/navigation.js | yusufsafak/cerebral | import React from 'react'
import Search from './search'
function Navigation(props) {
function renderMenu() {
return Object.keys(props.docs).map(function(sectionKey, index) {
return (
<li
key={index}
className={`docs-navigation-item${props.sectionName === sectionKey ? ' active' : ''}`}
>
<a href={`/docs/${sectionKey}`}>{sectionKey.replace('_', ' ')}</a>
<div className="underline" />
</li>
)
})
}
return (
<div id="navigation" className="docs-navigation">
<ul className="docs-navigation-menu">
{renderMenu()}
</ul>
<Search />
<div className="docs-icons">
<a
href="https://github.com/cerebral/cerebral"
className="docs-icon"
target="_new"
>
<div className="docs-icon-github" />
github repo
</a>
<a
href="https://discord.gg/0kIweV4bd2bwwsvH"
className="docs-icon"
target="_new"
>
<div className="docs-icon-discord" />
chat
</a>
<a
href="http://cerebral-website.herokuapp.com/"
className="docs-icon"
target="_new"
style={{ color: '#DD4A68' }}
>
old website
</a>
</div>
</div>
)
}
export default Navigation
|
app/components/main/Footer.js | ayqy/ready-to-work | import React, { Component } from 'react';
import { Button, Radio, Row, Col } from 'antd';
export default class Header extends Component {
render() {
const padding = '6px';
return (
<div className="main-footer footer">
<Row style={{padding: `${padding} 0`}}>
<Col span={8}>
<Button onClick={this.props.handleSyncClick} style={{marginLeft: padding}} size="small" shape="circle" icon="sync" />
</Col>
<Col span={8} offset={8} style={{textAlign: 'right'}}>
<Button onClick={this.props.handleLoginClick} style={{marginRight: padding}} size="small" shape="circle" icon="user" />
<Button onClick={this.props.handleSettingClick} style={{marginRight: padding}} size="small" shape="circle" icon="setting" />
</Col>
</Row>
</div>
);
}
}
|
app/components/NotFound.js | okmttdhr/redux-blog-example | import styles from './../styles/global.styl';
import React from 'react';
import CSSModules from 'react-css-modules';
@CSSModules(styles)
export default class NotFound extends React.Component {
render() {
return (
<div styleName="wrapper">
<h1>Not Found</h1>
</div>
);
}
}
|
app/components/PlatformsPageComponents/Chatbot.js | rapicastillo/beautifulrising-client | /**
*
* AboutPageComponents
*
*/
import React from 'react';
import styled from 'styled-components';
import { FormattedMessage } from 'react-intl';
import { PlatformsSection } from 'components/PlatformsPageComponents';
import VisibilitySensor from 'react-visibility-sensor';
import messages from './messages';
import Markdown from 'react-remarkable';
const Container = styled.div``;
const Viewport = styled.div`
display: inline-block;
`;
const TextContent = styled.div`
width: 30%;
float: left;
`;
const Content = styled.div`
text-align: left;
`;
const ImageContent= styled.div`
width: 69%;
float: right;
height: 400px;
display: inline-block;
`;
const Image = styled.div`
width: 100%;
height: 100%;
background-image: url(${props=> `https://www.beautifulrising.org/${props.source}`})
background-size: contain;
background-position: center;
background-repeat: no-repeat;
`;
const Title = styled.h1``;
const Subtitle = styled.h3``;
export default class Chatbot extends React.Component {
render() {
if (!this.props.content || this.props.content === undefined) return null;
return (
<PlatformsSection id='chatbot' name='chatbot'>
<Container>
<Viewport>
<TextContent>
<Content>
<Title>
{this.props.content.get('title')}
</Title>
<Subtitle>
{this.props.content.get('introduction')}
</Subtitle>
<Subtitle>
<FormattedMessage {...messages.what} />
</Subtitle>
<Markdown source={this.props.content.get('what')} />
<Subtitle>
<FormattedMessage {...messages.how} />
</Subtitle>
<Markdown source={this.props.content.get('how')} />
</Content>
</TextContent>
<ImageContent>
<Image source={this.props.content.get('image')} />
</ImageContent>
</Viewport>
</Container>
</PlatformsSection>
);
}
}
|
features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/components/FormComponents/Select.js | ChamNDeSilva/carbon-apimgt | /*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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';
const Select = (props) => (
<div className="form-group">
<select
name={props.name}
value={props.selectedOption}
onChange={props.controlFunc}
className="form-select">
<option value="">{props.placeholder}</option>
{props.options.map(opt => {
return (
<option
key={opt}
value={opt}>{opt}</option>
);
})}
</select>
</div>
);
Select.propTypes = {
name: React.PropTypes.string.isRequired,
options: React.PropTypes.array.isRequired,
selectedOption: React.PropTypes.string,
controlFunc: React.PropTypes.func.isRequired,
placeholder: React.PropTypes.string
};
export default Select; |
src/ButtonGroup.js | xiaoking/react-bootstrap | import React from 'react';
import classNames from 'classnames';
import BootstrapMixin from './BootstrapMixin';
import CustomPropTypes from './utils/CustomPropTypes';
const ButtonGroup = React.createClass({
mixins: [BootstrapMixin],
propTypes: {
vertical: React.PropTypes.bool,
justified: React.PropTypes.bool,
/**
* Display block buttons, only useful when used with the "vertical" prop.
* @type {bool}
*/
block: CustomPropTypes.all([
React.PropTypes.bool,
function(props) {
if (props.block && !props.vertical) {
return new Error('The block property requires the vertical property to be set to have any effect');
}
}
])
},
getDefaultProps() {
return {
block: false,
bsClass: 'button-group',
justified: false,
vertical: false
};
},
render() {
let classes = this.getBsClassSet();
classes['btn-group'] = !this.props.vertical;
classes['btn-group-vertical'] = this.props.vertical;
classes['btn-group-justified'] = this.props.justified;
classes['btn-block'] = this.props.block;
return (
<div
{...this.props}
className={classNames(this.props.className, classes)}>
{this.props.children}
</div>
);
}
});
export default ButtonGroup;
|
dev/6B_SCROLL.js | canalplus/react-keys | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { StyleSheet, css } from 'aphrodite/no-important';
import { createStore, combineReducers } from 'redux';
import { createStructuredSelector } from 'reselect';
import { connect, Provider } from 'react-redux';
import {
Binder,
keysInit,
keysReducer,
getBinderMarginLeft,
getCurrentSelectedId,
getCurrentBinder,
isVisibleInBinder,
} from '../src';
const styles = StyleSheet.create({
screen: {
display: 'block',
width: 400,
backgroundColor: 'grey',
height: 720,
overflow: 'hidden',
padding: 0,
margin: 0,
},
container: {
height: 220,
width: 360,
overflow: 'hidden',
},
ulStyle: {
listStyle: 'none',
width: 10000,
height: 220,
padding: 0,
margin: 0,
},
card: {
display: 'inline-block',
backgroundColor: 'yellow',
width: 100,
height: 200,
margin: 10,
},
focused: {
backgroundColor: 'green',
},
});
const store = createStore(
combineReducers({
'@@keys': keysReducer,
}),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);
keysInit({ store });
const PureCard = ({ id, current, isVisible }) => (
<li id={id} className={css(styles.card, current === id && styles.focused)}>
#{id}
COUCOU = {`${isVisible}`}
</li>
);
const Card = connect((state, props) => ({
current: getCurrentSelectedId()(),
isVisible: isVisibleInBinder(props.binderId, props.id)(),
}))(PureCard);
const GenericBinder = ({ id, priority, downExit, upExit, marginLeft }) => {
return (
<Binder
id={id}
wrapper={`#wrapper-${id}`}
priority={priority || 0}
strategy="mirror"
onDownExit={downExit}
onUpExit={upExit}
visibilityOffset={200}
>
<div id={`wrapper-${id}`} className={css(styles.container)}>
<ul className={css(styles.ulStyle)} style={{ marginLeft }}>
<Card id={`${id}-1`} binderId={id} />
<Card id={`${id}-2`} binderId={id} />
<Card id={`${id}-3`} binderId={id} />
<Card id={`${id}-4`} binderId={id} />
<Card id={`${id}-5`} binderId={id} />
<Card id={`${id}-6`} binderId={id} />
</ul>
</div>
</Binder>
);
};
const ConnectedBinder = connect((state, props) => {
return createStructuredSelector({
marginLeft: getBinderMarginLeft(props.id),
});
})(GenericBinder);
class PureBase extends Component {
constructor(props) {
super(props);
this.state = { position: 0 };
}
componentWillReceiveProps({ binder: { id } }) {
if (id < 3) return;
this.setState({ position: (id - 3) * 220 });
}
render() {
return (
<div style={{ marginTop: -this.state.position }}>
{this.props.children}
</div>
);
}
}
const Base = connect(() => ({ binder: getCurrentBinder()() }))(PureBase);
ReactDOM.render(
<Provider store={store}>
<div className={css(styles.screen)}>
<Base>
<ConnectedBinder id="1" downExit="2" upExit={null} priority={1} />
<ConnectedBinder id="2" downExit="3" upExit="1" />
<ConnectedBinder id="3" downExit="4" upExit="2" />
<ConnectedBinder id="4" downExit="5" upExit="3" />
<ConnectedBinder id="5" downExit="6" upExit="4" />
<ConnectedBinder id="6" downExit="7" upExit="5" />
<ConnectedBinder id="7" downExit="8" upExit="6" />
<ConnectedBinder id="8" downExit="9" upExit="7" />
<ConnectedBinder id="9" downExit="10" upExit="8" />
<ConnectedBinder id="10" downExit="11" upExit="9" />
<ConnectedBinder id="11" downExit={null} upExit="10" />
</Base>
</div>
</Provider>,
document.getElementById('body')
);
|
src/routes/Customisable/components/plugins/invoice-address/invoice-address.plugin.js | codingarchitect/react-counter-pair | import React from 'react'
import { Form, FormGroup, FormControl, ControlLabel } from 'react-bootstrap'
import InvoiceAddress from './invoice-address.rt'
import extensibleComponent from '../extensible-component'
import FormLayoutPluginRenderer from '../form-layout-plugin-renderer'
const addressForm = {
Address1: (props) => (<FormGroup controlId="formInlineAddress1">
<ControlLabel>Address1</ControlLabel>
<FormControl type="text" placeholder="Address1" />
</FormGroup>),
Address2: (props) => (<FormGroup controlId="formInlineAddress2">
<ControlLabel>Address2</ControlLabel>
<FormControl type="text" placeholder="Address2" />
</FormGroup>),
Address3: (props) => (<FormGroup controlId="formInlineAddress3">
<ControlLabel>Address3</ControlLabel>
<FormControl type="text" placeholder="Address3" />
</FormGroup>),
Address4: (props) => (<FormGroup controlId="formInlineAddress4">
<ControlLabel>Address4</ControlLabel>
<FormControl type="text" placeholder="Address4" />
</FormGroup>),
Address5: (props) => (<FormGroup controlId="formInlineAddress5">
<ControlLabel>Address5</ControlLabel>
<FormControl type="text" placeholder="Address5" />
</FormGroup>),
Country: (props) => (<FormGroup controlId="formInlineCountry">
<ControlLabel>Country</ControlLabel>
<FormControl componentClass="select" placeholder="Country">
<option value="UK">UK</option>
<option value="US">US</option>
<option value="Other">Other</option>
</FormControl>
</FormGroup>),
Postcode: (props) => (<FormGroup controlId="formInlinePostcode">
<ControlLabel>Postcode</ControlLabel>
<FormControl type="text" placeholder="Postcode" />
</FormGroup>)
};
export const pluginMetadata = {
name : "react-counter/soe/soh/invoice-address",
displayName : 'Invoice Address',
sequence : 7,
active : true,
childPluginNames : []
}
export default extensibleComponent(InvoiceAddress, pluginMetadata.name, FormLayoutPluginRenderer, addressForm); |
src/svg-icons/action/speaker-notes.js | barakmitz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionSpeakerNotes = (props) => (
<SvgIcon {...props}>
<path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 14H6v-2h2v2zm0-3H6V9h2v2zm0-3H6V6h2v2zm7 6h-5v-2h5v2zm3-3h-8V9h8v2zm0-3h-8V6h8v2z"/>
</SvgIcon>
);
ActionSpeakerNotes = pure(ActionSpeakerNotes);
ActionSpeakerNotes.displayName = 'ActionSpeakerNotes';
ActionSpeakerNotes.muiName = 'SvgIcon';
export default ActionSpeakerNotes;
|
src/views/UserEdit/UserForm.js | folio-org/ui-users | import isEqual from 'lodash/isEqual';
import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, FormattedMessage } from 'react-intl';
import { Field, FormSpy } from 'react-final-form';
import setFieldData from 'final-form-set-field-data';
import { AppIcon } from '@folio/stripes/core';
import {
Paneset,
Pane,
PaneMenu,
PaneHeaderIconButton,
PaneFooter,
Button,
ExpandAllButton,
Row,
Col,
Headline,
AccordionSet,
AccordionStatus,
HasCommand,
} from '@folio/stripes/components';
import { EditCustomFieldsRecord } from '@folio/stripes/smart-components';
import stripesFinalForm from '@folio/stripes/final-form';
import {
EditUserInfo,
EditExtendedInfo,
EditContactInfo,
EditProxy,
EditServicePoints,
} from '../../components/EditSections';
import { getFullName } from '../../components/util';
import RequestFeeFineBlockButtons from '../../components/RequestFeeFineBlockButtons';
import PermissionsAccordion from '../../components/PermissionsAccordion';
import {
statusFilterConfig,
permissionTypeFilterConfig,
} from '../../components/PermissionsAccordion/helpers/filtersConfig';
import { addressTypesShape } from '../../shapes';
import getProxySponsorWarning from '../../components/util/getProxySponsorWarning';
import css from './UserForm.css';
function validate(values, props) {
const errors = {};
errors.personal = {};
if (!props) {
return errors;
}
if (!values.personal || !values.personal.lastName) {
errors.personal.lastName = <FormattedMessage id="ui-users.errors.missingRequiredField" />;
}
if (!values.username && values.creds && values.creds.password) {
errors.username = <FormattedMessage id="ui-users.errors.missingRequiredUsername" />;
}
if (!props.initialValues.id && (!values.creds || !values.creds.password) && values.username) {
errors.creds = { password: <FormattedMessage id="ui-users.errors.missingRequiredPassword" /> };
}
if (!values.patronGroup) {
errors.patronGroup = <FormattedMessage id="ui-users.errors.missingRequiredPatronGroup" />;
}
if (!values.personal || !values.personal.preferredContactTypeId) {
if (errors.personal) errors.personal.preferredContactTypeId = <FormattedMessage id="ui-users.errors.missingRequiredContactType" />;
else errors.personal = { preferredContactTypeId: <FormattedMessage id="ui-users.errors.missingRequiredContactType" /> };
}
if (values.personal && values.personal.addresses) {
errors.personal.addresses = [];
values.personal.addresses.forEach((addr) => {
const err = (!addr.addressType) ? { addressType: <FormattedMessage id="ui-users.errors.missingRequiredAddressType" /> } : {};
errors.personal.addresses.push(err);
});
}
if (values.servicePoints && values.servicePoints.length > 0 && values.preferredServicePoint === undefined) {
errors.preferredServicePoint = <FormattedMessage id="ui-users.errors.missingRequiredPreferredServicePoint" />;
}
return errors;
}
class UserForm extends React.Component {
static propTypes = {
change: PropTypes.func,
addressTypes: addressTypesShape,
formData: PropTypes.object,
handleSubmit: PropTypes.func.isRequired,
location: PropTypes.object,
history: PropTypes.object,
uniquenessValidator: PropTypes.shape({
reset: PropTypes.func.isRequired,
GET: PropTypes.func.isRequired,
}).isRequired,
match: PropTypes.object,
pristine: PropTypes.bool,
submitting: PropTypes.bool,
invalid: PropTypes.bool,
onCancel: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
initialValues: PropTypes.object.isRequired,
servicePoints: PropTypes.object,
stripes: PropTypes.object,
form: PropTypes.object, // provided by final-form
intl: PropTypes.object,
};
static defaultProps = {
pristine: false,
submitting: false,
};
constructor(props) {
super(props);
this.accordionStatusRef = React.createRef();
this.closeButton = React.createRef();
this.saveButton = React.createRef();
this.cancelButton = React.createRef();
this.keyboardCommands = [
{
name: 'save',
handler: this.handleSaveKeyCommand
},
{
name: 'ignoreEnter',
handler: this.ignoreEnterKey,
shortcut: 'enter'
},
{
name: 'cancel',
handler: this.handleCancel,
shortcut: 'esc'
},
{
name: 'expandAllSections',
handler: this.expandAllSections,
},
{
name: 'collapseAllSections',
handler: this.collapseAllSections,
}
];
this.buttonRefs = [];
this.setButtonRef = el => this.buttonRefs.push(el);
}
handleCancel = () => {
const {
match: {
params
},
location: {
search,
},
history
} = this.props;
const idParam = params.id || '';
if (idParam) {
// if an id param is present, it's an edit view, go back to the user detail page...
history.push(`/users/preview/${idParam}${search}`);
} else {
// if no id param, it's a create form, go back to the top level search view.
history.push(`/users/${search}`);
}
}
getAddFirstMenu() {
const { intl } = this.props;
return (
<PaneMenu>
<PaneHeaderIconButton
id="clickable-closenewuserdialog"
onClick={this.handleCancel}
ref={this.closeButton}
aria-label={intl.formatMessage({ id: 'ui-users.crud.closeNewUserDialog' })}
icon="times"
/>
</PaneMenu>
);
}
ignoreEnterKey = (e) => {
const allowedControls = [
this.closeButton.current,
this.saveButton.current,
this.cancelButton.current,
...this.buttonRefs,
];
if (!allowedControls.includes(e.target)) {
e.preventDefault();
}
};
handleSaveKeyCommand = (e) => {
e.preventDefault();
this.executeSave();
};
executeSave() {
const {
handleSubmit,
onSubmit,
} = this.props;
const submitter = handleSubmit(onSubmit);
submitter();
}
getPaneFooter() {
const {
pristine,
submitting,
onCancel,
} = this.props;
const disabled = pristine || submitting;
const startButton = (
<Button
data-test-user-form-cancel-button
marginBottom0
id="clickable-cancel"
buttonStyle="default mega"
buttonRef={this.cancelButton}
onClick={onCancel}
>
<FormattedMessage id="ui-users.cancel" />
</Button>
);
const endButton = (
<Button
data-test-user-form-submit-button
marginBottom0
id="clickable-save"
buttonStyle="primary mega"
type="submit"
disabled={disabled}
buttonRef={this.saveButton}
>
<FormattedMessage id="ui-users.saveAndClose" />
</Button>
);
return (
<PaneFooter
renderStart={startButton}
renderEnd={endButton}
className={css.paneFooterClass}
innerClassName={css.paneFooterContentClass}
/>
);
}
getActionMenu = ({ onToggle }) => {
const { initialValues, stripes } = this.props;
const showActionMenu = stripes.hasPerm('ui-users.patron_blocks')
|| stripes.hasPerm('ui-users.feesfines.actions.all')
|| stripes.hasPerm('ui-requests.all');
const isEditing = initialValues && initialValues.id;
if (showActionMenu && isEditing) {
return (
<>
<RequestFeeFineBlockButtons
barcode={this.props.initialValues.barcode}
onToggle={onToggle}
userId={this.props.match.params.id}
/>
</>
);
} else {
return null;
}
}
render() {
const {
initialValues,
handleSubmit,
formData,
servicePoints,
onCancel,
stripes,
form,
uniquenessValidator,
} = this.props;
const selectedPatronGroup = form.getFieldState('patronGroup')?.value;
const firstMenu = this.getAddFirstMenu();
const footer = this.getPaneFooter();
const fullName = getFullName(initialValues);
const paneTitle = initialValues.id
? <FormattedMessage id="ui-users.edit" />
: <FormattedMessage id="ui-users.crud.createUser" />;
return (
<HasCommand commands={this.keyboardCommands}>
<form
data-test-form-page
className={css.UserFormRoot}
id="form-user"
onSubmit={handleSubmit}
>
<Paneset>
<Pane
actionMenu={this.getActionMenu}
firstMenu={firstMenu}
footer={footer}
centerContent
appIcon={<AppIcon app="users" appIconKey="users" />}
paneTitle={
<span data-test-header-title>
{paneTitle}
</span>
}
onClose={onCancel}
defaultWidth="fill"
>
{fullName && (
<Headline
size="xx-large"
tag="h2"
data-test-header-title
>
{fullName}
</Headline>
)}
<AccordionStatus ref={this.accordionStatusRef}>
<Row end="xs">
<Col xs>
<ExpandAllButton />
</Col>
</Row>
<AccordionSet
initialStatus={{
editUserInfo: true,
extendedInfo: true,
contactInfo: true,
proxy: false,
permissions: false,
servicePoints: false,
customFields: true,
}}
>
<EditUserInfo
accordionId="editUserInfo"
initialValues={initialValues}
patronGroups={formData.patronGroups}
stripes={stripes}
form={form}
selectedPatronGroup={selectedPatronGroup}
uniquenessValidator={uniquenessValidator}
/>
<EditExtendedInfo
accordionId="extendedInfo"
expanded
userId={initialValues.id}
userFirstName={initialValues.personal.firstName}
userEmail={initialValues.personal.email}
username={initialValues.username}
servicePoints={servicePoints}
addressTypes={formData.addressTypes}
departments={formData.departments}
uniquenessValidator={uniquenessValidator}
/>
<EditContactInfo
accordionId="contactInfo"
addressTypes={formData.addressTypes}
preferredContactTypeId={initialValues.preferredContactTypeId}
/>
<EditCustomFieldsRecord
expanded
formName="userForm"
accordionId="customFields"
backendModuleName="users"
entityType="user"
finalFormCustomFieldsValues={form.getState().values.customFields}
fieldComponent={Field}
changeFinalFormField={form.change}
/>
{initialValues.id &&
<div>
<EditProxy
accordionId="proxy"
sponsors={initialValues.sponsors}
proxies={initialValues.proxies}
fullName={fullName}
/>
<PermissionsAccordion
initialValues={initialValues}
filtersConfig={[
permissionTypeFilterConfig,
statusFilterConfig,
]}
visibleColumns={[
'selected',
'permissionName',
'type',
'status',
]}
accordionId="permissions"
headlineContent={<FormattedMessage id="ui-users.permissions.userPermissions" />}
permToRead="perms.users.get"
permToDelete="perms.users.item.delete"
permToModify="perms.users.item.put"
formName="userForm"
permissionsField="permissions"
form={form}
setButtonRef={this.setButtonRef}
/>
<EditServicePoints
accordionId="servicePoints"
setButtonRef={this.setButtonRef}
{...this.props}
/>
</div>
}
</AccordionSet>
</AccordionStatus>
</Pane>
</Paneset>
<FormSpy
subscription={{ values: true }}
onChange={({ values }) => {
const { mutators } = form;
['sponsors', 'proxies'].forEach(namespace => {
if (values[namespace]) {
values[namespace].forEach((_, index) => {
const warning = getProxySponsorWarning(values, namespace, index);
if (warning) {
mutators.setFieldData(`${namespace}[${index}].proxy.status`, { warning });
}
});
}
});
}}
/>
</form>
</HasCommand>
);
}
}
export default stripesFinalForm({
validate,
mutators: {
setFieldData,
},
initialValuesEqual: (a, b) => isEqual(a, b),
navigationCheck: true,
enableReinitialize: true,
})(injectIntl(UserForm));
|
fields/types/date/DateFilter.js | lojack/keystone | import _ from 'underscore';
import classNames from 'classnames';
import React from 'react';
import { FormField, FormInput, FormRow, FormSelect, SegmentedControl } from 'elemental';
const TOGGLE_OPTIONS = [
{ label: 'Matches', value: false },
{ label: 'Does NOT Match', value: true }
];
const MODE_OPTIONS = [
{ label: 'On', value: 'on' },
{ label: 'After', value: 'after' },
{ label: 'Before', value: 'before' },
{ label: 'Between', value: 'between' }
];
var NumberFilter = React.createClass({
getInitialState () {
return {
modeValue: MODE_OPTIONS[0].value, // 'on'
modeLabel: MODE_OPTIONS[0].label, // 'On'
inverted: TOGGLE_OPTIONS[0].value,
value: ''
};
},
componentDidMount () {
// focus the text input
React.findDOMNode(this.refs.input).focus();
},
toggleInverted (value) {
this.setState({
inverted: value
});
},
selectMode (mode) {
// TODO: implement w/o underscore
this.setState({
modeValue: mode,
modeLabel: _.findWhere(MODE_OPTIONS, { value: mode }).label
});
// focus the text input after a mode selection is made
React.findDOMNode(this.refs.input).focus();
},
renderToggle () {
return (
<FormField>
<SegmentedControl equalWidthSegments options={TOGGLE_OPTIONS} value={this.state.inverted} onChange={this.toggleInverted} />
</FormField>
);
},
renderControls () {
let controls;
let { field } = this.props;
let { modeLabel, modeValue } = this.state;
let placeholder = field.label + ' is ' + modeLabel.toLowerCase() + '...';
if (modeValue === 'between') {
controls = (
<FormRow>
<FormField width="one-half">
<FormInput ref="input" placeholder="From" />
</FormField>
<FormField width="one-half">
<FormInput placeholder="To" />
</FormField>
</FormRow>
);
} else {
controls = (
<FormField>
<FormInput ref="input" placeholder={placeholder} />
</FormField>
);
}
return controls;
},
render () {
let { modeLabel, modeValue } = this.state;
return (
<div>
{this.renderToggle()}
<FormSelect options={MODE_OPTIONS} onChange={this.selectMode} value={modeValue} />
{this.renderControls()}
</div>
);
}
});
module.exports = NumberFilter;
|
src/svg-icons/hardware/scanner.js | kasra-co/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let HardwareScanner = (props) => (
<SvgIcon {...props}>
<path d="M19.8 10.7L4.2 5l-.7 1.9L17.6 12H5c-1.1 0-2 .9-2 2v4c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-5.5c0-.8-.5-1.6-1.2-1.8zM7 17H5v-2h2v2zm12 0H9v-2h10v2z"/>
</SvgIcon>
);
HardwareScanner = pure(HardwareScanner);
HardwareScanner.displayName = 'HardwareScanner';
HardwareScanner.muiName = 'SvgIcon';
export default HardwareScanner;
|
app/javascript/mastodon/features/list_editor/index.js | abcang/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { injectIntl } from 'react-intl';
import { setupListEditor, clearListSuggestions, resetListEditor } from '../../actions/lists';
import Account from './components/account';
import Search from './components/search';
import EditListForm from './components/edit_list_form';
import Motion from '../ui/util/optional_motion';
import spring from 'react-motion/lib/spring';
const mapStateToProps = state => ({
accountIds: state.getIn(['listEditor', 'accounts', 'items']),
searchAccountIds: state.getIn(['listEditor', 'suggestions', 'items']),
});
const mapDispatchToProps = dispatch => ({
onInitialize: listId => dispatch(setupListEditor(listId)),
onClear: () => dispatch(clearListSuggestions()),
onReset: () => dispatch(resetListEditor()),
});
export default @connect(mapStateToProps, mapDispatchToProps)
@injectIntl
class ListEditor extends ImmutablePureComponent {
static propTypes = {
listId: PropTypes.string.isRequired,
onClose: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
onInitialize: PropTypes.func.isRequired,
onClear: PropTypes.func.isRequired,
onReset: PropTypes.func.isRequired,
accountIds: ImmutablePropTypes.list.isRequired,
searchAccountIds: ImmutablePropTypes.list.isRequired,
};
componentDidMount () {
const { onInitialize, listId } = this.props;
onInitialize(listId);
}
componentWillUnmount () {
const { onReset } = this.props;
onReset();
}
render () {
const { accountIds, searchAccountIds, onClear } = this.props;
const showSearch = searchAccountIds.size > 0;
return (
<div className='modal-root__modal list-editor'>
<EditListForm />
<Search />
<div className='drawer__pager'>
<div className='drawer__inner list-editor__accounts'>
{accountIds.map(accountId => <Account key={accountId} accountId={accountId} added />)}
</div>
{showSearch && <div role='button' tabIndex='-1' className='drawer__backdrop' onClick={onClear} />}
<Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
{({ x }) => (
<div className='drawer__inner backdrop' style={{ transform: x === 0 ? null : `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
{searchAccountIds.map(accountId => <Account key={accountId} accountId={accountId} />)}
</div>
)}
</Motion>
</div>
</div>
);
}
}
|
docs/app/Examples/modules/Rating/Types/RatingExampleStar.js | ben174/Semantic-UI-React | import React from 'react'
import { Rating } from 'semantic-ui-react'
const RatingExampleStar = () => (
<Rating icon='star' defaultRating={3} maxRating={4} />
)
export default RatingExampleStar
|
src/navigation/auth.js | OlivierVillequey/hackathon | /**
* Auth Scenes
*
* React Native Starter App
* https://github.com/mcnamee/react-native-starter-app
*/
import React from 'react';
import { Scene, ActionConst } from 'react-native-router-flux';
// Consts and Libs
import { AppConfig } from '@constants/';
// Scenes
import Authenticate from '@containers/auth/AuthenticateView';
import LoginForm from '@containers/auth/Forms/LoginContainer';
import SignUpForm from '@containers/auth/Forms/SignUpContainer';
import ResetPasswordForm from '@containers/auth/Forms/ResetPasswordContainer';
import UpdateProfileForm from '@containers/auth/Forms/UpdateProfileContainer';
import SignUpWithFacebookForm from '@containers/auth/Forms/SignUpWithFacebook'
/* Routes ==================================================================== */
const scenes = (
<Scene key={'authenticate'}>
<Scene
hideNavBar
key={'authLanding'}
component={Authenticate}
type={ActionConst.RESET}
analyticsDesc={'Authentication'}
/>
<Scene
{...AppConfig.navbarProps}
key={'login'}
title={'Login'}
clone
component={LoginForm}
analyticsDesc={'Login'}
/>
<Scene
{...AppConfig.navbarProps}
key={'signUpWithFacebook'}
title={'Sign Up With Facebook'}
clone
component={SignUpWithFacebookForm}
analyticsDesc={'Sign Up Fb'}
/>
<Scene
{...AppConfig.navbarProps}
key={'signUp'}
title={'Sign Up'}
clone
component={SignUpForm}
analyticsDesc={'Sign Up'}
/>
<Scene
{...AppConfig.navbarProps}
key={'passwordReset'}
title={'Password Reset'}
clone
component={ResetPasswordForm}
analyticsDesc={'Password Reset'}
/>
<Scene
{...AppConfig.navbarProps}
key={'updateProfile'}
title={'Update Profile'}
clone
component={UpdateProfileForm}
analyticsDesc={'Update Profile'}
/>
</Scene>
);
export default scenes;
|
src/MainComposition.js | tobias2801/app_gestoria | import React, { Component } from 'react';
import Header from './components/HeaderComponent';
import Sidebar from './components/SidebarComponent';
import Home from './components/HomeComponent';
import TypeForm from './components/forms/TypeFormComponent';
import ClientForm from './components/forms/ClientFormComponent';
import ArticleForm from './components/forms/ArticleFormComponent';
import SalesForm from './components/forms/SalesFormComponent';
export default class Main extends Component {
constructor() {
super();
this.onChangeView = this.onChangeView.bind(this);
this.state = {
view: <Home />
}
}
onChangeView(e) {
console.log(e.target.id);
let view = null;
switch(e.target.id) {
case 'home':
view = <Home />;
break
case 'new-client':
view = <ClientForm />;
break;
case 'new-article':
view = <ArticleForm />;
break;
case 'new-type':
view = <TypeForm />;
break;
case 'new-sale':
view = <SalesForm />;
break;
}
this.setState({
view
});
}
render() {
return (
<div>
<Header />
<Sidebar changeView={this.onChangeView} />
<div id="main-body">
{this.state.view}
</div>
<p id="firm">Tobías G. Schwarz ©2017</p>
</div>
);
}
} |
react-fundamentals/es6-react-setup/Wrapper.js | gongmingqm10/EggHead | import React from 'react';
import ReactDOM from 'react-dom';
class Wrapper extends React.Component {
constructor(props) {
super(props);
}
mount() {
ReactDOM.render(<App/>, document.getElementById(('container')));
}
unmount() {
ReactDOM.unmountComponentAtNode(document.getElementById('container'));
}
render() {
return (
<div>
<button onClick={this.mount.bind(this)}>Mount</button>
<button onClick={this.unmount.bind(this)}>Unmount</button>
<div id="container"></div>
</div>
);
}
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
val: 0
}
this.update = this.update.bind(this);
}
componentWillMount() {
console.log('Mounting');
this.setState({
multiple: 2
})
}
componentDidMount() {
console.log('Mounted');
this.inc = setInterval(this.update, 500);
}
componentWillUnmount() {
console.log('Bye!!!');
clearInterval(this.inc);
}
update() {
this.setState({
val: this.state.val + 1
});
}
render() {
console.log('Rendering');
return (
<button onClick={this.update.bind(this)}>{this.state.val * this.state.multiple}</button>
)
}
}
export default Wrapper; |
src/components/Proposal/Proposal.js | nambawan/g-old | import {
FormattedRelative,
FormattedMessage,
defineMessages,
} from 'react-intl';
import React from 'react';
import PropTypes from 'prop-types';
import cn from 'classnames';
import withStyles from 'isomorphic-style-loader/withStyles';
import s from './Proposal.css';
import UserThumbnail from '../UserThumbnail';
import WorkteamHeader from '../WorkteamHeader';
import { ICONS } from '../../constants';
const messages = defineMessages({
spokesman: {
id: 'spokesman',
defaultMessage: 'Spokesman',
description: 'Spokesman label',
},
});
class Proposal extends React.Component {
static propTypes = {
title: PropTypes.string.isRequired,
state: PropTypes.string.isRequired,
body: PropTypes.string.isRequired,
publishedAt: PropTypes.string.isRequired,
deletedAt: PropTypes.string,
spokesman: PropTypes.shape({
thumbnail: PropTypes.string,
name: PropTypes.string,
surname: PropTypes.string,
id: PropTypes.string,
}),
workteam: PropTypes.shape({
id: PropTypes.number,
displayName: PropTypes.string,
logo: PropTypes.string,
}),
};
static defaultProps = {
spokesman: null,
deletedAt: null,
workteam: null,
};
render() {
const {
deletedAt,
title,
publishedAt,
body,
spokesman,
workteam,
} = this.props;
return (
<div className={cn(s.root, deletedAt && s.deleted)}>
<div className={s.container}>
{workteam && (
<WorkteamHeader
displayName={workteam.displayName}
id={workteam.id}
logo={workteam.logo}
/>
)}
<div className={s.headline}>{title}</div>
<div className={s.details}>
{spokesman && (
<div>
<UserThumbnail
marked
label={<FormattedMessage {...messages.spokesman} />}
user={spokesman}
/>
</div>
)}
<div className={s.date}>
<svg
version="1.1"
viewBox="0 0 24 24"
width="24px"
height="24px"
role="img"
>
<path
fill="none"
stroke="#666"
strokeWidth="2"
d={ICONS.edit}
/>
</svg>{' '}
<FormattedRelative value={publishedAt} />
</div>
</div>
<div className={s.body} dangerouslySetInnerHTML={{ __html: body }} />
</div>
</div>
);
}
}
export default withStyles(s)(Proposal);
|
app/main.js | ibjohansen/k5g.no | 'use strict';
import React from 'react';
import Router, {Link, Route, DefaultRoute, NotFoundRoute} from 'react-router';
import Home from './pages/home';
import Map from './pages/map';
import Cats from './pages/cats';
require("./styles/normalize.css");
require("./styles/skeleton.css");
require("./styles/app.css");
React.initializeTouchEvents(true);
let injectTapEventPlugin = require("react-tap-event-plugin");
injectTapEventPlugin();
let routes = (
<Route path="/" handler={App}>
<DefaultRoute handler={Home}/>
<Route path="/home" handler={Home}/>
<Route path="/map" handler={Map}/>
<Route path="/cats" handler={Cats}/>
</Route>
);
var App = React.createClass({
render () {
return (
<RouteHandler/>
)
}
});
Router.run(routes, (Handler, state) => {
React.render(<Handler {...state}/>, document.querySelector('#app'));
});
|
src/utils/inputNodeCheck.js | manchesergit/material-ui | import React from 'react';
import warning from 'warning';
export const HtmlForTagName = 'htmlFor';
export const InputTypeName = 'input';
export const a11yButtonTagsToTest = [HtmlForTagName, 'aria-labelledby', 'aria-describedby'];
/*
* Check if the children have an input node.
* If there is an input node, check that it meets the a11y tag requirements :
* Must have all of the tags listed in the a11yTagsToTest array.
* If any of the tags are missing a warning will be output.
* Input : componentId - the ID of the component being checked or null.
* children - the child nodes of the component being checked or null.
* excludeTag - any tag of which the tests should be expcitly ignored.
*/
export function checkChildrenInputWitha11y(componentId, children, excludeTag) {
if (children !== null) {
// tags to test for in the children
const elementId = componentId !== null ? `Element [id: ${componentId}]:` : '';
const identity = `Material-UI: ${elementId}`;
const message =
'Buttons with a child <input> element should should contain the following property inside the input tag';
React.Children.forEach(children, (child) => {
if (child !== null) {
if (child.type === InputTypeName) {
for (let index = 0; index < a11yButtonTagsToTest.length; index++) {
const tagToTest = a11yButtonTagsToTest[index];
if (((tagToTest !== excludeTag)) && (!child.props.hasOwnProperty(tagToTest))) {
warning(false, `${identity} ${message} : '${tagToTest}'`);
}
}
}
}
});
}
}
|
blueocean-material-icons/src/js/components/svg-icons/image/filter-4.js | jenkinsci/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const ImageFilter4 = (props) => (
<SvgIcon {...props}>
<path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm12 10h2V5h-2v4h-2V5h-2v6h4v4zm6-14H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"/>
</SvgIcon>
);
ImageFilter4.displayName = 'ImageFilter4';
ImageFilter4.muiName = 'SvgIcon';
export default ImageFilter4;
|
server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js | lbndev/sonarqube | /*
* SonarQube
* Copyright (C) 2009-2017 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// @flow
import React from 'react';
import { connect } from 'react-redux';
import SearchForm from '../../shared/components/SearchForm';
import HoldersList from '../../shared/components/HoldersList';
import {
loadHolders,
grantToUser,
revokeFromUser,
grantToGroup,
revokeFromGroup,
updateQuery,
updateFilter,
selectPermission
} from '../store/actions';
import { translate } from '../../../../helpers/l10n';
import { PERMISSIONS_ORDER_BY_QUALIFIER } from '../constants';
import {
getPermissionsAppUsers,
getPermissionsAppGroups,
getPermissionsAppQuery,
getPermissionsAppFilter,
getPermissionsAppSelectedPermission
} from '../../../../store/rootReducer';
class AllHoldersList extends React.Component {
static propTypes = {
project: React.PropTypes.object.isRequired
};
componentDidMount() {
this.props.loadHolders(this.props.project.key);
}
handleSearch(query) {
this.props.onSearch(this.props.project.key, query);
}
handleFilter(filter) {
this.props.onFilter(this.props.project.key, filter);
}
handleToggleUser(user, permission) {
const hasPermission = user.permissions.includes(permission);
if (hasPermission) {
this.props.revokePermissionFromUser(this.props.project.key, user.login, permission);
} else {
this.props.grantPermissionToUser(this.props.project.key, user.login, permission);
}
}
handleToggleGroup(group, permission) {
const hasPermission = group.permissions.includes(permission);
if (hasPermission) {
this.props.revokePermissionFromGroup(this.props.project.key, group.name, permission);
} else {
this.props.grantPermissionToGroup(this.props.project.key, group.name, permission);
}
}
handleSelectPermission(permission) {
this.props.onSelectPermission(this.props.project.key, permission);
}
render() {
const order = PERMISSIONS_ORDER_BY_QUALIFIER[this.props.project.qualifier];
const permissions = order.map(p => ({
key: p,
name: translate('projects_role', p),
description: translate('projects_role', p, 'desc')
}));
return (
<HoldersList
permissions={permissions}
selectedPermission={this.props.selectedPermission}
users={this.props.users}
groups={this.props.groups}
onSelectPermission={this.handleSelectPermission.bind(this)}
onToggleUser={this.handleToggleUser.bind(this)}
onToggleGroup={this.handleToggleGroup.bind(this)}>
<SearchForm
query={this.props.query}
filter={this.props.filter}
onSearch={this.handleSearch.bind(this)}
onFilter={this.handleFilter.bind(this)}
/>
</HoldersList>
);
}
}
const mapStateToProps = state => ({
users: getPermissionsAppUsers(state),
groups: getPermissionsAppGroups(state),
query: getPermissionsAppQuery(state),
filter: getPermissionsAppFilter(state),
selectedPermission: getPermissionsAppSelectedPermission(state)
});
type OwnProps = {
project: {
organization?: string
}
};
const mapDispatchToProps = (dispatch: Function, ownProps: OwnProps) => ({
loadHolders: projectKey => dispatch(loadHolders(projectKey, ownProps.project.organization)),
onSearch: (projectKey, query) =>
dispatch(updateQuery(projectKey, query, ownProps.project.organization)),
onFilter: (projectKey, filter) =>
dispatch(updateFilter(projectKey, filter, ownProps.project.organization)),
onSelectPermission: (projectKey, permission) =>
dispatch(selectPermission(projectKey, permission, ownProps.project.organization)),
grantPermissionToUser: (projectKey, login, permission) =>
dispatch(grantToUser(projectKey, login, permission, ownProps.project.organization)),
revokePermissionFromUser: (projectKey, login, permission) =>
dispatch(revokeFromUser(projectKey, login, permission, ownProps.project.organization)),
grantPermissionToGroup: (projectKey, groupName, permission) =>
dispatch(grantToGroup(projectKey, groupName, permission, ownProps.project.organization)),
revokePermissionFromGroup: (projectKey, groupName, permission) =>
dispatch(revokeFromGroup(projectKey, groupName, permission, ownProps.project.organization))
});
export default connect(mapStateToProps, mapDispatchToProps)(AllHoldersList);
|
src/svg-icons/action/change-history.js | igorbt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionChangeHistory = (props) => (
<SvgIcon {...props}>
<path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"/>
</SvgIcon>
);
ActionChangeHistory = pure(ActionChangeHistory);
ActionChangeHistory.displayName = 'ActionChangeHistory';
ActionChangeHistory.muiName = 'SvgIcon';
export default ActionChangeHistory;
|
src/main.js | raffidil/garnanain | /**
* React Static Boilerplate
* https://github.com/kriasoft/react-static-boilerplate
*
* Copyright © 2015-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import localforage from 'localforage';
import 'babel-polyfill';
import 'whatwg-fetch';
import React from 'react';
import ReactDOM from 'react-dom';
import FastClick from 'fastclick';
import { Provider } from 'react-redux';
import store from './store';
import router from './router';
import history from './history';
let routes = require('./routes.json').default; // Loaded with utils/routes-loader.js
const container = document.getElementById('container');
function renderComponent(component) {
ReactDOM.render(<Provider store={store}>{component}</Provider>, container);
}
// Find and render a web page matching the current URL path,
// if such page is not found then render an error page (see routes.json, core/router.js)
function render(location) {
router.resolve(routes, location)
.then(renderComponent)
.catch(error => router.resolve(routes, { ...location, error }).then(renderComponent));
}
// Handle client-side navigation by using HTML5 History API
// For more information visit https://github.com/ReactJSTraining/history/tree/master/docs#readme
history.listen(render);
render(history.location);
// Eliminates the 300ms delay between a physical tap
// and the firing of a click event on mobile browsers
// https://github.com/ftlabs/fastclick
FastClick.attach(document.body);
// Enable Hot Module Replacement (HMR)
if (module.hot) {
module.hot.accept('./routes.json', () => {
routes = require('./routes.json').default; // eslint-disable-line global-require
render(history.location);
});
}
localforage.config({
name: 'Garnanain',
});
|
src/svg-icons/hardware/headset.js | andrejunges/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let HardwareHeadset = (props) => (
<SvgIcon {...props}>
<path d="M12 1c-4.97 0-9 4.03-9 9v7c0 1.66 1.34 3 3 3h3v-8H5v-2c0-3.87 3.13-7 7-7s7 3.13 7 7v2h-4v8h3c1.66 0 3-1.34 3-3v-7c0-4.97-4.03-9-9-9z"/>
</SvgIcon>
);
HardwareHeadset = pure(HardwareHeadset);
HardwareHeadset.displayName = 'HardwareHeadset';
HardwareHeadset.muiName = 'SvgIcon';
export default HardwareHeadset;
|
src/Parser/ShadowPriest/Modules/Spells/VoidformGraph.js | mwwscott0/WoWAnalyzer | import React from 'react';
import PropTypes from 'prop-types';
import ChartistGraph from 'react-chartist';
import Chartist from 'chartist';
import 'chartist-plugin-legend';
import './VoidformsTab.css';
const formatDuration = (duration) => {
const seconds = Math.floor(duration % 60);
return `${Math.floor(duration / 60)}:${seconds < 10 ? `0${seconds}` : seconds}`;
};
const MAX_MINDBENDER_MS = 21500;
// changing this value will have a large impact on webbrowser performance. About 200 seems to be best of 2 worlds.
const RESOLUTION_MS = 200;
const TIMESTAMP_ERROR_MARGIN = 500;
const NORMAL_VOIDFORM_MS_THRESHOLD = 70000;
const SURRENDER_TO_MADNESS_VOIDFORM_MS_THRESHOLD = 150000;
// current insanity formula:
// d = 6 + (2/3)*x
// where d = total drain of Insanity over 1 second
// max insanity is 10000 (100 ingame)
const INSANITY_DRAIN_INCREASE = 2 / 3 * 100; // ~66.67;
const INSANITY_DRAIN_INITIAL = 6 * 100; // 600;
const VOIDFORM_MINIMUM_INITIAL_INSANITY = 65 * 100; // 6500;
const T20_4P_DECREASE_DRAIN_MODIFIER_NORMAL = 0.9;
const T20_4P_DECREASE_DRAIN_MODIFIER_SURRENDER_TO_MADNESS = 0.95;
const VoidformGraph = ({
lingeringInsanityStacks,
mindbenderEvents,
voidTorrentEvents,
dispersionEvents,
insanityEvents,
surrenderToMadness = false,
setT20P4 = false,
fightEnd,
...voidform
}) => {
// todo: change ended to end on Voidform for consistency;
const voidFormEnd = voidform.ended === undefined ? fightEnd : voidform.ended;
const includesEndOfFight = voidform.ended === undefined || fightEnd <= voidform.ended + TIMESTAMP_ERROR_MARGIN;
const MAX_TIME_IN_VOIDFORM = surrenderToMadness ? SURRENDER_TO_MADNESS_VOIDFORM_MS_THRESHOLD : NORMAL_VOIDFORM_MS_THRESHOLD;
const labels = [];
const stacksData = [];
const insanityData = [];
const insanityGeneratedData = [];
const insanityDrain = [];
const initialInsanity = insanityEvents.length > 0 ? insanityEvents[0].classResources[0].amount - (insanityEvents[0].resourceChange * 100) - (insanityEvents[0].waste * 100) : VOIDFORM_MINIMUM_INITIAL_INSANITY;
const lingeringInsanityData = [];
const mindbenderData = [];
const voidTorrentData = [];
const dispersionData = [];
const endOfVoidformData = [];
const endData = [];
const INSANITY_DRAIN_MODIFIER = setT20P4 ?
(surrenderToMadness ?
T20_4P_DECREASE_DRAIN_MODIFIER_SURRENDER_TO_MADNESS :
T20_4P_DECREASE_DRAIN_MODIFIER_NORMAL)
: 1;
const INSANITY_DRAIN_START = INSANITY_DRAIN_INITIAL * INSANITY_DRAIN_MODIFIER;
const INSANITY_DRAIN_INCREASE_BY_SECOND = Math.round(INSANITY_DRAIN_INCREASE * INSANITY_DRAIN_MODIFIER);
const atLabel = timestamp => Math.floor((timestamp - voidform.start) / RESOLUTION_MS);
const voidFormIsOver = i => voidform.start + i * RESOLUTION_MS >= voidform.ended;
const fillData = (array, eventStart, eventEnd, data = false) => {
const amountOfSteps = Math.round((eventEnd - eventStart) / RESOLUTION_MS);
const startStep = atLabel(eventStart);
for (let i = 0; i < amountOfSteps; i += 1) {
if (eventStart + i * RESOLUTION_MS >= voidform.ended) break;
array[startStep + i] = data || stacksData[startStep + i];
}
};
const steps = MAX_TIME_IN_VOIDFORM / RESOLUTION_MS;
for (let i = 0; i < steps; i += 1) {
labels[i] = i;
stacksData[i] = null;
lingeringInsanityData[i] = null;
insanityData[i] = null;
insanityGeneratedData[i] = null;
mindbenderData[i] = null;
voidTorrentData[i] = null;
dispersionData[i] = null;
endData[i] = null;
endOfVoidformData[i] = null;
}
voidform.stacks.forEach(({ stack, timestamp }) => {
fillData(stacksData, timestamp, timestamp + 1000, stack);
});
// fill in dispersion gaps & 100s+ voidforms:
for (let i = 0; i <= steps; i += 1) {
if (stacksData[i] === null && (i * RESOLUTION_MS) + voidform.start < voidform.ended) stacksData[i] = stacksData[i - 1];
}
endOfVoidformData[atLabel(voidform.ended) + 1] = 100;
endOfVoidformData[atLabel(voidform.ended)] = 100;
if (lingeringInsanityStacks.length > 0) lingeringInsanityData[0] = lingeringInsanityStacks[0].stack + 2;
lingeringInsanityStacks.forEach(lingering => lingeringInsanityData[atLabel(lingering.timestamp)] = lingering.stack);
dispersionEvents.filter(dispersion => dispersion.start >= voidform.start && dispersion.end <= voidFormEnd + TIMESTAMP_ERROR_MARGIN).forEach(dispersion => fillData(dispersionData, dispersion.start, dispersion.end));
mindbenderEvents.filter(mindbender => mindbender.start >= voidform.start && mindbender.end <= voidFormEnd + MAX_MINDBENDER_MS).forEach(mindbender => fillData(mindbenderData, mindbender.start, mindbender.end));
voidTorrentEvents.filter(voidTorrent => voidTorrent.start >= voidform.start && voidTorrent.end <= voidFormEnd + TIMESTAMP_ERROR_MARGIN).forEach(voidTorrent => fillData(voidTorrentData, voidTorrent.start, voidTorrent.end));
let currentDrain = INSANITY_DRAIN_START;
let lastestDrainIncrease = 0;
for (let i = 0; i < steps; i += 1) {
// set drain to 0 if voidform ended:
if (voidFormIsOver(i)) {
currentDrain = 0;
break;
}
// dont increase if dispersion/voidtorrent is active:
if (dispersionData[i] === null && voidTorrentData[i] === null) {
lastestDrainIncrease += 1;
// only increase drain every second:
if (lastestDrainIncrease % (1000 / RESOLUTION_MS) === 0) {
currentDrain += INSANITY_DRAIN_INCREASE_BY_SECOND;
}
}
insanityDrain[i] = currentDrain;
}
insanityData[0] = initialInsanity;
insanityEvents.forEach(event => insanityData[atLabel(event.timestamp)] = event.classResources[0].amount);
let latestInsanityDataAt = 0;
for (let i = 0; i < steps; i += 1) {
if (insanityData[i] === null) {
insanityData[i] = insanityData[latestInsanityDataAt];
for (let j = latestInsanityDataAt; j <= i; j += 1) {
if (dispersionData[j] === null && voidTorrentData[j] === null) { insanityData[i] -= insanityDrain[j] / (1000 / RESOLUTION_MS); }
}
if (insanityData[i] < 0) insanityData[i] = 0;
} else {
latestInsanityDataAt = i;
}
}
let legends = {
classNames: [
'stacks',
'insanity',
// 'insanityDrain',
'voidtorrent',
'mindbender',
'dispersion',
'endOfVoidform',
],
};
let chartData = {
labels,
series: [
{
className: 'stacks',
name: 'Stacks',
data: Object.keys(stacksData).map(key => stacksData[key]).slice(0, steps),
},
{
className: 'insanity',
name: 'Insanity',
data: Object.keys(insanityData).map(key => insanityData[key] / 100).slice(0, steps),
},
{
className: 'voidtorrent',
name: 'Void Torrent',
data: Object.keys(voidTorrentData).map(key => voidTorrentData[key]).slice(0, steps),
},
// {
// className: 'insanityDrain',
// name: 'InsanityDrain',
// data: Object.keys(insanityDrain).map(key => insanityDrain[key]/100).slice(0, steps),
// },
{
className: 'mindbender',
name: 'Mindbender',
data: Object.keys(mindbenderData).map(key => mindbenderData[key]).slice(0, steps),
},
{
className: 'dispersion',
name: 'Dispersion',
data: Object.keys(dispersionData).map(key => dispersionData[key]).slice(0, steps),
},
{
className: 'endOfVoidform',
name: 'End of Voidform',
data: Object.keys(endOfVoidformData).map(key => endOfVoidformData[key]).slice(0, steps),
},
],
};
if (lingeringInsanityStacks.length > 0) {
chartData = {
...chartData,
series: [
{
className: 'lingeringInsanity',
name: 'Lingering Insanity',
data: Object.keys(lingeringInsanityData).map(key => lingeringInsanityData[key]).slice(0, steps),
},
...chartData.series,
],
};
legends = {
...legends,
classNames: [
'lingeringInsanity',
...legends.classNames,
],
};
}
if (includesEndOfFight) {
const fightEndedAtSecond = atLabel(fightEnd);
endData[fightEndedAtSecond - 1] = 100;
endData[fightEndedAtSecond] = 100;
chartData = {
...chartData,
series: [
...chartData.series,
{
className: 'endOfFight',
name: 'End of Fight',
data: Object.keys(endData).map(key => endData[key]).slice(0, steps),
},
],
};
legends = {
...legends,
classNames: [
...legends.classNames,
'endOfFight',
],
};
}
return (<ChartistGraph
data={chartData}
options={{
low: 0,
high: 100,
series: {
Stacks: {
lineSmooth: Chartist.Interpolation.none({
fillHoles: true,
}),
showPoint: false,
},
// 'insanityDrain': {
// lineSmooth: Chartist.Interpolation.none({
// fillHoles: true,
// }),
// showPoint: false,
// show: false,
// },
Insanity: {
lineSmooth: Chartist.Interpolation.none({
fillHoles: true,
}),
showPoint: false,
},
Mindbender: {
showArea: true,
lineSmooth: Chartist.Interpolation.none({
fillHoles: true,
}),
},
'Void Torrent': {
showArea: true,
},
Dispersion: {
showArea: true,
// lineSmooth: Chartist.Interpolation.step({
// fillHoles: true,
// }),
},
'Lingering Insanity': {
showArea: true,
lineSmooth: Chartist.Interpolation.none({
fillHoles: true,
}),
},
'End of Fight': {
showArea: true,
},
'End of Voidform': {
showArea: true,
},
},
fullWidth: true,
height: '200px',
axisX: {
labelInterpolationFnc: function skipLabels(ms) {
const everySecond = surrenderToMadness ? 10 : 5;
return (ms * (RESOLUTION_MS / 1000)) % everySecond === 0 ? formatDuration(ms * (RESOLUTION_MS / 1000)) : null;
},
offset: 30,
},
axisY: {
onlyInteger: true,
offset: 50,
labelInterpolationFnc: function skipLabels(numberOfStacks) {
return numberOfStacks;
},
},
plugins: [
Chartist.plugins.legend(legends),
],
}}
type="Line"
/>);
};
VoidformGraph.propTypes = {
fightEnd: PropTypes.number,
lingeringInsanityStacks: PropTypes.array,
insanityEvents: PropTypes.array,
mindbenderEvents: PropTypes.array,
voidTorrentEvents: PropTypes.array,
dispersionEvents: PropTypes.array,
surrenderToMadness: PropTypes.bool,
setT20P4: PropTypes.bool.isRequired,
};
export default VoidformGraph;
|
src/decorators/withViewport.js | thethirddan/pocket_axe | /*! 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});
}
};
}
export default withViewport;
|
src/JSONArrayNode.js | chibicode/react-json-tree | import React from 'react';
import PropTypes from 'prop-types';
import JSONNestedNode from './JSONNestedNode';
// Returns the "n Items" string for this node,
// generating and caching it if it hasn't been created yet.
function createItemString(data) {
return `${data.length} ${data.length !== 1 ? 'items' : 'item'}`;
}
// Configures <JSONNestedNode> to render an Array
const JSONArrayNode = ({ data, ...props }) => (
<JSONNestedNode
{...props}
data={data}
nodeType="Array"
nodeTypeIndicator="[]"
createItemString={createItemString}
expandable={data.length > 0}
/>
);
JSONArrayNode.propTypes = {
data: PropTypes.array
};
export default JSONArrayNode;
|
src/js/components/icons/base/AccessWheelchair.js | kylebyerly-hp/grommet | // (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import CSSClassnames from '../../../utils/CSSClassnames';
import Intl from '../../../utils/Intl';
import Props from '../../../utils/Props';
const CLASS_ROOT = CSSClassnames.CONTROL_ICON;
const COLOR_INDEX = CSSClassnames.COLOR_INDEX;
export default class Icon extends Component {
render () {
const { className, colorIndex } = this.props;
let { a11yTitle, size, responsive } = this.props;
let { intl } = this.context;
const classes = classnames(
CLASS_ROOT,
`${CLASS_ROOT}-access-wheelchair`,
className,
{
[`${CLASS_ROOT}--${size}`]: size,
[`${CLASS_ROOT}--responsive`]: responsive,
[`${COLOR_INDEX}-${colorIndex}`]: colorIndex
}
);
a11yTitle = a11yTitle || Intl.getMessage(intl, 'access-wheelchair');
const restProps = Props.omit(this.props, Object.keys(Icon.propTypes));
return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fillRule="evenodd" d="M8.05024041,4.27066668 C9.13670406,4.17035941 9.98081518,3.2343354 9.98081518,2.13951989 C9.98081517,0.961122081 9.01969309,0 7.84129528,0 C6.66289747,0 5.70181789,0.961122081 5.70181789,2.13951989 C5.70181789,2.49888341 5.80208265,2.86659878 5.96924725,3.17582992 L6.73158244,13.9028415 L14.5830059,13.9049667 L17.8033365,21.4503679 L22.0313726,19.7922379 L21.3766552,18.233225 L19.0104664,19.0873668 L15.8946083,11.8938486 L8.59449231,11.9428971 L8.49427005,10.5844138 L13.7789751,10.5865177 L13.7789751,8.5764834 L8.29267796,8.57433699 L8.05024041,4.27066668 L8.05024041,4.27066668 Z M15.9467171,19.6546554 C14.6215561,22.2742051 11.8479328,24 8.88942116,24 C4.54407658,24 1,20.4559234 1,16.1105788 C1,13.0595805 2.84909637,10.224349 5.60831112,8.96751171 L5.78686655,11.2976367 C4.1548759,12.3260199 3.14882807,14.1815767 3.14882807,16.12656 C3.14882807,19.2788007 5.71979669,21.8497268 8.8719949,21.8497268 C11.7559137,21.8497268 14.2150992,19.6365066 14.5504485,16.7972585 L15.9467171,19.6546554 L15.9467171,19.6546554 Z"/></svg>;
}
};
Icon.contextTypes = {
intl: PropTypes.object
};
Icon.defaultProps = {
responsive: true
};
Icon.displayName = 'AccessWheelchair';
Icon.icon = true;
Icon.propTypes = {
a11yTitle: PropTypes.string,
colorIndex: PropTypes.string,
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']),
responsive: PropTypes.bool
};
|
src/svg-icons/image/camera-roll.js | andrejunges/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageCameraRoll = (props) => (
<SvgIcon {...props}>
<path d="M14 5c0-1.1-.9-2-2-2h-1V2c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v1H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2h8V5h-8zm-2 13h-2v-2h2v2zm0-9h-2V7h2v2zm4 9h-2v-2h2v2zm0-9h-2V7h2v2zm4 9h-2v-2h2v2zm0-9h-2V7h2v2z"/>
</SvgIcon>
);
ImageCameraRoll = pure(ImageCameraRoll);
ImageCameraRoll.displayName = 'ImageCameraRoll';
ImageCameraRoll.muiName = 'SvgIcon';
export default ImageCameraRoll;
|
src/Dialog/Backdrop.js | gutenye/react-mc | // @flow
import React from 'react'
import cx from 'classnames'
import type { PropsC } from '../types'
class Backdrop extends React.Component {
props: PropsC
static defaultProps = {
component: 'div',
}
static displayName = 'Dialog.Backdrop'
render() {
const { component: Component, className, ...rest } = this.props
const rootClassName = cx('mdc-dialog__backdrop', className)
return <Component className={rootClassName} {...rest} />
}
}
export default Backdrop
|
src/UI/Keyboard.js | alex-wilmer/synth-starter | import React from 'react'
import { connect } from 'react-redux'
import { toFreq } from 'tonal-freq'
let Keyboard = ({ dispatch, octave }) => {
return (
<ul
className="piano"
onMouseUp={() => dispatch({ type: `CLEAR_KEYS` })}
>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`C` + octave) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`C#` + octave) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`D` + octave) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`D#` + octave) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`E` + octave) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`F` + octave) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`F#` + octave) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`G` + octave) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`G#` + octave) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`A` + octave) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`A#` + octave) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`B` + octave) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`C` + (octave + 1)) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`C#` + (octave + 1)) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`D` + (octave + 1)) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`D#` + (octave + 1)) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`E` + (octave + 1)) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`F` + (octave + 1)) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`F#` + (octave + 1)) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`G` + (octave + 1)) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`G#` + (octave + 1)) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`A` + (octave + 1)) })}
/>
<li
className="black"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`A#` + (octave + 1)) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`B` + (octave + 1)) })}
/>
<li
className="white"
onMouseDown={() => dispatch({ type: `PLAY_KEY`, key: toFreq(`C` + (octave + 2)) })}
/>
</ul>
)
}
export default connect(state => ({ octave: state.octave }))(Keyboard)
|
docs/app/Examples/views/Statistic/Content/index.js | aabustamante/Semantic-UI-React | import React from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
const Content = () => (
<ExampleSection title='Content'>
<ComponentExample
title='Value'
description='A statistic can contain a numeric, icon, image, or text value.'
examplePath='views/Statistic/Content/StatisticExampleValues'
/>
<ComponentExample examplePath='views/Statistic/Content/StatisticExampleProps' />
<ComponentExample
title='Label'
description='A statistic can contain a label to help provide context for the presented value.'
examplePath='views/Statistic/Content/StatisticExampleLabels'
/>
</ExampleSection>
)
export default Content
|
docs/app/Examples/collections/Grid/Variations/GridExampleRelaxed.js | ben174/Semantic-UI-React | import React from 'react'
import { Grid, Image } from 'semantic-ui-react'
const GridExampleRelaxed = () => (
<Grid relaxed columns={4}>
<Grid.Column>
<Image src='http://semantic-ui.com/images/wireframe/image.png' />
</Grid.Column>
<Grid.Column>
<Image src='http://semantic-ui.com/images/wireframe/image.png' />
</Grid.Column>
<Grid.Column>
<Image src='http://semantic-ui.com/images/wireframe/image.png' />
</Grid.Column>
<Grid.Column>
<Image src='http://semantic-ui.com/images/wireframe/image.png' />
</Grid.Column>
</Grid>
)
export default GridExampleRelaxed
|
src/js/components/app.js | Sinkler/italian-verbs-trainer | import React from 'react';
import Pronouns from '../pronouns';
import TensesList from '../tenses';
import Verbs from '../verbs';
import Form from '../containers/form'
import Counts from '../containers/counts'
import Footer from '../containers/footer'
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
tenses: TensesList,
counts: [0, 0]
};
}
//noinspection JSMethodCanBeStatic
componentWillMount() {
var hash = window.location.hash;
if (hash == '#swadesh') {
Verbs.verbs = Verbs.verbs.filter(item => item.is_swadesh);
} else if (hash == '#short') {
Verbs.verbs = Verbs.verbs_short;
}
}
updateForm(is_right) {
var counts = this.state.counts;
//noinspection JSCheckFunctionSignatures
this.setState({counts: [
is_right ? counts[0] + 1 : counts[0],
is_right ? counts[1] : counts[1] + 1
]});
}
updateTenses(id, is_checked) {
//noinspection JSCheckFunctionSignatures
this.setState({
tenses: this.state.tenses.map(item => {
if (item.id == id) {
item.active = is_checked;
}
return item;
})
});
}
render() {
var flag;
try {
/* global twemoji */
flag = twemoji.parse('🇮🇹', {size: 32});
} catch (e) {
flag = '';
}
//noinspection CheckTagEmptyBody,HtmlUnknownAttribute
return (
<div className="row">
<div className="small-12 large-7 large-centered columns">
<div className="text-center">
<h1><span dangerouslySetInnerHTML={{__html: flag}}></span> Italian Verbs Trainer</h1>
</div>
<Form
pronouns={Pronouns.list}
exceptions={Pronouns.exceptions}
verbs={Verbs.verbs}
translations={Verbs.translations}
tenses={this.state.tenses}
update={this.updateForm.bind(this)}/>
<Counts
counts={this.state.counts}/>
<Footer
tenses={this.state.tenses}
update={this.updateTenses.bind(this)}/>
</div>
</div>
);
}
}
export default App;
|
docs/src/app/components/pages/components/FontIcon/Page.js | barakmitz/material-ui | import React from 'react';
import Title from 'react-title-component';
import CodeExample from '../../../CodeExample';
import PropTypeDescription from '../../../PropTypeDescription';
import MarkdownElement from '../../../MarkdownElement';
import iconCode from '!raw!material-ui/FontIcon/FontIcon';
import iconReadmeText from './README';
import IconExampleSimple from './ExampleSimple';
import iconExampleSimpleCode from '!raw!./ExampleSimple';
import IconExampleIcons from './ExampleIcons';
import iconExampleIconsCode from '!raw!./ExampleIcons';
const descriptions = {
custom: 'This example uses a custom font (not part of Material-UI). The `className` defines the specific ' +
'icon. The third example has a `hoverColor` defined.',
public: 'This example uses the [Material icons font]' +
'(http://google.github.io/material-design-icons/#icon-font-for-the-web), referenced in the `<head>` of the docs ' +
'site index page. The `className` defines the font, and the `IconFont` tag content defines the specific icon.',
};
const FontIconPage = () => (
<div>
<Title render={(previousTitle) => `Font Icon - ${previousTitle}`} />
<MarkdownElement text={iconReadmeText} />
<CodeExample
title="Custom icon font"
description={descriptions.custom}
code={iconExampleSimpleCode}
>
<IconExampleSimple />
</CodeExample>
<CodeExample
title="Public icon font"
description={descriptions.public}
code={iconExampleIconsCode}
>
<IconExampleIcons />
</CodeExample>
<PropTypeDescription code={iconCode} />
</div>
);
export default FontIconPage;
|
src/svg-icons/editor/vertical-align-top.js | igorbt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorVerticalAlignTop = (props) => (
<SvgIcon {...props}>
<path d="M8 11h3v10h2V11h3l-4-4-4 4zM4 3v2h16V3H4z"/>
</SvgIcon>
);
EditorVerticalAlignTop = pure(EditorVerticalAlignTop);
EditorVerticalAlignTop.displayName = 'EditorVerticalAlignTop';
EditorVerticalAlignTop.muiName = 'SvgIcon';
export default EditorVerticalAlignTop;
|
assets/js/tests/Test.js | KiranJKurian/Election-Data-Exploration | import React from 'react';
import ReactDOM from 'react-dom';
import { Card, CardText, CardTitle, CardActions } from 'material-ui/Card';
import FlatButton from 'material-ui/FlatButton';
import tests from '../tests/tests';
const Test = (props) => {
tests();
return (
<div>
<Card style={{ margin: '1em' }}>
<CardTitle>Tests</CardTitle>
<CardActions>
<FlatButton onClick={tests} label="Test" />
</CardActions>
</Card>
</div>
);
}
export default Test;
|
source/components/Affiliation.js | sgmap/cout-embauche | import React from 'react'
import './Affiliation.css'
export default () =>
<section id="affiliation">
<a href="https://openfisca.fr?utm_source=affiliation&utm_campaign=widget_embauche" target="_blank">
<img alt="OpenFisca" src="https://www.openfisca.fr/hotlinks/logo-openfisca.svg" />
</a>
<a href="https://beta.gouv.fr" target="_blank">
<img id="logo-SGMAP" alt="Secrétariat Général pour la Modernisation de l'Action Publique" src="https://embauche.beta.gouv.fr/dist/images/marianne.svg" />
</a>
<a id="affiliation-contact" href="mailto:[email protected]?subject=A propos du simulateur d'embauche">contact</a>
</section>
|
src/clock.js | alecpblack/react-product-list | import React, { Component } from 'react';
class Clock extends Component {
constructor(props) {
super(props);
var now = new Date();
this.state = {
now: now,
partOfDay: this.getGreeting(now)
};
}
componentDidMount() {
this.timerID = setInterval(
() => this.tick(), 1000
);
}
componentWillUnmount() {
clearInterval(this.timerID);
this.timerID = null;
}
getGreeting(date) {
var currentHour = date.getHours();
return currentHour < 12
? 'Good morning'
: currentHour < 18
? 'Good afternoon'
: 'Good evening';
}
tick() {
var now = new Date();
this.setState({
now: now,
partOfDay: this.getGreeting(now)
});
}
render() {
return (
<h3>{this.state.partOfDay}. The time is {this.state.now.toLocaleTimeString()}</h3>
);
};
}
export default Clock; |
app/javascript/mastodon/components/short_number.js | ikuradon/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import { toShortNumber, pluralReady, DECIMAL_UNITS } from '../utils/numbers';
import { FormattedMessage, FormattedNumber } from 'react-intl';
// @ts-check
/**
* @callback ShortNumberRenderer
* @param {JSX.Element} displayNumber Number to display
* @param {number} pluralReady Number used for pluralization
* @returns {JSX.Element} Final render of number
*/
/**
* @typedef {object} ShortNumberProps
* @property {number} value Number to display in short variant
* @property {ShortNumberRenderer} [renderer]
* Custom renderer for numbers, provided as a prop. If another renderer
* passed as a child of this component, this prop won't be used.
* @property {ShortNumberRenderer} [children]
* Custom renderer for numbers, provided as a child. If another renderer
* passed as a prop of this component, this one will be used instead.
*/
/**
* Component that renders short big number to a shorter version
*
* @param {ShortNumberProps} param0 Props for the component
* @returns {JSX.Element} Rendered number
*/
function ShortNumber({ value, renderer, children }) {
const shortNumber = toShortNumber(value);
const [, division] = shortNumber;
// eslint-disable-next-line eqeqeq
if (children != null && renderer != null) {
console.warn('Both renderer prop and renderer as a child provided. This is a mistake and you really should fix that. Only renderer passed as a child will be used.');
}
// eslint-disable-next-line eqeqeq
const customRenderer = children != null ? children : renderer;
const displayNumber = <ShortNumberCounter value={shortNumber} />;
// eslint-disable-next-line eqeqeq
return customRenderer != null
? customRenderer(displayNumber, pluralReady(value, division))
: displayNumber;
}
ShortNumber.propTypes = {
value: PropTypes.number.isRequired,
renderer: PropTypes.func,
children: PropTypes.func,
};
/**
* @typedef {object} ShortNumberCounterProps
* @property {import('../utils/number').ShortNumber} value Short number
*/
/**
* Renders short number into corresponding localizable react fragment
*
* @param {ShortNumberCounterProps} param0 Props for the component
* @returns {JSX.Element} FormattedMessage ready to be embedded in code
*/
function ShortNumberCounter({ value }) {
const [rawNumber, unit, maxFractionDigits = 0] = value;
const count = (
<FormattedNumber
value={rawNumber}
maximumFractionDigits={maxFractionDigits}
/>
);
let values = { count, rawNumber };
switch (unit) {
case DECIMAL_UNITS.THOUSAND: {
return (
<FormattedMessage
id='units.short.thousand'
defaultMessage='{count}K'
values={values}
/>
);
}
case DECIMAL_UNITS.MILLION: {
return (
<FormattedMessage
id='units.short.million'
defaultMessage='{count}M'
values={values}
/>
);
}
case DECIMAL_UNITS.BILLION: {
return (
<FormattedMessage
id='units.short.billion'
defaultMessage='{count}B'
values={values}
/>
);
}
// Not sure if we should go farther - @Sasha-Sorokin
default: return count;
}
}
ShortNumberCounter.propTypes = {
value: PropTypes.arrayOf(PropTypes.number),
};
export default React.memo(ShortNumber);
|
src/components/remote/controls.js | scholtzm/arnold | import React, { Component } from 'react';
import { Grid, Container, Button, Header } from 'semantic-ui-react';
import ActionButton from '../../components/misc/action-button.js';
import input from '../../rpc/api/input.js';
import videoLibrary from '../../rpc/api/video-library.js';
import audioLibrary from '../../rpc/api/audio-library.js';
import player from '../../rpc/api/player.js';
import application from '../../rpc/api/application.js';
class Controls extends Component {
render() {
return (
<Container text>
<Grid>
<Grid.Row columns={3} textAlign='center'>
<Grid.Column>
<div><ActionButton icon='arrow up' asyncAction={input.up} /></div>
<div style={{margin: '5px 0'}}>
<ActionButton icon='arrow left' asyncAction={input.left} />
<ActionButton icon='selected radio' color='green' asyncAction={input.select} />
<ActionButton icon='arrow right' asyncAction={input.right} />
</div>
<div><ActionButton icon='arrow down' asyncAction={input.down} /></div>
<div style={{paddingTop: '10px'}}>
<ActionButton content='Home' asyncAction={input.home} />
{' '}
<ActionButton content='Back' asyncAction={input.back} />
</div>
</Grid.Column>
<Grid.Column>
<Header as='h5'>Playback</Header>
<div style={{paddingTop: '5px'}}>
<Button.Group color='blue'>
<ActionButton icon='play' asyncAction={player.playPause} />
<ActionButton icon='pause' asyncAction={player.playPause} />
<ActionButton icon='stop' asyncAction={player.stop} />
</Button.Group>
</div>
<div style={{paddingTop: '5px'}}>
<Button.Group basic>
<ActionButton icon='volume down' asyncAction={application.setVolume} asyncActionArguments={['decrement']} />
<ActionButton icon='volume off' asyncAction={application.setMute} />
<ActionButton icon='volume up' asyncAction={application.setVolume} asyncActionArguments={['increment']} />
</Button.Group>
</div>
</Grid.Column>
<Grid.Column>
<Header as='h5'>Video Library</Header>
<div style={{paddingTop: '5px'}}>
<ActionButton content='Scan' asyncAction={videoLibrary.scan} />
{' '}
<ActionButton content='Clean' asyncAction={videoLibrary.clean} />
</div>
<Header as='h5'>Audio Library</Header>
<div style={{paddingTop: '5px'}}>
<ActionButton content='Scan' asyncAction={audioLibrary.scan} />
{' '}
<ActionButton content='Clean' asyncAction={audioLibrary.clean} />
</div>
</Grid.Column>
</Grid.Row>
</Grid>
</Container>
);
}
}
export default Controls;
|
src/svg-icons/maps/local-movies.js | kittyjumbalaya/material-components-web | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsLocalMovies = (props) => (
<SvgIcon {...props}>
<path d="M18 3v2h-2V3H8v2H6V3H4v18h2v-2h2v2h8v-2h2v2h2V3h-2zM8 17H6v-2h2v2zm0-4H6v-2h2v2zm0-4H6V7h2v2zm10 8h-2v-2h2v2zm0-4h-2v-2h2v2zm0-4h-2V7h2v2z"/>
</SvgIcon>
);
MapsLocalMovies = pure(MapsLocalMovies);
MapsLocalMovies.displayName = 'MapsLocalMovies';
MapsLocalMovies.muiName = 'SvgIcon';
export default MapsLocalMovies;
|
src/app.js | aeldar/yet-another-react-bootstrap | import React from 'react';
import ReactDOM from 'react-dom';
import App from 'containers/App/App.jsx';
import 'static/styles/base.css';
import 'normalize.css';
ReactDOM.render(<App />, document.getElementById('root'));
|
js/ClientApp.js | steve-chen-nyc/fem_react | import React from 'react'
import { render } from 'react-dom'
import { BrowserRouter, Match } from 'react-router'
import { Provider } from 'react-redux'
import store from './store'
import Landing from './Landing'
import Search from './Search'
import Details from './Details'
import preload from '../public/data.json'
import '../public/normalize.css'
import '../public/style.css'
const App = React.createClass({
render () {
return (
<BrowserRouter>
<Provider store={store}>
<div className='app'>
<Match exactly pattern='/' component={Landing} />
<Match
pattern='/search'
component={(props) => <Search shows={preload.shows}
{...props} />}
/>
<Match
pattern='/details/:id'
component={(props) => {
const shows = preload.shows.filter((show) =>
props.params.id === show.imdbID)
return <Details show={shows[0]} {...props} />
}}
/>
</div>
</Provider>
</BrowserRouter>
)
}
})
render(<App />, document.getElementById('app'))
|
static/src/components/Footer/index.js | agelarry/online_quiz | import React from 'react';
/* component styles */
import { styles } from './styles.scss';
export const Footer = () =>
<footer className={`${styles}`}>
<div className="container">
<div className="row">
<div className="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<p>© LC 2017</p>
</div>
</div>
</div>
</footer>;
|
app/containers/NotFoundPage/index.js | dmitrykrylov/my-test-store | /**
* NotFoundPage
*
* This is the page we show when the user visits a url that doesn't have a route
*
* NOTE: while this component should technically be a stateless functional
* component (SFC), hot reloading does not currently support SFCs. If hot
* reloading is not a necessity for you then you can refactor it and remove
* the linting exception.
*/
import React from 'react';
export default class NotFound extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<h1>
Not Found
</h1>
);
}
}
|
docs/app/Examples/elements/Input/Variations/InputExampleActionLabeledButton.js | Rohanhacker/Semantic-UI-React | import React from 'react'
import { Input } from 'semantic-ui-react'
const InputExampleActionLabeledButton = () => (
<Input
action={{ color: 'teal', labelPosition: 'right', icon: 'copy', content: 'Copy' }}
defaultValue='http://ww.short.url/c0opq'
/>
)
export default InputExampleActionLabeledButton
|
docs/client/components/pages/Undo/CustomUndoEditor/index.js | draft-js-plugins/draft-js-plugins-v1 | import React, { Component } from 'react';
import { EditorState } from 'draft-js';
import Editor from 'draft-js-plugins-editor';
import createUndoPlugin from 'draft-js-undo-plugin';
import editorStyles from './editorStyles.css';
import buttonStyles from './buttonStyles.css';
const theme = {
undo: buttonStyles.button,
redo: buttonStyles.button,
};
const undoPlugin = createUndoPlugin({
undoContent: 'Undo',
redoContent: 'Redo',
theme,
});
const { UndoButton, RedoButton } = undoPlugin;
const plugins = [undoPlugin];
export default class CustomUndoEditor extends Component {
state = {
editorState: EditorState.createEmpty(),
};
onChange = (editorState) => {
this.setState({
editorState,
});
};
focus = () => {
this.refs.editor.focus();
};
render() {
return (
<div>
<div className={ editorStyles.editor } onClick={ this.focus }>
<Editor
editorState={this.state.editorState}
onChange={this.onChange}
plugins={ plugins }
ref="editor"
/>
</div>
<div className={ editorStyles.options }>
<UndoButton />
<RedoButton />
</div>
</div>
);
}
}
|
examples/redirect-using-index/app.js | Dodelkin/react-router | import React from 'react'
import { createHistory, useBasename } from 'history'
import { Router, Route, IndexRoute, Link } from 'react-router'
const history = useBasename(createHistory)({
basename: '/redirect-using-index'
})
class App extends React.Component {
render() {
return (
<div>
{this.props.children}
</div>
)
}
}
class Index extends React.Component {
render() {
return (
<div>
<h1>You should not see this.</h1>
{this.props.children}
</div>
)
}
}
class Child extends React.Component {
render() {
return (
<div>
<h2>Redirected to "/child"</h2>
<Link to="/">Try going to "/"</Link>
</div>
)
}
}
function redirectToChild(location, replaceState) {
replaceState(null, '/child')
}
React.render((
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={Index} onEnter={redirectToChild} />
<Route path="/child" component={Child} />
</Route>
</Router>
), document.getElementById('example'))
|
react/test/testHelper.js | koscim/beer-art-reviews | import { shallow, mount } from 'enzyme';
import jasmineEnzyme from 'jasmine-enzyme';
import React from 'react';
import $ from 'jquery';
import 'jasmine-ajax';
Object.assign(global, {
jasmineEnzyme,
mount,
React,
shallow,
$
});
beforeEach(() => {
jasmineEnzyme();
});
// function to require all modules for a given context
let requireAll = requireContext => {
requireContext.keys().forEach(requireContext);
};
// require all js files except testHelper.js in the test folder
requireAll(require.context('./', true, /^((?!testHelper).)*\.jsx?$/));
// require all js files except main.js in the src folder
requireAll(require.context('../src/', true, /^((?!main).)*\.jsx?$/));
// output to the browser's console when the tests run
console.info(`TESTS RAN AT ${new Date().toLocaleTimeString()}`);
|
src/parser/monk/mistweaver/modules/spells/Vivify.js | FaideWW/WoWAnalyzer | // Based on Clearcasting Implementation done by @Blazyb
import React from 'react';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import SpellIcon from 'common/SpellIcon';
import { formatNumber } from 'common/format';
import Analyzer from 'parser/core/Analyzer';
import Combatants from 'parser/shared/modules/Combatants';
import AbilityTracker from 'parser/shared/modules/AbilityTracker';
import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';
const debug = false;
class Vivify extends Analyzer {
static dependencies = {
abilityTracker: AbilityTracker,
combatants: Combatants,
};
remVivifyHealCount = 0;
remVivifyHealing = 0;
gustsHealing = 0;
lastCastTarget = null;
on_byPlayer_cast(event) {
const spellId = event.ability.guid;
if (SPELLS.VIVIFY.id !== spellId) {
return;
}
this.lastCastTarget = event.targetID;
}
on_byPlayer_heal(event) {
const spellId = event.ability.guid;
if ((spellId === SPELLS.GUSTS_OF_MISTS.id) && (this.lastCastTarget === event.targetID)) {
this.gustsHealing += (event.amount || 0) + (event.absorbed || 0);
}
if ((spellId === SPELLS.VIVIFY.id) && (this.lastCastTarget !== event.targetID)) {
this.remVivifyHealCount += 1;
this.remVivifyHealing += (event.amount || 0 ) + (event.absorbed || 0);
}
}
get averageRemPerVivify() {
const vivifyCasts = this.abilityTracker.getAbility(SPELLS.VIVIFY.id).casts || 0;
return this.remVivifyHealCount / vivifyCasts || 0;
}
get suggestionThresholds() {
return {
actual: this.averageRemPerVivify,
isLessThan: {
minor: 1.5,
average: 1,
major: 0.5,
},
style: 'number',
};
}
on_finished() {
if (debug) {
console.log("rem viv healing: ", this.remVivifyHealing);
console.log("viv gusts healing: ", this.gustsHealing);
}
}
suggestions(when) {
when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
return suggest(
<>
You are casting <SpellLink id={SPELLS.VIVIFY.id} /> with less than 2 <SpellLink id={SPELLS.RENEWING_MIST.id} /> out on the raid. To ensure you are gaining the maximum <SpellLink id={SPELLS.VIVIFY.id} /> healing, keep <SpellLink id={SPELLS.RENEWING_MIST.id} /> on cooldown.
</>
)
.icon(SPELLS.VIVIFY.icon)
.actual(`${this.averageRemPerVivify} Unused Uplifting Trance procs`)
.recommended(`${recommended} wasted UT Buffs is recommended`);
});
}
statistic() {
return (
<StatisticBox
postion={STATISTIC_ORDER.CORE(15)}
icon={<SpellIcon id={SPELLS.VIVIFY.id} />}
value={`${this.averageRemPerVivify.toFixed(2)}`}
label={(
<dfn data-tip={`Healing Breakdown:
<ul>
<li>${formatNumber(this.abilityTracker.getAbility(SPELLS.VIVIFY.id).healingEffective)} overall healing from Vivify.</li>
<li>${formatNumber(this.remVivifyHealing)} portion of your Vivify healing to REM targets.</li>
</ul>`}>
Avg REMs per Cast
</dfn>
)}
/>
);
}
}
export default Vivify;
|
ReduxThunkNews/src/js/components/ListContacts.js | fengnovo/webpack-react | import React from 'react';
import {List, ListItem} from 'material-ui/List';
import ActionGrade from 'material-ui/svg-icons/action/grade';
import Divider from 'material-ui/Divider';
import Avatar from 'material-ui/Avatar';
import {pinkA200, transparent} from 'material-ui/styles/colors';
const ListContacts = ({fetchData}) => (
<List>
{
fetchData && fetchData.map((item) => <ListItem
key={item.id}
primaryText={item.title}
leftIcon={<ActionGrade color={pinkA200} />}
rightAvatar={<Avatar src={item.author.avatar_url} />}
/>)
}
</List>
);
export default ListContacts; |
src/admin_components/ImportRaceComponent.js | chiefwhitecloud/running-man-frontend | import React from 'react';
import PropTypes from 'prop-types';
export default class ImportRaceComponent extends React.Component {
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleReset = this.handleReset.bind(this);
}
handleSubmit(urls) {
this.props.onSubmit(urls);
}
handleReset(event) {
event.preventDefault();
this.props.onReset();
}
render() {
let display;
if (!this.props.isSubmitted) {
display = <ImportRaceForm onSubmit={this.handleSubmit} />;
} else if (this.props.importStatus === 'Failed') {
display = (<div>{this.props.importStatus} {this.props.errorMessage}
<button onClick={this.handleReset}>Submit Another</button>
</div>);
} else {
display = <div>{this.props.importStatus} {this.props.errorMessage}</div>;
}
return display;
}
}
ImportRaceComponent.propTypes = {
isSubmitted: PropTypes.bool.isRequired,
onSubmit: PropTypes.func.isRequired,
onReset: PropTypes.func.isRequired,
importStatus: PropTypes.string,
errorMessage: PropTypes.string,
}
|
app/components/Charts/AreaChart/index.js | prudhvisays/season | import React from 'react';
import { ComposedChart, Line, Area, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts';
import './AreaStyle.css';
class CustomTooltip extends React.Component{
render() {
const { active } = this.props;
if (active) {
const { payload, label } = this.props;
const payload1 = `${payload[0].name}`;
const payload2 = `${payload[1].name}`;
return (
<div className="custom-tooltip">
<p className="desc">{label}</p>
<p className="label">{`${payload1} : ${payload[0].payload[`${payload1}`]}`}</p>
<p className="label">{`${payload2} : ${payload[1].payload[`${payload2}`]}`}</p>
</div>
);
}
return null;
}
}
export default class StackedAreaChart extends React.Component{
render() {
const { data, color} = this.props;
return (
<ComposedChart width={399} height={200} data={data}
margin={{top: 0, right: 0, bottom: 0, left: 0}}>
<XAxis dataKey="name" label="Pages"/>
<YAxis label="Index"/>
<Tooltip content={<CustomTooltip/>}/>
<Legend/>
<CartesianGrid stroke='#f5f5f5'/>
<Bar dataKey='actual' barSize={20} fill={color}/>
<Line type='monotone' dataKey='target' stroke='#ff7300'/>
</ComposedChart>
);
}
}
|
app/src/components/common/CustomSelectionView.js | kort/kort-native | // customized SelectionView
// credits to thinnakrit --> https://github.com/thinnakrit/React-Native-Selection
import React, { Component } from 'react';
import {
Text,
View,
ScrollView,
TouchableOpacity,
Dimensions,
Modal
} from 'react-native';
import _ from 'lodash';
import Icon from 'react-native-vector-icons/FontAwesome';
class CustomSelectionView extends Component {
static propTypes = {
onSelection: React.PropTypes.func,
isOpen: React.PropTypes.func,
options: React.PropTypes.array,
title: React.PropTypes.string,
mode: React.PropTypes.func,
style: React.PropTypes.object,
iconColor: React.PropTypes.string,
iconSize: React.PropTypes.number,
titleCustomize: React.PropTypes.bool,
}
constructor(props) {
super(props);
this.state = {
modalVisible: false,
title: props.title,
value: 0,
};
}
openOption() {
if (!_.isEmpty(this.props.options)) {
this.setState({ modalVisible: !this.state.modalVisible });
}
this.checkIfOpen();
}
checkIfOpen() {
if (this.state.modalVisible) {
this.props.isOpen(false);
} else {
this.props.isOpen(true);
}
}
onSelected(name, value) {
if (!_.isEmpty(this.props.options)) {
const data = {
value,
name,
};
this.props.onSelection(data);
this.setState({
modalVisible: false,
title: name,
value,
});
}
this.checkIfOpen();
}
checkIcon(icon) {
return (
<View
style={{
marginRight: 10 }}
>
<Icon name={icon} size={this.props.iconSize} color={this.props.iconColor} /></View>
);
}
render() {
const ScreenHeight = Dimensions.get('window').height;
const ScreenWidth = Dimensions.get('window').width;
let { style, options, title, mode, iconColor, iconSize } = this.props;
if (_.isEmpty(options)) {
options = [];
}
const styles = {
main: {
width: ScreenWidth - 80,
marginLeft: 40,
marginTop: 5,
marginBottom: 5,
borderColor: '#657C8E',
borderWidth: 1,
padding: 10,
backgroundColor: '#ffffff',
},
body: {
width: ScreenWidth - 80,
backgroundColor: '#ffffff',
maxHeight: ScreenHeight - this.props.missionHeight,
borderRadius: 10,
borderWidth: 1,
borderColor: '#657C8E',
overflow: 'hidden',
},
option: {
width: ScreenWidth - 80,
padding: 10,
borderBottomWidth: 1,
borderBottomColor: '#657C8E',
flexDirection: 'row',
margin: 0,
backgroundColor: '#ffffff'
},
optionText: {
fontSize: 20,
color: '#657C8E'
},
text: {
fontSize: 20,
color: 'white',
textAlign: 'center'
}
};
if (style.body!== null) {
styles.body = style.body;
}
if (style.option!== null) {
styles.option = style.option;
}
if (style.main!== null) {
styles.main = style.main;
}
let titleSet = '';
if (this.props.titleCustomize === true) {
titleSet = this.props.title;
} else {
titleSet = this.state.title;
}
return (
<View>
<Modal
visible={this.state.modalVisible}
onRequestClose={() =>{
this.setState({ modalVisible: false });
}}
transparent={true}
>
<TouchableOpacity onPress={()=> this.openOption()}>
<View
style={{
width: ScreenWidth,
height: ScreenHeight,
backgroundColor: 'rgba(0,0,0,0.6)',
alignItems: 'center',
justifyContent: 'center'
}}
>
<View style={styles.body}>
<ScrollView>
{_.map(options, (data, k)=>{
let icon = <View />;
if(!_.isEmpty(data.icon)){
icon = this.checkIcon(data.icon)
}
return(
<TouchableOpacity key={k} onPress={()=> this.onSelected(data.name, data.value)}>
<View style={styles.option}>
{icon}
<Text style={styles.optionText} >{data.name}</Text>
</View>
</TouchableOpacity>
)
})}
</ScrollView>
</View>
</View>
</TouchableOpacity>
</Modal>
<TouchableOpacity onPress={()=>this.openOption()}>
<View style={styles.main}>
<Text style={styles.text}>{titleSet}</Text>
</View>
</TouchableOpacity>
</View>
);
}
}
export { CustomSelectionView } ;
|
src/components/UsersCard.js | kusaeva/firebase-chat | import React from 'react'
import {Row, Col, Card} from 'wix-style-react/dist/src/Grid'
import MessageInput from 'containers/MessageInput'
import Messages from 'containers/Messages'
// function getUser (id) {
// // return 'https://pp.userapi.com/c841220/v841220877/ee41/x-F0a25bkoQ.jpg'
// return
// }
// const user = getUser (message.author)
// const data = {
// ...message,
// author: user.username
// imageUrl: user.profile_picture
// }
const UsersCard = (props) => {
console.log(props.name);
return (
<Card>
<Card.Header title='Side Card'/>
<Card.Content>
<Row>
<Col span={12}>
<Messages messages=
{[{author:'Olga Borzenkova', text:'hduwhqdnsjadjsajdbsajbdsabdsad', time:Date.now(), imageUrl:'https://pp.userapi.com/c841220/v841220877/ee41/x-F0a25bkoQ.jpg'}]}/>
<MessageInput onClick={()=>{console.log('click')}}/>
</Col>
</Row>
</Card.Content>
</Card>
)
}
export default UsersCard
|
src/svg-icons/action/supervisor-account.js | manchesergit/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionSupervisorAccount = (props) => (
<SvgIcon {...props}>
<path d="M16.5 12c1.38 0 2.49-1.12 2.49-2.5S17.88 7 16.5 7C15.12 7 14 8.12 14 9.5s1.12 2.5 2.5 2.5zM9 11c1.66 0 2.99-1.34 2.99-3S10.66 5 9 5C7.34 5 6 6.34 6 8s1.34 3 3 3zm7.5 3c-1.83 0-5.5.92-5.5 2.75V19h11v-2.25c0-1.83-3.67-2.75-5.5-2.75zM9 13c-2.33 0-7 1.17-7 3.5V19h7v-2.25c0-.85.33-2.34 2.37-3.47C10.5 13.1 9.66 13 9 13z"/>
</SvgIcon>
);
ActionSupervisorAccount = pure(ActionSupervisorAccount);
ActionSupervisorAccount.displayName = 'ActionSupervisorAccount';
ActionSupervisorAccount.muiName = 'SvgIcon';
export default ActionSupervisorAccount;
|
src/components/main/Layout/Layout.js | 5rabbits/portrait | import React from 'react'
import childrenPropType from 'propTypes/children'
const Layout = props =>
<section className="layout-wrapper" id="block-app">
<header className="layout-header" id="block-header">
{props.header}
</header>
<nav className="layout-navigation" id="block-navigation">
{props.navigation}
</nav>
<main className="layout-main" id="block-main">
{props.main}
</main>
</section>
Layout.propTypes = {
header: childrenPropType,
main: childrenPropType,
navigation: childrenPropType,
}
Layout.defaultProps = {
header: null,
main: null,
navigation: null,
}
export default Layout
|
monkey/monkey_island/cc/ui/src/components/report-components/attack/SelectedTechnique.js | guardicore/monkey | import React from 'react';
import Collapse from '@kunukn/react-collapse';
import AttackReport from '../AttackReport';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faQuestionCircle} from '@fortawesome/free-solid-svg-icons/faQuestionCircle';
import classNames from 'classnames';
class SelectedTechnique extends React.Component {
constructor(props) {
super(props);
this.state = {
techniques: this.props.techniques,
techComponents: this.props.techComponents,
selectedTechnique: this.props.selected
};
}
componentDidUpdate(prevProps) {
if (this.props.selected !== prevProps.selected || this.props.techniques !== prevProps.techniques) {
this.setState({ selectedTechnique: this.props.selected,
techniques: this.props.techniques})
}
}
getSelectedTechniqueComponent(tech_id) {
const TechniqueComponent = this.state.techComponents[tech_id];
return (
<div key={tech_id} className={classNames('collapse-item', {'item--active': true})}>
<button className={classNames('btn-collapse',
'selected-technique',
AttackReport.getComponentClass(tech_id, this.state.techniques))}>
<span>
{AttackReport.getStatusIcon(tech_id, this.state.techniques)}
{this.state.techniques[tech_id].title}
</span>
<span>
<a href={this.state.techniques[tech_id].link} rel="noopener noreferrer" target='_blank' className={'link-to-technique'}>
<FontAwesomeIcon icon={faQuestionCircle}
color={AttackReport.getComponentClass(tech_id, this.state.techniques) === 'collapse-default' ? '#ffffff' : '#000000'}/>
</a>
</span>
</button>
<Collapse
className='collapse-comp'
isOpen={true}
render={() => {
return (<div className={`content ${tech_id}`}>
<TechniqueComponent data={this.state.techniques[tech_id]}/>
</div>)
}}/>
</div>
);
}
render(){
let content = {};
let selectedTechId = this.state.selectedTechnique;
if(selectedTechId === false){
content = 'None. Select a technique from ATT&CK matrix above.';
} else {
content = this.getSelectedTechniqueComponent(selectedTechId)
}
return (
<div>
<h3 className='selected-technique-title'>Selected technique</h3>
<section className='attack-report selected-technique'>
{content}
</section>
</div>
)
}
}
export default SelectedTechnique;
|
public/components/tehtPage/tabsComponents/tehtava/JournalView.js | City-of-Vantaa-SmartLab/kupela | import React from 'react';
import { connect } from 'react-redux';
const JournalView = (props) => (
<div className="journalViewArea">
<div className="scrollableArea">
<div className="journalTextView">
TILANNEPÄIVÄKIRJA
{props.journalEntries.entries.map((c) =>
<p className="journalEntry">
{c.sender} : {c.time} - {c.message}
</p>
)}
</div>
</div>
</div>
);
const mapStateToProps = ({journal: {journalEntries}}) => ({
journalEntries
});
export default connect(mapStateToProps, null)(JournalView);
|
app/react/src/client/preview/error_display.js | enjoylife/storybook | import PropTypes from 'prop-types';
import React from 'react';
const mainStyle = {
position: 'fixed',
top: 0,
bottom: 0,
left: 0,
right: 0,
padding: 20,
backgroundColor: 'rgb(187, 49, 49)',
color: '#FFF',
WebkitFontSmoothing: 'antialiased',
};
const headingStyle = {
fontSize: 20,
fontWeight: 600,
letterSpacing: 0.2,
margin: '10px 0',
fontFamily: `
-apple-system, ".SFNSText-Regular", "San Francisco", Roboto, "Segoe UI",
"Helvetica Neue", "Lucida Grande", sans-serif
`,
};
const codeStyle = {
fontSize: 14,
width: '100vw',
overflow: 'auto',
};
const ErrorDisplay = ({ error }) =>
<div style={mainStyle}>
<div style={headingStyle}>{error.message}</div>
<pre style={codeStyle}>
<code>
{error.stack}
</code>
</pre>
</div>;
ErrorDisplay.propTypes = {
error: PropTypes.shape({
message: PropTypes.string,
stack: PropTypes.string,
}).isRequired,
};
export default ErrorDisplay;
|
app/scripts/ExportLinkDialog.js | hms-dbmi/higlass | import React from 'react';
import PropTypes from 'prop-types';
import Button from './Button';
import Dialog from './Dialog';
import '../styles/ExportLinkDialog.module.scss';
class ExportLinkDialog extends React.Component {
render() {
return (
<Dialog
okayOnly={true}
okayTitle="Done"
onOkay={this.props.onDone}
title="Share view link"
>
<div styleName="export-link-dialog-wrapper">
<input
ref={(element) => {
if (!element) return;
this.input = element;
element.focus();
element.select();
}}
onClick={(event) => {
event.target.select();
}}
placeholder="Generating the link..."
readOnly={true}
value={this.props.url}
/>
<Button
onClick={(event) => {
this.input.select();
document.execCommand('copy');
}}
>
Copy
</Button>
</div>
</Dialog>
);
}
}
ExportLinkDialog.defaultProps = {
onDone: () => {},
url: '',
};
ExportLinkDialog.propTypes = {
onDone: PropTypes.func,
url: PropTypes.string,
};
export default ExportLinkDialog;
|
packages/icons/src/md/editor/FormatShapes.js | suitejs/suitejs | import React from 'react';
import IconBase from '@suitejs/icon-base';
function MdFormatShapes(props) {
return (
<IconBase viewBox="0 0 48 48" {...props}>
<path d="M46 14h-4v20h4v12H34v-4H14v4H2V34h4V14H2V2h12v4h20V2h12v12zM6 6v4h4V6H6zm4 36v-4H6v4h4zm24-4v-4h4V14h-4v-4H14v4h-4v20h4v4h20zm8 4v-4h-4v4h4zm-4-32h4V6h-4v4zM27.47 28H20.5l-1.46 4h-3.25l6.8-18h2.81l6.81 18h-3.26l-1.48-4zm-6.1-2.52h5.22l-2.61-7.66-2.61 7.66z" />
</IconBase>
);
}
export default MdFormatShapes;
|
actor-apps/app-web/src/app/components/activity/UserProfile.react.js | shaunstanislaus/actor-platform | import React from 'react';
import { PureRenderMixin } from 'react/addons';
import ContactActionCreators from 'actions/ContactActionCreators';
import DialogActionCreators from 'actions/DialogActionCreators';
import PeerStore from 'stores/PeerStore';
import DialogStore from 'stores/DialogStore';
import AvatarItem from 'components/common/AvatarItem.react';
import UserProfileContactInfo from 'components/activity/UserProfileContactInfo.react';
const getStateFromStores = (userId) => {
const thisPeer = PeerStore.getUserPeer(userId);
return {
thisPeer: thisPeer,
isNotificationsEnabled: DialogStore.isNotificationsEnabled(thisPeer)
};
};
var UserProfile = React.createClass({
propTypes: {
user: React.PropTypes.object.isRequired
},
mixins: [PureRenderMixin],
getInitialState() {
return getStateFromStores(this.props.user.id);
},
componentWillMount() {
DialogStore.addNotificationsListener(this.whenNotificationChanged);
},
componentWillUnmount() {
DialogStore.removeNotificationsListener(this.whenNotificationChanged);
},
componentWillReceiveProps(newProps) {
this.setState(getStateFromStores(newProps.user.id));
},
addToContacts() {
ContactActionCreators.addContact(this.props.user.id);
},
removeFromContacts() {
ContactActionCreators.removeContact(this.props.user.id);
},
onNotificationChange(event) {
DialogActionCreators.changeNotificationsEnabled(this.state.thisPeer, event.target.checked);
},
whenNotificationChanged() {
this.setState(getStateFromStores(this.props.user.id));
},
render() {
const user = this.props.user;
const isNotificationsEnabled = this.state.isNotificationsEnabled;
let addToContacts;
if (user.isContact === false) {
addToContacts = <a className="link__blue" onClick={this.addToContacts}>Add to contacts</a>;
} else {
addToContacts = <a className="link__red" onClick={this.removeFromContacts}>Remove from contacts</a>;
}
return (
<div className="activity__body profile">
<div className="profile__name">
<AvatarItem image={user.bigAvatar}
placeholder={user.placeholder}
size="medium"
title={user.name}/>
<h3>{user.name}</h3>
</div>
<div className="notifications">
<label htmlFor="notifications">Enable Notifications</label>
<div className="switch pull-right">
<input checked={isNotificationsEnabled} id="notifications" onChange={this.onNotificationChange} type="checkbox"/>
<label htmlFor="notifications"></label>
</div>
</div>
<UserProfileContactInfo phones={user.phones}/>
<ul className="profile__list profile__list--usercontrols">
<li className="profile__list__item">
{addToContacts}
</li>
</ul>
</div>
);
}
});
export default UserProfile;
|
app/javascript/mastodon/components/setting_text.js | pixiv/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
export default class SettingText extends React.PureComponent {
static propTypes = {
settings: ImmutablePropTypes.map.isRequired,
settingKey: PropTypes.array.isRequired,
label: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
};
handleChange = (e) => {
this.props.onChange(this.props.settingKey, e.target.value);
}
render () {
const { settings, settingKey, label } = this.props;
return (
<label>
<span style={{ display: 'none' }}>{label}</span>
<input
className='setting-text'
value={settings.getIn(settingKey)}
onChange={this.handleChange}
placeholder={label}
/>
</label>
);
}
}
|
src/main.js | HackDFW/hackdfw-frontend | import React from 'react'
import ReactDOM from 'react-dom'
import createBrowserHistory from 'history/lib/createBrowserHistory'
import { syncReduxAndRouter } from 'redux-simple-router'
import routes from './routes'
import Root from './containers/Root'
import configureStore from './redux/configureStore'
const history = createBrowserHistory()
const store = configureStore(window.__INITIAL_STATE__)
syncReduxAndRouter(history, store, (state) => state.router)
// Render the React application to the DOM
ReactDOM.render(
<Root history={history} routes={routes} store={store} />,
document.getElementById('root')
)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.