path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
js/components/RouteCard.js | mekto/brouter-online | import React from 'react';
import * as actions from '../actions';
import {km} from '../filters';
import {SVGImport, ElevationChart} from '.';
import {getRouteTrackLength} from '../reducers/routes';
export default class RouteCard extends React.Component {
render() {
const route = this.props.route;
return (
<section className="card">
<div className="inner">
<div className="flex s-b">
<div>
<strong>{route.name}</strong><br/>
<small className="text-muted nowrap">
<strong>{km(getRouteTrackLength(route))}</strong>
<span className="separation-dot">·</span>
{route.profile.name} <span className="badge muted">{route.routeIndex + 1}</span>
</small>
</div>
<div className="actions">
<a onClick={()=>{ actions.fitRoute(route.id); }}><SVGImport src={require('expand.svg')}/></a>
<a onClick={()=>{ actions.toggleRouteLock(route.id); }} className={route.locked && 'active'}><SVGImport src={require('thumb-tack.svg')}/></a>
<a onClick={()=>{ actions.deleteRoute(route.id); }}><SVGImport src={require('x.svg')}/></a>
</div>
</div>
</div>
<ElevationChart route={route}/>
</section>
);
}
}
|
demo/demo.js | konsumer/react-sparklines | import React from 'react';
import { Sparklines, SparklinesBars, SparklinesLine, SparklinesNormalBand, SparklinesReferenceLine, SparklinesSpots } from '../src/Sparklines';
function boxMullerRandom () {
let phase = false,
x1, x2, w, z;
return (function() {
if (phase = !phase) {
do {
x1 = 2.0 * Math.random() - 1.0;
x2 = 2.0 * Math.random() - 1.0;
w = x1 * x1 + x2 * x2;
} while (w >= 1.0);
w = Math.sqrt((-2.0 * Math.log(w)) / w);
return x1 * w;
} else {
return x2 * w;
}
})();
}
function randomData(n = 30) {
return Array.apply(0, Array(n)).map(boxMullerRandom);
}
const sampleData = randomData(30);
const sampleData100 = randomData(100);
class Header extends React.Component {
render() {
return (
<Sparklines data={sampleData} width={300} height={50}>
<SparklinesLine style={{ stroke: "white", fill: "none" }} />
<SparklinesReferenceLine style={{ stroke: 'white', strokeOpacity: .75, strokeDasharray: '2, 2' }} />
</Sparklines>
);
}
}
class Simple extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine />
</Sparklines>
);
}
}
class Customizable1 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine color="#1c8cdc" />
</Sparklines>
);
}
}
class Customizable2 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine color="#fa7e17" />
</Sparklines>
);
}
}
class Customizable3 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine color="#ea485c" />
</Sparklines>
);
}
}
class Customizable4 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine color="#56b45d" />
</Sparklines>
);
}
}
class Customizable5 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine color="#8e44af" />
</Sparklines>
);
}
}
class Customizable6 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine color="#253e56" />
</Sparklines>
);
}
}
class Spots1 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine style={{ fill: "none" }} />
<SparklinesSpots />
</Sparklines>
);
}
}
class Spots2 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine color="#56b45d" />
<SparklinesSpots style={{ fill: "#56b45d" }} />
</Sparklines>
);
}
}
class Spots3 extends React.Component {
render() {
return (
<Sparklines data={sampleData} margin={6}>
<SparklinesLine style={{ strokeWidth: 3, stroke: "#336aff", fill: "none" }} />
<SparklinesSpots size={4} style={{ stroke: "#336aff", strokeWidth: 3, fill: "white" }} />
</Sparklines>
);
}
}
class Bars1 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesBars style={{ fill: "#41c3f9" }} />
</Sparklines>
);
}
}
class Bars2 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesBars style={{ stroke: "white", fill: "#41c3f9", fillOpacity: ".25" }} />
<SparklinesLine style={{ stroke: "#41c3f9", fill: "none" }} />
</Sparklines>
);
}
}
class Dynamic1 extends React.Component {
constructor(props) {
super(props);
this.state = { data: [] };
setInterval(() =>
this.setState({
data: this.state.data.concat([boxMullerRandom()])
}), 100);
}
render() {
return (
<Sparklines data={this.state.data} limit={20}>
<SparklinesLine color="#1c8cdc" />
<SparklinesSpots />
</Sparklines>
);
}
}
class Dynamic2 extends React.Component {
constructor(props) {
super(props);
this.state = { data: [] };
setInterval(() =>
this.setState({
data: this.state.data.concat([boxMullerRandom()])
}), 100);
}
render() {
return (
<Sparklines data={this.state.data} limit={20}>
<SparklinesBars style={{ fill: "#41c3f9", fillOpacity: ".25" }} />
<SparklinesLine style={{ stroke: "#41c3f9", fill: "none" }} />
</Sparklines>
);
}
}
class Dynamic3 extends React.Component {
constructor(props) {
super(props);
this.state = { data: [] };
setInterval(() =>
this.setState({
data: this.state.data.concat([boxMullerRandom()])
}), 100);
}
render() {
return (
<Sparklines data={this.state.data} limit={20}>
<SparklinesLine style={{ stroke: "none", fill: "#8e44af", fillOpacity: "1" }}/>
</Sparklines>
);
}
}
class Dynamic4 extends React.Component {
constructor(props) {
super(props);
this.state = { data: [] };
setInterval(() =>
this.setState({
data: this.state.data.concat([boxMullerRandom()])
}), 100);
}
render() {
return (
<Sparklines data={this.state.data} limit={10} >
<SparklinesBars color="#0a83d8" />
</Sparklines>
);
}
}
class ReferenceLine1 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine />
<SparklinesReferenceLine type="max" />
</Sparklines>
);
}
}
class ReferenceLine2 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine />
<SparklinesReferenceLine type="min" />
</Sparklines>
);
}
}
class ReferenceLine3 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine />
<SparklinesReferenceLine type="mean" />
</Sparklines>
);
}
}
class ReferenceLine4 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine />
<SparklinesReferenceLine type="avg" />
</Sparklines>
);
}
}
class ReferenceLine5 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine />
<SparklinesReferenceLine type="median" />
</Sparklines>
);
}
}
class ReferenceLine6 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesBars style={{ fill: 'slategray', fillOpacity: ".5" }} />
<SparklinesReferenceLine />
</Sparklines>
);
}
}
class NormalBand1 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine style={{ fill: "none" }}/>
<SparklinesNormalBand />
</Sparklines>
);
}
}
class NormalBand2 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine style={{ fill: "none" }}/>
<SparklinesNormalBand />
<SparklinesReferenceLine type="mean" />
</Sparklines>
);
}
}
class RealWorld1 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesLine style={{ strokeWidth: 3, stroke: "#336aff", fill: "none" }} />
</Sparklines>
);
}
}
class RealWorld2 extends React.Component {
render() {
return (
<Sparklines data={sampleData100} width={200}>
<SparklinesLine style={{ stroke: "#2991c8", fill: "none"}} />
<SparklinesSpots />
<SparklinesNormalBand style={{ fill: "#2991c8", fillOpacity: .1 }} />
</Sparklines>
);
}
}
class RealWorld3 extends React.Component {
render() {
return (
<Sparklines data={sampleData100}>
<SparklinesLine style={{ stroke: "black", fill: "none" }} />
<SparklinesSpots style={{ fill: "orange" }} />
</Sparklines>
);
}
}
class RealWorld4 extends React.Component {
render() {
return (
<Sparklines data={sampleData}>
<SparklinesBars style={{ stroke: "white", strokeWidth: "1", fill: "#40c0f5" }} />
</Sparklines>
);
}
}
class RealWorld5 extends React.Component {
render() {
return (
<Sparklines data={sampleData} height={80}>
<SparklinesLine style={{ stroke: "#8ed53f", strokeWidth: "1", fill: "none" }} />
</Sparklines>
);
}
}
class RealWorld6 extends React.Component {
render() {
return (
<Sparklines data={sampleData} height={80}>
<SparklinesLine style={{ stroke: "#d1192e", strokeWidth: "1", fill: "none" }} />
</Sparklines>
);
}
}
class RealWorld7 extends React.Component {
render() {
return (
<Sparklines data={sampleData} height={40}>
<SparklinesLine style={{ stroke: "#559500", fill: "#8fc638", fillOpacity: "1" }} />
</Sparklines>
);
}
}
class RealWorld8 extends React.Component {
render() {
return (
<Sparklines data={sampleData} style={{background: "#272727"}} margin={10} height={40}>
<SparklinesLine style={{ stroke: "none", fill: "#d2673a", fillOpacity: ".5" }} />
</Sparklines>
);
}
}
class RealWorld9 extends React.Component {
render() {
return (
<Sparklines data={sampleData} style={{background: "#00bdcc"}} margin={10} height={40}>
<SparklinesLine style={{ stroke: "white", fill: "none" }} />
<SparklinesReferenceLine style={{ stroke: 'white', strokeOpacity: .75, strokeDasharray: '2, 2' }} />
</Sparklines>
);
}
}
const demos = {
'headersparklines': Header,
'simple': Simple,
'customizable1': Customizable1,
'customizable2': Customizable2,
'customizable3': Customizable3,
'customizable4': Customizable4,
'customizable5': Customizable5,
'customizable6': Customizable6,
'spots1': Spots1,
'spots2': Spots2,
'spots3': Spots3,
'bars1': Bars1,
'bars2': Bars2,
'dynamic1': Dynamic1,
'dynamic2': Dynamic2,
'dynamic3': Dynamic3,
'dynamic4': Dynamic4,
'referenceline1': ReferenceLine1,
'referenceline2': ReferenceLine2,
'referenceline3': ReferenceLine3,
'referenceline4': ReferenceLine4,
'referenceline5': ReferenceLine5,
'referenceline6': ReferenceLine6,
'normalband1': NormalBand1,
'normalband2': NormalBand2,
'realworld1': RealWorld1,
'realworld2': RealWorld2,
'realworld3': RealWorld3,
'realworld4': RealWorld4,
'realworld5': RealWorld5,
'realworld6': RealWorld6,
'realworld7': RealWorld7,
'realworld8': RealWorld8,
'realworld9': RealWorld9
};
for (let d in demos) {
React.render(React.createElement(demos[d]), document.getElementById(d));
}
|
react/features/toolbox/components/web/ToolbarButton.js | bgrozev/jitsi-meet | /* @flow */
import Tooltip from '@atlaskit/tooltip';
import React from 'react';
import { Icon } from '../../../base/icons';
import AbstractToolbarButton from '../AbstractToolbarButton';
import type { Props as AbstractToolbarButtonProps }
from '../AbstractToolbarButton';
/**
* The type of the React {@code Component} props of {@link ToolbarButton}.
*/
type Props = AbstractToolbarButtonProps & {
/**
* The text to display in the tooltip.
*/
tooltip: string,
/**
* From which direction the tooltip should appear, relative to the
* button.
*/
tooltipPosition: string
};
/**
* Represents a button in the toolbar.
*
* @extends AbstractToolbarButton
*/
class ToolbarButton extends AbstractToolbarButton<Props> {
/**
* Default values for {@code ToolbarButton} component's properties.
*
* @static
*/
static defaultProps = {
tooltipPosition: 'top'
};
/**
* Renders the button of this {@code ToolbarButton}.
*
* @param {Object} children - The children, if any, to be rendered inside
* the button. Presumably, contains the icon of this {@code ToolbarButton}.
* @protected
* @returns {ReactElement} The button of this {@code ToolbarButton}.
*/
_renderButton(children) {
return (
<div
aria-label = { this.props.accessibilityLabel }
className = 'toolbox-button'
onClick = { this.props.onClick }>
{ this.props.tooltip
? <Tooltip
content = { this.props.tooltip }
position = { this.props.tooltipPosition }>
{ children }
</Tooltip>
: children }
</div>
);
}
/**
* Renders the icon of this {@code ToolbarButton}.
*
* @inheritdoc
*/
_renderIcon() {
return (
<div className = { `toolbox-icon ${this.props.toggled ? 'toggled' : ''}` }>
<Icon src = { this.props.icon } />
</div>
);
}
}
export default ToolbarButton;
|
app/javascript/mastodon/features/compose/components/character_counter.js | tootcafe/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import { length } from 'stringz';
export default class CharacterCounter extends React.PureComponent {
static propTypes = {
text: PropTypes.string.isRequired,
max: PropTypes.number.isRequired,
};
checkRemainingText (diff) {
if (diff < 0) {
return <span className='character-counter character-counter--over'>{diff}</span>;
}
return <span className='character-counter'>{diff}</span>;
}
render () {
const diff = this.props.max - length(this.props.text);
return this.checkRemainingText(diff);
}
}
|
LearnDemo/Login.js | TonyTong1993/Learn-React-Native | 'use strict';
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
Image,
TextInput,
Dimensions,
PixelRatio,
Button,
TouchableHighlight,
TouchableOpacity,
} from 'react-native';
//获取屏幕的尺寸
var screen_width = Dimensions.get('window').width;
class Login extends Component {
render() {
return (
<View style={styles.container}>
<Image
style={{height:80,width:80,alignSelf: 'center',borderRadius:40}}
source={{uri: 'http://pic.qiantucdn.com/58pic/13/72/07/55Z58PICKka_1024.jpg'}}
/>
<TextInput style={[styles.input,styles.center,styles.textCenter,styles.marginTop]}
placeholder = 'QQ号/手机号/邮箱'
clearButtonMode = 'while-editing'
>
</TextInput>
<TextInput style={[styles.input,styles.center,styles.textCenter,styles.lineHeight]}
placeholder = '密码'
secureTextEntry = {true}
clearButtonMode = 'while-editing'
>
</TextInput>
<TouchableHighlight
onPress={() =>{
console.log('login')
}}
style={[styles.loginButton,styles.center,styles.alignSelf,styles.marginTop]}
underlayColor='#4682b4'>
<Text style={styles.loginTextStyle}>
登录
</Text>
</TouchableHighlight>
<View style={[styles.assistBox,styles.marginTop]}>
<TouchableOpacity
onPress={() =>{
console.log('assistButton clicked');
}}
style={[styles.assistButton,styles.marginLeft]}
activeOpacity={0.5}>
<Text style={[styles.assistText]}>
忘记密码?
</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() =>{
console.log('assistButton clicked');
}}
style={[styles.assistButton]}
activeOpacity={0.5}>
<Text style={[styles.assistText]}>
新用户注册
</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container:{
flex:1,
paddingTop:64,
backgroundColor:'rgb(233,234,239)',
},
center:{
justifyContent: 'center',
alignItems: 'center',
},
loginTextStyle:{
fontSize:20,
color:'#ffffff',
},
alignSelf:{
alignSelf:'center',
},
color:{
color:'red',
},
input:{
height:44,
width:screen_width,//屏幕的宽度
borderBottomWidth:1/PixelRatio.get(),
borderBottomColor:'gray',
backgroundColor:'#ffffff'
},
marginTop:{
marginTop:15,
},
lineHeight:{
marginTop:2/PixelRatio.get(),
},
textCenter:{
textAlign:'center',
},
loginButton:{
width:screen_width-30,
height:40,
backgroundColor:'rgb(0,163,234)',
borderRadius:4,
},
assistBox:{
width:screen_width,
height:16,
flexDirection:'row',
justifyContent: 'space-around',
},
assistButton:{
},
assistText:{
fontSize:14,
color:'rgb(0,163,234)'
},
assistLeft:{
marginLeft:-50,
}
});
module.exports = Login; |
src/@ui/VideoPlayer/VideoPlayer.stories.js | NewSpring/Apollos | import React from 'react';
import { storiesOf } from '@storybook/react-native';
import { View } from 'react-native';
import VideoPlayer from './';
const videoUrl = 'https://secure-cf-c.ooyala.com/lnN3RmZDE6A5wfMQi8_l0MTUipc8acil/DOcJ-FxaFrRg4gtDEwOjI5cDowODE7AZ';
storiesOf('VideoPlayer', module)
.add('Default', () => (
<View style={{ width: '100%', aspectRatio: 16 / 9 }}>
<VideoPlayer
src={videoUrl}
/>
</View>
))
.add('Autoplay', () => (
<View style={{ width: '100%', aspectRatio: 16 / 9 }}>
<VideoPlayer
shouldPlay
src={videoUrl}
/>
</View>
));
|
client/components/button/index.js | yeoh-joer/synapse | /**
* External dependencies
*/
import React from 'react'
import PropTypes from 'prop-types'
import { omit, uniq, compact } from 'lodash'
/**
* Internal dependencies
*/
import './style.scss'
import classNames from 'client/lib/class-names'
export default class Button extends React.PureComponent {
static propTypes = {
dense: PropTypes.bool,
raised: PropTypes.bool,
compact: PropTypes.bool,
primary: PropTypes.bool,
accent: PropTypes.bool,
type: PropTypes.string,
href: PropTypes.string,
target: PropTypes.string,
rel: PropTypes.string
};
static defaultProps = {
type: 'button'
};
render() {
const omitProps = ['dense', 'raised', 'compact', 'primary', 'accent']
let tag
if (this.props.href) {
tag = 'a'
omitProps.push('type')
} else {
tag = 'button'
omitProps.push('target', 'rel')
}
const props = omit(this.props, omitProps)
// Block referrer when external link
if (props.target) {
props.rel = uniq(compact([
...(props.rel || '').split(' '),
'noopener',
'noreferrer'
])).join(' ')
}
return React.createElement(tag, {
...props,
className: classNames('mdc-button', this.props.className, {
'mdc-button--dense': this.props.dense,
'mdc-button--raised': this.props.raised,
'mdc-button--compact': this.props.compact,
'mdc-button--primary': this.props.primary,
'mdc-button--accent': this.props.accent
})
});
}
}
|
packages/material-ui-icons/src/SwapVerticalCircle.js | cherniavskii/material-ui | import React from 'react';
import createSvgIcon from './utils/createSvgIcon';
export default createSvgIcon(
<g><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM6.5 9L10 5.5 13.5 9H11v4H9V9H6.5zm11 6L14 18.5 10.5 15H13v-4h2v4h2.5z" /></g>
, 'SwapVerticalCircle');
|
src/icons/AndroidCompass.js | fbfeix/react-icons | import React from 'react';
import IconBase from './../components/IconBase/IconBase';
export default class AndroidCompass extends React.Component {
render() {
if(this.props.bare) {
return <g>
<path d="M256,231.358c-13.442,0-24.643,11.2-24.643,24.642s11.2,24.643,24.643,24.643s24.643-11.2,24.643-24.643
S269.442,231.358,256,231.358z M256,32C132.8,32,32,132.8,32,256s100.8,224,224,224s224-100.8,224-224S379.2,32,256,32z
M305.284,305.284L121.6,390.4l85.116-183.679L390.4,121.6L305.284,305.284z"></path>
</g>;
} return <IconBase>
<path d="M256,231.358c-13.442,0-24.643,11.2-24.643,24.642s11.2,24.643,24.643,24.643s24.643-11.2,24.643-24.643
S269.442,231.358,256,231.358z M256,32C132.8,32,32,132.8,32,256s100.8,224,224,224s224-100.8,224-224S379.2,32,256,32z
M305.284,305.284L121.6,390.4l85.116-183.679L390.4,121.6L305.284,305.284z"></path>
</IconBase>;
}
};AndroidCompass.defaultProps = {bare: false} |
webapp/src/app/availability/containers/InfoStaleState.js | cpollet/itinerants | import React from 'react';
import {connect} from 'react-redux';
class InfoStaleState extends React.Component {
render() {
return !this.props.stale ? null :
(
<div style={{position: 'relative'}}>
<div style={{
position: 'absolute',
top: -20,
right: -15,
zIndex: 999,
fontSize: '80%',
}}>{this.props.text}</div>
</div>
);
}
}
InfoStaleState.propTypes = {
stale: React.PropTypes.bool.isRequired,
text: React.PropTypes.string.isRequired,
};
function mapStateToProps(state) {
return {
stale: state.app.availabilities.serverSync.retryCount > 0 && (state.app.availabilities.serverSync.stale || state.app.availabilities.serverSync.syncPending),
};
}
export default connect(mapStateToProps)(InfoStaleState);
|
js/components/tab/tabTwo.js | alaxa27/Lukeat | import React, { Component } from 'react';
import { Container, Content, Card, CardItem, Text, Body } from 'native-base';
import styles from './styles';
export default class TabTwo extends Component {
// eslint-disable-line
render() {
// eslint-disable-line
return (
<Content padder style={{ marginTop: 0 }}>
<Card style={{ flex: 0 }}>
<CardItem>
<Body>
<Text>
NativeBase builds a layer on top of React Native that provides you with basic set of
components for mobile application development. This helps you to build world-class
application experiences on native platforms.
</Text>
</Body>
</CardItem>
</Card>
</Content>
);
}
}
|
ui/layouts/_base-layout.js | sakulstra/firebase-nextjs-mobx | import React from 'react'
import { Header, Footer } from '~/ui/generic'
const BaseLayout = ({ children }) => (
<div className='site'>
<style jsx>{`
.site{
display: flex;
min-height: 100vh;
flex-direction: column;
}
.content {
flex: 1;
}
`}</style>
<Header />
<div className='content'>
{children}
</div>
<Footer />
</div>
)
export default BaseLayout
|
client/components/ComputerNameGenerator/ComputerNameGenerator.js | vcu-lcc/nomad | /*
Copyright (C) 2017 Darren Chan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import Radium from 'radium';
import PropTypes from 'prop-types';
import ComputerName from './ComputerName';
import Dropdown from '../Shared/Dropdown';
import FieldSet from '../Shared/FieldSet';
import InputBox from '../Shared/InputBox';
class ComputerNameGenerator extends React.Component {
constructor(props) {
super(props);
this.state = {
done: false,
fields: []
};
}
updateFields(selections) {
let fields = [{
label: 'Computer Type',
options: ['Classroom Podium Workstation', 'Lab Workstation', 'Kiosk', 'Channel Player', 'Faculty/Staff Computer', 'Server']
}];
let computerName = '';
switch (selections[0]) {
case 0:
case 1: {
let university = selections.length > 1 ? this.props.universities[selections[1]] : null;
let campus = university && selections.length > 2 ? university.Campuses[selections[2]] : null;
let building = campus && selections.length > 3 ? campus.Buildings[selections[3]] : null;
let room = building && selections.length > 4 ? building.Rooms[selections[4]] : null;
let computerNumber = room && selections.length > 5 ? selections[5] : null;
fields.push({
label: 'University',
options: this.props.universities.map(u => u.Name)
});
if (university) {
fields.push({
label: 'Campus',
options: university.Campuses.map(c => c.Name)
});
}
if (campus) {
fields.push({
label: 'Building',
options: campus.Buildings.map(b => b.Name)
});
}
if (building) {
fields.push({
label: 'Room',
options: building.Rooms.map(r => r.Name)
});
}
if (room) {
fields.push({
label: 'Computer Number'
});
}
this.setState({
done: !!computerNumber
});
computerName = (campus ? campus.Acronym.substring(0, 3) || 'null' : '[CAMPUS]')
+ (building ? building.Acronym.substring(0, 3) || 'null' : '[BUILDING]')
+ (room ? room.RoomNumber.substring(Math.max(0, room.RoomNumber.length - 5), room.RoomNumber.length) || 'null' : '[ROOM]')
+ (selections[0] == 0 ? 'P' : 'L')
+ (computerNumber ? computerNumber.substring(0, 3)|| '#' : '[#]');
break;
}
case 2:
case 3: {
const ENVIRONMENTS = ['Office/Room', 'Other'];
let university = selections.length > 1 ? this.props.universities[selections[1]] : null;
let campus = university && selections.length > 2 ? university.Campuses[selections[2]] : null;
let building = campus && selections.length > 3 ? campus.Buildings[selections[3]] : null;
let environment = building && selections.length > 4 ? ENVIRONMENTS[selections[4]] : null;
let center = '...';
let roomNumber = environment == ENVIRONMENTS[0] && selections.length > 5 ? selections[5] : null;
let floor = environment == ENVIRONMENTS[1] && selections.length > 5 ? selections[5] : null;
let location = floor && selections.length > 6 ? selections[6] : null;
let computerNumber = null;
if (roomNumber) {
computerNumber = selections.length > 6 ? selections[6] : null;
}
if (location) {
computerNumber = selections.length > 7 ? selections[7] : null;
}
fields.push({
label: 'University',
options: this.props.universities.map(u => u.Name)
});
if (university) {
fields.push({
label: 'Campus',
options: university.Campuses.map(c => c.Name)
});
}
if (campus) {
fields.push({
label: 'Building',
options: campus.Buildings.map(b => b.Name)
});
}
if (building) {
fields.push({
label: 'Environment',
options: ENVIRONMENTS
});
}
if (environment === ENVIRONMENTS[0]) {
fields.push({
label: 'Office/Room'
});
center = roomNumber ? roomNumber.substring(0, 5) || '00000' : '[OFFICE/ROOM]';
} else if (environment === ENVIRONMENTS[1]) {
fields.push({
label: 'Floor'
});
if (floor) {
fields.push({
label: 'Location'
});
}
center = (floor ? floor.substring(0, 2) || '00' : '[FLOOR]')
+ (location ? location.substring(0, 3) || 'null' : '[LOCATION]');
}
if (roomNumber || location) {
fields.push({
label: 'Computer Number'
});
}
this.setState({
done: !!computerNumber
});
computerName = (campus ? campus.Acronym.substring(0, 3) || 'null' : '[CAMPUS]')
+ (building ? building.Acronym.substring(0, 3) || 'null' : '[BUILDING]')
+ center
+ (selections[0] == 2 ? 'K' : 'C')
+ (computerNumber ? computerNumber.substring(0, 3)|| '##' : '[##]');
break;
}
case 4: {
const FORM_FACTORS = ['Desktop', 'Laptop', 'Tablet', 'Mobile'];
let university = selections.length > 1 ? this.props.universities[selections[1]] : null;
let campus = university && selections.length > 2 ? university.Campuses[selections[2]] : null;
let topOU = campus && selections.length > 3 ? selections[3] : null;
let building = topOU && selections.length > 4 ? campus.Buildings[selections[4]] : null;
let initials = building && selections.length > 5 ? selections[5] : null;
let formFactor = initials && selections.length > 6 ? FORM_FACTORS[selections[6]] : null;
let computerNumber = formFactor && selections.length > 7 ? selections[7] : null;
fields.push({
label: 'University',
options: this.props.universities.map(u => u.Name)
});
if (university) {
fields.push({
label: 'Campus',
options: university.Campuses.map(c => c.Name)
});
}
if (campus) {
fields.push({
label: 'Top Level OU'
});
}
if (topOU) {
fields.push({
label: 'Building',
options: campus.Buildings.map(b => b.Name)
});
}
if (building) {
fields.push({
label: 'Initials'
});
}
if (initials) {
fields.push({
label: 'Device Form Factor',
options: FORM_FACTORS
});
}
if (formFactor) {
fields.push({
label: 'Computer Number'
});
}
this.setState({
done: !!computerNumber
});
computerName = (topOU ? topOU.substring(0, 3) || 'null' : '[TOP OU]')
+ (building ? building.Acronym.substring(0, 3) || 'null' : '[BUILDING]')
+ (initials ? initials.substring(0, 3) || 'null' : '[INITIALS]')
+ (formFactor ? formFactor[0] || '#' : '[#]')
+ (computerNumber ? computerNumber.substring(0, 3)|| '#' : '[#]');
break;
}
case 5: {
let deptFunc = selections.length > 1 ? selections[1] : null;
let computerNumber = deptFunc && selections.length > 2 ? selections[2] : null;
fields.push({
label: 'Department/Function'
});
if (deptFunc) {
fields.push({
label: 'Computer Number'
});
}
this.setState({
done: !!computerNumber
});
computerName = (deptFunc ? deptFunc.substring(0, 12) || 'null' : '[DEPTARTMENT/FUNCTION]')
+ (computerNumber ? computerNumber.substring(0, 3) || '###' : '[###]');
break;
}
}
this.setState({
fields
});
if (computerName) {
this.props.setComputerName(computerName);
}
}
componentDidMount() {
this.updateFields(this.props.selections);
}
componentWillReceiveProps(nextProps) {
if (nextProps.selections.length !== this.props.selections.length
|| !this.props.selections.reduce((accum, e, i) => accum ? e === nextProps.selections[i] : false, true)) {
// update asynchronously if the previous and next selections differ
setTimeout(() => this.updateFields(nextProps.selections));
}
}
render() {
return (
<FieldSet>
{
this.state.fields.map((e, i) => e.options ?
(<Dropdown key={this.props.selections.slice(0, i).join(',')} label={e.label} index={i < this.props.selections.length ? this.props.selections[i] : -1}
options={e.options} onSelect={idx => idx === this.props.selections[i] || this.props.updateSelections(this.props.selections.slice(0, i).concat([idx]))} />)
: (<InputBox key={this.props.selections.slice(0, i).join(',')} label={e.label} defaultValue={i < this.props.selections.length ? this.props.selections[i] : -1}
onChange={s => s === this.props.selections[i] || this.props.updateSelections(this.props.selections.slice(0, i).concat([s]))} />))
}
<ComputerName
allowUserOverride={this.props.allowUserOverride}
userSubmit={this.state.done}
minLength={this.props.minLength}
maxLength={this.props.maxLength}
setComputerName={this.props.setComputerName}
resolve={name => {
this.props.resolve(name);
}}
submitOnMount={this.props.apply}
>
{this.props.computerName}
</ComputerName>
</FieldSet>
);
}
}
ComputerNameGenerator.defaultProps = {
allowUserOverride: false,
computerName: '',
selections: [],
universities: [],
minLength: 0,
maxLength: Infinity,
apply: false
};
ComputerNameGenerator.propTypes = {
allowUserOverride: PropTypes.bool,
computerName: PropTypes.string,
selections: PropTypes.array,
universities: PropTypes.array,
minLength: PropTypes.number,
maxLength: PropTypes.number,
apply: PropTypes.bool
};
export default Radium(ComputerNameGenerator);
|
src/components/invest/index.js | oraclesorg/ico-wizard | import React from 'react'
import { attachToContract, checkNetWorkByID, checkTxMined, sendTXToContract } from '../../utils/blockchainHelpers'
import {
findCurrentContractRecursively,
getAccumulativeCrowdsaleData,
getContractStoreProperty,
getCrowdsaleData,
getCrowdsaleTargetDates,
getCurrentRate,
getJoinedTiers,
initializeAccumulativeData,
toBigNumber
} from '../crowdsale/utils'
import { countDecimalPlaces, getQueryVariable, toast } from '../../utils/utils'
import { getWhiteListWithCapCrowdsaleAssets } from '../../stores/utils'
import {
invalidCrowdsaleAddrAlert,
investmentDisabledAlertInTime, noGasPriceAvailable,
noMetaMaskAlert,
MetaMaskIsLockedAlert,
successfulInvestmentAlert
} from '../../utils/alerts'
import { Loader } from '../Common/Loader'
import { CrowdsaleConfig } from '../Common/config'
import { INVESTMENT_OPTIONS, TOAST } from '../../utils/constants'
import { inject, observer } from 'mobx-react'
import QRPaymentProcess from './QRPaymentProcess'
import CountdownTimer from './CountdownTimer'
import classNames from 'classnames'
import moment from 'moment'
import { BigNumber } from 'bignumber.js'
import { Form } from 'react-final-form'
import { InvestForm } from './InvestForm'
@inject('contractStore', 'crowdsalePageStore', 'web3Store', 'tierStore', 'tokenStore', 'generalStore', 'investStore', 'gasPriceStore', 'generalStore')
@observer
export class Invest extends React.Component {
constructor(props) {
super(props)
window.scrollTo(0, 0)
this.state = {
loading: true,
pristineTokenInput: true,
web3Available: false,
investThrough: INVESTMENT_OPTIONS.QR,
crowdsaleAddress: CrowdsaleConfig.crowdsaleContractURL || getQueryVariable('addr'),
toNextTick: {
days: 0,
hours: 0,
minutes: 0,
seconds: 0
},
nextTick: {},
msToNextTick: 0,
displaySeconds: false,
isFinalized: false
}
}
componentDidMount () {
const { web3Store, gasPriceStore, generalStore } = this.props
const { web3 } = web3Store
if (!web3) {
this.setState({ loading: false })
return
}
const networkID = CrowdsaleConfig.networkID ? CrowdsaleConfig.networkID : getQueryVariable('networkID')
checkNetWorkByID(networkID)
this.setState({
web3Available: true,
investThrough: INVESTMENT_OPTIONS.METAMASK
})
getWhiteListWithCapCrowdsaleAssets()
.then(_newState => {
this.setState(_newState)
this.extractContractsData()
gasPriceStore.updateValues()
.then(() => generalStore.setGasPrice(gasPriceStore.slow.price))
.catch(() => noGasPriceAvailable())
})
}
componentWillUnmount () {
this.clearTimeInterval()
}
extractContractsData() {
const { contractStore, web3Store } = this.props
const { web3 } = web3Store
const crowdsaleAddr = CrowdsaleConfig.crowdsaleContractURL ? CrowdsaleConfig.crowdsaleContractURL : getQueryVariable('addr')
if (!web3.utils.isAddress(crowdsaleAddr)) {
this.setState({ loading: false })
return invalidCrowdsaleAddrAlert()
}
getJoinedTiers(contractStore.crowdsale.abi, crowdsaleAddr, [], joinedCrowdsales => {
console.log('joinedCrowdsales:', joinedCrowdsales)
const crowdsaleAddrs = typeof joinedCrowdsales === 'string' ? [joinedCrowdsales] : joinedCrowdsales
contractStore.setContractProperty('crowdsale', 'addr', crowdsaleAddrs)
web3.eth.getAccounts()
.then((accounts) => {
if (accounts.length === 0) {
this.setState({ loading: false })
}
this.setState({
curAddr: accounts[0],
web3
})
})
.then(() => {
if (!contractStore.crowdsale.addr) {
this.setState({ loading: false })
return
}
findCurrentContractRecursively(0, null, crowdsaleContract => {
if (!crowdsaleContract) {
this.setState({ loading: false })
return
}
initializeAccumulativeData()
.then(() => getCrowdsaleData(crowdsaleContract))
.then(() => getAccumulativeCrowdsaleData())
.then(() => getCrowdsaleTargetDates())
.then(() => this.checkIsFinalized())
.then(() => this.setTimers())
.catch(err => console.log(err))
.then(() => this.setState({ loading: false }))
})
})
})
}
checkIsFinalized() {
return this.isFinalized()
.then(isFinalized => {
this.setState({ isFinalized })
})
}
setTimers = () => {
const { crowdsalePageStore } = this.props
let nextTick = 0
let millisecondsToNextTick = 0
let timeInterval
if (crowdsalePageStore.ticks.length) {
nextTick = crowdsalePageStore.extractNextTick()
millisecondsToNextTick = nextTick.time - Date.now()
const FIVE_MINUTES_BEFORE_TICK = moment(millisecondsToNextTick).subtract(5, 'minutes').valueOf()
const ONE_DAY = 24 * 3600 * 1000
if (FIVE_MINUTES_BEFORE_TICK < ONE_DAY) {
setTimeout(() => {
this.setState({ displaySeconds: true })
}, FIVE_MINUTES_BEFORE_TICK)
}
timeInterval = setInterval(() => {
const time = moment.duration(this.state.nextTick.time - Date.now())
this.setState({
toNextTick: {
days: Math.floor(time.asDays()) || 0,
hours: time.hours() || 0,
minutes: time.minutes() || 0,
seconds: time.seconds() || 0
}
})
}, 1000)
}
this.setState({
nextTick,
msToNextTick: millisecondsToNextTick,
displaySeconds: false,
timeInterval
})
}
resetTimers = () => {
this.clearTimeInterval()
this.setTimers()
}
clearTimeInterval = () => {
if (this.state.timeInterval) clearInterval(this.state.timeInterval)
}
investToTokens = () => {
const { investStore, crowdsalePageStore, web3Store } = this.props
const { startDate } = crowdsalePageStore
const { web3 } = web3Store
if (!this.isValidToken(investStore.tokensToInvest)) {
this.setState({ pristineTokenInput: false })
return
}
this.setState({ loading: true })
if (!startDate) {
this.setState({ loading: false })
return
}
if (web3.eth.accounts.length === 0) {
this.setState({ loading: false })
return MetaMaskIsLockedAlert()
}
this.investToTokensForWhitelistedCrowdsale()
}
investToTokensForWhitelistedCrowdsale() {
const { crowdsalePageStore, web3Store } = this.props
const { web3 } = web3Store
if (crowdsalePageStore.startDate > (new Date()).getTime()) {
this.setState({ loading: false })
return investmentDisabledAlertInTime(crowdsalePageStore.startDate)
}
findCurrentContractRecursively(0, null, (crowdsaleContract, tierNum) => {
if (!crowdsaleContract) {
this.setState({ loading: false })
return
}
getCurrentRate(crowdsaleContract)
.then(() => web3.eth.getAccounts())
.then((accounts) => this.investToTokensForWhitelistedCrowdsaleInternal(crowdsaleContract, tierNum, accounts))
.catch(console.log)
})
}
investToTokensForWhitelistedCrowdsaleInternal(crowdsaleContract, tierNum, accounts) {
const { contractStore, tokenStore, crowdsalePageStore, investStore, generalStore } = this.props
let nextTiers = []
for (let i = tierNum + 1; i < contractStore.crowdsale.addr.length; i++) {
nextTiers.push(contractStore.crowdsale.addr[i])
}
console.log('nextTiers:', nextTiers)
console.log(nextTiers.length)
const decimals = new BigNumber(tokenStore.decimals)
console.log('decimals:', decimals.toFixed())
const rate = new BigNumber(crowdsalePageStore.rate) //it is from contract. It is already in wei. How much 1 token costs in wei.
console.log('rate:', rate.toFixed())
const tokensToInvest = new BigNumber(investStore.tokensToInvest)
console.log('tokensToInvest:', tokensToInvest.toFixed())
const weiToSend = tokensToInvest.multipliedBy(rate)
console.log('weiToSend:', weiToSend.toFixed())
const opts = {
from: accounts[0],
value: weiToSend.integerValue(BigNumber.ROUND_CEIL),
gasPrice: generalStore.gasPrice
}
console.log(opts)
crowdsaleContract.methods.buy().estimateGas(opts)
.then(estimatedGas => {
const estimatedGasMax = 4016260
opts.gasLimit = !estimatedGas || estimatedGas > estimatedGasMax ? estimatedGasMax : estimatedGas + 100000
return sendTXToContract(crowdsaleContract.methods.buy().send(opts))
})
.then(() => successfulInvestmentAlert(investStore.tokensToInvest))
.catch(err => toast.showToaster({ type: TOAST.TYPE.ERROR, message: TOAST.MESSAGE.TRANSACTION_FAILED }))
.then(() => this.setState({ loading: false }))
}
txMinedCallback(txHash, receipt) {
const { investStore } = this.props
if (receipt) {
if (receipt.blockNumber) {
this.setState({ loading: false })
successfulInvestmentAlert(investStore.tokensToInvest)
}
} else {
setTimeout(() => {
checkTxMined(txHash, receipt => this.txMinedCallback(txHash, receipt))
}, 500)
}
}
updateInvestThrough = (investThrough) => {
this.setState({ investThrough })
}
isValidToken(token) {
return +token > 0 && countDecimalPlaces(token) <= this.props.tokenStore.decimals
}
isFinalized() {
const { contractStore } = this.props
const lastCrowdsaleAddress = contractStore.crowdsale.addr.slice(-1)[0]
return attachToContract(contractStore.crowdsale.abi, lastCrowdsaleAddress)
.then(crowdsaleContract => {
return crowdsaleContract.methods.finalized().call()
})
}
render () {
const { crowdsalePageStore, tokenStore, contractStore } = this.props
const { tokenAmountOf } = crowdsalePageStore
const { crowdsale } = contractStore
const { curAddr, investThrough, crowdsaleAddress, web3Available, toNextTick, nextTick } = this.state
const { days, hours, minutes, seconds } = toNextTick
const { decimals, ticker, name } = tokenStore
const tokenDecimals = !isNaN(decimals) ? decimals : 0
const tokenTicker = ticker ? ticker.toString() : ''
const tokenName = name ? name.toString() : ''
const maximumSellableTokens = toBigNumber(crowdsalePageStore.maximumSellableTokens)
const maxCapBeforeDecimals = toBigNumber(maximumSellableTokens).div(`1e${tokenDecimals}`)
const tokenAddress = getContractStoreProperty('token', 'addr')
//balance
const investorBalance = tokenAmountOf ? toBigNumber(tokenAmountOf).div(`1e${tokenDecimals}`).toFixed() : '0'
//total supply
const totalSupply = maxCapBeforeDecimals.toFixed()
const QRPaymentProcessElement = investThrough === INVESTMENT_OPTIONS.QR ?
<QRPaymentProcess crowdsaleAddress={crowdsaleAddress} /> :
null
const rightColumnClasses = classNames('invest-table-cell', 'invest-table-cell_right', {
'qr-selected': investThrough === INVESTMENT_OPTIONS.QR
})
return <div className="invest container">
<div className="invest-table">
<div className="invest-table-cell invest-table-cell_left">
<CountdownTimer
displaySeconds={this.state.displaySeconds}
nextTick={nextTick}
tiersLength={crowdsalePageStore && crowdsalePageStore.tiers.length}
days={days}
hours={hours}
minutes={minutes}
seconds={seconds}
msToNextTick={this.state.msToNextTick}
onComplete={this.resetTimers}
isFinalized={this.state.isFinalized}
/>
<div className="hashes">
<div className="hashes-i">
<p className="hashes-title">{curAddr}</p>
<p className="hashes-description">Current Account</p>
</div>
<div className="hashes-i">
<p className="hashes-title">{tokenAddress}</p>
<p className="hashes-description">Token Address</p>
</div>
<div className="hashes-i">
<p className="hashes-title">{crowdsale && crowdsale.addr && crowdsale.addr[0]}</p>
<p className="hashes-description">Crowdsale Contract Address</p>
</div>
<div className="hashes-i">
<p className="hashes-title">{tokenName}</p>
<p className="hashes-description">Name</p>
</div>
<div className="hashes-i">
<p className="hashes-title">{tokenTicker}</p>
<p className="hashes-description">Ticker</p>
</div>
<div className="hashes-i">
<p className="hashes-title">{totalSupply} {tokenTicker}</p>
<p className="hashes-description">Total Supply</p>
</div>
</div>
<p className="invest-title">Invest page</p>
<p className="invest-description">
{'Here you can invest in the crowdsale campaign. At the moment, you need Metamask client to invest into the crowdsale. If you don\'t have Metamask, you can send ethers to the crowdsale address with a MethodID: 0xa6f2ae3a. Sample '}
<a href="https://kovan.etherscan.io/tx/0x42073576a160206e61b4d9b70b436359b8d220f8b88c7c272c77023513c62c3d">transaction</a> on Kovan network.
</p>
</div>
<div className={rightColumnClasses}>
<div className="balance">
<p className="balance-title">{investorBalance} {tokenTicker}</p>
<p className="balance-description">Balance</p>
<p className="description">
Your balance in tokens.
</p>
</div>
<Form
onSubmit={this.investToTokens}
component={InvestForm}
investThrough={investThrough}
updateInvestThrough={this.updateInvestThrough}
web3Available={web3Available}
/>
{QRPaymentProcessElement}
</div>
</div>
<Loader show={this.state.loading}></Loader>
</div>
}
}
|
node_modules/react-router-dom/es/NavLink.js | yaolei/Samoyed | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import React from 'react';
import PropTypes from 'prop-types';
import Route from './Route';
import Link from './Link';
/**
* A <Link> wrapper that knows if it's "active" or not.
*/
var NavLink = function NavLink(_ref) {
var to = _ref.to,
exact = _ref.exact,
strict = _ref.strict,
location = _ref.location,
activeClassName = _ref.activeClassName,
className = _ref.className,
activeStyle = _ref.activeStyle,
style = _ref.style,
getIsActive = _ref.isActive,
ariaCurrent = _ref.ariaCurrent,
rest = _objectWithoutProperties(_ref, ['to', 'exact', 'strict', 'location', 'activeClassName', 'className', 'activeStyle', 'style', 'isActive', 'ariaCurrent']);
return React.createElement(Route, {
path: (typeof to === 'undefined' ? 'undefined' : _typeof(to)) === 'object' ? to.pathname : to,
exact: exact,
strict: strict,
location: location,
children: function children(_ref2) {
var location = _ref2.location,
match = _ref2.match;
var isActive = !!(getIsActive ? getIsActive(match, location) : match);
return React.createElement(Link, _extends({
to: to,
className: isActive ? [className, activeClassName].filter(function (i) {
return i;
}).join(' ') : className,
style: isActive ? _extends({}, style, activeStyle) : style,
'aria-current': isActive && ariaCurrent
}, rest));
}
});
};
NavLink.propTypes = {
to: Link.propTypes.to,
exact: PropTypes.bool,
strict: PropTypes.bool,
location: PropTypes.object,
activeClassName: PropTypes.string,
className: PropTypes.string,
activeStyle: PropTypes.object,
style: PropTypes.object,
isActive: PropTypes.func,
ariaCurrent: PropTypes.oneOf(['page', 'step', 'location', 'true'])
};
NavLink.defaultProps = {
activeClassName: 'active',
ariaCurrent: 'true'
};
export default NavLink; |
jenkins-design-language/src/js/components/material-ui/svg-icons/image/rotate-right.js | alvarolobato/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const ImageRotateRight = (props) => (
<SvgIcon {...props}>
<path d="M15.55 5.55L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42l1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"/>
</SvgIcon>
);
ImageRotateRight.displayName = 'ImageRotateRight';
ImageRotateRight.muiName = 'SvgIcon';
export default ImageRotateRight;
|
src/component/Mousetrap.js | georgeOsdDev/react-mousetrap-mixin | 'use strict';
import React from 'react';
import MousetrapMixin from '../mixin/Mousetrap';
let Mousetrap = React.createClass({
mixins: [MousetrapMixin],
propTypes: {
mousetrap: React.PropTypes.object
},
getMousetrap() {
return {
mousetrap: {}
}
},
render() {
let element = this.props.children || (<span key='mousetrap-hidden' id='mousetrap-hidden' style={{ display:'none' }} />);
return element;
}
});
export default Mousetrap;
|
ui/button/index.js | hakonhk/vaerhona | import React from 'react';
import styled from 'styled-components';
import is, { isNot } from 'styled-is';
import { lighten } from 'polished';
import { Spinner } from '../spinner';
import preventDoubleTapZoom from './preventDoubleTapZoom';
const themes = {
primary: {
default: `
background: #888;
color: #fff;
text-decoration: none;
text-align: center;
`,
hover: `
background: #999;
`,
disabled: `
background: #aaa;
color: #333;
`,
},
clean: {
default: ``,
hover: ``,
disabled: ``,
},
danger: {
default: `
background: red;
color: #fff;
text-decoration: none;
text-align: center;
`,
hover: `
background: ${lighten(0.05, 'red')};
`,
disabled: `
background: #aaa;
color: #333;
`,
},
};
function getTheme(rest) {
const themeNames = Object.keys(themes);
for (let i = 0; i < themeNames.length; i++) {
if (themeNames[i] in rest) {
return themes[themeNames[i]];
}
}
return themes.primary;
}
const sizes = {
tiny: {
padding: '0px 1px',
minWidth: '0',
},
small: {
padding: '5px 10px',
minWidth: '0',
},
medium: {
padding: '10px 15px',
},
large: {
padding: '0px 1px',
minWidth: '0',
},
xlarge: {
padding: '0px 1px',
minWidth: '0',
},
};
function getSize({ tiny, small, large, xlarge }) {
if (tiny) {
return sizes.tiny;
}
if (small) {
return sizes.small;
}
if (large) {
return sizes.large;
}
if (xlarge) {
return sizes.xlarge;
}
return sizes.medium;
}
const ButtonInner = styled.span`
display: flex;
align-items: center;
justify-content: center;
min-width: ${(p) => p.size.minWidth};
padding: ${(p) => p.size.padding};
padding: ${(p) => p.size.padding};
font-size: ${(p) => p.size.fontSize || 'inherit'};
transition: background-color 100ms;
position: relative;
${(p) => (p.theme ? p.theme.default : '')};
`;
const ButtonOuter = styled.button`
display: ${(p) => (p.block ? 'block' : 'inline-block')};
border-radius: 0;
border: none;
padding: 0;
appearance: none;
cursor: pointer;
text-decoration: none;
background: transparent;
&:hover ${ButtonInner} {
${({ theme }) => (theme ? theme.hover : ``)};
}
&[disabled] {
cursor: default;
${ButtonInner} {
${({ theme }) => (theme ? theme.disabled : ``)};
}
}
`;
const ButtonText = styled.span`
position: relative;
z-index: 2;
transition: opacity 100ms, transform 100ms;
${isNot('shown')`
opacity: 0;
transform: scale(0.7);
`};
`;
const ButtonLoading = styled.span`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0;
transform: scale(0.5);
transition: opacity 100ms, transform 100ms;
display: flex;
align-items: center;
justify-content: center;
svg {
width: auto;
height: 50%;
}
${is('shown')`
opacity: 1;
transform: none;
`};
`;
export const Button = ({
children,
tiny,
small,
large,
xlarge,
loading,
block,
...rest
}) => {
const theme = getTheme(rest);
const size = getSize({ tiny, small, large, xlarge });
const as = rest.as || 'button';
return (
<ButtonOuter
as={as}
{...rest}
theme={theme}
block={block}
onTouchStart={preventDoubleTapZoom}
>
<ButtonInner theme={theme} size={size}>
<ButtonText shown={!loading}>{children}</ButtonText>
<ButtonLoading shown={loading}>
<Spinner />
</ButtonLoading>
</ButtonInner>
</ButtonOuter>
);
};
|
client/modules/comments/components/.stories/create_comment.js | luki21213/tripIdeas | import React from 'react';
import { storiesOf, action } from '@kadira/storybook';
import CreateComment from '../create_comment';
storiesOf('comments.CreateComment', module)
.add('default view', () => {
return (
<div className='comments'>
<CreateComment postId='the-id' create={action('create comment')}/>
</div>
);
})
.add('with error', () => {
return (
<div className='comments'>
<CreateComment
error='This is the error message'
postId='the-id'
create={action('create comment')}
/>
</div>
);
});
|
stories/ui.js | maputnik/editor | import React from 'react';
export function Describe ({children}) {
return (
<div style={{maxWidth: "600px", margin: "0.8em"}}>
{children}
</div>
)
}
export function Wrapper ({children}) {
return (
<div style={{maxWidth: "260px", margin: "0.4em"}}>
{children}
</div>
);
};
export function InputContainer ({children}) {
return (
<div style={{maxWidth: "171px", margin: "0.4em"}}>
{children}
</div>
);
};
|
actor-apps/app-web/src/app/components/modals/CreateGroup.react.js | hzy87email/actor-platform | import React from 'react';
import CreateGroupActionCreators from 'actions/CreateGroupActionCreators';
import CreateGroupStore from 'stores/CreateGroupStore';
import CreateGroupForm from './create-group/Form.react';
import Modal from 'react-modal';
import { KeyCodes } from 'constants/ActorAppConstants';
const appElement = document.getElementById('actor-web-app');
Modal.setAppElement(appElement);
const getStateFromStores = () => {
return {
isShown: CreateGroupStore.isModalOpen()
};
};
class CreateGroup extends React.Component {
constructor(props) {
super(props);
this.state = getStateFromStores();
CreateGroupStore.addChangeListener(this.onChange);
document.addEventListener('keydown', this.onKeyDown, false);
}
componentWillUnmount() {
CreateGroupStore.removeChangeListener(this.onChange);
document.removeEventListener('keydown', this.onKeyDown, false);
}
render() {
const isShown = this.state.isShown;
return (
<Modal className="modal-new modal-new--create-group" closeTimeoutMS={150} isOpen={isShown}>
<header className="modal-new__header">
<a className="modal-new__header__close modal-new__header__icon material-icons" onClick={this.onClose}>clear</a>
<h3 className="modal-new__header__title">Create group</h3>
</header>
<CreateGroupForm/>
</Modal>
);
}
onChange = () => {
this.setState(getStateFromStores());
}
onClose = () => {
CreateGroupActionCreators.closeModal();
}
onKeyDown = (event) => {
if (event.keyCode === KeyCodes.ESC) {
event.preventDefault();
this.onClose();
}
}
}
CreateGroup.displayName = 'CreateGroup';
export default CreateGroup;
|
src/svg-icons/image/iso.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageIso = (props) => (
<SvgIcon {...props}>
<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5.5 7.5h2v-2H9v2h2V9H9v2H7.5V9h-2V7.5zM19 19H5L19 5v14zm-2-2v-1.5h-5V17h5z"/>
</SvgIcon>
);
ImageIso = pure(ImageIso);
ImageIso.displayName = 'ImageIso';
ImageIso.muiName = 'SvgIcon';
export default ImageIso;
|
client/src/components/JoinChannel.js | shamb0t/orbit | 'use strict'
import React from 'react'
import TransitionGroup from "react-addons-css-transition-group"
import 'styles/JoinChannel.scss'
var initialStatusMessage = "This channel requires a password";
class JoinChannel extends React.Component {
constructor(props) {
super(props);
this.state = {
channelNamePlaceholder: props.channelNamePlaceholder,
requirePassword: props.requirePassword,
statusMsg: initialStatusMessage,
theme: props.theme
};
}
componentWillReceiveProps(nextProps) {
this.setState({
requirePassword: nextProps.channelNamePlaceholder ? nextProps.requirePassword : false,
channelNamePlaceholder: nextProps.channelNamePlaceholder,
theme: nextProps.theme
});
}
// componentDidUpdate(prevProps, prevState) {
// if(this.state.requirePassword)
// this.refs.password.focus();
// Actions.raiseInvalidChannelPassword.listen(() => this.setState({ statusMsg: "Incorrect password" }));
// }
componentDidMount() {
this.refs.channel.focus();
}
joinChannel(event) {
event.preventDefault();
var channel = this.refs.channel.value.trim();
if(channel !== '') {
var password = this.state.requirePassword ? this.refs.password.value.trim() : "";
this.setState({ requirePassword: false });
this.props.onJoinChannel(channel, password);
}
this.refs.channel.focus();
}
handleNameChange(event) {
event.preventDefault();
this.setState({
channelNamePlaceholder: event.target.value,
requirePassword: false,
statusMsg: initialStatusMessage
});
}
render() {
var passwordField = this.state.requirePassword ? (
<TransitionGroup component="div" transitionName="passwordFieldAnimation" transitionAppear={true} className="passwordContainer">
<input type="password" ref="password" placeholder="Password..."/>
</TransitionGroup>
) : "";
var channelNameField = this.state.channelNamePlaceholder ?
<input type="text" ref="channel" defaultValue={this.state.channelNamePlaceholder} onChange={this.handleNameChange.bind(this)}/> :
<input type="text" ref="channel" placeholder="channel"/>;
var final = this.state.requirePassword ? (
<form onSubmit={this.joinChannel.bind(this)}>
<input type="submit" value="" style={{ display: "none" }}></input>
<div className="row">
<span className="label">#</span>
<span className="field" style={this.state.theme}>{channelNameField}</span>
</div>
<div className="row">
<span className="label"></span>
<span className="field" style={this.state.theme}>{passwordField}</span>
</div>
<div className="row">
<span className="label"></span>
<span className="field"><span className="text">{this.state.statusMsg}</span></span>
</div>
</form>
) : (
<form onSubmit={this.joinChannel.bind(this)}>
<div className="row">
<span className="label">#</span>
<span className="field" style={this.state.theme}>{channelNameField}</span>
</div>
</form>
);
return (
<div className="JoinChannel">
{final}
</div>
);
}
}
export default JoinChannel;
|
js/app/dashboard/handler.js | monetario/web |
'use strict';
import React from 'react';
import {Router, Route, Link} from 'react-router'
import Reflux from 'reflux';
import classNames from 'classnames';
import _ from 'lodash';
import Store from './store';
import Actions from './actions';
import Dashboard from './components';
var DashboardHandler = React.createClass({
mixins: [
Reflux.listenTo(Store, 'onStoreUpdate')
],
componentDidMount() {
Actions.load();
},
getInitialState() {
var storeData = Store.getDefaultData();
return {
balance: storeData.balance,
categories: storeData.categories
};
},
onStoreUpdate(storeData) {
if (storeData.balance !== undefined) {
this.setState({balance: storeData.balance});
}
if (storeData.categories !== undefined) {
this.setState({categories: storeData.categories});
}
},
render() {
return <Dashboard balance={this.state.balance}
categories={this.state.categories} />;
}
});
export default DashboardHandler;
|
src/Accordion.js | johanneshilden/react-bootstrap | import React from 'react';
import PanelGroup from './PanelGroup';
const Accordion = React.createClass({
render() {
return (
<PanelGroup {...this.props} accordion={true}>
{this.props.children}
</PanelGroup>
);
}
});
export default Accordion;
|
frontend/advocate/Container.js | datoszs/czech-lawyers | import React from 'react';
import {Row, Col} from 'react-bootstrap';
import {Msg, RichText, SearchDisclaimer} from '../containers';
import {PageSubheader, Center} from '../components';
import {TimelineScroll} from '../components/timeline';
import {courts} from '../model';
import Header from './Header';
import Title from './Title';
import Detail from './Detail';
import CakLink from './CakLink';
import StatisticsContainer from './Statistics';
import CourtFilter from './CourtFilter';
import TimelineContainer from './Timeline';
import CaseContainer from './CaseContainer';
import CourtStatistics from './CourtStatistics';
import samename from './samename';
import CaseScroller from './CaseScroller';
export default () => (
<section>
<Title />
<Header />
<Row>
<Col sm={6}>
<samename.Container />
<Detail />
<CakLink />
</Col>
<Col sm={6}>
<SearchDisclaimer />
<Center><StatisticsContainer /></Center>
<Row>
<Col sm={4}><CourtStatistics court={courts.NS} /></Col>
<Col sm={4}><CourtStatistics court={courts.NSS} /></Col>
<Col sm={4}><CourtStatistics court={courts.US} /></Col>
</Row>
</Col>
</Row>
<CaseScroller name="case.scroller" />
<PageSubheader><Msg msg="advocate.cases" /></PageSubheader>
<CourtFilter />
<TimelineScroll>
<TimelineContainer />
</TimelineScroll>
<CaseContainer />
<RichText msg="advocate.cases.disclaimer" />
</section>
);
|
app/javascript/mastodon/features/lists/components/new_list_form.js | clworld/mastodon | import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { changeListEditorTitle, submitListEditor } from '../../../actions/lists';
import IconButton from '../../../components/icon_button';
import { defineMessages, injectIntl } from 'react-intl';
const messages = defineMessages({
label: { id: 'lists.new.title_placeholder', defaultMessage: 'New list title' },
title: { id: 'lists.new.create', defaultMessage: 'Add list' },
});
const mapStateToProps = state => ({
value: state.getIn(['listEditor', 'title']),
disabled: state.getIn(['listEditor', 'isSubmitting']),
});
const mapDispatchToProps = dispatch => ({
onChange: value => dispatch(changeListEditorTitle(value)),
onSubmit: () => dispatch(submitListEditor(true)),
});
export default @connect(mapStateToProps, mapDispatchToProps)
@injectIntl
class NewListForm extends React.PureComponent {
static propTypes = {
value: PropTypes.string.isRequired,
disabled: PropTypes.bool,
intl: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
};
handleChange = e => {
this.props.onChange(e.target.value);
}
handleSubmit = e => {
e.preventDefault();
this.props.onSubmit();
}
handleClick = () => {
this.props.onSubmit();
}
render () {
const { value, disabled, intl } = this.props;
const label = intl.formatMessage(messages.label);
const title = intl.formatMessage(messages.title);
return (
<form className='column-inline-form' onSubmit={this.handleSubmit}>
<label>
<span style={{ display: 'none' }}>{label}</span>
<input
className='setting-text'
value={value}
disabled={disabled}
onChange={this.handleChange}
placeholder={label}
/>
</label>
<IconButton
disabled={disabled}
icon='plus'
title={title}
onClick={this.handleClick}
/>
</form>
);
}
}
|
client/components/toolbar/Logo.js | yanigisawa/voting-tornado | import React from 'react';
const Logo = (props) => (
<svg viewBox="0 0 144 131" {...props}>
<g>
<path d="M118.954,87.235 C117.784,80.465 115.755,73.277 112.881,65.938 C115.756,58.592 117.784,51.398 118.952,44.624 C130.693,50.324 137.999,57.982 138,65.909 C138,73.901 130.708,81.552 118.954,87.235 L118.954,87.235 Z M105,123.11 C102.829,124.364 100.281,125 97.428,125 C91.361,125 84.259,122.231 76.981,117.308 C82.313,112.871 87.579,107.457 92.545,101.223 C100.313,100.042 107.527,98.206 113.955,95.844 C114.897,108.916 111.902,119.125 105,123.11 L105,123.11 Z M46.568,124.997 C43.717,124.997 41.171,124.362 39.001,123.108 C32.104,119.127 29.109,108.918 30.052,95.846 C36.472,98.205 43.677,100.037 51.435,101.218 C56.402,107.454 61.671,112.871 67.005,117.309 C59.731,122.23 52.633,124.997 46.568,124.997 L46.568,124.997 Z M6,65.909 C6,57.957 13.296,50.305 25.036,44.612 C26.204,51.397 28.236,58.604 31.117,65.963 C28.25,73.288 26.224,80.464 25.055,87.221 C13.301,81.532 6,73.877 6,65.909 L6,65.909 Z M46.881,37.496 C34.717,58.616 46.806,37.626 34.785,58.498 C32.879,52.829 31.528,47.322 30.729,42.143 C35.601,40.255 41.033,38.677 46.881,37.496 L46.881,37.496 Z M72.005,18.28 C76.117,21.584 80.221,25.531 84.168,30.008 C60.223,29.96 84.478,30.009 59.886,29.959 C63.82,25.502 67.909,21.571 72.005,18.28 L72.005,18.28 Z M109.214,58.468 C97.071,37.445 109.179,58.408 97.101,37.496 C102.949,38.678 108.383,40.259 113.26,42.152 C112.461,47.319 111.113,52.813 109.214,58.468 L109.214,58.468 Z M109.235,73.475 C111.119,79.096 112.457,84.56 113.251,89.702 C108.396,91.576 102.987,93.144 97.16,94.319 C109.053,73.79 96.994,94.605 109.235,73.475 L109.235,73.475 Z M34.764,73.5 C47.04,94.67 34.992,73.892 46.834,94.313 C41.014,93.136 35.61,91.567 30.758,89.691 C31.551,84.56 32.886,79.107 34.764,73.5 L34.764,73.5 Z M84.108,101.947 C80.175,106.402 76.088,110.332 71.993,113.623 C67.883,110.321 63.78,106.375 59.835,101.902 C83.777,101.946 59.54,101.901 84.108,101.947 L84.108,101.947 Z M86.649,95.951 L71.75,95.924 L56.853,95.896 C56.122,95.812 55.399,95.718 54.677,95.622 C54.474,95.357 54.27,95.096 54.068,94.829 L38.235,67.525 C38.011,67.004 37.8,66.484 37.584,65.963 C37.731,65.609 37.871,65.255 38.022,64.9 L53.936,37.268 C54.21,36.903 54.487,36.545 54.764,36.185 C55.365,36.105 55.965,36.024 56.572,35.953 L72.262,35.984 L87.951,36.016 C88.387,36.069 88.816,36.131 89.248,36.188 C89.475,36.483 89.702,36.775 89.927,37.073 L105.949,64.813 C106.109,65.189 106.259,65.564 106.414,65.939 C106.2,66.457 105.989,66.975 105.766,67.494 L89.983,94.737 C89.757,95.038 89.529,95.331 89.301,95.628 C88.424,95.744 87.54,95.853 86.649,95.951 L86.649,95.951 Z M144,65.909 C143.999,54.951 134.647,45.112 119.808,38.364 C121.377,22.123 117.514,9.088 108.001,3.596 C104.843,1.774 101.279,0.905 97.437,0.905 L97.438,6.905 C100.286,6.905 102.831,7.54 105.001,8.793 C111.904,12.778 114.898,22.945 113.965,35.978 C107.519,33.608 100.279,31.77 92.485,30.588 C87.54,24.392 82.299,19.008 76.992,14.593 C84.266,9.672 91.365,6.906 97.435,6.905 L97.437,0.905 L97.434,0.905 C89.71,0.906 80.873,4.42 72.008,10.742 C63.141,4.418 54.301,0.904 46.573,0.904 L46.573,6.904 C52.639,6.904 59.74,9.672 67.017,14.594 C61.711,19.009 56.47,24.391 51.525,30.586 C43.724,31.768 36.477,33.608 30.026,35.981 C29.095,22.949 32.093,12.782 39,8.794 C41.172,7.54 43.72,6.904 46.573,6.904 L46.573,0.904 C42.729,0.904 39.16,1.773 36,3.597 C26.486,9.091 22.619,22.126 24.184,38.366 C9.349,45.114 0,54.953 0,65.909 C0,76.869 9.357,86.709 24.202,93.457 C22.615,109.734 26.472,122.804 36.001,128.304 C39.16,130.128 42.725,130.997 46.568,130.997 C54.292,130.997 63.128,127.484 71.992,121.162 C80.859,127.486 89.7,131 97.428,131 C101.271,131 104.84,130.131 108,128.306 C117.53,122.803 121.391,109.73 119.804,93.451 C134.643,86.702 144,76.866 144,65.909 L144,65.909 Z" />
<path d="M71.5482968,65.9688173 C69.154234,70.0775221 66.7769144,74.1965782 64.47,78.356 C63.271,80.497 62.097,82.654 60.931,84.815 C59.794,86.993 58.615,89.146 57.518,91.348 C58.905,89.316 60.21,87.237 61.558,85.183 C62.876,83.111 64.187,81.035 65.472,78.944 C67.9377029,74.9691498 70.3353266,70.9543598 72.7167607,66.929899 L99.741,65.952 L72.7137677,64.9739927 C70.3372065,60.9888441 67.9401733,57.0159615 65.476,53.083 C64.19,51.014 62.88,48.96 61.562,46.909 C60.212,44.879 58.907,42.821 57.518,40.813 C58.613,42.995 59.792,45.128 60.926,47.286 C62.093,49.426 63.268,51.561 64.466,53.682 C66.7739163,57.7980908 69.150305,61.8738486 71.5470195,65.9374346 L71.5387573,65.952 L71.5482968,65.9688173 Z M56.341,93.07 L40.684,65.952 L56.344,38.834 L87.657,38.831 L103.315,65.952 L87.659,93.073 L56.341,93.07 Z" />
</g>
</svg>
);
export default Logo;
|
imports/ui/components/messenger/newMsgPop.js | jiyuu-llc/jiyuu | import React from 'react';
import { Meteor } from 'meteor/meteor';
const NewMsgPop = () => ({
convoCreate(){
const un2 = $("#receiverSel").val();
const data = $("#message").val();
Meteor.call("convo.create",Meteor.userId(), un2, data);
},
render() {
return (
<div className="modal fade" id="newMsgPop" role="dialog">
<div className="modal-dialog">
<div className="modal-content">
<div className="modal-header">
<button type="button" className="close" data-dismiss="modal">×</button>
<h4 className="modal-title">New Message</h4>
</div>
<div className="modal-body">
<div className="form-group">
<input type="text" className="form-control" id="receiverSel"/>
</div>
<div className="form-group">
<textarea className="form-control" rows="5" id="message"/>
</div>
</div>
<div className="modal-footer">
<button type="button" className="btn btn-primary" onClick={this.convoCreate.bind(this)} data-dismiss="modal">Send</button>
<button type="button" className="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
);
}
});
export default NewMsgPop;
|
src/LightboxRenderer.js | aksonov/react-native-router-flux | /* @flow */
import React from 'react';
import { View } from 'react-native';
export default ({ navigation, descriptors }) => {
const { state } = navigation;
const descriptor = descriptors[state.routes[0].key]; // base component to render
const Component = descriptor.getComponent();
const popupDescriptor = descriptors[state.routes[state.index].key];
const Popup = state.index !== 0 ? popupDescriptor.getComponent() : null;
return (
<View style={{ flex: 1 }}>
<Component navigation={descriptor.navigation} />
{Popup && <Popup navigation={popupDescriptor.navigation} />}
</View>
);
};
|
gatsby-strapi-tutorial/cms/plugins/content-type-builder/admin/src/components/EmptyContentTypeView/index.js | strapi/strapi-examples | /**
*
* EmptyContentTypeView
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import Button from 'components/Button';
import Brush from '../../assets/images/paint_brush.svg';
import styles from './styles.scss';
class EmptyContentTypeView extends React.Component { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<div className={styles.emptyContentTypeView}>
<img src={Brush} alt="" />
<div>
<FormattedMessage id="content-type-builder.home.emptyContentType.title">
{(title) => <div className={styles.title}>{title}</div>}
</FormattedMessage>
<FormattedMessage id="content-type-builder.home.emptyContentType.description">
{(description) => <div className={styles.description}>{description}</div>}
</FormattedMessage>
<div className={styles.buttonContainer}>
<Button
primaryAddShape
label="content-type-builder.button.contentType.create"
onClick={this.props.handleButtonClick}
/>
</div>
</div>
</div>
);
}
}
EmptyContentTypeView.propTypes = {
handleButtonClick: PropTypes.func.isRequired,
};
export default EmptyContentTypeView;
|
docs/app/Layouts/BootstrapMigrationLayout.js | shengnian/shengnian-ui-react | import React from 'react'
import {
Button,
Divider,
Dropdown,
Grid,
Header,
Icon,
Image,
Label,
Menu,
Message,
Segment,
Table,
} from 'shengnian-ui-react'
const BootstrapMigrationLayout = () => (
<Grid container style={{ padding: '5em 0em' }}>
<Grid.Row>
<Grid.Column>
<Header as='h1' dividing>Bootstrap Migration</Header>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Message>
<Header as='h1'>Hello, world!</Header>
<p>
This is a template for a simple marketing or informational website. It includes a large callout called a
jumbotron and three supporting pieces of content. Use it as a starting point to create something more
unique.
</p>
<Button color='blue'>Learn more »</Button>
</Message>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>Buttons</Header>
<Button as='a' tabindex='0'>Default</Button>
<Button as='a' primary tabindex='0'>Primary</Button>
<Button as='a' basic tabindex='0'>Basic</Button>
<Button as='a' positive tabindex='0'>Success</Button>
<Button as='a' negative tabindex='0'>Error</Button>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>Thumbnails</Header>
<Divider />
<Image size='small' src='/assets/images/wireframe/image.png' />
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>Dropdown</Header>
<Divider />
<Dropdown
options={[
{ key: 'Male', value: 'Male', text: 'Male' },
{ key: 'Female', value: 'Female', text: 'Female' },
]}
placeholder='Select'
selection
/>
<Menu vertical>
<Menu.Item active>Friends</Menu.Item>
<Menu.Item>Messages</Menu.Item>
<Dropdown text='More' pointing='left' className='link item'>
<Dropdown.Menu>
<Dropdown.Item>Edit Profile</Dropdown.Item>
<Dropdown.Item>Choose Language</Dropdown.Item>
<Dropdown.Item>Account Settings</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Menu>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>Badges</Header>
<Divider />
<Menu vertical>
<Menu.Item>
One <Label>2</Label>
</Menu.Item>
<Menu.Item>
Two <Label>2</Label>
</Menu.Item>
<Menu.Item>
Three <Label>2</Label>
</Menu.Item>
</Menu>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>Tables</Header>
<Grid columns={2}>
<Grid.Column>
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Premium Plan</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>John</Table.Cell>
<Table.Cell>No</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jamie</Table.Cell>
<Table.Cell>Yes</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jill</Table.Cell>
<Table.Cell>Yes</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
</Grid.Column>
<Grid.Column>
<Table basic>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Premium Plan</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>John</Table.Cell>
<Table.Cell>No</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jamie</Table.Cell>
<Table.Cell>Yes</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jill</Table.Cell>
<Table.Cell>Yes</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
</Grid.Column>
<Grid.Column>
<Table definition>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Premium Plan</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>John</Table.Cell>
<Table.Cell>No</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jamie</Table.Cell>
<Table.Cell>Yes</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jill</Table.Cell>
<Table.Cell>Yes</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
</Grid.Column>
<Grid.Column>
<Table basic='very'>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Premium Plan</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>John</Table.Cell>
<Table.Cell>No</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jamie</Table.Cell>
<Table.Cell>Yes</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jill</Table.Cell>
<Table.Cell>Yes</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
</Grid.Column>
<Grid.Column width={16}>
<Table celled structured>
<Table.Header>
<Table.Row>
<Table.HeaderCell rowSpan='2'>Name</Table.HeaderCell>
<Table.HeaderCell rowSpan='2'>Type</Table.HeaderCell>
<Table.HeaderCell rowSpan='2'>Files</Table.HeaderCell>
<Table.HeaderCell colSpan='3'>Languages</Table.HeaderCell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>Ruby</Table.HeaderCell>
<Table.HeaderCell>JavaScript</Table.HeaderCell>
<Table.HeaderCell>Python</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>Alpha Team</Table.Cell>
<Table.Cell>Project 1</Table.Cell>
<Table.Cell textAlign='right'>2</Table.Cell>
<Table.Cell textAlign='center'>
<Icon color='green' name='checkmark' size='large' />
</Table.Cell>
<Table.Cell />
<Table.Cell />
</Table.Row>
<Table.Row>
<Table.Cell rowSpan='3'>Beta Team</Table.Cell>
<Table.Cell>Project 1</Table.Cell>
<Table.Cell textAlign='right'>52</Table.Cell>
<Table.Cell textAlign='center'>
<Icon color='green' name='checkmark' size='large' />
</Table.Cell>
<Table.Cell />
<Table.Cell />
</Table.Row>
<Table.Row>
<Table.Cell>Project 2</Table.Cell>
<Table.Cell textAlign='right'>12</Table.Cell>
<Table.Cell />
<Table.Cell textAlign='center'>
<Icon color='green' name='checkmark' size='large' />
</Table.Cell>
<Table.Cell />
</Table.Row>
<Table.Row>
<Table.Cell>Project 3</Table.Cell>
<Table.Cell textAlign='right'>21</Table.Cell>
<Table.Cell textAlign='center'>
<Icon color='green' name='checkmark' size='large' />
</Table.Cell>
<Table.Cell />
<Table.Cell />
</Table.Row>
</Table.Body>
</Table>
</Grid.Column>
</Grid>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>Alerts</Header>
<Divider />
<Message positive>Well done! You successfully read this important alert message.</Message>
<Message info>Heads up! This alert needs your attention, but it's not super important.</Message>
<Message warning>Warning! Best check yo self, you're not looking too good.</Message>
<Message error>Oh snap! Change a few things up and try submitting again.</Message>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>List groups</Header>
<Divider />
<Grid columns={3}>
<Grid.Column>
<Segment.Group>
<Segment>
<p>Cras justo odio</p>
</Segment>
<Segment>
<p>Dapibus ac facilisis in</p>
</Segment>
<Segment>
<p>Morbi leo risus</p>
</Segment>
<Segment>
<p>Porta ac consectetur ac</p>
</Segment>
<Segment>
<p>Vestibulum at eros</p>
</Segment>
</Segment.Group>
</Grid.Column>
<Grid.Column>
<Menu vertical fluid>
<Menu.Item>
<p>Cras justo odio</p>
</Menu.Item>
<Menu.Item>
<p>Vestibulum at eros</p>
</Menu.Item>
</Menu>
</Grid.Column>
<Grid.Column>
<Menu vertical fluid>
<Menu.Item>
<Header size='medium' as='h1'>List group item heading</Header>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
</Menu.Item>
<Menu.Item>
<Header size='medium' as='h1'>List group item heading</Header>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
</Menu.Item>
<Menu.Item>
<Header size='medium' as='h1'>List group item heading</Header>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
</Menu.Item>
</Menu>
</Grid.Column>
</Grid>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>Panels</Header>
<Divider />
<Grid columns={3}>
<Grid.Column>
<Segment.Group>
<Segment color='red'>One</Segment>
<Segment color='blue'>Two</Segment>
<Segment color='green'>Three</Segment>
</Segment.Group>
</Grid.Column>
<Grid.Column>
<Segment.Group raised>
<Segment>One</Segment>
<Segment>Two</Segment>
<Segment>Three</Segment>
</Segment.Group>
</Grid.Column>
<Grid.Column>
<Segment.Group stacked>
<Segment>One</Segment>
<Segment>Two</Segment>
<Segment>Three</Segment>
</Segment.Group>
</Grid.Column>
<Grid.Column>
<Message attached='top' error>Error</Message>
<Segment attached='bottom'>Panel content</Segment>
</Grid.Column>
<Grid.Column>
<Message attached='top' info>Info</Message>
<Segment attached='bottom'>Panel content</Segment>
</Grid.Column>
<Grid.Column>
<Message attached='top' success>Success</Message>
<Segment attached='bottom'>Panel content</Segment>
</Grid.Column>
<Grid.Column>
<Header attached='top' as='h4' inverted>Header</Header>
<Segment attached='bottom'>Panel content</Segment>
</Grid.Column>
<Grid.Column>
<Header attached='top' as='h4' block>Header</Header>
<Segment attached='bottom'>Panel content</Segment>
</Grid.Column>
<Grid.Column>
<Header attached='top' as='h4'>Header</Header>
<Segment attached='bottom'>Panel content</Segment>
</Grid.Column>
</Grid>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Header as='h1'>Wells</Header>
<Divider />
<Segment>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit
amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel
scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non
commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla
sed consectetur.
</p>
</Segment>
<Segment secondary>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit
amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel
scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non
commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla
sed consectetur.
</p>
</Segment>
<Segment tertiary>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit
amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel
scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non
commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla
sed consectetur.
</p>
</Segment>
<Segment inverted>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit
amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel
scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non
commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla
sed consectetur.
</p>
</Segment>
<Segment inverted secondary>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit
amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel
scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non
commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla
sed consectetur.
</p>
</Segment>
<Segment inverted tertiary>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit
amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel
scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non
commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla
sed consectetur.
</p>
</Segment>
</Grid.Column>
</Grid.Row>
</Grid>
)
export default BootstrapMigrationLayout
|
server/sonar-web/src/main/js/main/nav/component/component-nav-favorite.js | joansmith/sonarqube | /*
* SonarQube
* Copyright (C) 2009-2016 SonarSource SA
* mailto:contact 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.
*/
import React from 'react';
import Favorite from '../../../components/shared/favorite';
export default React.createClass({
render() {
if (!this.props.canBeFavorite) {
return null;
}
return (
<div className="navbar-context-favorite">
<Favorite component={this.props.component} favorite={this.props.favorite}/>
</div>
);
}
});
|
src/components/HowToApp.react.js | andrewMuntyan/simple-how-to | import './__styles/common/common.scss';
import React from 'react';
import UserStore from './../stores/UserStore';
import UserActions from '../actions/UserActions';
import { Router, Route, Link, History } from 'react-router';
import FlatButton from 'material-ui/lib/flat-button';
import Avatar from 'material-ui/lib/avatar';
import AppBar from 'material-ui/lib/app-bar';
import muiFix from './../utils/mui-fix-mixin';
var HowToApp = React.createClass({
mixins: [ History, muiFix ],
getInitialState() {
return {
user: UserStore.getCurrentUser()
}
},
componentDidMount() {
UserStore.addChangeListener(this._onChange);
},
componentWillUnmount() {
UserStore.removeChangeListener(this._onChange);
},
/**
* @return {object}
*/
render() {
return (
<div className="g-container">
<header id="header" className="g-header">
<AppBar
iconElementLeft={
<Link to='/' className="logo h-left">
<img src={require("./../../static/img/logo.png")} alt="Logo"/>
</Link>
}
iconElementRight={
<div className="h-right">
<div className="usr-blck">
{this.state.user ? this.renderLogged() : this.renderUnlogged()}
</div>
</div>
}
style={{
minHeight: '65px'
}}
/>
</header>
{this.props.children}
</div>
)
},
renderLogged() {
let user = this.state.user;
let firstLetter = user[0];
return(
<div>
<div className="l-side">
<Avatar size={35}>{firstLetter}</Avatar>
<h2 className="user-name">{this.state.user}</h2>
</div>
<div className="r-side">
<FlatButton style={{float: 'right'}} onClick={this.logout} label="Log out" />
</div>
</div>
);
},
renderUnlogged() {
if (this.props.location.pathname !== '/login') {
return(
<div>
<div className="r-side">
<FlatButton onClick={this.login} label="Log in" />
</div>
</div>
)
}
return null;
},
logout() {
UserActions.logout(() => {
this.history.replaceState(null, '/');
})
},
login() {
this.history.pushState(null, '/login');
},
_onChange() {
this.setState({user: UserStore.getCurrentUser()})
}
});
export default HowToApp;
|
examples/async/containers/Root.js | rmadsen/redux | import React, { Component } from 'react';
import { Provider } from 'react-redux';
import configureStore from '../store/configureStore';
import AsyncApp from './AsyncApp';
const store = configureStore();
export default class Root extends Component {
render() {
return (
<Provider store={store}>
{() => <AsyncApp />}
</Provider>
);
}
}
|
src/components/sidebar/Sidebar.js | RaymondBuckman/Turkey | import React, { Component } from 'react';
import ReactTooltip from 'react-tooltip';
import crescentstar from '../../img/crescent-star.png';
export default class Sidebar extends Component {
render() {
return(
<div>
<ul id="sidebar">
<li>
<a href="#top-of-page" role="link">
<img src="https://png.icons8.com/moon-star-filled/ios7/75/FFFFFF" height="25px" alt="go to the top of the page" data-tip data-for="crescent-star-tooltip"></img>
</a>
</li>
<li>
<a href="#cografya" role="link">
<img src="https://png.icons8.com/mountain-filled/ios7/75/FFFFFF" width="25" height="25" alt="go to geography" data-tip data-for="geography-tooltip"></img>
</a>
</li>
<li>
<a href="#sehirler" role="link">
<img src="https://png.icons8.com/city-filled/ios7/75/FFFFFF" width="25" height="25" alt="go to cities" alt="go to the top of the page" data-tip data-for="cities-tooltip"></img>
</a>
</li>
<li>
<a href="#sights-1-div" role="link">
<img src="https://png.icons8.com/tourist-guide-filled/ios7/75/FFFFFF" width="25" height="25" alt="go to sights" data-tip data-for="sights-tooltip"></img>
</a>
</li>
<li>
<a href="#oteleler" role="link">
<img src="https://png.icons8.com/bed-filled/ios7/75/FFFFFF" width="25" height="25" alt="go to hotels" data-tip data-for="hotels-tooltip"></img>
</a>
</li>
<li>
<a href="#mutfak" role="link">
<img src="https://png.icons8.com/food-and-wine-filled/ios7/75/FFFFFF" width="25" height="25" alt="go to cuisine" data-tip data-for="cuisine-tooltip"></img>
</a>
</li>
<li>
<a href="#language-1-div" role="link">
<img src="https://png.icons8.com/communication-filled/ios7/75/FFFFFF" width="25" height="25" alt="go to language" data-tip data-for="language-tooltip"></img>
</a>
</li>
</ul>
<ReactTooltip id="crescent-star-tooltip" place="right" type="light" effect="solid" delayShow={100} offset={{left: 15}}>
<span className="tooltip-span">Go to top</span>
</ReactTooltip>
<ReactTooltip id="geography-tooltip" place="left" type="light" effect="solid" delayShow={100} offset={{left: 15}}>
<span className="tooltip-span">Go to geography</span>
</ReactTooltip>
<ReactTooltip id="cities-tooltip" place="left" type="light" effect="solid" delayShow={100} offset={{left: 15}}>
<span className="tooltip-span">Go to cities</span>
</ReactTooltip>
<ReactTooltip id="sights-tooltip" place="left" type="light" effect="solid" delayShow={100} offset={{left: 15}}>
<span className="tooltip-span">Go to sights</span>
</ReactTooltip>
<ReactTooltip id="hotels-tooltip" place="left" type="light" effect="solid" delayShow={100} offset={{left: 15}}>
<span className="tooltip-span">Go to hotels</span>
</ReactTooltip>
<ReactTooltip id="cuisine-tooltip" place="left" type="light" effect="solid" delayShow={100} offset={{left: 15}}>
<span className="tooltip-span">Go to cuisine</span>
</ReactTooltip>
<ReactTooltip id="language-tooltip" place="left" type="light" effect="solid" delayShow={100} offset={{left: 15}}>
<span className="tooltip-span">Go to language</span>
</ReactTooltip>
</div>
);
}
}
|
docs/app/Examples/modules/Embed/Usage/EmbedExampleSettings.js | koenvg/Semantic-UI-React | import React from 'react'
import { Embed } from 'semantic-ui-react'
const EmbedExampleSettings = () => (
<Embed
autoplay={false}
brandedUI={false}
color='white'
hd={false}
id='D0WnZyxp_Wo'
placeholder='http://semantic-ui.com/images/image-16by9.png'
source='youtube'
/>
)
export default EmbedExampleSettings
|
src/svg-icons/image/adjust.js | ruifortes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageAdjust = (props) => (
<SvgIcon {...props}>
<path d="M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10 10-4.49 10-10S17.51 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3-8c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3z"/>
</SvgIcon>
);
ImageAdjust = pure(ImageAdjust);
ImageAdjust.displayName = 'ImageAdjust';
ImageAdjust.muiName = 'SvgIcon';
export default ImageAdjust;
|
src/components/settings.js | LaserWeb/LaserWeb4 | import React from 'react';
import ReactDOM from 'react-dom'
import { connect } from 'react-redux';
import stringify from 'json-stringify-pretty-compact';
import { FileStorage, LocalStorage } from '../lib/storages';
import update from 'immutability-helper';
import omit from 'object.omit';
import Validator from 'validatorjs';
import { setSettingsAttrs, uploadSettings, downloadSettings, uploadMachineProfiles, downloadMachineProfiles, uploadSnapshot, downloadSnapshot, storeSnapshot, recoverSnapshot } from '../actions/settings';
import { SETTINGS_VALIDATION_RULES, ValidateSettings } from '../reducers/settings';
import MachineProfile from './machine-profiles';
import { MaterialDatabaseButton } from './material-database';
import { Macros } from './macros'
import { NumberField, TextField, ToggleField, QuadrantField, FileField, CheckBoxListField, SelectField, InputRangeField, Info } from './forms';
import { PanelGroup, Panel, Tooltip, OverlayTrigger, FormControl, InputGroup, ControlLabel, FormGroup, ButtonGroup, Label, Collapse, Badge, ButtonToolbar, Button } from 'react-bootstrap';
import Icon from './font-awesome';
import { VideoDeviceField, VideoPort, VideoResolutionField, ArucoMarker } from './webcam';
import { alert, prompt, confirm } from './laserweb';
import { getSubset } from 'redux-localstorage-filter';
import { Details } from './material-database'
export class ApplicationSnapshot extends React.Component {
constructor(props) {
super(props);
this.state = { keys: [] }
this.handleChange.bind(this)
}
getExportData(keys) {
return getSubset(this.props.state, keys)
}
handleChange(data) {
this.setState({ keys: data })
}
render() {
let data = Object.keys(omit(this.props.state, "history"));
return (
<div className="well well-sm " id="ApplicationSnapshot">
<CheckBoxListField onChange={(data) => this.handleChange(data)} data={data} />
<section>
<table style={{ width: 100 + '%' }}><tbody><tr><td><strong>On File</strong></td>
<td><ApplicationSnapshotToolbar loadButton saveButton stateKeys={this.state.keys} saveName="laserweb-snapshot.json" /></td></tr></tbody></table>
</section>
<section>
<table style={{ width: 100 + '%' }}><tbody><tr><td><strong>On LocalStorage</strong></td>
<td><ApplicationSnapshotToolbar recoverButton storeButton stateKeys={this.state.keys} /></td></tr></tbody></table>
</section>
</div>
)
}
}
export class ApplicationSnapshotToolbar extends React.Component {
constructor(props) {
super(props);
this.handleDownload.bind(this)
this.handleUpload.bind(this)
this.handleStore.bind(this)
this.handleRecover.bind(this)
}
getExportData(keys) {
return getSubset(this.props.state, keys)
}
handleDownload(statekeys, saveName, e) {
prompt('Save as', saveName || "laserweb-snapshot.json", (file) => {
if (file !== null) {
statekeys = Array.isArray(statekeys) ? statekeys : (this.props.stateKeys || []);
this.props.handleDownload(file, this.getExportData(statekeys), downloadSnapshot)
}
}, !e.shiftKey)
}
handleUpload(file, statekeys) {
statekeys = Array.isArray(statekeys) ? statekeys : (this.props.stateKeys || []);
this.props.handleUpload(file, uploadSnapshot, statekeys)
}
handleStore(statekeys) {
statekeys = Array.isArray(statekeys) ? statekeys : (this.props.stateKeys || []);
this.props.handleStore("laserweb-snapshot", this.getExportData(statekeys), storeSnapshot)
}
handleRecover(statekeys) {
statekeys = Array.isArray(statekeys) ? statekeys : (this.props.stateKeys || []);
this.props.handleRecover("laserweb-snapshot", uploadSnapshot)
}
render() {
let buttons = [];
if (this.props.loadButton) {
buttons.push(<FileField onChange={(e) => this.handleUpload(e.target.files[0], this.props.loadButton)} accept="application/json, .json"><Button bsStyle="danger" bsSize="xs">Load <Icon name="upload" /></Button></FileField>);
}
if (this.props.saveButton) {
buttons.push(<Button onClick={(e) => this.handleDownload(this.props.saveButton, this.props.saveName, e)} className="btn btn-success btn-xs">Save <Icon name="download" /></Button>);
}
if (this.props.recoverButton) {
buttons.push(<Button onClick={(e) => this.handleRecover(this.props.recoverButton)} bsClass="btn btn-danger btn-xs">Load <Icon name="upload" /></Button>);
}
if (this.props.storeButton) {
buttons.push(<Button onClick={(e) => this.handleStore(this.props.storeButton)} bsClass="btn btn-success btn-xs">Save <Icon name="download" /></Button>);
}
return <div>
<div style={{ float: "right", clear: "right" }}>{buttons.map((button, i) => React.cloneElement(button, { key: i }))}{this.props.children}</div>
</div>
}
}
class SettingsPanel extends React.Component {
render() {
let filterProps = omit(this.props, ['header', 'errors', 'defaultExpanded']);
let childrenFields = this.props.children.map((item) => { if (item) return item.props.field })
let hasErrors = Object.keys(this.props.errors || []).filter((error) => { return childrenFields.includes(error) }).length;
filterProps['defaultExpanded'] = (this.props.defaultExpanded || hasErrors) ? true : false
let children = this.props.children.map((child, i) => {
if (!child) return
let props = { key: i }
if (child.props.field) props['errors'] = this.props.errors;
return React.cloneElement(child, props);
})
let icon = hasErrors ? <Label bsStyle="warning">Please check!</Label> : undefined;
return <Panel {...filterProps} header={<span>{icon}{this.props.header}</span>} >{children}</Panel>
}
}
export function SettingsValidator({ style, className = 'badge', noneOnSuccess = false, ...rest }) {
let validator = ValidateSettings(false);
let errors = (validator.fails()) ? ("Please review Settings:\n\n" + Object.values(validator.errors.errors)) : undefined
if (noneOnSuccess && !errors) return null;
return <span className={className} title={errors ? errors : "Good to go!"} style={style}><Icon name={errors ? 'warning' : 'check'} /></span>
}
class MachineFeedRanges extends React.Component {
handleChangeValue(ax, v) {
let state = this.props.object[this.props.field];
state = Object.assign(state, { [ax]: Object.assign({ min: Number(this.props.minValue || 0), max: Number(this.props.maxValue || 1e100) }, v || {}) });
this.props.dispatch(this.props.setAttrs({ [this.props.field]: state }, this.props.object.id))
}
render() {
let axis = this.props.axis || ['X', 'Y'];
let value = this.props.object[this.props.field];
return <div className="form-group"><Details handler={<label>Machine feed ranges</label>}>
<div className="well">{this.props.description ? <small className="help-block">{this.props.description}</small> : undefined}
<table width="100%" >
<tbody>
{axis.map((ax, i) => { return <tr key={i}><th width="15%">{ax}</th><td><InputRangeField normalize key={ax} minValue={this.props.minValue || 0} maxValue={this.props.maxValue || 1e100} value={value[ax]} onChangeValue={value => this.handleChangeValue(ax, value)} /></td></tr> })}
</tbody>
</table>
</div>
</Details>
</div>
}
}
MachineFeedRanges = connect()(MachineFeedRanges)
class Settings extends React.Component {
constructor(props) {
super(props);
this.state = { errors: null }
}
validate(data, rules) {
let check = new Validator(data, rules);
if (check.fails()) {
console.error("Settings Error:" + JSON.stringify(check.errors.errors));
return check.errors.errors;
}
return null;
}
rules() {
return SETTINGS_VALIDATION_RULES;
}
componentWillMount() {
this.setState({ errors: this.validate(this.props.settings, this.rules()) })
}
componentWillReceiveProps(nextProps) {
this.setState({ errors: this.validate(nextProps.settings, this.rules()) })
}
render() {
let isVideoDeviceSelected = Boolean(this.props.settings['toolVideoDevice'] && this.props.settings['toolVideoDevice'].length);
return (
<div className="form">
<PanelGroup>
<Panel header="Machine Profiles" bsStyle="primary" collapsible defaultExpanded={true} eventKey="0">
<MachineProfile onApply={this.props.handleApplyProfile} />
<MaterialDatabaseButton>Launch Material Database</MaterialDatabaseButton>
</Panel>
<SettingsPanel collapsible header="Machine" eventKey="1" bsStyle="info" errors={this.state.errors} >
<h5 className="header">Dimensions</h5>
<NumberField {...{ object: this.props.settings, field: 'machineWidth', setAttrs: setSettingsAttrs, description: 'Machine Width', units: 'mm' }} />
<NumberField {...{ object: this.props.settings, field: 'machineHeight', setAttrs: setSettingsAttrs, description: 'Machine Height', units: 'mm' }} />
<h5 className="header">Origin offsets</h5>
<ToggleField {...{ object: this.props.settings, field: 'showMachine', setAttrs: setSettingsAttrs, description: 'Show Machine' }} />
<NumberField {...{ object: this.props.settings, field: 'machineBottomLeftX', setAttrs: setSettingsAttrs, description: 'Machine Left X', units: 'mm' }} />
<NumberField {...{ object: this.props.settings, field: 'machineBottomLeftY', setAttrs: setSettingsAttrs, description: 'Machine Bottom Y', units: 'mm' }} />
<h5 className="header">Tool head</h5>
<NumberField {...{ object: this.props.settings, field: 'machineBeamDiameter', setAttrs: setSettingsAttrs, description: (<span>Beam <abbr title="Diameter">Ø</abbr></span>), units: 'mm' }} />
<h5 className="header">Probe tool</h5>
<NumberField {...{ object: this.props.settings, field: 'machineXYProbeOffset', setAttrs: setSettingsAttrs, description: 'X/Y Probe Offset', units: 'mm' }} />
<NumberField {...{ object: this.props.settings, field: 'machineZProbeOffset', setAttrs: setSettingsAttrs, description: 'Z Probe Offset', units: 'mm' }} />
<hr />
<MachineFeedRanges minValue={1} maxValue={Infinity} axis={['XY', 'Z', 'A', 'S']} object={this.props.settings} field={'machineFeedRange'} setAttrs={setSettingsAttrs} description="Stablishes the feed range warning threshold for an axis." />
<hr />
<ToggleField {... { object: this.props.settings, field: 'machineZEnabled', setAttrs: setSettingsAttrs, description: 'Machine Z stage' }} />
<Collapse in={this.props.settings.machineZEnabled}>
<div>
<NumberField {...{ errors: this.state.errors, object: this.props.settings, field: 'machineZToolOffset', setAttrs: setSettingsAttrs, description: 'Tool Offset', labelAddon: false, units: 'mm' }} />
<TextField {...{ errors: this.state.errors, object: this.props.settings, field: 'machineZStartHeight', setAttrs: setSettingsAttrs, description: 'Default Start Height', labelAddon: false, units: 'mm' }} />
</div>
</Collapse>
<hr />
<ToggleField {... { object: this.props.settings, field: 'machineAEnabled', setAttrs: setSettingsAttrs, description: 'Machine A stage' }} />
<hr />
<ToggleField {...{ errors: this.state.errors, object: this.props.settings, field: 'machineBlowerEnabled', setAttrs: setSettingsAttrs, description: 'Air Assist' }} />
<Collapse in={this.props.settings.machineBlowerEnabled}>
<div>
<TextField {...{ object: this.props.settings, field: 'machineBlowerGcodeOn', setAttrs: setSettingsAttrs, description: 'Gcode AA ON', rows: 5, style: { resize: "vertical" } }} />
<TextField {...{ object: this.props.settings, field: 'machineBlowerGcodeOff', setAttrs: setSettingsAttrs, description: 'Gcode AA OFF', rows: 5, style: { resize: "vertical" } }} />
</div>
</Collapse>
</SettingsPanel>
<SettingsPanel collapsible header="File Settings" eventKey="2" bsStyle="info" errors={this.state.errors}>
<h5 className="header">SVG</h5>
<NumberField {...{ object: this.props.settings, field: 'pxPerInch', setAttrs: setSettingsAttrs, description: 'PX Per Inch', units: 'pxpi' }} />
<ToggleField {...{ object: this.props.settings, field: 'forcePxPerInch', setAttrs: setSettingsAttrs, description: 'Force PX Per Inch' }} />
<h5 className="header">BITMAPS (bmp, png, jpg)</h5>
<NumberField {...{ object: this.props.settings, field: 'dpiBitmap', setAttrs: setSettingsAttrs, description: 'Bitmap DPI', units: 'dpi' }} />
</SettingsPanel>
<SettingsPanel collapsible header="Gcode" eventKey="3" bsStyle="info" errors={this.state.errors}>
<SelectField {...{ object: this.props.settings, field: 'gcodeGenerator', setAttrs: setSettingsAttrs, data: ['default', 'marlin'], defaultValue: 'default', description: 'GCode Generator', selectProps: { clearable: false } }} />
<TextField {...{ object: this.props.settings, field: 'gcodeStart', setAttrs: setSettingsAttrs, description: 'Gcode Start', rows: 5, style: { resize: "vertical" } }} />
<TextField {...{ object: this.props.settings, field: 'gcodeEnd', setAttrs: setSettingsAttrs, description: 'Gcode End', rows: 5, style: { resize: "vertical" } }} />
<TextField {...{ object: this.props.settings, field: 'gcodeHoming', setAttrs: setSettingsAttrs, description: 'Gcode Homing', rows: 5, style: { resize: "vertical" } }} />
<TextField {...{ object: this.props.settings, field: 'gcodeToolOn', setAttrs: setSettingsAttrs, description: 'Tool ON', rows: 5, style: { resize: "vertical" } }} />
<TextField {...{ object: this.props.settings, field: 'gcodeToolOff', setAttrs: setSettingsAttrs, description: 'Tool OFF', rows: 5, style: { resize: "vertical" } }} />
<TextField {...{ object: this.props.settings, field: 'gcodeLaserIntensity', setAttrs: setSettingsAttrs, description: 'Laser Intensity', style: { resize: "vertical" } }} />
<ToggleField {... { object: this.props.settings, field: 'gcodeLaserIntensitySeparateLine', setAttrs: setSettingsAttrs, description: 'Intensity Separate Line' }} />
<NumberField {...{ object: this.props.settings, field: 'gcodeSMinValue', setAttrs: setSettingsAttrs, description: 'PWM Min S value' }} />
<NumberField {...{ object: this.props.settings, field: 'gcodeSMaxValue', setAttrs: setSettingsAttrs, description: 'PWM Max S value' }} />
<NumberField {...{ object: this.props.settings, field: 'gcodeCheckSizePower', setAttrs: setSettingsAttrs, description: 'Check-Size Power', units: '%' }} />
<NumberField {...{ object: this.props.settings, field: 'gcodeToolTestPower', setAttrs: setSettingsAttrs, description: 'Tool Test Power', units: '%' }} />
<NumberField {...{ object: this.props.settings, field: 'gcodeToolTestDuration', setAttrs: setSettingsAttrs, description: 'Tool Test duration', units: 'ms' }} />
<h5 className="header">Gcode generation</h5>
<NumberField {...{ object: this.props.settings, field: 'gcodeConcurrency', setAttrs: setSettingsAttrs, description: 'Gcode Generation threads', units: '', info: Info(<p className="help-block">Higher number of threads demands powerful host computer, but increases performance on large files with lots of operations.</p>,"Gcode threads") }} />
<NumberField {...{ object: this.props.settings, field: 'gcodeCurvePrecision', setAttrs: setSettingsAttrs, description: 'Gcode Curve Linearization factor', units: '', info: Info(<p className="help-block">
Enter from 0.1 (Ultra High Precision - Slow) to 2.0 (Low Precision - Fast) to achieve different levels of curve to gcode performance
</p>,"Gcode Linearization Factor")} } />
</SettingsPanel>
<SettingsPanel collapsible header="Application" eventKey="4" bsStyle="info" errors={this.state.errors}>
<h5 className="header">Grid</h5>
<p className="help-block">Grid spacing requires app reload. Use with caution, will affect display performance</p>
<NumberField {...{ object: this.props.settings, field: 'toolGridWidth', setAttrs: setSettingsAttrs, description: 'Grid Width', units: 'mm' }} />
<NumberField {...{ object: this.props.settings, field: 'toolGridHeight', setAttrs: setSettingsAttrs, description: 'Grid Height', units: 'mm' }} />
<NumberField {...{ object: this.props.settings, field: 'toolGridMinorSpacing', setAttrs: setSettingsAttrs, description: 'Grid Minor Spacing', units: 'mm' }} />
<NumberField {...{ object: this.props.settings, field: 'toolGridMajorSpacing', setAttrs: setSettingsAttrs, description: 'Grid Major Spacing', units: 'mm' }} />
<hr/>
<SelectField {...{ object: this.props.settings, field: 'toolFeedUnits', setAttrs: setSettingsAttrs, data: ['mm/s', 'mm/min'], defaultValue: 'mm/min', description: 'Feed Units', selectProps: { clearable: false } }} />
<hr/>
<ToggleField {... { object: this.props.settings, field: 'toolUseNumpad', setAttrs: setSettingsAttrs, description: 'Use Numpad', info: Info(<p className="help-block">
X <Label>4</Label> <Label>6</Label><br/>
Y <Label>2</Label> <Label>8</Label><br/>
Z <Label>+</Label> <Label>-</Label><br/>
A <Label>*</Label> <Label>/</Label>
</p>,"Jog using Numpad")}} />
<ToggleField {... { object: this.props.settings, field: 'toolUseGamepad', setAttrs: setSettingsAttrs, description: 'Use Gamepad',info: Info(<p className="help-block">Gamepad for jogging. Use analog left stick (XY) or right stick (Z) to move on Jog tab.</p>) }} />
<ToggleField {... { object: this.props.settings, field: 'toolCreateEmptyOps', setAttrs: setSettingsAttrs, description: 'Create Empty Operations' }} />
<QuadrantField {... { object: this.props.settings, field: 'toolImagePosition', setAttrs: setSettingsAttrs, description: 'Raster Image Position' }} />
<hr/>
<p className="help-block">Enable Display cache. Disable animations.</p>
<ToggleField {... { object: this.props.settings, field: 'toolDisplayCache', setAttrs: setSettingsAttrs, description: 'Display Cache' }} />
</SettingsPanel>
<Panel collapsible header="Camera" bsStyle="info" eventKey="6">
<div id="novideodevices" style={{ display: "none" }}>
<h5 className="header">Video Device List Unavailable</h5>
<small className="help-block">This may be due to running over an insecure connection, blocking in browser preferences, or other privacy protections.</small>
</div>
<div id="localvideodevices">
<table width="100%"><tbody><tr>
<td width="45%"><VideoDeviceField {...{ object: this.props.settings, field: 'toolVideoDevice', setAttrs: setSettingsAttrs, description: 'Video Device', disabled: !!this.props.settings['toolWebcamUrl']}} /></td>
<td width="45%"><VideoResolutionField {...{ object: this.props.settings, field: 'toolVideoResolution', setAttrs: setSettingsAttrs, deviceId: this.props.settings['toolVideoDevice'] }} /></td>
</tr></tbody></table>
<ToggleField {... { object: this.props.settings, field: 'toolVideoOMR', setAttrs: setSettingsAttrs, description: 'Activate OMR', info: Info(<p className="help-block">
Enabling this, ARUCO markers will be recognized by floating camera port, allowing stock alignment. <Label bsStyle="warning">Experimental!</Label>
</p>,"Optical Mark Recognition"), disabled:!this.props.settings['toolVideoDevice'] }} />
<Collapse in={this.props.settings.toolVideoOMR}>
<div>
<NumberField {...{ object: this.props.settings, field: 'toolVideoOMROffsetX', setAttrs: setSettingsAttrs, description: 'Camera offset X', units:'mm' }} />
<NumberField {...{ object: this.props.settings, field: 'toolVideoOMROffsetY', setAttrs: setSettingsAttrs, description: 'Camera offset Y', units:'mm' }} />
<NumberField {...{ object: this.props.settings, field: 'toolVideoOMRMarkerSize', setAttrs: setSettingsAttrs, description: 'Marker size', units:'mm' }} />
<ArucoMarker />
</div>
</Collapse>
</div>
<hr/>
<VideoPort height={240} enabled={(this.props.settings['toolVideoDevice'] !== null) || (this.props.settings['toolWebcamUrl'])} />
<TextField {... { object: this.props.settings, field: 'toolWebcamUrl', setAttrs: setSettingsAttrs, description: 'Webcam Url' }} disabled={this.props.settings['toolVideoDevice'] !== null} />
</Panel>
<Panel collapsible header="Macros" bsStyle="info" eventKey="7">
<Macros />
</Panel>
<Panel collapsible header="Tools" bsStyle="danger" eventKey="8" >
<table style={{ width: 100 + '%' }}><tbody>
<tr><td><strong>Settings</strong></td>
<td><ApplicationSnapshotToolbar loadButton saveButton stateKeys={['settings']} label="Settings" saveName="laserweb-settings.json" /><hr /></td></tr>
<tr><td><strong>Machine Profiles</strong></td>
<td><ApplicationSnapshotToolbar loadButton saveButton stateKeys={['machineProfiles']} label="Machine Profiles" saveName="laserweb-profiles.json" /><hr /></td></tr>
<tr><td><strong>Macros</strong></td>
<td><Button bsSize="xsmall" onClick={e => this.props.handleResetMacros()} bsStyle="warning">Reset</Button></td></tr>
</tbody></table>
<h5 >Application Snapshot <Label bsStyle="warning">Caution!</Label></h5>
<small className="help-block">This dialog allows to save an entire snapshot of the current state of application.</small>
<ApplicationSnapshot />
</Panel>
</PanelGroup>
</div>
);
}
}
const mapStateToProps = (state) => {
return {
settings: state.settings,
profiles: state.machineProfiles
}
};
const mapDispatchToProps = (dispatch) => {
return {
handleResetMacros: () => {
confirm("Are you sure?", (data) => { if (data !== null) dispatch({ type: "MACROS_RESET" }) })
},
handleSettingChange: (attrs) => {
dispatch(setSettingsAttrs(attrs, 'settings'))
},
handleDownload: (file, settings, action) => {
try{
FileStorage.save(file, stringify(settings), "application/json",".json")
dispatch(action(settings));
} catch(e) {
FileStorage.save(file, JSON.stringify(settings), "application/json",".json")
dispatch(action(settings));
}
},
handleUpload: (file, action, onlyKeys) => {
FileStorage.load(file, (file, result) => {
dispatch(action(file, result, onlyKeys));
})
},
handleStore: (name, settings, action) => {
try {
LocalStorage.save(name, JSON.stringify(settings), "application/json")
} catch (e) {
console.error(e);
alert(e)
}
dispatch(action(settings));
},
handleRecover: (name, action) => {
LocalStorage.load(name, (file, result) => dispatch(action(file, result)));
},
handleApplyProfile: (settings) => {
dispatch(setSettingsAttrs(settings));
}
};
};
export { Settings }
ApplicationSnapshot = connect((state) => {
return { state: state }
}, mapDispatchToProps)(ApplicationSnapshot);
ApplicationSnapshotToolbar = connect((state) => {
return { state: state }
}, mapDispatchToProps)(ApplicationSnapshotToolbar);
export default connect(mapStateToProps, mapDispatchToProps)(Settings);
|
docs/app/animations/index.js | Sandreu/react-mf-modal | import React from 'react';
import ModalService from 'react-mf-modal';
import AnimatedContainer from './animated-container';
import AnimatedDialog from './animated-dialog';
import AnimatedSidebar from '!babel!../webpack/demo-loader!./animated-sidebar';
import AnimatedBackdrop from './animated-backdrop';
import animations from '../statics/animations.md';
import containerCode from '!../webpack/code-loader!./animated-container';
import backdropCode from '!../webpack/code-loader!./animated-backdrop';
import dialogCode from '!../webpack/code-loader!./animated-dialog';
import sidebarCode from '!../webpack/code-loader!./animated-sidebar';
const rapidExample = {
textAlign: 'center',
padding:'40px 0 10px 0',
};
export default class Animations extends React.Component {
handleSimple = () => {
ModalService.open(<AnimatedDialog />)
.then(result => console.log(result))
.catch(cause => console.warn(cause));
}
handleSidebar = () => {
ModalService.open(<AnimatedSidebar />)
.then(result => console.log(result))
.catch(cause => console.warn(cause));
}
render() {
return <AnimatedContainer BackdropComponent={AnimatedBackdrop}>
<div style={rapidExample}>
<button className="btn" onClick={this.handleSimple}>Animated Simple modal</button>
<button className="btn" onClick={this.handleSidebar}>Animated Sidebar</button>
</div>
<div dangerouslySetInnerHTML={{__html:animations}} />
<h4>Container</h4>
<p>Here is the overloaded container</p>
<p>My AnimHelper is built on react-motion, you can see it in sources.</p>
<div dangerouslySetInnerHTML={{__html:containerCode}} />
<h4>Backdrop</h4>
<p>Here is the new backdrop</p>
<div dangerouslySetInnerHTML={{__html:backdropCode}} />
<h4>Custom Modals</h4>
<p>Now you have everything, you just need to do you modal custom modal components</p>
<button className="btn" onClick={this.handleSimple}>Animated Simple modal</button>
<div dangerouslySetInnerHTML={{__html:dialogCode}} />
<button className="btn" onClick={this.handleSidebar}>Animated Sidebar</button>
<div dangerouslySetInnerHTML={{__html:sidebarCode}} />
</AnimatedContainer>;
}
} |
index.ios.js | wvicioso/dapr | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
} from 'react-native';
import Main from './app/main';
AppRegistry.registerComponent('Dapr', () => Main);
|
pootle/static/js/shared/components/FormSelectInput.js | ta2-1/pootle | /*
* Copyright (C) Pootle contributors.
*
* This file is a part of the Pootle project. It is distributed under the GPL3
* or later license. See the LICENSE file for a copy of the license and the
* AUTHORS file for copyright and authorship information.
*/
import React from 'react';
import Select from 'react-select';
const FormSelectInput = React.createClass({
propTypes: {
handleChange: React.PropTypes.func.isRequired,
multiple: React.PropTypes.bool,
name: React.PropTypes.string.isRequired,
options: React.PropTypes.array.isRequired,
value: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.number,
React.PropTypes.string,
React.PropTypes.array,
]).isRequired,
},
handleChange(value) {
const newValue = this.props.multiple ? value.split(',') : value;
this.props.handleChange(this.props.name, newValue);
},
render() {
const { value } = this.props;
/* FIXME: react-select#25 prevents using non-string values */
const selectValue = this.props.multiple ? value : value.toString();
return (
<Select
clearAllText={gettext('Clear all')}
clearValueText={gettext('Clear value')}
noResultsText={gettext('No results found')}
onChange={this.handleChange}
placeholder={gettext('Select...')}
searchPromptText={gettext('Type to search')}
{...this.props}
multi={this.props.multiple}
value={selectValue}
/>
);
},
});
export default FormSelectInput;
|
app/components/examples/ListItem/index.js | GuiaLa/guiala-web-app | import React from 'react';
import styles from './styles.css';
function ListItem(props) {
return (
<li className={ props.className || styles.item }>
<div className={ styles.itemContent }>
{ props.content }
</div>
</li>
);
}
export default ListItem;
|
src/common/containers/landing.js | canonical-websites/build.snapcraft.io | import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Anchor } from '../components/vanilla-modules/button';
import { HeadingTwo, HeadingThree } from '../components/vanilla-modules/heading';
import { List, ListItem } from '../components/vanilla-modules/list';
import Testimonial from '../components/testimonial';
import containerStyles from './container.css';
import styles from './landing.css';
import octocat from '../images/octocat.svg';
import * as images from '../images';
class Landing extends Component {
render() {
const { user } = this.props;
return (
<div>
<div className={ containerStyles.strip }>
<div>
<div className={ `${containerStyles.wrapper} ${styles.centeredText}` }>
<HeadingTwo>
Auto-build and publish software<br />for any Linux system or device
</HeadingTwo>
<ul className={ styles.banner }>
<li className={ styles.bannerImage }>
<img src='https://assets.ubuntu.com/v1/ed6d1c5b-build.snapcraft.hero.svg' alt=""/>
</li>
<li className={ styles.bannerLabel }>
Push to GitHub
</li>
<li className={ styles.bannerLabel }>
Built automatically
</li>
<li className={ styles.bannerLabel }>
Released for your users
</li>
</ul>
<div className={ styles.bannerButton }>
{ this.props.auth.authenticated
? (
<div className={ styles.bannerMessage }>
Hi { user.name || user.login }, <a href={`/user/${user.login}`}>let’s take a look at your repos</a>.
</div>
)
: (
<Anchor href="/auth/authenticate" isBigger appearance='positive' >
Set up in minutes
<img className= { styles.icon } src={ octocat } />
</Anchor>
)
}
</div>
</div>
</div>
</div>
<section className={ `${styles.section} ${styles.sectionTopBorderOnly}` }>
<div className={ `${containerStyles.wrapper}` }>
<HeadingTwo className={ styles.landingHeading }>
Publish your software for
</HeadingTwo>
<div className={ `${styles.row}` }>
<img className={ styles.brandLogo } alt="Debian," src={images.debian} />
<img className={ styles.brandLogo } alt="openSUSE," src={images.opensuse} />
<img className={ styles.brandLogo } alt="Arch Linux," src={images.archlinux} />
<img className={ styles.brandLogo } alt="Gentoo," src={images.gentoo} />
<img className={ styles.brandLogo } alt="Fedora," src={images.fedora} />
<img className={ styles.brandLogo } alt="Ubuntu." src={images.ubuntu} />
</div>
</div>
</section>
<section className={ `${styles.section} ${styles.sectionNoBorder} ${containerStyles.lightStrip}` }>
<div className={ `${containerStyles.wrapper}` }>
<HeadingTwo className={ styles.landingHeading }>
Why use Snapcraft?
</HeadingTwo>
<div className={ `${styles.row}` }>
<div className={ styles.rowItemGrow }>
<List>
<ListItem isTicked>Scale to millions of installs</ListItem>
<ListItem isTicked>Automatic updates for everyone</ListItem>
</List>
</div>
<div className={ styles.rowItemGrow }>
<List>
<ListItem isTicked>Available on all clouds and Linux OSes</ListItem>
<ListItem isTicked>Roll back versions effortlessly</ListItem>
</List>
</div>
<div className={ styles.rowItemGrow }>
<List>
<ListItem isTicked>No need for build infrastructure</ListItem>
<ListItem isTicked>FREE for open source projects</ListItem>
</List>
</div>
</div>
</div>
</section>
<section className={ `${styles.section} ${styles.sectionNoBorder}` }>
<div className={ `${containerStyles.wrapper}` }>
<HeadingTwo className={ styles.landingHeading }>
How Snapcraft fits into your workflow
</HeadingTwo>
<div className={ `${styles.row} `}>
<img src='https://assets.ubuntu.com/v1/b70a5c55-workflow-illustration.svg' className={ `${styles.centeredImage}`} alt="1: You receive a pull request on GitHub. 2: Test with Travis or other CI system. 3: The code lands on your GitHub master. 4: Snapcraft builds a new snap version. 5: Auto-released to the snap store for testing. 6: You promote to beta, candidate, or stable."/>
</div>
</div>
<div className={ styles.centeredButton }>
<Anchor href="/auth/authenticate" isBigger appearance='positive'>
Get started now
<img className= { styles.icon } src={ octocat } />
</Anchor>
</div>
</section>
<section className={ `${styles.section} ${styles.sectionNoBorder} ${containerStyles.lightStrip}` }>
<div className={ `${containerStyles.wrapper} ${styles.row}` }>
<div className={ `${styles.twoThirds}` }>
<HeadingTwo className={ styles.landingHeading }>
Fast to install, easy to create, safe to run
</HeadingTwo>
<div>
<p className={styles.snaps}>With Snapcraft, it’s easy to get your software published in the snap store. This store lets people safely install apps from any vendor on mission-critical devices and PCs. Snaps are secure, sandboxed, containerised applications, packaged with their dependencies for predictable behaviour.</p>
<a href="https://snapcraft.io" className={ styles.external } >More about snaps</a>
</div>
</div>
<div className={styles.oneThird}>
<img alt="" src='https://assets.ubuntu.com/v1/2c5e93c5-fast-easy-safe-illustration.svg'/>
</div>
</div>
</section>
<section className={ styles.section }>
<div className={ `${containerStyles.wrapper}` }>
<HeadingThree>
What people are saying about snaps
</HeadingThree>
<div className={ `${styles.row}` }>
<div className={ styles.oneThird }>
<Testimonial citation='Frank Karlitschek, NextCloud' logo='https://assets.ubuntu.com/v1/99a0b969-Nextcloud_Logo.svg'>
Snaps provide an excellent way to distribute updates in a way that is both secure and does not risk breaking end user devices.
</Testimonial>
</div>
<div className={ styles.oneThird }>
<Testimonial citation='Mac Devine, IBM' logo='https://assets.ubuntu.com/v1/683950fd-logo-ibm.svg'>
Snaps allow developers to build and deploy applications in a format that’s easily portable and upgradeable across a number of IoT devices so that a cognitive relationship between the cloud and the edges of the network can be established.
</Testimonial>
</div>
<div className={ styles.oneThird }>
<Testimonial citation='Aaron Ogle, Rocket.Chat' logo='https://assets.ubuntu.com/v1/1ad274f9-rocket-chat.svg'>
Getting Rocket.Chat snapped was as easy as defining a simple yaml file and adding into our CI. This is definitely one of the easiest distribution methods we have ever used.
</Testimonial>
</div>
</div>
</div>
</section>
</div>
);
}
}
Landing.propTypes = {
children: PropTypes.node,
auth: PropTypes.object,
user: PropTypes.object
};
function mapStateToProps(state) {
const {
auth,
user
} = state;
return {
auth,
user
};
}
export default connect(mapStateToProps)(Landing);
|
src/components/onboarding/steps/Step3.js | golemfactory/golem-electron | import React from 'react';
import Lottie from 'react-lottie';
import animData from './../../../assets/anims/onboarding/requestor.json';
const defaultOptions = {
loop: false,
autoplay: true,
animationData: animData,
rendererSettings: {
preserveAspectRatio: 'xMidYMid slice'
}
};
export default class Step3 extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="container-step__onboarding">
<div className="section-image__onboarding section__fixed">
<Lottie options={defaultOptions} />
</div>
<div className="desc__onboarding">
<h1>Become a requestor</h1>
<span>
After topping up your wallet you just drag & drop your
files and adjust your task settings before sending them
to the network.
</span>
</div>
</div>
);
}
}
|
src/components/RadioList/Radio.js | InsideSalesOfficial/insidesales-components | import PropTypes from 'prop-types';
import { transparentize } from 'polished';
import React from 'react';
import styled, { css } from 'styled-components';
import _ from 'lodash';
import {
colors,
typography,
renderThemeIfPresentOrDefault,
ifThemeInPropsIsPresentUse
} from '../styles';
const size = 16;
function renderThemedLabelActiveBackground(props) {
if (props.theme.lightRadio || !props.theme.brand01) return '';
return transparentize(0.9, props.theme.brand01)
}
function renderThemedLabelBackground(props) {
if (props.theme.lightRadio) return 'transparent';
return props.theme.primary05;
}
const RadioLabel = styled.label`
${typography.bodyCompact}
background: ${props => ifThemeInPropsIsPresentUse({ props, value: renderThemedLabelBackground(props), defaultValue: props.theme.background })};
display: flex;
align-items: center;
width: 100%;
color: ${renderThemeIfPresentOrDefault({ key: 'white60', defaultValue: colors.black60 })};
cursor: pointer;
padding: ${props => {
if (!_.isEmpty(props.label.super) && !_.isEmpty(props.label.main) && !_.isEmpty(props.theme.padding)) {
return `6px ${props.theme.padding} 4px ${props.theme.padding}`;
} else if (!_.isEmpty(props.theme.padding)) {
return props.theme.padding;
}
return '0.75em';
}};
margin: ${props => props.theme.margin} 0;
${props => {
if (props.active) {
return css`
background: ${props => ifThemeInPropsIsPresentUse({ props, value: renderThemedLabelActiveBackground(props), defaultValue: props.theme.backgroundFocused })};
color: ${renderThemeIfPresentOrDefault({ key: 'brand01', defaultValue: colors.black90 })};
`;
}
return css`
&:hover {
color: ${renderThemeIfPresentOrDefault({ key: 'white', defaultValue: colors.black })};
span {
border-color: ${renderThemeIfPresentOrDefault({ key: 'white', defaultValue: colors.black })};
}
}
`
}}
`;
const RadioInput = styled.input`
opacity: 0;
position: fixed;
width: 0;
`;
function renderThemedRadioCircleBorder(props) {
return props.theme.white60;
}
function renderRadioCircleBorder(props) {
return props.theme.lightRadio ? colors.black40 : colors.black
}
function renderThemedOuterRadioCircle(props) {
if (!props.active) return '';
return `border-color: ${props.theme.brand01};`
}
function renderOuterRadioCircle(props) {
if (!props.theme.lightRadio || !props.active) return '';
return `border-color: ${colors.green};`
}
const RadioCircle = styled.span`
min-width: ${size}px;
min-height: ${size}px;
border-radius: 50%;
display: inline-block;
border: 2px solid ${props => ifThemeInPropsIsPresentUse({ props, value: renderThemedRadioCircleBorder(props), defaultValue: renderRadioCircleBorder(props) })};
position: relative;
vertical-align: middle;
margin-right: 0.5714em;
background: ${renderThemeIfPresentOrDefault({ key: 'transparent', defaultValue: colors.white })};
box-sizing: content-box;
${props => ifThemeInPropsIsPresentUse({ props, value: renderThemedOuterRadioCircle(props), defaultValue: renderOuterRadioCircle(props) })}
${props => props.active && css`
&:before {
content: '';
border-radius: 50%;
width: ${size * 0.625}px;
height: ${size * 0.625}px;
background-color: ${renderThemeIfPresentOrDefault({ key: 'brand01', defaultValue: colors.green })};
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
`}
`;
const MultiLineLabelWrapper = styled.div`
display: inline-block;
vertical-align: middle;
`;
const SuperscriptLabel = styled.div`
color: ${renderThemeIfPresentOrDefault({ key: 'white60', defaultValue: colors.black60 })};
${typography.caption}
`;
const MainLabel = styled.div`
color: ${renderThemeIfPresentOrDefault({ key: 'white60', defaultValue: colors.black90 })};
${typography.subhead1}
`;
const RadioComponent = ({ id, name, label = "", value, setValue, selectedValue = "" }) => {
const active = value === selectedValue;
const findLabel = (label) => {
if (!_.isEmpty(label.super) && !_.isEmpty(label.main)) {
return (
<MultiLineLabelWrapper>
<SuperscriptLabel>{label.super}</SuperscriptLabel>
<MainLabel>{label.main}</MainLabel>
</MultiLineLabelWrapper>
);
}
return label;
}
return (<div>
<RadioInput
className="pb-test__radio"
type="radio"
id={id}
name={name}
value={value}
checked={active}
onChange={() => { setValue(value) }}
onFocus={() => { setValue(value) }}
/>
<RadioLabel htmlFor={id} active={active} label={label}>
<RadioCircle active={active}></RadioCircle>{findLabel(label)}
</RadioLabel>
</div>);
};
RadioComponent.propTypes = {
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
label: PropTypes.any,
selectedValue: PropTypes.any,
value: PropTypes.any.isRequired,
setValue: PropTypes.func.isRequired
};
export default RadioComponent;
|
client/dev/components/listItems.js | tetondan/ReactReduxToDo | import React, { Component } from 'react';
import { connect } from 'react-redux';
import ListItem from './listItem';
class ListItems extends Component {
render(){
let props = this.props
return (
<ul className="listitems">
{props.items.map( (item, index) => {
return <ListItem itemClick={props.toggleAction} selected={props.selected} item={item} key={item.id}/>
})}
</ul>
)
}
};
const mapStateToProps = state => {
return {
items: state.items,
selected: state.selected
};
};
const mapDispatchToProps = dispatch => {
return {
toggleAction: id => {
dispatch({type: "TOGGLE_TODO", id})
}
};
};
export default connect(mapStateToProps, mapDispatchToProps)(ListItems);
|
src/routes.js | KhaledSami/reactblog | import React from 'react';
import {Route, IndexRoute} from 'react-router';
import App from './components/app';
import PostIndex from './components/post-index';
import PostNew from './components/post-new';
import PostsShow from './components/posts-show';
export default (
<Route path="/" component={App}>
<IndexRoute component={PostIndex} />
<Route path="posts/new" component={PostNew} />
<Route path="posts/:id" component={PostsShow} />
</Route>
); |
client/src/components/Home.js | gkovats/kidtracker | import React from 'react';
import { Link } from 'react-router-dom';
export class Home extends React.Component {
componentWillMount() {
console.log(this.props);
}
render() {
return (
<div className="not-found">
<h1>HOME</h1>
<p>
<Link to="/">Go back to the main page</Link>
</p>
</div>
);
}
}
export default Home;
|
docs/app/Examples/collections/Message/Types/MessageExampleMessageProps.js | koenvg/Semantic-UI-React | import React from 'react'
import { Message } from 'semantic-ui-react'
const MessageExampleMessageProps = () => (
<Message
header='Changes in Service'
content='We updated our privacy policy here to better service our customers. We recommend reviewing the changes.'
/>
)
export default MessageExampleMessageProps
|
src/components/Routes/Routes.js | zerkedev/zerke-app | import React from 'react';
import Loadable from 'react-loadable';
import LoadingComponent from '../../components/LoadingComponent/LoadingComponent';
import { RestrictedRoute } from '../../containers/RestrictedRoute';
import { Route, Switch } from 'react-router-dom';
function MyLoadable(opts, preloadComponents) {
return Loadable(Object.assign({
loading: LoadingComponent,
render(loaded, props) {
if(preloadComponents!==undefined && preloadComponents instanceof Array){
preloadComponents.map(component=>component.preload());
}
let Component = loaded.default;
return <Component {...props}/>;
}
}, opts));
};
const AsyncDashboard = MyLoadable({loader: () => import('../../containers/Dashboard/Dashboard')});
const AsyncHome = MyLoadable({loader: () => import('../../containers/Home/Home')});
const AsyncAbout = MyLoadable({loader: () => import('../../containers/About/About')});
const AsyncPublicChats = MyLoadable({loader: () => import('../../containers/PublicChats/PublicChats')});
const AsyncMyAccount = MyLoadable({loader: () => import('../../containers/MyAccount/MyAccount')});
const AsyncPredefinedChatMessages = MyLoadable({loader: () => import('../../containers/PredefinedChatMessages/PredefinedChatMessages')});
const AsyncTask = MyLoadable({loader: () => import('../../containers/Tasks/Task')});
const AsyncTasks = MyLoadable({loader: () => import('../../containers/Tasks/Tasks')}, [AsyncTask]);
const AsyncRole = MyLoadable({loader: () => import('../../containers/Roles/Role')});
const AsyncRoles = MyLoadable({loader: () => import('../../containers/Roles/Roles')}, AsyncRole);
const AsyncChat = MyLoadable({loader: () => import('../../containers/Chats/Chat')});
const AsyncCreateChat = MyLoadable({loader: () => import('../../containers/Chats/CreateChat')});
const AsyncChats = MyLoadable({loader: () => import('../../containers/Chats/Chats')}, [AsyncChat, AsyncCreateChat]);
const AsyncCompany = MyLoadable({loader: () => import('../../containers/Companies/Company')});
const AsyncCompanies = MyLoadable({loader: () => import('../../containers/Companies/Companies')}, [AsyncCompany]);
const AsyncLocation = MyLoadable({loader: () => import('../../containers/Locations/Location')});
const AsyncLocations = MyLoadable({loader: () => import('../../containers/Locations/Locations')}, [AsyncLocation]);
const AsyncReview = MyLoadable({loader: () => import('../../containers/Reviews/Review')});
const AsyncReviews = MyLoadable({loader: () => import('../../containers/Reviews/Reviews')}, [AsyncReview]);
const AsyncLocationPage = MyLoadable({loader: () => import('../../containers/Locations/LocationPage')}, [AsyncLocation]);
const AsyncBill = MyLoadable({loader: () => import('../../containers/Billing/Bill')});
const AsyncBilling = MyLoadable({loader: () => import('../../containers/Billing/Billing')}, [AsyncBill]);
const AsyncPost = MyLoadable({loader: () => import('../../containers/Posts/Post')});
const AsyncPosts = MyLoadable({loader: () => import('../../containers/Posts/Posts')}, [AsyncPost]);
const AsyncUser = MyLoadable({loader: () => import('../../containers/Users/User')});
const AsyncUsers = MyLoadable({loader: () => import('../../containers/Users/Users')}, [AsyncUser]);
const AsyncSignIn = MyLoadable({loader: () => import('../../containers/SignIn/SignIn')});
const AsyncPageNotFound = MyLoadable({loader: () => import('../../components/PageNotFound/PageNotFound')});
const Routes = (props, context) => {
return (
<Switch >
<RestrictedRoute type='private' path="/" exact component={AsyncHome} />
<RestrictedRoute type='private' path="/dashboard" exact component={AsyncDashboard} />
<RestrictedRoute type='private' path="/home" exact component={AsyncHome} />
<RestrictedRoute type='private' path="/loading" exact component={LoadingComponent} />
<RestrictedRoute type='private' path="/public_chats" exact component={AsyncPublicChats} />
<RestrictedRoute type='private' path="/tasks" exact component={AsyncTasks} />
<RestrictedRoute type='private' path="/tasks/edit/:uid" exact component={AsyncTask} />
<RestrictedRoute type='private' path="/tasks/create" exact component={AsyncTask} />
<RestrictedRoute type='private' path="/roles" exact component={AsyncRoles} />
<RestrictedRoute type='private' path="/roles/edit/:uid" exact component={AsyncRole} />
<RestrictedRoute type='private' path="/roles/create" exact component={AsyncRole} />
<RestrictedRoute type='private' path="/companies" exact component={AsyncCompanies} />
<RestrictedRoute type='private' path="/companies/edit/:uid" exact component={AsyncCompany} />
<RestrictedRoute type='private' path="/companies/create" exact component={AsyncCompany} />
<RestrictedRoute type='private' path="/locations" exact component={AsyncLocations} />
<RestrictedRoute type='private' path="/locations/edit/:uid" exact component={AsyncLocation} />
<RestrictedRoute type='private' path="/locations/create" exact component={AsyncLocation} />
<RestrictedRoute type='private' path="/locations/:uid" exact component={AsyncLocationPage} />
<RestrictedRoute type='private' path="/billing" exact component={AsyncBilling} />
<RestrictedRoute type='private' path="/billing/edit/:uid" exact component={AsyncBill} />
<RestrictedRoute type='private' path="/billing/create" exact component={AsyncBill} />
<RestrictedRoute type='private' path="/posts" exact component={AsyncPosts} />
<RestrictedRoute type='private' path="/posts/edit/:uid" exact component={AsyncPost} />
<RestrictedRoute type='private' path="/posts/create" exact component={AsyncPost} />
<RestrictedRoute type='private' path="/reviews" exact component={AsyncReviews} />
<RestrictedRoute type='private' path="/reviews/edit/:uid" exact component={AsyncReview} />
<RestrictedRoute type='private' path="/reviews/create" exact component={AsyncReview} />
<RestrictedRoute type='private' path="/predefined_chat_messages" exact component={AsyncPredefinedChatMessages} />
<RestrictedRoute type='private' path="/chats" exact component={AsyncChats} />
<RestrictedRoute type='private' path="/chats/edit/:uid" exact component={AsyncChat} />
<RestrictedRoute type='private' path="/chats/create" exact component={AsyncCreateChat} />
<RestrictedRoute type='private' path="/users" exact component={AsyncUsers} />
<RestrictedRoute type='private' path="/users/edit/:uid/:editType" exact component={AsyncUser} />
<RestrictedRoute type='private' path="/about" exact component={AsyncAbout} />
<RestrictedRoute type='private' path="/my_account" exact component={AsyncMyAccount} />
<RestrictedRoute type='public' path="/signin" component={AsyncSignIn} />
<Route component={AsyncPageNotFound} />
</Switch>
);
}
export default Routes;
|
docs/src/examples/views/Feed/Content/FeedExampleImageLabelShorthand.js | Semantic-Org/Semantic-UI-React | import React from 'react'
import { Feed } from 'semantic-ui-react'
const FeedExampleImageLabelShorthand = () => (
<Feed>
<Feed.Event
image='/images/avatar/small/elliot.jpg'
content='You added Elliot Fu to the group Coworkers'
/>
<Feed.Event>
<Feed.Label image='/images/avatar/small/elliot.jpg' />
<Feed.Content content='You added Elliot Fu to the group Coworkers' />
</Feed.Event>
</Feed>
)
export default FeedExampleImageLabelShorthand
|
src/svg-icons/action/check-circle.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionCheckCircle = (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-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
</SvgIcon>
);
ActionCheckCircle = pure(ActionCheckCircle);
ActionCheckCircle.displayName = 'ActionCheckCircle';
ActionCheckCircle.muiName = 'SvgIcon';
export default ActionCheckCircle;
|
docs/pages/components/backdrop.js | lgollut/material-ui | import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import { prepareMarkdown } from 'docs/src/modules/utils/parseMarkdown';
const pageFilename = 'components/backdrop';
const requireDemo = require.context('docs/src/pages/components/backdrop', false, /\.(js|tsx)$/);
const requireRaw = require.context(
'!raw-loader!../../src/pages/components/backdrop',
false,
/\.(js|md|tsx)$/,
);
export default function Page({ demos, docs }) {
return <MarkdownDocs demos={demos} docs={docs} requireDemo={requireDemo} />;
}
Page.getInitialProps = () => {
const { demos, docs } = prepareMarkdown({ pageFilename, requireRaw });
return { demos, docs };
};
|
src/index.js | MrEliasen/react-boilderplate | /*
* @Author: Mark Eliasen
* @Date: 2017-03-01 17:45:14
* @Last Modified by: Mark Eliasen
* @Last Modified time: 2017-06-08 14:48:37
*/
import React from 'react';
import ReactDOM from 'react-dom';
import {AppContainer} from 'react-hot-loader';
import Routes from './routes';
// When building the app
if (process.env.NODE_ENV === 'production') {
ReactDOM.render(
<Routes />,
document.getElementById('root')
);
} else {
// When developing the app
const render = (Component) => {
ReactDOM.render(
<AppContainer>
<Component />
</AppContainer>,
document.getElementById('root')
);
};
render(Routes);
if (module.hot) {
module.hot.accept('./routes', () => {
render(
Routes
);
});
}
}
|
react/reactRedux/redux-master/examples/counter/src/index.js | huxinmin/PracticeMakesPerfect | import React from 'react'
import ReactDOM from 'react-dom'
import { createStore } from 'redux'
import Counter from './components/Counter'
import counter from './reducers'
const store = createStore(counter)
const rootEl = document.getElementById('root')
const render = () => ReactDOM.render(
<Counter
value={store.getState()}
onIncrement={() => store.dispatch({ type: 'INCREMENT' })}
onDecrement={() => store.dispatch({ type: 'DECREMENT' })}
/>,
rootEl
)
render()
store.subscribe(render)
|
example/src/index.js | Demi-IO/golden-type | import React from 'react';
import ReactDom from 'react-dom';
import App from './App';
ReactDom.render(<App/>, document.getElementById('root'));
|
packages/material-ui-icons/src/PowerSettingsNew.js | cherniavskii/material-ui | import React from 'react';
import createSvgIcon from './utils/createSvgIcon';
export default createSvgIcon(
<g><path d="M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z" /></g>
, 'PowerSettingsNew');
|
assets/jqwidgets/demos/react/app/kanban/righttoleftlayout/app.js | juannelisalde/holter | import React from 'react';
import ReactDOM from 'react-dom';
import JqxKanban from '../../../jqwidgets-react/react_jqxkanban.js';
class App extends React.Component {
render() {
let fields = [
{ name: 'id', type: 'string' },
{ name: 'status', map: 'state', type: 'string' },
{ name: 'text', map: 'label', type: 'string' },
{ name: 'tags', type: 'string' },
{ name: 'color', map: 'hex', type: 'string' },
{ name: 'resourceId', type: 'number' }
];
let source =
{
localData: [
{ id: '1161', state: 'new', label: 'Combine Orders', tags: 'orders, combine', hex: '#5dc3f0', resourceId: 3 },
{ id: '1645', state: 'work', label: 'Change Billing Address', tags: 'billing', hex: '#f19b60', resourceId: 1 },
{ id: '9213', state: 'new', label: 'One item added to the cart', tags: 'cart', hex: '#5dc3f0', resourceId: 3 },
{ id: '6546', state: 'done', label: 'Edit Item Price', tags: 'price, edit', hex: '#5dc3f0', resourceId: 4 },
{ id: '9034', state: 'new', label: 'Login 404 issue', tags: 'issue, login', hex: '#6bbd49' }
],
dataType: 'array',
dataFields: fields
};
let dataAdapter = new $.jqx.dataAdapter(source);
let resourcesAdapterFunc = () => {
let resourcesSource =
{
localData: [
{ id: 0, name: 'No name', image: '../../jqwidgets/styles/images/common.png', common: true },
{ id: 1, name: 'Andrew Fuller', image: '../../images/andrew.png' },
{ id: 2, name: 'Janet Leverling', image: '../../images/janet.png' },
{ id: 3, name: 'Steven Buchanan', image: '../../images/steven.png' },
{ id: 4, name: 'Nancy Davolio', image: '../../images/nancy.png' },
{ id: 5, name: 'Michael Buchanan', image: '../../images/Michael.png' },
{ id: 6, name: 'Margaret Buchanan', image: '../../images/margaret.png' },
{ id: 7, name: 'Robert Buchanan', image: '../../images/robert.png' },
{ id: 8, name: 'Laura Buchanan', image: '../../images/Laura.png' },
{ id: 9, name: 'Laura Buchanan', image: '../../images/Anne.png' }
],
dataType: 'array',
dataFields: [
{ name: 'id', type: 'number' },
{ name: 'name', type: 'string' },
{ name: 'image', type: 'string' },
{ name: 'common', type: 'boolean' }
]
};
let resourcesDataAdapter = new $.jqx.dataAdapter(resourcesSource);
return resourcesDataAdapter;
}
let columns =
[
{ text: 'Backlog', dataField: 'new' },
{ text: 'In Progress', dataField: 'work' },
{ text: 'Done', dataField: 'done' }
];
return (
<JqxKanban
rtl={true} resources={resourcesAdapterFunc()}
source={dataAdapter} columns={columns}
/>
)
}
}
ReactDOM.render(<App />, document.getElementById('app')); |
templates/components/front/pages/home.js | wi2/sails-auto-admin | "use strict";
import React from 'react'
import Layout from '../layout'
export default class extends React.Component {
render() {
return (
<Layout {...this.props} {...this.state}>
<h1>HomePage</h1>
</Layout>
);
}
}
|
src/svg-icons/action/settings.js | mmrtnz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionSettings = (props) => (
<SvgIcon {...props}>
<path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"/>
</SvgIcon>
);
ActionSettings = pure(ActionSettings);
ActionSettings.displayName = 'ActionSettings';
ActionSettings.muiName = 'SvgIcon';
export default ActionSettings;
|
tests/react_modules/es6class-proptypes-callsite.js | jgrund/flow | /* @flow */
import React from 'react';
import Hello from './es6class-proptypes-module';
class HelloLocal extends React.Component<void, {name: string}, void> {
defaultProps = {};
propTypes = {
name: React.PropTypes.string.isRequired,
};
render(): React.Element<*> {
return <div>{this.props.name}</div>;
}
}
class Callsite extends React.Component<void, {}, void> {
render(): React.Element<*> {
return (
<div>
<Hello />
<HelloLocal />
</div>
);
}
}
module.exports = Callsite;
|
src/svg-icons/device/battery-charging-90.js | hai-cea/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceBatteryCharging90 = (props) => (
<SvgIcon {...props}>
<path fillOpacity=".3" d="M15.67 4H14V2h-4v2H8.33C7.6 4 7 4.6 7 5.33V8h5.47L13 7v1h4V5.33C17 4.6 16.4 4 15.67 4z"/><path d="M13 12.5h2L11 20v-5.5H9L12.47 8H7v12.67C7 21.4 7.6 22 8.33 22h7.33c.74 0 1.34-.6 1.34-1.33V8h-4v4.5z"/>
</SvgIcon>
);
DeviceBatteryCharging90 = pure(DeviceBatteryCharging90);
DeviceBatteryCharging90.displayName = 'DeviceBatteryCharging90';
DeviceBatteryCharging90.muiName = 'SvgIcon';
export default DeviceBatteryCharging90;
|
packages/component/src/ConnectivityStatus/Assets/ErrorNotificationIcon.js | billba/botchat | import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
const { useDirection } = hooks;
const ICON_SIZE_FACTOR = 16;
const ErrorNotificationIcon = ({ className, size }) => {
const [direction] = useDirection();
return (
<svg
alt=""
className={classNames(className + '', direction === 'rtl' && 'webchat__error--rtl')}
height={ICON_SIZE_FACTOR * size}
viewBox="0 0 13.1 13.1"
width={ICON_SIZE_FACTOR * size}
>
<path
d="M6.5,13C2.9,13,0,10.1,0,6.5S2.9,0,6.5,0S13,2.9,13,6.5S10.1,13,6.5,13z M6.1,3.5v4.3h0.9V3.5H6.1z M6.1,8.7v0.9h0.9V8.7H6.1z"
fillRule="evenodd"
/>
</svg>
);
};
ErrorNotificationIcon.defaultProps = {
className: '',
size: 1
};
ErrorNotificationIcon.propTypes = {
className: PropTypes.string,
size: PropTypes.number
};
export default ErrorNotificationIcon;
|
pet-projects/list-of-stuff/pages/login/login-page.js | oka-haist/codeHere | import React from 'react';
import { StyleSheet, TextInput, View, Button } from 'react-native';
export default class LoginPage extends React.Component {
constructor(props) {
super(props);
this.state = {
form: {
username: '',
password: ''
}
};
}
onLogin(ev) {
console.log('Login in...', ev);
}
render() {
return (
<View>
<TextInput
style={styles.textInput}
placeholder="Username"
onChangeText={(text) => this.setState({
form: {
username: text
}
})} />
<TextInput
style={styles.textInput}
placeholder="Password"
onChangeText={(text) => this.setState({
form: {
password: text
}
})} />
<Button
onPress={this.onLogin}
title="Login"
color="#61f298" />
</View>
);
}
}
const styles = StyleSheet.create({
textInput: {
width: 200,
height: 50
},
});
|
src/LiturgicalDayProperties.js | OCMC-Translation-Projects/ioc-liturgical-react | import React from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
import server from './helpers/Server';
import {ControlLabel, DropdownButton, FormGroup, MenuItem} from 'react-bootstrap';
import DatePicker from 'react-bootstrap-date-picker'
import Form from 'react-jsonschema-form';
import ResponseParser from './helpers/ResponseParser'
class LiturgicalDayProperties extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedType: "g"
, labels: props.session.labels[props.session.labelTopics.ldp]
};
this.handleChange = this.handleChange.bind(this);
this.fetchData = this.fetchData.bind(this);
this.onSelect = this.onSelect.bind(this);
}
componentWillReceiveProps = (nextProps) => {
this.setState(
{
labels: nextProps.session.labels[nextProps.session.labelTopics.ldp]
}
);
};
componentWillMount = () => {
var value = new Date().toISOString();
this.setState({
value: value, // ISO String, ex: "2016-11-19T12:00:00.000Z"
});
};
handleChange = (value, formattedValue) => {
this.setState({
value: value, // ISO String, ex: "2016-11-19T12:00:00.000Z"
formattedValue: formattedValue // Formatted String, ex: "11/19/2016"
}, this.fetchData(value));
};
onSelect = (index) => {
this.setState({
selectedType: index
})
};
fetchData(date) {
var config = {
auth: {
username: this.props.session.userInfo.username
, password: this.props.session.userInfo.password
}
};
let parms =
"?t=" + encodeURIComponent(this.state.selectedType)
+ "&d=" + encodeURIComponent(date)
;
axios.get(
this.props.session.restServer
+ server.getWsServerLiturgicalDayPropertiesApi()
+ parms
, config
)
.then(response => {
ResponseParser.setItem(response.data);
this.setState( {
item: ResponseParser.getItemObject()
}
);
})
.catch( (error) => {
this.setState( { data: error.message });
this.props.callback(error.message, "");
});
}
render() {
return (
<div className="App-DateSelector">
<h3 className="App-DateSelector-prompt">{this.props.formPrompt}</h3>
<FormGroup>
<ControlLabel>{this.state.labels.prompt}</ControlLabel>
<p/>
<DropdownButton
bsStyle="primary"
title={this.state.labels.calendar}
key={"a"}
id={`App-DateSelector-calendar-type`}
onSelect={this.onSelect}
>
<MenuItem eventKey="j">{this.state.labels.julian}</MenuItem>
<MenuItem eventKey="g">{this.state.labels.gregorian}</MenuItem>
</DropdownButton>
<p/>
<DatePicker
id="app-datepicker"
value={this.state.value}
onChange={this.handleChange}
/>
</FormGroup>
{this.state.item ?
<Form
schema={this.state.item.schema}
uiSchema={this.state.item.uiSchema}
formData={this.state.item.value}
onSubmit={this.onSubmit}>
</Form>
:
<div></div>
}
</div>
)
}
}
LiturgicalDayProperties.propTypes = {
session: PropTypes.object.isRequired
, callback: PropTypes.func.isRequired
};
LiturgicalDayProperties.defaultProps = {
};
export default LiturgicalDayProperties;
|
geonode/contrib/monitoring/frontend/src/pages/software-performance/index.js | MapStory/geonode | import React from 'react';
import Header from '../../components/organisms/header';
import GeonodeAnalytics from '../../components/organisms/geonode-analytics';
import GeonodeLayersAnalytics from '../../components/organisms/geonode-layers-analytics';
import WSAnalytics from '../../components/organisms/ws-analytics';
import WSLayersAnalytics from '../../components/organisms/ws-layers-analytics';
import styles from './styles';
class SWPerf extends React.Component {
render() {
return (
<div style={styles.root}>
<Header back="/" />
<div style={styles.analytics}>
<GeonodeAnalytics />
<WSAnalytics />
</div>
<div style={styles.analytics}>
<GeonodeLayersAnalytics />
<WSLayersAnalytics />
</div>
</div>
);
}
}
export default SWPerf;
|
04/EW/trding/trding/src/components/list/Pagination.js | rgllm/uminho | import React from 'react';
import PropTypes from 'prop-types';
import './Pagination.css';
const Pagination = (props) => {
const { page, totalPages, handlePaginationClick} = props;
return(
<div className="Pagination">
<button
className="Pagination-button"
onClick={() => handlePaginationClick('prev')}
disabled={page <=1}>
←
</button>
<span className="Pagination-info">
page <b>{page}</b> of <b>{totalPages}</b>
</span>
<button
className="Pagination-button"
onClick={handlePaginationClick.bind(this,'next')}
disabled={page >= totalPages}>
→
</button>
</div>
);
}
Pagination.propTypes = {
totalPages: PropTypes.number.isRequired,
page: PropTypes.number.isRequired,
handlePaginationClick: PropTypes.func.isRequired,
}
export default Pagination;
|
yycomponent/timeline/Timeline.js | 77ircloud/yycomponent | import React from 'react';
import { Timeline as _Timeline } from 'antd';
class Timeline extends React.Component{
constructor(props){
super(props);
}
render(){
return (<_Timeline {...this.props}/>);
}
}
export default Timeline
|
docs/src/pages/components/tabs/IconLabelTabs.js | lgollut/material-ui | import React from 'react';
import Paper from '@material-ui/core/Paper';
import { makeStyles } from '@material-ui/core/styles';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import PhoneIcon from '@material-ui/icons/Phone';
import FavoriteIcon from '@material-ui/icons/Favorite';
import PersonPinIcon from '@material-ui/icons/PersonPin';
const useStyles = makeStyles({
root: {
flexGrow: 1,
maxWidth: 500,
},
});
export default function IconLabelTabs() {
const classes = useStyles();
const [value, setValue] = React.useState(0);
const handleChange = (event, newValue) => {
setValue(newValue);
};
return (
<Paper square className={classes.root}>
<Tabs
value={value}
onChange={handleChange}
variant="fullWidth"
indicatorColor="secondary"
textColor="secondary"
aria-label="icon label tabs example"
>
<Tab icon={<PhoneIcon />} label="RECENTS" />
<Tab icon={<FavoriteIcon />} label="FAVORITES" />
<Tab icon={<PersonPinIcon />} label="NEARBY" />
</Tabs>
</Paper>
);
}
|
test/integration/production-swcminify/pages/error-in-browser-render-status-code.js | zeit/next.js | import React from 'react'
export default class ErrorInRenderPage extends React.Component {
render() {
if (typeof window !== 'undefined') {
const error = new Error('An Expected error occurred')
// This will be extracted by getInitialProps in the _error page,
// which will result in a different error message being rendered.
error.statusCode = 404
throw error
}
return <div />
}
}
|
src/popover/popover-header.js | ricsv/react-leonardo-ui | import React from 'react';
import { luiClassName } from '../util';
const PopoverHeader = ({
className,
children,
nopad,
...extraProps
}) => {
const finalClassName = luiClassName('popover__header', {
className,
states: { nopad },
});
return (
<div className={finalClassName} {...extraProps}>
{children}
</div>
);
};
export default PopoverHeader;
|
app/javascript/mastodon/components/status_content.js | RobertRence/Mastodon | import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { isRtl } from '../rtl';
import { FormattedMessage } from 'react-intl';
import Permalink from './permalink';
import classnames from 'classnames';
export default class StatusContent extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
status: ImmutablePropTypes.map.isRequired,
expanded: PropTypes.bool,
onExpandedToggle: PropTypes.func,
onClick: PropTypes.func,
};
state = {
hidden: true,
};
_updateStatusLinks () {
const node = this.node;
const links = node.querySelectorAll('a');
for (var i = 0; i < links.length; ++i) {
let link = links[i];
if (link.classList.contains('status-link')) {
continue;
}
link.classList.add('status-link');
let mention = this.props.status.get('mentions').find(item => link.href === item.get('url'));
if (mention) {
link.addEventListener('click', this.onMentionClick.bind(this, mention), false);
link.setAttribute('title', mention.get('acct'));
} else if (link.textContent[0] === '#' || (link.previousSibling && link.previousSibling.textContent && link.previousSibling.textContent[link.previousSibling.textContent.length - 1] === '#')) {
link.addEventListener('click', this.onHashtagClick.bind(this, link.text), false);
} else {
link.setAttribute('title', link.href);
}
link.setAttribute('target', '_blank');
link.setAttribute('rel', 'noopener');
}
}
componentDidMount () {
this._updateStatusLinks();
}
componentDidUpdate () {
this._updateStatusLinks();
}
onMentionClick = (mention, e) => {
if (this.context.router && e.button === 0) {
e.preventDefault();
this.context.router.history.push(`/accounts/${mention.get('id')}`);
}
}
onHashtagClick = (hashtag, e) => {
hashtag = hashtag.replace(/^#/, '').toLowerCase();
if (this.context.router && e.button === 0) {
e.preventDefault();
this.context.router.history.push(`/timelines/tag/${hashtag}`);
}
}
handleMouseDown = (e) => {
this.startXY = [e.clientX, e.clientY];
}
handleMouseUp = (e) => {
if (!this.startXY) {
return;
}
const [ startX, startY ] = this.startXY;
const [ deltaX, deltaY ] = [Math.abs(e.clientX - startX), Math.abs(e.clientY - startY)];
if (e.target.localName === 'button' || e.target.localName === 'a' || (e.target.parentNode && (e.target.parentNode.localName === 'button' || e.target.parentNode.localName === 'a'))) {
return;
}
if (deltaX + deltaY < 5 && e.button === 0 && this.props.onClick) {
this.props.onClick();
}
this.startXY = null;
}
handleSpoilerClick = (e) => {
e.preventDefault();
if (this.props.onExpandedToggle) {
// The parent manages the state
this.props.onExpandedToggle();
} else {
this.setState({ hidden: !this.state.hidden });
}
}
setRef = (c) => {
this.node = c;
}
render () {
const { status } = this.props;
const hidden = this.props.onExpandedToggle ? !this.props.expanded : this.state.hidden;
const content = { __html: status.get('contentHtml') };
const spoilerContent = { __html: status.get('spoilerHtml') };
const directionStyle = { direction: 'ltr' };
const classNames = classnames('status__content', {
'status__content--with-action': this.props.onClick && this.context.router,
});
if (isRtl(status.get('search_index'))) {
directionStyle.direction = 'rtl';
}
if (status.get('spoiler_text').length > 0) {
let mentionsPlaceholder = '';
const mentionLinks = status.get('mentions').map(item => (
<Permalink to={`/accounts/${item.get('id')}`} href={item.get('url')} key={item.get('id')} className='mention'>
@<span>{item.get('username')}</span>
</Permalink>
)).reduce((aggregate, item) => [...aggregate, item, ' '], []);
const toggleText = hidden ? <FormattedMessage id='status.show_more' defaultMessage='Show more' /> : <FormattedMessage id='status.show_less' defaultMessage='Show less' />;
if (hidden) {
mentionsPlaceholder = <div>{mentionLinks}</div>;
}
return (
<div className={classNames} ref={this.setRef} tabIndex='0' aria-label={status.get('search_index')} onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp}>
<p style={{ marginBottom: hidden && status.get('mentions').isEmpty() ? '0px' : null }}>
<span dangerouslySetInnerHTML={spoilerContent} />
{' '}
<button tabIndex='0' className='status__content__spoiler-link' onClick={this.handleSpoilerClick}>{toggleText}</button>
</p>
{mentionsPlaceholder}
<div tabIndex={!hidden && 0} className={`status__content__text ${!hidden ? 'status__content__text--visible' : ''}`} style={directionStyle} dangerouslySetInnerHTML={content} />
</div>
);
} else if (this.props.onClick) {
return (
<div
ref={this.setRef}
tabIndex='0'
aria-label={status.get('search_index')}
className={classNames}
style={directionStyle}
onMouseDown={this.handleMouseDown}
onMouseUp={this.handleMouseUp}
dangerouslySetInnerHTML={content}
/>
);
} else {
return (
<div
tabIndex='0'
aria-label={status.get('search_index')}
ref={this.setRef}
className='status__content'
style={directionStyle}
dangerouslySetInnerHTML={content}
/>
);
}
}
}
|
node_modules/react-bootstrap/es/ButtonToolbar.js | acalabano/get-committed | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
var ButtonToolbar = function (_React$Component) {
_inherits(ButtonToolbar, _React$Component);
function ButtonToolbar() {
_classCallCheck(this, ButtonToolbar);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
ButtonToolbar.prototype.render = function render() {
var _props = this.props,
className = _props.className,
props = _objectWithoutProperties(_props, ['className']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = getClassSet(bsProps);
return React.createElement('div', _extends({}, elementProps, {
role: 'toolbar',
className: classNames(className, classes)
}));
};
return ButtonToolbar;
}(React.Component);
export default bsClass('btn-toolbar', ButtonToolbar); |
src/svg-icons/hardware/cast-connected.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let HardwareCastConnected = (props) => (
<SvgIcon {...props}>
<path d="M1 18v3h3c0-1.66-1.34-3-3-3zm0-4v2c2.76 0 5 2.24 5 5h2c0-3.87-3.13-7-7-7zm18-7H5v1.63c3.96 1.28 7.09 4.41 8.37 8.37H19V7zM1 10v2c4.97 0 9 4.03 9 9h2c0-6.08-4.93-11-11-11zm20-7H3c-1.1 0-2 .9-2 2v3h2V5h18v14h-7v2h7c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"/>
</SvgIcon>
);
HardwareCastConnected = pure(HardwareCastConnected);
HardwareCastConnected.displayName = 'HardwareCastConnected';
HardwareCastConnected.muiName = 'SvgIcon';
export default HardwareCastConnected;
|
chapter-12/express_server/src/Routes.js | mocheng/react-and-redux | import React from 'react';
import {Router, Route, IndexRoute, browserHistory} from 'react-router';
import {Provider} from 'react-redux';
import {combineReducers} from 'redux';
import {syncHistoryWithStore} from 'react-router-redux';
import App from './pages/App.js';
import store from './Store.js';
const createElement = (Component, props) => {
return (
<Provider store={store}>
<Component {...props} />
</Provider>
);
};
const getHomePage = (nextState, callback) => {
require.ensure([], function(require) {
callback(null, require('./pages/Home.js').default);
}, 'home');
};
const getAboutPage = (nextState, callback) => {
require.ensure([], function(require) {
callback(null, require('./pages/About.js').default);
}, 'about');
};
const getCounterPage = (nextState, callback) => {
require.ensure([], function(require) {
const {page, reducer, stateKey, initState} = require('./pages/CounterPage.js');
initState().then((result) => {
const state = store.getState();
store.reset(combineReducers({
...store._reducers,
counter: reducer
}), {
...state,
[stateKey]: result
});
callback(null, page);
});
}, 'counter');
};
const getNotFoundPage = (nextState, callback) => {
require.ensure([], function(require) {
callback(null, require('./pages/NotFound.js').default);
}, '404');
};
const history = syncHistoryWithStore(browserHistory, store);
//const history = browserHistory;
const routes = (
<Route path="/" component={App}>
<IndexRoute getComponent={getHomePage} />
<Route path="home" getComponent={getHomePage} />
<Route path="counter" getComponent={getCounterPage} />
<Route path="about" getComponent={getAboutPage} />
<Route path="*" getComponent={getNotFoundPage} />
</Route>
);
const Routes = () => (
<Router history={history} createElement={createElement}>
{routes}
</Router>
);
export default Routes;
|
src/container/DevTools.js | jerryshew/test-redux | import React from 'react';
import { createDevTools } from 'redux-devtools';
import LogMonitor from 'redux-devtools-log-monitor';
import DockMonitor from 'redux-devtools-dock-monitor';
export default createDevTools(
<DockMonitor toggleVisibilityKey='ctrl-h'
changePositionKey='ctrl-q'>
<LogMonitor />
</DockMonitor>
); |
admin/client/components/Popout/PopoutListItem.js | Tangcuyu/keystone | import React from 'react';
import blacklist from 'blacklist';
import classnames from 'classnames';
var PopoutListItem = React.createClass({
displayName: 'PopoutListItem',
propTypes: {
icon: React.PropTypes.string,
iconHover: React.PropTypes.string,
isSelected: React.PropTypes.bool,
label: React.PropTypes.string.isRequired,
onClick: React.PropTypes.func,
},
getInitialState () {
return {
hover: false,
};
},
hover () {
this.setState({ hover: true });
},
unhover () {
this.setState({ hover: false });
},
renderIcon () {
if (!this.props.icon) return null;
const icon = this.state.hover && this.props.iconHover ? this.props.iconHover : this.props.icon;
const iconClassname = classnames('PopoutList__item__icon octicon', ('octicon-' + icon));
return <span className={iconClassname} />;
},
render () {
const itemClassname = classnames('PopoutList__item', {
'is-selected': this.props.isSelected,
});
const props = blacklist(this.props, 'className', 'icon', 'isSelected', 'label');
return (
<button
type="button"
title={this.props.label}
className={itemClassname}
onFocus={this.hover}
onBlur={this.unhover}
onMouseOver={this.hover}
onMouseOut={this.unhover}
{...props}
>
{this.renderIcon()}
<span className="PopoutList__item__label">{this.props.label}</span>
</button>
);
},
});
module.exports = PopoutListItem;
|
example/src/components/Header.js | ethanselzer/react-lazy-tree | import React from 'react';
import { Navbar, Nav, NavItem } from 'react-bootstrap';
import npmLogo from '../images/npm-logo.png';
import githubLogo from '../images/github-logo.png';
import '../styles/header.css';
class Navigation extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedNavKey: 0
};
}
componentDidMount() {
const path = this.props.route.path;
this.setState({
selectedNavKey: this.getNavKeyByRoutePath(path)
})
}
getNavKeyByRoutePath(path) {
switch (path) {
case '/' :
return 1;
case '/Hamburger' :
return 2;
case '/Catalog*' :
return 3;
case '/Viewer' :
return 4;
default :
return 1;
}
}
render() {
return (
<Navbar inverse fixedTop>
<Navbar.Header>
<Navbar.Brand>
<a className="logo" href="#/">
<ReactLazyTree/>
</a>
</Navbar.Brand>
<Navbar.Toggle />
</Navbar.Header>
<Navbar.Collapse>
<Nav {...{activeKey: this.state.selectedNavKey}}>
<NavItem eventKey={1} href="#/">Home</NavItem>
<NavItem eventKey={2} href="#/Hamburger">Hamburger</NavItem>
<NavItem eventKey={3} href="#/Catalog/Women/Clothing/Dresses/Work">Category</NavItem>
<NavItem eventKey={4} href="#/Viewer">Viewer</NavItem>
</Nav>
<Nav pullRight>
<NavItem
eventKey={1}
className="github-link"
href="https://github.com/ethanselzer/react-lazy-tree"
>
<img src={githubLogo} alt="GitHub Logo" />
</NavItem>
<NavItem
eventKey={2}
href="https://www.npmjs.com/package/react-lazy-tree"
className="npm-link"
>
<img src={npmLogo} alt="NPM Logo" />
</NavItem>
</Nav>
</Navbar.Collapse>
</Navbar>
);
}
}
export default Navigation;
|
hapiApp/source/index.js | raydecastro/example-above-the-fold-hapijs | import 'babel-polyfill';
import React from 'react';
import { render } from 'react-dom';
import configureStore from './store/configureStore';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
import './styles/styles.css';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
const store = configureStore();
render(
<Provider store={store}>
<Router history={browserHistory} routes={routes} />
</Provider>,
document.getElementById('app')
); |
src/svg-icons/editor/strikethrough-s.js | pradel/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorStrikethroughS = (props) => (
<SvgIcon {...props}>
<path d="M7.24 8.75c-.26-.48-.39-1.03-.39-1.67 0-.61.13-1.16.4-1.67.26-.5.63-.93 1.11-1.29.48-.35 1.05-.63 1.7-.83.66-.19 1.39-.29 2.18-.29.81 0 1.54.11 2.21.34.66.22 1.23.54 1.69.94.47.4.83.88 1.08 1.43.25.55.38 1.15.38 1.81h-3.01c0-.31-.05-.59-.15-.85-.09-.27-.24-.49-.44-.68-.2-.19-.45-.33-.75-.44-.3-.1-.66-.16-1.06-.16-.39 0-.74.04-1.03.13-.29.09-.53.21-.72.36-.19.16-.34.34-.44.55-.1.21-.15.43-.15.66 0 .48.25.88.74 1.21.38.25.77.48 1.41.7H7.39c-.05-.08-.11-.17-.15-.25zM21 12v-2H3v2h9.62c.18.07.4.14.55.2.37.17.66.34.87.51.21.17.35.36.43.57.07.2.11.43.11.69 0 .23-.05.45-.14.66-.09.2-.23.38-.42.53-.19.15-.42.26-.71.35-.29.08-.63.13-1.01.13-.43 0-.83-.04-1.18-.13s-.66-.23-.91-.42c-.25-.19-.45-.44-.59-.75-.14-.31-.25-.76-.25-1.21H6.4c0 .55.08 1.13.24 1.58.16.45.37.85.65 1.21.28.35.6.66.98.92.37.26.78.48 1.22.65.44.17.9.3 1.38.39.48.08.96.13 1.44.13.8 0 1.53-.09 2.18-.28s1.21-.45 1.67-.79c.46-.34.82-.77 1.07-1.27s.38-1.07.38-1.71c0-.6-.1-1.14-.31-1.61-.05-.11-.11-.23-.17-.33H21z"/>
</SvgIcon>
);
EditorStrikethroughS = pure(EditorStrikethroughS);
EditorStrikethroughS.displayName = 'EditorStrikethroughS';
export default EditorStrikethroughS;
|
examples/todos-with-undo/index.js | omnidan/redux | import React from 'react';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import App from './containers/App';
import todoApp from './reducers';
const store = createStore(todoApp);
const rootElement = document.getElementById('root');
React.render(
// The child must be wrapped in a function
// to work around an issue in React 0.13.
<Provider store={store}>
{() => <App />}
</Provider>,
rootElement
);
|
src/containers/react-css-themr.js | steplov/storybook-addon-themr | import React from 'react';
import PropTypes from 'prop-types';
import { ThemeProvider } from 'react-css-themr';
import { EVENT_ID_INIT, EVENT_ID_DATA } from '../';
class ReactCSSThemr extends React.Component {
constructor(props) {
super(props);
this.onReceiveData = this.onReceiveData.bind(this);
this.state = {
currentTheme: Object.keys(props.themes)[0],
isReady: false
};
this.props.channel.on(EVENT_ID_DATA, this.onReceiveData);
this.props.channel.emit(EVENT_ID_INIT, {
themes: this.props.themes,
currentTheme: this.state.currentTheme
});
}
componentWillUnmount() {
this.props.channel.removeListener(EVENT_ID_DATA, this.onReceiveData);
}
onReceiveData(data) {
this.setState({
isReady: true,
currentTheme: data.currentTheme
});
}
render() {
const { story, themes } = this.props;
const { currentTheme, isReady } = this.state;
return (
isReady ?
<ThemeProvider
key={currentTheme}
theme={themes[currentTheme]}
>
{story}
</ThemeProvider> :
story
);
}
}
ReactCSSThemr.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
themes: PropTypes.object.isRequired,
channel: PropTypes.shape({
on: PropTypes.func.isRequired,
removeListener: PropTypes.func.isRequired,
emit: PropTypes.func.isRequired
}).isRequired,
story: PropTypes.node.isRequired
};
export default ReactCSSThemr;
|
app/src/components/ControlPanel/Knob.js | civa86/electrophone | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import $ from 'jquery';
import knob from 'jquery-knob';
class Knob extends Component {
componentDidMount () {
const
node = $(ReactDOM.findDOMNode(this)),
{ property, module, onUpdate } = this.props;
node.find('input').knob({
min: property.bounds[0] || 0,
max: property.bounds[1] || 0,
step: property.step || 1,
fgColor: '#46bcec',
bgColor: '#ccc',
change: (value) => onUpdate(module, property.name, value)
});
node.find('input').val(property.value).trigger('change');
node.find('input').on('keyup', () => onUpdate(module, property.name, +node.find('input').val()));
}
componentWillReceiveProps (newProps) {
const
node = $(ReactDOM.findDOMNode(this)),
{ property } = newProps;
node.find('input')
.val(property.value)
.trigger('change');
}
render () {
const { property } = this.props;
return (
<div style={{ width: '80px', height: '80px', margin: '0 auto' }}>
<div style={{ textAlign: 'center' }}>{property.name.toUpperCase()}</div>
<input type="text"
data-width="80"
data-height="80"
data-skin="tron"
data-thickness=".3"
data-anglearc="250"
data-angleoffset="-125"/>
</div>
);
}
}
export default Knob;
|
webpack/scenes/Subscriptions/components/SubscriptionsToolbar/SubscriptionsToolbar.js | cfouant/katello | import React from 'react';
import PropTypes from 'prop-types';
import { Row, Col, Form, FormGroup, Button } from 'patternfly-react';
import { LinkContainer } from 'react-router-bootstrap';
import { noop } from 'foremanReact/common/helpers';
import Search from '../../../../components/Search/index';
import TooltipButton from '../../../../move_to_pf/TooltipButton';
import OptionTooltip from '../../../../move_to_pf/OptionTooltip';
const SubscriptionsToolbar = ({
disableManifestActions,
disableManifestReason,
disableDeleteButton,
disableDeleteReason,
disableAddButton,
getAutoCompleteParams,
updateSearchQuery,
onDeleteButtonClick,
onSearch,
onManageManifestButtonClick,
onExportCsvButtonClick,
tableColumns,
toolTipOnChange,
toolTipOnclose,
}) => (
<Row className="toolbar-pf table-view-pf-toolbar-external">
<Col sm={12}>
<Form className="toolbar-pf-actions">
<FormGroup className="toolbar-pf-filter">
<Search
onSearch={onSearch}
getAutoCompleteParams={getAutoCompleteParams}
updateSearchQuery={updateSearchQuery}
/>
</FormGroup>
<div className="option-tooltip-container">
<OptionTooltip options={tableColumns} icon="fa-columns" id="subscriptionTableTooltip" onChange={toolTipOnChange} onClose={toolTipOnclose} />
</div>
<div className="toolbar-pf-action-right">
<FormGroup>
<LinkContainer
to="subscriptions/add"
disabled={disableManifestActions || disableAddButton}
>
<TooltipButton
tooltipId="add-subscriptions-button-tooltip"
tooltipText={disableManifestReason}
tooltipPlacement="top"
title={__('Add Subscriptions')}
disabled={disableManifestActions}
bsStyle="primary"
/>
</LinkContainer>
<Button onClick={onManageManifestButtonClick}>
{__('Manage Manifest')}
</Button>
<Button
onClick={onExportCsvButtonClick}
>
{__('Export CSV')}
</Button>
<TooltipButton
bsStyle="danger"
onClick={onDeleteButtonClick}
tooltipId="delete-subscriptions-button-tooltip"
tooltipText={disableDeleteReason}
tooltipPlacement="top"
title={__('Delete')}
disabled={disableManifestActions || disableDeleteButton}
/>
</FormGroup>
</div>
</Form>
</Col>
</Row>
);
SubscriptionsToolbar.propTypes = {
...Search.propTypes,
tableColumns: OptionTooltip.propTypes.options,
disableManifestActions: PropTypes.bool,
disableManifestReason: PropTypes.string,
disableDeleteButton: PropTypes.bool,
disableDeleteReason: PropTypes.string,
disableAddButton: PropTypes.bool,
onDeleteButtonClick: PropTypes.func,
onManageManifestButtonClick: PropTypes.func,
onExportCsvButtonClick: PropTypes.func,
toolTipOnChange: PropTypes.func,
toolTipOnclose: PropTypes.func,
};
SubscriptionsToolbar.defaultProps = {
...Search.defaultProps,
tableColumns: [],
disableManifestActions: false,
disableManifestReason: '',
disableDeleteButton: false,
disableDeleteReason: '',
disableAddButton: false,
onDeleteButtonClick: noop,
onManageManifestButtonClick: noop,
onExportCsvButtonClick: noop,
toolTipOnChange: noop,
toolTipOnclose: noop,
};
export default SubscriptionsToolbar;
|
src/parser/hunter/beastmastery/modules/features/AlwaysBeCasting.js | FaideWW/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import { formatPercentage } from 'common/format';
import SpellLink from 'common/SpellLink';
import CoreAlwaysBeCasting from 'parser/shared/modules/AlwaysBeCasting';
class AlwaysBeCasting extends CoreAlwaysBeCasting {
get suggestionThresholds() {
return {
actual: this.activeTimePercentage,
isLessThan: {
minor: 0.85,
average: 0.8,
major: 0.775,
},
style: 'percentage',
};
}
suggestions(when) {
when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
return suggest(
<>Your downtime can be improved. Try to reduce the delay between casting spells. If everything is on cooldown, try and use <SpellLink id={SPELLS.COBRA_SHOT.id} /> to stay off the focus cap and do some damage.
</>)
.icon('spell_mage_altertime')
.actual(`${formatPercentage(1 - actual)}% downtime`)
.recommended(`<${formatPercentage(1 - recommended)}% is recommended`);
});
}
}
export default AlwaysBeCasting;
|
packages/react-error-overlay/src/components/CodeBlock.js | Bogala/create-react-app-awesome-ts | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/* @flow */
import React from 'react';
import { redTransparent, yellowTransparent } from '../styles';
const _preStyle = {
display: 'block',
padding: '0.5em',
marginTop: '0.5em',
marginBottom: '0.5em',
overflowX: 'auto',
whiteSpace: 'pre-wrap',
borderRadius: '0.25rem',
};
const primaryPreStyle = {
..._preStyle,
backgroundColor: redTransparent,
};
const secondaryPreStyle = {
..._preStyle,
backgroundColor: yellowTransparent,
};
const codeStyle = {
fontFamily: 'Consolas, Menlo, monospace',
};
type CodeBlockPropsType = {|
main: boolean,
codeHTML: string,
|};
function CodeBlock(props: CodeBlockPropsType) {
const preStyle = props.main ? primaryPreStyle : secondaryPreStyle;
const codeBlock = { __html: props.codeHTML };
return (
<pre style={preStyle}>
<code style={codeStyle} dangerouslySetInnerHTML={codeBlock} />
</pre>
);
}
export default CodeBlock;
|
client/src/app/components/Footer.js | lefnire/jobs | import React from 'react';
import {
Jumbotron
} from 'react-bootstrap';
export default class Footer extends React.Component {
render() {
return (
<Jumbotron className="footer">
<ul className='footer-links'>
<li>
<a href="/blog.html">Blog</a>
</li>
<li>
<a href="mailto:[email protected]">Contact Us</a>
</li>
<li >
<a href="https://github.com/lefnire/jobpig" >Fork on GitHub</a>
{/*<iframe src="https://ghbtns.com/github-btn.html?user=lefnire&repo=jobpig&type=fork&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>*/}
</li>
<li>
<a href="//www.iubenda.com/privacy-policy/7841505" className="iubenda-black iub-legal-only iubenda-embed" title="Privacy Policy">Privacy Policy</a>
</li>
<li>
<a href="http://www.freepik.com/free-photos-vectors/animal">Animal vector designed by Freepik</a>
</li>
</ul>
</Jumbotron>
);
}
}
|
src/svg-icons/hardware/laptop-chromebook.js | pomerantsev/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let HardwareLaptopChromebook = (props) => (
<SvgIcon {...props}>
<path d="M22 18V3H2v15H0v2h24v-2h-2zm-8 0h-4v-1h4v1zm6-3H4V5h16v10z"/>
</SvgIcon>
);
HardwareLaptopChromebook = pure(HardwareLaptopChromebook);
HardwareLaptopChromebook.displayName = 'HardwareLaptopChromebook';
HardwareLaptopChromebook.muiName = 'SvgIcon';
export default HardwareLaptopChromebook;
|
src/main/app/scripts/views/Todo.js | ondrejhudek/pinboard | import React from 'react'
import { connect } from 'react-redux'
import AddTodo from '../containers/todo/AddTodo'
import Todos from '../components/todo/Todos'
import { fetchTodos } from '../actions/todos'
let fetched = false
class TodoView extends React.Component {
constructor(props) {
super(props)
this.state = {
dispatch: props.dispatch
}
}
componentWillMount() {
if (!fetched) {
this.state.dispatch(fetchTodos())
fetched = true
}
}
render() {
return (
<div className="view-todo">
<h2>Todo lists</h2>
<AddTodo />
<Todos />
</div>
)
}
}
TodoView = connect()(TodoView)
export default TodoView
|
src/parser/shared/modules/features/STAT.js | yajinni/WoWAnalyzer | import React from 'react';
import { Trans } from '@lingui/macro';
import HealthIcon from 'interface/icons/Health';
import StaminaIcon from 'interface/icons/Stamina';
import ManaIcon from 'interface/icons/Mana';
import StrengthIcon from 'interface/icons/Strength';
import AgilityIcon from 'interface/icons/Agility';
import IntellectIcon from 'interface/icons/Intellect';
import CriticalStrikeIcon from 'interface/icons/CriticalStrike';
import HasteIcon from 'interface/icons/Haste';
import MasteryIcon from 'interface/icons/Mastery';
import VersatilityIcon from 'interface/icons/Versatility';
import LeechIcon from 'interface/icons/Leech';
import AvoidanceIcon from 'interface/icons/Avoidance';
import SpeedIcon from 'interface/icons/Speed';
const STAT = {
HEALTH: 'health',
STAMINA: 'stamina',
MANA: 'mana',
STRENGTH: 'strength',
AGILITY: 'agility',
INTELLECT: 'intellect',
CRITICAL_STRIKE: 'criticalstrike',
HASTE: 'haste',
HASTE_HPCT: 'hastehpct',
HASTE_HPM: 'hastehpm',
MASTERY: 'mastery',
VERSATILITY: 'versatility',
VERSATILITY_DR: 'versatilitydr',
LEECH: 'leech',
AVOIDANCE: 'avoidance',
SPEED: 'speed',
};
export default STAT;
export function getName(stat) {
switch (stat) {
case STAT.HEALTH: return 'Health';
case STAT.STAMINA: return 'Stamina';
case STAT.MANA: return 'Mana';
case STAT.STRENGTH: return 'Strength';
case STAT.AGILITY: return 'Agility';
case STAT.INTELLECT: return 'Intellect';
case STAT.CRITICAL_STRIKE: return 'Critical Strike';
case STAT.HASTE: return 'Haste';
case STAT.HASTE_HPCT: return 'Haste (HPCT)';
case STAT.HASTE_HPM: return 'Haste (HPM)';
case STAT.MASTERY: return 'Mastery';
case STAT.VERSATILITY: return 'Versatility';
case STAT.VERSATILITY_DR: return 'Versatility (with DR)';
case STAT.LEECH: return 'Leech';
case STAT.AVOIDANCE: return 'Avoidance';
case STAT.SPEED: return 'Speed';
default: return null;
}
}
export function getNameTranslated(stat) { // there's stuff using getName with string functions which Trans breaks
switch (stat) {
case STAT.HEALTH: return <Trans id="common.stat.health">Health</Trans>;
case STAT.STAMINA: return <Trans id="common.stat.stamina">Stamina</Trans>;
case STAT.MANA: return <Trans id="common.stat.mana">Mana</Trans>;
case STAT.STRENGTH: return <Trans id="common.stat.strength">Strength</Trans>;
case STAT.AGILITY: return <Trans id="common.stat.agility">Agility</Trans>;
case STAT.INTELLECT: return <Trans id="common.stat.intellect">Intellect</Trans>;
case STAT.CRITICAL_STRIKE: return <Trans id="common.stat.criticalStrike">Critical Strike</Trans>;
case STAT.HASTE: return <Trans id="common.stat.haste">Haste</Trans>;
case STAT.HASTE_HPCT: return <Trans id="common.stat.hasteHPCT">Haste (HPCT)</Trans>;
case STAT.HASTE_HPM: return <Trans id="common.stat.hasteHPM">Haste (HPM)</Trans>;
case STAT.MASTERY: return <Trans id="common.stat.mastery">Mastery</Trans>;
case STAT.VERSATILITY: return <Trans id="common.stat.versatility">Versatility</Trans>;
case STAT.VERSATILITY_DR: return <Trans id="common.stat.versatilityDR">Versatility (with DR)</Trans>;
case STAT.LEECH: return <Trans id="common.stat.leech">Leech</Trans>;
case STAT.AVOIDANCE: return <Trans id="common.stat.avoidance">Avoidance</Trans>;
case STAT.SPEED: return <Trans id="common.stat.speed">Speed</Trans>;
default: return null;
}
}
export function getClassNameColor(stat) {
switch (stat) {
case STAT.HEALTH: return 'stat-health';
case STAT.STAMINA: return 'stat-stamina';
case STAT.MANA: return 'stat-mana';
case STAT.STRENGTH: return 'stat-strength';
case STAT.AGILITY: return 'stat-agility';
case STAT.INTELLECT: return 'stat-intellect';
case STAT.CRITICAL_STRIKE: return 'stat-criticalstrike';
case STAT.HASTE: return 'stat-haste';
case STAT.HASTE_HPCT: return 'stat-haste';
case STAT.HASTE_HPM: return 'stat-haste';
case STAT.MASTERY: return 'stat-mastery';
case STAT.VERSATILITY: return 'stat-versatility';
case STAT.VERSATILITY_DR: return 'stat-versatility';
case STAT.LEECH: return 'stat-leech';
case STAT.AVOIDANCE: return 'stat-avoidance';
case STAT.SPEED: return 'stat-speed';
default: return null;
}
}
export function getClassNameBackgroundColor(stat) {
return `${getClassNameColor(stat)}-bg`;
}
export function getIcon(stat) {
switch (stat) {
case STAT.HEALTH: return HealthIcon;
case STAT.STAMINA: return StaminaIcon;
case STAT.MANA: return ManaIcon;
case STAT.STRENGTH: return StrengthIcon;
case STAT.AGILITY: return AgilityIcon;
case STAT.INTELLECT: return IntellectIcon;
case STAT.CRITICAL_STRIKE: return CriticalStrikeIcon;
case STAT.HASTE: return HasteIcon;
case STAT.HASTE_HPCT: return HasteIcon;
case STAT.HASTE_HPM: return HasteIcon;
case STAT.MASTERY: return MasteryIcon;
case STAT.VERSATILITY: return VersatilityIcon;
case STAT.VERSATILITY_DR: return VersatilityIcon;
case STAT.LEECH: return LeechIcon;
case STAT.AVOIDANCE: return AvoidanceIcon;
case STAT.SPEED: return SpeedIcon;
default: return null;
}
}
|
P/bucket/src/pages/Login.js | imuntil/React | import React from 'react'
// import HomeLayout from '../layouts/HomeLayout'
// import FormItem from '../components/FormItem'
import {post} from '../utils/request'
// import formProvider from '../utils/formProvider'
import { Icon, Form, Input, Button, message } from 'antd'
import styles from './Login.less'
const FormItem = Form.Item
class Login extends React.Component {
handleSubmit (e) {
e.preventDefault()
const {history, form} = this.props
form.validateFields((err, values) => {
if (!err) {
post('http://localhost:3000/login', {
account: account.value,
password: password.value
})
.then(res => {
if (res) {
history.push('/')
} else {
alert('登录失败')
}
})
}
})
}
render () {
const {form} = this.props
const {getFieldDecorator} = form
return (
<div className={styles.wrapper}>
<div className={styles.body}>
<header className={styles.header}>
ReactManager
</header>
<section className={styles.form}>
<Form onSubmit={this.handleSubmit.bind(this)}>
<FormItem>
{getFieldDecorator('account', {
rules: [
{
required: true,
message: '请输入管理员账号',
type: 'string'
}
]
})(
<Input type="text" addonBefore={<Icon type="user"/>}/>
)}
</FormItem>
<FormItem>
{getFieldDecorator('password', {
rules: [
{
required: true,
message: '请输入密码',
type: 'string'
}
]
})(
<Input type="password" addonBefore={<Icon type="lock" />}/>
)}
</FormItem>
<Button className={styles.btn} type="primary" htmlType="submit">Sign In</Button>
</Form>
</section>
</div>
</div>
)
}
}
Login = Form.create()(Login)
export default Login |
src/svg-icons/maps/directions-bike.js | barakmitz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsDirectionsBike = (props) => (
<SvgIcon {...props}>
<path d="M15.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM5 12c-2.8 0-5 2.2-5 5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0 8.5c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5 3.5 1.6 3.5 3.5-1.6 3.5-3.5 3.5zm5.8-10l2.4-2.4.8.8c1.3 1.3 3 2.1 5.1 2.1V9c-1.5 0-2.7-.6-3.6-1.5l-1.9-1.9c-.5-.4-1-.6-1.6-.6s-1.1.2-1.4.6L7.8 8.4c-.4.4-.6.9-.6 1.4 0 .6.2 1.1.6 1.4L11 14v5h2v-6.2l-2.2-2.3zM19 12c-2.8 0-5 2.2-5 5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0 8.5c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5 3.5 1.6 3.5 3.5-1.6 3.5-3.5 3.5z"/>
</SvgIcon>
);
MapsDirectionsBike = pure(MapsDirectionsBike);
MapsDirectionsBike.displayName = 'MapsDirectionsBike';
MapsDirectionsBike.muiName = 'SvgIcon';
export default MapsDirectionsBike;
|
src/components/ContainerProgress.react.js | phnz/kitematic | import React from 'react';
/*
Usage: <ContainerProgress pBar1={20} pBar2={70} pBar3={100} pBar4={20} />
*/
var ContainerProgress = React.createClass({
render: function () {
var pBar1Style = {
height: this.props.pBar1 + '%'
};
var pBar2Style = {
height: this.props.pBar2 + '%'
};
var pBar3Style = {
height: this.props.pBar3 + '%'
};
var pBar4Style = {
height: this.props.pBar4 + '%'
};
return (
<div className="container-progress">
<div className="bar-1 bar-bg">
<div className="bar-fg" style={pBar4Style}></div>
</div>
<div className="bar-2 bar-bg">
<div className="bar-fg" style={pBar3Style}></div>
</div>
<div className="bar-3 bar-bg">
<div className="bar-fg" style={pBar2Style}></div>
</div>
<div className="bar-4 bar-bg">
<div className="bar-fg" style={pBar1Style}></div>
</div>
</div>
);
}
});
module.exports = ContainerProgress;
|
examples/forms-material-ui/src/components/dialogs/Layout.js | lore/lore-forms | import React from 'react';
import createReactClass from 'create-react-class';
import { Drawer, AppBar } from 'material-ui';
import List from '../_common/List';
import PayloadStates from '../../constants/PayloadStates';
export default createReactClass({
displayName: 'Layout',
componentDidMount: function() {
window.scrollTo(0, 0);
},
onClick(tweet) {
const { router, route } = this.props;
router.push(`/${route}/${tweet.id}`);
},
render: function() {
const { title } = this.props;
return (
<div>
<div style={{ paddingLeft: '256px' }}>
<AppBar
title={title || 'Dialogs'}
showMenuIconButton={false}
/>
</div>
<div className="container-fluid" style={{ paddingTop: '15px', paddingLeft: '30px', paddingRight: '30px' }}>
<div style={{paddingLeft: '256px'}}>
<div className="row">
<div style={{ paddingLeft: '15px', paddingRight: '15px', width: 'calc(100% - 300px)'}}>
{React.cloneElement(this.props.children)}
</div>
<Drawer width={300} openSecondary={true} open={true} >
<AppBar
title="Tweets"
showMenuIconButton={false}
/>
<List onClick={this.onClick} />
</Drawer>
</div>
</div>
</div>
</div>
);
}
});
|
src/modules/comments/components/CommentEditor/CommentersInput/CommentersInput.js | CtrHellenicStudies/Commentary | import React from 'react';
import { compose } from 'react-apollo';
import Select from 'react-select';
import autoBind from 'react-autobind';
import commentersQuery from '../../../../commenters/graphql/queries/list';
class CommentersInput extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedOption: null,
};
autoBind(this);
}
handleChange(selectedOption) {
this.setState({ selectedOption });
}
render() {
const { commentersQuery } = this.props;
const { selectedOption } = this.state;
const options = [];
let commenters = [];
if (commentersQuery && commentersQuery.commenters) {
commenters = commentersQuery.commenters;
}
commenters.forEach(commenter => {
options.push({
value: commenter._id,
label: commenter.name,
});
});
return (
<div className="commentersInput">
<Select
value={selectedOption}
onChange={this.handleChange}
options={options}
multi
/>
</div>
);
}
}
export default compose(
commentersQuery,
)(CommentersInput);
|
node_modules/react-router/es6/RouteContext.js | captify-iolenchenko/leaderboard | import warning from './routerWarning';
import React from 'react';
var object = React.PropTypes.object;
/**
* The RouteContext mixin provides a convenient way for route
* components to set the route in context. This is needed for
* routes that render elements that want to use the Lifecycle
* mixin to prevent transitions.
*/
var RouteContext = {
propTypes: {
route: object.isRequired
},
childContextTypes: {
route: object.isRequired
},
getChildContext: function getChildContext() {
return {
route: this.props.route
};
},
componentWillMount: function componentWillMount() {
process.env.NODE_ENV !== 'production' ? warning(false, 'The `RouteContext` mixin is deprecated. You can provide `this.props.route` on context with your own `contextTypes`. http://tiny.cc/router-routecontextmixin') : void 0;
}
};
export default RouteContext; |
src/SearchBar.js | umhan35/react-native-search-bar | import React from 'react';
import PropTypes from 'prop-types';
import {
NativeModules,
requireNativeComponent,
findNodeHandle,
} from 'react-native';
const RNSearchBar = requireNativeComponent('RNSearchBar', null);
class SearchBar extends React.PureComponent {
static propTypes = {
placeholder: PropTypes.string,
text: PropTypes.string,
barTintColor: PropTypes.string,
tintColor: PropTypes.string,
textColor: PropTypes.string,
textFieldBackgroundColor: PropTypes.string,
cancelButtonText: PropTypes.string,
showsCancelButton: PropTypes.bool,
onChange: PropTypes.func,
onChangeText: PropTypes.func,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onSearchButtonPress: PropTypes.func,
onCancelButtonPress: PropTypes.func,
enablesReturnKeyAutomatically: PropTypes.bool,
hideBackground: PropTypes.bool,
keyboardType: PropTypes.oneOf([
// Cross-platform
'default',
'email-address',
'numeric',
'phone-pad',
// iOS-only
'ascii-capable',
'numbers-and-punctuation',
'url',
'number-pad',
'name-phone-pad',
'decimal-pad',
'twitter',
'web-search',
]),
keyboardAppearance: PropTypes.oneOf(['default', 'light', 'dark']),
autoCapitalize: PropTypes.oneOf([
'none',
'words',
'sentences',
'characters',
]),
autoCorrect: PropTypes.bool,
spellCheck: PropTypes.bool,
barStyle: PropTypes.oneOf(['default', 'black']),
searchBarStyle: PropTypes.oneOf(['default', 'prominent', 'minimal']),
editable: PropTypes.bool,
returnKeyType: PropTypes.string,
showsCancelButtonWhileEditing: PropTypes.bool,
};
static defaultProps = {
text: '',
placeholder: 'Search',
barStyle: 'default',
searchBarStyle: 'default',
editable: true,
cancelButtonText: 'Cancel',
showsCancelButton: false,
hideBackground: false,
enablesReturnKeyAutomatically: true,
textFieldBackgroundColor: null,
tintColor: null,
barTintColor: null,
textColor: null,
returnKeyType: 'search',
keyboardType: 'default',
keyboardAppearance: 'default',
autoCapitalize: 'sentences',
autoCorrect: false,
spellCheck: false,
showsCancelButtonWhileEditing: true,
onChange: () => null,
onChangeText: () => null,
onFocus: () => null,
onBlur: () => null,
onSearchButtonPress: () => null,
onCancelButtonPress: () => null,
};
onChange = e => {
this.props.onChange(e);
this.props.onChangeText(e.nativeEvent.text);
};
onSearchButtonPress = e => {
this.props.onSearchButtonPress(e.nativeEvent.searchText);
};
onFocus = () => {
if (this.props.showsCancelButtonWhileEditing) {
NativeModules.RNSearchBarManager.toggleCancelButton(
findNodeHandle(this),
true
);
}
this.props.onFocus();
};
onCancelButtonPress = () => {
if (this.props.showsCancelButtonWhileEditing) {
NativeModules.RNSearchBarManager.toggleCancelButton(
findNodeHandle(this),
false
);
}
this.props.onChangeText('');
this.props.onCancelButtonPress();
};
onBlur = () => {
if (this.props.showsCancelButtonWhileEditing) {
NativeModules.RNSearchBarManager.toggleCancelButton(
findNodeHandle(this),
false
);
}
this.props.onBlur();
};
blur() {
return NativeModules.RNSearchBarManager.blur(findNodeHandle(this));
}
focus() {
return NativeModules.RNSearchBarManager.focus(findNodeHandle(this));
}
clearText() {
return NativeModules.RNSearchBarManager.clearText(findNodeHandle(this));
}
unFocus() {
return NativeModules.RNSearchBarManager.unFocus(findNodeHandle(this));
}
render() {
return (
<RNSearchBar
style={{ height: NativeModules.RNSearchBarManager.ComponentHeight }}
{...this.props}
onChange={this.onChange}
onPress={this.onPress}
onFocus={this.onFocus}
onBlur={this.onBlur}
onSearchButtonPress={this.onSearchButtonPress}
onCancelButtonPress={this.onCancelButtonPress}
/>
);
}
}
export default SearchBar;
|
src/home-component.js | Clemson-University-Energizer/energizer-app |
import React from 'react';
const HomeComponent = () => (
<div className="row">
<div className="col text-center"><h2>Welcome to Energizer!</h2></div>
</div>
);
export default HomeComponent;
|
js/jqwidgets/demos/react/app/knob/infiniteknob/app.js | luissancheza/sice | import React from 'react';
import ReactDOM from 'react-dom';
import JqxKnob from '../../../jqwidgets-react/react_jqxknob.js';
class App extends React.Component {
componentDidMount() {
let lastValue;
let newValue = 0;
let min = 0;
let max = 100;
this.refs.myKnob.on('change', (event) => {
lastValue = newValue;
newValue = event.args.value;
if (newValue >= min && newValue <= min + 10 && lastValue <= max && lastValue >= max - 10) {
min = max;
max += 100;
this.refs.myKnob.setOptions({ value: max, max: max, min: min });
} else if (newValue >= max - 10 && newValue <= max && lastValue >= min && lastValue <= min + 10) {
max = min;
min -= 100;
this.refs.myKnob.setOptions({ value: min, min: min, max: max });
}
});
}
render() {
let style = {
stroke: '#dfe3e9',
strokeWidth: 3,
fill: {
color: '#fefefe', gradientType: 'linear',
gradientStops: [[0, 1], [50, 0.9], [100, 1]]
}
};
let marks = {
colorRemaining: '#333',
colorProgress: '#333',
type: 'line',
offset: '71%',
thickness: 1,
size: '6%',
majorSize: '9%',
majorInterval: 10,
minorInterval: 2
};
let labels = {
offset: '88%',
step: 10
};
let progressBar = {
style: { fill: { color: '#00a644', gradientType: 'linear', gradientStops: [[0, 1], [50, 0.9], [100, 1]] }, stroke: '#00a644' },
background: { fill: { color: '#ff8b1e', gradientType: 'linear', gradientStops: [[0, 1], [50, 0.9], [100, 1]] }, stroke: '#ff8b1e' },
size: '9%',
offset: '60%'
};
let pointer = {
type: 'circle',
style: { fill: '#ef6100', stroke: '#ef6100' },
size: '5%',
offset: '38%',
thickness: 20
};
let spinner =
{
style: { fill: { color: '#00a4e1', gradientType: 'linear', gradientStops: [[0, 1], [50, 0.9], [100, 1]] }, stroke: '#00a4e1' },
innerRadius: '45%', // specifies the inner Radius of the dial
outerRadius: '60%', // specifies the outer Radius of the dial
marks: {
colorRemaining: '#fff',
colorProgress: '#fff',
type: 'line',
offset: '46%',
thickness: 2,
size: '14%',
majorSize: '14%',
majorInterval: 10,
minorInterval: 10
}
};
let dial =
{
style: { fill: { color: '#dfe3e9', gradientType: 'linearHorizontal', gradientStops: [[0, 0.9], [50, 1], [100, 1]] }, stroke: '#dfe3e9' },
innerRadius: '0%', // specifies the inner Radius of the dial
outerRadius: '45%'
};
return (
<JqxKnob ref='myKnob'
min={0} max={100} value={60} startAngle={150} endAngle={510}
rotation={'clockwise'} snapToStep={true} spinner={spinner}
style={style} marks={marks} labels={labels} dial={dial}
progressBar={progressBar} pointer={pointer}
/>
)
}
}
ReactDOM.render(<App />, document.getElementById('app'));
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.