path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
demos/redux-demo/app/myComponent.js | Snger/fullstack-training-cn | import React from 'react';
import ReactDOM from 'react-dom';
class MyComponent extends React.Component {
render() {
return (
<div className="index">
<p>{this.props.text}</p>
<input defaultValue={this.props.name} onChange={this.props.onChange} />
</div>
);
}
}
export default MyComponent;
|
public/js/components/admin/path.react.js | MadushikaPerera/Coupley | /**
* Created by Isuru 1 on 21/01/2016.
*/
import React from 'react';
import { Link } from 'react-router';
import PathStore from './../../stores/admin/PathStore';
const Path = React.createClass({
getInitialState: function () {
return PathStore.getpath();
},
componentDidMount: function () {
PathStore.addChangeListener(this._onChange);
},
_onChange: function () {
this.setState(
PathStore.getpath()
);
},
render: function () {
return (
<div className="path">
<section className="content-header">
<h1>
Dashboard
<small>Control panel</small>
</h1>
<ol className="breadcrumb">
<li>
<a >
<i className="fa fa-dashboard"></i>
HOME</a>
</li>
<li className="active">{this.state.path}</li>
</ol>
</section>
</div>
);
},
});
export default Path;
|
src/index.js | GJMcGowan/personal_site | import React from 'react';
import ReactDOM from 'react-dom';
import { browserHistory } from 'react-router';
import Routes from './routes';
import './index.css';
ReactDOM.render(
<Routes history={browserHistory} />,
document.getElementById('root')
);
|
local-cli/templates/HelloNavigation/views/welcome/WelcomeText.android.js | kesha-antonov/react-native | import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native';
export default class WelcomeText extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
This app shows the basics of navigating between a few screens,
working with ListView and handling text input.
</Text>
<Text style={styles.instructions}>
Modify any files to get started. For example try changing the
file views/welcome/WelcomeText.android.js.
</Text>
<Text style={styles.instructions}>
Double tap R on your keyboard to reload,{'\n'}
Shake or press menu button for dev menu.
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
padding: 20,
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 16,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 12,
},
});
|
src/svg-icons/maps/local-offer.js | pradel/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsLocalOffer = (props) => (
<SvgIcon {...props}>
<path d="M21.41 11.58l-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42zM5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7z"/>
</SvgIcon>
);
MapsLocalOffer = pure(MapsLocalOffer);
MapsLocalOffer.displayName = 'MapsLocalOffer';
export default MapsLocalOffer;
|
node_modules/react-select/examples/src/app.js | rblin081/drafting-client | /* eslint react/prop-types: 0 */
import React from 'react';
import ReactDOM from 'react-dom';
import Select from 'react-select';
import Creatable from './components/Creatable';
import Contributors from './components/Contributors';
import GithubUsers from './components/GithubUsers';
import CustomComponents from './components/CustomComponents';
import CustomRender from './components/CustomRender';
import Multiselect from './components/Multiselect';
import NumericSelect from './components/NumericSelect';
import BooleanSelect from './components/BooleanSelect';
import Virtualized from './components/Virtualized';
import States from './components/States';
ReactDOM.render(
<div>
<States label="States" searchable />
<Multiselect label="Multiselect" />
<Virtualized label="Virtualized" />
<Contributors label="Contributors (Async)" />
<GithubUsers label="Github users (Async with fetch.js)" />
<NumericSelect label="Numeric Values" />
<BooleanSelect label="Boolean Values" />
<CustomRender label="Custom Render Methods"/>
<CustomComponents label="Custom Placeholder, Option, Value, and Arrow Components" />
<Creatable
hint="Enter a value that's NOT in the list, then hit return"
label="Custom tag creation"
/>
</div>,
document.getElementById('example')
);
|
source/component/listview/offlineList.js | togayther/react-native-cnblogs | import React, { Component } from 'react';
import {
View,
ListView
} from 'react-native';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import OfflineRow from './offlineRow';
import ViewPage from '../view';
class OfflineList extends Component {
constructor(props) {
super(props);
let dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: dataSource.cloneWithRows(props.posts||{}),
};
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
}
componentWillReceiveProps(nextProps) {
if (nextProps.posts && nextProps.posts.length && nextProps.posts !== this.props.posts) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(nextProps.posts)
});
}
}
onListRowPress(post){
this.props.router.push(ViewPage.offlinePost(), {
id: post.Id,
category: this.props.category,
post
});
}
renderListRow(post) {
if(post && post.Id){
const { onRemovePress = ()=>null } = this.props;
return (
<OfflineRow
key={ post.Id }
post={ post }
onRowLongPress={(e)=>onRemovePress(e)}
onRowPress={ (e)=>this.onListRowPress(e) } />
)
}
}
render() {
return (
<ListView
ref = {(view)=> this.listView = view }
removeClippedSubviews
enableEmptySections = { true }
onEndReachedThreshold={ 10 }
initialListSize={ 10 }
pageSize = { 10 }
pagingEnabled={ false }
scrollRenderAheadDistance={ 150 }
dataSource={ this.state.dataSource }
renderRow={ (e)=>this.renderListRow(e) }>
</ListView>
);
}
}
export default connect((state, props) => ({
posts : state.offline.posts
}), dispatch => ({
}))(OfflineList); |
examples/shopping-cart/src/components/ProductItem.js | lifeiscontent/redux | import React from 'react'
import PropTypes from 'prop-types'
import Product from './Product'
const ProductItem = ({ product, onAddToCartClicked }) => (
<div style={{ marginBottom: 20 }}>
<Product
title={product.title}
price={product.price} />
<button
onClick={onAddToCartClicked}
disabled={product.inventory > 0 ? '' : 'disabled'}>
{product.inventory > 0 ? 'Add to cart' : 'Sold Out'}
</button>
</div>
)
ProductItem.propTypes = {
product: PropTypes.shape({
title: PropTypes.string.isRequired,
price: PropTypes.number.isRequired,
inventory: PropTypes.number.isRequired
}).isRequired,
onAddToCartClicked: PropTypes.func.isRequired
}
export default ProductItem
|
packages/material-ui-icons/src/LeakRemove.js | AndriusBil/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let LeakRemove = props =>
<SvgIcon {...props}>
<path d="M10 3H8c0 .37-.04.72-.12 1.06l1.59 1.59C9.81 4.84 10 3.94 10 3zM3 4.27l2.84 2.84C5.03 7.67 4.06 8 3 8v2c1.61 0 3.09-.55 4.27-1.46L8.7 9.97C7.14 11.24 5.16 12 3 12v2c2.71 0 5.19-.99 7.11-2.62l2.5 2.5C10.99 15.81 10 18.29 10 21h2c0-2.16.76-4.14 2.03-5.69l1.43 1.43C14.55 17.91 14 19.39 14 21h2c0-1.06.33-2.03.89-2.84L19.73 21 21 19.73 4.27 3 3 4.27zM14 3h-2c0 1.5-.37 2.91-1.02 4.16l1.46 1.46C13.42 6.98 14 5.06 14 3zm5.94 13.12c.34-.08.69-.12 1.06-.12v-2c-.94 0-1.84.19-2.66.52l1.6 1.6zm-4.56-4.56l1.46 1.46C18.09 12.37 19.5 12 21 12v-2c-2.06 0-3.98.58-5.62 1.56z" />
</SvgIcon>;
LeakRemove = pure(LeakRemove);
LeakRemove.muiName = 'SvgIcon';
export default LeakRemove;
|
docs/app/Examples/elements/Container/index.js | vageeshb/Semantic-UI-React | import React from 'react'
import Types from './Types'
import Variations from './Variations'
const ContainerExamples = () => (
<div>
<Types />
<Variations />
</div>
)
export default ContainerExamples
|
examples/infinite-scrolling/src/components/ShowLoadingScreen.js | lore/lore | /**
* This component shows the loading screen. It does so by removing any classes it
* has, which will revert it back to it's default state, which is visible.
**/
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
export default createReactClass({
displayName: 'ShowLoadingScreen',
/*
* This component will show the loading screen once it's mounted.
*/
componentDidMount() {
const element = document.getElementById("loading-screen");
// As a precaution, check if the loading screen exists and stop
// here if does not
if (!element) {
return;
}
// Remove any classes applied to the loading screen, which will revert
// it back to it's default state of being visible
element.className = "";
},
/*
* This component doesn't render anything; it strictly exists for behavioral
* control of the loading screen.
*/
render() {
return null;
}
});
|
src/components/RightController/index.js | Plop3D/sandbox | import React from 'react'
import { Entity } from 'aframe-react'
const RightController = (props) => {
return (
<Entity
id="rightController"
hand-controls="right"
sphere-collider={{ objects: '.interactive', radius: 0.05 }}
if-no-vr-headset={{ visible: false }}
super-hands
static-body={{ shape: 'sphere', sphereRadius: 0.05 }}
{...props}
/>
)
}
export default RightController
|
client/components/basic/avatar/RoomAvatar.js | subesokun/Rocket.Chat | import React from 'react';
import { Avatar } from '@rocket.chat/fuselage';
import { roomTypes } from '../../../../app/utils/client';
function RoomAvatar({ room: { type, ...room }, ...props }) {
const avatarUrl = roomTypes.getConfig(type).getAvatarPath({ type, ...room });
return <Avatar url={avatarUrl} title={avatarUrl} {...props}/>;
}
export default RoomAvatar;
|
src/components/Feedback/Feedback.js | lolilukia/smda | /**
* 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 withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Feedback.scss';
class Feedback extends Component {
render() {
return (
<div className={s.root}>
<div className={s.container}>
<a
className={s.link}
href="https://gitter.im/kriasoft/react-starter-kit"
>Ask a question</a>
<span className={s.spacer}>|</span>
<a
className={s.link}
href="https://github.com/kriasoft/react-starter-kit/issues/new"
>Report an issue</a>
</div>
</div>
);
}
}
export default withStyles(Feedback, s);
|
js/jqwidgets/demos/react/app/notification/events/app.js | luissancheza/sice | import React from 'react';
import ReactDOM from 'react-dom';
import JqxNotification from '../../../jqwidgets-react/react_jqxnotification.js';
import JqxButton from '../../../jqwidgets-react/react_jqxbuttons.js';
import JqxPanel from '../../../jqwidgets-react/react_jqxpanel.js';
class App extends React.Component {
componentDidMount() {
this.refs.checkMail.on('click', () => {
this.refs.jqxNotification.open();
});
this.refs.jqxNotification.on('open', (event) => {
this.refs.eventsPanel.append(event.type + '<br />');
});
this.refs.jqxNotification.on('close', (event) => {
this.refs.eventsPanel.append(event.type + '<br />');
});
this.refs.jqxNotification.on('click', () => {
this.refs.eventsPanel.append(event.type + '<br />');
document.getElementById('messagePanel').style.display = 'inline-block';
});
}
render() {
return (
<div>
<JqxNotification ref='jqxNotification'
width={'auto'}
position={'top-right'}
opacity={0.9}
closeOnClick={true}
autoClose={false}
showCloseButton={true}
template={'mail'}
blink={true}
>
<div>You have <b>2</b> new messages.</div>
<div style={{ fontSize: 'smaller', textAlign: 'center' }}>Click to view.</div>
</JqxNotification>
<JqxButton ref='checkMail' value='Check mail' style={{ marginTop: '20px', position: 'relative' }} />
<div style={{ marginTop: 15 }}>
Events log:</div>
<JqxPanel ref='eventsPanel'
width={150} height={150}
/>
<div id='messagePanel' style={{ width: 400, display: 'none' }}>
<p>
<b>From:</b> Ken</p>
<p>
<b>About</b>: Appointment</p>
<p>
Hi,<br />
I just wanted to remind you dinner is at 8pm tonight at Carl's.</p>
<hr style={{ width: 300, textAlign: 'right' }} />
<p>
<b>From:</b> Sue</p>
<p>
<b>About</b>: Shopping</p>
<p>
Here's the shopping list for tommorow's party:</p>
<ul>
<li>Wine</li>
<li>Tomatoes</li>
<li>Cheese</li>
<li>Popcorn</li></ul>
</div>
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById('app'));
|
src/IconImage/index.js | christianalfoni/ducky-components | import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import styles from './styles.css';
function IconImage(props) {
return (
<img
className={classNames(styles.wrapper, {
[styles[props.size]]: props.size,
[props.className]: props.className
})}
onClick={props.onClick}
src={props.icon}
style={props.style}
>
</img>
);
}
IconImage.propTypes = {
className: PropTypes.string,
icon: PropTypes.string,
onClick: PropTypes.func,
size: PropTypes.oneOf(['small', 'standard',
'large', 'display1', 'display2']),
style: PropTypes.objectOf(PropTypes.oneOfType(
[PropTypes.number, PropTypes.string]
))
};
export default IconImage;
|
springboot/GReact/src/main/resources/static/app/components/ui/UiAjaxAutocomplete.js | ezsimple/java | import React from 'react'
export default class UiAjaxAutocomplete extends React.Component {
componentDidMount() {
let self = this;
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
function extractFirst(term) {
return split(term)[0];
}
let element = $(this.refs.input)
element.autocomplete({
source (request, response) {
jQuery.getJSON(
"http://gd.geobytes.com/AutoCompleteCity?callback=?&q=" + extractLast(request.term),
function (data) {
response(data);
}
);
},
minLength: 3,
select (event, ui) {
var selectedObj = ui.item,
placeName = selectedObj.value;
if (typeof placeName == "undefined") placeName = element.val();
if (placeName) {
var terms = split(element.val());
// remove the current input
terms.pop();
// add the selected item (city only)
terms.push(extractFirst(placeName));
// add placeholder to get the comma-and-space at the end
terms.push("");
if (self.props.onFind)
self.props.onFind(terms.join(", "))
}
return false;
},
focus () {
// prevent value inserted on focus
return false;
},
delay: 100
});
}
render() {
const { onFind, ...props} = {...this.props}
return <input type="text" {...props} ref="input"/>
}
} |
src/views/containers/pages/about_page/about_page.js | michaelBenin/react-ssr-spa | import get from 'lodash/get';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import withRouter from 'react-router/withRouter';
import Link from 'react-router-dom/Link';
import loadData from './about_page_data_fetch';
import Footer from './../../../components/footer/footer';
class AboutPage extends Component {
componentWillMount() {
if (!get(this.props, 'state.config.initialPageLoad')) {
loadData(this.props.match, this.props.dispatch, this.props.state);
} else {
// TODO: warm cache for PWA, don't trigger render
}
}
render() {
return (
<div className="about-page">
<h1>What's this about?</h1>
<p>
This project aims to do one thing well: make server side rendering
simple in a react application using only mature community maintained
libraries.
<Link to="/repo/michaelBenin/react-ssr-spa">demo: react-ssr-spa</Link>
</p>
<Footer />
</div>
);
}
}
AboutPage.propTypes = {
match: PropTypes.shape({}).isRequired,
dispatch: PropTypes.func.isRequired,
state: PropTypes.shape({}).isRequired
};
AboutPage.defaultProps = {};
function mapStateToProps(state = {}) {
return {
state
};
}
export default withRouter(connect(mapStateToProps)(AboutPage));
|
packages/flow-upgrade/src/upgrades/0.53.0/ReactComponentExplicitTypeArgs/__tests__/fixtures/LifecycleMethodsPropsAndState.js | gabelevi/flow | // @flow
import React from 'react';
class MyComponent1 extends React.Component {
componentWillReceiveProps(nextProps: Props) {}
}
class MyComponent2 extends React.Component {
shouldComponentUpdate(prevProps: Props, prevState: State) {}
}
class MyComponent3 extends React.Component {
componentWillUpdate(prevProps: Props, prevState: State) {}
}
class MyComponent4 extends React.Component {
componentDidUpdate(prevProps: Props, prevState: State) {}
}
const expression1 = () =>
class extends React.Component {
componentWillReceiveProps(nextProps: Props) {}
}
const expression2 = () =>
class extends React.Component {
shouldComponentUpdate(prevProps: Props, prevState: State) {}
}
const expression3 = () =>
class extends React.Component {
componentWillUpdate(prevProps: Props, prevState: State) {}
}
const expression4 = () =>
class extends React.Component {
componentDidUpdate(prevProps: Props, prevState: State) {}
}
|
docs/server.js | xiaoking/react-bootstrap | /* eslint no-console: 0 */
import 'colors';
import React from 'react';
import express from 'express';
import path from 'path';
import Router from 'react-router';
import routes from './src/Routes';
import httpProxy from 'http-proxy';
import metadata from './generate-metadata';
import ip from 'ip';
const development = process.env.NODE_ENV !== 'production';
const port = process.env.PORT || 4000;
let app = express();
if (development) {
let proxy = httpProxy.createProxyServer();
let webpackPort = process.env.WEBPACK_DEV_PORT;
let target = `http://${ip.address()}:${webpackPort}`;
app.get('/assets/*', function(req, res) {
proxy.web(req, res, { target });
});
proxy.on('error', function(e) {
console.log('Could not connect to webpack proxy'.red);
console.log(e.toString().red);
});
console.log('Prop data generation started:'.green);
metadata().then( props => {
console.log('Prop data generation finished:'.green);
app.use(function renderApp(req, res) {
res.header('Access-Control-Allow-Origin', target);
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
Router.run(routes, req.url, Handler => {
let html = React.renderToString(<Handler assetBaseUrl={target} propData={props}/>);
res.send('<!doctype html>' + html);
});
});
});
} else {
app.use(express.static(path.join(__dirname, '../docs-built')));
}
app.listen(port, function() {
console.log(`Server started at:`);
console.log(`- http://localhost:${port}`);
console.log(`- http://${ip.address()}:${port}`);
});
|
tests/react/key.js | samwgoldman/flow | // @flow
import React from 'react';
class Foo extends React.Component<{}, void> {}
<Foo />; // OK
<Foo key="42" />; // OK
<Foo key={42} />; // OK
<Foo key={null} />; // OK
<Foo key={undefined} />; // OK
<Foo key={true} />; // Error
class FooExact extends React.Component<{||}, void> {}
<FooExact />; // OK
<FooExact key="42" />; // OK
<FooExact key={42} />; // OK
<FooExact key={null} />; // OK
<FooExact key={undefined} />; // OK
<FooExact key={true} />; // Error
|
src/components/layout/Header/LoginSection.js | DominicTremblay/gramventures | import React from 'react';
import {Link} from 'react-router';
import Auth from '../../api/Auth.js';
import LoginType from './LoginType.js';
class LoginSection extends React.Component {
render() {
return (
<div className="login-section">
<ul>
<li><LoginType currentUser={Auth.retrieveUser()} /></li>
</ul>
</div>
)
}
}
export default LoginSection; |
src/components/__mocks__/Biggo.js | swashcap/LookieHere | import React, { Component } from 'react';
import { View } from 'react-native';
jest.genMockFromModule('../Biggo');
export default class MockMiniList extends Component {
render() {
return <View />;
}
}
|
public/src/jest/LinkButton.js | codelegant/react-action | /**
* Author: CodeLai
* Email: codelai@dotdotbuy.com
* DateTime: 2016/7/15 17:17
*/
import React, { Component } from 'react';
export default class LinkButton extends Component {
constructor() {
super();
this.state = {liked: false};
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
return this.setState({
liked: !this.state.liked
});
}
render() {
const text = this.state.liked ? 'like' : 'haven\'t liked';
return (<p onClick={this.handleClick}>
You {text} this.Click to toggle.
</p>);
}
}
|
src/svg-icons/maps/person-pin.js | rscnt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsPersonPin = (props) => (
<SvgIcon {...props}>
<path d="M19 2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h4l3 3 3-3h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 3.3c1.49 0 2.7 1.21 2.7 2.7 0 1.49-1.21 2.7-2.7 2.7-1.49 0-2.7-1.21-2.7-2.7 0-1.49 1.21-2.7 2.7-2.7zM18 16H6v-.9c0-2 4-3.1 6-3.1s6 1.1 6 3.1v.9z"/>
</SvgIcon>
);
MapsPersonPin = pure(MapsPersonPin);
MapsPersonPin.displayName = 'MapsPersonPin';
export default MapsPersonPin;
|
src/components/ChatApp/ChatApp.react.js | RMCoder198/chat.susi.ai | import MessageSection from './MessageSection/MessageSection.react';
import React, { Component } from 'react';
import './ChatApp.css';
import history from '../../history';
export default class ChatApp extends Component {
componentDidMount() {
document.title = 'SUSI.AI Chat - Open Source Artificial Intelligence';
// force an update if the URL changes
history.listen(() => this.forceUpdate());
}
render() {
return (
<div className="chatapp">
<MessageSection {...this.props} />
</div>
);
}
}
|
docs/src/app/components/pages/components/DropDownMenu/ExampleLongMenu.js | andrejunges/material-ui | import React from 'react';
import DropDownMenu from 'material-ui/DropDownMenu';
import MenuItem from 'material-ui/MenuItem';
const items = [];
for (let i = 0; i < 100; i++ ) {
items.push(<MenuItem value={i} key={i} primaryText={`Item ${i}`} />);
}
export default class DropDownMenuLongMenuExample extends React.Component {
constructor(props) {
super(props);
this.state = {value: 10};
}
handleChange = (event, index, value) => this.setState({value});
render() {
return (
<DropDownMenu maxHeight={300} value={this.state.value} onChange={this.handleChange}>
{items}
</DropDownMenu>
);
}
}
|
src/routes/contact/Contact.js | DaveyEdwards/myiworlds | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import PropTypes from 'prop-types';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Contact.css';
class Contact extends React.Component {
static propTypes = {
title: PropTypes.string.isRequired,
};
render() {
return (
<div className={s.root}>
<div className={s.container}>
<h1>{this.props.title}</h1>
<p>...</p>
</div>
</div>
);
}
}
export default withStyles(s)(Contact);
|
src/js/components/Search.js | nicholasodonnell/moonshine | import React from 'react';
class Search extends React.Component {
constructor() {
super();
}
componentWillMount() {
}
render() {
return (
<form class="c-search">
<input class="c-search__input" type="text" name="q" id="q" />
<label class="c-search__label">What are you looking for?</label>
<i class="c-search__icon fa fa-search" aria-hidden="true"></i>
</form>
);
}
}
export default Search;
|
src/svg-icons/image/wb-cloudy.js | ngbrown/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageWbCloudy = (props) => (
<SvgIcon {...props}>
<path d="M19.36 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.64-4.96z"/>
</SvgIcon>
);
ImageWbCloudy = pure(ImageWbCloudy);
ImageWbCloudy.displayName = 'ImageWbCloudy';
ImageWbCloudy.muiName = 'SvgIcon';
export default ImageWbCloudy;
|
node_modules/react-bootstrap/es/ModalDialog.js | cmccandless/SolRFrontEnd | 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, bsSizes, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
import { Size } from './utils/StyleConfig';
var propTypes = {
/**
* A css class to apply to the Modal dialog DOM node.
*/
dialogClassName: React.PropTypes.string
};
var ModalDialog = function (_React$Component) {
_inherits(ModalDialog, _React$Component);
function ModalDialog() {
_classCallCheck(this, ModalDialog);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
ModalDialog.prototype.render = function render() {
var _extends2;
var _props = this.props,
dialogClassName = _props.dialogClassName,
className = _props.className,
style = _props.style,
children = _props.children,
props = _objectWithoutProperties(_props, ['dialogClassName', 'className', 'style', 'children']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var bsClassName = prefix(bsProps);
var modalStyle = _extends({ display: 'block' }, style);
var dialogClasses = _extends({}, getClassSet(bsProps), (_extends2 = {}, _extends2[bsClassName] = false, _extends2[prefix(bsProps, 'dialog')] = true, _extends2));
return React.createElement(
'div',
_extends({}, elementProps, {
tabIndex: '-1',
role: 'dialog',
style: modalStyle,
className: classNames(className, bsClassName)
}),
React.createElement(
'div',
{ className: classNames(dialogClassName, dialogClasses) },
React.createElement(
'div',
{ className: prefix(bsProps, 'content'), role: 'document' },
children
)
)
);
};
return ModalDialog;
}(React.Component);
ModalDialog.propTypes = propTypes;
export default bsClass('modal', bsSizes([Size.LARGE, Size.SMALL], ModalDialog)); |
src/svg-icons/action/chrome-reader-mode.js | hai-cea/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionChromeReaderMode = (props) => (
<SvgIcon {...props}>
<path d="M13 12h7v1.5h-7zm0-2.5h7V11h-7zm0 5h7V16h-7zM21 4H3c-1.1 0-2 .9-2 2v13c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 15h-9V6h9v13z"/>
</SvgIcon>
);
ActionChromeReaderMode = pure(ActionChromeReaderMode);
ActionChromeReaderMode.displayName = 'ActionChromeReaderMode';
ActionChromeReaderMode.muiName = 'SvgIcon';
export default ActionChromeReaderMode;
|
example/src/index.js | xuezhma/react-bpg | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<App />,
document.getElementById('root')
);
|
app/pages/CategoryPage.js | EleTeam/Shop-React-Native | /**
* ShopReactNative
*
* @author Tony Wong
* @date 2016-08-13
* @email 908601756@qq.com
* @copyright Copyright © 2016 EleTeam
* @license The MIT License (MIT)
*/
'use strict';
import React, { Component } from 'react';
import {
StyleSheet,
View,
ListView,
Text,
Image,
InteractionManager,
TouchableOpacity,
Alert
} from 'react-native';
import { categoryListWithProduct } from '../actions/productActions';
import Loading from '../components/Loading';
import ProductContainer from '../containers/ProductContainer';
import Common from '../common/constants';
//页面变量
let isLoading = true;
let curCategoryIndex = 0;
export default class CategoryPage extends Component {
constructor(props) {
super(props);
let dsCategory = new ListView.DataSource({
getRowData: (data, sectionId, rowId) => {
return data[sectionId][rowId];
},
getSectionHeaderData: (data, sectionId) => {
return data[sectionId];
},
rowHasChanged: (row1, row2) => row1 !== row2,
sectionHeaderHasChanged: (section1, section2) => section1 !== section2,
});
let dsProduct = new ListView.DataSource({
getRowData: (data, sectionId, rowId) => {
return data[sectionId][rowId];
},
getSectionHeaderData: (data, sectionId) => {
return data[sectionId];
},
rowHasChanged: (row1, row2) => row1 !== row2,
sectionHeaderHasChanged: (section1, section2) => section1 !== section2,
});
this.state = {
dsCategory: dsCategory,
dsProduct: dsProduct
}
}
componentDidMount() {
//交互管理器在任意交互/动画完成之后,允许安排长期的运行工作. 在所有交互都完成之后安排一个函数来运行。
InteractionManager.runAfterInteractions(() => {
const {dispatch} = this.props;
dispatch(categoryListWithProduct(isLoading));
});
}
render() {
const {categoryReducer} = this.props;
let categories = categoryReducer.categories;
let products = [];
if (!categoryReducer.isLoading){
products = categories[curCategoryIndex].products;
isLoading = false;
}
return (
<View style={styles.container}>
<View style={styles.headerWrap}>
<Text style={styles.header}>商品分类</Text>
</View>
{isLoading ?
<Loading /> :
<View style={styles.mainWrap}>
<ListView style={styles.categoryList}
dataSource={this.state.dsCategory.cloneWithRows(categories)}
renderRow={this._renderRowCategory.bind(this)}
enableEmptySections={true}
/>
<ListView style={styles.productList}
dataSource={this.state.dsProduct.cloneWithRows(products)}
renderRow={this._renderRowProduct.bind(this)}
enableEmptySections={true}
/>
</View>
}
</View>
)
}
//=== 分类栏方法 ===
_renderRowCategory(category, sectionId, rowId) {
let categoryItemStyle = [styles.categoryItem];
if (curCategoryIndex == rowId) {
categoryItemStyle.push(styles.categoryItemActive);
}
return (
<TouchableOpacity
onPress={this._onPressCategory.bind(this, rowId)}
>
<View style={categoryItemStyle}>
<Text>{category.name}</Text>
</View>
</TouchableOpacity>
);
}
_onPressCategory(rowId) {
curCategoryIndex = rowId;
this.forceUpdate();
}
//=== 产品栏方法 ===
_renderRowProduct(product, sectionId, rowId) {
return (
<TouchableOpacity onPress={this._onPressProduct.bind(this, product.id)}>
<View style={styles.productItem}>
<Image
style={styles.productImage}
source={{uri: product.image_small}}
/>
<View style={styles.productRight}>
<Text>{product.name}</Text>
<View style={{flexDirection:'row'}}>
<Text>¥{product.price}</Text>
<Text>¥{product.featured_price}</Text>
</View>
<Text>立减 ¥{product.price - product.featured_price}</Text>
</View>
</View>
</TouchableOpacity>
);
}
_onPressProduct(product_id) {
// Alert.alert(product_id);
InteractionManager.runAfterInteractions(() => {
this.props.navigator.push({
name: 'ProductContainer',
component: ProductContainer,
passProps: {...this.props, product_id:product_id}
})
});
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
headerWrap: {
alignItems: 'center',
height: 44,
backgroundColor: '#ff7419',
},
header: {
color: '#fff',
paddingTop: 22,
fontSize: 16,
},
mainWrap: {
flex:1,
flexDirection:'row',
},
categoryList: {
flex:0,
backgroundColor: '#eee',
width: 70,
height: Common.window.height - 64 - 24,
},
productList: {
flex: 1,
height: Common.window.height - 64 - 24,
},
line:{
backgroundColor:'#eef0f3',
height:1,
},
categoryItem:{
alignItems: 'center', //水平居中
justifyContent: 'center',//垂直居中
height:50,
},
categoryItemActive: {
backgroundColor: '#fff',
},
category_bg_select:{
backgroundColor:'#d7ead6',
},
category_bg_normal:{
backgroundColor:'#fff',
},
productItem: {
height: 80,
flexDirection:'row',
padding: 15,
marginBottom: 1,
backgroundColor:'#fff',
},
productRight: {
flexDirection:'column',
},
productImage: {
width: 60,
height: 60,
marginRight: 15,
},
productPrice: {
fontSize: 24,
color: 'red',
},
productFeaturedPrice: {
fontSize: 14,
color: '#ddd',
}
}); |
blueocean-material-icons/src/js/components/svg-icons/image/filter-drama.js | kzantow/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const ImageFilterDrama = (props) => (
<SvgIcon {...props}>
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.61 5.64 5.36 8.04 2.35 8.36 0 10.9 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4h2c0-2.76-1.86-5.08-4.4-5.78C8.61 6.88 10.2 6 12 6c3.03 0 5.5 2.47 5.5 5.5v.5H19c1.65 0 3 1.35 3 3s-1.35 3-3 3z"/>
</SvgIcon>
);
ImageFilterDrama.displayName = 'ImageFilterDrama';
ImageFilterDrama.muiName = 'SvgIcon';
export default ImageFilterDrama;
|
app/javascript/mastodon/features/compose/components/upload_progress.js | kirakiratter/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import Motion from '../../ui/util/optional_motion';
import spring from 'react-motion/lib/spring';
import Icon from 'mastodon/components/icon';
export default class UploadProgress extends React.PureComponent {
static propTypes = {
active: PropTypes.bool,
progress: PropTypes.number,
icon: PropTypes.string.isRequired,
message: PropTypes.node.isRequired,
};
render () {
const { active, progress, icon, message } = this.props;
if (!active) {
return null;
}
return (
<div className='upload-progress'>
<div className='upload-progress__icon'>
<Icon id={icon} />
</div>
<div className='upload-progress__message'>
{message}
<div className='upload-progress__backdrop'>
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
{({ width }) =>
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
}
</Motion>
</div>
</div>
</div>
);
}
}
|
app/javascript/mastodon/features/ui/components/confirmation_modal.js | anon5r/mastonon | import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, FormattedMessage } from 'react-intl';
import Button from '../../../components/button';
@injectIntl
export default class ConfirmationModal extends React.PureComponent {
static propTypes = {
message: PropTypes.node.isRequired,
confirm: PropTypes.string.isRequired,
onClose: PropTypes.func.isRequired,
onConfirm: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
componentDidMount() {
this.button.focus();
}
handleClick = () => {
this.props.onClose();
this.props.onConfirm();
}
handleCancel = () => {
this.props.onClose();
}
setRef = (c) => {
this.button = c;
}
render () {
const { message, confirm } = this.props;
return (
<div className='modal-root__modal confirmation-modal'>
<div className='confirmation-modal__container'>
{message}
</div>
<div className='confirmation-modal__action-bar'>
<Button onClick={this.handleCancel} className='confirmation-modal__cancel-button'>
<FormattedMessage id='confirmation_modal.cancel' defaultMessage='Cancel' />
</Button>
<Button text={confirm} onClick={this.handleClick} ref={this.setRef} />
</div>
</div>
);
}
}
|
src/components/Intro.js | neontribe/spool | import React, { Component } from 'react';
import headings from '../css/Headings.module.css';
class Intro extends Component {
render () {
return (
<div>
<h2 className={headings.large}>Welcome!</h2>
<p>We would really like to know about the things you do.</p>
<p>What you like. What you don't like.</p>
<p>Use this app to tell us about what you do.</p>
</div>
);
}
}
export default Intro;
|
src/files/modals/new-folder-modal/NewFolderModal.js | ipfs/webui | import React from 'react'
import PropTypes from 'prop-types'
import { withTranslation } from 'react-i18next'
import FolderIcon from '../../../icons/StrokeFolder'
import TextInputModal from '../../../components/text-input-modal/TextInputModal'
function NewFolderModal ({ t, tReady, onCancel, onSubmit, className, ...props }) {
return (
<TextInputModal
onSubmit={(p) => onSubmit(p.trim())}
onChange={(p) => p.trimStart()}
onCancel={onCancel}
className={className}
title={t('newFolderModal.title')}
description={t('newFolderModal.description')}
Icon={FolderIcon}
submitText={t('app:actions.create')}
{...props} />
)
}
NewFolderModal.propTypes = {
onCancel: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
t: PropTypes.func.isRequired,
tReady: PropTypes.bool.isRequired
}
export default withTranslation('files')(NewFolderModal)
|
modules/Lifecycle.js | BerkeleyTrue/react-router | import React from 'react'
import invariant from 'invariant'
const { object } = React.PropTypes
/**
* The Lifecycle mixin adds the routerWillLeave lifecycle method to a
* component that may be used to cancel a transition or prompt the user
* for confirmation.
*
* On standard transitions, routerWillLeave receives a single argument: the
* location we're transitioning to. To cancel the transition, return false.
* To prompt the user for confirmation, return a prompt message (string).
*
* During the beforeunload event (assuming you're using the useBeforeUnload
* history enhancer), routerWillLeave does not receive a location object
* because it isn't possible for us to know the location we're transitioning
* to. In this case routerWillLeave must return a prompt message to prevent
* the user from closing the window/tab.
*/
const Lifecycle = {
contextTypes: {
history: object.isRequired,
// Nested children receive the route as context, either
// set by the route component using the RouteContext mixin
// or by some other ancestor.
route: object
},
propTypes: {
// Route components receive the route object as a prop.
route: object
},
componentDidMount() {
invariant(
this.routerWillLeave,
'The Lifecycle mixin requires you to define a routerWillLeave method'
)
const route = this.props.route || this.context.route
invariant(
route,
'The Lifecycle mixin must be used on either a) a <Route component> or ' +
'b) a descendant of a <Route component> that uses the RouteContext mixin'
)
this._unlistenBeforeLeavingRoute = this.context.history.listenBeforeLeavingRoute(
route,
this.routerWillLeave
)
},
componentWillUnmount() {
if (this._unlistenBeforeLeavingRoute)
this._unlistenBeforeLeavingRoute()
}
}
export default Lifecycle
|
src/containers/LoginSection.js | giladgreen/pokerStats | import React, { Component } from 'react';
import { Connect,PreConnect } from '../actions/index';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {cloneDeep} from 'lodash';
class LoginSection extends Component {
constructor(props){
super(props);
// console.log('LoginSection ctor');
const groupId = localStorage.getItem('groupId') || '';
const password = localStorage.getItem('password') || '';
this.state = {
groupId:groupId,
password:password
}
this.onGroupIdChange = this.onGroupIdChange.bind(this);
this.onGroupIdChangeFromOutSide = this.onGroupIdChangeFromOutSide.bind(this);
this.onPaswordChange = this.onPaswordChange.bind(this);
this.onFormSubmit = this.onFormSubmit.bind(this);
const THIS = this;
if (!this.props.pokerStats.connected &&
!this.props.pokerStats.connecting &&
!!groupId && groupId.length>0 && !!password && password.length>0){
setTimeout(()=>{
THIS.props.PreConnect();
setTimeout(()=>{
THIS.props.Connect(groupId,password);
},700);
},400);
}
}
componentDidMount () {
if (this.props.onMounted) {
this.props.onMounted({
onGroupIdChangeFromOutSide: groupId => this.onGroupIdChangeFromOutSide(groupId)
})
}
}
onFormSubmit(event){
const THIS = this;
if (event){
event.preventDefault();
}
const {password,groupId} = this.state;
THIS.props.PreConnect();
setTimeout(()=>{
THIS.props.Connect(groupId,password);
},700);
}
onGroupIdChangeFromOutSide(groupId){
const newState = cloneDeep(this.state);
newState.groupId=groupId;
newState.password='';
this.setState(newState);
}
onGroupIdChange(groupId){
const newState = cloneDeep(this.state);
newState.groupId=groupId;
this.setState(newState);
}
onPaswordChange(password){
const newState = cloneDeep(this.state);
newState.password=password;
this.setState(newState);
}
render() {
const {connected,loginError} = this.props.pokerStats;
if (connected){
return <div/>;
}
// console.log('LoginSection render');
const error = loginError ? (
<div id="loginError" className="redText">
<span className="glyphicon glyphicon-info-sign" aria-hidden="true" > </span>
{loginError}
</div>
) : <div/>;
const linkToCreateGroup = (
<div className="text-center">
<span id="DontHaveGroupYetHeader" >Don't have a group yet? </span>
<a id="CreateNowHeader" href="#newgroup"> Create now </a>
</div>
);
return (
<div id="login" className="section md-padding">
<div className="container">
<div className="row">
<div className="text-center">
<h2 className="title" id="loginHeader">Login</h2>
</div>
<div className="login">
<form className="input-group loginForm row" onSubmit={(e)=>this.onFormSubmit(e)}>
<div className="loginItem " >
<label className="formLabel">Group Id:</label>
<input type="text" name="groupId" value={this.state.groupId} onChange={event => this.onGroupIdChange(event.target.value)}></input>
<br /> <br />
</div>
<div className="loginItem " >
<label className="formLabel">Password:</label>
<input type="password" name="password" value={this.state.password} onChange={event => this.onPaswordChange(event.target.value)}></input>
<hr />
</div>
{error}
<button type="submit" className="loginItem btn btn-success text-xs-right centerButton" >
<span className="glyphicon glyphicon-resize-small" aria-hidden="true" > </span>
Login
</button>
</form>
</div>
{linkToCreateGroup}
</div>
</div>
</div>
);
}
}
function mapStateToProps(state){
return {pokerStats:state.pokerStats};
}
function mapDispatchToProps(dispatch){
return bindActionCreators({Connect,PreConnect},dispatch);
}
export default connect(mapStateToProps,mapDispatchToProps)(LoginSection);
|
src/routes/GasHybridElectric/components/Results3.js | psound/jm-liberty | import React from 'react'
import { IndexLink, Link } from 'react-router'
import './HomeView.scss'
const styles = {};
let data = require('../assets/data.json');
class Results3 extends React.Component {
constructor (props) {
super(props);
this.state = {
heroImage: require(`../../../img/${data.results[0].hero}`),
}
}
componentDidMount() {}
componentWillReceiveProps(nextProps) {}
render() {
return(
<div className={'results'}>
<div className="row subheaderbar" >
<em>{data.quizName}</em>
</div>
<div className="r1">
<img src={this.state.heroImage} className="img-responsive img-circle results" />
</div>
<div className="row2">
<h2>Your Car Should be <b>{data.results[2].title}</b></h2>
<Link className="whystate">email my results></Link>
<p className="resultLegend">{data.results[2].text}
<a href="http://www.libertymutual.com/carbuying" >Click here for guaranteed savings</a>
through the Liberty Mutual Car Buying Program.
</p>
</div>
<div className="clearfix"></div>
<div className="col-sm-6">
<p className="text-center lm-blue">
<em>Which Is Right for you:<br />
New or Used?</em>
</p>
<nav aria-label="...">
<ul className="pager">
<li><a href="#"><em>Take this quiz <span className="yellow">></span></em></a></li>
</ul>
</nav>
</div>
<div className="col-sm-6">
<p className="text-center lm-blue">
<em>Which Is Right for You:<br />
Buy or Lease?</em>
</p>
<nav aria-label="...">
<ul className="pager">
<li><a href="#"><em>Take this quiz <span className="yellow">></span></em></a></li>
</ul>
</nav>
</div>
</div>
)
}
}
Results3.contextTypes = {
router: React.PropTypes.object.isRequired
};
export default Results3
|
src/Breadcrumb.js | react-materialize/react-materialize | import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Col from './Col';
const Breadcrumb = ({ cols, children, className }) => (
<nav className={cx('row', className)}>
<div className="nav-wrapper">
<Col s={cols}>
{React.Children.map(children, item =>
React.cloneElement(item, { className: 'breadcrumb' })
)}
</Col>
</div>
</nav>
);
Breadcrumb.propTypes = {
children: PropTypes.node,
/**
* responsive col value
* @default 12
*/
cols: PropTypes.number,
className: PropTypes.string
};
Breadcrumb.defaultProps = {
cols: 12
};
export default Breadcrumb;
|
react/components/Container/Main/Overlay.js | GeorgeGkas/web-class.gr | import React from 'react';
import sidebarStore from '../Sidebar/SidebarStore.js';
export default class Header extends React.Component {
constructor() {
super();
this.state = {
SidebarIsCollapse: sidebarStore.getCurrentState()
}
this.OverlayClass = 'hidden';
}
componentWillMount() {
sidebarStore.on('change', () => {
this.setState({ SidebarIsCollapse: sidebarStore.getCurrentState() });
this.SetOverlayState();
});
}
SetOverlayState() {
if (this.state.SidebarIsCollapse) {
this.OverlayClass = "hidden-sm hidden-md hidden-lg";
} else {
this.OverlayClass = "hidden";
}
}
render() {
return (
<div class={this.OverlayClass} id="overlay"></div>
);
}
}
|
client/components/signup/SignupForm.js | brucelane/react-redux | import React from 'react';
import classnames from 'classnames';
import validateInput from '../../../server/shared/validations/signup';
import TextFieldGroup from '../common/TextFieldGroup';
class SignupForm extends React.Component {
constructor(props) {
super(props);
this.state = {
username: '',
email: '',
password: '',
passwordConfirmation: '',
timezone: '',
errors: {},
isLoading: false,
invalid: false
}
this.onChange = this.onChange.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.checkUserExists = this.checkUserExists.bind(this);
}
onChange(e) {
this.setState({ [e.target.name]: e.target.value });
}
isValid() {
const { errors, isValid } = validateInput(this.state);
if (!isValid) {
this.setState({ errors });
}
return isValid;
}
checkUserExists(e) {
const field = e.target.name;
const val = e.target.value;
if (val !== '') {
this.props.isUserExists(val).then(res => {
let errors = this.state.errors;
let invalid;
if (res.data.user) {
errors[field] = 'There is user with such ' + field;
invalid = true;
} else {
errors[field] = '';
invalid = false;
}
this.setState({ errors, invalid });
});
}
}
onSubmit(e) {
e.preventDefault();
if (this.isValid()) {
this.setState({ errors: {}, isLoading: true });
this.props.userSignupRequest(this.state).then(
() => {
this.props.addFlashMessage({
type: 'success',
text: 'You signed up successfully. Welcome!'
});
this.context.router.push('/');
},
(err) => this.setState({ errors: err.response.data, isLoading: false })
);
}
}
render() {
const { errors } = this.state;
return (
<form onSubmit={this.onSubmit}>
<h1>Join our community!</h1>
<TextFieldGroup
error={errors.username}
label="Username"
onChange={this.onChange}
checkUserExists={this.checkUserExists}
value={this.state.username}
field="username"
/>
<TextFieldGroup
error={errors.email}
label="Email"
onChange={this.onChange}
checkUserExists={this.checkUserExists}
value={this.state.email}
field="email"
/>
<TextFieldGroup
error={errors.password}
label="Password"
onChange={this.onChange}
value={this.state.password}
field="password"
type="password"
/>
<TextFieldGroup
error={errors.passwordConfirmation}
label="Password Confirmation"
onChange={this.onChange}
value={this.state.passwordConfirmation}
field="passwordConfirmation"
type="password"
/>
<div className="form-group">
<button disabled={this.state.isLoading || this.state.invalid} className="btn btn-primary btn-lg">
Sign up
</button>
</div>
</form>
);
}
}
SignupForm.propTypes = {
userSignupRequest: React.PropTypes.func.isRequired,
addFlashMessage: React.PropTypes.func.isRequired,
isUserExists: React.PropTypes.func.isRequired
}
SignupForm.contextTypes = {
router: React.PropTypes.object.isRequired
}
export default SignupForm;
|
envkey-react/src/components/env_manager/entry_form.js | envkey/envkey-app | import React from 'react'
import R from 'ramda'
import h from "lib/ui/hyperscript_with_helpers"
import LabelRow from './label_row'
import EntryFormRow from './entry_form_row'
import SmallLoader from 'components/shared/small_loader'
export default class EntryForm extends React.Component {
_onSubmit(){
const formData = this.refs.entryFormRow.formData()
if (formData.entryKey){
this.props.onSubmit(formData)
this.refs.entryFormRow.reset()
}
}
componentWillReceiveProps(nextProps){
if (this.props.parent.id != nextProps.parent.id){
this.refs.entryFormRow.reset()
}
}
_classNames(){
const autocompleteOpen = this.props.autocompleteOpenEnvironment &&
this.props.autocompleteOpenEntryKey === null,
lastEnv = this.props.environments[this.props.environments.length - 1],
autocompleteLastEnvironmentOpen = autocompleteOpen &&
lastEnv === this.props.autocompleteOpenEnvironment
return [
"entry-form",
(autocompleteLastEnvironmentOpen ? "autocomplete-open-last-environment" : "")
]
}
render(){
return h.div({
className: this._classNames().join(" ")
}, [
h(EntryFormRow, {
...this.props,
ref: "entryFormRow"
}),
h.div(".submit-row", [this._renderSubmit()])
])
}
_renderSubmit(){
if (!(this.props.editingMultilineEnvironment && !this.props.editingMultilineEntryKey)){
return h.button(".submit",{onClick: ::this._onSubmit}, "Add Variable")
}
}
} |
tests/react_modules/es6class-proptypes-module.js | ylu1317/flow | /* @flow */
import React from 'react';
import type {Node} from 'react';
class Hello extends React.Component<{name: string}> {
defaultProps = {};
propTypes = {
name: React.PropTypes.string.isRequired,
};
render(): Node {
return <div>{this.props.name}</div>;
}
}
module.exports = Hello;
|
src/components/datetime-picker/picker.js | jl-/bronote | /**
* <DatePicker
* date
* onChange // trigge on selected date change
* />
*
*
*
*/
import React, { Component } from 'react';
import cx from 'classnames';
import './style.scss';
const LEVEL_YEARS = 1;
const LEVEL_MONTHS = 2;
const LEVEL_DATES = 3;
const LEVEL_TIME = 4;
const YEAR_OFFSET = 4;
const MONTH_OFFSET = 4;
const MONTHS = [
'Jan', 'Feb', 'Mar',
'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec'
];
const DTP_REF = Symbol('dtp');
const WEEKDAY_FLAGS = (
<div className='dtp-wfs'>
{
['S', 'M', 'T', 'W', 'T', 'F', 'S'].map((flag, index) => (
<span key={index} className='dtp__wf'>{flag}</span>
))
}
</div>
);
function isValidDate(date) {
return date instanceof Date && !isNaN(date.getTime());
}
function composeDateFromTarget(target, root) {
while (target && target !== root) {
let dataDate = target.getAttribute('data-date');
if (dataDate) return new Date(dataDate);
target = target.parentElement;
}
return null;
}
class DatetimePicker extends Component {
constructor(props) {
super(props);
const { date: selectedDate, level = LEVEL_DATES } = props;
const pendingDate = isValidDate(selectedDate) ? new Date(selectedDate) : new Date();
this.state = { selectedDate, pendingDate, level };
this.handleCalendarClick = ::this.handleCalendarClick;
}
componentWillReceiveProps({ date, level }) {
const dateChanged = date !== this.props.date && isValidDate(date);
const levelChange = level !== this.props.level;
if (dateChanged) {
this.setState({ selectedDate: date, pendingDate: new Date(date) });
}
if (levelChange) {
this.setState({ level });
}
}
getValue() {
return this.state.selectedDate;
}
levelUp(thisLevel) {
if (thisLevel === LEVEL_YEARS) return;
const level = thisLevel === LEVEL_TIME ? LEVEL_DATES : thisLevel === LEVEL_DATES ? LEVEL_MONTHS : LEVEL_YEARS;
this.setState({ level });
}
nav(level, factor) {
const { pendingDate: prevPendingDate, selectedDate: prevSelectedDate } = this.state;
const [prevYear, prevMonth, prevDate] = [
prevPendingDate.getFullYear(), prevPendingDate.getMonth(), prevPendingDate.getDate()
];
let pendingDate, selectedDate = prevSelectedDate;
if (level === LEVEL_YEARS) {
pendingDate = new Date(prevYear + factor * 10, prevMonth);
} else if (level === LEVEL_MONTHS) {
pendingDate = new Date(prevYear + factor, prevMonth);
} else if (level === LEVEL_DATES) {
pendingDate = new Date(prevYear, prevMonth + factor + 1, 0);
const daysCount = pendingDate.getDate();
if (daysCount > prevDate) {
pendingDate.setDate(prevDate);
}
} else {
pendingDate = new Date();
}
this.setState({ pendingDate, selectedDate });
}
handleCalendarClick(e) {
const date = composeDateFromTarget(e.target, this.refs[DTP_REF]);
if (!isValidDate(date)) return;
const { level: prevLevel, selectedDate: prevSelectedDate } = this.state;
const level = prevLevel === LEVEL_YEARS ? LEVEL_MONTHS :
prevLevel === LEVEL_MONTHS ? LEVEL_DATES : LEVEL_TIME;
const pendingDate = date;
const selectedDate = prevLevel === LEVEL_DATES || prevLevel === LEVEL_TIME ? new Date(date) : prevSelectedDate;
const { onChange } = this.props;
setTimeout(() => this.setState({ level, selectedDate, pendingDate }), 0);
if (typeof onChange === 'function') onChange(selectedDate);
}
renderHeaderCtrl(pendingDate, level) {
const year = pendingDate.getFullYear();
return (
<div className='dtp-hc'>
<span className='dtp-prev fa fa-angle-double-left' onClick={() => this.nav(level, -1)}></span>
<span
className='dtp-curr'
onClick={() => this.levelUp(level)}
>
{
level === LEVEL_YEARS ? `${year - YEAR_OFFSET} - ${year + 7}` :
level === LEVEL_MONTHS ? `${year}` :
level === LEVEL_DATES ? `${year} - ${pendingDate.getMonth() + 1}` :
`${year} - ${pendingDate.getMonth() + 1} - ${pendingDate.getDate()}`
}
</span>
<span className='dtp-next fa fa-angle-double-right' onClick={() => this.nav(level, 1)}></span>
</div>
);
}
renderYears(thisYear) {
const startYear = thisYear - YEAR_OFFSET;
const endYear = startYear + 11;
const currentYear = (new Date()).getFullYear();
const years = [];
for (let year = startYear; year <= endYear; year++) {
let isPast = year < currentYear;
let isCurrent = year === currentYear;
let className = `dtp__yc dtp__yc--${isPast ? 'past' : isCurrent ? 'curr' : 'future'}`;
(year === thisYear) && (className += ' dtp__yc--selected');
years.push((
<span
key={years.length}
className={className}
data-date={`${year}`}
>
{year}
</span>
));
}
return <div className='dtp-ycs'>{years}</div>;
}
renderMonths(thisYear, thisMonth) {
const today = new Date();
const currentYear = today.getFullYear();
const currentMonth = today.getMonth();
const months = MONTHS.map((month, index) => {
const isPast = thisYear < currentYear || (thisYear === currentYear && index < currentMonth);
const isCurrent = thisYear === currentYear && index === currentMonth;
let className = `dtp__mc dtp__mc--${isPast ? 'past' : isCurrent ? 'curr' : 'future'}`;
(index === thisMonth) && (className += ' dtp__mc--selected');
return (
<span
key={index}
className={className}
data-date={`${thisYear}/${index + 1}`}
>
{month}
</span>
);
});
return <div className='dtp-mcs'>{months}</div>
}
renderDates(thisYear, thisMonth, thisDate, selected) {
const today = new Date();
const [currentYear, currentMonth, currentDate] = [
today.getFullYear(), today.getMonth(), today.getDate()
];
const selectedYear = selected && selected.getFullYear();
const selectedMonth = selected && selected.getMonth();
const selectedDate = selected && selected.getDate();
const lastDateOfThisMonth = new Date(thisYear, thisMonth + 1, 0);
const datesCountOfThisMonth = lastDateOfThisMonth.getDate();
const lastDateOfPrevMonth = new Date(thisYear, thisMonth, 0);
const lastDayOfPrevMonth = lastDateOfPrevMonth.getDay();
const visibleDatesCountOfPrevMonth = (lastDayOfPrevMonth + 1) % 7;
// there are 42 dates in the calendar of a month.
const visibleDatesCountOfNextMonth = 42 - visibleDatesCountOfPrevMonth - datesCountOfThisMonth;
const dates = [];
// a few ending dates of previous month may be visible
// in the begining of the calendar of this month.
if (visibleDatesCountOfPrevMonth > 0) {
const datesCountOfPrevMonth = lastDateOfPrevMonth.getDate();
const startDateOfPrevVisible = datesCountOfPrevMonth - visibleDatesCountOfPrevMonth + 1;
const prevMonth = (thisMonth -1 + 12) % 12;
const prevYear = prevMonth > thisMonth ? thisYear - 1 : thisYear;
for (let date = startDateOfPrevVisible; date <= datesCountOfPrevMonth; date++) {
dates.push({ date, year: prevYear, month: prevMonth });
}
}
// dates of this month
for (let date = 1; date <= datesCountOfThisMonth; date++) {
dates.push({ date, year: thisYear, month: thisMonth });
}
// a few begining dates of next month may be visible
// in the end of the calendar of this month
if (visibleDatesCountOfNextMonth > 0) {
const nextMonth = (thisMonth + 1) % 12;
const nextYear = nextMonth > thisMonth ? thisYear : thisYear + 1;
for (let date = 1; date <= visibleDatesCountOfNextMonth; date++) {
dates.push({ date, year: nextYear, month: nextMonth });
}
}
const dateItems = dates.map(({ date, year, month }, index) => {
const isPast = (year < currentYear) || (year === currentYear && (
(month < currentMonth) || (month === currentMonth && date < currentDate)
));
const isCurrent = !isPast && (year === currentYear) && (month === currentMonth) && (date === currentDate);
const isFuture = !isCurrent && !isPast;
const isSelected = year === selectedYear && month === selectedMonth && date === selectedDate;
let className = `dtp__dc dtp__dc--${isPast ? 'past' : isCurrent ? 'curr' : 'future'}`;
className += ` dtp__dc--${month < thisMonth ? 'prev' : month === thisMonth ? 'this' : 'next'}`;
isSelected && (className += ' dtp__dc--selected');
(month === thisMonth && date === thisDate) && (className += ' dtp__dc--this-selected');
return (
<span
key={index}
data-date={`${year}/${month + 1}/${date}`}
className={className}
>
{date}
</span>
);
});
return <div className='dtp-dcs'>{dateItems}</div>;
}
setTime(hour, minute) {
const { onChange } = this.props;
const selectedDate = new Date(this.state.selectedDate);
selectedDate.setHours(hour);
selectedDate.setMinutes(minute);
const pendingDate = new Date(selectedDate);
this.setState({ selectedDate, pendingDate });
if (typeof onChange === 'function') onChange(selectedDate);
}
renderTimePicker(selectedDate) {
const selectedHour = selectedDate.getHours();
const selectedMinute = selectedDate.getMinutes();
const isPM = selectedHour >= 12;
return (
<div className='dtp-tc'>
<div className='dtp-tc-g'>
<span className='dtp-tc__plus fa fa-chevron-up' onClick={() => this.setTime(selectedHour + 1, selectedMinute)}></span>
<input
type='number' min={0} max={12}
className='dtp-tc__input'
value={isPM ? selectedHour - 12 : selectedHour}
onChange={e => {
const value = e.target.value;
e.stopPropagation();
this.setTime(isPM ? value + 12 : value, selectedMinute);
}}
/>
<span className='dtp-tc__min fa fa-chevron-down' onClick={() => this.setTime(selectedHour - 1, selectedMinute)}></span>
</div>
<span className=''>:</span>
<div className='dtp-tc-g'>
<span className='dtp-tc__plus fa fa-chevron-up' onClick={() => this.setTime(selectedHour, selectedMinute + 5)}></span>
<input
type='number' min={0} max={59}
className='dtp-tc__input'
value={selectedMinute}
onChange={e => {
e.stopPropagation();
this.setTime(selectedHour, e.target.value);
}}
/>
<span className='dtp-tc__min fa fa-chevron-down' onClick={() => this.setTime(selectedHour, selectedMinute - 5)}></span>
</div>
<span
className='dtp-tc__apm'
onClick={() => this.setTime(isPM ? selectedHour - 12 : selectedHour + 12, selectedMinute)}
>
{isPM ? 'PM' : 'AM'}
</span>
</div>
);
}
render() {
const { date, level: _level, ...props } = this.props;
const { level, pendingDate, selectedDate } = this.state;
const thisYear = pendingDate.getFullYear();
const thisMonth = pendingDate.getMonth();
const thisDate = pendingDate.getDate();
props.className = cx(props.className, 'dtp');
return (
<div {...props} onClick={this.handleCalendarClick} ref={DTP_REF}>
{this.renderHeaderCtrl(pendingDate, level)}
{
level === LEVEL_DATES ? WEEKDAY_FLAGS : null
}
{
level === LEVEL_YEARS ? this.renderYears(thisYear) :
level === LEVEL_MONTHS ? this.renderMonths(thisYear, thisMonth) :
level === LEVEL_DATES ? this.renderDates(thisYear, thisMonth, thisDate, selectedDate) :
this.renderTimePicker(selectedDate)
}
</div>
);
}
}
export default DatetimePicker;
|
client/src/components/pages/account/ChangePasswordPage.js | 15thnight/15thnight | import React from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import { InputField, FormErrors } from 'form';
import { changePassword, clearFormStatus } from 'actions';
const { stringify, parse } = JSON;
class ChangePassowrdPage extends React.Component {
constructor(props) {
super(props);
this.defaultState = {
current: '',
new_password: '',
confirm: '',
error: {}
}
this.state = parse(stringify(this.defaultState));
}
componentWillReceiveProps(nextProps) {
if (nextProps.submitFormSuccess) {
this.setState(this.defaultState);
return this.props.clearFormStatus();
}
if (nextProps.submitFormError) {
this.setState({
error: nextProps.submitFormError
});
return this.clearFormStatus();
}
}
handleInputChange(name, value) {
this.setState({ [name]: value });
}
handleFormSubmit(e) {
e.preventDefault();
this.setState({ errors: {} });
let { current, new_password, confirm } = this.state;
if (new_password !== confirm) {
let error = ['Passwords do not match.'];
return this.setState({
error: {
new_password: error,
confirm: error
}
});
}
this.props.changePassword({ current, new_password });
}
render() {
return (
<div className="text-center row col-md-offset-3 col-md-6">
<h1>Change Password</h1>
<br/>
<FormErrors errors={this.state.error.form} />
<form className="form-horizontal" onSubmit={this.handleFormSubmit.bind(this)}>
<InputField
type="password"
label="Current Password"
name="current"
value={this.state.current}
errors={this.state.error.current}
onChange={this.handleInputChange.bind(this)} />
<InputField
type="password"
label="New Password"
name="new_password"
value={this.state.new_password}
errors={this.state.error.new_password}
onChange={this.handleInputChange.bind(this)} />
<InputField
type="password"
label="Confirm New Password"
name="confirm"
value={this.state.confirm}
errors={this.state.error.confirm}
onChange={this.handleInputChange.bind(this)} />
<button className="btn btn-success" type="submit">
Submit
</button>
</form>
</div>
)
}
}
function mapStateToProps(state) {
return {
submitFormSuccess: state.submitFormSuccess,
submitFormError: state.submitFormError
}
}
export default connect(mapStateToProps, {
changePassword
})(withRouter(ChangePassowrdPage)); |
docs/src/pages/premium-themes/paperbase/Content.js | lgollut/material-ui | import React from 'react';
import PropTypes from 'prop-types';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import Tooltip from '@material-ui/core/Tooltip';
import IconButton from '@material-ui/core/IconButton';
import { withStyles } from '@material-ui/core/styles';
import SearchIcon from '@material-ui/icons/Search';
import RefreshIcon from '@material-ui/icons/Refresh';
const styles = (theme) => ({
paper: {
maxWidth: 936,
margin: 'auto',
overflow: 'hidden',
},
searchBar: {
borderBottom: '1px solid rgba(0, 0, 0, 0.12)',
},
searchInput: {
fontSize: theme.typography.fontSize,
},
block: {
display: 'block',
},
addUser: {
marginRight: theme.spacing(1),
},
contentWrapper: {
margin: '40px 16px',
},
});
function Content(props) {
const { classes } = props;
return (
<Paper className={classes.paper}>
<AppBar className={classes.searchBar} position="static" color="default" elevation={0}>
<Toolbar>
<Grid container spacing={2} alignItems="center">
<Grid item>
<SearchIcon className={classes.block} color="inherit" />
</Grid>
<Grid item xs>
<TextField
fullWidth
placeholder="Search by email address, phone number, or user UID"
InputProps={{
disableUnderline: true,
className: classes.searchInput,
}}
/>
</Grid>
<Grid item>
<Button variant="contained" color="primary" className={classes.addUser}>
Add user
</Button>
<Tooltip title="Reload">
<IconButton>
<RefreshIcon className={classes.block} color="inherit" />
</IconButton>
</Tooltip>
</Grid>
</Grid>
</Toolbar>
</AppBar>
<div className={classes.contentWrapper}>
<Typography color="textSecondary" align="center">
No users for this project yet
</Typography>
</div>
</Paper>
);
}
Content.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(Content);
|
src/utils/ValidComponentChildren.js | mengmenglv/react-bootstrap | import React from 'react';
/**
* Maps children that are typically specified as `props.children`,
* but only iterates over children that are "valid components".
*
* The mapFunction provided index will be normalised to the components mapped,
* so an invalid component would not increase the index.
*
* @param {?*} children Children tree container.
* @param {function(*, int)} mapFunction.
* @param {*} mapContext Context for mapFunction.
* @return {object} Object containing the ordered map of results.
*/
function mapValidComponents(children, func, context) {
let index = 0;
return React.Children.map(children, function(child) {
if (React.isValidElement(child)) {
let lastIndex = index;
index++;
return func.call(context, child, lastIndex);
}
return child;
});
}
/**
* Iterates through children that are typically specified as `props.children`,
* but only iterates over children that are "valid components".
*
* The provided forEachFunc(child, index) will be called for each
* leaf child with the index reflecting the position relative to "valid components".
*
* @param {?*} children Children tree container.
* @param {function(*, int)} forEachFunc.
* @param {*} forEachContext Context for forEachContext.
*/
function forEachValidComponents(children, func, context) {
let index = 0;
return React.Children.forEach(children, function(child) {
if (React.isValidElement(child)) {
func.call(context, child, index);
index++;
}
});
}
/**
* Count the number of "valid components" in the Children container.
*
* @param {?*} children Children tree container.
* @returns {number}
*/
function numberOfValidComponents(children) {
let count = 0;
React.Children.forEach(children, function(child) {
if (React.isValidElement(child)) { count++; }
});
return count;
}
/**
* Determine if the Child container has one or more "valid components".
*
* @param {?*} children Children tree container.
* @returns {boolean}
*/
function hasValidComponent(children) {
let hasValid = false;
React.Children.forEach(children, function(child) {
if (!hasValid && React.isValidElement(child)) {
hasValid = true;
}
});
return hasValid;
}
function find(children, finder) {
let child;
forEachValidComponents(children, (c, idx)=> {
if (!child && finder(c, idx, children)) {
child = c;
}
});
return child;
}
export default {
map: mapValidComponents,
forEach: forEachValidComponents,
numberOf: numberOfValidComponents,
find,
hasValidComponent
};
|
actor-apps/app-web/src/app/components/activity/ActivityHeader.react.js | changjiashuai/actor-platform | import React from 'react';
import ReactMixin from 'react-mixin';
import addons from 'react/addons';
const {addons: { PureRenderMixin }} = addons;
@ReactMixin.decorate(PureRenderMixin)
class ActivityHeader extends React.Component {
static propTypes = {
close: React.PropTypes.func,
title: React.PropTypes.string
};
constructor(props) {
super(props);
}
render() {
const title = this.props.title;
const close = this.props.close;
let headerTitle;
if (typeof title !== 'undefined') {
headerTitle = <span className="activity__header__title">{title}</span>;
}
return (
<header className="activity__header toolbar">
<a className="activity__header__close material-icons" onClick={close}>clear</a>
{headerTitle}
</header>
);
}
}
export default ActivityHeader;
|
src/framework/client/root-component.js | foobarhq/reworkjs | // @flow
import React from 'react';
import { CookiesProvider } from 'react-cookie';
import { HelmetProvider } from 'react-helmet-async';
import { BrowserRouter } from 'react-router-dom';
import { getDefault } from '../../shared/util/ModuleUtil';
import ReworkRootComponent from '../app/ReworkRootComponent';
import { rootRoute } from '../common/kernel';
// eslint-disable-next-line import/no-unresolved
import { isHash } from 'val-loader!./_react-router';
import BrowserLanguageProvider from './browser-language-provider';
import ClientHooks from './client-hooks';
const clientHooks = ClientHooks.map(hookModule => {
const HookClass = getDefault(hookModule);
return new HookClass();
});
const RootComponent = () => {
const didCleanUrl = React.useRef(!isHash);
const basename = isHash ? `${location.pathname}#` : '';
if (!didCleanUrl.current && isHash) {
// avoid resetting the url
didCleanUrl.current = true;
// URL format must be "pathname[?search][#fragment]"
// because we use #fragment for routing, we cannot have a search query
// BEFORE the fragment or router will break.
// We instead move it after the #fragment. Technically it's part of the
// fragment but react-router will treat it as the query
// don't use window.location.search, use react-router's useLocation() instead
// OBVIOUSLY don't use fragments at all as it stores the routing state
const url = new URL(location.href);
const oldSearch = url.search;
url.search = '';
if (!url.hash.startsWith('#/')) {
url.hash = `#/${oldSearch}`;
} else {
url.hash += oldSearch;
}
// using history.replace instead of window.location to avoid relaunching the app
history.replaceState('', document.title, url.toString());
}
let rootElement = (
<BrowserLanguageProvider>
<HelmetProvider>
<CookiesProvider>
<ReworkRootComponent>
<BrowserRouter basename={basename}>
{rootRoute}
</BrowserRouter>
</ReworkRootComponent>
</CookiesProvider>
</HelmetProvider>
</BrowserLanguageProvider>
);
// allow plugins to add components
for (const clientHook of clientHooks) {
if (clientHook.wrapRootComponent) {
rootElement = clientHook.wrapRootComponent(rootElement);
}
}
return rootElement;
};
export default RootComponent;
|
webpack/components/Table/components/TranslatedPlural.js | Katello/katello | import React from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
// a defaultMessage like
// "{count, plural, =0 {No errata} one {# erratum} other {# errata}}"
// will give us properly translated pluralized strings!
// see https://formatjs.io/docs/react-intl/components/#message-syntax
export const TranslatedPlural = ({
count, singular,
plural = `${singular}s`,
zeroMsg = `No ${plural}`,
id,
...props
}) => (
<FormattedMessage
defaultMessage={`{count, plural, =0 {${zeroMsg}} one {# ${singular}} other {# ${plural}}}`}
values={{
count,
}}
id={id}
{...props}
/>
);
TranslatedPlural.propTypes = {
count: PropTypes.number.isRequired,
singular: PropTypes.string.isRequired,
plural: PropTypes.string,
zeroMsg: PropTypes.string,
id: PropTypes.string.isRequired,
};
TranslatedPlural.defaultProps = {
plural: undefined,
zeroMsg: undefined,
};
export const TranslatedAnchor = ({
href, style, ariaLabel, ...props
}) => (
<a href={href} style={style} aria-label={ariaLabel}>
<TranslatedPlural
{...props}
/>
</a>
);
TranslatedAnchor.propTypes = {
href: PropTypes.string.isRequired,
style: PropTypes.shape({}),
ariaLabel: PropTypes.string.isRequired,
};
TranslatedAnchor.defaultProps = {
style: undefined,
};
|
admin/client/components/Forms/FormHeading.js | pswoodworth/keystone | import React from 'react';
import evalDependsOn from '../../../../fields/utils/evalDependsOn';
module.exports = React.createClass({
displayName: 'FormHeading',
propTypes: {
options: React.PropTypes.object,
},
render () {
if (!evalDependsOn(this.props.options.dependsOn, this.props.options.values)) {
return null;
}
return <h3 className="form-heading">{this.props.content}</h3>;
},
});
|
packages/mcs-lite-ui/src/MobileDeviceCard/MobileDeviceCard.js | MCS-Lite/mcs-lite | import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import TextTruncate from 'react-text-truncate';
import Card from '../Card';
import Img from '../Img';
import Heading from '../Heading';
export const StyledCard = Card.extend`
height: 120px;
display: flex;
`;
export const ImageWrapper = styled.div`
flex-grow: 2;
`;
export const ContentWrapper = styled.div`
flex-grow: 1;
flex-basis: 0;
padding: 8px;
`;
const MobileDeviceCard = ({ title, image, ...otherProps }) => (
<StyledCard {...otherProps}>
<ImageWrapper>
<Img src={image} />
</ImageWrapper>
<ContentWrapper>
<Heading level={4} color="black">
<TextTruncate line={4} truncateText=" ..." text={title} />
</Heading>
</ContentWrapper>
</StyledCard>
);
MobileDeviceCard.displayName = 'MobileDeviceCard';
MobileDeviceCard.propTypes = {
title: PropTypes.string.isRequired,
image: PropTypes.string.isRequired,
};
export default MobileDeviceCard;
|
pages/Skills.js | amni/alanmni-portfolio | import React from 'react'
import { Link } from 'react-router'
import { prefixLink } from 'gatsby-helpers'
import Helmet from "react-helmet"
import { config } from 'config'
import Profile from 'components/Profile'
import SkillsView from 'components/SkillsView'
export default class Skills extends React.Component {
render () {
return (
<div style= {{textAlign:"center"}}>
<Helmet
title={config.siteTitle}
meta={[
{"name": "description", "content": "Alan Ni."},
{"name": "keywords", "content": "Alan Ni, Portfolio, Personal Site"},
]}
/>
<SkillsView/>
</div>
)
}
}
|
examples/huge-apps/routes/Messages/components/Messages.js | meraki/react-router | import React from 'react'
class Messages extends React.Component {
render() {
return (
<div>
<h2>Messages</h2>
</div>
)
}
}
module.exports = Messages
|
src/svg-icons/editor/pie-chart-outlined.js | rhaedes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorPieChartOutlined = (props) => (
<SvgIcon {...props}>
<path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm1 2.07c3.61.45 6.48 3.33 6.93 6.93H13V4.07zM4 12c0-4.06 3.07-7.44 7-7.93v15.87c-3.93-.5-7-3.88-7-7.94zm9 7.93V13h6.93c-.45 3.61-3.32 6.48-6.93 6.93z"/>
</SvgIcon>
);
EditorPieChartOutlined = pure(EditorPieChartOutlined);
EditorPieChartOutlined.displayName = 'EditorPieChartOutlined';
export default EditorPieChartOutlined;
|
plugins/react/frontend/components/controls/base/FunctionControl/index.js | carteb/carte-blanche | /**
* FunctionControl
*/
import React from 'react';
import Row from '../../../form/Grid/Row';
import LeftColumn from '../../../form/Grid/LeftColumn';
import RightColumn from '../../../form/Grid/RightColumn';
import Label from '../../../form/Label';
import styles from './styles.css';
const FunctionControl = ({ label, secondaryLabel, nestedLevel }) => (
<Row>
<LeftColumn nestedLevel={nestedLevel}>
<Label
type={secondaryLabel}
propKey={label}
/>
</LeftColumn>
<RightColumn>
<div className={styles.info}>
{'function() { console.log(\'Run\') }'}
</div>
</RightColumn>
</Row>
);
FunctionControl.randomValue = () => () => {
console.log('Run') // eslint-disable-line
};
export default FunctionControl;
|
Rate.UI/app/components/AddReviewContainer.js | jcnavarro/rateflicks | import React from 'react';
import SearchFlick from './SearchFlick';
import FlickStore from "../stores/FlickStore";
import Movie from './Movie';
import ReviewActions from "../actions/ReviewActions";
import AddReview from "./AddReview";
export default class AddReviewContainer extends React.Component {
constructor (props) {
super(props);
this.getFlick = this.getFlick.bind(this);
this.state = {
flick : {
title: ''
},
showMovie: false,
reviewText:"",
showReviewForm: false,
}
}
componentWillMount () {
FlickStore.addChangeListener(this.getFlick);
}
componentWillUnmount() {
FlickStore.removeChangeListener(this.getFlick);
}
getFlick(){
let flick = FlickStore.getFlick();
this.setState({
flick : flick,
showMovie: true
});
}
addReview(){
let {flick} = this.state;
let review = {
reviewText : this.state.reviewText,
flick_Id : flick.id,
id : +new Date()
}
ReviewActions.createReview(review);
resetAddReview();
}
resetAddReview(){
this.setState({showMovie: false});
toggleAddReview();
}
handleText(value){
this.setState({reviewText:value});
}
toggleAddReview() {
this.setState({showReviewForm: !this.state.showReviewForm});
}
render() {
let {flick, showReviewForm, showMovie} = this.state;
return (
<AddReview
flick={flick}
showReviewForm = {showReviewForm}
showMovie = {showMovie}
handleText ={this.handleText.bind(this)}
toggleAddReview= {this.toggleAddReview.bind(this)}
addReview={this.addReview.bind(this)}
resetAddReview={this.resetAddReview.bind(this)}/>
)
}
}
|
src/components/common/form/AutoCompleteTextInput.js | goodjoblife/GoodJobShare | import React from 'react';
import PropTypes from 'prop-types';
import Autocomplete from 'react-autocomplete';
import styles from './TextInput/TextInput.module.css';
const renderItem = (item, isHighlighted) => (
<div
key={item.value}
style={{
background: isHighlighted ? 'lightgray' : 'white',
padding: '5px 10px',
}}
>
<p
style={{
color: isHighlighted ? 'black' : '#222',
}}
className={isHighlighted ? 'pSBold' : 'pS'}
>
{item.label}
</p>
</div>
);
class AutoCompleteTextInput extends React.PureComponent {
constructor(props) {
super(props);
this.handleIsOpen = this.handleIsOpen.bind(this);
this.onFocus = this.onFocus.bind(this);
this.onBlur = this.onBlur.bind(this);
this.state = {
isOpen: false,
};
}
onFocus() {
this.handleIsOpen(true);
}
onBlur() {
this.handleIsOpen(false);
}
handleIsOpen(isOpen) {
this.setState({
isOpen,
});
}
render() {
const {
value,
placeholder,
onChange,
isWarning,
warningWording,
type,
getItemValue,
items,
onSelect,
...rest
} = this.props;
const { isOpen } = this.state;
const inputClassName = isWarning ? styles.warning : styles.input;
return (
<div
style={{
position: 'relative',
}}
>
<Autocomplete
inputProps={{
type,
placeholder,
className: inputClassName,
onFocus: this.onFocus,
onBlur: this.onBlur,
}}
value={value}
onChange={onChange}
renderItem={renderItem}
getItemValue={getItemValue}
items={items}
wrapperStyle={{
display: 'block',
}}
menuStyle={{
display: items.length !== 0 ? 'block' : 'none',
position: 'absolute',
zIndex: '99',
top: null,
bottom: 0,
left: 0,
transform: 'translateY(100%)',
border: '1px solid #b4b4b4',
maxHeight: '150px',
overflowY: 'scroll',
padding: '5px 0',
}}
autoHighlight={false}
onSelect={onSelect}
open={isOpen}
{...rest}
/>
{warningWording ? (
<p
className={`
pS ${styles.warning__text} ${isWarning ? styles.isWarning : ''}
`}
>
{warningWording}
</p>
) : null}
</div>
);
}
}
AutoCompleteTextInput.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
placeholder: PropTypes.string,
onChange: PropTypes.func,
isWarning: PropTypes.bool,
warningWording: PropTypes.string,
type: PropTypes.string,
getItemValue: PropTypes.func,
items: PropTypes.array,
onSelect: PropTypes.func,
};
AutoCompleteTextInput.defaultProps = {
type: 'text',
};
export default AutoCompleteTextInput;
|
src/client/pages/notfound.react.js | terakilobyte/socketreact | import Component from '../components/component.react';
import DocumentTitle from 'react-document-title';
import React from 'react';
import {Link} from 'react-router';
import {msg} from '../intl/store';
class NotFound extends Component {
render() {
return (
<DocumentTitle title={msg('notFound.title')}>
<div className="notfound-page">
<h1>{msg('notFound.header')}</h1>
<p>{msg('notFound.message')}</p>
<Link to="home">{msg('notFound.continueMessage')}</Link>
</div>
</DocumentTitle>
);
}
}
export default NotFound;
|
actor-apps/app-web/src/app/components/sidebar/RecentSection.react.js | wangkang0627/actor-platform | import _ from 'lodash';
import React from 'react';
import { Styles, RaisedButton } from 'material-ui';
import ActorTheme from 'constants/ActorTheme';
import DialogActionCreators from 'actions/DialogActionCreators';
import DialogStore from 'stores/DialogStore';
import CreateGroupActionCreators from 'actions/CreateGroupActionCreators';
import RecentSectionItem from './RecentSectionItem.react';
import CreateGroupModal from 'components/modals/CreateGroup.react';
import CreateGroupStore from 'stores/CreateGroupStore';
const ThemeManager = new Styles.ThemeManager();
const LoadDialogsScrollBottom = 100;
const getStateFromStore = () => {
return {
isCreateGroupModalOpen: CreateGroupStore.isModalOpen(),
dialogs: DialogStore.getAll()
};
};
class RecentSection extends React.Component {
static childContextTypes = {
muiTheme: React.PropTypes.object
};
getChildContext() {
return {
muiTheme: ThemeManager.getCurrentTheme()
};
}
constructor(props) {
super(props);
this.state = getStateFromStore();
DialogStore.addChangeListener(this.onChange);
DialogStore.addSelectListener(this.onChange);
CreateGroupStore.addChangeListener(this.onChange);
ThemeManager.setTheme(ActorTheme);
}
componentWillUnmount() {
DialogStore.removeChangeListener(this.onChange);
DialogStore.removeSelectListener(this.onChange);
CreateGroupStore.removeChangeListener(this.onChange);
}
onChange = () => {
this.setState(getStateFromStore());
}
openCreateGroup = () => {
CreateGroupActionCreators.openModal();
}
onScroll = event => {
if (event.target.scrollHeight - event.target.scrollTop - event.target.clientHeight <= LoadDialogsScrollBottom) {
DialogActionCreators.onDialogsEnd();
}
}
render() {
let dialogs = _.map(this.state.dialogs, (dialog, index) => {
return (
<RecentSectionItem dialog={dialog} key={index}/>
);
}, this);
let createGroupModal;
if (this.state.isCreateGroupModalOpen) {
createGroupModal = <CreateGroupModal/>;
}
return (
<section className="sidebar__recent">
<ul className="sidebar__list sidebar__list--recent" onScroll={this.onScroll}>
{dialogs}
</ul>
<footer>
<RaisedButton label="Create group" onClick={this.openCreateGroup} style={{width: '100%'}}/>
{createGroupModal}
</footer>
</section>
);
}
}
export default RecentSection;
|
app/components/QuickControl.js | mkawauchi/react-rpm | import React from 'react';
import styles from './QuickControl.css';
const propTypes = {
children: React.PropTypes.node
};
export default function QuickControl({ children }) {
return (
<div className={styles.quickControl}>
{children}
</div>
);
}
QuickControl.propTypes = propTypes;
|
src/AddButton.js | PSilling/StudentHubUIDevelopment | import React, { Component } from 'react';
import Button from 'react-toolbox/lib/button/Button.js';
/**
* Renders the add Button.
* @param selectedUniversity the university that is selected
* @param toggleUniversityHandler() defines the function to call onClick when universities are browsed
* @param toggleFacultyHandler() defines the function to call onClick when faculties are browsed
*/
class AddButton extends Component {
generateButton = () => {
var button;
if(this.props.selectedUniversity === -1) {
button = <Button onClick={() => this.props.toggleUniversityHandler()} icon="add" label="Add New University" raised primary floating />;
}
else button = <Button onClick={() => this.props.toggleFacultyHandler()} icon="add" label="Add New Faculty" raised primary floating />;
return button;
}
render() {
return(
<span>
{this.generateButton()}
</span>
);
}
}
export default AddButton;
|
src/collections/Form/FormTextArea.js | koenvg/Semantic-UI-React | import React from 'react'
import {
customPropTypes,
getElementType,
getUnhandledProps,
META,
} from '../../lib'
import TextArea from '../../addons/TextArea'
import FormField from './FormField'
/**
* Sugar for <Form.Field control={TextArea} />.
* @see Form
* @see TextArea
*/
function FormTextArea(props) {
const { control } = props
const rest = getUnhandledProps(FormTextArea, props)
const ElementType = getElementType(FormTextArea, props)
return <ElementType {...rest} control={control} />
}
FormTextArea._meta = {
name: 'FormTextArea',
parent: 'Form',
type: META.TYPES.COLLECTION,
}
FormTextArea.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,
/** A FormField control prop. */
control: FormField.propTypes.control,
}
FormTextArea.defaultProps = {
as: FormField,
control: TextArea,
}
export default FormTextArea
|
MobileApp/node_modules/react-native/local-cli/templates/HelloWorld/index.ios.js | VowelWeb/CoinTradePros.com | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
export default class HelloWorld extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('HelloWorld', () => HelloWorld);
|
docs/app/Examples/modules/Dropdown/Content/DropdownExampleImage.js | koenvg/Semantic-UI-React | import React from 'react'
import { Dropdown } from 'semantic-ui-react'
import { friendOptions } from '../common'
const DropdownExampleImage = () => (
<Dropdown text='Add user' icon='add user' floating labeled button className='icon'>
<Dropdown.Menu>
<Dropdown.Header content='People You Might Know' />
{friendOptions.map((option) => <Dropdown.Item key={option.value} {...option} />)}
</Dropdown.Menu>
</Dropdown>
)
export default DropdownExampleImage
|
src/components/page/StartPage.js | mrbjoern/SpringFitnessMobile | import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
AsyncStorage,
ActivityIndicator,
} from 'react-native';
import {
COLOR,
PRIMARY_COLORS
} from 'react-native-material-design';
import { connect } from 'react-redux';
import {
saveCredentials,
} from '../../actions';
import {
showLoginPage,
showHomePage,
} from '../../actions/routingActions';
import {
requestTokenFromApi,
} from '../../actions/tokenActions';
import Global from '../../globals/global';
let credentials = {
'username': 'admin',
'password': 'test',
}
class StartPage extends Component {
shouldComponentUpdate(props, state) {
if (props.state.token.token) {
this.props.showHomePage();
} else if (props.errors) {
return true;
} else if (props.state.token.error) {
this.props.showLoginPage();
}
return true;
}
render() {
const state = this.props.state;
let message = '';
let loading = true;
if (state.messages) {
if (state.messages.error) {
message = this.props.state.messages.error;
loading = false;
} else if (state.messages.message) {
message = this.props.state.messages.message;
}
}
return (
<View style={{backgroundColor: COLOR['paperBlue400'].color, flex: 1, justifyContent: 'center'}}>
<Text style={{
textAlign: 'center',
color: '#fff',
fontSize: 30,
}}>
Spring Fitness</Text>
<ActivityIndicator
animating={loading}
size='large'
color='#fff'
style={{paddingTop: 20}}
/>
<Text style={{
padding: 40,
textAlign: 'center',
color: '#fff'
}}>{message}</Text>
</View>
);
}
componentDidMount() {
let credString = JSON.stringify(credentials);
AsyncStorage.setItem('credentials', credString)
.then((value) => {
this.props.saveCredentials(credentials.username, credentials.password);
this.props.requestTokenFromApi();
})
.catch((error) => {
console.warn(error);
})
}
}
const ConnectedApp = connect(
state => ({
routing: state.routing,
isLoading: true,
isStoredCredentials: false,
state: state,
}),
(dispatch) => ({
showLoginPage: () => dispatch(showLoginPage()),
showHomePage: () => dispatch(showHomePage()),
saveCredentials: () => dispatch(saveCredentials()),
requestTokenFromApi: () => dispatch(requestTokenFromApi(credentials)),
}),
)(StartPage);
export default ConnectedApp;
|
src/App.js | cedjud/nst-prototype | import React, { Component } from 'react';
import {
BrowserRouter as Router,
Link,
Route
} from 'react-router-dom';
import { Button } from 'semantic-ui-react';
import fire from './fire.js';
import Login from './components/Login';
import Register from './components/Register';
import Dashboard from './components/Dashboard';
import './App.css';
const LocalAuth = {
isAuthenticated: false,
user: {}
}
/* const Dashboard = (props) => {
return (
<div>
<h1>Welcome to the App!</h1>
<p>your username is {props.user.email}</p>
<p>your uid is {props.user.uid}</p>
<Button content="Sign out" onClick={() => fire.auth().signOut()} />
</div>
)
}; */
class App extends Component {
constructor(props){
super(props);
this.state = {
userIsLoggedIn: false,
user: {}
}
this.userStatus = fire.auth().onAuthStateChanged((user) => {
if (user) {
this.setState({
userIsLoggedIn: true,
user: user,
})
} else {
this.setState({
userIsLoggedIn: false,
user: {},
})
console.log('logged out');
}
});
}
render() {
return (
<Router>
<div>
<Route exact path="/" component={
this.state.userIsLoggedIn ?
() => <Dashboard user={this.state.user}/>
: Login
} />
<Route path="/register" component={Register} />
</div>
</Router>
);
}
}
export default App;
|
app/javascript/mastodon/features/ui/components/audio_modal.js | kazh98/social.arnip.org | import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import Audio from 'mastodon/features/audio';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { FormattedMessage } from 'react-intl';
import { previewState } from './video_modal';
import classNames from 'classnames';
import Icon from 'mastodon/components/icon';
export default class AudioModal extends ImmutablePureComponent {
static propTypes = {
media: ImmutablePropTypes.map.isRequired,
status: ImmutablePropTypes.map,
onClose: PropTypes.func.isRequired,
};
static contextTypes = {
router: PropTypes.object,
};
componentDidMount () {
if (this.context.router) {
const history = this.context.router.history;
history.push(history.location.pathname, previewState);
this.unlistenHistory = history.listen(() => {
this.props.onClose();
});
}
}
componentWillUnmount () {
if (this.context.router) {
this.unlistenHistory();
if (this.context.router.history.location.state === previewState) {
this.context.router.history.goBack();
}
}
}
handleStatusClick = e => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`);
}
}
render () {
const { media, status } = this.props;
return (
<div className='modal-root__modal audio-modal'>
<div className='audio-modal__container'>
<Audio
src={media.get('url')}
alt={media.get('description')}
duration={media.getIn(['meta', 'original', 'duration'], 0)}
height={135}
preload
/>
</div>
{status && (
<div className={classNames('media-modal__meta')}>
<a href={status.get('url')} onClick={this.handleStatusClick}><Icon id='comments' /> <FormattedMessage id='lightbox.view_context' defaultMessage='View context' /></a>
</div>
)}
</div>
);
}
}
|
node_modules/react-scripts/template/src/index.js | dippnerd/home-control-panel | import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
|
app/javascript/mastodon/features/ui/components/image_loader.js | unarist/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { LoadingBar } from 'react-redux-loading-bar';
import ZoomableImage from './zoomable_image';
export default class ImageLoader extends React.PureComponent {
static propTypes = {
alt: PropTypes.string,
src: PropTypes.string.isRequired,
previewSrc: PropTypes.string,
width: PropTypes.number,
height: PropTypes.number,
onClick: PropTypes.func,
}
static defaultProps = {
alt: '',
width: null,
height: null,
};
state = {
loading: true,
error: false,
width: null,
}
removers = [];
canvas = null;
get canvasContext() {
if (!this.canvas) {
return null;
}
this._canvasContext = this._canvasContext || this.canvas.getContext('2d');
return this._canvasContext;
}
componentDidMount () {
this.loadImage(this.props);
}
componentWillReceiveProps (nextProps) {
if (this.props.src !== nextProps.src) {
this.loadImage(nextProps);
}
}
componentWillUnmount () {
this.removeEventListeners();
}
loadImage (props) {
this.removeEventListeners();
this.setState({ loading: true, error: false });
Promise.all([
props.previewSrc && this.loadPreviewCanvas(props),
this.hasSize() && this.loadOriginalImage(props),
].filter(Boolean))
.then(() => {
this.setState({ loading: false, error: false });
this.clearPreviewCanvas();
})
.catch(() => this.setState({ loading: false, error: true }));
}
loadPreviewCanvas = ({ previewSrc, width, height }) => new Promise((resolve, reject) => {
const image = new Image();
const removeEventListeners = () => {
image.removeEventListener('error', handleError);
image.removeEventListener('load', handleLoad);
};
const handleError = () => {
removeEventListeners();
reject();
};
const handleLoad = () => {
removeEventListeners();
this.canvasContext.drawImage(image, 0, 0, width, height);
resolve();
};
image.addEventListener('error', handleError);
image.addEventListener('load', handleLoad);
image.src = previewSrc;
this.removers.push(removeEventListeners);
})
clearPreviewCanvas () {
const { width, height } = this.canvas;
this.canvasContext.clearRect(0, 0, width, height);
}
loadOriginalImage = ({ src }) => new Promise((resolve, reject) => {
const image = new Image();
const removeEventListeners = () => {
image.removeEventListener('error', handleError);
image.removeEventListener('load', handleLoad);
};
const handleError = () => {
removeEventListeners();
reject();
};
const handleLoad = () => {
removeEventListeners();
resolve();
};
image.addEventListener('error', handleError);
image.addEventListener('load', handleLoad);
image.src = src;
this.removers.push(removeEventListeners);
});
removeEventListeners () {
this.removers.forEach(listeners => listeners());
this.removers = [];
}
hasSize () {
const { width, height } = this.props;
return typeof width === 'number' && typeof height === 'number';
}
setCanvasRef = c => {
this.canvas = c;
if (c) this.setState({ width: c.offsetWidth });
}
render () {
const { alt, src, width, height, onClick } = this.props;
const { loading } = this.state;
const className = classNames('image-loader', {
'image-loader--loading': loading,
'image-loader--amorphous': !this.hasSize(),
});
return (
<div className={className}>
<LoadingBar loading={loading ? 1 : 0} className='loading-bar' style={{ width: this.state.width || width }} />
{loading ? (
<canvas
className='image-loader__preview-canvas'
ref={this.setCanvasRef}
width={width}
height={height}
/>
) : (
<ZoomableImage
alt={alt}
src={src}
onClick={onClick}
/>
)}
</div>
);
}
}
|
src/organisms/cards/StackedCard/index.js | policygenius/athenaeum | import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import styles from './stacked_card.module.scss';
const stackChild = (child) => {
if (child) {
return <li className={styles['stacked-li']}>{ child }</li>;
}
return null;
};
const stackChildren = (children) => React.Children.map(children, stackChild);
function StackedCard(props) {
const {
children,
className,
inverted
} = props;
const classes = [
styles['stacked'],
inverted && styles['inverted'],
className,
];
return (
<ul className={classnames(...classes)}>
{ stackChildren(children) }
</ul>
);
}
StackedCard.propTypes = {
/**
* This prop will add a new className to any inherent classNames
* provided in the component's index.js file.
*/
className: PropTypes.string,
/**
* Inverted color scheme.
*/
inverted: PropTypes.bool
};
StackedCard.defaultProps = {
inverted: false
};
export default StackedCard;
|
src/client/lib/validation.js | obimod/este | /*
Simple serial sync/async chriso/validator.js validation wrapper with promises.
*/
import Promise from 'bluebird';
import React from 'react';
import validator from 'validator';
export class ValidationError extends Error {
constructor(message, prop) {
super();
this.message = message;
this.prop = prop;
}
}
export function focusInvalidField(component) {
return (error) => {
if (error instanceof ValidationError) {
if (!error.prop) return;
const node = React.findDOMNode(component);
if (!node) return;
const el = node.querySelector(`[name=${error.prop}]`);
if (!el) return;
el.focus();
return;
}
throw error;
};
}
export default class Validation {
constructor(object) {
this._object = object;
this._prop = null;
this._validator = validator;
this.promise = Promise.resolve();
}
custom(callback, {required} = {}) {
const prop = this._prop;
const value = this._object[prop];
const object = this._object;
this.promise = this.promise.then(() => {
if (required && !this._isEmptyString(value)) return;
callback(value, prop, object);
});
return this;
}
_isEmptyString(value) {
return !this._validator.toString(value).trim();
}
prop(prop) {
this._prop = prop;
return this;
}
required(getRequiredMessage) {
return this.custom((value, prop) => {
const msg = getRequiredMessage
? getRequiredMessage(prop, value)
: this.getRequiredMessage(prop, value);
throw new ValidationError(msg, prop);
}, {required: true});
}
getRequiredMessage(prop, value) {
return `Please fill out '${prop}' field.`;
}
email() {
return this.custom((value, prop) => {
if (this._validator.isEmail(value)) return;
throw new ValidationError(
this.getEmailMessage(prop, value),
prop
);
});
}
getEmailMessage() {
return `Email address is not valid.`;
}
simplePassword() {
return this.custom((value, prop) => {
const minLength = 5;
if (value.length >= minLength) return;
throw new ValidationError(
this.getSimplePasswordMessage(minLength),
prop
);
});
}
getSimplePasswordMessage(minLength) {
return `Password must contain at least ${minLength} characters.`;
}
}
|
src/components/UI/loader/Loader.js | radekzz/netlify-cms-test | import React from 'react';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import styles from './Loader.css';
export default class Loader extends React.Component {
state = {
currentItem: 0,
};
componentWillUnmount() {
if (this.interval) {
clearInterval(this.interval);
}
}
setAnimation = () => {
if (this.interval) return;
const { children } = this.props;
this.interval = setInterval(() => {
const nextItem = (this.state.currentItem === children.length - 1) ? 0 : this.state.currentItem + 1;
this.setState({ currentItem: nextItem });
}, 5000);
};
renderChild = () => {
const { children } = this.props;
const { currentItem } = this.state;
if (!children) {
return null;
} else if (typeof children == 'string') {
return <div className={styles.text}>{children}</div>;
} else if (Array.isArray(children)) {
this.setAnimation();
return (<div className={styles.text}>
<ReactCSSTransitionGroup
transitionName={styles}
transitionEnterTimeout={500}
transitionLeaveTimeout={500}
>
<div key={currentItem} className={styles.animateItem}>{children[currentItem]}</div>
</ReactCSSTransitionGroup>
</div>);
}
};
render() {
const { active, style, className = '' } = this.props;
// Class names
let classNames = styles.loader;
if (active) {
classNames += ` ${ styles.active }`;
}
if (className.length > 0) {
classNames += ` ${ className }`;
}
return <div className={classNames} style={style}>{this.renderChild()}</div>;
}
}
|
src/components/Header.js | ajaycheenath/abs | import React, { Component } from 'react';
import Menu from "./Menu";
import headerStyle from "../css/app.css";
class Header extends Component {
render() {
return (
<div className={headerStyle.header}>
<div className={headerStyle.productName}>product name</div>
<Menu search={this.props.search}/>
</div>
);
}
}
export default Header;
|
src/components/Background/Background.js | Zoomdata/nhtsa-dashboard-2.2 | import styles from './Background.css';
import React from 'react';
const Background = ({data}) => {
return (
<div
className={styles.root}
>
{data}
</div>
)
};
export default Background; |
dist/lib/carbon-fields/assets/js/fields/components/oembed/search-input.js | ArtFever911/statrer-kit | /**
* The external dependencies.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { compose, withHandlers, defaultProps } from 'recompose';
import { debounce } from 'lodash';
/**
* The internal dependencies.
*/
import { KEY_ENTER } from 'lib/constants';
/**
* Render the field used to filter the available options
* inside the oembed field.
*
* @param {Object} props
* @param {String} [props.name]
* @param {String} props.term
* @param {Function} props.handleKeyDown
* @param {Function} props.handleChange
* @return {React.Element}
*/
export const SearchInput = ({
name,
term,
handleKeyDown,
handleChange,
}) => {
return <div className="search-field carbon-association-search dashicons-before dashicons-search">
<input
type="text"
defaultValue={term}
name={name}
className="search-field"
placeholder={carbonFieldsL10n.field.searchPlaceholder}
onKeyDown={handleKeyDown}
onChange={handleChange} />
</div>;
};
/**
* Validate the props.
*
* @type {Object}
*/
SearchInput.propTypes = {
name: PropTypes.string,
term: PropTypes.string,
handleSubmit: PropTypes.func,
};
/**
* The enhancer.
*
* @type {Function}
*/
export const enhance = compose(
/**
* Setup the default props.
*/
defaultProps({
onSubmit: () => {}
}),
/**
* Pass some handlers to the component.
*/
withHandlers({
debouncedOnChange: ({ onSubmit }) => debounce(v => onSubmit(v), 200),
handleSubmit: ({ onSubmit }) => e => {
onSubmit(e.target.value);
},
}),
/**
* Pass some handlers to the component.
*/
withHandlers({
handleChange: ({ debouncedOnChange }) => ({ target: { value }}) => debouncedOnChange(value),
handleKeyDown: ({ handleSubmit }) => e => {
if (e.keyCode === KEY_ENTER) {
e.preventDefault();
handleSubmit(e);
}
},
})
);
export default enhance(SearchInput);
|
src/components/book.js | mailofjordi/librarySJ | import React, { Component } from 'react';
import {showBookDetails} from "../actions/index";
import {connect} from "react-redux";
class Book extends Component {
render() {
return (
<div>
<div>Título: {this.props.book.title}</div>
<div>Autor: {this.props.book.author}</div>
<input type="button" onClick={() => this.props.showBookDetails(this.props.bookIndex)} value="Editar"/>
</div>
);
}
}
export default connect(null, {showBookDetails})(Book);
|
src/OverlayRenderer.js | aksonov/react-native-router-flux | /* @flow */
import React from 'react';
import { View } from 'react-native';
export default ({ navigationConfig, descriptors }) => {
const { initialRouteName, order, contentComponent } = navigationConfig;
const ContentComponent = contentComponent || View;
const descriptor = descriptors[initialRouteName];
const Component = descriptor.getComponent();
const overlays = [];
for (let i = 0; i < order.length; i += 1) {
const routeName = order[i];
if (initialRouteName !== routeName) {
const Overlay = descriptors[routeName].getComponent();
overlays.push(<Overlay key={routeName} navigation={descriptors[routeName].navigation} />);
}
}
return (
<ContentComponent style={{ flex: 1 }}>
<Component navigation={descriptor.navigation} />
{overlays}
</ContentComponent>
);
};
|
app/addons/permissions/routes.js | apache/couchdb-fauxton | // 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 app from '../../app';
import FauxtonAPI from '../../core/api';
import Databases from '../databases/base';
import BaseRoute from '../documents/shared-routes';
import Layout from './layout';
const PermissionsRouteObject = BaseRoute.extend({
roles: ['fx_loggedIn'],
routes: {
'database/:database/_partition/:partitionKey/permissions': {
route: 'permissions',
roles: ['fx_loggedIn']
},
'database/:database/permissions': {
route: 'permissions',
roles: ['fx_loggedIn']
}
},
initialize: function () {
const docOptions = app.getParams();
docOptions.include_docs = true;
},
permissions: function (databaseId, partitionKey) {
// XXX magic inheritance props we need to maintain for BaseRoute
this.database = new Databases.Model({ id: databaseId });
// XXX magic methods we have to call - originating from BaseRoute.extend
this.createDesignDocsCollection();
this.addSidebar('permissions');
const crumbs = [
{ name: this.database.id, link: Databases.databaseUrl(databaseId)},
{ name: 'Permissions' }
];
const encodedDatabaseId = encodeURIComponent(databaseId);
const url = FauxtonAPI.urls('permissions', 'server', encodedDatabaseId);
return <Layout
docURL={FauxtonAPI.constants.DOC_URLS.DB_PERMISSION}
endpoint={url}
dbName={this.database.id}
dropDownLinks={crumbs}
database={this.database}
partitionKey={partitionKey} />;
}
});
const Permissions = {
RouteObjects: [PermissionsRouteObject]
};
export default Permissions;
|
src/Tab/index.js | szchenghuang/react-mdui | 'use strict';
import _ from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import ClassNames from 'classnames';
import mdui from '../index';
import Item from './Item';
class Tab extends React.Component {
componentDidMount() {
const { trigger, loop } = this.props;
const options = { trigger, loop: !!loop };
new mdui.Tab( this.root, options );
}
render() {
const {
className,
children,
trigger,
loop,
scrollable,
centered,
fullWidth,
...restProps
} = this.props;
const clx = ClassNames({
...( className && { [ className ]: true } ),
'mdui-tab': true,
'mdui-tab-scrollable': scrollable,
'mdui-tab-centered': centered,
'mdui-full-width': fullWidth
});
const props = {
...restProps,
className: clx,
ref: node => this.root = node
};
const ids = _.map( children, child => child.props.id );
return (
<div>
<div { ...props }>
{ _.map( children, ( child, index ) => {
const {
children,
className,
id,
ripple,
icon,
label,
active,
...restProps
} = child.props;
const clx = ClassNames({
...( className && { [ className ]: true } ),
'mdui-ripple': ripple,
'mdui-tab-active': active
});
return (
<a
key={ index }
href={ '#' + id }
className={ clx }
{ ...restProps }
>
{ icon }
{ icon ? <label>{ label }</label> : label }
</a>
);
})}
</div>
{ _.map( children, ( child, index ) => (
<div key={ index } id={ ids[ index ] }>
{ child.props.children }
</div>
))}
</div>
);
}
}
Tab.propTypes = {
style: PropTypes.object,
className: PropTypes.string,
children: PropTypes.node,
trigger: PropTypes.string,
loop: PropTypes.any,
scrollable: PropTypes.any,
centered: PropTypes.any,
fullWidth: PropTypes.any
};
Tab.defaultProps = {
trigger: 'click'
};
export default Tab;
export { Item };
|
src/ButtonToolbar.js | Cellule/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;
|
docs/app/Examples/elements/Button/Types/index.js | Rohanhacker/Semantic-UI-React | import React from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
const ButtonTypesExamples = () => (
<ExampleSection title='Types'>
<ComponentExample
title='Button'
description='A standard button.'
examplePath='elements/Button/Types/ButtonExampleButton'
/>
<ComponentExample
description='Button content can also be defined with props.'
examplePath='elements/Button/Types/ButtonExampleContentProp'
/>
<ComponentExample
title='Emphasis'
description='A button can be formatted to show different levels of emphasis.'
examplePath='elements/Button/Types/ButtonExampleEmphasis'
/>
<ComponentExample
title='Animated'
description='Buttons can animate to show additional or hidden content.'
examplePath='elements/Button/Types/ButtonExampleAnimated'
/>
<ComponentExample
title='Labeled'
description='A button can be accompanied by a label.'
examplePath='elements/Button/Types/ButtonExampleLabeled'
/>
<ComponentExample
examplePath='elements/Button/Types/ButtonExampleLabeledBasic'
/>
<ComponentExample
description='You can also configure the markup with props.'
examplePath='elements/Button/Types/ButtonExampleLabeledProps'
/>
<ComponentExample
title='Icon'
description='A button can be made of only an icon.'
examplePath='elements/Button/Types/ButtonExampleIcon'
/>
<ComponentExample
description='You can also define an icon button with props.'
examplePath='elements/Button/Types/ButtonExampleIconProp'
/>
<ComponentExample
title='Labeled Icon'
description='A button can use an icon as a label.'
examplePath='elements/Button/Types/ButtonExampleLabeledIcon'
/>
<ComponentExample
title='Basic'
description='The basic button has a subtle appearance.'
examplePath='elements/Button/Types/ButtonExampleBasic'
/>
<ComponentExample
title='Inverted'
description='A button can be formatted to appear on a dark background.'
examplePath='elements/Button/Types/ButtonExampleInverted'
/>
</ExampleSection>
)
export default ButtonTypesExamples
|
app/config/routes.js | DiegoCardoso/github-battle | import React from 'react'
import {Router, Route, IndexRoute, hashHistory} from 'react-router'
import Main from '../components/Main'
import Home from '../components/Home'
import PromptContainer from '../containers/PromptContainer'
import ConfirmBattleContainer from '../containers/ConfirmBattleContainer'
import ResultsContainer from '../containers/ResultsContainer'
export default (
<Router history={hashHistory}>
<Route path='/' component={Main}>
<IndexRoute component={Home} />
<Route path='playerOne' header='Player One' component={PromptContainer} />
<Route path='playerTwo/:playerOne' header='Player Two' component={PromptContainer} />
<Route path='battle' component={ConfirmBattleContainer}/>
<Route path='results' component={ResultsContainer}/>
</Route>
</Router>
); |
examples/client.js | MrCheater/text-resize-and-word-wrap-provider | import React from 'react';
import ReactDOM from 'react-dom';
import { DemoAlignScaleColorDebug } from './DemoAlignScaleColorDebug';
import DemoAlignScaleColorDebugCode from '!raw-loader!./DemoAlignScaleColorDebug';
import { DemoChartBar } from './DemoChartBar';
import DemoChartBarCode from '!raw-loader!./DemoChartBar';
import { DemoTwoChartBarOneContext } from './DemoTwoChartBarOneContext';
import DemoTwoChartBarOneContextCode from '!raw-loader!./DemoTwoChartBarOneContext';
import { DemoColors } from './DemoColors';
import DemoColorsCode from '!raw-loader!./DemoColors';
import { DemoScale } from './DemoScale';
import DemoScaleCode from '!raw-loader!./DemoScale';
import { DemoTreeMap } from './DemoTreeMap';
import DemoTreeMapCode from '!raw-loader!./DemoTreeMap';
import { DemoRichText } from './DemoRichText';
import DemoRichTextCode from '!raw-loader!./DemoRichText';
import { DemoBubbles } from './DemoBubbles';
import DemoBubblesCode from '!raw-loader!./DemoBubbles';
import { DemoSupportTagA } from './DemoSupportTagA';
import DemoSupportTagACode from '!raw-loader!./DemoSupportTagA';
import { DemoMouseEvents } from './DemoMouseEvents';
import DemoMouseEventsCode from '!raw-loader!./DemoMouseEvents';
import { DemoRotation } from './DemoRotation';
import DemoRotationCode from '!raw-loader!./DemoRotation';
import { DemoMouseCursor } from './DemoMouseCursor';
import DemoMouseCursorCode from '!raw-loader!./DemoMouseCursor';
import { DemoStroke } from './DemoStroke';
import DemoStrokeCode from '!raw-loader!./DemoStroke';
import { Demo } from './Demo';
ReactDOM.render((
<div>
<Demo
title = 'Demo Bar Chart'
result = {DemoChartBar}
code = {DemoChartBarCode}
/>
<Demo
title = 'Demo Two Bar Chart - One Context'
result = {DemoTwoChartBarOneContext}
code = {DemoTwoChartBarOneContextCode}
/>
<Demo
title = 'Demo Bubbles'
result = {DemoBubbles}
code = {DemoBubblesCode}
/>
<Demo
title = 'Demo Tree Map'
result = {DemoTreeMap}
code = {DemoTreeMapCode}
/>
<Demo
title = 'Demo Align, Scale, Colors, Debug Mode, Multi Text'
result = {DemoAlignScaleColorDebug}
code = {DemoAlignScaleColorDebugCode}
/>
<Demo
title = 'Demo Scale'
result = {DemoScale}
code = {DemoScaleCode}
/>
<Demo
title = 'Demo Colors'
result = {DemoColors}
code = {DemoColorsCode}
/>
<Demo
title = 'Demo Rich Text'
result = {DemoRichText}
code = {DemoRichTextCode}
/>
<Demo
title = 'Demo Support Tag "A"'
result = {DemoSupportTagA}
code = {DemoSupportTagACode}
/>
<Demo
title = 'Demo onClick/onMouseOut/onMouseOver'
result = {DemoMouseEvents}
code = {DemoMouseEventsCode}
/>
<Demo
title = 'Demo Rotation'
result = {DemoRotation}
code = {DemoRotationCode}
/>
<Demo
title = 'Demo Mouse Cursor'
result = {DemoMouseCursor}
code = {DemoMouseCursorCode}
/>
<Demo
title = 'Demo Stroke'
result = {DemoStroke}
code = {DemoStrokeCode}
/>
<h1>Demo Max Number Of Rows</h1>
</div>
), document.getElementById('app'));
|
src/index.js | ctrlplusb/react-redux | import React from 'react';
import createAll from './components/createAll';
export const { Provider, connect } = createAll(React);
|
app/containers/SearchBar.js | arixse/ReactNeteaseCloudMusic | import React, { Component } from 'react';
import { connect } from 'react-redux';
import AutoComplete from 'material-ui/AutoComplete';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
// import Play from './Play';
import List from '../components/List';
import { show, load, search } from '../actions';
import axios from 'axios';
const API = 'https://api.imjad.cn/cloudmusic/';
const inputStyle = {
color: '#fff'
};
class SearchBar extends Component {
constructor(props) {
super(props);
this.state = {
dataSource: [],
};
this.onNewRequest = this.onNewRequest.bind(this);
this.onPlay = this.onPlay.bind(this);
}
onPlay(song) {
const { dispatch } = this.props;
dispatch(show(song));
dispatch(load(song.id));
}
handleUpdateInput = (value) => {
axios.get(API, {
params: {
type: 'search',
s: value
}
})
.then((res) => {
if (res.data && res.data.result && res.data.result.songs) {
const list = res.data.result.songs.map(song => song.name);
this.setState({
dataSource: list
});
}
});
}
onNewRequest(value) {
const { dispatch } = this.props;
dispatch(search(value));
}
render() {
const { history, searchList } = this.props;
return (
<div>
<div className="detail-header">
<span className="iconfont prev" onTouchTap={() => { history.goBack(); }}></span>
<MuiThemeProvider>
<AutoComplete
hintText="请输入歌曲名字"
dataSource={this.state.dataSource}
onUpdateInput={this.handleUpdateInput}
style={inputStyle}
onNewRequest={this.onNewRequest}
/>
</MuiThemeProvider>
</div>
<List items={searchList} onPlay={this.onPlay} />
</div>
);
}
}
SearchBar.propTypes = {
history: React.PropTypes.object,
dispatch: React.PropTypes.func,
searchList: React.PropTypes.array
};
const mapStateToProps = (state) => {
return {
searchList: state.searchList
};
};
export default connect(mapStateToProps)(SearchBar);
|
ReactApp/src/Pages/Artisans.js | hoh/FolkMarsinne | import React, { Component } from 'react';
import {Card, CardActions, CardHeader, CardMedia, CardTitle, CardText} from 'material-ui/Card';
import {List, ListItem} from 'material-ui/List';
import Paper from 'material-ui/Paper';
import RaisedButton from 'material-ui/RaisedButton';
import {red500, brown500} from 'material-ui/styles/colors';
import EmailIcon from 'material-ui/svg-icons/communication/email';
import EmailOutlineIcon from 'material-ui/svg-icons/communication/mail-outline';
import CustomTitle from '../Cards/CustomTitle';
class LinkedImage extends React.Component {
render() {
return (
<a href={this.props.src} target="_blank">
<img src={this.props.src}
height={this.props.height}
style={this.props.style}
/>
</a>
);
}
}
const i18n_strings = {
fr: {
intro: {
title: 'Artisans',
text: 'Le festival héberge plusieurs artisans et autres associations : luthiers, vêtements, chaussures, bijoux, Mains-Unies asbl',
},
mainsunies: {
title: 'Mains Unies - Mettez du Folk dans vos vacances !',
text: (
<div>
<p>
Chaque été, <b>MAINS UNIES</b> propose des <b>séjours participatifs</b> dans des <b>sites naturels</b>.
Accompagnés par des bénévoles, 50 à 80 participants organisent les activités.
</p>
<p>
<b>Et tous les soirs, bal folk !</b> Petits et grands découvrent ou pratiquent la danse avec des musiciens et animateurs chevronnés !
</p>
<p>
Sous tente ou en gîte, une formule qui séduira les amateurs d'authenticité et de rencontres !
</p>
</div>
),
},
},
en: {
intro: {
title: 'Artisans',
text: 'The festival is host to several artisans and other associations: instrument makers, clothes, shoes, jewels, Mains-Unies npo',
},
mainsunies: {
title: 'Mains Unies - Put Folk in your holidays !',
text: (
<div>
<p>
Every summer, <b>MAINS UNIES</b> organises <b>participative stays</b> in <b>natural sites</b>.
Accompanied by volunteers, 50 to 80 participants organize the activities.
</p>
<p>
<b>And every evening offers its folk ball !</b> Children and adults discover or practice dancing accompagnied by experienced musicians animators !
</p>
<p>
Whether lodging in a tent or a holiday home, this experience will seduce those seeking authenticity and genuine encounters !
</p>
</div>
),
},
},
nl: {
intro: {
title: 'Kunstenaars',
text: 'Het festival is gastheer voor kunstenaars en diverse verenigingen : instrument makers, kleren, schoenen, juwelen, Mains-Unies vzw',
},
mainsunies: {
title: 'Mains Unies - Zet in op Folk voor je vakantie !',
text: (
<div>
<p>
Elke zomer biedt <b>MAINS UNIES participatieve uitstapjes </b> aan in een mooi natuurkader.
Begeleid door vrijwilligers kunnen 50 tot 80 deelnemers verschillende activiteiten organizeren.
</p>
<p>
<b>En iedere avond volksbal !</b> Klein en groot kan dan deelnemen met het dansen onder leiding van ervaren muzikanten en animators.
</p>
<p>
Onder tent of in vakantiehuis, een formule die de liefhebbers van authenticiteit en vergaderingen !
</p>
</div>
),
},
},
}
export default class ArtisansPage extends React.Component {
render() {
var strings = i18n_strings[this.props.lang] || i18n_strings['fr'];
return (
<div>
<CustomTitle title={strings.intro.title}
desc={strings.intro.text} />
<Card>
<CardTitle title={strings.mainsunies.title}
subtitle="" />
<CardText>
<img src="/static/artisans/mains-unies.jpg" width="250px"
style={{float: 'right'}} />
{strings.mainsunies.text}
</CardText>
<RaisedButton label="mainsunies.be" secondary={true}
style={{margin: 12}} href="http://www.mainsunies.be/"
linkButton={true} />
<RaisedButton label="02 / 344 46 53" primary={true}
style={{margin: 12}} href="tel:+3223444653"
linkButton={true} />
</Card>
<p/>
</div>
);
}
}
|
node_modules/react-bootstrap/es/Image.js | yeshdev1/Everydays-project | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { bsClass, prefix, splitBsProps } from './utils/bootstrapUtils';
var propTypes = {
/**
* Sets image as responsive image
*/
responsive: PropTypes.bool,
/**
* Sets image shape as rounded
*/
rounded: PropTypes.bool,
/**
* Sets image shape as circle
*/
circle: PropTypes.bool,
/**
* Sets image shape as thumbnail
*/
thumbnail: PropTypes.bool
};
var defaultProps = {
responsive: false,
rounded: false,
circle: false,
thumbnail: false
};
var Image = function (_React$Component) {
_inherits(Image, _React$Component);
function Image() {
_classCallCheck(this, Image);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Image.prototype.render = function render() {
var _classes;
var _props = this.props,
responsive = _props.responsive,
rounded = _props.rounded,
circle = _props.circle,
thumbnail = _props.thumbnail,
className = _props.className,
props = _objectWithoutProperties(_props, ['responsive', 'rounded', 'circle', 'thumbnail', 'className']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = (_classes = {}, _classes[prefix(bsProps, 'responsive')] = responsive, _classes[prefix(bsProps, 'rounded')] = rounded, _classes[prefix(bsProps, 'circle')] = circle, _classes[prefix(bsProps, 'thumbnail')] = thumbnail, _classes);
return React.createElement('img', _extends({}, elementProps, {
className: classNames(className, classes)
}));
};
return Image;
}(React.Component);
Image.propTypes = propTypes;
Image.defaultProps = defaultProps;
export default bsClass('img', Image); |
src/svg-icons/action/print.js | ichiohta/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionPrint = (props) => (
<SvgIcon {...props}>
<path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"/>
</SvgIcon>
);
ActionPrint = pure(ActionPrint);
ActionPrint.displayName = 'ActionPrint';
ActionPrint.muiName = 'SvgIcon';
export default ActionPrint;
|
packages/material-ui-icons/src/Apps.js | dsslimshaddy/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let Apps = props =>
<SvgIcon {...props}>
<path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z" />
</SvgIcon>;
Apps = pure(Apps);
Apps.muiName = 'SvgIcon';
export default Apps;
|
packages/flow-upgrade/src/upgrades/0.53.0/ReactComponentExplicitTypeArgs/__tests__/fixtures/StateInferred.js | facebook/flow | // @flow
import React from 'react';
class MyComponent extends React.Component {
props: Props;
state = {};
defaultProps: T;
static props: T;
static state: T;
a: T;
b = 5;
c: T = 5;
method() {}
}
const expression = () =>
class extends React.Component {
props: Props;
state = {};
defaultProps: T;
static props: T;
static state: T;
a: T;
b = 5;
c: T = 5;
method() {}
}
|
src-example/components/pages/NotFoundPage/index.js | SIB-Colombia/biodiversity_catalogue_v2_frontend | import React from 'react'
import { PageTemplate, Header, Footer, Heading } from 'components'
const NotFoundPage = () => {
return (
<PageTemplate header={<Header />} footer={<Footer />}>
<Heading>404 Not Found</Heading>
</PageTemplate>
)
}
export default NotFoundPage
|
client/scripts/components/Glossary.js | ahoarfrost/metaseek | import React from 'react';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import ColorPalette from './ColorPalette';
import Paper from 'material-ui/Paper';
import {List, ListItem} from 'material-ui/List';
import { Link } from 'react-router';
import Subheader from 'material-ui/Subheader';
var Glossary2 = React.createClass ({
getInitialState : function() {
return {}
},
renderGlossary : function(category) {
<div>
<Subheader>{category}</Subheader>
<List>
{Object.keys(glossary[category]).map(function(item){
return(
<ListItem
primaryText={item}
nestedItems={[
<section className="glossary-item" key={item}>
{glossary[category][item]}
</section>
]}
/>
)
})}
</List>
</div>
},
render : function() {
const glossary = require('../glossary.json');
//console.log(glossary["investigation_type"]);
return (
<MuiThemeProvider muiTheme={getMuiTheme(ColorPalette)}>
<Paper className="glossary-paper">
<div>
<h2>Glossary</h2>
{Object.keys(glossary).map(function(category){
return(
<div>
<Subheader>{category}</Subheader>
<List>
{Object.keys(glossary[category]).map(function(item) {
return(
<ListItem
primaryText={item}
nestedItems={[
<section className="glossary-item" key={item}>
{glossary[category][item]}
</section>
]}
/>
)
})}
</List>
</div>
)
})};
</div>
</Paper>
</MuiThemeProvider>
)
}
});
export default Glossary2;
|
accounts-ui/app/components/appReActivate.js | CloudBoost/cloudboost | import React from 'react';
import {Link, browserHistory} from 'react-router'
import axios from 'axios'
import CircularProgress from 'material-ui/CircularProgress'
class Reset extends React.Component {
constructor() {
super()
this.state = {
appActivated: false,
error: false
}
}
componentDidMount() {
if(__isBrowser) document.title = "CloudBoost | Activate"
if (!__isDevelopment) {
/****Tracking*********/
mixpanel.track('Portal:Visited ForgotPassword Page', {"Visited": "Visited ForgotPassword page in portal!"});
/****End of Tracking*****/
}
let postData = {}
let appId = window.location.pathname.split('/')[2];
axios.post(USER_SERVICE_URL + "/app/active/" + appId, postData).then(function(data) {
this.state.appActivated = true;
this.state.appname = data.data;
this.setState(this.state);
setTimeout(function() {
browserHistory.replace('/');
}, 5000);
}.bind(this), function(err) {
this.state.error = true;
this.setState(this.state);
}.bind(this))
if (!__isDevelopment) {
/****Tracking*********/
mixpanel.track('activate-app', {"app-data": appId});
/****End of Tracking*****/
}
}
render() {
return (
<div>
<div id="login">
<div id="image">
<img className="logo" src="public/assets/images/CbLogoIcon.png"/>
<div className={this.state.appActivated || this.state.error
? 'hide'
: ''}><CircularProgress color="#4E8EF7" size={50} thickness={6}/>
</div>
</div>
<div id="headLine" className={this.state.appActivated
? ''
: 'hide'}>
<h3 className="tacenter hfont">Your app {this.state.appname}
is now activated.</h3>
<h5 className="tacenter bfont">Your app is now in active state and will NOT be deleted automatically. Please make sure you use your app regularly to avoid being marked as inactive.</h5>
</div>
<div id="headLine" className={this.state.error
? ''
: 'hide'}>
<h3 className="tacenter hfont">
Unable to activate your app.</h3>
<h5 className="tacenter bfont">We’re sorry, we cannot activate your app at this time. We request you to please contact us at
<a href="mailto:support@cloudboost.io">
support@cloudboost.io
</a>
</h5>
</div>
</div>
</div>
);
}
}
export default Reset;;
|
src/containers/NotFound/NotFound.js | kiyonish/kiyonishimura | import React from 'react'
export default function NotFound() {
return (
<div className="container">
<h1>Doh! 404!</h1>
<p>These are <em>not</em> the droids you are looking for!</p>
</div>
)
}
|
src/components/App.js | OSDLabs/swd | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import PropTypes from 'prop-types';
import injectTapEventPlugin from 'react-tap-event-plugin';
// react-tap-event-plugin provides onTouchTap() to all React Components.
// It's a mobile-friendly onClick() alternative for components in Material-UI,
// especially useful for the buttons.
injectTapEventPlugin();
/**
* The top-level React component setting context (global) variables
* that can be accessed from all the child components.
*
* https://facebook.github.io/react/docs/context.html
*
* Usage example:
*
* const context = {
* history: createBrowserHistory(),
* store: createStore(),
* };
*
* ReactDOM.render(
* <App context={context}>
* <Layout>
* <LandingPage />
* </Layout>
* </App>,
* container,
* );
*/
class App extends React.PureComponent {
getChildContext() {
return this.props.context;
}
render() {
// NOTE: If you need to add or modify header, footer etc. of the app,
// please do that inside the Layout component.
return React.Children.only(this.props.children);
}
}
App.propTypes = {
context: PropTypes.object.isRequired,
children: PropTypes.element.isRequired,
};
App.childContextTypes = {
insertCss: PropTypes.func.isRequired,
muiTheme: PropTypes.object.isRequired,
};
export default App;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.