path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
Realization/frontend/czechidm-example/src/content/example-product/ExampleProductRoute.js | bcvsolutions/CzechIdMng | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
//
import { Basic, Advanced } from 'czechidm-core';
import { ExampleProductManager } from '../../redux';
const manager = new ExampleProductManager();
/**
* ExampleProduct detail with tabs
*
* @author Radek Tomiška
*/
class ExampleProductRoute extends Basic.AbstractContent {
componentDidMount() {
const { entityId } = this.props.match.params;
// load entity from BE - for nice labels etc.
this.context.store.dispatch(manager.fetchEntityIfNeeded(entityId));
}
render() {
const { entity, showLoading } = this.props;
//
return (
<Basic.Div>
<Advanced.DetailHeader
showLoading={ showLoading }
icon="link"
entity={ entity }
back="/example/products">
{ this.i18n('example:content.example-product.detail.edit.header', { name: manager.getNiceLabel(entity), escape: false }) }
</Advanced.DetailHeader>
<Advanced.TabPanel parentId="example-products" match={ this.props.match }>
{ this.getRoutes() }
</Advanced.TabPanel>
</Basic.Div>
);
}
}
ExampleProductRoute.propTypes = {
entity: PropTypes.instanceOf(PropTypes.object),
showLoading: PropTypes.bool
};
ExampleProductRoute.defaultProps = {
entity: null,
showLoading: false
};
function select(state, component) {
const { entityId } = component.match.params;
return {
entity: manager.getEntity(state, entityId),
showLoading: manager.isShowLoading(state, null, entityId)
};
}
export default connect(select)(ExampleProductRoute);
|
app/containers/ColioApp.js | oeb25/colio | import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'redux/react';
import { Snackbar } from 'material-ui';
import RoomContainer from '../containers/RoomContainer';
import LandingContainer from '../containers/LandingContainer';
import * as RoomActions from '../actions/RoomActions';
@connect(state => ({
isInRoom: !!state.room
}))
export default class ColioApp {
render() {
const { isInRoom, dispatch } = this.props;
return (
<div>
{isInRoom ?
<RoomContainer />
:
<LandingContainer />
}
</div>
);
}
}
|
app/javascript/mastodon/main.js | TheInventrix/mastodon | import * as registerPushNotifications from './actions/push_notifications';
import { default as Mastodon, store } from './containers/mastodon';
import React from 'react';
import ReactDOM from 'react-dom';
import ready from './ready';
const perf = require('./performance');
function main() {
perf.start('main()');
if (window.history && history.replaceState) {
const { pathname, search, hash } = window.location;
const path = pathname + search + hash;
if (!(/^\/web[$/]/).test(path)) {
history.replaceState(null, document.title, `/web${path}`);
}
}
ready(() => {
const mountNode = document.getElementById('mastodon');
const props = JSON.parse(mountNode.getAttribute('data-props'));
ReactDOM.render(<Mastodon {...props} />, mountNode);
if (process.env.NODE_ENV === 'production') {
// avoid offline in dev mode because it's harder to debug
require('offline-plugin/runtime').install();
store.dispatch(registerPushNotifications.register());
}
perf.stop('main()');
});
}
export default main;
|
src/charts/line/Line.js | jchen-eb/britecharts-react | import React from 'react';
import PropTypes from 'prop-types';
import line from './lineChart';
import {loadingContainerWrapper} from '../loading/LoadingContainer';
class Line extends React.Component {
static propTypes = {
/**
* Internally used, do not overwrite.
*/
data: PropTypes.object,
/**
* Exposes the constants to be used to force the x axis to respect a
* certain granularity current options: MINUTE_HOUR, HOUR_DAY, DAY_MONTH, MONTH_YEAR
*/
axisTimeCombinations: PropTypes.number,
/**
* Gets or Sets the aspect ratio of the chart
*/
aspectRatio: PropTypes.number,
/**
* Gets or Sets the colorSchema of the chart
*/
colorSchema: PropTypes.arrayOf(PropTypes.string),
/**
* Gets or Sets the dateLabel of the chart
*/
dateLabel: PropTypes.string,
/**
* Gets or Sets the grid mode.
*/
grid: PropTypes.string,
/**
* Gets or Sets the height of the chart
*/
height: PropTypes.number,
/**
* Gets or Sets the isAnimated property of the chart, making it to animate
* when render. By default this is 'false'
*/
isAnimated: PropTypes.bool,
/**
* Gets or Sets the curve of the line chart
*/
lineCurve: PropTypes.string,
/**
* Gets or Sets the gradient colors of the line chart when there is only one line
*/
lineGradient: PropTypes.arrayOf(PropTypes.string),
/**
* Pass language tag for the tooltip to localize the date. Feature
* uses Intl.DateTimeFormat, for compatability and support, refer
* to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
*/
locale: PropTypes.string,
/**
* Gets or Sets the margin of the chart
*/
margin: PropTypes.shape({
top: PropTypes.number,
bottom: PropTypes.number,
left: PropTypes.number,
right: PropTypes.number,
}),
/**
* Gets or Sets the number format of the line chart
*/
numberFormat: PropTypes.string,
/**
* Gets or Sets whether a loading state will be shown
*/
shouldShowLoadingState: PropTypes.bool,
/**
* Gets or Sets the minimum width of the graph in order
* to show the tooltip NOTE: This could also depend on the aspect ratio
*/
tooltipThreshold: PropTypes.number,
/**
* Gets or Sets the topicLabel of the chart
*/
topicLabel: PropTypes.number,
/**
* Gets or Sets the valueLabel of the chart
*/
valueLabel: PropTypes.number,
/**
* Gets or Sets the width of the chart
*/
width: PropTypes.number,
/**
* Exposes the ability to force the chart to show a certain x format
* It requires a `xAxisFormat` of 'custom' in order to work.
* NOTE: localization not supported
*/
xAxisCustomFormat: PropTypes.string,
/**
* Exposes the ability to force the chart to show a certain x axis grouping
*/
xAxisFormat: PropTypes.string,
/**
* Gets or Sets the label of the X axis of the chart
*/
xAxisLabel: PropTypes.string,
/**
* Exposes the ability to force the chart to show a certain x ticks. It
* requires a `xAxisFormat` of 'custom' in order to work. NOTE: This
* value needs to be a multiple of 2, 5 or 10. They won't always work
* as expected, as D3 decides at the end how many and where the ticks will appear.
*/
xTicks: PropTypes.number,
/**
* Gets or Sets the label of the Y axis of the chart
*/
yAxisLabel: PropTypes.string,
/**
* Gets or Sets the number of ticks of the y axis on the chart (Default is 5)
*/
yTicks: PropTypes.number,
customMouseOver: PropTypes.func,
customMouseMove: PropTypes.func,
customMouseOut: PropTypes.func,
/**
* Internally used, do not overwrite.
*
* @ignore
*/
chart: PropTypes.object,
}
static defaultProps = {
chart: line,
createTooltip: () => null,
shouldShowLoadingState: false,
}
componentDidMount() {
if (!this.props.shouldShowLoadingState) {
this._createChart();
}
}
componentDidUpdate() {
if (!this.props.shouldShowLoadingState) {
if (!this._chart) {
this._createChart();
} else {
this._updateChart();
this.props.createTooltip();
}
}
}
componentWillUnmount() {
this.props.chart.destroy(this._rootNode);
}
_createChart() {
this._chart = this.props.chart.create(
this._rootNode,
this.props.data,
this._getChartConfiguration()
);
}
_updateChart() {
this.props.chart.update(
this._rootNode,
this.props.data,
this._getChartConfiguration(),
this._chart
);
}
/**
* We want to remove the chart and data from the props in order to have a configuration object
* @return {Object} Configuration object for the chart
*/
_getChartConfiguration() {
let configuration = { ...this.props };
delete configuration.data;
delete configuration.chart;
delete configuration.createTooltip;
delete configuration.shouldShowLoadingState;
return configuration;
}
_setRef(componentNode) {
this._rootNode = componentNode;
}
render() {
return loadingContainerWrapper(
this.props,
this.props.loadingState || this.props.chart.loading(),
<div className="line-container" ref={this._setRef.bind(this)} />
);
}
}
export default Line;
|
src/components/auth/ProfilePreview.js | zebras-filming-videos/streamr-web | import React from 'react'
import { Link } from 'react-router-dom'
import preventDefault from '../../utils/preventDefault'
export default ({
user,
onLogOut
}) => (
<li className='profile-preview'>
<Link to={`/profile/${user.id}`} className='profile-link'>{user.name}</Link>
<Link to='/me'>account</Link>
{' '}
<a href='' onClick={preventDefault(onLogOut)}>logout</a>
</li>
)
|
packages/react-ui-components/src/Tree/index.story.js | dimaip/neos-ui | import React from 'react';
import {storiesOf, action} from '@kadira/storybook';
import {StoryWrapper} from './../_lib/storyUtils.js';
import Tree from './index.js';
storiesOf('Tree', module)
.addWithInfo(
'default',
() => (
<StoryWrapper>
<Tree>
<Tree.Node>
<Tree.Node.Header
hasChildren={true}
isCollapsed={false}
isActive={true}
isFocused={true}
isLoading={false}
isDirty={true}
hasError={false}
label="Active focused node with children"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
<Tree.Node.Contents>
<Tree.Node>
<Tree.Node.Header
hasChildren={false}
isCollapsed={true}
isActive={false}
isFocused={false}
isLoading={false}
hasError={false}
label="Normal node"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
</Tree.Node>
<Tree.Node>
<Tree.Node.Header
hasChildren={false}
isCollapsed={true}
isActive={true}
isFocused={false}
isLoading={false}
isDirty={true}
hasError={false}
label="Active node"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
</Tree.Node>
<Tree.Node>
<Tree.Node.Header
hasChildren={false}
isCollapsed={true}
isActive={false}
isFocused={true}
isLoading={false}
hasError={false}
label="Focused node"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
</Tree.Node>
<Tree.Node>
<Tree.Node.Header
hasChildren={false}
isCollapsed={true}
isActive={false}
isFocused={false}
isLoading={false}
isHiddenInIndex={true}
hasError={false}
label="Hidden in menus"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
</Tree.Node>
<Tree.Node>
<Tree.Node.Header
hasChildren={false}
isCollapsed={true}
isActive={false}
isFocused={false}
isLoading={false}
isHidden={true}
hasError={false}
label="Hidden (invisible)"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
</Tree.Node>
</Tree.Node.Contents>
</Tree.Node>
</Tree>
</StoryWrapper>
),
{inline: true}
)
.addWithInfo(
'drag and drop',
() => (
<StoryWrapper>
<Tree>
<Tree.Node>
<Tree.Node.Header
hasChildren={true}
isCollapsed={false}
isActive={true}
isFocused={true}
isLoading={false}
hasError={false}
label="Parent Node"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
<Tree.Node.Contents>
<Tree.Node>
<Tree.Node.Header
hasChildren={false}
isCollapsed={true}
isActive={false}
isFocused={false}
isLoading={false}
hasError={false}
dragAndDropContext={{
data: 'hello',
acceptsBefore: () => true,
acceptsInto: () => false,
onDropBefore: action('dropBefore'),
onDropInto: action('dropInto')
}}
label="Normal node"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
</Tree.Node>
<Tree.Node>
<Tree.Node.Header
hasChildren={false}
isCollapsed={true}
isActive={false}
isFocused={false}
isLoading={false}
hasError={false}
dragAndDropContext={{
data: 'hello',
acceptsBefore: () => false,
acceptsInto: () => true,
onDropBefore: action('dropBefore'),
onDropInto: action('dropInto')
}}
label="Normal node"
onNodeToggle={action('onNodeToggle')}
onNodeClick={action('onNodeClick')}
onNodeFocus={action('onNodeFocus')}
/>
</Tree.Node>
</Tree.Node.Contents>
</Tree.Node>
</Tree>
</StoryWrapper>
),
{inline: true}
);
|
MobileApp/node_modules/react-native-elements/example/src/views/buttons_home.js | VowelWeb/CoinTradePros.com | import Expo from 'expo';
import React, { Component } from 'react';
import { View, ScrollView, StyleSheet, Platform } from 'react-native';
import { Text, Button, Icon, SocialIcon, Card } from 'react-native-elements';
import colors from 'HSColors';
import socialColors from 'HSSocialColors';
import fonts from 'HSFonts';
const log = () => {
console.log('Attach a method here.');
};
class Buttons extends Component {
render() {
const { navigation } = this.props;
return (
<ScrollView>
<View style={styles.hero}>
<Icon color="white" name="whatshot" size={62} type="material" />
<Text style={styles.heading}>Buttons & Icons</Text>
</View>
<Button
buttonStyle={styles.button}
backgroundColor={socialColors.facebook}
icon={{ name: 'account', type: 'material-community' }}
onPress={() =>
navigation.navigate('Button_Detail', { name: 'Jordan' })}
title="Got to Buttons Detail View"
/>
<Button
backgroundColor={socialColors.stumbleupon}
onPress={() => log()}
title="BUTTON"
buttonStyle={styles.button}
/>
<Button
buttonStyle={styles.button}
iconRight
backgroundColor={socialColors.quora}
icon={{ name: 'invert-colors' }}
onPress={() => log()}
title="BUTTON WITH RIGHT ICON"
/>
<Button
buttonStyle={styles.button}
iconRight
backgroundColor={socialColors.tumblr}
icon={{ name: 'motorcycle' }}
onPress={() => log()}
title="BUTTON WITH RIGHT ICON"
/>
<Button
buttonStyle={styles.button}
raised
backgroundColor={socialColors.foursquare}
icon={{ name: 'card-travel' }}
onPress={() => log()}
title="BUTTON RAISED"
/>
<Button
buttonStyle={styles.button}
raised
backgroundColor={socialColors.vimeo}
icon={{ name: 'touch-app' }}
onPress={() => log()}
title="BUTTON RAISED"
/>
<Button
buttonStyle={styles.button}
raised
backgroundColor={socialColors.twitter}
icon={{ name: 'new-releases' }}
onPress={() => log()}
title="BUTTON RAISED"
/>
<Button
buttonStyle={styles.button}
raised
backgroundColor={socialColors.linkedin}
icon={{ name: 'business' }}
onPress={() => log()}
title="BUTTON RAISED"
/>
<Button
buttonStyle={styles.button}
raised
backgroundColor={socialColors.pinterest}
icon={{ name: 'send' }}
onPress={() => log()}
title="BUTTON RAISED"
/>
<Button
buttonStyle={styles.button}
raised
onPress={() => log()}
title="BUTTON RAISED"
/>
<Button
large={true}
buttonStyle={styles.button}
onPress={() => log()}
backgroundColor={socialColors.facebook}
title="LARGE BUTTON"
/>
<Button
large={true}
buttonStyle={styles.button}
backgroundColor={socialColors.stumbleupon}
icon={{ name: 'cached' }}
title="LARGE BUTTON WITH ICON"
/>
<Button
large={true}
buttonStyle={styles.button}
backgroundColor={socialColors.quora}
raised
icon={{ name: 'album' }}
title="LARGE RAISED WITH ICON"
/>
<Button
large={true}
buttonStyle={styles.button}
raised
iconRight
backgroundColor={socialColors.tumblr}
icon={{ name: 'accessibility' }}
title="LARGE RAISED RIGHT ICON"
/>
<Button
large={true}
buttonStyle={styles.button}
raised
iconRight
backgroundColor={socialColors.foursquare}
icon={{ name: 'account-balance' }}
title="LARGE RAISED RIGHT ICON"
/>
<Button
large={true}
buttonStyle={styles.button}
raised
backgroundColor={socialColors.vimeo}
icon={{ name: 'change-history' }}
title="LARGE RAISED WITH ICON"
/>
<Button
large={true}
buttonStyle={[{ marginBottom: 15, marginTop: 15 }]}
icon={{ name: 'code' }}
backgroundColor={socialColors.twitter}
title="LARGE ANOTHER BUTTON"
/>
<Card title="ICONS" containerStyle={{ marginTop: 15 }}>
<View style={[styles.socialRow, { marginVertical: 10 }]}>
<Icon
onPress={() => navigation.navigate('Icons_Detail')}
type="font-awesome"
color="#e14329"
name="hashtag"
/>
<Icon
onPress={() => console.log('hello')}
type="font-awesome"
color="#02b875"
name="rocket"
/>
<Icon
onPress={() => console.log('hello')}
color="#000000"
name="snapchat-ghost"
type="font-awesome"
/>
<Icon
color="#6441A5"
name="btc"
type="font-awesome"
onPress={() => console.log('hello')}
/>
<Icon
color="#f50"
name="heartbeat"
type="font-awesome"
onPress={() => console.log('hello')}
/>
</View>
<View style={[styles.socialRow, { marginVertical: 10 }]}>
<Icon
name="rowing"
color="#673AB7"
onPress={() => console.log('hello')}
/>
<Icon
name="g-translate"
color="#03A9F4"
onPress={() => console.log('hello')}
/>
<Icon
color="#009688"
name="sc-telegram"
type="evilicon"
onPress={() => console.log('hello')}
/>
<Icon
color="#8BC34A"
name="social-apple"
type="foundation"
onPress={() => console.log('hello')}
/>
<Icon
color="#FFC107"
name="ios-american-football"
type="ionicon"
onPress={() => console.log('hello')}
/>
</View>
<View style={styles.socialRow}>
<Icon
raised
name="vpn-key"
color="#E91E63"
onPress={() => console.log('hello')}
/>
<Icon
raised
name="ring-volume"
color="#3F51B5"
onPress={() => console.log('hello')}
/>
<Icon
raised
color="#00BCD4"
name="weekend"
onPress={() => console.log('hello')}
/>
<Icon
raised
color="#CDDC39"
name="bubble-chart"
onPress={() => console.log('hello')}
/>
<Icon
raised
color="#FF5722"
name="burst-mode"
onPress={() => console.log('hello')}
/>
</View>
<View style={styles.socialRow}>
<Icon
reverse
raised
name="account-balance"
color="#673AB7"
onPress={() => console.log('hello')}
/>
<Icon
reverse
raised
name="android"
color="#03A9F4"
onPress={() => console.log('hello')}
/>
<Icon
reverse
raised
color="#009688"
name="code"
onPress={() => console.log('hello')}
/>
<Icon
reverse
raised
color="#8BC34A"
name="card-travel"
onPress={() => console.log('hello')}
/>
<Icon
reverse
raised
color="#FF9800"
name="extension"
onPress={() => console.log('hello')}
/>
</View>
<View style={styles.socialRow}>
<Icon
reverse
name="group-work"
color="#E91E63"
onPress={() => console.log('hello')}
/>
<Icon
reverse
name="lightbulb-outline"
color="#3F51B5"
onPress={() => console.log('hello')}
/>
<Icon
reverse
color="#00BCD4"
name="pets"
onPress={() => console.log('hello')}
/>
<Icon
reverse
color="#CDDC39"
name="polymer"
onPress={() => console.log('hello')}
/>
<Icon
reverse
color="#FF5722"
name="touch-app"
onPress={() => console.log('hello')}
/>
</View>
</Card>
<Card
title="SOCIAL ICONS"
containerStyle={[
styles.socialRow,
{ marginTop: 15, marginBottom: 15 },
]}
>
<View style={styles.socialRow}>
<SocialIcon
raised={false}
type="gitlab"
onPress={() => console.log('hi!')}
/>
<SocialIcon type="medium" onPress={() => console.log('hi2!')} />
<SocialIcon type="github-alt" onPress={() => console.log('hi3!')} />
<SocialIcon type="twitch" />
<SocialIcon type="soundcloud" />
</View>
<View style={styles.socialRow}>
<SocialIcon
raised={false}
type="facebook"
onPress={() => console.log('hi!')}
/>
<SocialIcon type="twitter" onPress={() => console.log('hi2!')} />
<SocialIcon type="instagram" onPress={() => console.log('hi3!')} />
<SocialIcon raised={false} type="codepen" />
<SocialIcon raised={false} type="youtube" />
</View>
</Card>
<Card
title="LIGHT SOCIAL ICONS"
containerStyle={{ marginTop: 15, marginBottom: 15 }}
>
<View style={styles.socialRow}>
<SocialIcon
light
raised={false}
type="gitlab"
onPress={() => console.log('hi!')}
/>
<SocialIcon
light
type="medium"
onPress={() => console.log('hi2!')}
/>
<SocialIcon
light
type="github-alt"
onPress={() => console.log('hi3!')}
/>
<SocialIcon light type="twitch" />
<SocialIcon light type="soundcloud" />
</View>
</Card>
<Card
containerStyle={{ marginTop: 15, marginBottom: 15 }}
title="SOCIAL BUTTONS"
>
<SocialIcon button type="medium" />
<SocialIcon button type="twitch" />
<SocialIcon
title="Sign In With Facebook"
button
fontWeight="400"
type="facebook"
/>
<SocialIcon title="Some Twitter Message" button type="twitter" />
<SocialIcon
light
button
title="Some Instagram Message"
type="instagram"
/>
</Card>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
heading: {
color: 'white',
marginTop: 10,
fontSize: 22,
},
hero: {
justifyContent: 'center',
alignItems: 'center',
padding: 40,
backgroundColor: colors.primary2,
},
titleContainer: {},
button: {
marginTop: 15,
},
title: {
textAlign: 'center',
color: colors.grey2,
...Platform.select({
ios: {
fontFamily: fonts.ios.black,
},
}),
},
socialRow: {
flexDirection: 'row',
justifyContent: 'space-around',
},
});
export default Buttons;
|
src/Add.js | SaintEmbers/awesomejar | import React from 'react'
import ReactDom from 'react-dom'
require('./styles/main.css')
import { Router, Route, Link, browserHistory, IndexRoute } from 'react-router'
require('./styles/main.css')
var Add = React.createClass({
getInitialState(){
console.log('yooo in app')
return{
addToJar: false
}
},
openJar(){
console.log('clicked')
this.setState({addToJar: true})
// browserHistory.push('modal')
},
render (){
if(!this.state.addToJar){
return (
<div>
<div className={this.state.addToJar ? 'transition jar ' : 'jar'} onClick={ this.openJar }>
<div className={this.state.addToJar ? 'transition content ' : 'content'}>
<svg width="300" height="300" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" className='add'>
<title>Slice 1</title>
<g fill="none" fill-rule="evenodd" strokeLinecap="square" strokeWidth="4">
<path d="M200 1.5v400" stroke="#38B5B9"/>
<path d="M1.5 200h400" stroke="#5DBCC6"/>
</g>
</svg>
</div>
</div>
</div>
)
} else{
return(
<div>
<div className='transition jar' onClick={ this.openJar }>
<div className='transition content'>
<svg width="300" height="300" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" className='add-transition transition add'>
<title>Slice 1</title>
<g fill="none" fill-rule="evenodd" strokeLinecap="square" strokeWidth="4">
<path d="M200 1.5v400" stroke="#38B5B9"/>
<path d="M1.5 200h400" stroke="#5DBCC6"/>
</g>
</svg>
</div>
</div>
<h1></h1>
<form action="#" className="memory-form" method="post">
<div>
<textarea className="memory-input"></textarea>
</div>
<button type="submit" className="submit">Submit</button>
</form>
</div>
)
}
}
})
export default Add
|
src/app/layouts/mainLayout.js | kristjanpikk/things-to-do | import React from 'react';
import Header from '~shared/header';
import Footer from '~shared/footer';
// Create MainLayout component
export default class MainLayout extends React.Component{
constructor(props) {
super(props);
}
render() {
return(
<div className="container">
<Header />
<main className="main" role="main">
{this.props.children}
</main>
<Footer />
</div>
);
} // Render
}; |
src/components/pageBreak/PageBreak.js | djErock/Telemed-Website | import React, { Component } from 'react';
import './pageBreak.css';
const PageBreak = (props) => (
<article className="pageBreak">
<div className="container">
<h2>{props.heading}</h2>
</div>
</article>
)
export default PageBreak; |
src/CarouselItem.js | natlownes/react-bootstrap | import React from 'react';
import classNames from 'classnames';
import TransitionEvents from './utils/TransitionEvents';
const CarouselItem = React.createClass({
propTypes: {
direction: React.PropTypes.oneOf(['prev', 'next']),
onAnimateOutEnd: React.PropTypes.func,
active: React.PropTypes.bool,
animateIn: React.PropTypes.bool,
animateOut: React.PropTypes.bool,
caption: React.PropTypes.node,
index: React.PropTypes.number
},
getInitialState() {
return {
direction: null
};
},
getDefaultProps() {
return {
active: false,
animateIn: false,
animateOut: false
};
},
handleAnimateOutEnd() {
if (this.props.onAnimateOutEnd && this.isMounted()) {
this.props.onAnimateOutEnd(this.props.index);
}
},
componentWillReceiveProps(nextProps) {
if (this.props.active !== nextProps.active) {
this.setState({
direction: null
});
}
},
componentDidUpdate(prevProps) {
if (!this.props.active && prevProps.active) {
TransitionEvents.addEndEventListener(
React.findDOMNode(this),
this.handleAnimateOutEnd
);
}
if (this.props.active !== prevProps.active) {
setTimeout(this.startAnimation, 20);
}
},
startAnimation() {
if (!this.isMounted()) {
return;
}
this.setState({
direction: this.props.direction === 'prev' ?
'right' : 'left'
});
},
render() {
let classes = {
item: true,
active: (this.props.active && !this.props.animateIn) || this.props.animateOut,
next: this.props.active && this.props.animateIn && this.props.direction === 'next',
prev: this.props.active && this.props.animateIn && this.props.direction === 'prev'
};
if (this.state.direction && (this.props.animateIn || this.props.animateOut)) {
classes[this.state.direction] = true;
}
return (
<div {...this.props} className={classNames(this.props.className, classes)}>
{this.props.children}
{this.props.caption ? this.renderCaption() : null}
</div>
);
},
renderCaption() {
return (
<div className="carousel-caption">
{this.props.caption}
</div>
);
}
});
export default CarouselItem;
|
docs/src/app/components/pages/components/RefreshIndicator/ExampleReady.js | mtsandeep/material-ui | import React from 'react';
import RefreshIndicator from 'material-ui/RefreshIndicator';
const style = {
container: {
position: 'relative',
},
refresh: {
display: 'inline-block',
position: 'relative',
},
};
const RefreshIndicatorExampleSimple = () => (
<div style={style.container}>
<RefreshIndicator
percentage={30}
size={40}
left={10}
top={0}
status="ready"
style={style.refresh}
/>
<RefreshIndicator
percentage={60}
size={50}
left={65}
top={0}
status="ready"
style={style.refresh}
/>
<RefreshIndicator
percentage={80}
size={60}
left={120}
top={0}
color="red"
status="ready"
style={style.refresh}
/>
<RefreshIndicator
percentage={100}
size={70}
left={175}
top={0}
color="red" // Overridden by percentage={100}
status="ready"
style={style.refresh}
/>
</div>
);
export default RefreshIndicatorExampleSimple;
|
code-samples/js/ARSample/HelloWorldSceneAR.js | viromedia/viro | 'use strict';
import React, { Component } from 'react';
import {StyleSheet} from 'react-native';
import {
ViroARScene,
ViroText,
ViroMaterials,
ViroBox,
Viro3DObject,
ViroAmbientLight,
ViroSpotLight,
ViroARPlane,
ViroARPlaneSelector,
ViroQuad,
ViroNode,
ViroAnimations,
ViroConstants
} from 'react-viro';
var createReactClass = require('create-react-class');
var HelloWorldSceneAR = createReactClass({
getInitialState() {
return {
hasARInitialized : false,
text : "Initializing AR...",
};
},
render: function() {
return (
<ViroARScene onTrackingUpdated={this._onTrackingUpdated}>
{/* Text to show whether or not the AR system has initialized yet, see ViroARScene's onTrackingInitialized*/}
<ViroText text={this.state.text} scale={[.5, .5, .5]} position={[0, 0, -1]} style={styles.helloWorldTextStyle} />
<ViroBox position={[0, -.5, -1]}
animation={{name: "rotate", run: true, loop: true}}
scale={[.3, .3, .1]} materials={["grid"]} />
<ViroAmbientLight color={"#aaaaaa"} influenceBitMask={1} />
<ViroSpotLight
innerAngle={5}
outerAngle={90}
direction={[0,-1,-.2]}
position={[0, 3, 1]}
color="#aaaaaa"
castsShadow={true}
/>
{/* Node that contains a light, an object and a surface to catch its shadow
notice that the dragType is "FixedToWorld" so the object can be dragged
along real world surfaces and points. */}
<ViroNode position={[-.5, -.5, -.5]} dragType="FixedToWorld" onDrag={()=>{}} >
{/* Spotlight to cast light on the object and a shadow on the surface, see
the Viro documentation for more info on lights & shadows */}
<ViroSpotLight
innerAngle={5}
outerAngle={45}
direction={[0,-1,-.2]}
position={[0, 3, 0]}
color="#ffffff"
castsShadow={true}
influenceBitMask={2}
shadowMapSize={2048}
shadowNearZ={2}
shadowFarZ={5}
shadowOpacity={.7} />
<Viro3DObject
source={require('./res/emoji_smile/emoji_smile.vrx')}
position={[0, .2, 0]}
scale={[.2, .2, .2]}
type="VRX"
lightReceivingBitMask={3}
shadowCastingBitMask={2}
transformBehaviors={['billboardY']}
resources={[require('./res/emoji_smile/emoji_smile_diffuse.png'),
require('./res/emoji_smile/emoji_smile_specular.png'),
require('./res/emoji_smile/emoji_smile_normal.png')]}/>
<ViroQuad
rotation={[-90,0,0]}
width={.5} height={.5}
arShadowReceiver={true}
lightReceivingBitMask={2} />
</ViroNode>
{/* Node that contains a light, an object and a surface to catch its shadow
notice that the dragType is "FixedToWorld" so the object can be dragged
along real world surfaces and points. */}
<ViroNode position={[.5,-.5,-.5]} dragType="FixedToWorld" onDrag={()=>{}} >
{/* Spotlight to cast light on the object and a shadow on the surface, see
the Viro documentation for more info on lights & shadows */}
<ViroSpotLight
innerAngle={5}
outerAngle={45}
direction={[0,-1,-.2]}
position={[0, 3, 0]}
color="#ffffff"
castsShadow={true}
influenceBitMask={4}
shadowMapSize={2048}
shadowNearZ={2}
shadowFarZ={5}
shadowOpacity={.7} />
<Viro3DObject
source={require('./res/object_soccerball/object_soccer_ball.vrx')}
position={[0, .15, 0]}
scale={[.3, .3, .3]}
type="VRX"
lightReceivingBitMask={5}
shadowCastingBitMask={4}
transformBehaviors={['billboardY']}
resources={[require('./res/object_soccerball/object_soccer_ball_diffuse.png'),
require('./res/object_soccerball/object_soccer_ball_normal.png'),
require('./res/object_soccerball/object_soccer_ball_specular.png')]}/>
<ViroQuad
rotation={[-90,0,0]}
width={.5} height={.5}
arShadowReceiver={true}
lightReceivingBitMask={4} />
</ViroNode>
</ViroARScene>
);
},
_onTrackingUpdated(state, reason) {
// if the state changes to "TRACKING_NORMAL" for the first time, then
// that means the AR session has initialized!
if (!this.state.hasARInitialized && state == ViroConstants.TRACKING_NORMAL) {
this.setState({
hasARInitialized : true,
text : "Hello World!"
});
}
}
});
var styles = StyleSheet.create({
helloWorldTextStyle: {
fontFamily: 'Arial',
fontSize: 30,
color: '#ffffff',
textAlignVertical: 'center',
textAlign: 'center',
},
});
ViroMaterials.createMaterials({
grid: {
diffuseTexture: require('./res/grid_bg.jpg'),
},
});
ViroAnimations.registerAnimations({
rotate: {
properties: {
rotateY: "+=90"
},
duration: 250, //.25 seconds
},
});
module.exports = HelloWorldSceneAR;
|
app/containers/home.js | mersocarlin/react-webpack-template | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
class Home extends Component {
componentDidMount () {
this.test();
}
request () {
return new Promise((resolve) => {
setTimeout(() => {
resolve('123');
}, 5 * 1000);
});
}
async test () {
let t = await this.request();
if (t === 'aaa') {
t = 0;
}
const arr = [1, 2, 3, 4, 5];
let find = arr.find(item => item > 2 && item < 4);
if (find === 0) {
find = 1;
}
}
render () {
const param1 = '123';
const param2 = 456;
return (
<div className="app-page page-home">
Home Page
<br />
<Link to={`/about?q1=${param1}&q2=${param2}`}>About (query)</Link>
<br />
<Link to={`/about/${param1}/test/${param2}`}>About (params)</Link>
</div>
);
}
}
export default connect((/* state */) => {
return {
};
})(Home);
|
submissions/arqex/src/boot.js | enkidevs/flux-challenge | import React from 'react';
import AppContainer from './components/AppContainer';
import State from './State';
// Subscribe reactions
import './Reactions';
// Start listening to planet updates
var ws = new WebSocket('ws://localhost:4000');
ws.onmessage = function (event) {
State.trigger('planet:update', JSON.parse(event.data) );
};
// Fetch the first sith
State.trigger('siths:fetch', 3616);
React.render(<AppContainer />, document.getElementById('root'));
|
packages/react-error-overlay/src/components/NavigationBar.js | tharakawj/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/* @flow */
import React from 'react';
import { red, redTransparent } from '../styles';
const navigationBarStyle = {
marginBottom: '0.5rem',
};
const buttonContainerStyle = {
marginRight: '1em',
};
const _navButtonStyle = {
backgroundColor: redTransparent,
color: red,
border: 'none',
borderRadius: '4px',
padding: '3px 6px',
cursor: 'pointer',
};
const leftButtonStyle = {
..._navButtonStyle,
borderTopRightRadius: '0px',
borderBottomRightRadius: '0px',
marginRight: '1px',
};
const rightButtonStyle = {
..._navButtonStyle,
borderTopLeftRadius: '0px',
borderBottomLeftRadius: '0px',
};
type Callback = () => void;
type NavigationBarPropsType = {|
currentError: number,
totalErrors: number,
previous: Callback,
next: Callback,
|};
function NavigationBar(props: NavigationBarPropsType) {
const { currentError, totalErrors, previous, next } = props;
return (
<div style={navigationBarStyle}>
<span style={buttonContainerStyle}>
<button onClick={previous} style={leftButtonStyle}>
←
</button>
<button onClick={next} style={rightButtonStyle}>
→
</button>
</span>
{`${currentError} of ${totalErrors} errors on the page`}
</div>
);
}
export default NavigationBar;
|
docs/src/examples/elements/Flag/Types/FlagExampleFlag.js | Semantic-Org/Semantic-UI-React | import React from 'react'
import { Flag, Segment } from 'semantic-ui-react'
const FlagExampleFlag = () => (
<Segment>
<Flag name='ae' />
<Flag name='france' />
<Flag name='myanmar' />
</Segment>
)
export default FlagExampleFlag
|
node_modules/react-navigation/src/views/Drawer/DrawerNavigatorItems.js | jiangqizheng/ReactNative-BookProject | /* @flow */
import React from 'react';
import { View, Text, Platform, StyleSheet } from 'react-native';
import TouchableItem from '../TouchableItem';
import type {
NavigationScreenProp,
NavigationState,
NavigationAction,
NavigationRoute,
ViewStyleProp,
TextStyleProp,
} from '../../TypeDefinition';
import type { DrawerScene, DrawerItem } from './DrawerView.js';
type Props = {
navigation: NavigationScreenProp<NavigationState, NavigationAction>,
items: Array<NavigationRoute>,
activeItemKey?: string,
activeTintColor?: string,
activeBackgroundColor?: string,
inactiveTintColor?: string,
inactiveBackgroundColor?: string,
getLabel: (scene: DrawerScene) => ?(React.Element<*> | string),
renderIcon: (scene: DrawerScene) => ?React.Element<*>,
onItemPress: (info: DrawerItem) => void,
style?: ViewStyleProp,
labelStyle?: TextStyleProp,
};
/**
* Component that renders the navigation list in the drawer.
*/
const DrawerNavigatorItems = ({
navigation: { state, navigate },
items,
activeItemKey,
activeTintColor,
activeBackgroundColor,
inactiveTintColor,
inactiveBackgroundColor,
getLabel,
renderIcon,
onItemPress,
style,
labelStyle,
}: Props) => (
<View style={[styles.container, style]}>
{items.map((route: NavigationRoute, index: number) => {
const focused = activeItemKey === route.key;
const color = focused ? activeTintColor : inactiveTintColor;
const backgroundColor = focused
? activeBackgroundColor
: inactiveBackgroundColor;
const scene = { route, index, focused, tintColor: color };
const icon = renderIcon(scene);
const label = getLabel(scene);
return (
<TouchableItem
key={route.key}
onPress={() => {
onItemPress({ route, focused });
}}
delayPressIn={0}
>
<View style={[styles.item, { backgroundColor }]}>
{icon ? (
<View style={[styles.icon, focused ? null : styles.inactiveIcon]}>
{icon}
</View>
) : null}
{typeof label === 'string' ? (
<Text style={[styles.label, { color }, labelStyle]}>{label}</Text>
) : (
label
)}
</View>
</TouchableItem>
);
})}
</View>
);
/* Material design specs - https://material.io/guidelines/patterns/navigation-drawer.html#navigation-drawer-specs */
DrawerNavigatorItems.defaultProps = {
activeTintColor: '#2196f3',
activeBackgroundColor: 'rgba(0, 0, 0, .04)',
inactiveTintColor: 'rgba(0, 0, 0, .87)',
inactiveBackgroundColor: 'transparent',
};
const styles = StyleSheet.create({
container: {
marginTop: Platform.OS === 'ios' ? 20 : 0,
paddingVertical: 4,
},
item: {
flexDirection: 'row',
alignItems: 'center',
},
icon: {
marginHorizontal: 16,
width: 24,
alignItems: 'center',
},
inactiveIcon: {
/*
* Icons have 0.54 opacity according to guidelines
* 100/87 * 54 ~= 62
*/
opacity: 0.62,
},
label: {
margin: 16,
fontWeight: 'bold',
},
});
export default DrawerNavigatorItems;
|
src/parser/priest/shadow/modules/spells/VoidformAverageStacks.js | sMteX/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import Analyzer from 'parser/core/Analyzer';
import { formatNumber } from 'common/format';
import SpellIcon from 'common/SpellIcon';
import SpellLink from 'common/SpellLink';
import { TooltipElement } from 'common/Tooltip';
import StatisticBox from 'interface/others/StatisticBox';
import { STATISTIC_ORDER } from 'interface/others/StatisticBox';
import Voidform from './Voidform';
class VoidformAverageStacks extends Analyzer {
static dependencies = {
voidform: Voidform,
};
constructor(...args) {
super(...args);
this.active = true;
}
suggestions(when) {
when(this.voidform.averageVoidformStacks).isLessThan(21.5)
.addSuggestion((suggest, actual, recommended) => {
return suggest(
<>
Your <SpellLink id={SPELLS.VOIDFORM.id} /> stacks can be improved. Try to maximize the uptime by using <SpellLink id={SPELLS.VOID_BOLT.id} />, <SpellLink id={SPELLS.MIND_BLAST.id} />, and <SpellLink id={SPELLS.MINDBENDER_TALENT_SHADOW.id} /> on cooldown.<br /><br />
Managing your <SpellLink id={SPELLS.VOIDFORM.id} />s is a large part of playing shadow. The recommended way is to try to keep your <SpellLink id={SPELLS.VOIDFORM.id} /> cycles to around 20 seconds each, meaning you will have access to <SpellLink id={SPELLS.MINDBENDER_TALENT_SHADOW.id} /> every other <SpellLink id={SPELLS.VOIDFORM.id} />.<br /><br />
<SpellLink id={SPELLS.DISPERSION.id} /> can be used to synchronize your cooldowns back in order or in case of an emergency if you are about to fall out of <SpellLink id={SPELLS.VOIDFORM.id} /> and you have a <SpellLink id={SPELLS.MINDBENDER_TALENT_SHADOW.id} /> active. This should be used as a last resort as long as you will not need to use Dispersion defensively before it comes back up.
</>
)
.icon(SPELLS.VOIDFORM_BUFF.icon)
.actual(`${formatNumber(actual)} average Voidform stacks.`)
.recommended(`>${formatNumber(recommended)} stacks is recommended.`)
.regular(recommended).major(recommended - 5);
});
}
statistic() {
const { voidforms } = this.voidform;
if (!voidforms || voidforms.length === 0) {
return null;
}
const lastVoidformWasExcluded = voidforms[voidforms.length - 1].excluded;
return (
<StatisticBox
position={STATISTIC_ORDER.CORE(0)}
icon={<SpellIcon id={SPELLS.VOIDFORM.id} />}
value={`${formatNumber(this.voidform.averageVoidformStacks)} stacks`}
label={(
<TooltipElement content={`The average stacks of your voidforms.${lastVoidformWasExcluded ? 'The last voidform of the fight was excluded since it skewed the average.' : ''}`}>
Average voidform
</TooltipElement>
)}
>
<table className="table table-condensed">
<thead>
<tr>
<th>#</th>
<th>Stacks</th>
</tr>
</thead>
<tbody>
{
voidforms
.map((voidform, index) => (
<tr key={index}>
<th scope="row">{index + 1}</th>
<td>{voidform.stacks.length}</td>
</tr>
))
}
</tbody>
</table>
</StatisticBox>
);
}
}
export default VoidformAverageStacks;
|
node_modules/react-bootstrap/es/Badge.js | C0deSamurai/muzjiks | 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';
// TODO: `pullRight` doesn't belong here. There's no special handling here.
var propTypes = {
pullRight: React.PropTypes.bool
};
var defaultProps = {
pullRight: false
};
var Badge = function (_React$Component) {
_inherits(Badge, _React$Component);
function Badge() {
_classCallCheck(this, Badge);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Badge.prototype.hasContent = function hasContent(children) {
var result = false;
React.Children.forEach(children, function (child) {
if (result) {
return;
}
if (child || child === 0) {
result = true;
}
});
return result;
};
Badge.prototype.render = function render() {
var _props = this.props,
pullRight = _props.pullRight,
className = _props.className,
children = _props.children,
props = _objectWithoutProperties(_props, ['pullRight', 'className', 'children']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = _extends({}, getClassSet(bsProps), {
'pull-right': pullRight,
// Hack for collapsing on IE8.
hidden: !this.hasContent(children)
});
return React.createElement(
'span',
_extends({}, elementProps, {
className: classNames(className, classes)
}),
children
);
};
return Badge;
}(React.Component);
Badge.propTypes = propTypes;
Badge.defaultProps = defaultProps;
export default bsClass('badge', Badge); |
node_modules/react-native-mock/src/Libraries/NavigationExperimental/NavigationCard.js | niukui/gitpro | import React from 'react';
class CardStackPanResponder {
}
class PagerPanResponder {
}
class NavigationCard extends React.Component {
static CardStackPanResponder = CardStackPanResponder;
static CardStackStyleInterpolator = {
forHorizontal: () => ({}),
forVertical: () => ({}),
};
static PagerPanResponder = PagerPanResponder;
static PagerStyleInterpolator = {
forHorizontal: () => ({}),
};
}
module.exports = NavigationCard;
|
react/dashboard_example/src/vendor/recharts/demo/component/Curve.js | webmaster444/webmaster444.github.io | import React from 'react';
import { Surface, Curve, Layer } from 'recharts';
import { curveBundle, curveCardinal, curveCardinalClosed, curveCardinalOpen,
curveCatmullRomOpen } from 'd3-shape';
import { scaleOrdinal, schemeCategory10 } from 'd3-scale';
export default React.createClass({
render () {
const points = [
{ x: 10, y: 40 },
{ x: 50, y: 150 },
{ x: 90, y: 60 },
{ x: 130, y: 180 },
{ x: 170, y: 50 }
];
const scale = scaleOrdinal(schemeCategory10);
const ticks = [0, 0.25, 0.5, 0.75, 1];
return (
<Surface width={600} height={800}>
<Layer>
<text x={10} y={20}>curveCardinalClosed</text>
{
ticks.map((entry, index) => (
<Layer key={`curve-${index}`}>
<Curve
stroke={scale(entry)}
fill="none"
type={curveCardinalClosed.tension(entry)}
points={points}
/>
<text x={200} y={40 + index * 30} fill={scale(entry)}>
{`curveCardinalClosed.tension(${entry})`}
</text>
</Layer>
))
}
{
points.map((entry, index) => (
<circle cx={entry.x} cy={entry.y} r={4} key={`circle-${index}`}/>
))
}
</Layer>
<Layer transform="translate(0, 200)">
<text x={10} y={20}>curveCatmullRomOpen</text>
{
ticks.map((entry, index) => (
<Layer key={`curve-${index}`}>
<Curve
stroke={scale(entry)}
fill="none"
type={curveCatmullRomOpen.alpha(entry)}
points={points}
/>
<text x={200} y={40 + index * 30} fill={scale(entry)}>
{`curveCatmullRomOpen.alpha(${entry})`}
</text>
</Layer>
))
}
{
points.map((entry, index) => (
<circle cx={entry.x} cy={entry.y} r={4} key={`circle-${index}`}/>
))
}
</Layer>
<Layer transform="translate(0, 400)">
<text x={10} y={20}>curveBundle</text>
{
ticks.map((entry, index) => (
<Layer key={`curve-${index}`}>
<Curve
stroke={scale(entry)}
fill="none"
type={curveBundle.beta(entry)}
points={points}
/>
<text x={200} y={40 + index * 30} fill={scale(entry)}>
{`curveBundle.beta(${entry})`}
</text>
</Layer>
))
}
{
points.map((entry, index) => (
<circle cx={entry.x} cy={entry.y} r={4} key={`circle-${index}`}/>
))
}
</Layer>
</Surface>
);
}
});
|
docs/src/app/components/pages/components/IconButton/Page.js | nathanmarks/material-ui | import React from 'react';
import Title from 'react-title-component';
import CodeExample from '../../../CodeExample';
import PropTypeDescription from '../../../PropTypeDescription';
import MarkdownElement from '../../../MarkdownElement';
import iconButtonCode from '!raw!material-ui/IconButton/IconButton';
import iconButtonReadmeText from './README';
import iconButtonExampleSimpleCode from '!raw!./ExampleSimple';
import IconButtonExampleSimple from './ExampleSimple';
import iconButtonExampleComplexCode from '!raw!./ExampleComplex';
import IconButtonExampleComplex from './ExampleComplex';
import iconButtonExampleSizeCode from '!raw!./ExampleSize';
import IconButtonExampleSize from './ExampleSize';
import iconButtonExampleTooltipCode from '!raw!./ExampleTooltip';
import IconButtonExampleTooltip from './ExampleTooltip';
import iconButtonExampleTouchCode from '!raw!./ExampleTouch';
import IconButtonExampleTouch from './ExampleTouch';
const descriptions = {
simple: 'An Icon Button using an icon specified with the `iconClassName` property, and a `disabled` example.',
tooltip: 'Icon Buttons showing the available `tooltip` positions.',
touch: 'The `touch` property adjusts the tooltip size for better visibility on mobile devices.',
size: 'Examples of Icon Button in different sizes.',
other: 'An Icon Button using a nested [Font Icon](/#/components/font-icon), ' +
'a nested [SVG Icon](/#/components/svg-icon) and an icon font ligature.',
};
const IconButtonPage = () => (
<div>
<Title render={(previousTitle) => `Icon Button - ${previousTitle}`} />
<MarkdownElement text={iconButtonReadmeText} />
<CodeExample
title="Simple example"
description={descriptions.simple}
code={iconButtonExampleSimpleCode}
>
<IconButtonExampleSimple />
</CodeExample>
<CodeExample
title="Further examples"
description={descriptions.other}
code={iconButtonExampleComplexCode}
>
<IconButtonExampleComplex />
</CodeExample>
<CodeExample
title="Size examples"
description={descriptions.size}
code={iconButtonExampleSizeCode}
>
<IconButtonExampleSize />
</CodeExample>
<CodeExample
title="Tooltip examples"
description={descriptions.tooltip}
code={iconButtonExampleTooltipCode}
>
<IconButtonExampleTooltip />
</CodeExample>
<CodeExample
title="Touch example"
description={descriptions.touch}
code={iconButtonExampleTouchCode}
>
<IconButtonExampleTouch />
</CodeExample>
<PropTypeDescription code={iconButtonCode} />
</div>
);
export default IconButtonPage;
|
es/components/sidebar/panel-element-editor/panel-element-editor.js | cvdlab/react-planner | import React from 'react';
import PropTypes from 'prop-types';
import Panel from '../panel';
import { Seq } from 'immutable';
import { MODE_IDLE, MODE_2D_ZOOM_IN, MODE_2D_ZOOM_OUT, MODE_2D_PAN, MODE_3D_VIEW, MODE_3D_FIRST_PERSON, MODE_WAITING_DRAWING_LINE, MODE_DRAWING_LINE, MODE_DRAWING_HOLE, MODE_DRAWING_ITEM, MODE_DRAGGING_LINE, MODE_DRAGGING_VERTEX, MODE_DRAGGING_ITEM, MODE_DRAGGING_HOLE, MODE_FITTING_IMAGE, MODE_UPLOADING_IMAGE, MODE_ROTATING_ITEM } from '../../../constants';
import ElementEditor from './element-editor';
export default function PanelElementEditor(_ref, _ref2) {
var state = _ref.state;
var projectActions = _ref2.projectActions,
translator = _ref2.translator;
var scene = state.scene,
mode = state.mode;
if (![MODE_IDLE, MODE_2D_ZOOM_IN, MODE_2D_ZOOM_OUT, MODE_2D_PAN, MODE_3D_VIEW, MODE_3D_FIRST_PERSON, MODE_WAITING_DRAWING_LINE, MODE_DRAWING_LINE, MODE_DRAWING_HOLE, MODE_DRAWING_ITEM, MODE_DRAGGING_LINE, MODE_DRAGGING_VERTEX, MODE_DRAGGING_ITEM, MODE_DRAGGING_HOLE, MODE_ROTATING_ITEM, MODE_UPLOADING_IMAGE, MODE_FITTING_IMAGE].includes(mode)) return null;
var componentRenderer = function componentRenderer(element, layer) {
return React.createElement(
Panel,
{ key: element.id, name: translator.t('Properties: [{0}] {1}', element.type, element.id), opened: true },
React.createElement(
'div',
{ style: { padding: '5px 15px' } },
React.createElement(ElementEditor, { element: element, layer: layer, state: state })
)
);
};
var layerRenderer = function layerRenderer(layer) {
return Seq().concat(layer.lines, layer.holes, layer.areas, layer.items).filter(function (element) {
return element.selected;
}).map(function (element) {
return componentRenderer(element, layer);
}).valueSeq();
};
return React.createElement(
'div',
null,
scene.layers.valueSeq().map(layerRenderer)
);
}
PanelElementEditor.propTypes = {
state: PropTypes.object.isRequired
};
PanelElementEditor.contextTypes = {
projectActions: PropTypes.object.isRequired,
translator: PropTypes.object.isRequired
}; |
samples/apollo-client/src/QueryRunner.js | TOTBWF/FSharp.Data.GraphQL | import React from 'react';
import ApolloClient from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import gql from 'graphql-tag';
const deferQuery = `# This is a sample query with defer directive.
# The GraphQL Giraffe server is configured to return deferred results after 5 seconds,
# so you can observe better how the effects of a defer directive works.
query TestQuery {
hero(id:"1000") {
id
name
appearsIn
homePlanet
friends @defer {
id
name
}
}
}`;
const streamQuery = `# This is a sample query with stream and defer directive.
# The GraphQL Giraffe server is configured to return each result after 5 seconds,
# so you can observe better how the effects of stream and defer directives work.
query TestQuery {
hero(id:"1000") {
id
name
appearsIn @defer
homePlanet
friends @stream {
... on Human {
name
}
... on Droid {
name
primaryFunction
}
}
}
}`
const thresholdQuery = `# This is a sample query that will be denied by a query complexity threshold middleware.
# The field "friends" of both Human and Droid have a query weight of 0.5.
# The maximum query weight (threshold) is set to 2.0 on the server.
# Hero friends will have a weight of 0.5.
# Friends of friends of hero will have a weight of 1.0 (since they can be both Human and Droid).
# Also, their inner friends will have a weight of 1.0.
# Total weight is 2.5, making the query too complex for the threshold meter.
query TestQuery {
hero(id:"1000") {
id, friends { id, friends { id, friends { id } } }
}
}`
const liveQuery = `# This is a sample query using live directive.
# This query will subscribe to updates on the isMoon field by the mutation "setMoon".
# Whenever the mutation is done, the new value will be sent after 5 seconds.
query testQuery {
planet (id : 1) {
id
name
isMoon @live
}
}`
export default class QueryRunner extends React.Component {
constructor(props) {
super(props);
var subscription = new SubscriptionClient('ws://localhost:8084/', {
reconnect: true
});
var client = new ApolloClient({
link: subscription,
cache: new InMemoryCache()
});
this.state = {
query: deferQuery,
subscription: subscription,
client: client,
results : ''
};
this.handleChange = this.handleChange.bind(this);
this.handleRun = this.handleRun.bind(this);
this.handleSampleQueryChange = this.handleSampleQueryChange.bind(this);
}
handleChange(event) {
this.setState({ query: event.target.value });
}
handleSampleQueryChange(event) {
switch (event.target.value)
{
case "defer":
this.setState({ query: deferQuery });
break;
case "stream":
this.setState({ query: streamQuery });
break;
case "threshold":
this.setState({ query: thresholdQuery });
break;
case "live":
this.setState({ query: liveQuery });
break;
default:
break;
}
}
handleRun(event) {
this.setState({ results: '' });
this.state.subscription.unsubscribeAll();
this.state.client.subscribe({
query: gql`${this.state.query}`,
variables: {}
}).subscribe({
next: result => {
this.setState({ results: this.state.results + JSON.stringify(result) + "\n\n" });
},
error: e => {
this.setState({ results: this.state.results + JSON.stringify(e) + "\n\n" });
}
});
event.preventDefault();
}
render() {
return (
<div>
<div>
<p>
Type a query here, or select one of the sample queries in the selection below.
You can type subscriptions and defer directives,
the client will wait for more responses over Web Socket connection.
</p>
<p>Once typed, just click "Run query" to connect to the socket and wait for responses.</p>
</div>
<div>
<p>
Sample queries:
<select onChange={this.handleSampleQueryChange}>
<option value="defer">Deferred query sample</option>
<option value="stream">Streamed query sample</option>
<option value="threshold">Threshold for complex queries sample</option>
<option value="live">Live query sample</option>
</select>
</p>
</div>
<div>
<textarea cols="100" rows="20" value={this.state.query} onChange={this.handleChange}></textarea>
</div>
<div>
<button onClick={this.handleRun}>Run query</button>
</div>
<div>
<p>Results are displayed here.</p>
<p>
As explained above, queries are run by GraphQL over WebSocket protocol.
If the query is a subscription or defer query, the client will wait for subsequent responses from the Socket.
</p>
</div>
<div>
<textarea cols="100" rows="20" value={this.state.results}></textarea>
</div>
</div>
);
}
} |
client/acp/src/view/widget/api-tokens-list.js | NicolasSiver/nodebb-plugin-ns-awards | import PropTypes from 'prop-types';
import React from 'react';
import {connect} from 'react-redux';
import {createApiTokenWithPrompt, deleteApiToken} from '../../action/actions';
import RoundButton from '../display/round-button';
import {getApiTokens} from '../../model/selector/selectors';
class ApiTokensList extends React.Component {
render() {
return (
<div className="api-tokens-list">
<h5>API Tokens</h5>
<p>This is a list of API tokens. Tokens provide an access to Awards API for other plugins.
Remove any tokens that you do not recognize.</p>
<div>
<RoundButton
icon="fa-plus"
animate={false}
role="active"
clickListener={() => this.props.createToken()}/> Create API Token...
</div>
<div className="api-tokens-list__body">
{this.props.apiTokens !== null && this.props.apiTokens.map(tokenData => {
return (
<div className="api-tokens-list__item" key={tokenData.id}>
<div className="api-tokens-list__item-name">
{tokenData.name}
</div>
<div className="api-tokens-list__item-value">
{tokenData.token}
</div>
<div className="api-tokens-list__item-controls">
<RoundButton
icon="fa-trash"
animate={true}
role="danger"
clickListener={() => this.props.deleteToken(tokenData.id)}/>
</div>
</div>
);
})}
</div>
</div>
);
}
}
ApiTokensList.propTypes = {
apiTokens : PropTypes.array,
createToken: PropTypes.func,
deleteToken: PropTypes.func
};
export default connect(
state => {
return {
apiTokens: getApiTokens(state)
};
},
dispatch => {
return {
createToken: () => dispatch(createApiTokenWithPrompt()),
deleteToken: id => dispatch(deleteApiToken(id))
};
}
)(ApiTokensList);
|
src/svg-icons/communication/stay-primary-portrait.js | spiermar/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationStayPrimaryPortrait = (props) => (
<SvgIcon {...props}>
<path d="M17 1.01L7 1c-1.1 0-1.99.9-1.99 2v18c0 1.1.89 2 1.99 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z"/>
</SvgIcon>
);
CommunicationStayPrimaryPortrait = pure(CommunicationStayPrimaryPortrait);
CommunicationStayPrimaryPortrait.displayName = 'CommunicationStayPrimaryPortrait';
CommunicationStayPrimaryPortrait.muiName = 'SvgIcon';
export default CommunicationStayPrimaryPortrait;
|
src/components/withViewport.js | dadish-etudes/react-todo | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import EventEmitter from 'eventemitter3';
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
let EE;
let viewport = { width: 1366, height: 768 }; // Default size for server-side rendering
const RESIZE_EVENT = 'resize';
function handleWindowResize() {
if (viewport.width !== window.innerWidth || viewport.height !== window.innerHeight) {
viewport = { width: window.innerWidth, height: window.innerHeight };
EE.emit(RESIZE_EVENT, viewport);
}
}
function withViewport(ComposedComponent) {
return class WithViewport extends Component {
constructor() {
super();
this.state = {
viewport: canUseDOM ? { width: window.innerWidth, height: window.innerHeight } : viewport,
};
}
componentDidMount() {
if (!EE) {
EE = new EventEmitter();
window.addEventListener('resize', handleWindowResize);
window.addEventListener('orientationchange', handleWindowResize);
}
EE.on(RESIZE_EVENT, this.handleResize, this);
}
componentWillUnmount() {
EE.removeListener(RESIZE_EVENT, this.handleResize, this);
if (!EE.listeners(RESIZE_EVENT, true)) {
window.removeEventListener('resize', handleWindowResize);
window.removeEventListener('orientationchange', handleWindowResize);
EE = null;
}
}
render() {
return <ComposedComponent {...this.props} viewport={this.state.viewport} />;
}
handleResize(value) {
this.setState({ viewport: value });
}
};
}
export default withViewport;
|
docs/navigation/menu/index.js | aruberto/react-foundation-components | import React from 'react';
import { Menu, MenuItem } from '../../../src/menu';
import {
Menu as FlexMenu,
MenuItem as FlexMenuItem,
} from '../../../lib/menu-flex'; // eslint-disable-line import/no-unresolved
const iconStyle = {
fontStyle: 'normal',
};
const MenuPage = () => (
<div>
<Menu>
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
<Menu horizontalAlignment="right">
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
<Menu horizontalAlignment="center">
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
<Menu expanded>
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
</Menu>
<Menu expanded>
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
</Menu>
<Menu expanded>
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
<Menu vertical horizontal="medium">
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
<Menu horizontal vertical="medium">
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
<Menu simple>
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
<Menu vertical>
<MenuItem>
<a href="#">One</a>
<Menu nested vertical>
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
</MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
<MenuItem><a href="#">Four</a></MenuItem>
</Menu>
<Menu>
<MenuItem active><a href="#">Home</a></MenuItem>
<MenuItem><a href="#">About</a></MenuItem>
<MenuItem><a href="#">Nachos</a></MenuItem>
</Menu>
<Menu>
<MenuItem text>Site Title</MenuItem>
<MenuItem><a href="#">One</a></MenuItem>
<MenuItem><a href="#">Two</a></MenuItem>
<MenuItem><a href="#">Three</a></MenuItem>
</Menu>
<Menu>
<MenuItem><a href="#"><i style={iconStyle}>☰</i> One</a></MenuItem>
<MenuItem><a href="#"><i style={iconStyle}>☰</i> Two</a></MenuItem>
<MenuItem><a href="#"><i style={iconStyle}>☰</i> Three</a></MenuItem>
<MenuItem><a href="#"><i style={iconStyle}>☰</i> Four</a></MenuItem>
</Menu>
<Menu iconTop>
<MenuItem><a href="#"><i style={iconStyle}>☰</i> One</a></MenuItem>
<MenuItem><a href="#"><i style={iconStyle}>☰</i> Two</a></MenuItem>
<MenuItem><a href="#"><i style={iconStyle}>☰</i> Three</a></MenuItem>
<MenuItem><a href="#"><i style={iconStyle}>☰</i> Four</a></MenuItem>
</Menu>
<FlexMenu>
<FlexMenuItem><a href="#">One</a></FlexMenuItem>
<FlexMenuItem><a href="#">Two</a></FlexMenuItem>
<FlexMenuItem><a href="#">Three</a></FlexMenuItem>
<FlexMenuItem><a href="#">Four</a></FlexMenuItem>
</FlexMenu>
<FlexMenu horizontalAlignment="right">
<FlexMenuItem><a href="#">One</a></FlexMenuItem>
<FlexMenuItem><a href="#">Two</a></FlexMenuItem>
<FlexMenuItem><a href="#">Three</a></FlexMenuItem>
<FlexMenuItem><a href="#">Four</a></FlexMenuItem>
</FlexMenu>
<FlexMenu horizontalAlignment="center">
<FlexMenuItem><a href="#">One</a></FlexMenuItem>
<FlexMenuItem><a href="#">Two</a></FlexMenuItem>
<FlexMenuItem><a href="#">Three</a></FlexMenuItem>
<FlexMenuItem><a href="#">Four</a></FlexMenuItem>
</FlexMenu>
</div>
);
export default MenuPage;
|
src/routes/UIElement/dataTable/index.js | shaohuawang2015/goldbeans-admin | import React from 'react'
import { DataTable } from 'components'
import { Table, Row, Col, Card, Select } from 'antd'
class DataTablePage extends React.Component {
constructor (props) {
super(props)
this.state = { filterCase: {
gender: '',
} }
}
handleSelectChange = (gender) => {
this.setState({
filterCase: {
gender,
},
})
}
render () {
const { filterCase } = this.state
const staticDataTableProps = {
dataSource: [{ key: '1', name: 'John Brown', age: 24, address: 'New York' }, { key: '2', name: 'Jim Green', age: 23, address: 'London' }],
columns: [{ title: 'name', dataIndex: 'name' }, { title: 'Age', dataIndex: 'age' }, { title: 'Address', dataIndex: 'address' }],
pagination: false,
}
const fetchDataTableProps = {
fetch: {
url: 'https://randomuser.me/api',
data: {
results: 10,
testPrams: 'test',
},
dataKey: 'results',
},
columns: [
{ title: 'Name', dataIndex: 'name', render: (text) => `${text.first} ${text.last}` },
{ title: 'Phone', dataIndex: 'phone' },
{ title: 'Gender', dataIndex: 'gender' },
],
rowKey: 'registered',
}
const caseChangeDataTableProps = {
fetch: {
url: 'https://randomuser.me/api',
data: {
results: 10,
testPrams: 'test',
...filterCase,
},
dataKey: 'results',
},
columns: [
{ title: 'Name', dataIndex: 'name', render: (text) => `${text.first} ${text.last}` },
{ title: 'Phone', dataIndex: 'phone' },
{ title: 'Gender', dataIndex: 'gender' },
],
rowKey: 'registered',
}
return (<div className="content-inner">
<Row gutter={32}>
<Col lg={12} md={24}>
<Card title="默认">
<DataTable pagination={false} />
</Card>
</Col>
<Col lg={12} md={24}>
<Card title="静态数据">
<DataTable
{...staticDataTableProps}
/>
</Card>
</Col>
<Col lg={12} md={24}>
<Card title="远程数据">
<DataTable
{...fetchDataTableProps}
/>
</Card>
</Col>
<Col lg={12} md={24}>
<Card title="参数变化">
<Select placeholder="Please select gender" allowClear onChange={this.handleSelectChange} style={{ width: 200, marginBottom: 16 }}>
<Select.Option value="male">Male</Select.Option>
<Select.Option value="female">Female</Select.Option>
</Select>
<DataTable
{...caseChangeDataTableProps}
/>
</Card>
</Col>
</Row>
<h2 style={{ margin: '16px 0' }}>Props</h2>
<Row>
<Col lg={18} md={24}>
<Table
rowKey={(record, key) => key}
pagination={false}
bordered
scroll={{ x: 800 }}
columns={[
{
title: '参数',
dataIndex: 'props',
},
{
title: '说明',
dataIndex: 'desciption',
},
{
title: '类型',
dataIndex: 'type',
},
{
title: '默认值',
dataIndex: 'default',
},
]}
dataSource={[
{
props: 'fetch',
desciption: '远程获取数据的参数',
type: 'Object',
default: '后面有空加上',
}]}
/>
</Col>
</Row>
</div>)
}
}
export default DataTablePage
|
spec/components/card.js | rubenmoya/react-toolbox | /* eslint-disable react/prop-types */
import React from 'react';
import Button, { IconButton } from '../../components/button';
import Card, { CardActions, CardMedia, CardText, CardTitle } from '../../components/card';
import style from '../style';
const dummyText = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.';
const Spacer = () => <div style={{ display: 'flex', flex: '1 1 auto' }} />;
const CardList = ({ children }) => <ul className={style.cardsGroup}>{children}</ul>;
const CardListItem = ({ component, name }) => (
<li className={style.cardItem}>
<div className={style.cardItemContent}>{component}</div>
<div className={style.cardItemName}>{name}</div>
</li>
);
const cards = {
basic: [{
name: 'Basic Card',
component: (
<Card className={style.card}>
<CardTitle
title="Title goes here"
subtitle="Subtitle here"
/>
<CardText>{dummyText}</CardText>
<CardActions>
<Button label="Action 1" />
<Button label="Action 2" />
</CardActions>
</Card>
),
}, {
name: 'Raised Card',
component: (
<Card raised className={style.card}>
<CardTitle
title="Title goes here"
subtitle="Subtitle here"
/>
<CardText>{dummyText}</CardText>
<CardActions>
<Button label="Action 1" />
<Button label="Action 2" />
</CardActions>
</Card>
),
}, {
name: 'Customized header',
component: (
<Card className={style.card}>
<CardTitle
title={<u>Title component</u>}
subtitle={<u>Subtitle component</u>}
/>
<CardText>{dummyText}</CardText>
<CardActions>
<Button label="Action 1" />
<Button label="Action 2" />
</CardActions>
</Card>
),
}],
media: [{
name: '16:9 Card Media Area',
component: (
<Card className={style.card}>
<CardMedia
aspectRatio="wide"
className={style.primary}
>
<CardTitle>Basic Card</CardTitle>
</CardMedia>
<CardTitle subtitle="You can also use a subtitle like this" />
<CardText>{dummyText}</CardText>
</Card>
),
}, {
name: '16:9 Card Media Image',
component: (
<Card className={style.card}>
<CardMedia
aspectRatio="wide"
image="https://placeimg.com/800/450/nature"
/>
<CardTitle
title="Title goes here"
subtitle="Subtitle here"
/>
<CardText>{dummyText}</CardText>
</Card>
),
}, {
name: 'Square Media Card',
component: (
<Card className={style.card}>
<CardMedia
contentOverlay
aspectRatio="square"
image="https://placeimg.com/700/700/nature"
>
<CardTitle
title="Title goes here"
subtitle="Subtitle here"
/>
<CardActions>
<Button inverse label="Action 1" />
<Button inverse label="Action 2" />
</CardActions>
</CardMedia>
</Card>
),
}],
avatar: [{
name: 'Avatar Card Title',
component: (
<Card className={style.card}>
<CardTitle
avatar="https://placeimg.com/80/80/animals"
title="Avatar Card"
subtitle="An awesome basic card"
/>
<CardMedia
aspectRatio="wide"
image="https://placeimg.com/800/450/nature"
/>
<CardActions style={{ justifyContent: 'flex-end' }}>
<IconButton icon="share" />
<IconButton icon="favorite" />
</CardActions>
</Card>
),
}, {
name: 'Video in a card',
component: (
<Card className={style.card}>
<CardTitle
avatar="https://placeimg.com/80/80/animals"
title="Avatar Card"
subtitle="An awesome basic card"
/>
<CardMedia
aspectRatio="wide"
>
<iframe width="1280" height="720" src="https://www.youtube.com/embed/sGbxmsDFVnE?rel=0&showinfo=0" frameBorder="0" allowFullScreen />
</CardMedia>
<CardActions style={{ justifyContent: 'flex-end' }}>
<IconButton icon="report_problem" />
<Spacer />
<IconButton icon="share" />
<IconButton icon="favorite" />
</CardActions>
</Card>
),
}],
horizontal: [{
name: 'Alternative Layout Example',
component: (
<Card className={style.card}>
<div className={style.cardRow}>
<CardTitle
title="Title goes here"
subtitle="Subtitle here"
/>
<CardMedia
className={style.media}
image="https://placeimg.com/400/400/nature"
/>
</div>
<CardActions>
<Button label="Action 1" />
<Button label="Action 2" />
</CardActions>
</Card>
),
}, {
name: 'Another Variation',
component: (
<Card>
<div className={style.cardRow}>
<CardTitle
title="Title goes here"
subtitle="Subtitle here"
/>
<CardMedia
className={style.mediaLarge}
image="https://placeimg.com/400/400/nature"
/>
</div>
</Card>
),
}],
small: [{
name: 'Small Media Card',
component: (
<Card>
<CardMedia
aspectRatio="square"
image="https://placeimg.com/400/400/nature"
>
<CardTitle>Test</CardTitle>
</CardMedia>
<CardActions style={{ justifyContent: 'center' }}>
<IconButton icon="thumb_down" />
<IconButton icon="thumb_up" />
<IconButton icon="turned_in_not" />
</CardActions>
</Card>
),
}, {
name: 'Small Media Controls',
component: (
<Card style={{ width: '140px' }}>
<CardMedia
contentOverlay
aspectRatio="square"
image="https://placeimg.com/280/280/people"
>
<CardActions style={{ justifyContent: 'center' }}>
<IconButton inverse icon="fast_rewind" />
<IconButton inverse icon="play_arrow" />
<IconButton inverse icon="fast_forward" />
</CardActions>
</CardMedia>
</Card>
),
}],
};
const CardTest = () => (
<section>
<h5>Cards</h5>
<p>You have multiple options for cards. Combine different subcomponents to create your own:</p>
<div className={style.cards}>
{Object.keys(cards).map(key => (
<CardList key={key}>
{cards[key].map((demo, i) => <CardListItem key={key + i} {...demo} />)}
</CardList>
))}
</div>
</section>
);
export default CardTest;
|
src/Tooltip.js | HPate-Riptide/react-bootstrap | import classNames from 'classnames';
import React from 'react';
import isRequiredForA11y from 'react-prop-types/lib/isRequiredForA11y';
import { bsClass, getClassSet, prefix, splitBsProps }
from './utils/bootstrapUtils';
const propTypes = {
/**
* An html id attribute, necessary for accessibility
* @type {string|number}
* @required
*/
id: isRequiredForA11y(React.PropTypes.oneOfType([
React.PropTypes.string, React.PropTypes.number,
])),
/**
* Sets the direction the Tooltip is positioned towards.
*/
placement: React.PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
/**
* The "top" position value for the Tooltip.
*/
positionTop: React.PropTypes.oneOfType([
React.PropTypes.number, React.PropTypes.string,
]),
/**
* The "left" position value for the Tooltip.
*/
positionLeft: React.PropTypes.oneOfType([
React.PropTypes.number, React.PropTypes.string,
]),
/**
* The "top" position value for the Tooltip arrow.
*/
arrowOffsetTop: React.PropTypes.oneOfType([
React.PropTypes.number, React.PropTypes.string,
]),
/**
* The "left" position value for the Tooltip arrow.
*/
arrowOffsetLeft: React.PropTypes.oneOfType([
React.PropTypes.number, React.PropTypes.string,
]),
};
const defaultProps = {
placement: 'right',
};
class Tooltip extends React.Component {
render() {
const {
placement,
positionTop,
positionLeft,
arrowOffsetTop,
arrowOffsetLeft,
className,
style,
children,
...props
} = this.props;
const [bsProps, elementProps] = splitBsProps(props);
const classes = {
...getClassSet(bsProps),
[placement]: true,
};
const outerStyle = {
top: positionTop,
left: positionLeft,
...style,
};
const arrowStyle = {
top: arrowOffsetTop,
left: arrowOffsetLeft,
};
return (
<div
{...elementProps}
role="tooltip"
className={classNames(className, classes)}
style={outerStyle}
>
<div className={prefix(bsProps, 'arrow')} style={arrowStyle} />
<div className={prefix(bsProps, 'inner')}>
{children}
</div>
</div>
);
}
}
Tooltip.propTypes = propTypes;
Tooltip.defaultProps = defaultProps;
export default bsClass('tooltip', Tooltip);
|
setup/src/universal/services/countries.js | ch-apptitude/goomi | import React from 'react';
import { defineMessages, FormattedMessage } from 'react-intl';
const messages = defineMessages({
AF: {
id: 'app.countries.AF',
defaultMessage: 'Afghanistan',
},
AX: {
id: 'app.countries.AX',
defaultMessage: 'Åland Islands',
},
AL: {
id: 'app.countries.AL',
defaultMessage: 'Albania',
},
DZ: {
id: 'app.countries.DZ',
defaultMessage: 'Algeria',
},
AS: {
id: 'app.countries.AS',
defaultMessage: 'American Samoa',
},
AD: {
id: 'app.countries.AD',
defaultMessage: 'Andorra',
},
AO: {
id: 'app.countries.AO',
defaultMessage: 'Angola',
},
AI: {
id: 'app.countries.AI',
defaultMessage: 'Anguilla',
},
AQ: {
id: 'app.countries.AQ',
defaultMessage: 'Antarctica',
},
AG: {
id: 'app.countries.AG',
defaultMessage: 'Antigua and Barbuda',
},
AR: {
id: 'app.countries.AR',
defaultMessage: 'Argentina',
},
AM: {
id: 'app.countries.AM',
defaultMessage: 'Armenia',
},
AW: {
id: 'app.countries.AW',
defaultMessage: 'Aruba',
},
AU: {
id: 'app.countries.AU',
defaultMessage: 'Australia',
},
AT: {
id: 'app.countries.AT',
defaultMessage: 'Austria',
},
AZ: {
id: 'app.countries.AZ',
defaultMessage: 'Azerbaijan',
},
BS: {
id: 'app.countries.BS',
defaultMessage: 'The Bahamas',
},
BH: {
id: 'app.countries.BH',
defaultMessage: 'Bahrain',
},
BD: {
id: 'app.countries.BD',
defaultMessage: 'Bangladesh',
},
BB: {
id: 'app.countries.BB',
defaultMessage: 'Barbados',
},
BY: {
id: 'app.countries.BY',
defaultMessage: 'Belarus',
},
BE: {
id: 'app.countries.BE',
defaultMessage: 'Belgium',
},
BZ: {
id: 'app.countries.BZ',
defaultMessage: 'Belize',
},
BJ: {
id: 'app.countries.BJ',
defaultMessage: 'Benin',
},
BM: {
id: 'app.countries.BM',
defaultMessage: 'Bermuda',
},
BT: {
id: 'app.countries.BT',
defaultMessage: 'Bhutan',
},
BO: {
id: 'app.countries.BO',
defaultMessage: 'Bolivia',
},
BQ: {
id: 'app.countries.BQ',
defaultMessage: 'Bonaire',
},
BA: {
id: 'app.countries.BA',
defaultMessage: 'Bosnia and Herzegovina',
},
BW: {
id: 'app.countries.BW',
defaultMessage: 'Botswana',
},
BV: {
id: 'app.countries.BV',
defaultMessage: 'Bouvet Island',
},
BR: {
id: 'app.countries.BR',
defaultMessage: 'Brazil',
},
IO: {
id: 'app.countries.IO',
defaultMessage: 'British Indian Ocean Territory',
},
UM: {
id: 'app.countries.UM',
defaultMessage: 'United States Minor Outlying Islands',
},
VG: {
id: 'app.countries.VG',
defaultMessage: 'Virgin Islands (British)',
},
VI: {
id: 'app.countries.VI',
defaultMessage: 'Virgin Islands (U.S.)',
},
BN: {
id: 'app.countries.BN',
defaultMessage: 'Brunei',
},
BG: {
id: 'app.countries.BG',
defaultMessage: 'Bulgaria',
},
BF: {
id: 'app.countries.BF',
defaultMessage: 'Burkina Faso',
},
BI: {
id: 'app.countries.BI',
defaultMessage: 'Burundi',
},
KH: {
id: 'app.countries.KH',
defaultMessage: 'Cambodia',
},
CM: {
id: 'app.countries.CM',
defaultMessage: 'Cameroon',
},
CA: {
id: 'app.countries.CA',
defaultMessage: 'Canada',
},
CV: {
id: 'app.countries.CV',
defaultMessage: 'Cape Verde',
},
KY: {
id: 'app.countries.KY',
defaultMessage: 'Cayman Islands',
},
CF: {
id: 'app.countries.CF',
defaultMessage: 'Central African Republic',
},
TD: {
id: 'app.countries.TD',
defaultMessage: 'Chad',
},
CL: {
id: 'app.countries.CL',
defaultMessage: 'Chile',
},
CN: {
id: 'app.countries.CN',
defaultMessage: 'China',
},
CX: {
id: 'app.countries.CX',
defaultMessage: 'Christmas Island',
},
CC: {
id: 'app.countries.CC',
defaultMessage: 'Cocos (Keeling) Islands',
},
CO: {
id: 'app.countries.CO',
defaultMessage: 'Colombia',
},
KM: {
id: 'app.countries.KM',
defaultMessage: 'Comoros',
},
CG: {
id: 'app.countries.CG',
defaultMessage: 'Republic of the Congo',
},
CD: {
id: 'app.countries.CD',
defaultMessage: 'Democratic Republic of the Congo',
},
CK: {
id: 'app.countries.CK',
defaultMessage: 'Cook Islands',
},
CR: {
id: 'app.countries.CR',
defaultMessage: 'Costa Rica',
},
HR: {
id: 'app.countries.HR',
defaultMessage: 'Croatia',
},
CU: {
id: 'app.countries.CU',
defaultMessage: 'Cuba',
},
CW: {
id: 'app.countries.CW',
defaultMessage: 'Curaçao',
},
CY: {
id: 'app.countries.CY',
defaultMessage: 'Cyprus',
},
CZ: {
id: 'app.countries.CZ',
defaultMessage: 'Czech Republic',
},
DK: {
id: 'app.countries.DK',
defaultMessage: 'Denmark',
},
DJ: {
id: 'app.countries.DJ',
defaultMessage: 'Djibouti',
},
DM: {
id: 'app.countries.DM',
defaultMessage: 'Dominica',
},
DO: {
id: 'app.countries.DO',
defaultMessage: 'Dominican Republic',
},
EC: {
id: 'app.countries.EC',
defaultMessage: 'Ecuador',
},
EG: {
id: 'app.countries.EG',
defaultMessage: 'Egypt',
},
SV: {
id: 'app.countries.SV',
defaultMessage: 'El Salvador',
},
GQ: {
id: 'app.countries.GQ',
defaultMessage: 'Equatorial Guinea',
},
ER: {
id: 'app.countries.ER',
defaultMessage: 'Eritrea',
},
EE: {
id: 'app.countries.EE',
defaultMessage: 'Estonia',
},
ET: {
id: 'app.countries.ET',
defaultMessage: 'Ethiopia',
},
FK: {
id: 'app.countries.FK',
defaultMessage: 'Falkland Islands',
},
FO: {
id: 'app.countries.FO',
defaultMessage: 'Faroe Islands',
},
FJ: {
id: 'app.countries.FJ',
defaultMessage: 'Fiji',
},
FI: {
id: 'app.countries.FI',
defaultMessage: 'Finland',
},
FR: {
id: 'app.countries.FR',
defaultMessage: 'France',
},
GF: {
id: 'app.countries.GF',
defaultMessage: 'French Guiana',
},
PF: {
id: 'app.countries.PF',
defaultMessage: 'French Polynesia',
},
TF: {
id: 'app.countries.TF',
defaultMessage: 'French Southern and Antarctic Lands',
},
GA: {
id: 'app.countries.GA',
defaultMessage: 'Gabon',
},
GM: {
id: 'app.countries.GM',
defaultMessage: 'The Gambia',
},
GE: {
id: 'app.countries.GE',
defaultMessage: 'Georgia',
},
DE: {
id: 'app.countries.DE',
defaultMessage: 'Germany',
},
GH: {
id: 'app.countries.GH',
defaultMessage: 'Ghana',
},
GI: {
id: 'app.countries.GI',
defaultMessage: 'Gibraltar',
},
GR: {
id: 'app.countries.GR',
defaultMessage: 'Greece',
},
GL: {
id: 'app.countries.GL',
defaultMessage: 'Greenland',
},
GD: {
id: 'app.countries.GD',
defaultMessage: 'Grenada',
},
GP: {
id: 'app.countries.GP',
defaultMessage: 'Guadeloupe',
},
GU: {
id: 'app.countries.GU',
defaultMessage: 'Guam',
},
GT: {
id: 'app.countries.GT',
defaultMessage: 'Guatemala',
},
GG: {
id: 'app.countries.GG',
defaultMessage: 'Guernsey',
},
GW: {
id: 'app.countries.GW',
defaultMessage: 'Guinea-Bissau',
},
GY: {
id: 'app.countries.GY',
defaultMessage: 'Guyana',
},
HT: {
id: 'app.countries.HT',
defaultMessage: 'Haiti',
},
HM: {
id: 'app.countries.HM',
defaultMessage: 'Heard Island and McDonald Islands',
},
VA: {
id: 'app.countries.VA',
defaultMessage: 'Holy See',
},
HN: {
id: 'app.countries.HN',
defaultMessage: 'Honduras',
},
HK: {
id: 'app.countries.HK',
defaultMessage: 'Hong Kong',
},
HU: {
id: 'app.countries.HU',
defaultMessage: 'Hungary',
},
IS: {
id: 'app.countries.IS',
defaultMessage: 'Iceland',
},
IN: {
id: 'app.countries.IN',
defaultMessage: 'India',
},
ID: {
id: 'app.countries.ID',
defaultMessage: 'Indonesia',
},
CI: {
id: 'app.countries.CI',
defaultMessage: 'Ivory Coast',
},
IR: {
id: 'app.countries.IR',
defaultMessage: 'Iran',
},
IQ: {
id: 'app.countries.IQ',
defaultMessage: 'Iraq',
},
IE: {
id: 'app.countries.IE',
defaultMessage: 'Republic of Ireland',
},
IM: {
id: 'app.countries.IM',
defaultMessage: 'Isle of Man',
},
IL: {
id: 'app.countries.IL',
defaultMessage: 'Israel',
},
IT: {
id: 'app.countries.IT',
defaultMessage: 'Italy',
},
JM: {
id: 'app.countries.JM',
defaultMessage: 'Jamaica',
},
JP: {
id: 'app.countries.JP',
defaultMessage: 'Japan',
},
JE: {
id: 'app.countries.JE',
defaultMessage: 'Jersey',
},
JO: {
id: 'app.countries.JO',
defaultMessage: 'Jordan',
},
KZ: {
id: 'app.countries.KZ',
defaultMessage: 'Kazakhstan',
},
KE: {
id: 'app.countries.KE',
defaultMessage: 'Kenya',
},
KI: {
id: 'app.countries.KI',
defaultMessage: 'Kiribati',
},
KW: {
id: 'app.countries.KW',
defaultMessage: 'Kuwait',
},
KG: {
id: 'app.countries.KG',
defaultMessage: 'Kyrgyzstan',
},
LA: {
id: 'app.countries.LA',
defaultMessage: 'Laos',
},
LV: {
id: 'app.countries.LV',
defaultMessage: 'Latvia',
},
LB: {
id: 'app.countries.LB',
defaultMessage: 'Lebanon',
},
LS: {
id: 'app.countries.LS',
defaultMessage: 'Lesotho',
},
LR: {
id: 'app.countries.LR',
defaultMessage: 'Liberia',
},
LY: {
id: 'app.countries.LY',
defaultMessage: 'Libya',
},
LI: {
id: 'app.countries.LI',
defaultMessage: 'Liechtenstein',
},
LT: {
id: 'app.countries.LT',
defaultMessage: 'Lithuania',
},
LU: {
id: 'app.countries.LU',
defaultMessage: 'Luxembourg',
},
MO: {
id: 'app.countries.MO',
defaultMessage: 'Macau',
},
MK: {
id: 'app.countries.MK',
defaultMessage: 'Republic of Macedonia',
},
MG: {
id: 'app.countries.MG',
defaultMessage: 'Madagascar',
},
MW: {
id: 'app.countries.MW',
defaultMessage: 'Malawi',
},
MY: {
id: 'app.countries.MY',
defaultMessage: 'Malaysia',
},
MV: {
id: 'app.countries.MV',
defaultMessage: 'Maldives',
},
ML: {
id: 'app.countries.ML',
defaultMessage: 'Mali',
},
MT: {
id: 'app.countries.MT',
defaultMessage: 'Malta',
},
MH: {
id: 'app.countries.MH',
defaultMessage: 'Marshall Islands',
},
MQ: {
id: 'app.countries.MQ',
defaultMessage: 'Martinique',
},
MR: {
id: 'app.countries.MR',
defaultMessage: 'Mauritania',
},
MU: {
id: 'app.countries.MU',
defaultMessage: 'Mauritius',
},
YT: {
id: 'app.countries.YT',
defaultMessage: 'Mayotte',
},
MX: {
id: 'app.countries.MX',
defaultMessage: 'Mexico',
},
FM: {
id: 'app.countries.FM',
defaultMessage: 'Federated States of Micronesia',
},
MD: {
id: 'app.countries.MD',
defaultMessage: 'Moldova',
},
MC: {
id: 'app.countries.MC',
defaultMessage: 'Monaco',
},
MN: {
id: 'app.countries.MN',
defaultMessage: 'Mongolia',
},
ME: {
id: 'app.countries.ME',
defaultMessage: 'Montenegro',
},
MS: {
id: 'app.countries.MS',
defaultMessage: 'Montserrat',
},
MA: {
id: 'app.countries.MA',
defaultMessage: 'Morocco',
},
MZ: {
id: 'app.countries.MZ',
defaultMessage: 'Mozambique',
},
MM: {
id: 'app.countries.MM',
defaultMessage: 'Myanmar',
},
NA: {
id: 'app.countries.NA',
defaultMessage: 'Namibia',
},
NR: {
id: 'app.countries.NR',
defaultMessage: 'Nauru',
},
NP: {
id: 'app.countries.NP',
defaultMessage: 'Nepal',
},
NL: {
id: 'app.countries.NL',
defaultMessage: 'Netherlands',
},
NC: {
id: 'app.countries.NC',
defaultMessage: 'New Caledonia',
},
NZ: {
id: 'app.countries.NZ',
defaultMessage: 'New Zealand',
},
NI: {
id: 'app.countries.NI',
defaultMessage: 'Nicaragua',
},
NE: {
id: 'app.countries.NE',
defaultMessage: 'Niger',
},
NG: {
id: 'app.countries.NG',
defaultMessage: 'Nigeria',
},
NU: {
id: 'app.countries.NU',
defaultMessage: 'Niue',
},
NF: {
id: 'app.countries.NF',
defaultMessage: 'Norfolk Island',
},
KP: {
id: 'app.countries.KP',
defaultMessage: 'North Korea',
},
MP: {
id: 'app.countries.MP',
defaultMessage: 'Northern Mariana Islands',
},
NO: {
id: 'app.countries.NO',
defaultMessage: 'Norway',
},
OM: {
id: 'app.countries.OM',
defaultMessage: 'Oman',
},
PK: {
id: 'app.countries.PK',
defaultMessage: 'Pakistan',
},
PW: {
id: 'app.countries.PW',
defaultMessage: 'Palau',
},
PS: {
id: 'app.countries.PS',
defaultMessage: 'Palestine',
},
PA: {
id: 'app.countries.PA',
defaultMessage: 'Panama',
},
PG: {
id: 'app.countries.PG',
defaultMessage: 'Papua New Guinea',
},
PY: {
id: 'app.countries.PY',
defaultMessage: 'Paraguay',
},
PE: {
id: 'app.countries.PE',
defaultMessage: 'Peru',
},
PH: {
id: 'app.countries.PH',
defaultMessage: 'Philippines',
},
PN: {
id: 'app.countries.PN',
defaultMessage: 'Pitcairn Islands',
},
PL: {
id: 'app.countries.PL',
defaultMessage: 'Poland',
},
PT: {
id: 'app.countries.PT',
defaultMessage: 'Portugal',
},
PR: {
id: 'app.countries.PR',
defaultMessage: 'Puerto Rico',
},
QA: {
id: 'app.countries.QA',
defaultMessage: 'Qatar',
},
XK: {
id: 'app.countries.XK',
defaultMessage: 'Republic of Kosovo',
},
RE: {
id: 'app.countries.RE',
defaultMessage: 'Réunion',
},
RO: {
id: 'app.countries.RO',
defaultMessage: 'Romania',
},
RU: {
id: 'app.countries.RU',
defaultMessage: 'Russia',
},
RW: {
id: 'app.countries.RW',
defaultMessage: 'Rwanda',
},
BL: {
id: 'app.countries.BL',
defaultMessage: 'Saint Barthélemy',
},
SH: {
id: 'app.countries.SH',
defaultMessage: 'Saint Helena',
},
KN: {
id: 'app.countries.KN',
defaultMessage: 'Saint Kitts and Nevis',
},
LC: {
id: 'app.countries.LC',
defaultMessage: 'Saint Lucia',
},
MF: {
id: 'app.countries.MF',
defaultMessage: 'Saint Martin',
},
PM: {
id: 'app.countries.PM',
defaultMessage: 'Saint Pierre and Miquelon',
},
VC: {
id: 'app.countries.VC',
defaultMessage: 'Saint Vincent and the Grenadines',
},
WS: {
id: 'app.countries.WS',
defaultMessage: 'Samoa',
},
SM: {
id: 'app.countries.SM',
defaultMessage: 'San Marino',
},
ST: {
id: 'app.countries.ST',
defaultMessage: 'São Tomé and Príncipe',
},
SA: {
id: 'app.countries.SA',
defaultMessage: 'Saudi Arabia',
},
SN: {
id: 'app.countries.SN',
defaultMessage: 'Senegal',
},
RS: {
id: 'app.countries.RS',
defaultMessage: 'Serbia',
},
SC: {
id: 'app.countries.SC',
defaultMessage: 'Seychelles',
},
SL: {
id: 'app.countries.SL',
defaultMessage: 'Sierra Leone',
},
SG: {
id: 'app.countries.SG',
defaultMessage: 'Singapore',
},
SX: {
id: 'app.countries.SX',
defaultMessage: 'Sint Maarten',
},
SK: {
id: 'app.countries.SK',
defaultMessage: 'Slovakia',
},
SI: {
id: 'app.countries.SI',
defaultMessage: 'Slovenia',
},
SB: {
id: 'app.countries.SB',
defaultMessage: 'Solomon Islands',
},
SO: {
id: 'app.countries.SO',
defaultMessage: 'Somalia',
},
ZA: {
id: 'app.countries.ZA',
defaultMessage: 'South Africa',
},
GS: {
id: 'app.countries.GS',
defaultMessage: 'South Georgia',
},
KR: {
id: 'app.countries.KR',
defaultMessage: 'South Korea',
},
SS: {
id: 'app.countries.SS',
defaultMessage: 'South Sudan',
},
ES: {
id: 'app.countries.ES',
defaultMessage: 'Spain',
},
LK: {
id: 'app.countries.LK',
defaultMessage: 'Sri Lanka',
},
SD: {
id: 'app.countries.SD',
defaultMessage: 'Sudan',
},
SR: {
id: 'app.countries.SR',
defaultMessage: 'Surinae',
},
SJ: {
id: 'app.countries.SJ',
defaultMessage: 'Svalbard and Jan Mayen',
},
SZ: {
id: 'app.countries.SZ',
defaultMessage: 'Swaziland',
},
SE: {
id: 'app.countries.SE',
defaultMessage: 'Sweden',
},
CH: {
id: 'app.countries.CH',
defaultMessage: 'Switzerland',
},
SY: {
id: 'app.countries.SY',
defaultMessage: 'Syria',
},
TW: {
id: 'app.countries.TW',
defaultMessage: 'Taiwan',
},
TJ: {
id: 'app.countries.TJ',
defaultMessage: 'Tajikistan',
},
TZ: {
id: 'app.countries.TZ',
defaultMessage: 'Tanzania',
},
TH: {
id: 'app.countries.TH',
defaultMessage: 'Thailand',
},
TL: {
id: 'app.countries.TL',
defaultMessage: 'East Timor',
},
TG: {
id: 'app.countries.TG',
defaultMessage: 'Togo',
},
TK: {
id: 'app.countries.TK',
defaultMessage: 'Tokelau',
},
TO: {
id: 'app.countries.TO',
defaultMessage: 'Tonga',
},
TT: {
id: 'app.countries.TT',
defaultMessage: 'Trinidad and Tobago',
},
TN: {
id: 'app.countries.TN',
defaultMessage: 'Tunisia',
},
TR: {
id: 'app.countries.TR',
defaultMessage: 'Turkey',
},
TM: {
id: 'app.countries.TM',
defaultMessage: 'Turkmenistan',
},
TC: {
id: 'app.countries.TC',
defaultMessage: 'Turks and Caicos Islands',
},
TV: {
id: 'app.countries.TV',
defaultMessage: 'Tuvalu',
},
UG: {
id: 'app.countries.UG',
defaultMessage: 'Uganda',
},
UA: {
id: 'app.countries.UA',
defaultMessage: 'Ukraine',
},
AE: {
id: 'app.countries.AE',
defaultMessage: 'United Arab Emirates',
},
GB: {
id: 'app.countries.GB',
defaultMessage: 'United Kingdom',
},
US: {
id: 'app.countries.US',
defaultMessage: 'United States',
},
UY: {
id: 'app.countries.UY',
defaultMessage: 'Uruguay',
},
UZ: {
id: 'app.countries.UZ',
defaultMessage: 'Uzbekistan',
},
VU: {
id: 'app.countries.VU',
defaultMessage: 'Vanuatu',
},
VE: {
id: 'app.countries.VE',
defaultMessage: 'Venezuela',
},
VN: {
id: 'app.countries.VN',
defaultMessage: 'Vietnam',
},
WF: {
id: 'app.countries.WF',
defaultMessage: 'Wallis and Futuna',
},
EH: {
id: 'app.countries.EH',
defaultMessage: 'Western Sahara',
},
YE: {
id: 'app.countries.YE',
defaultMessage: 'Yemen',
},
ZM: {
id: 'app.countries.ZM',
defaultMessage: 'Zambia',
},
ZW: {
id: 'app.countries.ZW',
defaultMessage: 'Zimbabwe',
},
});
export default [
{
value: 'AF',
label: <FormattedMessage {...messages.AF} />,
},
{
value: 'AX',
label: <FormattedMessage {...messages.AX} />,
},
{
value: 'AL',
label: <FormattedMessage {...messages.AL} />,
},
{
value: 'DZ',
label: <FormattedMessage {...messages.DZ} />,
},
{
value: 'AS',
label: <FormattedMessage {...messages.AS} />,
},
{
value: 'AD',
label: <FormattedMessage {...messages.AD} />,
},
{
value: 'AO',
label: <FormattedMessage {...messages.AO} />,
},
{
value: 'AI',
label: <FormattedMessage {...messages.AI} />,
},
{
value: 'AQ',
label: <FormattedMessage {...messages.AQ} />,
},
{
value: 'AG',
label: <FormattedMessage {...messages.AG} />,
},
{
value: 'AR',
label: <FormattedMessage {...messages.AR} />,
},
{
value: 'AM',
label: <FormattedMessage {...messages.AM} />,
},
{
value: 'AW',
label: <FormattedMessage {...messages.AW} />,
},
{
value: 'AU',
label: <FormattedMessage {...messages.AU} />,
},
{
value: 'AT',
label: <FormattedMessage {...messages.AT} />,
},
{
value: 'AZ',
label: <FormattedMessage {...messages.AZ} />,
},
{
value: 'BS',
label: <FormattedMessage {...messages.BS} />,
},
{
value: 'BH',
label: <FormattedMessage {...messages.BH} />,
},
{
value: 'BD',
label: <FormattedMessage {...messages.BD} />,
},
{
value: 'BB',
label: <FormattedMessage {...messages.BB} />,
},
{
value: 'BY',
label: <FormattedMessage {...messages.BY} />,
},
{
value: 'BE',
label: <FormattedMessage {...messages.BE} />,
},
{
value: 'BZ',
label: <FormattedMessage {...messages.BZ} />,
},
{
value: 'BJ',
label: <FormattedMessage {...messages.BJ} />,
},
{
value: 'BM',
label: <FormattedMessage {...messages.BM} />,
},
{
value: 'BT',
label: <FormattedMessage {...messages.BT} />,
},
{
value: 'BO',
label: <FormattedMessage {...messages.BO} />,
},
{
value: 'BQ',
label: <FormattedMessage {...messages.BQ} />,
},
{
value: 'BA',
label: <FormattedMessage {...messages.BA} />,
},
{
value: 'BW',
label: <FormattedMessage {...messages.BW} />,
},
{
value: 'BV',
label: <FormattedMessage {...messages.BV} />,
},
{
value: 'BR',
label: <FormattedMessage {...messages.BR} />,
},
{
value: 'IO',
label: <FormattedMessage {...messages.IO} />,
},
{
value: 'UM',
label: <FormattedMessage {...messages.UM} />,
},
{
value: 'VG',
label: <FormattedMessage {...messages.VG} />,
},
{
value: 'VI',
label: <FormattedMessage {...messages.VI} />,
},
{
value: 'BN',
label: <FormattedMessage {...messages.BN} />,
},
{
value: 'BG',
label: <FormattedMessage {...messages.BG} />,
},
{
value: 'BF',
label: <FormattedMessage {...messages.BF} />,
},
{
value: 'BI',
label: <FormattedMessage {...messages.BI} />,
},
{
value: 'KH',
label: <FormattedMessage {...messages.KH} />,
},
{
value: 'CM',
label: <FormattedMessage {...messages.CM} />,
},
{
value: 'CA',
label: <FormattedMessage {...messages.CA} />,
},
{
value: 'CV',
label: <FormattedMessage {...messages.CV} />,
},
{
value: 'KY',
label: <FormattedMessage {...messages.KY} />,
},
{
value: 'CF',
label: <FormattedMessage {...messages.CF} />,
},
{
value: 'TD',
label: <FormattedMessage {...messages.TD} />,
},
{
value: 'CL',
label: <FormattedMessage {...messages.CL} />,
},
{
value: 'CN',
label: <FormattedMessage {...messages.CN} />,
},
{
value: 'CX',
label: <FormattedMessage {...messages.CX} />,
},
{
value: 'CC',
label: <FormattedMessage {...messages.CC} />,
},
{
value: 'CO',
label: <FormattedMessage {...messages.CO} />,
},
{
value: 'KM',
label: <FormattedMessage {...messages.KM} />,
},
{
value: 'CG',
label: <FormattedMessage {...messages.CG} />,
},
{
value: 'CD',
label: <FormattedMessage {...messages.CD} />,
},
{
value: 'CK',
label: <FormattedMessage {...messages.CK} />,
},
{
value: 'CR',
label: <FormattedMessage {...messages.CR} />,
},
{
value: 'HR',
label: <FormattedMessage {...messages.HR} />,
},
{
value: 'CU',
label: <FormattedMessage {...messages.CU} />,
},
{
value: 'CW',
label: <FormattedMessage {...messages.CW} />,
},
{
value: 'CY',
label: <FormattedMessage {...messages.CY} />,
},
{
value: 'CZ',
label: <FormattedMessage {...messages.CZ} />,
},
{
value: 'DK',
label: <FormattedMessage {...messages.DK} />,
},
{
value: 'DJ',
label: <FormattedMessage {...messages.DJ} />,
},
{
value: 'DM',
label: <FormattedMessage {...messages.DM} />,
},
{
value: 'DO',
label: <FormattedMessage {...messages.DO} />,
},
{
value: 'EC',
label: <FormattedMessage {...messages.EC} />,
},
{
value: 'EG',
label: <FormattedMessage {...messages.EG} />,
},
{
value: 'SV',
label: <FormattedMessage {...messages.SV} />,
},
{
value: 'GQ',
label: <FormattedMessage {...messages.GQ} />,
},
{
value: 'ER',
label: <FormattedMessage {...messages.ER} />,
},
{
value: 'EE',
label: <FormattedMessage {...messages.EE} />,
},
{
value: 'ET',
label: <FormattedMessage {...messages.ET} />,
},
{
value: 'FK',
label: <FormattedMessage {...messages.FK} />,
},
{
value: 'FO',
label: <FormattedMessage {...messages.FO} />,
},
{
value: 'FJ',
label: <FormattedMessage {...messages.FJ} />,
},
{
value: 'FI',
label: <FormattedMessage {...messages.FI} />,
},
{
value: 'FR',
label: <FormattedMessage {...messages.FR} />,
},
{
value: 'GF',
label: <FormattedMessage {...messages.GF} />,
},
{
value: 'PF',
label: <FormattedMessage {...messages.PF} />,
},
{
value: 'TF',
label: <FormattedMessage {...messages.TF} />,
},
{
value: 'GA',
label: <FormattedMessage {...messages.GA} />,
},
{
value: 'GM',
label: <FormattedMessage {...messages.GM} />,
},
{
value: 'GE',
label: <FormattedMessage {...messages.GE} />,
},
{
value: 'DE',
label: <FormattedMessage {...messages.DE} />,
},
{
value: 'GH',
label: <FormattedMessage {...messages.GH} />,
},
{
value: 'GI',
label: <FormattedMessage {...messages.GI} />,
},
{
value: 'GR',
label: <FormattedMessage {...messages.GR} />,
},
{
value: 'GL',
label: <FormattedMessage {...messages.GL} />,
},
{
value: 'GD',
label: <FormattedMessage {...messages.GD} />,
},
{
value: 'GP',
label: <FormattedMessage {...messages.GP} />,
},
{
value: 'GU',
label: <FormattedMessage {...messages.GU} />,
},
{
value: 'GT',
label: <FormattedMessage {...messages.GT} />,
},
{
value: 'GG',
label: <FormattedMessage {...messages.GG} />,
},
{
value: 'GW',
label: <FormattedMessage {...messages.GW} />,
},
{
value: 'GY',
label: <FormattedMessage {...messages.GY} />,
},
{
value: 'HT',
label: <FormattedMessage {...messages.HT} />,
},
{
value: 'HM',
label: <FormattedMessage {...messages.HM} />,
},
{
value: 'VA',
label: <FormattedMessage {...messages.VA} />,
},
{
value: 'HN',
label: <FormattedMessage {...messages.HN} />,
},
{
value: 'HK',
label: <FormattedMessage {...messages.HK} />,
},
{
value: 'HU',
label: <FormattedMessage {...messages.HU} />,
},
{
value: 'IS',
label: <FormattedMessage {...messages.IS} />,
},
{
value: 'IN',
label: <FormattedMessage {...messages.IN} />,
},
{
value: 'ID',
label: <FormattedMessage {...messages.ID} />,
},
{
value: 'CI',
label: <FormattedMessage {...messages.CI} />,
},
{
value: 'IR',
label: <FormattedMessage {...messages.IR} />,
},
{
value: 'IQ',
label: <FormattedMessage {...messages.IQ} />,
},
{
value: 'IE',
label: <FormattedMessage {...messages.IE} />,
},
{
value: 'IM',
label: <FormattedMessage {...messages.IM} />,
},
{
value: 'IL',
label: <FormattedMessage {...messages.IL} />,
},
{
value: 'IT',
label: <FormattedMessage {...messages.IT} />,
},
{
value: 'JM',
label: <FormattedMessage {...messages.JM} />,
},
{
value: 'JP',
label: <FormattedMessage {...messages.JP} />,
},
{
value: 'JE',
label: <FormattedMessage {...messages.JE} />,
},
{
value: 'JO',
label: <FormattedMessage {...messages.JO} />,
},
{
value: 'KZ',
label: <FormattedMessage {...messages.KZ} />,
},
{
value: 'KE',
label: <FormattedMessage {...messages.KE} />,
},
{
value: 'KI',
label: <FormattedMessage {...messages.KI} />,
},
{
value: 'KW',
label: <FormattedMessage {...messages.KW} />,
},
{
value: 'KG',
label: <FormattedMessage {...messages.KG} />,
},
{
value: 'LA',
label: <FormattedMessage {...messages.LA} />,
},
{
value: 'LV',
label: <FormattedMessage {...messages.LV} />,
},
{
value: 'LB',
label: <FormattedMessage {...messages.LB} />,
},
{
value: 'LS',
label: <FormattedMessage {...messages.LS} />,
},
{
value: 'LR',
label: <FormattedMessage {...messages.LR} />,
},
{
value: 'LY',
label: <FormattedMessage {...messages.LY} />,
},
{
value: 'LI',
label: <FormattedMessage {...messages.LI} />,
},
{
value: 'LT',
label: <FormattedMessage {...messages.LT} />,
},
{
value: 'LU',
label: <FormattedMessage {...messages.LU} />,
},
{
value: 'MO',
label: <FormattedMessage {...messages.MO} />,
},
{
value: 'MK',
label: <FormattedMessage {...messages.MK} />,
},
{
value: 'MG',
label: <FormattedMessage {...messages.MG} />,
},
{
value: 'MW',
label: <FormattedMessage {...messages.MW} />,
},
{
value: 'MY',
label: <FormattedMessage {...messages.MY} />,
},
{
value: 'MV',
label: <FormattedMessage {...messages.MV} />,
},
{
value: 'ML',
label: <FormattedMessage {...messages.ML} />,
},
{
value: 'MT',
label: <FormattedMessage {...messages.MT} />,
},
{
value: 'MH',
label: <FormattedMessage {...messages.MH} />,
},
{
value: 'MQ',
label: <FormattedMessage {...messages.MQ} />,
},
{
value: 'MR',
label: <FormattedMessage {...messages.MR} />,
},
{
value: 'MU',
label: <FormattedMessage {...messages.MU} />,
},
{
value: 'YT',
label: <FormattedMessage {...messages.YT} />,
},
{
value: 'MX',
label: <FormattedMessage {...messages.MX} />,
},
{
value: 'FM',
label: <FormattedMessage {...messages.FM} />,
},
{
value: 'MD',
label: <FormattedMessage {...messages.MD} />,
},
{
value: 'MC',
label: <FormattedMessage {...messages.MC} />,
},
{
value: 'MN',
label: <FormattedMessage {...messages.MN} />,
},
{
value: 'ME',
label: <FormattedMessage {...messages.ME} />,
},
{
value: 'MS',
label: <FormattedMessage {...messages.MS} />,
},
{
value: 'MA',
label: <FormattedMessage {...messages.MA} />,
},
{
value: 'MZ',
label: <FormattedMessage {...messages.MZ} />,
},
{
value: 'MM',
label: <FormattedMessage {...messages.MM} />,
},
{
value: 'NA',
label: <FormattedMessage {...messages.NA} />,
},
{
value: 'NR',
label: <FormattedMessage {...messages.NR} />,
},
{
value: 'NP',
label: <FormattedMessage {...messages.NP} />,
},
{
value: 'NL',
label: <FormattedMessage {...messages.NL} />,
},
{
value: 'NC',
label: <FormattedMessage {...messages.NC} />,
},
{
value: 'NZ',
label: <FormattedMessage {...messages.NZ} />,
},
{
value: 'NI',
label: <FormattedMessage {...messages.NI} />,
},
{
value: 'NE',
label: <FormattedMessage {...messages.NE} />,
},
{
value: 'NG',
label: <FormattedMessage {...messages.NG} />,
},
{
value: 'NU',
label: <FormattedMessage {...messages.NU} />,
},
{
value: 'NF',
label: <FormattedMessage {...messages.NF} />,
},
{
value: 'KP',
label: <FormattedMessage {...messages.KP} />,
},
{
value: 'MP',
label: <FormattedMessage {...messages.MP} />,
},
{
value: 'NO',
label: <FormattedMessage {...messages.NO} />,
},
{
value: 'OM',
label: <FormattedMessage {...messages.OM} />,
},
{
value: 'PK',
label: <FormattedMessage {...messages.PK} />,
},
{
value: 'PW',
label: <FormattedMessage {...messages.PW} />,
},
{
value: 'PS',
label: <FormattedMessage {...messages.PS} />,
},
{
value: 'PA',
label: <FormattedMessage {...messages.PA} />,
},
{
value: 'PG',
label: <FormattedMessage {...messages.PG} />,
},
{
value: 'PY',
label: <FormattedMessage {...messages.PY} />,
},
{
value: 'PE',
label: <FormattedMessage {...messages.PE} />,
},
{
value: 'PH',
label: <FormattedMessage {...messages.PH} />,
},
{
value: 'PN',
label: <FormattedMessage {...messages.PN} />,
},
{
value: 'PL',
label: <FormattedMessage {...messages.PL} />,
},
{
value: 'PT',
label: <FormattedMessage {...messages.PT} />,
},
{
value: 'PR',
label: <FormattedMessage {...messages.PR} />,
},
{
value: 'QA',
label: <FormattedMessage {...messages.QA} />,
},
{
value: 'XK',
label: <FormattedMessage {...messages.XK} />,
},
{
value: 'RE',
label: <FormattedMessage {...messages.RE} />,
},
{
value: 'RO',
label: <FormattedMessage {...messages.RO} />,
},
{
value: 'RU',
label: <FormattedMessage {...messages.RU} />,
},
{
value: 'RW',
label: <FormattedMessage {...messages.RW} />,
},
{
value: 'BL',
label: <FormattedMessage {...messages.BL} />,
},
{
value: 'SH',
label: <FormattedMessage {...messages.SH} />,
},
{
value: 'KN',
label: <FormattedMessage {...messages.KN} />,
},
{
value: 'LC',
label: <FormattedMessage {...messages.LC} />,
},
{
value: 'MF',
label: <FormattedMessage {...messages.MF} />,
},
{
value: 'PM',
label: <FormattedMessage {...messages.PM} />,
},
{
value: 'VC',
label: <FormattedMessage {...messages.VC} />,
},
{
value: 'WS',
label: <FormattedMessage {...messages.WS} />,
},
{
value: 'SM',
label: <FormattedMessage {...messages.SM} />,
},
{
value: 'ST',
label: <FormattedMessage {...messages.ST} />,
},
{
value: 'SA',
label: <FormattedMessage {...messages.SA} />,
},
{
value: 'SN',
label: <FormattedMessage {...messages.SN} />,
},
{
value: 'RS',
label: <FormattedMessage {...messages.RS} />,
},
{
value: 'SC',
label: <FormattedMessage {...messages.SC} />,
},
{
value: 'SL',
label: <FormattedMessage {...messages.SL} />,
},
{
value: 'SG',
label: <FormattedMessage {...messages.SG} />,
},
{
value: 'SX',
label: <FormattedMessage {...messages.SX} />,
},
{
value: 'SK',
label: <FormattedMessage {...messages.SK} />,
},
{
value: 'SI',
label: <FormattedMessage {...messages.SI} />,
},
{
value: 'SB',
label: <FormattedMessage {...messages.SB} />,
},
{
value: 'SO',
label: <FormattedMessage {...messages.SO} />,
},
{
value: 'ZA',
label: <FormattedMessage {...messages.ZA} />,
},
{
value: 'GS',
label: <FormattedMessage {...messages.GS} />,
},
{
value: 'KR',
label: <FormattedMessage {...messages.KR} />,
},
{
value: 'SS',
label: <FormattedMessage {...messages.SS} />,
},
{
value: 'ES',
label: <FormattedMessage {...messages.ES} />,
},
{
value: 'LK',
label: <FormattedMessage {...messages.LK} />,
},
{
value: 'SD',
label: <FormattedMessage {...messages.SD} />,
},
{
value: 'SR',
label: <FormattedMessage {...messages.SR} />,
},
{
value: 'SJ',
label: <FormattedMessage {...messages.SJ} />,
},
{
value: 'SZ',
label: <FormattedMessage {...messages.SZ} />,
},
{
value: 'SE',
label: <FormattedMessage {...messages.SE} />,
},
{
value: 'CH',
label: <FormattedMessage {...messages.CH} />,
},
{
value: 'SY',
label: <FormattedMessage {...messages.SY} />,
},
{
value: 'TW',
label: <FormattedMessage {...messages.TW} />,
},
{
value: 'TJ',
label: <FormattedMessage {...messages.TJ} />,
},
{
value: 'TZ',
label: <FormattedMessage {...messages.TZ} />,
},
{
value: 'TH',
label: <FormattedMessage {...messages.TH} />,
},
{
value: 'TL',
label: <FormattedMessage {...messages.TL} />,
},
{
value: 'TG',
label: <FormattedMessage {...messages.TG} />,
},
{
value: 'TK',
label: <FormattedMessage {...messages.TK} />,
},
{
value: 'TO',
label: <FormattedMessage {...messages.TO} />,
},
{
value: 'TT',
label: <FormattedMessage {...messages.TT} />,
},
{
value: 'TN',
label: <FormattedMessage {...messages.TN} />,
},
{
value: 'TR',
label: <FormattedMessage {...messages.TR} />,
},
{
value: 'TM',
label: <FormattedMessage {...messages.TM} />,
},
{
value: 'TC',
label: <FormattedMessage {...messages.TC} />,
},
{
value: 'TV',
label: <FormattedMessage {...messages.TV} />,
},
{
value: 'UG',
label: <FormattedMessage {...messages.UG} />,
},
{
value: 'UA',
label: <FormattedMessage {...messages.UA} />,
},
{
value: 'AE',
label: <FormattedMessage {...messages.AE} />,
},
{
value: 'GB',
label: <FormattedMessage {...messages.GB} />,
},
{
value: 'US',
label: <FormattedMessage {...messages.US} />,
},
{
value: 'UY',
label: <FormattedMessage {...messages.UY} />,
},
{
value: 'UZ',
label: <FormattedMessage {...messages.UZ} />,
},
{
value: 'VU',
label: <FormattedMessage {...messages.VU} />,
},
{
value: 'VE',
label: <FormattedMessage {...messages.VE} />,
},
{
value: 'VN',
label: <FormattedMessage {...messages.VN} />,
},
{
value: 'WF',
label: <FormattedMessage {...messages.WF} />,
},
{
value: 'EH',
label: <FormattedMessage {...messages.EH} />,
},
{
value: 'YE',
label: <FormattedMessage {...messages.YE} />,
},
{
value: 'ZM',
label: <FormattedMessage {...messages.ZM} />,
},
{
value: 'ZW',
label: 'Zimbabwe',
},
];
|
data-viz/react/game-of-life/src/App.js | mkermani144/freecodecamp-projects | import React, { Component } from 'react';
import BoardContainer from './BoardContainer';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import IconButton from 'material-ui/IconButton';
import RaisedButton from 'material-ui/RaisedButton';
import AvPause from 'material-ui/svg-icons/av/pause';
import AvPlayArrow from 'material-ui/svg-icons/av/play-arrow';
import ImageNavigateNext from 'material-ui/svg-icons/image/navigate-next';
import './App.css';
class App extends Component {
constructor() {
super();
this.state = {
mustPlay: 1,
pauseOrPlay: 'pause',
generation: 0
};
}
render() {
let pauseOrPlay;
if (this.state.pauseOrPlay === 'pause') {
pauseOrPlay = (
<IconButton>
<AvPause onClick={() => {
this.setState({
mustPlay: 0,
pauseOrPlay: 'play'
});
}}/>
</IconButton>
);
} else {
pauseOrPlay = (
<IconButton>
<AvPlayArrow onClick={() => {
this.setState({
mustPlay: 1,
pauseOrPlay: 'pause'
});
}}/>
</IconButton>
);
}
return (
<MuiThemeProvider>
<div className="App">
<p>Game of <strong>Life</strong></p>
<div className="generationNumber">Generation: {this.state.generation}</div>
<BoardContainer
mustPlay={this.state.mustPlay}
reportPlay={(clear) => {
this.setState((prev) => {
return {
mustPlay: !clear,
generation: prev.generation + 1
}
});
}}
/>
<div className="controls">
<IconButton disabled={this.state.pauseOrPlay === 'pause'}>
<ImageNavigateNext onClick={() => this.setState({mustPlay: 2})} />
</IconButton>
{pauseOrPlay}
</div>
<RaisedButton label="Clear" secondary={true} onClick={() => {this.setState({mustPlay: 3})}}/>
</div>
</MuiThemeProvider>
);
}
}
export default App;
|
src/common/PLOverlayLoader.js | PowerlineApp/powerline-rn | /**
* @providesModule PLOverlayLoader
*/
import React, { Component } from 'react';
import {
Modal,
ActivityIndicator,
View,
Text,
StyleSheet
} from 'react-native';
import PLLoader from './PLLoader';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
// padding: 20,
backgroundColor: 'rgba(0, 0, 0, 0.5)'
},
innerContainer: {
// borderRadius: 10,
alignItems: 'center',
// padding: 20
},
indicator: {
marginBottom: 15
},
message: {
color: '#fff',
fontSize: 24,
fontWeight: '400'
}
});
const SIZES = ['small', 'normal', 'large'];
export default class PLOverlayLoader extends Component {
constructor(props) {
super(props);
}
static propTypes = {
visible: React.PropTypes.bool,
color: React.PropTypes.string,
logo: React.PropTypes.bool,
indicatorSize: React.PropTypes.oneOf(SIZES),
messageFontSize: React.PropTypes.number,
message: React.PropTypes.string
};
static defaultProps = {
visible: false,
color: 'white',
logo: false,
indicatorSize: 'large',
messageFontSize: 24,
message: '',
};
render() {
const messageStyle = {
color: this.props.color,
fontSize: this.props.messageFontSize
};
if (this.props.logo) {
return (
<Modal
animationType={'fade'}
transparent={true}
visible={this.props.visible}
supportedOrientations={['portrait', 'landscape']}
onOrientationChange={
evt => this.setState({ currentOrientation: evt.nativeEvent.orientation })
}
>
<View style={{
backgroundColor: 'rgba(0, 0, 0, 0.5)',
flex: 1,
}}>
<PLLoader position="center" />
</View>
</Modal>
);
} else {
return (
<Modal
onRequestClose={() => this.close()}
animationType={'fade'}
transparent={true}
visible={this.props.visible}
supportedOrientations={['portrait', 'landscape']}
onOrientationChange={
evt => this.setState({ currentOrientation: evt.nativeEvent.orientation })
}
>
<View style={[styles.container]}>
<View style={[styles.innerContainer]}>
<ActivityIndicator
style={[styles.indicator]}
size={this.props.indicatorSize}
color={this.props.color}
/>
<Text style={[styles.message, messageStyle]}>
{this.props.message}
</Text>
</View>
</View>
</Modal>
);
}
}
}
|
form/StringField.js | ExtPoint/yii2-frontend | import React from 'react';
import PropTypes from 'prop-types';
import {view} from 'components';
export default class StringField extends React.Component {
static propTypes = {
metaItem: PropTypes.object.isRequired,
input: PropTypes.shape({
name: PropTypes.string,
value: PropTypes.any,
onChange: PropTypes.func,
}),
readOnly: PropTypes.bool,
securityLevel: PropTypes.bool,
onChange: PropTypes.func,
};
constructor() {
super(...arguments);
this._onChange = this._onChange.bind(this);
this.state = {
level: '',
error: '',
readOnly: this.props.readOnly,
};
}
render() {
const {input, disabled, placeholder, ...props} = this.props;
const StringFieldView = this.props.view || view.getFormView('StringFieldView');
return (
<StringFieldView
{...props}
inputProps={{
name: input.name,
type: 'text',
disabled,
readOnly: this.state.readOnly,
placeholder,
onChange: this._onChange,
value: input.value,
...this.props.inputProps,
}}
onEdit={() => this.setState({readOnly: false})}
/>
);
}
_onChange(e) {
const value = e.target.value;
this.props.input.onChange(value);
if (this.props.onChange) {
this.props.onChange(value);
}
}
}
|
src/components/DeveloperMenu.js | yogakurniawan/phoney-mobile | import React from 'react';
import {View} from 'react-native';
// For tests
const DeveloperMenu = () => <View/>;
export default DeveloperMenu;
|
pages/api/step-label.js | cherniavskii/material-ui | import React from 'react';
import withRoot from 'docs/src/modules/components/withRoot';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import markdown from './step-label.md';
function Page() {
return <MarkdownDocs markdown={markdown} />;
}
export default withRoot(Page);
|
app/containers/ListProducts.js | ikhsanalatsary/react-mini-shop | import React from 'react';
import Loading from 'react-loading-animation';
import { find } from 'lodash/collection';
import { getProducts, getCart, setProducts, setCart } from '../api/localstorage.js';
import { normalString } from '../helpers/slug.js';
import Products from '../components/Products.js';
import ProductDetail from '../components/ProductDetail.js';
class ListProducts extends React.Component {
constructor(props) {
super(props);
this.state = {
products: [],
isLoading: true
};
this.onLikeClick = this.onLikeClick.bind(this);
this.deleteComment = this.deleteComment.bind(this);
this.postComment = this.postComment.bind(this);
this.addtoCart = this.addtoCart.bind(this);
}
componentDidMount() {
setTimeout(() => {
this.setState({
products: getProducts(),
isLoading: false,
});
}, 1000);
}
onLikeClick(val) {
var products = this.state.products
return products
.filter(prod => prod.id === val)
.map(prod => {
prod.liked ? prod.liked = false : prod.liked = true;
this.updateProduct(products);
});
}
deleteComment(val, id) {
var products = this.state.products
return products
.filter(prod => prod.id === id)
.map(prod => {
prod.comments = prod.comments.filter(comment => comment.content != val);
this.updateProduct(products);
});
}
postComment(val, id) {
var products = this.state.products
return products
.filter(prod => prod.id === id)
.map(prod => {
prod.comments = [...prod.comments, {content: val}];
this.updateProduct(products);
});
}
addtoCart(stock, prod) {
var cart = getCart();
let product = {
name: prod.name,
color: stock.color,
price: prod.price,
amount: 1
};
let allCart = cart.all;
let duplicate = find(allCart, (item) => item.name === product.name && item.color === product.color);
if (typeof duplicate !== 'undefined') {
let indexOfDuplicateProduct = allCart.indexOf(duplicate);
allCart[indexOfDuplicateProduct].amount += 1;
} else {
cart.all.push(product);
}
cart.totalItem += product.amount;
this.updateCart(cart);
this.decreaseStock({ id: prod.id, color: stock.color});
}
updateCart(cart) {
setCart(cart)
}
updateProduct(products) {
setProducts(products);
this.setState({ products });
}
decreaseStock(val) {
var products = this.state.products
let theProduct = find(products, (prod) => prod.id === val.id);
let allStock = theProduct.stocks;
let findColor = find(allStock, (stock) => stock.color === val.color);
let indexOfColor = allStock.indexOf(findColor);
allStock[indexOfColor].stock = findColor.stock - 1;
this.updateProduct(products);
}
render() {
var { products, isLoading} = this.state;
var query = this.props.location.query.q;
if (isLoading) return <div className='loading'><Loading /></div>;
if (query && query.length > 0) {
let decodeUri = decodeURIComponent(query);
let q = decodeUri.trim().toLowerCase();
products = products.filter(
prod => prod.name.toLowerCase().match(q)
);
}
if (this.props.params && this.props.params.name) {
let productName = normalString(this.props.params.name);
return (
<div className="container-mini">
{products.filter(prod => prod.name.match(new RegExp('('+productName+')','ig')))
.map(product => (
<ProductDetail key={product.id} product={product}
onLike={this.onLikeClick} deleteComment={this.deleteComment}
postComment={this.postComment} addtoCart={this.addtoCart} />
))}
</div>
);
} else if (this.props.params && this.props.params.categoryname) {
let categoryName = this.props.params.categoryname;
return (
<div className="container-mini">
<p className='result'>{`The Result of Category "${categoryName}"`}</p>
{products.filter(prod => prod.categories[prod.categories.length - 1] === categoryName)
.map(product => (
<Products key={product.id} product={product}
onLike={this.onLikeClick} addtoCart={this.addtoCart} />
))}
</div>
);
} else {
return (
<div className='container-mini'>
{query && <p className='result'>{`The Result of Searching Query "${query}"`}</p>}
{products.length > 0 ? products.map(product => (
<Products key={product.id} product={product}
onLike={this.onLikeClick} addtoCart={this.addtoCart} />)) :
<h3 className='not-found text-center'>Sorry... We can not found them :(</h3>}
</div>
);
}
}
}
export default ListProducts;
|
client/src/index.js | bmtwebdevs/sodalicious | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import '../semantic/dist/semantic.min.css';
import './components/drink/style.css';
import Admin from './components/admin';
import DrinksAdmin from './components/admin/drinksAdmin';
import PumpsAdmin from './components/admin/pumpsAdmin';
import Home from './components/home';
import NotFound from './NotFound'
import { BrowserRouter, Route, Switch } from 'react-router-dom'
ReactDOM.render((
<BrowserRouter>
<App>
<Switch>
<Route exact={true} path="/" component={Home}/>
<Route exact path="/admin" component={Admin}/>
<Route path="/admin/drinks" component={DrinksAdmin}/>
<Route path="/admin/pumps" component={PumpsAdmin}/>
<Route path="*" component={NotFound}/>
</Switch>
</App>
</BrowserRouter>),
document.getElementById('root'), // eslint-disable-line no-undef
); |
src/ButtonToolbar.js | tannewt/react-bootstrap | import React from 'react';
import classNames from 'classnames';
import BootstrapMixin from './BootstrapMixin';
const ButtonToolbar = React.createClass({
mixins: [BootstrapMixin],
getDefaultProps() {
return {
bsClass: 'button-toolbar'
};
},
render() {
let classes = this.getBsClassSet();
return (
<div
{...this.props}
role="toolbar"
className={classNames(this.props.className, classes)}>
{this.props.children}
</div>
);
}
});
export default ButtonToolbar;
|
developers.diem.com/src/theme/DocItem/index.js | libra/libra | import React from 'react';
import Head from '@docusaurus/Head';
import isInternalUrl from '@docusaurus/isInternalUrl';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import useTOCHighlight from '@theme/hooks/useTOCHighlight';
import { OVERFLOW_CONTAINER_CLASS } from '@theme/Layout';
import Feedback from 'components/docs/Feedback';
import Pagination from './Pagination';
import { RightSidebar } from 'diem-docusaurus-components';
import classnames from 'classnames';
import styles from './styles.module.css';
function DocItem(props) {
const {
siteConfig: { url: siteUrl, title: siteTitle },
} = useDocusaurusContext();
const { content: DocContent } = props;
const {
frontMatter: {
disable_pagination: disablePagination,
hide_right_sidebar: hideRightSidebar,
image: metaImage,
keywords,
hide_title: hideTitle,
hide_table_of_contents: hideTableOfContents,
wider_content: widerContent,
thinner_content: thinnerContent,
no_pad_top: noPadTop,
},
metadata,
toc,
} = DocContent;
const { description, title, permalink, editUrl } = metadata;
const metaTitle = title ? `${title} | ${siteTitle}` : siteTitle;
let metaImageUrl = siteUrl + useBaseUrl(metaImage);
if (!isInternalUrl(metaImage)) {
metaImageUrl = metaImage;
}
return (
<>
<Head>
<title>{metaTitle}</title>
<meta property="og:title" content={metaTitle} />
{description && <meta name="description" content={description} />}
{description && (
<meta property="og:description" content={description} />
)}
{keywords && keywords.length && (
<meta name="keywords" content={keywords.join(',')} />
)}
{metaImage && <meta property="og:image" content={metaImageUrl} />}
{metaImage && <meta property="twitter:image" content={metaImageUrl} />}
{metaImage && (
<meta name="twitter:image:alt" content={`Image for ${title}`} />
)}
{permalink && <meta property="og:url" content={siteUrl + permalink} />}
</Head>
<div className={classnames('container', styles.docItemWrapper)}>
<div
className={classnames('main-content', {
[styles.fullWidthContent]: hideRightSidebar,
})}
>
<div
className={classnames(
styles.docItemContainer,
classnames({
[styles.wider]: widerContent,
[styles.thinner]: thinnerContent,
[styles.noPadTop]: noPadTop,
})
)}
>
<article>
{!hideTitle && (
<header>
<h1 className={styles.docTitle}>{title}</h1>
</header>
)}
<div className="markdown">
<DocContent />
</div>
</article>
<Feedback />
<span className={styles.community}>
<a href="https://community.diem.com/">Ask the community</a> for
support
</span>
{!disablePagination && <Pagination metadata={metadata} />}
</div>
</div>
{!hideRightSidebar && <RightSidebar editUrl={editUrl} headings={toc} />}
</div>
</>
);
}
export default DocItem;
|
packages/material-ui-icons/src/Streetview.js | AndriusBil/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let Streetview = props =>
<SvgIcon {...props}>
<path d="M12.56 14.33c-.34.27-.56.7-.56 1.17V21h7c1.1 0 2-.9 2-2v-5.98c-.94-.33-1.95-.52-3-.52-2.03 0-3.93.7-5.44 1.83z" /><circle cx="18" cy="6" r="5" /><path d="M11.5 6c0-1.08.27-2.1.74-3H5c-1.1 0-2 .9-2 2v14c0 .55.23 1.05.59 1.41l9.82-9.82C12.23 9.42 11.5 7.8 11.5 6z" />
</SvgIcon>;
Streetview = pure(Streetview);
Streetview.muiName = 'SvgIcon';
export default Streetview;
|
ui/components/Quote.js | nlhuykhang/apollo-react-quotes-client | import React from 'react';
import { Card, CardActions, CardHeader, CardText } from 'material-ui/Card';
import IconButton from 'material-ui/IconButton';
import ContentSave from 'material-ui/svg-icons/content/save';
import ActionDelete from 'material-ui/svg-icons/action/delete';
export default class Quote extends React.Component {
static propTypes = {
quote: React.PropTypes.object,
saveQuote: React.PropTypes.func,
deleteQuote: React.PropTypes.func,
isShowSaveButton: React.PropTypes.bool,
isShowDeleteButton: React.PropTypes.bool,
};
state = {};
onTouchSaveQuote = () => {
const {
quote,
saveQuote,
} = this.props;
const {
content,
author,
} = quote;
saveQuote({
content,
authorName: author.name,
});
}
onTouchDeleteQuote = () => {
const {
quote,
deleteQuote,
} = this.props;
deleteQuote(quote.id);
}
renderSaveButton() {
if (this.props.isShowSaveButton) {
return (
<IconButton
onTouchTap={this.onTouchSaveQuote}
tooltip="Save Quote"
style={{
padding: '0px',
}}
>
<ContentSave />
</IconButton>
);
}
return null;
}
renderDeleteButton() {
if (this.props.isShowDeleteButton) {
return (
<IconButton
onTouchTap={this.onTouchDeleteQuote}
tooltip="Delete Quote"
style={{
padding: '0px',
}}
>
<ActionDelete />
</IconButton>
);
}
return null;
}
render() {
const {
quote,
} = this.props;
const {
content,
author,
} = quote;
return (
<Card style={{ margin: '10px' }}>
<CardText style={{ fontStyle: 'italic' }}>
{content}
</CardText>
<CardHeader
subtitle={author.name}
style={{
textAlign: 'right',
paddingTop: '0px',
paddingBottom: '5px',
}}
textStyle={{
paddingRight: '0px',
}}
/>
<CardActions
style={{
padding: '0px',
}}
>
{this.renderSaveButton()}
{this.renderDeleteButton()}
</CardActions>
</Card>
);
}
}
|
app/main.js | neekey/demo-react-master-detail-view | import React from 'react';
import './index.scss';
export default function Main(props) {
return (<div>
<div className="content">
{props.children}
</div>
</div>);
}
Main.propTypes = {
children: React.PropTypes.any,
};
|
server/app.js | javion25/chiji | import Koa from 'koa';
// import koaBetterRouter from 'koa-better-router';
import React from 'react';
import {renderToString, renderToStaticMarkup} from 'react-dom/server';
// import Home from '../client/containers/Home/index'
const app = new Koa();
// const router = koaBetterRouter().loadMethods();
// function renderFullPage(html, initState){
// // const main = JSON.parse(fs.readFileSync(path.join(__dirname,'../webpack/webpack-assets.json'))).javascript.main;
// const index = '/dist/client/index.js'
// const vendor = '/dist/client/vendor.js'
// const manifest = '/dist/client/manifest.js'
// return `
// <!DOCTYPE html>
// <html lang="en">
// <head>
// <meta charset="UTF-8">
// <title></title>
// <link href="/dist/client/css/style.css" rel="stylesheet"></head>
// </head>
// <body>
// <div id="root"><div>${html}</div></div>
// <script>
// window.__INITIAL_STATE__ = ${JSON.stringify(initState)}
// </script>
// <script src=${manifest}></script>
// <script src=${vendor}></script>
// <script src=${index}></script>
// </body>
// </html>
// `
// }
// router.get('/', async(ctx, next) => {
// const html = renderToString(<Home />);
// return ctx.body = renderFullPage(html, '');
// });
// router.get('/aaa', async(ctx, next) => {
// return ctx.body = "asdasdasdas";
// })
// app.use(router.middleware());
// response
// app.use(ctx => {
// ctx.body = 'Hello Koa';
// });
// console.log(app)
export default app;
|
frontend/js/index.js | devilish1/nsa-contacts | import 'babel-polyfill'
import React from 'react'
import { render } from 'react-dom'
import Root from './root'
import config from './config'
window.config = config
render(<Root />, document.getElementById('root'))
|
packages/node_modules/@webex/react-component-join-call-button/src/index.js | ciscospark/react-ciscospark | import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Button from '@webex/react-component-button';
import Timer from '@webex/react-component-timer';
import styles from './styles.css';
function JoinCallButton({callStartTime, onJoinClick}) {
return (
<div className={classNames('webex-join-call', styles.join)}>
<Button
accessibilityLabel="Join Call"
buttonClassName={classNames('webex-join-call-button', styles.joinButton)}
label="Join"
onClick={onJoinClick}
/>
<div className={classNames('webex-join-call-duration', styles.duration)}>
<Timer startTime={callStartTime} />
</div>
</div>
);
}
JoinCallButton.propTypes = {
callStartTime: PropTypes.number.isRequired,
onJoinClick: PropTypes.func.isRequired
};
export default JoinCallButton;
|
src/components/Playback.js | pyreta/MIDInterceptor-Electron | import React from 'react';
class Playback extends React.Component {
shouldComponentUpdate() {
const notesToPlay = this.props.state.recordedEvents[`${this.props.state.breathcontrollercoarse}.${this.props.state.programchange}.${this.props.state.channelaftertouch}`];
(notesToPlay || []).forEach(e => this.props.state.outputDevice.playNote(e.note.number, 1, { velocity: 0.5}))
return true;
}
render() {
return <div>{`Recording: ${this.props.state.recording}`}</div>
}
}
export default Playback
|
screens/Settings.js | CyrusRoshan/TenOutOfTennis | import React from 'react';
import {
StyleSheet,
Text,
View,
Button,
Image,
Dimensions,
} from 'react-native';
import {
StackNavigator,
} from 'react-navigation';
class SettingsScreen extends React.Component {
static navigationOptions = {
title: 'Settings'
};
render() {
return (
<View style={{alignItems: 'center', justifyContent: 'center', flex: 1}}>
<Text onPress={this._handlePress}>Go Home</Text>
</View>
)
}
_handlePress = () => {
this.props.navigation.navigate('Home');
}
} |
pages/people/ccgalindog.js | pcm-ca/pcm-ca.github.io | import React from 'react'
import { Link } from 'react-router'
import Helmet from 'react-helmet'
import { config } from 'config'
import { prefixLink } from 'gatsby-helpers'
import bib from './bib'
import info from './info'
import PersonPage from '../../components/PersonPage'
export default class Index extends React.Component {
render() {
return (
<div>
<Helmet title={config.siteTitle + ' | people | ccgalindog'} />
<PersonPage
{...info.ccgalindog}
picture="../images/ccgalindog.jpg"
/>
</div>
)
}
}
|
js/index.js | HipsterBrown/resource-finder-firefox | import React from 'react';
import fetch from 'whatwg-fetch';
import FormClass from './form';
import ResultsListClass from './results-list';
let D = React.DOM;
let Form = React.createFactory(FormClass);
let ResultsList = React.createFactory(ResultsListClass);
let urls = {
npm: "http://npm-registry-cors-proxy.herokuapp.com/",
bower: "http://bower.herokuapp.com/packages/search/",
github: "http://github-raw-cors-proxy.herokuapp.com/"
};
let App = React.createClass({
displayName: "App",
getInitialState() {
return {
results: [],
error: false,
listTitle: "Most Recent Results: "
};
},
componentDidMount() {
let cache = this.fetchCache();
if( cache ) {
cache.forEach(this.parseBower);
}
},
parseBower(json) {
let self = this;
let name = json.name;
let url = json.url;
let author = url.split('/')[3];
let ghURL = `${urls.github}${author}/${name}/blob/master/bower.json`;
let links = [];
let result = {
name: name,
author: author,
url: url
};
window.fetch(ghURL).then(function(response){
return response.json();
}).then(function(json){
if( json === "Not Found" || !json.main ) {
return false;
} else if( Array.isArray(json.main) ) {
json.main.forEach(function(path){
links.push(`https://rawgit.com/${author}/${name}/master/${path}`);
});
} else {
links.push(`https://rawgit.com/${author}/${name}/master/${json.main}`);
}
result.links = links;
result.version = json.version || "N/A";
self.setState({
results: self.state.results.concat(result)
});
});
},
storeResults(data) {
let dataString = JSON.stringify(data);
window.localStorage.setItem('results', dataString);
},
fetchCache() {
let dataString = window.localStorage.getItem('results');
return dataString ? JSON.parse(dataString) : false;
},
saveQuery(string) {
let queries = window.localStorage.getItem('queries') || "[]";
let query = string.toLowerCase();
queries = JSON.parse(queries);
if(queries.indexOf(query) !== -1) {
return false;
}
queries.push(query);
queries = JSON.stringify(queries);
window.localStorage.setItem('queries', queries);
},
fetchQueries() {
let queries = window.localStorage.getItem('queries');
return queries ? JSON.parse(queries) : false;
},
handleSubmit(e) {
e.preventDefault();
let self = this;
let query = self.refs.searchForm.getDOMNode().elements['search-input'].value;
if(query) {
self.saveQuery(query);
} else {
self.setState({
error: D.h3({ className: "error-message" }, "I Think You Forgot Something...")
});
return false;
}
if (self.state.error) {
self.setState({ error: false });
}
//let npmFetch = window.fetch( urls.npm + query );
let bowerFetch = window.fetch( urls.bower + query );
Promise.all([bowerFetch]).then(function(results){
Promise.all(results.map(function(result){ return result.json(); }))
.then(function(json){
let finalArr = json[0];
if (!finalArr.length) {
self.setState({
error: D.h2({ className: "error-message" }, "No Results Found")
});
return false;
}
self.setState({
results: [],
listTitle: `Results for "${query}": `
});
finalArr.forEach(self.parseBower);
self.storeResults(finalArr);
});
});
},
render() {
let self = this;
return D.div({}, [
Form({
submitHandler: self.handleSubmit,
ref: "searchForm"
}),
self.state.error ? self.state.error : self.state.results.length ? ResultsList({
results: self.state.results,
title: self.state.listTitle
}) : void 0
]);
}
});
React.render(React.createElement(App), document.getElementById('app'));
|
example/basic-with-router/template.js | iansinnott/react-static-webpack-plugin | import React from 'react';
const Html = (props) => (
<html lang='en'>
<head>
<title>{props.title}</title>
</head>
<body>
<div id='root' dangerouslySetInnerHTML={{ __html: props.body }} />
<script src='/app.js' />
</body>
</html>
);
export default Html;
|
src/components/Landing/CurrencyPanel.js | franciskim722/crypy | import React, { Component } from 'react';
import PropTypes from 'prop-types';
export default class CurrencyPanel extends Component {
constructor(props, context) {
super(props, context);
this.state = {
};
}
render(){
console.log(this.props);
return (
<div>
Currency Panel
</div>
);
}
}
CurrencyPanel.propTypes ={
currency: PropTypes.object,
};
|
src/@ui/Onboarding/index.js | NewSpring/Apollos | import React from 'react';
import { StyleSheet } from 'react-native';
import PropTypes from 'prop-types';
import { compose, pure, setPropTypes } from 'recompose';
import AppIntroSlider from 'react-native-app-intro-slider';
import Chip from '@ui/Chip';
const enhance = compose(pure, setPropTypes({ closeModal: PropTypes.func }));
const styles = StyleSheet.create({
image: {
width: '100%',
height: '100%',
resizeMode: 'contain',
},
});
const slides = [
{
key: 'one',
image: require('../../assets/onboarding/1-Welcome.jpg'),
imageStyle: styles.image,
backgroundColor: '#6bac43',
},
{
key: 'two',
image: require('../../assets/onboarding/2-Stories.jpg'),
imageStyle: styles.image,
backgroundColor: '#6bac43',
},
{
key: 'three',
image: require('../../assets/onboarding/3-Sermons.jpg'),
imageStyle: styles.image,
backgroundColor: '#6bac43',
},
{
key: 'four',
image: require('../../assets/onboarding/4-Music.jpg'),
imageStyle: styles.image,
backgroundColor: '#6bac43',
},
{
key: 'five',
image: require('../../assets/onboarding/5-Scripture.jpg'),
imageStyle: styles.image,
backgroundColor: '#6bac43',
},
{
key: 'six',
image: require('../../assets/onboarding/6-Favorites.jpg'),
imageStyle: styles.image,
backgroundColor: '#6bac43',
},
{
key: 'seven',
image: require('../../assets/onboarding/7-Campus.jpg'),
imageStyle: styles.image,
backgroundColor: '#6bac43',
},
{
key: 'eight',
image: require('../../assets/onboarding/8-Get-Started.jpg'),
imageStyle: styles.image,
backgroundColor: '#6bac43',
},
];
const renderDoneButton = () => <Chip pill title="Go" type="secondary" />;
const Onboarding = enhance(({ closeModal }) => (
<AppIntroSlider
hideNextButton
onDone={closeModal}
renderDoneButton={renderDoneButton}
slides={slides}
/>
));
Onboarding.propTypes = {
closeModal: PropTypes.func,
};
export default Onboarding;
|
hub-ui/src/components/forms/FormInput.js | lchase/hub | import React from 'react';
export default class FormInput extends React.Component {
render() {
console.log("FormInput props: " + this.props);
var containerClassName = "form-group has-feedback";
if (this.props.meta.touched && this.props.meta.error) {
containerClassName += " has-error";
}
return (
<div className={containerClassName}>
<input {...this.props.input} placeholder={this.props.placeholder} className={this.props.className} type={this.props.type} />
{this.props.inlineIco && <span className={"glyphicon " + this.props.inlineIco + " form-control-feedback"}></span>}
{this.props.meta.touched && this.props.meta.error && <span className="help-block">{this.props.meta.error}</span>}
</div>
)
}
} |
client/src/index.js | vygandas/react-redux-nodejs-mongodb-auth-skeleton | import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import reduxThunk from 'redux-thunk';
import { AUTH_USER } from './actions/types';
import App from './components/app';
import reducers from './reducers';
const createStoreWithMiddleware = applyMiddleware(reduxThunk)(createStore);
const store = createStoreWithMiddleware(reducers);
const token = localStorage.getItem('token');
// If we have a token - consider the user to be signed in
if (token) {
store.dispatch({ type: AUTH_USER });
}
ReactDOM.render(
<Provider store={store}>
<BrowserRouter>
<div>
<Switch>
<Route path="/" component={App}/>
</Switch>
</div>
</BrowserRouter>
</Provider>
, document.querySelector('.container'));
|
src/applications/disability-benefits/all-claims/pages/secondaryIncidentDescription.js | department-of-veterans-affairs/vets-website | import React from 'react';
import fullSchema from 'vets-json-schema/dist/21-526EZ-ALLCLAIMS-schema.json';
import { ptsd781aNameTitle } from '../content/ptsdClassification';
const incidentDescriptionInstructions = (
<h3 className="vads-u-font-size--h5">Event description</h3>
);
const { description } = fullSchema.definitions.secondaryPtsdIncident.properties;
export const uiSchema = index => ({
'ui:title': ptsd781aNameTitle,
'ui:description': incidentDescriptionInstructions,
[`secondaryIncident${index}`]: {
incidentDescription: {
'ui:title':
'Please tell us what happened during the event. You don’t have to repeat any information that you’ve already shared in this form. You only need to provide the level of detail that you’re comfortable sharing.',
'ui:widget': 'textarea',
'ui:options': {
rows: 5,
maxLength: 32000,
},
},
},
});
export const schema = index => ({
type: 'object',
properties: {
[`secondaryIncident${index}`]: {
type: 'object',
properties: {
incidentDescription: description,
},
},
},
});
|
src/index.js | michaelfriedman/capstone-g40 | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('root'),
);
|
src/components/ShopHeader.js | qandobooking/booking-frontend | import React, { Component } from 'react';
import classNames from 'classnames';
class ShopHeader extends Component {
render() {
const { title, caption, full, imageUrl } = this.props;
const headerClass = classNames('shop-header', { 'shop-header-full': full });
return (
<div className={headerClass} style={{ backgroundImage: `url(${imageUrl})` }}>
<div className="text-center shop-header-background">
<h1>{title}</h1>
<div>{caption}</div>
</div>
</div>
);
}
}
ShopHeader.defaultProps = { full: true };
export default ShopHeader;
|
packages/wix-style-react/src/MessageBox/docs/DestructiveAlertExamples/Secondary.js | wix/wix-style-react | /* eslint-disable react/prop-types */
import React from 'react';
import { MessageBoxFunctionalLayout } from 'wix-style-react';
export default () => (
<MessageBoxFunctionalLayout
title="Delete Files?"
confirmText="Main"
cancelText="Secondary"
theme="red"
dataHook="destructive-alert-secondary"
>
Do you really want to delete selected files? Once removed, cannot be undone.
</MessageBoxFunctionalLayout>
);
|
whatIsAround/src/index.js | liang121/what-s-around | import React, { Component } from 'react';
import { Tabs, Root } from './config/router';
import {
StyleSheet,
View
} from 'react-native'
export default class App extends Component {
render() {
return <Root />
}
}
|
examples/simple/client.js | fattenap/react-async | import Promise from 'bluebird';
import React from 'react';
import axios from 'axios';
import ReactMount from 'react/lib/ReactMount';
import {Async} from '../../src';
import Rx from 'rx';
ReactMount.allowFullPageRender = true;
function get(url) {
return {
id: url,
keepData: true,
start() {
return Rx.Observable.fromPromise(axios.get(url).then(response => response.data));
}
};
}
function AppObservables({name}) {
return {
message: get(`http://localhost:3000/api/message?name=${name}`)
};
}
@Async(AppObservables)
class App extends React.Component {
constructor(props) {
super(props);
this.state = {name: 'Andrey'};
}
componentDidMount() {
Rx.Observable.interval(1000).forEach(() => {
this.setState({name: this.state.name + 1});
});
}
render() {
let {message} = this.props;
let {name} = this.state;
return (
<html>
<head>
</head>
<body>
<div>{message ? message.message : 'Loading...'}</div>
<Nested name={this.state.name} />
<Timer />
</body>
</html>
);
}
}
@Async
class Nested extends React.Component {
static observe({name}) {
return {
message: get(`http://localhost:3000/api/message?name=${name}`)
};
}
render() {
let {message} = this.props;
return <div>{message ? message.message : 'Loading...'}</div>
}
}
@Async
class Timer extends React.Component {
static observe() {
return {
count: {
id: null,
start(count) {
// produce a new value each second
let observable = Rx.Observable.interval(1000);
// if we are resuming counting then shift by a previously computed
// value on server
if (count !== undefined) {
return observable.map(x => x + count).startWith(count);
} else {
return observable;
}
}
}
};
}
render() {
return <div>Count: {this.props.count}</div>;
}
}
if (typeof window !== 'undefined') {
React.render(<App />, document);
}
export default App;
|
src/admin/client/modules/apps/serviceDetails/components/description.js | cezerin/cezerin | import React from 'react';
import { Link } from 'react-router-dom';
import messages from 'lib/text';
import style from './style.css';
import Paper from 'material-ui/Paper';
import RaisedButton from 'material-ui/RaisedButton';
import Divider from 'material-ui/Divider';
import FontIcon from 'material-ui/FontIcon';
const ServiceDescription = ({
service,
loadingEnableDisable,
enableService,
disableService
}) => {
if (service) {
return (
<div style={{ maxWidth: 720, width: '100%' }}>
<Paper className="paper-box" zDepth={1}>
<div className={style.innerBox}>
<div className="row">
<div className="col-xs-4">
<img
src={service.cover_url}
alt={service.name}
className={style.cover}
/>
</div>
<div className="col-xs-8">
<h1 className={style.title}>{service.name}</h1>
<div className={style.developer}>{service.developer.name}</div>
{!service.enabled && (
<RaisedButton
label={messages.enable}
primary={true}
disabled={loadingEnableDisable}
onClick={enableService}
/>
)}
{service.enabled && (
<RaisedButton
label={messages.disable}
disabled={loadingEnableDisable}
onClick={disableService}
/>
)}
</div>
</div>
<div
className={style.description}
dangerouslySetInnerHTML={{ __html: service.description }}
/>
</div>
</Paper>
</div>
);
} else {
return null;
}
};
export default ServiceDescription;
|
client/components/Carousel/Slides.js | Art404/platform404 | /*eslint-disable*/
import React from 'react';
export default React.createClass({
displayName: 'Slides',
propTypes: {
onMouseDown: React.PropTypes.func,
slides: React.PropTypes.any,
style: React.PropTypes.object
},
render() {
const {style, slides, onMouseDown} = this.props
return (
<div
className="Carousel-slides"
style={style}
onMouseDown={onMouseDown}>
{slides}
</div>
);
}
});
|
src/parser/warrior/arms/modules/talents/ImpendingVictory.js | FaideWW/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import { formatThousands } from 'common/format';
import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
import AbilityTracker from 'parser/shared/modules/AbilityTracker';
import SpellLink from 'common/SpellLink';
import StatisticListBoxItem from 'interface/others/StatisticListBoxItem';
import Events from 'parser/core/Events';
/**
* Instantly attack the target, causing [ 39.31% of Attack Power ] damage
* and healing you for 20% of your maximum health.
*
* Killing an enemy that yields experience or honor resets the cooldown of Impending Victory.
*/
class ImpendingVictory extends Analyzer {
static dependencies = {
abilityTracker: AbilityTracker,
};
totalHeal = 0;
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTalent(SPELLS.IMPENDING_VICTORY_TALENT.id);
this.addEventListener(Events.heal.by(SELECTED_PLAYER).spell(SPELLS.IMPENDING_VICTORY_TALENT_HEAL), this._onImpendingVictoryHeal);
}
_onImpendingVictoryHeal(event) {
this.totalHeal += event.amount;
}
subStatistic() {
const impendingVictory = this.abilityTracker.getAbility(SPELLS.IMPENDING_VICTORY_TALENT.id);
const total = impendingVictory.damageEffective || 0;
const avg = this.totalHeal / (impendingVictory.casts || 1);
return (
<StatisticListBoxItem
title={<>Average <SpellLink id={SPELLS.IMPENDING_VICTORY_TALENT.id} /> heal</>}
value={formatThousands(avg)}
valueTooltip={`Total Impending Victory heal: ${formatThousands(this.totalHeal)} <br />Total Impending Victory damages: ${formatThousands(total)}`}
/>
);
}
}
export default ImpendingVictory;
|
app/components/global/AccountLink.js | soosgit/vessel | // @flow
import React, { Component } from 'react';
const { shell } = require('electron');
export default class AccountLink extends Component {
handleLink = () => {
const { name } = this.props;
shell.openExternal(`https://steemit.com/@${name}`);
}
render() {
const { name, content } = this.props;
return (
<a
onClick={this.handleLink}
>
{content}
</a>
);
}
}
|
src/components/IndexPage.js | pekkis/kino-kobros | import React from 'react';
import Header from './Header';
import Footer from './Footer';
class IndexPage extends React.Component {
constructor(props, context) {
super(props, context);
this.onSubmit = this.onSubmit.bind(this);
}
onSubmit(e) {
e.preventDefault();
const { push } = this.props;
const id = this.refs.id.value;
push(`/event/${id}`);
}
render() {
return (
<section>
<Header />
<p>
Kino Kobros on parempi ja massaostoystävällinen käyttöliittymä
Finnkinon e-lippuihin.
</p>
<p>
Finnkinon oston numeron löydät esimerkiksi varmistussähköpostin otsikosta.
</p>
<p>
<strong>OBS! </strong> Kaikkien ostosten tiedot vähintään käyvät
palvelimellani, ja niiden tietoja
potentiaalisesti säilötään jotta voin kehittää käyttöliittymää paremmaksi.
Nähdäkseni käytettyjen ostosten ja lippujen numeroilla ei ole varsinaista
arvoa, mutta parempi että joka tapauksessa tiedostat asian.
</p>
<p>
Jos haluat tarkkaan tietää, mitä koodi tekee, <a target="_blank" href="https://github.com/pekkis/kino-kobros">lue se läpi.</a>
{' '}Jos et usko että palvelimellani pyörivä koodi on sama, ota ihmeessä forkki ja hostaa oma versiosi!
</p>
<form onSubmit={this.onSubmit}>
<label>Oston numero</label>
<input ref="id" type="text" placeholder="Finnkinon oston numero" />
<button type="submit">Lähetä</button>
</form>
<Footer />
</section>
);
}
};
export default IndexPage;
|
SQL/client/src/components/dumb/List.js | thebillkidy/MERGE-Stack | import React from 'react';
import ListView from './ListView';
import GridView from './GridView';
export default class List extends React.Component {
render() {
if (this.props.type == 'grid') {
return (
<div className="gutter-free clearfix">
<GridView data={this.props.data} />
</div>
)
} else {
return (
<div className="gutter-free clearfix">
<ListView data={this.props.data} />
</div>
)
}
}
}
|
mlflow/server/js/src/experiment-tracking/components/modals/RestoreRunModal.js | mlflow/mlflow | import React, { Component } from 'react';
import { ConfirmModal } from './ConfirmModal';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { openErrorModal, restoreRunApi } from '../../actions';
import Utils from '../../../common/utils/Utils';
export class RestoreRunModalImpl extends Component {
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
}
static propTypes = {
isOpen: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
selectedRunIds: PropTypes.arrayOf(PropTypes.string).isRequired,
openErrorModal: PropTypes.func.isRequired,
restoreRunApi: PropTypes.func.isRequired,
};
handleSubmit() {
const restorePromises = [];
this.props.selectedRunIds.forEach((runId) => {
restorePromises.push(this.props.restoreRunApi(runId));
});
return Promise.all(restorePromises).catch(() => {
this.props.openErrorModal('While restoring an experiment run, an error occurred.');
});
}
render() {
const number = this.props.selectedRunIds.length;
return (
<ConfirmModal
isOpen={this.props.isOpen}
onClose={this.props.onClose}
handleSubmit={this.handleSubmit}
title={`Restore Experiment ${Utils.pluralize('Run', number)}`}
helpText={`${number} experiment ${Utils.pluralize('run', number)} will be restored.`}
confirmButtonText={'Restore'}
/>
);
}
}
const mapDispatchToProps = {
restoreRunApi,
openErrorModal,
};
export default connect(null, mapDispatchToProps)(RestoreRunModalImpl);
|
src/library/modal/index.js | zdizzle6717/react-flux-arc | 'use strict';
import React from 'react';
import classNames from 'classnames';
import Animation from 'react-addons-css-transition-group';
export default class Modal extends React.Component {
constructor(props, context) {
super(props, context);
}
render() {
let containerClasses = classNames({
'modal-container': true,
'show': this.props.modalIsOpen
})
let backdropClasses = classNames({
'modal-backdrop': true,
'show': this.props.modalIsOpen
})
return (
<div className={containerClasses} key={this.props.name}>
<Animation transitionName={this.props.transitionName} className="modal-animation-wrapper" transitionAppear={true} transitionAppearTimeout={250} transitionEnter={true} transitionEnterTimeout={250} transitionLeave={true} transitionLeaveTimeout={250}>
{
this.props.modalIsOpen &&
<div className="modal">
<div className="modal-content">
<div className="panel">
<div className="panel-title primary">
{this.props.title}
</div>
<div className="panel-content">
{this.props.children}
</div>
<div className="panel-footer text-right">
<button type="button collapse" className="button alert" onClick={this.props.handleClose}>Cancel</button>
<button type="button collapse" className="button success" onClick={this.props.handleSubmit}>Submit</button>
</div>
</div>
</div>
</div>
}
</Animation>
<div className={backdropClasses} onClick={this.props.handleClose}></div>
</div>
);
}
}
Modal.propTypes = {
'handleClose': React.PropTypes.func.isRequired,
'handleSubmit': React.PropTypes.func.isRequired,
'modalIsOpen': React.PropTypes.bool.isRequired,
'name': React.PropTypes.string.isRequired,
'title': React.PropTypes.string.isRequired,
'transitionName': React.PropTypes.string
}
Modal.defaultProps = {
'transitionName': 'fade'
}
|
seeds/node_modules/alt/test/alt-iso-test.js | Vincent-yz/react-creater | import React from 'react'
import Alt from '../'
import AltContainer from '../AltContainer'
import AltIso from '../utils/AltIso'
import { assert } from 'chai'
const alt = new Alt()
const UserActions = alt.generateActions('receivedUser', 'failed')
const UserSource = {
fetchUser() {
return {
remote(state, id, name) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve({ id, name }), 10)
})
},
success: UserActions.receivedUser,
error: UserActions.failed
}
}
}
class UserStore {
static displayName = 'UserStore'
constructor() {
this.user = null
this.exportAsync(UserSource)
this.bindActions(UserActions)
}
receivedUser(user) {
this.user = user
}
failed(e) {
console.error('Failure', e)
}
}
const userStore = alt.createStore(UserStore)
const NumberActions = alt.generateActions('receivedNumber', 'failed')
const NumberSource = {
fetchNumber() {
return {
remote(state, id) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(id), 5)
})
},
success: NumberActions.receivedNumber,
error: NumberActions.failed
}
}
}
class NumberStore {
static displayName = 'NumberStore'
constructor() {
this.n = []
this.exportAsync(NumberSource)
this.bindActions(NumberActions)
}
receivedNumber(n) {
this.n = n
}
failed(e) {
console.error(e)
}
}
const numberStore = alt.createStore(NumberStore)
@AltIso.define((props) => {
return Promise.all([
userStore.fetchUser(props.id, props.name),
numberStore.fetchNumber(props.id)
])
})
class User extends React.Component {
render() {
return (
<div>
<AltContainer
store={userStore}
render={(props) => {
return (
<div>
<h1>{props.user.name}</h1>
<span>{props.user.id}</span>
</div>
)
}}
/>
<AltContainer
store={numberStore}
render={(props) => {
return <span>{props.n}</span>
}}
/>
</div>
)
}
}
class App extends React.Component {
render() {
return <User id={this.props.id} name={this.props.name} />
}
}
export default {
'AltIso': {
'concurrent server requests are resolved properly'(done) {
const promises = []
function test(Component, props) {
promises.push(AltIso.render(alt, Component, props))
}
setTimeout(() => test(App, { id: 111111, name: 'AAAAAA' }), 10)
setTimeout(() => test(App, { id: 333333, name: 'CCCCCC' }), 20)
setTimeout(() => test(App, { id: 222222, name: 'BBBBBB' }), 10)
setTimeout(() => test(App, { id: 444444, name: 'DDDDDD' }), 20)
setTimeout(() => {
Promise.all(promises).then((values) => {
assert.match(values[0].html, /AAAAAA/)
assert.match(values[0].html, /111111/)
assert.notMatch(values[0].html, /BBBBBB/)
assert.notMatch(values[0].html, /222222/)
assert.notMatch(values[0].html, /CCCCCC/)
assert.notMatch(values[0].html, /333333/)
assert.notMatch(values[0].html, /DDDDDD/)
assert.notMatch(values[0].html, /444444/)
assert.match(values[1].html, /BBBBBB/)
assert.match(values[1].html, /222222/)
assert.notMatch(values[1].html, /AAAAAA/)
assert.notMatch(values[1].html, /111111/)
assert.notMatch(values[1].html, /CCCCCC/)
assert.notMatch(values[1].html, /333333/)
assert.notMatch(values[1].html, /DDDDDD/)
assert.notMatch(values[1].html, /444444/)
assert.match(values[2].html, /CCCCCC/)
assert.match(values[2].html, /333333/)
assert.notMatch(values[2].html, /AAAAAA/)
assert.notMatch(values[2].html, /111111/)
assert.notMatch(values[2].html, /BBBBBB/)
assert.notMatch(values[2].html, /222222/)
assert.notMatch(values[2].html, /DDDDDD/)
assert.notMatch(values[2].html, /444444/)
assert.match(values[3].html, /DDDDDD/)
assert.match(values[3].html, /444444/)
assert.notMatch(values[3].html, /AAAAAA/)
assert.notMatch(values[3].html, /111111/)
assert.notMatch(values[3].html, /BBBBBB/)
assert.notMatch(values[3].html, /222222/)
assert.notMatch(values[3].html, /CCCCCC/)
assert.notMatch(values[3].html, /333333/)
done()
}).catch(e => done(e))
}, 50)
},
'not as a decorator'() {
const User = AltIso.define(() => { }, class extends React.Component { })
assert.isFunction(User)
},
'single fetch call, single request'(done) {
const User = AltIso.define((props) => {
return userStore.fetchUser(props.id, props.name)
}, class extends React.Component {
render() {
return (
<AltContainer
store={userStore}
render={props => <span>{props.user.name}</span>}
/>
)
}
})
AltIso.render(alt, User, { id: 0, name: 'ZZZZZZ' }).then((obj) => {
assert.match(obj.html, /ZZZZZZ/)
done()
}).catch(e => done(e))
},
'errors still render the request'() {
const err = new Error('oops')
const User = AltIso.define((props) => {
return Promise.reject(err)
}, class extends React.Component {
render() {
return <span>JUST TESTING</span>
}
})
AltIso.render(alt, User, { id: 0, name: '√∆' }).catch((obj) => {
assert(obj.err === err)
assert.match(obj.html, /JUST TESTING/)
done()
})
},
}
}
|
examples/simple/components/App.js | joshblack/library-boilerplate | import React, { Component } from 'react';
import { add } from 'library-boilerplate';
export default class App extends Component {
render() {
return (
<p>
2 + 2 = {add(2, 2)}
</p>
);
}
}
|
component.js | Kevnz/cmd-line-tools | 'use strict';
require('babel/register');
let to = require('to-case');
let path = require('path');
let pluralize = require('pluralize');
let fs = require('fs');
let argv = require('minimist')(process.argv.slice(2));
let component = to.lower(argv.c);
let schemaFile = `${component}.json`;
let schemaPath = path.join('./models/schemas', schemaFile);
console.log(schemaPath);
let schemaExists = false;
try {
fs.statSync(schemaPath);
schemaExists = true;
} catch (err) {
console.log('There is no schema so creating with empty properties');
}
let schema = schemaExists ? require('../'+schemaPath) : { properties : {}};
let componentName = to.capital(component);
let appFolder = path.join('./app', 'components');
let propertyBagRead = [];
let propertyBagWrite = [];
console.log(schema.properties);
for (var prop in schema.properties) {
if (schema.properties.hasOwnProperty(prop)) {
switch (schema.properties[prop].type) {
case 'string':
propertyBagRead.push(`\t\t\t\t<div>{this.props.${prop}}</div>`);
propertyBagWrite.push(`<input type="text" value={this.props.${prop}} />`);
break;
case 'integer':
case 'number': // no break statement in 'case 0:' so this case will run as well
propertyBagRead.push(`\t\t\t\t<div>{this.props.${prop}}</div>`);
propertyBagWrite.push(`<input type="text" value={this.props.${prop}} />`);
break; // it encounters this break so will not continue into 'case 2:'
case 'boolean':
propertyBagRead.push(`\t\t\t\t<div>{this.props.${prop}}</div>`);
propertyBagWrite.push(`<input type="text" value={this.props.${prop}} />`);
break;
case 'objectId':
propertyBagRead.push(`\t\t\t\t<div><a href="#" onClick={this.onViewDetails}>View Details</a></div>`);
propertyBagWrite.push(`<input type="hidden" value={this.props.${prop}} />`);
break;
default:
console.log('default');
}
}
}
let props = propertyBagRead.join('\n').replace(/\t/gi, ' ');
let reactComponent = `import React from 'react';
export default class ${componentName} extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
${props}
</div>
);
}
}`;
let pluralComponent = pluralize(component);
let reactComponentList = `import React from 'react';
import ${componentName} from './${component}';
export default class ${componentName}List extends React.Component {
constructor(props) {
super(props);
}
render() {
let ${component}Nodes = this.state.settings.map((${component}) => {
return (<${componentName} ${component}={${component}} />);
});
return (
<div>
{${component}Nodes}
</div>
);
}
}`;
//reactComponent
fs.writeFileSync(path.join(appFolder, component + '.js'), reactComponent);
fs.writeFileSync(path.join(appFolder, component + '-list.js'), reactComponentList); |
src/main/resources/public/js/pages/app-install.js | ozwillo/ozwillo-portal | import React from 'react';
import Slider from 'react-slick';
import ModalImage from '../components/modal-image';
import {
buyApplication,
fetchAppDetails,
fetchAvailableOrganizations,
fetchRateApp,
unavailableOrganizationToInstallAnApp
} from '../util/store-service';
import RatingWrapper from '../components/rating';
import Select from 'react-select';
import PropTypes from 'prop-types';
import {Link} from 'react-router-dom';
import OrganizationService from '../util/organization-service';
import {i18n} from '../config/i18n-config';
import {t, Trans} from '@lingui/macro'
import UpdateTitle from '../components/update-title';
import Spinner from '../components/spinner';
import UserService from '../util/user-service';
const Showdown = require('showdown');
const converter = new Showdown.Converter({tables: true});
export default class AppInstall extends React.Component {
state = {
app: {},
appDetails: {
longdescription: '',
policy: '',
rateable: false,
rating: 0,
screenshots: [],
serviceUrl: null,
tos: ''
},
config: {},
organizationsAvailable: {organizations: [], loading: true},
user: {}
};
constructor(props) {
super(props);
this._organizationService = new OrganizationService();
this._userService = new UserService();
}
componentDidMount = async () => {
const {app, config} = this.props.location.state;
const user = await this._userService.fetchUserInfos();
this.setState({app: app, config: config, user: user}, async () => {
await this._loadAppDetails();
if(user) {
await this._loadOrgs();
}
});
};
_loadOrgs = async () => {
const {app} = this.state;
const data = await fetchAvailableOrganizations(app.type, app.id);
this.setState({organizationsAvailable: {organizations: data, loading: false}});
const newOrganizationsAvailable = await this._disableOrganizationWhereAppAlreadyInstalled(data);
this.setState({organizationsAvailable: {organizations: newOrganizationsAvailable, loading: false}});
};
_disableOrganizationWhereAppAlreadyInstalled = async (allOrganizations) => {
const {app} = this.state;
const organizationUnavailable = await unavailableOrganizationToInstallAnApp(app.id, app.type)
allOrganizations.forEach(org => {
organizationUnavailable.forEach(unAvailableOrg => {
if(org.id === unAvailableOrg.id){
org.disabled = true;
}
})
});
return allOrganizations;
};
_loadAppDetails = async () => {
const {app} = this.state;
const data = await fetchAppDetails(app.type, app.id);
this.setState({appDetails: data});
};
_rateApp = async (rate) => {
let {app, appDetails} = this.state;
await fetchRateApp(app.type, app.id, rate);
appDetails.rateable = false;
appDetails.rating = rate;
this.setState({appDetails});
};
_displayScreenShots = (arrayScreenshots) => {
if (arrayScreenshots) {
return arrayScreenshots.map((screenshot, index) => {
return (
<div key={index} onClick={() => this._openModal(screenshot)}>
<img className={'screenshot'} src={screenshot} alt={'screenshot' + index}/>
</div>
)
})
}
};
_openModal = (imageSrc) => {
this.refs.modalImage._openModal(imageSrc);
};
scrollToLongDescription = () => { // run this method to execute scrolling.
window.scrollTo({
top: this.longDescription.offsetTop,
behavior: 'smooth' // Optional, adds animation
})
};
render() {
const {app, appDetails, organizationsAvailable, config, user} = this.state;
const settings = {
dots: true,
speed: 500,
slidesToScroll: 1,
variableWidth: true,
accessibility: true,
};
return (
<div className={'app-install-wrapper'}>
<UpdateTitle title={app.name}/>
<div className={'flex-row header-app-install'}>
<div className={'information-app flex-row'}>
<img alt={'app icon'} src={app.icon}/>
<div className={'information-app-details'}>
<p><strong>{app.name}</strong></p>
<p>{app.provider}</p>
<p>{app.description}
{
appDetails.longdescription === app.description ?
null :
<i className="fas fa-external-link-alt go-to-long-description"
onClick={this.scrollToLongDescription}/>
}
</p>
<div className={'rate-content'}>
<RatingWrapper rating={appDetails.rating} rateable={appDetails.rateable}
rate={this._rateApp}/>
</div>
</div>
</div>
<div className={'install-app'}>
<div className={'dropdown'}>
<InstallForm user={user} app={app} organizationsAvailable={organizationsAvailable}
config={config}/>
</div>
</div>
</div>
{
appDetails.screenshots && appDetails.screenshots.length > 1 &&
<div className={'app-install-carousel'}>
<div className={'carousel-container'}>
<Slider {...settings}>
{this._displayScreenShots(appDetails.screenshots)}
</Slider>
</div>
</div>
}
{
appDetails.screenshots && appDetails.screenshots.length === 1 &&
<div className={'unique-screenshot'}>
<img src={appDetails.screenshots[0]}
onClick={() => this._openModal(appDetails.screenshots[0])}
alt={'screenshot ' + appDetails.screenshots[0]}/>
</div>
}
<div className={'flex-row app-install-description'} ref={(ref) => this.longDescription = ref}>
{
appDetails.longdescription === app.description ?
<div dangerouslySetInnerHTML={{__html: converter.makeHtml(app.description)}}/>
:
<div className={'long'}
dangerouslySetInnerHTML={{__html: converter.makeHtml(appDetails.longdescription)}}/>
}
</div>
< ModalImage
ref={'modalImage'}
/>
</div>
)
}
}
export class InstallForm extends React.Component {
state = {
installType: null,
error: {status: false, http_status: 200},
organizationSelected: null,
buying: false,
installed: false
};
_hasCitizens = () => {
return this.props.app.target_citizens;
};
_hasOrganizations = () => {
return (this.props.app.target_companies) || (this.props.app.target_publicbodies);
};
_createOptions = () => {
let options = [];
this._hasCitizens() ? options.push({
value: i18n._('install.org.type.PERSONAL'),
label: 'PERSONAL',
id: 1
}) : null;
this._hasOrganizations() ? options.push({
value: i18n._('install.org.type.ORG'),
label: 'ORG',
id: 2
}) : null;
return options;
};
_installButtonIsDisabled = () => {
const {app} = this.props;
const {installType, organizationSelected, buying} = this.state;
if (!installType || buying || (organizationSelected && organizationSelected.disabled)) {
return true;
} else if (installType && !(installType === 'PERSONAL') && !(app.type === 'service') && organizationSelected) {
return false;
} else if (installType && ((installType === 'PERSONAL') || (app.type === 'service'))) {
return false;
} else {
return true;
}
};
_doInstallApp = async () => {
const {app} = this.props;
const {organizationSelected} = this.state;
// set buying to true to display the spinner until any below ajax response is received.
this.setState({installed: false, buying: true, error: {status: false, http_status: 200}});
try {
await buyApplication(app.id, app.type, organizationSelected);
this.setState({buying: false, installed: true});
} catch (error) {
this.setState({buying: false, error: {status: true, http_status: error.status}})
}
};
render() {
const options = this._createOptions();
const {installType, organizationSelected, buying, installed, error} = this.state;
const {organizationsAvailable, app, user} = this.props;
let disabledOrganization = !installType;
if (!user) {
return (
<div className={'flex-row install-area redirect-to-connection'}>
<div className="install">
<button className="btn pull-right btn-install">{i18n._('store.install')}</button>
</div>
</div>
)
}
return (
<React.Fragment>
{!installed &&
<div className={'install-selector'}>
<label><Trans>For which usage</Trans></label>
<Select
className="select"
value={installType}
labelKey="value"
valueKey="id"
onChange={(value) => this.setState({installType: value})}
clearable={false}
options={options}/>
</div>
}
{!installed && !(installType === 'PERSONAL') && !(app.type === 'service') ?
<div className={'install-selector'}>
<label className={organizationsAvailable.loading ? 'label-spinner' : null}><Trans>For which organization</Trans></label>
<div className={'select-organization'}>
<Spinner display={organizationsAvailable.loading} className={'organization-spinner'}/>
<Select
disabled={disabledOrganization || organizationsAvailable.loading}
className={'select'}
value={organizationSelected}
labelKey="name"
valueKey="id"
onChange={(value) => this.setState({organizationSelected: value})}
clearable={false}
options={organizationsAvailable.organizations}
/>
</div>
</div>
: null
}
<div className={'flex-row install-area'}>
<Spinner display={buying}/>
{installed ?
<div className="install installed">
<Link className="btn btn-default-inverse pull-right btn-install"
to={`/${this.props.config.language}/store`}>
{i18n._('ui.appstore')}
</Link>
<Link className="btn btn-default-inverse pull-right btn-install dashboard"
to={'/my/dashboard'}>
{i18n._('my.dashboard')}
</Link>
</div>
:
<div className="install">
<button className="btn pull-right btn-install"
disabled={this._installButtonIsDisabled()}
onClick={this._doInstallApp}>{i18n._('store.install')}</button>
</div>
}
</div>
{error.http_status !== 200 &&
<div className={'alert alert-danger'}>
<p>{i18n._('could-not-install-app')}</p>
</div>
}
</React.Fragment>
)
}
}
InstallForm.propTypes = {
app: PropTypes.object.isRequired,
organizationsAvailable: PropTypes.object.isRequired,
user: PropTypes.object
};
|
plugins/Terminal/js/components/commandinput.js | NebulousLabs/New-Sia-UI | import React from 'react'
import { commandInputHelper } from '../utils/helpers.js'
export default class CommandInput extends React.Component {
componentDidUpdate () {
// Give DOM time to register the update.
if (!this.props.showWalletPrompt && !this.props.showSeedPrompt) {
this._input.focus()
}
}
render () {
const handleTextInput = e =>
this.props.actions.setCurrentCommand(e.target.value)
const handleKeyboardPress = e =>
commandInputHelper(
e,
this.props.actions,
this.props.currentCommand,
this.props.showCommandOverview,
this.props.commandHistory.size
)
return (
<input
id='command-input'
onChange={handleTextInput}
onKeyDown={handleKeyboardPress}
type='text'
value={this.props.currentCommand}
autoFocus
autoComplete
ref={c => (this._input = c)}
/>
)
}
}
|
src/components/NumberPlayersView.js | IShin00biI/Ktulu | import React from 'react'
import {
Text,
View
} from 'react-native'
import { NextFooter } from './Buttons'
export const NumberPlayersView = ({number, onSubmit}) => {
return (
<View>
<Text>Liczba graczy</Text>
<Text>
{number}
</Text>
<NextFooter title='Zatwierdź' onPress={onSubmit} />
</View>
)
}
export default NumberPlayersView
|
src/svg-icons/maps/local-hotel.js | igorbt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsLocalHotel = (props) => (
<SvgIcon {...props}>
<path d="M7 13c1.66 0 3-1.34 3-3S8.66 7 7 7s-3 1.34-3 3 1.34 3 3 3zm12-6h-8v7H3V5H1v15h2v-3h18v3h2v-9c0-2.21-1.79-4-4-4z"/>
</SvgIcon>
);
MapsLocalHotel = pure(MapsLocalHotel);
MapsLocalHotel.displayName = 'MapsLocalHotel';
MapsLocalHotel.muiName = 'SvgIcon';
export default MapsLocalHotel;
|
src/svg-icons/action/eject.js | matthewoates/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionEject = (props) => (
<SvgIcon {...props}>
<path d="M5 17h14v2H5zm7-12L5.33 15h13.34z"/>
</SvgIcon>
);
ActionEject = pure(ActionEject);
ActionEject.displayName = 'ActionEject';
ActionEject.muiName = 'SvgIcon';
export default ActionEject;
|
docs/client/components/pages/Video/gettingStarted.js | koaninc/draft-js-plugins | // It is important to import the Editor which accepts plugins.
import Editor from 'draft-js-plugins-editor'; // eslint-disable-line import/no-unresolved
import createVideoPlugin from 'draft-js-video-plugin'; // eslint-disable-line import/no-unresolved
import React from 'react';
// Creates an Instance. At this step, a configuration object can be passed in
// as an argument.
const videoPlugin = createVideoPlugin();
// The Editor accepts an array of plugins. In this case, only the linkifyPlugin
// is passed in, although it is possible to pass in multiple plugins.
const MyEditor = ({ editorState, onChange }) => (
<Editor
editorState={editorState}
onChange={onChange}
plugins={[videoPlugin]}
/>
);
export default MyEditor;
|
frontend/index.js | fdemian/Morpheus | import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import storeCreator from './store/configureStore';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import createBrowserHistory from 'history/createBrowserHistory'
import AdminRoute from './PrivateRoutes/AdminRoute';
// Route components.
import App from './App/App'; // Main application.
import Category from './Category/Container';
import Categories from './Categories/Container';
import Activation from './Activation/Container';
import User from './User/Container';
import Stories from './Stories/Container';
import Story from './Story/Container';
import StoryComposer from './StoryComposer/Container';
import Login from './Login/ConnectedLogin';
import Authentication from './Authentication/Container';
import Register from './Register/Container';
import Home from './App/Home'; // Home
import NotFound from './Errors/NotFound'; // 404
import loadConfig from './App/Actions';
import injectTapEventPlugin from 'react-tap-event-plugin';
// Required by material-ui.
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
const store = storeCreator();
const browserHistory = createBrowserHistory();
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
// Load configuration.
store.dispatch(loadConfig());
const Root = () => {
return (
<Provider store={store}>
<Router history={browserHistory} >
<MuiThemeProvider>
<div>
<Route path="/" component={App} />
<Route exact path="/" component={Home} />
<Route exact path="/login" component={Login} />
<Route exact path="/auth" component={Authentication} />
<Route exact path="/register" component={Register} />
<Route exact path="/users/:userId/:userName" component={User}/>
<Route exact path="/stories" component={Stories} />
<AdminRoute exact path="/stories/new" component={StoryComposer} store={store} />
<Route exact path="/stories/:storyId/:storyName" component={Story} />
<Route exact path="/categories" component={Categories} />
<Route exact path="/categories/:categoryId/:categoryName" component={Category} />
<Route exact path="/activation/:code" component={Activation} />
</div>
</MuiThemeProvider>
</Router>
</Provider>
);
}
//<Route exact path="*" component={NotFound} />
ReactDOM.render(<Root />, document.getElementById('root'));
|
src/svg-icons/editor/insert-emoticon.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorInsertEmoticon = (props) => (
<SvgIcon {...props}>
<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"/>
</SvgIcon>
);
EditorInsertEmoticon = pure(EditorInsertEmoticon);
EditorInsertEmoticon.displayName = 'EditorInsertEmoticon';
EditorInsertEmoticon.muiName = 'SvgIcon';
export default EditorInsertEmoticon;
|
src/components/NewPostLink.js | DimaRGB/twi-cool | import React from 'react'
import { Link } from 'react-router'
export default class NewPostLink extends React.Component {
render() {
return (
<Link to='/create' className='fixed bg-white top-0 right-0 pa4 ttu dim black no-underline'>
+ New Post
</Link>
)
}
}
|
src/svg-icons/action/play-for-work.js | ArcanisCz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionPlayForWork = (props) => (
<SvgIcon {...props}>
<path d="M11 5v5.59H7.5l4.5 4.5 4.5-4.5H13V5h-2zm-5 9c0 3.31 2.69 6 6 6s6-2.69 6-6h-2c0 2.21-1.79 4-4 4s-4-1.79-4-4H6z"/>
</SvgIcon>
);
ActionPlayForWork = pure(ActionPlayForWork);
ActionPlayForWork.displayName = 'ActionPlayForWork';
ActionPlayForWork.muiName = 'SvgIcon';
export default ActionPlayForWork;
|
src/parser/druid/feral/modules/features/checklist/Module.js | sMteX/WoWAnalyzer | import React from 'react';
import BaseChecklist from 'parser/shared/modules/features/Checklist/Module';
import CastEfficiency from 'parser/shared/modules/CastEfficiency';
import Combatants from 'parser/shared/modules/Combatants';
import PreparationRuleAnalyzer from 'parser/shared/modules/features/Checklist/PreparationRuleAnalyzer';
import Component from './Component';
import RakeUptime from '../../bleeds/RakeUptime';
import MoonfireUptime from '../../talents/MoonfireUptime';
import SwipeHitCount from '../../spells/SwipeHitCount';
import ComboPointDetails from '../../combopoints/ComboPointDetails';
import RipUptime from '../../bleeds/RipUptime';
import SavageRoarUptime from '../../talents/SavageRoarUptime';
import FerociousBiteEnergy from '../../spells/FerociousBiteEnergy';
import EnergyCapTracker from '../EnergyCapTracker';
import RipSnapshot from '../../bleeds/RipSnapshot';
import RakeSnapshot from '../../bleeds/RakeSnapshot';
import MoonfireSnapshot from '../../talents/MoonfireSnapshot';
import PredatorySwiftness from '../../spells/PredatorySwiftness';
import Bloodtalons from '../../talents/Bloodtalons';
import Predator from '../../talents/Predator';
import TigersFuryEnergy from '../../spells/TigersFuryEnergy';
import Shadowmeld from '../../racials/Shadowmeld';
import FinisherUse from '../../combopoints/FinisherUse';
class Checklist extends BaseChecklist {
static dependencies = {
combatants: Combatants,
castEfficiency: CastEfficiency,
preparationRuleAnalyzer: PreparationRuleAnalyzer,
rakeUptime: RakeUptime,
moonfireUptime: MoonfireUptime,
swipeHitCount: SwipeHitCount,
comboPointDetails: ComboPointDetails,
ripUptime: RipUptime,
savageRoarUptime: SavageRoarUptime,
ferociousBiteEnergy: FerociousBiteEnergy,
energyCapTracker: EnergyCapTracker,
ripSnapshot: RipSnapshot,
rakeSnapshot: RakeSnapshot,
moonfireSnapshot: MoonfireSnapshot,
predatorySwiftness: PredatorySwiftness,
bloodtalons: Bloodtalons,
predator: Predator,
tigersFuryEnergy: TigersFuryEnergy,
shadowmeld: Shadowmeld,
finisherUse: FinisherUse,
};
render() {
return (
<Component
combatant={this.combatants.selected}
castEfficiency={this.castEfficiency}
thresholds={{
// be prepared
...this.preparationRuleAnalyzer.thresholds,
// builders
rakeUptime: this.rakeUptime.suggestionThresholds,
moonfireUptime: this.moonfireUptime.suggestionThresholds,
swipeHitOne: this.swipeHitCount.hitJustOneThresholds,
comboPointsWaste: this.comboPointDetails.wastingSuggestionThresholds,
// finishers
ripUptime: this.ripUptime.suggestionThresholds,
savageRoarUptime: this.savageRoarUptime.suggestionThresholds,
ferociousBiteEnergy: this.ferociousBiteEnergy.suggestionThresholds,
ripShouldBeBite: this.ripSnapshot.shouldBeBiteSuggestionThresholds,
ripDurationReduction: this.ripSnapshot.durationReductionThresholds,
badLowComboFinishers: this.finisherUse.badFinishersThresholds,
// energy
energyCapped: this.energyCapTracker.suggestionThresholds,
tigersFuryIgnoreEnergy: this.tigersFuryEnergy.shouldIgnoreEnergyWaste,
tigersFuryEnergy: this.tigersFuryEnergy.suggestionThresholds,
// cooldowns
shadowmeld: this.shadowmeld.efficiencyThresholds,
// snapshot
rakeDowngrade: this.rakeSnapshot.downgradeSuggestionThresholds,
rakeProwlDowngrade: this.rakeSnapshot.prowlLostSuggestionThresholds,
ripDowngrade: this.ripSnapshot.downgradeSuggestionThresholds,
moonfireDowngrade: this.moonfireSnapshot.downgradeSuggestionThresholds,
// bloodtalons
predatorySwiftnessWasted: this.predatorySwiftness.suggestionThresholds,
bloodtalonsWasted: this.bloodtalons.suggestionThresholds,
// talent selection
predatorWrongTalent: this.predator.suggestionThresholds,
}}
/>
);
}
}
export default Checklist;
|
examples/cra-react15/src/stories/welcome.stories.js | kadirahq/react-storybook | import React from 'react';
import { storiesOf, setAddon } from '@storybook/react';
import { linkTo } from '@storybook/addon-links';
import { Welcome } from '@storybook/react/demo';
// Added deprecated setAddon tests
setAddon({
aa() {
console.log('aa');
},
});
setAddon({
bb() {
console.log('bb');
},
});
storiesOf('Welcome', module)
.addParameters({
component: Welcome,
})
.aa()
.bb()
.add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);
|
react/src/components/Loader.js | museumary/Museumary | /*
Loading gifs that display when the application is fetching data
Loading is the fancy image
LoadingText is the literal 'Loading' text
*/
import React from 'react';
import Loading from 'static/images/Loading-cropped.gif';
import LoadingText from 'static/images/LoadingText-cropped.gif';
const Loader = () => {
return (
<div className='container'>
<img src={LoadingText} alt='LoadingText' width='500'/><br/>
<img src={Loading} alt='Loading' />
</div>
);
}
export default Loader; |
web/static/js/graphql/app.js | yasuhiro-okada-aktsk/sample_phoenix_react | import 'babel/polyfill';
import FeedList from './components/FeedList.jsx';
import AppHomeRoute from './routes/AppHomeRoute';
import React from 'react';
import ReactDOM from 'react-dom';
import Relay from 'react-relay';
Relay.injectNetworkLayer(
new Relay.DefaultNetworkLayer('/api/v1/graphql')
);
ReactDOM.render(
<Relay.RootContainer
Component={FeedList}
route={new AppHomeRoute()}
/>,
document.getElementById('app')
);
|
src/svg-icons/content/remove.js | igorbt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ContentRemove = (props) => (
<SvgIcon {...props}>
<path d="M19 13H5v-2h14v2z"/>
</SvgIcon>
);
ContentRemove = pure(ContentRemove);
ContentRemove.displayName = 'ContentRemove';
ContentRemove.muiName = 'SvgIcon';
export default ContentRemove;
|
cerberus-dashboard/src/components/SDBDescriptionField/SDBDescriptionField.js | Nike-Inc/cerberus | /*
* Copyright (c) 2020 Nike, inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react'
import { Component } from 'react'
import PropTypes from 'prop-types'
import * as cms from '../../constants/cms'
/**
* Component for an Add Button (a button with a plus and a message)
*/
export default class SDBDescriptionField extends Component {
static propTypes = {
description: PropTypes.object.isRequired
}
render() {
const {description} = this.props
return (
<div id='description' className='ncss-form-group'>
<div className={((description.touched && description.error) ? 'ncss-textarea-container error' : 'ncss-textarea-container')}>
<label className='ncss-label'>Description</label>
<textarea className='ncss-textarea pt2-sm pr4-sm pb2-sm pl4-sm'
placeholder='Enter a description for your Bucket'
maxLength={`${cms.SDB_DESC_MAX_LENGTH}`}
{...description} />
{description.touched && description.error && <div className='ncss-error-msg'>{description.error}</div>}
</div>
</div>
)
}
}
|
packages/babel-plugin-transform-react-constant-elements/test/fixtures/constant-elements/compound-assignment/input.js | maurobringolf/babel | import React from 'react';
import Loader from 'loader';
const errorComesHere = () => <Loader className="full-height"/>,
thisWorksFine = () => <Loader className="p-y-5"/>;
|
views/Business/account/nwdRegister.js | leechuanjun/TLRNProjectTemplate |
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
ScrollView,
TouchableOpacity,
TextInput,
AlertIOS,
NavigatorIOS,
} from 'react-native';
import ToastIOS from 'react-native-sk-toast';
import NWDUtil from '../../Common/nwdUtil';
import NWDHttpClient from '../../Service/nwdHttpClient';
import NWDMacroDefine from '../../Common/nwdMacroDefine';
// import NWDTabBar from '../../App/nwdTabBar';
export default class NWDRegister extends Component{
constructor(props) {
super(props);
this.state = {
username: '',
telephone: '',
password: '',
};
}
render(){
return (
<ScrollView style={{paddingTop:80}}>
<View style={styles.row}>
<Text style={styles.label}>用户名</Text>
<TextInput style={styles.input} autoCorrect={false} autoCapitalize={'none'} autoFocus={true} onChangeText={this._setUserName.bind(this)}/>
</View>
<View style={styles.row}>
<Text style={styles.label}>密 码</Text>
<TextInput style={styles.input} autoCorrect={false} autoCapitalize={'none'} password={true} placeholder="初始密码" onChangeText={this._setPassword.bind(this)}/>
</View>
<View style={styles.row}>
<Text style={styles.label}>手机号码</Text>
<TextInput style={styles.input} autoCorrect={false} autoCapitalize={'none'} onChangeText={this._setTelephone.bind(this)}/>
</View>
<View style={{marginTop:30, alignItems:'center', justifyContent:'center'}}>
<TouchableOpacity onPress={() => this._register()}>
<View style={styles.btn}>
<Text>注册</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={this._cancle.bind(this)}>
<View style={[styles.btn,{marginTop:15}]}>
<Text>取消</Text>
</View>
</TouchableOpacity>
</View>
</ScrollView>
);
}
_setUserName(val){
this.setState({
username: val
});
}
_setPassword(val){
this.setState({
password: val
});
}
_setTelephone(val){
this.setState({
telephone: val
});
}
_register(){
var username = this.state.username;
var password = this.state.password;
var telephone = this.state.telephone;
if(!username || !password || !telephone){
return AlertIOS.alert('提示', '用户名、初始密码、手机号必填,请确认!');
}
var that = this;
NWDHttpClient.nwdRegister(username, telephone, password, function(result) {
if (result == NWDMacroDefine._MD_Result_Success) {
// AlertIOS.alert('成功','注册成功,请告知用户初始密码');
that.props.navigator.pop();
// that.props.navigator.resetTo({
// component: NWDTabBar,
// title: 'Home',
// });
}
else {
ToastIOS.bottom('注册失败!');
}
});
}
_cancle() {
this.props.navigator.pop();
}
}
var styles = StyleSheet.create({
row:{
flexDirection:'row',
alignItems:'center',
marginBottom:7,
},
label:{
width:70,
marginLeft:15,
},
input:{
borderWidth: NWDUtil.pixel,
height:35,
flex:1,
marginRight:20,
borderColor:'#ddd',
borderRadius: 4,
paddingLeft:5,
fontSize:14,
},
btn:{
borderColor:'#268DFF',
height:35,
width:200,
borderRadius:5,
borderWidth:NWDUtil.pixel,
alignItems:'center',
justifyContent:'center'
}
});
|
stories/DayPickerRangeController.js | airbnb/react-dates | import React from 'react';
import moment from 'moment';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withInfo } from '@storybook/addon-info';
import InfoPanelDecorator, { monospace } from './InfoPanelDecorator';
import isSameDay from '../src/utils/isSameDay';
import isInclusivelyAfterDay from '../src/utils/isInclusivelyAfterDay';
import CloseButton from '../src/components/CloseButton';
import KeyboardShortcutRow from '../src/components/KeyboardShortcutRow';
import { NAV_POSITION_BOTTOM, VERTICAL_ORIENTATION, VERTICAL_SCROLLABLE } from '../src/constants';
import DayPickerRangeControllerWrapper from '../examples/DayPickerRangeControllerWrapper';
const dayPickerRangeControllerInfo = `The ${monospace('DayPickerRangeController')} component is a
fully controlled version of the ${monospace('DayPicker')} that has built-in rules for selecting a
date range. Unlike the ${monospace('DayPicker')}, which requires the consumer to explicitly define
${monospace('onDayMouseEnter')}, ${monospace('onDayMouseLeave')}, and ${monospace('onDayClick')}
handlers, the consumer needs simply to maintain the ${monospace('focusedInput')},
${monospace('startDate')}, and ${monospace('endDate')} values in state and then pass these down as
props along with ${monospace('onFocusChange')} and ${monospace('onDatesChange')} callbacks that
update them appropriately. You can see an example of this implementation <a href=
"https://github.com/airbnb/react-dates/blob/master/examples/DayPickerRangeControllerWrapper.jsx">
here</a>. <br/><br/>
Note that the ${monospace('focusedInput')} prop may be ${monospace('null')}, but if this is the
case, dates are not selectable. As a result, in the example wrapper, we always force
${monospace('focusedInput')} to be truthy in the ${monospace('onFocusChange')} method. <br/><br/>
The ${monospace('DayPickerRangeController')} is particularly useful if you are interested in the
${monospace('DateRangePicker')} functionality and calendar presentation, but would like to
implement your own inputs.`;
const TestPrevIcon = () => (
<div
style={{
border: '1px solid #dce0e0',
backgroundColor: '#fff',
color: '#484848',
left: '22px',
padding: '3px',
position: 'absolute',
top: '20px',
}}
tabIndex="0"
>
Prev
</div>
);
const TestNextIcon = () => (
<div
style={{
border: '1px solid #dce0e0',
backgroundColor: '#fff',
color: '#484848',
padding: '3px',
position: 'absolute',
right: '22px',
top: '20px',
}}
tabIndex="0"
>
Next
</div>
);
const TestBottomPrevIcon = () => (
<div
style={{
border: '1px solid #dce0e0',
backgroundColor: '#fff',
color: '#484848',
padding: '3px',
margin: '-10px 22px 30px',
}}
tabIndex="0"
>
Prev
</div>
);
const TestBottomNextIcon = () => (
<div
style={{
border: '1px solid #dce0e0',
backgroundColor: '#fff',
color: '#484848',
padding: '3px',
margin: '-10px 22px 30px',
}}
tabIndex="0"
>
Next
</div>
);
const TestCustomInfoPanel = () => (
<div
style={{
padding: '10px 21px',
borderTop: '1px solid #dce0e0',
color: '#484848',
}}
>
❕ Some useful info here
</div>
);
function renderNavPrevButton(buttonProps) {
const {
ariaLabel,
disabled,
onClick,
onKeyUp,
onMouseUp,
} = buttonProps;
return (
<button
aria-label={ariaLabel}
disabled={disabled}
onClick={onClick}
onKeyUp={onKeyUp}
onMouseUp={onMouseUp}
style={{ position: 'absolute', top: 23, left: 22 }}
type="button"
>
‹ Prev
</button>
);
}
function renderNavNextButton(buttonProps) {
const {
ariaLabel,
disabled,
onClick,
onKeyUp,
onMouseUp,
} = buttonProps;
return (
<button
aria-label={ariaLabel}
disabled={disabled}
onClick={onClick}
onKeyUp={onKeyUp}
onMouseUp={onMouseUp}
style={{ position: 'absolute', top: 23, right: 22 }}
type="button"
>
Next
</button>
);
}
function renderNavPrevButtonForVerticalScrollable(buttonProps) {
const {
ariaLabel,
disabled,
onClick,
onKeyUp,
onMouseUp,
} = buttonProps;
return (
<button
aria-label={ariaLabel}
disabled={disabled}
onClick={onClick}
onKeyUp={onKeyUp}
onMouseUp={onMouseUp}
style={{ width: '100%', textAlign: 'center' }}
type="button"
>
Prev
</button>
);
}
function renderNavNextButtonForVerticalScrollable(buttonProps) {
const {
ariaLabel,
disabled,
onClick,
onKeyUp,
onMouseUp,
} = buttonProps;
return (
<button
aria-label={ariaLabel}
disabled={disabled}
onClick={onClick}
onKeyUp={onKeyUp}
onMouseUp={onMouseUp}
style={{ width: '100%', textAlign: 'center' }}
type="button"
>
Next ›
</button>
);
}
function renderKeyboardShortcutsButton(buttonProps) {
const { ref, onClick, ariaLabel } = buttonProps;
const buttonStyle = {
backgroundColor: '#914669',
border: 0,
borderRadius: 0,
color: 'inherit',
font: 'inherit',
lineHeight: 'normal',
overflow: 'visible',
padding: 0,
cursor: 'pointer',
width: 26,
height: 26,
position: 'absolute',
bottom: 0,
right: 0,
};
const spanStyle = {
color: 'white',
position: 'absolute',
bottom: 5,
right: 9,
};
return (
<button
ref={ref}
style={buttonStyle}
type="button"
aria-label={ariaLabel}
onClick={onClick}
onMouseUp={(e) => {
e.currentTarget.blur();
}}
>
<span style={spanStyle}>?</span>
</button>
);
}
function renderKeyboardShortcutsPanel(panelProps) {
const {
closeButtonAriaLabel,
keyboardShortcuts,
onCloseButtonClick,
onKeyDown,
title,
} = panelProps;
const PANEL_PADDING_PX = 50;
return (
<div style={{
position: 'fixed',
width: '100%',
height: '100%',
top: 0,
left: 0,
zIndex: 2,
}}
>
<div style={{
backgroundColor: '#000000',
opacity: 0.5,
width: '100%',
height: '100%',
}}
/>
<div style={{
backgroundColor: '#ffffff',
padding: PANEL_PADDING_PX,
width: '50%',
height: '50%',
position: 'absolute',
top: '25%',
left: '25%',
}}
>
<button
aria-label={closeButtonAriaLabel}
onClick={onCloseButtonClick}
onKeyDown={onKeyDown}
style={{
height: 25,
width: 25,
position: 'absolute',
top: PANEL_PADDING_PX,
right: PANEL_PADDING_PX,
}}
type="button"
>
<CloseButton />
</button>
<div style={{
fontSize: 16,
fontWeight: 'bold',
marginBottom: 16,
}}
>
{title}
</div>
{keyboardShortcuts.map(({ action: keyboardShortcutAction, label, unicode }) => (
<KeyboardShortcutRow
action={keyboardShortcutAction}
key={label}
label={label}
unicode={unicode}
/>
))}
</div>
</div>
);
}
const datesList = [
moment(),
moment().add(1, 'days'),
moment().add(3, 'days'),
moment().add(9, 'days'),
moment().add(10, 'days'),
moment().add(11, 'days'),
moment().add(12, 'days'),
moment().add(13, 'days'),
];
storiesOf('DayPickerRangeController', module)
.addDecorator(InfoPanelDecorator(dayPickerRangeControllerInfo))
.add('default', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
/>
)))
.add('with 7 days range selection', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
startDateOffset={(day) => day.subtract(3, 'days')}
endDateOffset={(day) => day.add(3, 'days')}
/>
)))
.add('with 45 days range selection', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
startDateOffset={(day) => day.subtract(22, 'days')}
endDateOffset={(day) => day.add(22, 'days')}
/>
)))
.add('with 4 days after today range selection', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
endDateOffset={(day) => day.add(4, 'days')}
/>
)))
.add('with current week range selection', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
startDateOffset={(day) => day.startOf('week')}
endDateOffset={(day) => day.endOf('week')}
/>
)))
.add('with custom inputs', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
showInputs
/>
)))
.add('non-english locale', withInfo()(() => {
moment.locale('zh-cn');
return (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
monthFormat="YYYY[年]MMMM"
/>
);
}))
.add('single month', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
numberOfMonths={1}
/>
)))
.add('single month, custom caption', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerSingleDateController::onOutsideClick')}
onPrevMonthClick={action('DayPickerSingleDateController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerSingleDateController::onNextMonthClick')}
numberOfMonths={1}
renderMonthElement={({ month, onMonthSelect, onYearSelect }) => (
<div style={{ display: 'flex', justifyContent: 'center' }}>
<div>
<select
value={month.month()}
onChange={(e) => { onMonthSelect(month, e.target.value); }}
>
{moment.months().map((label, value) => (
<option value={value}>{label}</option>
))}
</select>
</div>
<div>
<select
value={month.year()}
onChange={(e) => { onYearSelect(month, e.target.value); }}
>
<option value={moment().year() - 1}>Last year</option>
<option value={moment().year()}>{moment().year()}</option>
<option value={moment().year() + 1}>Next year</option>
</select>
</div>
</div>
)}
/>
)))
.add('3 months', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
numberOfMonths={3}
/>
)))
.add('vertical', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
orientation={VERTICAL_ORIENTATION}
/>
)))
.add('vertical scrollable', withInfo()(() => (
<div style={{ height: 500 }}>
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
orientation={VERTICAL_SCROLLABLE}
numberOfMonths={6}
verticalHeight={800}
/>
</div>
)))
.add('vertical scrollable with custom month nav', withInfo()(() => (
<div style={{ height: 500 }}>
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
orientation={VERTICAL_SCROLLABLE}
numberOfMonths={3}
verticalHeight={300}
navNext={(
<div style={{ position: 'relative' }}>
<span
style={{
position: 'absolute',
bottom: 20,
left: 50,
fontSize: 24,
border: '1px solid gray',
width: 200,
padding: 10,
}}
>
Show More Months
</span>
</div>
)}
navPrev={(
<div style={{ position: 'relative' }}>
<span
style={{
position: 'absolute',
top: 20,
left: 50,
fontSize: 24,
border: '1px solid gray',
width: 200,
padding: 10,
}}
>
Show More Months
</span>
</div>
)}
/>
</div>
)))
.add('vertical scrollable with custom rendered month navigation', withInfo()(() => (
<div style={{ height: 500 }}>
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
orientation={VERTICAL_SCROLLABLE}
numberOfMonths={3}
verticalHeight={300}
renderNavPrevButton={renderNavPrevButtonForVerticalScrollable}
renderNavNextButton={renderNavNextButtonForVerticalScrollable}
/>
</div>
)))
.add('with custom month navigation icons', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
navPrev={<TestPrevIcon />}
navNext={<TestNextIcon />}
/>
)))
.add('with custom month navigation buttons', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
renderNavPrevButton={renderNavPrevButton}
renderNavNextButton={renderNavNextButton}
/>
)))
.add('with custom month navigation and blocked navigation (minDate and maxDate)', withInfo()(() => (
<DayPickerRangeControllerWrapper
minDate={moment().subtract(2, 'months').startOf('month')}
maxDate={moment().add(2, 'months').endOf('month')}
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
navPrev={<TestPrevIcon />}
navNext={<TestNextIcon />}
/>
)))
.add('with month navigation positioned at the bottom', withInfo()(() => (
<DayPickerRangeControllerWrapper
navPosition={NAV_POSITION_BOTTOM}
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
/>
)))
.add('with custom month navigation positioned at the bottom', withInfo()(() => (
<DayPickerRangeControllerWrapper
navPosition={NAV_POSITION_BOTTOM}
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
navPrev={<TestBottomPrevIcon />}
navNext={<TestBottomNextIcon />}
dayPickerNavigationInlineStyles={{
display: 'flex',
justifyContent: 'space-between',
}}
/>
)))
.add('with outside days enabled', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
numberOfMonths={1}
enableOutsideDays
/>
)))
.add('with month specified on open', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
initialVisibleMonth={() => moment().add(10, 'months')}
/>
)))
.add('with minimum nights set', withInfo()(() => (
<DayPickerRangeControllerWrapper
minimumNights={3}
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
initialStartDate={moment().add(3, 'days')}
autoFocusEndDate
/>
)))
.add('allows single day range', withInfo()(() => (
<DayPickerRangeControllerWrapper
minimumNights={0}
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
initialStartDate={moment().add(3, 'days')}
autoFocusEndDate
/>
)))
.add('allows all days, including past days', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
isOutsideRange={() => false}
/>
)))
.add('allows next two weeks only', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
isOutsideRange={(day) => !isInclusivelyAfterDay(day, moment())
|| isInclusivelyAfterDay(day, moment().add(2, 'weeks'))}
/>
)))
.add('with some blocked dates', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
isDayBlocked={(day1) => datesList.some((day2) => isSameDay(day1, day2))}
/>
)))
.add('with some highlighted dates', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
isDayHighlighted={(day1) => datesList.some((day2) => isSameDay(day1, day2))}
/>
)))
.add('blocks fridays', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
isDayBlocked={(day) => moment.weekdays(day.weekday()) === 'Friday'}
/>
)))
.add('with navigation blocked (minDate and maxDate)', withInfo()(() => (
<DayPickerRangeControllerWrapper
minDate={moment().subtract(2, 'months').startOf('month')}
maxDate={moment().add(2, 'months').endOf('month')}
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
/>
)))
.add('with custom daily details', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
renderDayContents={(day) => day.format('ddd')}
/>
)))
.add('with info panel', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
renderCalendarInfo={() => (
<TestCustomInfoPanel />
)}
/>
)))
.add('with no animation', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
transitionDuration={0}
/>
)))
.add('with vertical spacing applied', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
verticalBorderSpacing={16}
/>
)))
.add('with custom horizontal month spacing applied', withInfo()(() => (
<div style={{ height: 500 }}>
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
orientation={VERTICAL_SCROLLABLE}
numberOfMonths={6}
verticalHeight={800}
horizontalMonthPadding={0}
/>
</div>
)))
.add('with no nav buttons', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
noNavButtons
/>
)))
.add('with no nav prev button', withInfo()(() => (
<div style={{ height: 500 }}>
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
orientation={VERTICAL_SCROLLABLE}
numberOfMonths={6}
verticalHeight={800}
noNavPrevButton
/>
</div>
)))
.add('with no nav next button', withInfo()(() => (
<div style={{ height: 500 }}>
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
orientation={VERTICAL_SCROLLABLE}
numberOfMonths={6}
verticalHeight={800}
noNavNextButton
/>
</div>
)))
.add('with minimum nights for the hovered date', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
getMinNightsForHoverDate={() => 2}
/>
)))
.add('with minimum nights for the hovered date and some blocked dates', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
getMinNightsForHoverDate={() => 2}
isDayBlocked={(day1) => datesList.some((day2) => isSameDay(day1, day2))}
/>
)))
.add('with custom keyboard shortcuts button', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
renderKeyboardShortcutsButton={renderKeyboardShortcutsButton}
/>
)))
.add('with custom keyboard shortcuts panel', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
renderKeyboardShortcutsPanel={renderKeyboardShortcutsPanel}
/>
)))
.add('with minimum nights set and daysViolatingMinNightsCanBeClicked set to true', withInfo()(() => (
<DayPickerRangeControllerWrapper
daysViolatingMinNightsCanBeClicked
minimumNights={3}
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
initialStartDate={moment().add(3, 'days')}
autoFocusEndDate
/>
)));
|
src/index.js | ramaya314/UndocuFunds | import React from 'react';
import ReactDOM from 'react-dom';
import App from './components';
import './css/index.css';
import './css/font-awesome.min.css';
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();
ReactDOM.render(
<App />,
document.getElementById('root')
);
|
app/static/src/diagnostic/TestTypeResultForm_modules/NewBushingTestForm.js | vsilent/Vision | import React from 'react';
import FormControl from 'react-bootstrap/lib/FormControl';
import FormGroup from 'react-bootstrap/lib/FormGroup';
import Button from 'react-bootstrap/lib/Button';
import ControlLabel from 'react-bootstrap/lib/ControlLabel';
import {findDOMNode} from 'react-dom';
import {hashHistory} from 'react-router';
import {Link} from 'react-router';
import HelpBlock from 'react-bootstrap/lib/HelpBlock';
import {NotificationContainer, NotificationManager} from 'react-notifications';
var TextField = React.createClass({
render: function () {
var label = (this.props.label != null) ? this.props.label : "";
var name = (this.props.name != null) ? this.props.name : "";
var value = (this.props.value != null) ? this.props.value : "";
var validationState = (this.props.errors[name]) ? 'error' : null;
var error = this.props.errors[name];
return (
<FormGroup validationState={validationState}>
<ControlLabel>{label}</ControlLabel>
<FormControl type="text"
placeholder={label}
name={name}
value={value}
data-type="float"
/>
<HelpBlock className="warning">{error}</HelpBlock>
<FormControl.Feedback />
</FormGroup>
);
}
});
var NewBushingTestForm = React.createClass({
getInitialState: function () {
return {
loading: false,
errors: {},
fields: [
'h1', 'h2', 'h3', 'hn', 'x1', 'x2', 'x3', 'xn', 't1', 't2', 't3', 'tn', 'q1', 'q2', 'q3', 'qn',
'h1c1', 'h2c1', 'h3c1', 'hnc1', 'h1c2', 'h2c2', 'h3c2', 'hnc2',
'x1c1', 'x1c1', 'x1c1', 'xnc1', 'x1c2', 'x2c2', 'x3c2', 'xnc2',
'q1c1', 'q2c1', 'q3c1', 'qnc1', 'q1c2', 'q2c2', 'q3c2', 'qnc2',
'test_kv_h1', 'test_kv_h2', 'test_kv_h3', 'test_kv_hn',
'test_kv_x1', 'test_kv_x2', 'test_kv_x3', 'test_kv_xn',
'test_kv_t1', 'test_kv_t2', 'test_kv_t3', 'test_kv_tn',
'test_kv_q1', 'test_kv_q2', 'test_kv_q3', 'test_kv_qn',
'test_pfc2_h1', 'test_pfc2_h2', 'test_pfc2_h3', 'test_pfc2_hn',
'test_pfc2_x1', 'test_pfc2_x2', 'test_pfc2_x3', 'test_pfc2_xn',
'test_pfc2_t1', 'test_pfc2_t2', 'test_pfc2_t3', 'test_pfc2_tn',
'test_pfc2_q1', 'test_pfc2_q2', 'test_pfc2_q3', 'test_pfc2_qn',
'facteur', 'facteur1', 'facteur2', 'facteur3',
'facteurn', 'facteur1', 'facteur2', 'facteur3',
'temperature', 'humidity'
]
}
},
_create: function () {
var fields = this.state.fields;
var data = {test_result_id: this.props.testResultId};
var url = '/api/v1.0/' + this.props.tableName + '/';
for (var i = 0; i < fields.length; i++) {
var key = fields[i];
data[key] = this.state[key];
}
if ('id' in this.state) {
url += this.state['id'];
delete data.id;
}
return $.authorizedAjax({
url: url,
type: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(data),
beforeSend: function () {
this.setState({loading: true});
}.bind(this)
})
},
_onSubmit: function (e) {
e.preventDefault();
// Do not propagate the submit event of the main form
e.stopPropagation();
if (!this._validate()){
NotificationManager.error('Please correct the errors');
e.stopPropagation();
return false;
}
var xhr = this._create();
xhr.done(this._onSuccess)
.fail(this._onError)
.always(this.hideLoading)
},
hideLoading: function () {
this.setState({loading: false});
},
_onSuccess: function (data) {
// this.setState(this.getInitialState());
NotificationManager.success('Test values have been saved successfully.');
if ($.isNumeric(data.result)) {
this.setState({id: data.result});
}
},
_onError: function (data) {
var message = "Failed to create";
var res = data.responseJSON;
if (res.message) {
message = data.responseJSON.message;
}
if (res.error) {
// We get list of errors
if (data.status >= 500) {
message = res.error.join(". ");
} else if (res.error instanceof Object){
// We get object of errors with field names as key
for (var field in res.error) {
var errorMessage = res.error[field];
if (Array.isArray(errorMessage)) {
errorMessage = errorMessage.join(". ");
}
res.error[field] = errorMessage;
}
this.setState({
errors: res.error
});
} else {
message = res.error;
}
}
NotificationManager.error(message);
},
componentDidMount: function () {
var source = '/api/v1.0/' + this.props.tableName + '/?test_result_id=' + this.props.testResultId;
this.serverRequest = $.authorizedGet(source, function (result) {
var res = (result['result']);
if (res.length > 0) {
var data = res[0];
var state = {data: data};
for (var k in data) {
if (data.hasOwnProperty(k)) {
state[k] = data[k];
}
}
this.setState(state);
}
}.bind(this), 'json');
},
_onChange: function (e) {
var state = {};
if (e.target.type == 'checkbox') {
state[e.target.name] = e.target.checked;
} else if (e.target.type == 'select-one') {
state[e.target.name] = e.target.value;
} else {
state[e.target.name] = e.target.value;
}
var errors = this._validateFieldType(e.target.value, e.target.getAttribute("data-type"));
state = this._updateFieldErrors(e.target.name, state, errors);
this.setState(state);
},
_validateFieldType: function (value, type){
var errors = {};
if (type != undefined && value){
var typePatterns = {
"int": /^(-|\+)?(0|[1-9]\d*)$/,
"float": /^(-|\+?)[0-9]+(\.)?[0-9]*$/
};
if (!typePatterns[type].test(value)){
errors = "Invalid " + type + " value";
}
}
return errors;
},
_updateFieldErrors: function (fieldName, state, errors){
// Clear existing errors related to the current field as it has been edited
state.errors = this.state.errors;
delete state.errors[fieldName];
// Update errors with new ones, if present
if (Object.keys(errors).length){
state.errors[fieldName] = errors
}
return state;
},
_validate: function () {
var response = true;
if (Object.keys(this.state.errors).length > 0){
response = false;
}
return response;
},
_formGroupClass: function (field) {
var className = "form-group ";
if (field) {
className += " has-error"
}
return className;
},
render: function () {
return (
<div className="form-container">
<form method="post" action="#" onSubmit={this._onSubmit} onChange={this._onChange}>
<h4>Parameters and conditions</h4>
<div className="row">
<div className="col-md-1">
<TextField label="H1" name="h1" value={this.state.h1} errors={this.state.errors}
data-type="float"/>
</div>
<div className="col-md-1">
<TextField label="H2" name="h2" value={this.state.h2} errors={this.state.errors}
data-type="float"/>
</div>
<div className="col-md-1">
<TextField label="H3" name="h3" value={this.state.h3} errors={this.state.errors}
data-type="float"/>
</div>
<div className="col-md-1">
<TextField label="Hn" name="hn" value={this.state.hn} errors={this.state.errors}
data-type="float"/>
</div>
<div className="col-md-1">
<TextField label="X1" name="x1" value={this.state.x1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="X2" name="x2" value={this.state.x2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="X3" name="x3" value={this.state.x3} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Xn" name="xn" value={this.state.xn} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T1" name="t1" value={this.state.t1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T2" name="t2" value={this.state.t2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T3" name="t3" value={this.state.t3} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Tn" name="tn" value={this.state.tn} errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-1">
<TextField label="H1C1" name="h1c1" value={this.state.h1c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="H2C1" name="h2c1" value={this.state.h2c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="H3C1" name="h3c1" value={this.state.h3c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="HnC1" name="hnc1" value={this.state.hnc1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="X1C1" name="x1c1" value={this.state.x1c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="X2C1" name="x2c1" value={this.state.x2c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="X3C1" name="x3c1" value={this.state.x3c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="XnC1" name="xnc1" value={this.state.xnc1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T1C1" name="t1c1" value={this.state.t1c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T2C1" name="t2c1" value={this.state.t2c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T3C1" name="t3c1" value={this.state.t3c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="TnC1" name="tnc1" value={this.state.tnc1} errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-1">
<TextField label="H1C2" name="h1c2" value={this.state.h1c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="H2C2" name="h2c2" value={this.state.h2c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="H3C2" name="h3c2" value={this.state.h3c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="HnC2" name="hnc2" value={this.state.hnc2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="X1C2" name="x1c2" value={this.state.x1c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="X2C2" name="x2c2" value={this.state.x2c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="X3C2" name="x3c2" value={this.state.x3c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="XnC2" name="xnc2" value={this.state.xnc2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T1C2" name="t1c2" value={this.state.t1c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T2C2" name="t2c2" value={this.state.t2c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="T3C2" name="t3c2" value={this.state.t3c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="TnC2" name="tnc2" value={this.state.tnc2} errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-1">
<TextField label="Q1" name="q1" value={this.state.q1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Q2" name="q2" value={this.state.q2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Q3" name="q3" value={this.state.q3} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Qn" name="qn" value={this.state.qn} errors={this.state.errors}/>
</div>
<div className="col-md-4">
<TextField label="Factor" name="facteur" value={this.state.facteur}
errors={this.state.errors}/>
</div>
<div className="col-md-4">
<TextField label="Factor 1" name="facteur1" value={this.state.facteur1}
errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-1">
<TextField label="Q1C1" name="q1c1" value={this.state.q1c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Q2C1" name="q2c1" value={this.state.q2c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Q3C1" name="q3c1" value={this.state.q3c1} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="QnC1" name="qnc1" value={this.state.qnc1} errors={this.state.errors}/>
</div>
<div className="col-md-4">
<TextField label="Factor 2" name="facteur2" value={this.state.facteur2}
errors={this.state.errors}/>
</div>
<div className="col-md-4">
<TextField label="Factor 3" name="facteur3" value={this.state.facteur3}
errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-1">
<TextField label="Q1C2" name="q1c2" value={this.state.q1c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Q2C2" name="q2c2" value={this.state.q2c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Q3C2" name="q3c2" value={this.state.q3c2} errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="QnC2" name="qnc2" value={this.state.qnc2} errors={this.state.errors}/>
</div>
<div className="col-md-4 ">
<TextField label="Temperature" name="temperature" value={this.state.temperature}
errors={this.state.errors}/>
</div>
<div className="col-md-4 ">
<TextField label="Humidity" name="humidity" value={this.state.humidity}
errors={this.state.errors}/>
</div>
</div>
<hr></hr>
<h4>Tests</h4>
<div className="row">
<div className="col-md-1">
<TextField label="kV H1" name="test_kv_h1" value={this.state.test_kv_h1}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV H2" name="test_kv_h2" value={this.state.test_kv_h2}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV H3" name="test_kv_h3" value={this.state.test_kv_h3}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV Hn" name="test_kv_hn" value={this.state.test_kv_hn}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV X1" name="test_kv_x1" value={this.state.test_kv_x1}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV X2" name="test_kv_x2" value={this.state.test_kv_x2}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV X3" name="test_kv_x3" value={this.state.test_kv_x3}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV Xn" name="test_kv_xn" value={this.state.test_kv_xn}
errors={this.state.errors}/>
</div>
<div className="col-md-4">
<TextField label="Factor n" name="facteurn" value={this.state.facteurn}
errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-1">
<TextField label="kV T1" name="test_kv_t1" value={this.state.test_kv_t1}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV T2" name="test_kv_t2" value={this.state.test_kv_t2}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV T3" name="test_kv_t3" value={this.state.test_kv_t3}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV Tn" name="test_kv_tn" value={this.state.test_kv_tn}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV Q1" name="test_kv_q1" value={this.state.test_kv_q1}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV Q2" name="test_kv_q2" value={this.state.test_kv_q2}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV Q3" name="test_kv_q3" value={this.state.test_kv_q3}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="kV Qn" name="test_kv_qn" value={this.state.test_kv_qn}
errors={this.state.errors}/>
</div>
<div className="col-md-4">
<TextField label="Factor n1" name="facteurn1" value={this.state.facteurn1}
errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-1">
<TextField label="Test PFC H1" name="test_pfc2_h1" value={this.state.test_pfc2_h1}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC H2" name="test_pfc2_h2" value={this.state.test_pfc2_h2}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC H3" name="test_pfc2_h3" value={this.state.test_pfc2_h3}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC Hn" name="test_pfc2_hn" value={this.state.test_pfc2_hn}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC X1" name="test_pfc2_x1" value={this.state.test_pfc2_x1}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC X2" name="test_pfc2_x2" value={this.state.test_pfc2_x2}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC X3" name="test_pfc2_x3" value={this.state.test_pfc2_x3}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC Xn" name="test_pfc2_xn" value={this.state.test_pfc2_xn}
errors={this.state.errors}/>
</div>
<div className="col-md-4">
<TextField label="Factor n2" name="facteurn2" value={this.state.facteurn2}
errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-1">
<TextField label="Test PFC T1" name="test_pfc2_t1" value={this.state.test_pfc2_t1}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC T2" name="test_pfc2_t2" value={this.state.test_pfc2_t2}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC T3" name="test_pfc2_t3" value={this.state.test_pfc2_t3}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC Tn" name="test_pfc2_tn" value={this.state.test_pfc2_tn}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC Q1" name="test_pfc2_q1" value={this.state.test_pfc2_q1}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC Q2" name="test_pfc2_q2" value={this.state.test_pfc2_q2}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC Q3" name="test_pfc2_q3" value={this.state.test_pfc2_q3}
errors={this.state.errors}/>
</div>
<div className="col-md-1">
<TextField label="Test PFC Qn" name="test_pfc2_qn" value={this.state.test_pfc2_qn}
errors={this.state.errors}/>
</div>
<div className="col-md-4">
<TextField label="Factor n3" name="facteurn3" value={this.state.facteurn3}
errors={this.state.errors}/>
</div>
</div>
<div className="row">
<div className="col-md-12 ">
<Button bsStyle="success"
className="pull-right"
type="submit">Save</Button>
<Button bsStyle="danger"
className="pull-right margin-right-xs"
onClick={this.props.handleClose}
>Cancel</Button>
</div>
</div>
</form>
</div>
);
}
});
export default NewBushingTestForm;
|
indico/modules/core/client/js/impersonation.js | indico/indico | // This file is part of Indico.
// Copyright (C) 2002 - 2022 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.
import impersonateURL from 'indico-url:auth.admin_impersonate';
import React from 'react';
import ReactDOM from 'react-dom';
import {LazyUserSearch} from 'indico/react/components/principals/Search';
import {Translate} from 'indico/react/i18n';
import {indicoAxios, handleAxiosError} from 'indico/utils/axios';
async function sendRequest(data) {
try {
await indicoAxios.post(impersonateURL(), data);
} catch (error) {
handleAxiosError(error);
return;
}
window.location.reload();
}
export function impersonateUser(id) {
sendRequest({user_id: id});
}
const searchTrigger = triggerProps => (
<a {...triggerProps}>
<Translate>Login as...</Translate>
</a>
);
document.addEventListener('DOMContentLoaded', () => {
const undoLoginAs = document.querySelectorAll('.undo-login-as');
const loginAs = document.querySelector('#login-as');
if (undoLoginAs.length) {
undoLoginAs.forEach(elem => {
elem.addEventListener('click', e => {
e.preventDefault();
sendRequest({undo: true});
});
});
}
if (loginAs) {
ReactDOM.render(
<LazyUserSearch
existing={[]}
onAddItems={e => impersonateUser(e.userId)}
triggerFactory={searchTrigger}
alwaysConfirm
single
/>,
document.getElementById('login-as')
);
}
});
|
src/docs/examples/TextInputBEM/ExampleOptional.js | patchygreen/ps-react-patchygreen | import React from 'react';
import TextInputBEM from "ps-react/TextInputBEM";
/** Optional TextBox */
export default class ExampleOptional extends React.Component {
render() {
return (
<TextInputBEM
htmlId='example-optional'
label='First Name'
name='firstname'
onChange={() => {}}
/>
)
}
} |
demo/js/readmeDemos.js | esseb/react-aria-menubutton | // Simple ES6 Example
import React from 'react';
import ariaMenuButton from '../../src/ariaMenuButton';
const menuItemWords = ['foo', 'bar', 'baz'];
class MyMenuButton extends React.Component {
componentWillMount() {
this.amb = ariaMenuButton({
onSelection: handleSelection,
});
}
render() {
const { Button, Menu, MenuItem } = this.amb;
const menuItems = menuItemWords.map((word, i) => {
return (
<li key={i}>
<MenuItem className='MyMenuButton-menuItem'>
{word}
</MenuItem>
</li>
);
});
return (
<div className='MyMenuButton'>
<Button className='MyMenuButton-button'>
click me
</Button>
<Menu className='MyMenuButton-menu'>
<ul>{menuItems}</ul>
</Menu>
</div>
);
}
}
// Complex ES5 Example
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
var people = [{
name: 'Charles Choo-Choo',
id: 1242,
}, {
name: 'Mina Meowmers',
id: 8372,
}, {
name: 'Susan Sailor',
id: 2435,
}];
var MyMenuButton2 = React.createClass({
componentWillMount: function() {
this.amb = ariaMenuButton({
onSelection: handleSelection,
});
},
render: function() {
var MyButton = this.amb.Button;
var MyMenu = this.amb.Menu;
var MyMenuItem = this.amb.MenuItem;
var peopleMenuItems = people.map(function(person, i) {
return (
<MyMenuItem
key={i}
tag='li'
value={person.id}
text={person.name}
className='PeopleMenu-person'
>
<div className='PeopleMenu-personPhoto'>
<img src={'/people/pictures/' + person.id + '.jpg'}/ >
</div>
<div className='PeopleMenu-personName'>
{person.name}
</div>
</MyMenuItem>
);
});
var peopleMenuInnards = function(menuState) {
var menu = (!menuState.isOpen) ? false : (
<div
className='PeopleMenu-menu'
key='menu'
>
{peopleMenuItems}
</div>
);
return (
<CSSTransitionGroup transitionName='people'>
{menu}
</CSSTransitionGroup>
);
};
return (
<div className='PeopleMenu'>
<MyButton className='PeopleMenu-trigger'>
<span className='PeopleMenu-triggerText'>
Select a person
</span>
<span className='PeopleMenu-triggerIcon' />
</MyButton>
<MyMenu>
{peopleMenuInnards}
</MyMenu>
</div>
);
},
});
// Getting it working
function handleSelection(value, event) {
console.log(value, event);
}
React.render(
<div>
<MyMenuButton />
<MyMenuButton2 />
</div>,
document.body
);
var style = document.createElement('style');
var css = (
`.PeopleMenu-menu {
transform: scale(1);
transition: transform 0.3s linear;
}
.PeopleMenu-menu.people-enter,
.PeopleMenu-menu.people-leave.people-leave-active {
transform: scale(0);
}
.PeopleMenu-menu.people-leave,
.PeopleMenu-menu.people-enter.people-enter-active {
transform: scale(1);
}
`);
style.appendChild(document.createTextNode(css));
document.head.appendChild(style);
|
src/components/Calendar/CalendarComponent.js | viktorfa/squeezed-days | import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import {Link, Element} from 'react-scroll';
import classes from './Calendar.css'
import YearButtons from "./YearButtons";
import SqueezeNumberButtons from "./SqueezeNumberButtons";
import ScrollStickyMenu from "./ScrollStickyMenu";
const Calendar = (props) => (
<div className={classes.calendar}>
<div>
<h3 style={{margin: '10px 0 0 0'}}>{`År ${props.year}`}</h3>
<h4 style={{margin: '0 0 10px 0'}}>Regner <strong>{props.squeezeNumber}</strong> dager mellom fri som
inneklemt</h4>
</div>
<ScrollStickyMenu>
<YearButtons
style={{margin: '2px'}}
switchYear={props.switchYear}
year={props.year}
/>
<SqueezeNumberButtons
style={{margin: '2px'}}
switchSqueezeNumber={props.switchSqueezeNumber}
currentSqueezeNumber={props.squeezeNumber}
/>
</ScrollStickyMenu>
<SqueezedDays calendar={props.calendar}/>
<ul style={{listStyle: 'none', padding: 0}}>
{_.map(props.calendar, (day) => {
return (
<CalendarDay type={day.type} day={day} includeExtraText/>
)
})}
</ul>
</div>
);
Calendar.propTypes = {
calendar: PropTypes.object,
year: PropTypes.number,
squeezeNumber: PropTypes.number,
switchYear: PropTypes.func,
switchSqueezeNumber: PropTypes.func
};
const Day = (props) => {
let backgroundColor;
let color;
let text;
// Add appropriate styling and text to days
switch (props.type) {
case 'inneklemt':
backgroundColor = '#71a74b';
color = 'black';
text = props.day.formattedDate + ' - INNEKLEMT!';
break;
case 'weekend':
backgroundColor = 'rgb(197, 150, 237)';
color = 'inherit';
break;
case 'holiday':
backgroundColor = 'lightcoral';
color = 'inherit';
text = props.day.formattedDate + ' - ' + props.day.name;
break;
default:
backgroundColor = 'lightblue';
color = 'inherit';
}
const style = {
backgroundColor: backgroundColor,
color: color,
marginTop: props.firstSqueezedDay ? '5px' : 0,
padding: '5px 0',
fontSize: '1.1em',
listStyle: 'none'
};
return (
<li style={style}>
{
props.includeExtraText && text ? text : props.day.formattedDate
}
</li>
)
};
Day.propTypes = {
day: PropTypes.object.isRequired,
type: PropTypes.string,
includeExtraText: PropTypes.bool,
firstSqueezedDay: PropTypes.bool
};
const ButtonSqueezedDay = (props) => {
return (
<Link to={props.day.formattedDate} offset={-document.documentElement.clientHeight / 2} smooth={true}
duration={200}>
<Day day={props.day} firstSqueezedDay={props.firstSqueezedDay} includeExtraText={false}
type={'inneklemt'}/>
</Link>
)
};
ButtonSqueezedDay.propTypes = {
day: PropTypes.object.isRequired,
firstSqueezedDay: PropTypes.bool
};
const CalendarDay = (props) => {
return (
<Element name={props.day.formattedDate}>
<Day day={props.day} firstSqueezedDay={false} includeExtraText={true} type={props.type}/>
</Element>
)
};
CalendarDay.propTypes = {
day: PropTypes.object.isRequired,
type: PropTypes.string,
};
const SqueezedDays = (props) => (
<div>
<h4>{`Inneklemte dager (${_.filter(props.calendar, day => day.type === 'inneklemt').length})`}</h4>
<ul style={{padding: 0}}>
{
/**
* Getting all squeezed days and adding a small space if there is some other type of days between two
* continuous chunks of squeezed days.
*/
_
.filter(props.calendar, day => day.type === 'inneklemt')
.map((day) => {
if (day.daysFromLast === 0) {
return <ButtonSqueezedDay key={day.formattedDate} day={day} firstSqueezedDay/>
} else {
return <ButtonSqueezedDay key={day.formattedDate} day={day}/>
}
})
}
</ul>
</div>
);
export default Calendar;
|
src/Parser/Hunter/Survival/Modules/Traits/EaglesBite.js | hasseboulen/WoWAnalyzer | import React from 'react';
import Analyzer from 'Parser/Core/Analyzer';
import Combatants from 'Parser/Core/Modules/Combatants';
import SPELLS from 'common/SPELLS';
import SpellIcon from "common/SpellIcon";
import SpellLink from "common/SpellLink";
import ItemDamageDone from 'Main/ItemDamageDone';
/*
* Harpoon applies On the Trail, a unique damage over time effect that deals [ 360% of Attack Power ] damage over until cancelled.
* Your melee autoattacks extend its duration by 6 sec.
*/
//TODO: Dig through logs and find average uptimes and make suggestions for this
class EaglesBite extends Analyzer {
static dependencies = {
combatants: Combatants,
};
damage = 0;
on_initialized() {
this.active = this.combatants.selected.traitsBySpellId[SPELLS.EAGLES_BITE_TRAIT.id];
}
on_byPlayer_damage(event) {
const spellId = event.ability.guid;
if (spellId !== SPELLS.ON_THE_TRAIL_DAMAGE.id) {
return;
}
this.damage += event.amount + (event.absorbed || 0);
}
subStatistic() {
return (
<div className="flex">
<div className="flex-main">
<SpellLink id={SPELLS.EAGLES_BITE_TRAIT.id}>
<SpellIcon id={SPELLS.EAGLES_BITE_TRAIT.id} noLink /> Eagle's Bite
</SpellLink>
</div>
<div className="flex-sub text-right">
<ItemDamageDone amount={this.damage} />
</div>
</div>
);
}
}
export default EaglesBite;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.