path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
react-router-demo/lessons/13-server-rendering/modules/Repo.js | zhangjunhd/react-examples | import React from 'react'
export default React.createClass({
render() {
const { userName, repoName } = this.props.params
return (
<div>
<h2>{userName} / {repoName}</h2>
</div>
)
}
})
|
app/components/slide_up_panel/slide_up_panel_indicator.js | mattermost/mattermost-mobile | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Animated, Platform, StyleSheet, View} from 'react-native';
export default function slideUpPanelIndicator() {
if (Platform.OS === 'android') {
return null;
}
return (
<Animated.View
style={styles.dragIndicatorContainer}
>
<View style={styles.dragIndicator}/>
</Animated.View>
);
}
const styles = StyleSheet.create({
dragIndicatorContainer: {
marginVertical: 10,
alignItems: 'center',
justifyContent: 'center',
},
dragIndicator: {
backgroundColor: 'white',
height: 5,
width: 62.5,
opacity: 0.9,
borderRadius: 25,
},
});
|
app/components/newAppDialog.js | JustinBeckwith/trebuchet | import React from 'react';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import RaisedButton from 'material-ui/RaisedButton';
import TextField from 'material-ui/TextField';
import SelectField from 'material-ui/SelectField';
import MenuItem from 'material-ui/MenuItem';
import Checkbox from 'material-ui/Checkbox';
import * as AppEvents from './../machines/appEvents';
import {remote} from 'electron';
import CloudDone from 'material-ui/svg-icons/file/cloud-done';
import CloudOff from 'material-ui/svg-icons/file/cloud-off';
import generate from 'project-name-generator';
import os from 'os';
import path from 'path';
import fs from 'fs';
export default class newAppDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false,
title: "New Application",
}
let manager = this.props.manager;
let localPath = path.join(os.homedir(), "AppEngineApps");
fs.mkdir(localPath, err => {});
this.runtimes = [
{ key: 'python', label: 'Python'},
{ key: 'go', label: 'Go'},
{ key: 'php', label: 'PHP'}
];
/**
* Handle opening the new App Dialog.
*/
manager.on(AppEvents.NEW_APP, () => {
this.getNextPort().then((port) => {
let name = generate({ number: true }).dashed;
let localPath = path.join(os.homedir(), "AppEngineApps");
this.setState({
open: true,
project: name,
port: port,
adminPort: port+1,
path: localPath,
runtime: "python",
autoCreate: true,
env: 'standard',
isEditMode: false,
title: "New application",
});
});
});
/**
* Handle opening the edit App Dialog.
*/
manager.on(AppEvents.SHOW_APP_SETTINGS_DIALOG, (app) => {
this.setState({
open: true,
project: app.name,
port: app.port,
adminPort: app.adminPort,
path: app.path,
runtime: app.runtime,
autoCreate: false,
env: app.env,
isEditMode: true,
title: "Edit application settings",
});
});
}
handleOpen = () => {
this.setState({open: true});
};
handleClose = () => {
this.setState({open: false});
};
handleSubmit = () => {
let app = this.state;
let manager = this.props.manager;
if (this.state.isEditMode) {
manager.updateApp(app);
} else {
manager.addApp(app);
}
this.setState({open: false});
};
onProjectChange = (event) => {
this.setState({
project: event.target.value,
}, () => {
if (!this.state.pathModified) {
this.setState({
path: path.join(os.homedir(), "AppEngineApps")
});
}
});
}
onPortChange = (event) => {
this.setState({
port: parseInt(event.target.value),
});
}
onAdminPortChange = (event) => {
this.setState({
adminPort: parseInt(event.target.value),
});
}
onRuntimeChange = (event, key, value) => {
this.setState({
runtime: value,
});
}
onUploadClick = () => {
let result = remote.dialog.showOpenDialog({
properties: ['openDirectory', 'createDirectory'],
defaultPath: this.state.path
});
if (result && result.length > 0) {
this.setState({
path: result[0],
pathModified: true,
});
}
}
onAutoCreateCheck = (event, isInputChecked) => {
this.setState({
autoCreate: isInputChecked,
});
}
getNextPort = () => {
return this.props.manager.getApps().then((apps) => {
// find the highest port available in the 8xxx range
let max = 8000;
for (let app of apps) {
if (app.port > max) max = app.port;
if (app.adminPort > max) max = app.adminPort;
}
return (max+1);
});
}
render() {
const actions = [
<FlatButton
label="Cancel"
onTouchTap={this.handleClose}
/>,
<FlatButton
label="Submit"
primary={true}
keyboardFocused={true}
onTouchTap={this.handleSubmit}
/>,
];
const runtimes = this.runtimes.map((runtime) => {
return <MenuItem value={runtime.key} primaryText={runtime.label} key={runtime.key} />
});
return (
<Dialog
title={this.state.title}
actions={actions}
modal={false}
open={this.state.open}
onRequestClose={this.handleClose}
autoScrollBodyContent={true}>
<div style={{width: '250px', float: 'left'}}>
<div>
<TextField
fullWidth={true}
hintText="Project"
floatingLabelText="Project name"
value={this.state.project}
disabled={this.state.isEditMode}
onChange={this.onProjectChange} />
</div>
<div>
<SelectField
style={{width:'100px'}}
floatingLabelText="Language"
value={this.state.runtime}
disabled={this.state.isEditMode}
onChange={this.onRuntimeChange}>
{runtimes}
</SelectField>
</div>
<div>
<TextField
style={{width:'100px'}}
floatingLabelText="Local port"
hintText="Local port"
value={this.state.port}
onChange={this.onPortChange}
type="number" />
</div>
<div>
<TextField
style={{width:'100px'}}
floatingLabelText="Admin port"
hintText="Admin Port"
value={this.state.adminPort}
onChange={this.onAdminPortChange}
type="number" />
</div>
</div>
<div style={{float: 'right', border: '1px solid #CCC', width: 'calc(100% - 270px)', height: '270px', marginTop: '20px'}}>
<img src={'./images/svg/' + this.state.runtime + '.svg'} style={{width: '100%', height: '270px', margin: 'auto', display: 'block'}}/>
<div style={{float:'right', whiteSpace: 'nowrap'}}>
<Checkbox
checkedIcon={<CloudDone />}
uncheckedIcon={<CloudOff />}
label="Create cloud project"
checked={this.state.autoCreate}
onCheck={this.onAutoCreateCheck}
disabled={this.state.isEditMode}
labelStyle={{fontSize: '12px', textTransform: 'uppercase', fontWeight: 'bold', color: '#777'}} />
</div>
</div>
<div style={{clear: 'both', marginTop: '15px'}}>
<TextField
style={{width: 'calc(100% - 110px)', marginRight: '20px'}}
floatingLabelText="Application directory"
hintText="Application directory"
value={this.state.path}
onChange={this.onPathChange}
disabled={true} />
<RaisedButton
label="..."
disabled={this.state.isEditMode}
onClick={this.onUploadClick}>
</RaisedButton>
</div>
</Dialog>
);
}
} |
src/components/buttons/demos/Icon.js | isogon/material-components | import React from 'react'
import { Button, Icon } from '../../../'
export default () => (
<Button icon>
<Icon name="add" />
</Button>
)
|
src/desktop/apps/consign/components/submission_flow/index.js | kanaabe/force | import PropTypes from 'prop-types'
import React from 'react'
import _StepMarker from '../step_marker'
import block from 'bem-cn-lite'
import _stepsConfig from '../../client/steps_config'
import { connect } from 'react-redux'
import {
resizeWindow
} from '../../client/actions'
// FIXME: Rewire
let StepMarker = _StepMarker
let stepsConfig = _stepsConfig
function SubmissionFlow (props) {
const b = block('consignments-submission-flow')
const { CurrentStepComponent } = props
return (
<div className={b()}>
<StepMarker />
<div className={b('step-form')}>
<CurrentStepComponent />
</div>
</div>
)
}
const mapStateToProps = (state) => {
const {
submissionFlow: {
currentStep
}
} = state
return {
CurrentStepComponent: stepsConfig[currentStep].component
}
}
const mapDispatchToProps = {
responsiveWindowAction: resizeWindow
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(SubmissionFlow)
SubmissionFlow.propTypes = {
CurrentStepComponent: PropTypes.func.isRequired
}
|
src/templates/allTagsIndex.js | gvlachos/gvlachos.github.io | import React from 'react';
import {Link} from 'gatsby';
export default ({data, pageContext}) => {
const {tags} = pageContext;
return (
<div style={{fontFamily: 'avenir'}}>
<div>
<ul>
{tags.map((tagName, index) => {
return (
<li key={index}>
<Link to={`/tags/${tagName}`}>{tagName}</Link>
</li>
);
})}
</ul>
<Link to="/">Home</Link>
</div>
</div>
);
};
|
src/components/Containers.react.js | virajkanwade/kitematic | import $ from 'jquery';
import _ from 'underscore';
import React from 'react';
import Router from 'react-router';
import containerStore from '../stores/ContainerStore';
import ContainerList from './ContainerList.react';
import Header from './Header.react';
import metrics from '../utils/MetricsUtil';
import shell from 'shell';
import machine from '../utils/DockerMachineUtil';
var Containers = React.createClass({
contextTypes: {
router: React.PropTypes.func
},
getInitialState: function () {
return {
sidebarOffset: 0,
containers: containerStore.getState().containers,
sorted: this.sorted(containerStore.getState().containers)
};
},
componentDidMount: function () {
containerStore.listen(this.update);
},
componentDidUnmount: function () {
containerStore.unlisten(this.update);
},
sorted: function (containers) {
return _.values(containers).sort(function (a, b) {
if (a.State.Downloading && !b.State.Downloading) {
return -1;
} else if (!a.State.Downloading && b.State.Downloading) {
return 1;
} else {
if (a.State.Running && !b.State.Running) {
return -1;
} else if (!a.State.Running && b.State.Running) {
return 1;
} else {
return a.Name.localeCompare(b.Name);
}
}
});
},
update: function () {
let containers = containerStore.getState().containers;
let sorted = this.sorted(containerStore.getState().containers);
let name = this.context.router.getCurrentParams().name;
if (containerStore.getState().pending) {
this.context.router.transitionTo('pull');
} else if (name && !containers[name]) {
if (sorted.length) {
this.context.router.transitionTo('containerHome', {name: sorted[0].Name});
} else {
this.context.router.transitionTo('search');
}
}
this.setState({
containers: containers,
sorted: sorted,
pending: containerStore.getState().pending
});
},
handleScroll: function (e) {
if (e.target.scrollTop > 0 && !this.state.sidebarOffset) {
this.setState({
sidebarOffset: e.target.scrollTop
});
} else if (e.target.scrollTop === 0 && this.state.sidebarOffset) {
this.setState({
sidebarOffset: 0
});
}
},
handleNewContainer: function () {
$(this.getDOMNode()).find('.new-container-item').parent().fadeIn();
this.context.router.transitionTo('new');
metrics.track('Pressed New Container');
},
handleClickPreferences: function () {
metrics.track('Opened Preferences', {
from: 'app'
});
this.context.router.transitionTo('preferences');
},
handleClickDockerTerminal: function () {
metrics.track('Opened Docker Terminal', {
from: 'app'
});
machine.dockerTerminal();
},
handleClickReportIssue: function () {
metrics.track('Opened Issue Reporter', {
from: 'app'
});
shell.openExternal('https://github.com/kitematic/kitematic/issues/new');
},
handleMouseEnterDockerTerminal: function () {
this.setState({
currentButtonLabel: 'Open terminal to use Docker command line.'
});
},
handleMouseLeaveDockerTerminal: function () {
this.setState({
currentButtonLabel: ''
});
},
handleMouseEnterReportIssue: function () {
this.setState({
currentButtonLabel: 'Report an issue or suggest feedback.'
});
},
handleMouseLeaveReportIssue: function () {
this.setState({
currentButtonLabel: ''
});
},
handleMouseEnterPreferences: function () {
this.setState({
currentButtonLabel: 'Change app preferences.'
});
},
handleMouseLeavePreferences: function () {
this.setState({
currentButtonLabel: ''
});
},
render: function () {
var sidebarHeaderClass = 'sidebar-header';
if (this.state.sidebarOffset) {
sidebarHeaderClass += ' sep';
}
var container = this.context.router.getCurrentParams().name ? this.state.containers[this.context.router.getCurrentParams().name] : {};
return (
<div className="containers">
<Header />
<div className="containers-body">
<div className="sidebar">
<section className={sidebarHeaderClass}>
<h4>Containers</h4>
<div className="create">
<Router.Link to="new">
<span className="btn btn-new btn-action has-icon btn-hollow"><span className="icon icon-add"></span>New</span>
</Router.Link>
</div>
</section>
<section className="sidebar-containers" onScroll={this.handleScroll}>
<ContainerList containers={this.state.sorted} newContainer={this.state.newContainer} />
</section>
<section className="sidebar-buttons">
<span className="btn-sidebar btn-terminal" onClick={this.handleClickDockerTerminal} onMouseEnter={this.handleMouseEnterDockerTerminal} onMouseLeave={this.handleMouseLeaveDockerTerminal}><span className="icon icon-docker-cli"></span><span className="text">DOCKER CLI</span></span>
<span className="btn-sidebar btn-feedback" onClick={this.handleClickReportIssue} onMouseEnter={this.handleMouseEnterDockerTerminal} onMouseLeave={this.handleMouseLeaveDockerTerminal}><span className="icon icon-feedback"></span></span>
<span className="btn-sidebar btn-preferences" onClick={this.handleClickPreferences} onMouseEnter={this.handleMouseEnterDockerTerminal} onMouseLeave={this.handleMouseLeaveDockerTerminal}><span className="icon icon-preferences"></span></span>
</section>
</div>
<Router.RouteHandler pending={this.state.pending} containers={this.state.containers} container={container}/>
</div>
</div>
);
}
});
module.exports = Containers;
|
node_modules/react-native/Libraries/Utilities/throwOnWrongReactAPI.js | ninamanalo19/react-native-sliding-up-panel | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule throwOnWrongReactAPI
* @flow
*/
'use strict';
function throwOnWrongReactAPI(key: string) {
throw new Error(
`Seems you're trying to access 'ReactNative.${key}' from the 'react-native' package. Perhaps you meant to access 'React.${key}' from the 'react' package instead?
For example, instead of:
import React, { Component, View } from 'react-native';
You should now do:
import React, { Component } from 'react';
import { View } from 'react-native';
Check the release notes on how to upgrade your code - https://github.com/facebook/react-native/releases/tag/v0.25.1
`);
}
module.exports = throwOnWrongReactAPI;
|
src/common/lib/redux-firebase/firebase.js | robinpokorny/este | // @flow
import * as actions from './actions';
import React from 'react';
// // Example
// OnlineUsers = firebase((database, props) => {
// const usersPresenceRef = database.child('users-presence');
// return [
// [usersPresenceRef, 'on', 'value', props.onUsersPresence],
// ]
// })(OnlineUsers);
type Query = [Object, string, string, Function, Function | void];
type onMount = (database: Object, props: any) => void | Array<Query>;
// Higher order component for Firebase declarative queries.
const firebase = (onMount: onMount) => (WrappedComponent: Function) =>
class Firebase extends React.Component {
static contextTypes = {
store: React.PropTypes.object, // Redux store.
serverFetchPromises: React.PropTypes.array,
};
queries: Array<Query>;
createAction(type) {
const refs = this.queries.map(([ref]) => ref.toString());
return { type, payload: { refs } };
}
componentWillMount() {
const { serverFetchPromises } = this.context;
if (!serverFetchPromises) return;
// This is called only on the server.
this.context.store.dispatch(({ firebase }) => {
this.queries = onMount(firebase, this.props) || [];
this.queries.forEach(([ref, , eventType, cb1, cb2]) => {
// Enforce once eventType and store a promise so render can wait.
const promise = ref.once(eventType, cb1, cb2);
serverFetchPromises.push(promise);
});
return this.createAction(actions.FIREBASE_ON_QUERY);
});
}
// This is called only on the client.
componentDidMount() {
this.context.store.dispatch(({ firebase }) => {
this.queries = onMount(firebase, this.props) || [];
this.queries.forEach(([ref, method, eventType, cb1, cb2]) => {
ref[method](eventType, cb1, cb2);
});
return this.createAction(actions.FIREBASE_ON_QUERY);
});
}
componentWillUnmount() {
this.context.store.dispatch(() => {
this.queries.forEach(([ref, method, eventType, cb1, cb2]) => {
if (method === 'once') return;
ref.off(eventType, cb1, cb2);
});
return this.createAction(actions.FIREBASE_OFF_QUERY);
});
}
render() {
return (
<WrappedComponent {...this.props} />
);
}
};
export default firebase;
|
src/components/KeyDetails.js | cpsubrian/redis-explorer | import React from 'react'
import pureRender from 'pure-render-decorator'
import ImmutablePropTypes from 'react-immutable-proptypes'
import HashDetails from '../components/details/HashDetails'
import ListDetails from '../components/details/ListDetails'
import SetDetails from '../components/details/SetDetails'
import SortedSetDetails from '../components/details/SortedSetDetails'
import StringDetails from '../components/details/StringDetails'
@pureRender
class KeyDetails extends React.Component {
static propTypes = {
item: ImmutablePropTypes.map
}
render () {
switch (this.props.item.get('type')) {
case 'string':
return <StringDetails {...this.props}/>
case 'list':
return <ListDetails {...this.props}/>
case 'set':
return <SetDetails {...this.props}/>
case 'zset':
return <SortedSetDetails {...this.props}/>
case 'hash':
return <HashDetails {...this.props}/>
}
}
}
export default KeyDetails
|
docs/src/app/components/pages/components/IconMenu/ExampleSimple.js | ruifortes/material-ui | import React from 'react';
import IconMenu from 'material-ui/IconMenu';
import MenuItem from 'material-ui/MenuItem';
import IconButton from 'material-ui/IconButton/IconButton';
import MoreVertIcon from 'material-ui/svg-icons/navigation/more-vert';
const IconMenuExampleSimple = () => (
<div>
<IconMenu
iconButtonElement={<IconButton><MoreVertIcon /></IconButton>}
anchorOrigin={{horizontal: 'left', vertical: 'top'}}
targetOrigin={{horizontal: 'left', vertical: 'top'}}
>
<MenuItem primaryText="Refresh" />
<MenuItem primaryText="Send feedback" />
<MenuItem primaryText="Settings" />
<MenuItem primaryText="Help" />
<MenuItem primaryText="Sign out" />
</IconMenu>
<IconMenu
iconButtonElement={<IconButton><MoreVertIcon /></IconButton>}
anchorOrigin={{horizontal: 'left', vertical: 'bottom'}}
targetOrigin={{horizontal: 'left', vertical: 'bottom'}}
>
<MenuItem primaryText="Refresh" />
<MenuItem primaryText="Send feedback" />
<MenuItem primaryText="Settings" />
<MenuItem primaryText="Help" />
<MenuItem primaryText="Sign out" />
</IconMenu>
<IconMenu
iconButtonElement={<IconButton><MoreVertIcon /></IconButton>}
anchorOrigin={{horizontal: 'right', vertical: 'bottom'}}
targetOrigin={{horizontal: 'right', vertical: 'bottom'}}
>
<MenuItem primaryText="Refresh" />
<MenuItem primaryText="Send feedback" />
<MenuItem primaryText="Settings" />
<MenuItem primaryText="Help" />
<MenuItem primaryText="Sign out" />
</IconMenu>
<IconMenu
iconButtonElement={<IconButton><MoreVertIcon /></IconButton>}
anchorOrigin={{horizontal: 'right', vertical: 'top'}}
targetOrigin={{horizontal: 'right', vertical: 'top'}}
>
<MenuItem primaryText="Refresh" />
<MenuItem primaryText="Send feedback" />
<MenuItem primaryText="Settings" />
<MenuItem primaryText="Help" />
<MenuItem primaryText="Sign out" />
</IconMenu>
</div>
);
export default IconMenuExampleSimple;
|
src/components/molecules/IconButton/index.stories.js | DimensionLab/narc | import React from 'react'
import { storiesOf } from '@storybook/react'
import { IconButton } from 'components'
storiesOf('IconButton', module)
.add('default', () => (
<IconButton icon="close">Hello</IconButton>
))
.add('transparent', () => (
<IconButton icon="close" transparent>Hello</IconButton>
))
.add('with icon on right', () => (
<IconButton icon="close" right>Hello</IconButton>
))
.add('responsive', () => (
<IconButton icon="close" responsive>Decrease panel width</IconButton>
))
.add('responsive with breakpoint', () => (
<IconButton icon="close" breakpoint={300} responsive>Decrease panel width to 300</IconButton>
))
.add('without text', () => (
<IconButton icon="close" />
))
.add('collapsed', () => (
<IconButton icon="close" collapsed>Hello</IconButton>
))
.add('height', () => (
<IconButton icon="close" height={100}>Hello</IconButton>
))
|
node_modules/@expo/vector-icons/website/src/index.js | jasonlarue/react-native-flashcards | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(<App />, document.getElementById('root'));
|
src/svg-icons/maps/transfer-within-a-station.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsTransferWithinAStation = (props) => (
<SvgIcon {...props}>
<path d="M16.49 15.5v-1.75L14 16.25l2.49 2.5V17H22v-1.5zm3.02 4.25H14v1.5h5.51V23L22 20.5 19.51 18zM9.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM5.75 8.9L3 23h2.1l1.75-8L9 17v6h2v-7.55L8.95 13.4l.6-3C10.85 12 12.8 13 15 13v-2c-1.85 0-3.45-1-4.35-2.45l-.95-1.6C9.35 6.35 8.7 6 8 6c-.25 0-.5.05-.75.15L2 8.3V13h2V9.65l1.75-.75"/>
</SvgIcon>
);
MapsTransferWithinAStation = pure(MapsTransferWithinAStation);
MapsTransferWithinAStation.displayName = 'MapsTransferWithinAStation';
MapsTransferWithinAStation.muiName = 'SvgIcon';
export default MapsTransferWithinAStation;
|
src/index.js | shawnzhang009/react-starter | import { AppContainer } from 'react-hot-loader';
import React from 'react'
import ReactDOM from 'react-dom'
import App from './components/App'
import injectTapEventPlugin from 'react-tap-event-plugin'
injectTapEventPlugin()
ReactDOM.render(
<div>
<App />
</div>,
document.getElementById('main')
)
if (module.hot) {
module.hot.accept('./components/App', () => {
// If you use Webpack 2 in ES modules mode, you can
// use <App /> here rather than require() a <NextApp />.
const NextApp = require('./components/App').default;
ReactDOM.render(
<AppContainer>
<NextApp />
</AppContainer>,
document.getElementById('main')
);
});
} |
Hebrides/SmartHome/Me/HeaderCell.js | HarrisLee/React-Native-Express | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
Image,
TouchableHighlight,
PixelRatio
} from 'react-native';
import Constant from '../Global/Constant.js';
export default class HeaderCell extends Component {
static defaultProps = {
}
constructor(props) {
super(props);
this.state = {
obj: this.props.obj
};
}
render(){
return (<TouchableHighlight onPress={this.props.onSelect} underlayColor='#ff0000'>
<View style={styles.Header}>
<Image style={styles.headerBackground} source={require('../../res/images/me/[email protected]')}>
<View style={styles.ItemsBottom}>
<Image style={styles.headerIcon} source={require('../../res/images/me/[email protected]')}/>
<Text style={styles.titleText}>苏宁智能下午好!</Text>
<HeaderButton hasLine={true} title={'智能场景'} icon={require('../../res/images/me/[email protected]')}/>
<HeaderButton hasLine={false} title={'我的服务'} icon={require('../../res/images/me/[email protected]')}/>
</View>
</Image>
</View>
</TouchableHighlight>);
}
}
class HeaderButton extends Component {
constructor(props) {
super(props);
this.state = {};
}
render(){
return (
<TouchableHighlight>
<View style={[styles.button, this.props.hasLine ? styles.rightLine : null]}>
<Image source={this.props.icon}/>
<Text style={styles.text}> {this.props.title}</Text>
</View>
</TouchableHighlight>
);
}
}
const styles = StyleSheet.create({
Header:{
width:global.CONSTANST.screen_width,
height:240,
backgroundColor:'#ffffff',
marginBottom:15,
flexDirection:'row',
alignItems:'flex-end',
},
headerBackground:{
resizeMode:'cover',
backgroundColor:'#ffffff',
alignItems:'flex-end',
flexDirection:'row',
flex:1,
// flexWrap:'wrap',
},
ItemsBottom:{
flex:1,
height:186,
flexDirection:'row',
flexWrap:'wrap',
alignItems:'center',
justifyContent:'center',
marginTop:54,
},
button:{
width:global.CONSTANST.screen_width/2.0,
height:44,
alignItems:'center',
flexDirection:'row',
justifyContent:'center',
borderTopWidth : 1/PixelRatio.get(),
borderTopColor : '#cccccc',
borderStyle : 'solid',
opacity:0.6,
marginTop:32,
},
rightLine:{
borderRightWidth : 1/PixelRatio.get(),
borderRightColor : '#cccccc',
borderStyle : 'solid',
},
text:{
color:'#ffffff',
backgroundColor:'transparent',
},
titleText:{
width:global.CONSTANST.screen_width,
height:20,
fontSize:13,
color:'#ffffff',
textAlign:'center',
marginTop:10,
backgroundColor:'transparent',
},
headerIcon:{
width:80,
height:80,
borderRadius:40,
}
}); |
app/javascript/mastodon/features/ui/components/drawer_loading.js | koba-lab/mastodon | import React from 'react';
const DrawerLoading = () => (
<div className='drawer'>
<div className='drawer__pager'>
<div className='drawer__inner' />
</div>
</div>
);
export default DrawerLoading;
|
src/components/FolderButton.js | feedreaderco/web | import React, { Component } from 'react';
export default class FolderButton extends Component {
constructor(props) {
super(props);
let className = 'pillbox empty';
if (this.props.folders.indexOf(this.props.folder) !== -1) {
className = 'pillbox';
}
this.state = { className };
}
onClick(e) {
e.preventDefault();
if (this.state.className === 'pillbox') {
this.removeFromFolder(folderButton);
} else {
this.addToFolder(folderButton);
}
}
addToFolder() {
this.props.lib.user.folders.folder.post(this.props.folder, this.props.feed).then(() => {
this.setState({ className: 'pillbox' });
}).catch(console.error);
}
removeFromFolder() {
this.props.lib.user.folders.folder.del(this.props.folder, this.props.feed).then(() => {
this.setState({ className: 'pillbox empty' });
}).catch(console.error);
}
render() {
return <input type="submit"
className={this.state.className}
value={this.props.folder}
onClick={this.onClick}
/>;
}
}
|
src/main/webapp/resources/modules/lobby/CreateGameDialog/CreateGameDialog.js | cwoolner/flex-poker | import React from 'react'
import Button from 'react-bootstrap/Button'
import Modal from 'react-bootstrap/Modal'
import Form from 'react-bootstrap/Form'
export default ({showModal, hideDialogCallback, submitFormCallback}) => {
return (
<Modal size="sm" show={showModal} onHide={hideDialogCallback}>
<Modal.Header closeButton>
<Modal.Title>Create Game</Modal.Title>
</Modal.Header>
<form id="create-game-form" onSubmit={submitFormCallback}>
<Modal.Body>
<Form.Group>
<Form.Label>Name</Form.Label>
<Form.Control type="text" name="name" autoFocus />
</Form.Group>
<Form.Group>
<Form.Label>Number of Players (2 - 90)</Form.Label>
<Form.Control type="number" name="players" min="2" max="90" />
</Form.Group>
<Form.Group>
<Form.Label>Number of Players per Table (2 - 9)</Form.Label>
<Form.Control type="number" name="playersPerTable" min="2" max="9" />
</Form.Group>
<Form.Group>
<Form.Label>Blind increment in minutes (1 - 60)</Form.Label>
<Form.Control type="number" name="numberOfMinutesBetweenBlindLevels" min="1" max="60" />
</Form.Group>
<Form.Group>
<Form.Label>Blind timer in seconds (1 - 60)</Form.Label>
<Form.Control type="number" name="secondsForActionOnTimer" min="1" max="60" />
</Form.Group>
</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={hideDialogCallback}>Close</Button>
<Button type="submit" variant="primary">Create Game</Button>
</Modal.Footer>
</form>
</Modal>
)
}
|
src/svg-icons/image/palette.js | xmityaz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImagePalette = (props) => (
<SvgIcon {...props}>
<path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"/>
</SvgIcon>
);
ImagePalette = pure(ImagePalette);
ImagePalette.displayName = 'ImagePalette';
ImagePalette.muiName = 'SvgIcon';
export default ImagePalette;
|
maodou/events/client/components/events.js | ShannChiang/meteor-react-redux-base | import React from 'react';
import {Link} from 'react-router';
import moment from 'moment';
import Loading from 'client/components/common/loading';
export default (props) => {
const T = props.context.T;
return (
<div className="container" style={{ paddingTop: '60px'}}>
<div className="row">
{
props.events.status === 'ready' ?
props.events.data.length > 0 ?
props.events.data.map((event, index) =>
<div key={index} className="col-sm-12">
<div className="hpanel blog-box">
{/*<div className="panel-heading">*/}
{/*<div className="media clearfix">*/}
{/*<Link to="#" className="pull-left">*/}
{/*<img src="/images/a8.jpg" alt="profile-picture" />*/}
{/*</Link>*/}
{/*<div className="media-body">*/}
{/*<small>Created by: <span className="font-bold">Mike Smith</span></small>*/}
{/*<br />*/}
{/*<small className="text-muted">21.03.2015, 06:45 pm</small>*/}
{/*</div>*/}
{/*</div>*/}
{/*</div>*/}
<div className="panel-body">
<div className="event-img">
<img src={event.coverUrl} alt="event picture"/>
</div>
<Link to={`/event/${event._id}`}>
<h4>{event.title}</h4>
<p className="event-desc">{event.plainDesc}</p>
</Link>
</div>
<div className="panel-footer">
<span className="pull-right">
费用: {event.unit === 'dollar' ? '$' : '¥'} {event.fee}
</span>
<i className='fa fa-clock-o'></i>{ moment(event.time).format('YYYY-MM-DD')} | <i className='fa fa-location-arrow'></i>{event.location}
</div>
</div>
</div>
) :
<div>抱歉,目前还没有活动!</div> :
<Loading />
}
</div>
</div>
);
}
|
src/components/containers/Header/Header.js | PulseTile/PulseTile-React | import React from 'react';
import { Switch, Route } from 'react-router-dom'
import HeaderToolbar from './HeaderToolbar/HeaderToolbar';
import HeaderTitle from './HeaderTitle/HeaderTitle';
import { clientUrls } from '../../../config/client-urls.constants'
import { routersPluginConfig } from '../../../plugins.config';
import '../../../config/styles';
const Header = props =>
<div>
<Switch>
<Route exact path={`${clientUrls.PATIENTS}/:userId/${clientUrls.PATIENTS_SUMMARY}`} component={HeaderToolbar} />
{routersPluginConfig.map(item => !item.withoutHeaderToolbar ? <Route exact path={item.path} component={HeaderToolbar} key={item.key} /> : null)}
<Route path={clientUrls.ROOT} component={HeaderTitle} />
</Switch>
</div>
export default Header;
|
react/src/components/FileHoverButtons/index.js | sinfin/folio | import React from 'react'
const FileHoverButtons = ({ destroy, edit, onDestroy, onEdit }) => {
return (
<React.Fragment>
{destroy && (
<button
type='button'
className='f-c-file-list__file-btn f-c-file-list__file-btn--destroy btn btn-danger fa fa-times'
onClick={(e) => { e.stopPropagation(); onDestroy() }}
/>
)}
{edit && (
<button
type='button'
className='f-c-file-list__file-btn f-c-file-list__file-btn--edit btn btn-secondary fa fa-edit'
onClick={(e) => { e.stopPropagation(); onEdit() }}
/>
)}
</React.Fragment>
)
}
export default FileHoverButtons
|
src/index.js | cichy/redux-login | import React from 'react'
import ReactDOM from 'react-dom'
import createStore from './store/createStore'
import 'normalize.css'
import './styles/main.scss'
// Store Initialization
// ------------------------------------
const store = createStore(window.__INITIAL_STATE__)
// Render Setup
// ------------------------------------
const MOUNT_NODE = document.getElementById('root')
let render = () => {
const App = require('./components/App').default
const routes = require('./routes/index').default(store)
ReactDOM.render(
<App store={store} routes={routes} />,
MOUNT_NODE
)
}
render()
|
admin/client/App/index.js | cermati/keystone | /**
* This is the main entry file, which we compile the main JS bundle from. It
* only contains the client side routing setup.
*/
// Needed for ES6 generators (redux-saga) to work
import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';
import { Provider } from 'react-redux';
import { syncHistoryWithStore } from 'react-router-redux';
import App from './App';
import Home from './screens/Home';
import Item from './screens/Item';
import List from './screens/List';
import store from './store';
// Sync the browser history to the Redux store
const history = syncHistoryWithStore(browserHistory, store);
// Initialise Keystone.User list
import { listsByKey } from '../utils/lists';
Keystone.User = listsByKey[Keystone.userList];
ReactDOM.render(
<Provider store={store}>
<Router history={history}>
<Route path={Keystone.adminPath} component={App}>
<IndexRoute component={Home} />
<Route path=":listId" component={List} />
<Route path=":listId/:itemId" component={Item} />
</Route>
</Router>
</Provider>,
document.getElementById('react-root')
);
|
common/components/ide/panels/ProcessPanel.js | ebertmi/webbox | import React from 'react';
import Terminal from '../Terminal';
import optionManager from '../../../models/options';
const bell = new Audio('/public/audio/bell.ogg');
export default class ProcessPanel extends React.Component {
constructor(props) {
super(props);
this.onChangeOption = this.onChangeOption.bind(this);
this.onBell = this.onBell.bind(this);
this.onResize = this.onResize.bind(this);
this.onTitle = this.onTitle.bind(this);
this.state = {
options: optionManager.getOptions()
};
}
componentDidMount() {
optionManager.on('change', this.onChangeOption);
this.onChangeOption();
}
componentWillUnmount() {
optionManager.removeListener('change', this.onChangeOption);
}
onChangeOption() {
this.setState({
options: optionManager.getOptions()
});
}
onResize(cols, rows) {
let process = this.props.item;
process.resize(cols, rows);
}
onTitle(title) {
this.props.item.emit('title', title);
}
onBell() {
if (this.state.options.terminal.audibleBell) {
if (bell.paused) {
bell.play();
} else {
bell.currentTime = 0;
}
}
this.props.item.emit('bell');
}
render() {
let process = this.props.item;
let {font, fontSize} = this.state.options;
return (
<Terminal
fontFamily={`${font}, monospace`}
fontSize={`${fontSize}`}
onBell={this.onBell}
onResize={this.onResize}
onTitle={this.onTitle}
hidden={!this.props.active}
process={process}
/>
);
}
}
ProcessPanel.renderInactive = true;
|
src/icons/CloseIcon.js | kiloe/ui | import React from 'react';
import Icon from '../Icon';
export default class CloseIcon extends Icon {
getSVG(){return <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path d="M38 12.83L35.17 10 24 21.17 12.83 10 10 12.83 21.17 24 10 35.17 12.83 38 24 26.83 35.17 38 38 35.17 26.83 24z"/></svg>;}
}; |
client/index.js | alan-jordan/gamr-v2 | import React from 'react'
import {render} from 'react-dom'
import {Provider} from 'react-redux'
import store from './store'
import App from './components/App'
document.addEventListener('DOMContentLoaded', () => {
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('app')
)
})
|
react/features/video-menu/components/native/MuteEveryonesVideoDialog.js | jitsi/jitsi-meet | // @flow
import React from 'react';
import Dialog from 'react-native-dialog';
import { Divider } from 'react-native-paper';
import { ColorSchemeRegistry } from '../../../base/color-scheme';
import { ConfirmDialog } from '../../../base/dialog';
import { translate } from '../../../base/i18n';
import { connect } from '../../../base/redux';
import { StyleType } from '../../../base/styles';
import AbstractMuteEveryonesVideoDialog, {
abstractMapStateToProps,
type Props as AbstractProps } from '../AbstractMuteEveryonesVideoDialog';
import styles from './styles';
type Props = AbstractProps & {
/**
* The color-schemed stylesheet of the base/dialog feature.
*/
_dialogStyles: StyleType
}
/**
* A React Component with the contents for a dialog that asks for confirmation
* from the user before muting all remote participants.
*
* @augments AbstractMuteEveryonesVideoDialog
*/
class MuteEveryonesVideoDialog extends AbstractMuteEveryonesVideoDialog<Props> {
/**
* Renders the dialog switch.
*
* @returns {React$Component}
*/
_renderSwitch() {
return (
this.props.exclude.length === 0
&& <Dialog.Switch
label = { this.props.t('dialog.moderationVideoLabel') }
onValueChange = { this._onToggleModeration }
value = { !this.state.moderationEnabled } />
);
}
/**
* Toggles advanced moderation switch.
*
* @returns {void}
*/
_onToggleModeration() {
this.setState(state => {
return {
moderationEnabled: !state.moderationEnabled,
content: this.props.t(state.moderationEnabled
? 'dialog.muteEveryonesVideoDialog' : 'dialog.muteEveryonesVideoDialogModerationOn'
)
};
});
}
/**
* Implements {@code Component#render}.
*
* @inheritdoc
*/
render() {
return (
<ConfirmDialog
confirmLabel = 'dialog.muteEveryonesVideoDialogOk'
descriptionKey = { this.state.content }
onSubmit = { this._onSubmit }
title = { this.props.title }>
<Divider style = { styles.dividerDialog } />
{ this._renderSwitch() }
</ConfirmDialog>
);
}
_onSubmit: () => boolean;
}
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @param {Props} ownProps - The own props of the component.
* @returns {{
* _dialogStyles: StyleType
* }}
*/
function _mapStateToProps(state: Object, ownProps: Props) {
return {
...abstractMapStateToProps(state, ownProps),
_dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
};
}
export default translate(connect(_mapStateToProps)(MuteEveryonesVideoDialog));
|
src/components/ServerListItem.react.js | bygloam/desktop | import React from 'react';
import RetinaImage from 'react-retina-image';
var SingleValue = React.createClass({
propTypes: {
placeholder: React.PropTypes.string,
value: React.PropTypes.object
},
render () {
var obj = this.props.value;
var size = 15;
var flagStyle = {
display: 'inline-block',
marginRight: 10,
position: 'relative',
top: -2,
verticalAlign: 'middle',
};
var flag = false;
if (obj.value == 'hub.vpn.ht') {
flag = "flag-icon";
} else {
if (obj && obj.country) {
flag = "flag-icon flag-icon-"+obj.country;
}
}
return (
<div className="Select-placeholder">
{flag ? (
<div>
<i className={flag} style={flagStyle}></i>
{obj.label}
</div>
) : (
this.props.placeholder
)
}
</div>
);
}
});
module.exports = SingleValue;
|
frontend/src/components/ShareIcon.js | carlosascari/opencollective-website | import React from 'react';
import Icon from './Icon';
export default ({type, url, name, description}) => {
const tweet = encodeURIComponent(`I just backed the ${name} collective.\nJoin me in supporting them! ${url}`);
const subject = encodeURIComponent(`I just backed the ${name} collective. Join me in supporting them!`);
const body = encodeURIComponent(`I just backed the ${name} collective:\n ${description}\n ${url}\n\nJoin me in supporting them!\n`);
const url_encoded = encodeURIComponent(url);
const link = {
twitter: `https://twitter.com/intent/tweet?status=${tweet}`,
facebook: `https://www.facebook.com/sharer.php?url=${url_encoded}`,
mail: `mailto:?subject=${subject}&body=${body}`,
};
const w = 650;
const h = 450;
const top = 0;
const left = 0;
// const left = (screen.width / 2) - (w / 2);
// const top = (screen.height / 2) - (h / 2);
return (
<span
onClick={() => window.open(link[type], 'ShareWindow', `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${w}, height=${h}, top=${top}, left=${left}`)}
className='ShareIcon'>
<Icon type={type} />
</span>
)
};
|
src/components/header/stories.js | chuckharmston/testpilot-contribute | import React from 'react';
import { storiesOf } from '@kadira/storybook';
import { wrapper } from '../wrapper/decorator';
import Header, { HomeNav } from './index';
storiesOf('Header', module)
.addDecorator(wrapper('dark'))
.add('With no navigation', () => <Header />)
.add('With homepage navigation', () => <Header><HomeNav /></Header>);
|
src/internal/Transition.js | AndriusBil/material-ui | // @flow
import React from 'react';
import type { Element } from 'react';
import ReactDOM from 'react-dom';
import transitionInfo from 'dom-helpers/transition/properties';
import addEventListener from 'dom-helpers/events/on';
import classNames from 'classnames';
import type { SyntheticUIEventHandler } from './dom';
const transitionEndEvent = transitionInfo.end;
export const UNMOUNTED = 0;
export const EXITED = 1;
export const ENTERING = 2;
export const ENTERED = 3;
export const EXITING = 4;
/**
* A helper function that calls back when any pending animations have started This is needed as the
* callback hooks might be setting some style properties that needs a frame to take effect.
*/
function requestAnimationStart(callback) {
// Feature detect rAF, fallback to setTimeout
if (window.requestAnimationFrame) {
// Chrome and Safari have a bug where calling rAF once returns the current
// frame instead of the next frame, so we need to call a double rAF here.
// See https://crbug.com/675795 for more.
window.requestAnimationFrame(() => {
window.requestAnimationFrame(callback);
});
} else {
setTimeout(callback, 0);
}
}
type State = {
status: 0 | 1 | 2 | 3 | 4,
};
export type TransitionCallback = (element: HTMLElement) => void;
export type TransitionRequestTimeout = (element: HTMLElement) => number;
export type Props = {
/**
* A single child content element.
*/
children?: Element<*>,
/**
* @ignore
*/
className?: string,
/**
* The CSS class applied when the component is entered.
*/
enteredClassName?: string,
/**
* The CSS class applied while the component is entering.
*/
enteringClassName?: string,
/**
* The CSS class applied when the component has exited.
*/
exitedClassName?: string,
/**
* The CSS class applied while the component is exiting.
*/
exitingClassName?: string,
/**
* Show the component; triggers the enter or exit animation.
*/
in?: boolean,
/**
* Callback fired before the "entering" classes are applied.
*/
onEnter?: TransitionCallback,
/**
* Callback fired after the "entering" classes are applied.
*/
onEntering?: TransitionCallback,
/**
* Callback fired after the "enter" classes are applied.
*/
onEntered?: TransitionCallback, // eslint-disable-line react/sort-prop-types
/**
* Callback fired before the "exiting" classes are applied.
*/
onExit?: TransitionCallback,
/**
* Callback fired after the "exiting" classes are applied.
*/
onExiting?: TransitionCallback,
/**
* Callback fired after the "exited" classes are applied.
*/
onExited?: TransitionCallback, // eslint-disable-line react/sort-prop-types
/**
* @ignore
*/
onRequestTimeout?: TransitionRequestTimeout,
/**
* A Timeout for the animation, in milliseconds, to ensure that a node doesn't
* transition indefinitely if the browser transitionEnd events are
* canceled or interrupted.
*
* By default this is set to a high number (5 seconds) as a failsafe. You should consider
* setting this to the duration of your animation (or a bit above it).
*/
timeout?: number,
/**
* Run the enter animation when the component mounts, if it is initially
* shown.
*/
transitionAppear?: boolean,
/**
* Unmount the component (remove it from the DOM) when it is not shown.
*/
unmountOnExit?: boolean,
};
type AllProps = Props;
/**
* @ignore - internal component.
*
* Drawn from https://raw.githubusercontent.com/react-bootstrap/react-overlays/master/src/Transition.js
*
* The Transition component lets you define and run CSS transitions with a simple declarative api.
* It works similarly to React's own CSSTransitionGroup
* but is specifically optimized for transitioning a single child "in" or "out".
*
* You don't even need to use class based CSS transitions if you don't want to (but it is easiest).
* The extensive set of lifecyle callbacks means you have control over
* the transitioning now at each step of the way.
*/
class Transition extends React.Component<AllProps, State> {
props: AllProps;
static defaultProps = {
in: false,
unmountOnExit: false,
transitionAppear: false,
timeout: 5000,
};
state = {
status: UNMOUNTED,
};
componentWillMount() {
let status;
if (this.props.in) {
// Start enter transition in componentDidMount.
status = this.props.transitionAppear ? EXITED : ENTERED;
} else {
status = this.props.unmountOnExit ? UNMOUNTED : EXITED;
}
this.setState({ status });
this.nextCallback = null;
}
componentDidMount() {
if (this.props.transitionAppear && this.props.in) {
this.performEnter(this.props);
}
}
componentWillReceiveProps(nextProps: Props) {
if (nextProps.in && this.props.unmountOnExit) {
if (this.state.status === UNMOUNTED) {
// Start enter transition in componentDidUpdate.
this.setState({ status: EXITED });
}
} else {
this.needsUpdate = true;
}
}
shouldComponentUpdate(nextProps: Props, nextState: State) {
if (this.props.in && this.state.status === EXITED && this.state.status === nextState.status) {
return false;
}
return true;
}
componentDidUpdate() {
const status = this.state.status;
if (this.props.unmountOnExit && status === EXITED) {
// EXITED is always a transitional state to either ENTERING or UNMOUNTED
// when using unmountOnExit.
if (this.props.in) {
this.performEnter(this.props);
} else {
this.setState({ status: UNMOUNTED }); // eslint-disable-line react/no-did-update-set-state
}
return;
}
// guard ensures we are only responding to prop changes
if (this.needsUpdate) {
this.needsUpdate = false;
if (this.props.in) {
if (status === EXITING) {
this.performEnter(this.props);
} else if (status === EXITED) {
this.performEnter(this.props);
}
// Otherwise we're already entering or entered.
} else if (status === ENTERING || status === ENTERED) {
this.performExit(this.props);
}
// Otherwise we're already exited or exiting.
}
}
componentWillUnmount() {
this.cancelNextCallback();
}
nextCallback = null;
needsUpdate = false;
performEnter(props: Props) {
this.cancelNextCallback();
const node = ReactDOM.findDOMNode(this);
if (node instanceof HTMLElement) {
if (props.onEnter) {
props.onEnter(node);
}
this.performEntering(node);
}
}
performEntering(element: HTMLElement) {
this.safeSetState({ status: ENTERING }, () => {
if (this.props.onEntering) {
this.props.onEntering(element);
}
this.onTransitionEnd(element, () => {
this.safeSetState({ status: ENTERED }, () => {
if (this.props.onEntered) {
this.props.onEntered(element);
}
});
});
});
}
performExit(props: Props) {
this.cancelNextCallback();
const node = ReactDOM.findDOMNode(this);
if (node instanceof HTMLElement) {
// Not this.props, because we might be about to receive new props.
if (props.onExit) {
props.onExit(node);
}
this.safeSetState({ status: EXITING }, () => {
if (this.props.onExiting) {
this.props.onExiting(node);
}
this.onTransitionEnd(node, () => {
this.safeSetState({ status: EXITED }, () => {
if (this.props.onExited) {
this.props.onExited(node);
}
});
});
});
}
}
cancelNextCallback() {
if (this.nextCallback !== null) {
this.nextCallback.cancel();
this.nextCallback = null;
}
}
safeSetState(nextState: State, callback: Function) {
// This shouldn't be necessary, but there are weird race conditions with
// setState callbacks and unmounting in testing, so always make sure that
// we can cancel any pending setState callbacks after we unmount.
this.setState(nextState, this.setNextCallback(callback));
}
setNextCallback(callback: SyntheticUIEventHandler) {
let active = true;
// FIXME: These next two blocks are a real enigma for flow typing outside of weak mode.
// FIXME: I suggest we refactor - rosskevin
this.nextCallback = (event?: SyntheticUIEvent<>) => {
requestAnimationStart(() => {
if (active) {
active = false;
this.nextCallback = null;
callback(event);
}
});
};
this.nextCallback.cancel = () => {
active = false;
};
return this.nextCallback;
}
onTransitionEnd(element: HTMLElement, handler: SyntheticUIEventHandler) {
this.setNextCallback(handler);
if (element) {
addEventListener(element, transitionEndEvent, event => {
if (event.target === element && this.nextCallback) {
this.nextCallback();
}
});
setTimeout(this.nextCallback, this.getTimeout(element));
} else {
setTimeout(this.nextCallback, 0);
}
}
getTimeout(element: HTMLElement) {
let timeout;
if (this.props.onRequestTimeout && element instanceof HTMLElement) {
timeout = this.props.onRequestTimeout(element);
}
if (typeof timeout !== 'number') {
timeout = this.props.timeout;
}
return timeout;
}
render() {
const { status } = this.state;
if (status === UNMOUNTED) {
return null;
}
const {
children,
className,
in: inProp,
enteredClassName,
enteringClassName,
exitedClassName,
exitingClassName,
onEnter,
onEntering,
onEntered,
onExit,
onExiting,
onExited,
onRequestTimeout,
timeout,
transitionAppear,
unmountOnExit,
...other
} = this.props;
let transitionClassName;
if (status === EXITED) {
transitionClassName = this.props.exitedClassName;
} else if (status === ENTERING) {
transitionClassName = this.props.enteringClassName;
} else if (status === ENTERED) {
transitionClassName = this.props.enteredClassName;
} else if (status === EXITING) {
transitionClassName = this.props.exitingClassName;
}
const child = React.Children.only(children);
return React.cloneElement(child, {
className: classNames(child.props.className, className, transitionClassName),
...other,
});
}
}
export default Transition;
|
src/parser/hunter/beastmastery/modules/talents/KillerInstinct.js | sMteX/WoWAnalyzer | import React from 'react';
import SpellLink from 'common/SpellLink';
import TalentStatisticBox from 'interface/others/TalentStatisticBox';
import ItemDamageDone from 'interface/others/ItemDamageDone';
import StatisticListBoxItem from 'interface/others/StatisticListBoxItem';
import calculateEffectiveDamage from 'parser/core/calculateEffectiveDamage';
import SPELLS from 'common/SPELLS';
import Analyzer from 'parser/core/Analyzer';
import { formatNumber } from 'common/format';
const KILLER_INSTINCT_TRESHOLD = 0.35;
const KILLER_INSTINCT_CONTRIBUTION = 0.5;
/**
* Kill Command deals 50% increased damage against enemies below 35% health.
*
* Example log: https://www.warcraftlogs.com/reports/CznQpdmRFBJkjg4w/#fight=40&source=16&type=damage-done
*/
class KillerInstinct extends Analyzer {
casts = 0;
castsWithExecute = 0;
damage = 0;
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTalent(SPELLS.KILLER_INSTINCT_TALENT.id);
}
on_byPlayerPet_damage(event) {
const spellId = event.ability.guid;
if (spellId !== SPELLS.KILL_COMMAND_DAMAGE_BM.id) {
return;
}
this.casts++;
const enemyHealthPercent = (event.hitPoints / event.maxHitPoints);
if (enemyHealthPercent <= KILLER_INSTINCT_TRESHOLD) {
this.castsWithExecute++;
const traitDamage = calculateEffectiveDamage(event, KILLER_INSTINCT_CONTRIBUTION);
this.damage += traitDamage;
}
}
statistic() {
return (
<TalentStatisticBox
talent={SPELLS.KILLER_INSTINCT_TALENT.id}
value={(
<>
{formatNumber(this.castsWithExecute)} <small>casts at < 35% health</small>
</>
)}
tooltip={`You cast a total of ${this.casts} Kill Commands, of which ${this.castsWithExecute} were on enemies with less than 35% of their health remaining.
These ${this.castsWithExecute} casts provided you a total of ${formatNumber(this.damage)} extra damage throughout the fight.`}
/>
);
}
subStatistic() {
return (
<StatisticListBoxItem
title={<SpellLink id={SPELLS.KILLER_INSTINCT_TALENT.id} />}
value={<ItemDamageDone amount={this.damage} />}
/>
);
}
}
export default KillerInstinct;
|
frontend/src/components/Main.js | textilemuseum/spinningjenny | import React from 'react'
// components
import ConnectNavigationBar from './ConnectNavigationBar'
import EditProfile from './EditProfile'
import Login from './Login'
import NotFound from './NotFound'
import RestrictedRoute from './RestrictedRoute'
import { Route, Switch } from 'react-router-dom'
import UserProfile from './UserProfile'
import ViewTeam from './ViewTeam'
class Main extends React.Component {
render() {
return (
<div>
<ConnectNavigationBar></ConnectNavigationBar>
<Switch>
<Route path="/" exact render={ () => (<Login {...this.props} />) }/>
<RestrictedRoute {...this.props} authed={this.props.user.token.length !== 0} path='/teams/:id' component={ViewTeam} />
<RestrictedRoute {...this.props} authed={this.props.user.token.length !== 0} path='/user/edit' component={EditProfile} />
<RestrictedRoute {...this.props} authed={this.props.user.token.length !== 0} path='/user' component={UserProfile} />
<Route component={NotFound} />
</Switch>
</div>
)
}
}
export default Main
|
src/ReactBoilerplate/Scripts/routes.js | theonlylawislove/react-dot-net | import React from 'react';
import { IndexRoute, Route } from 'react-router';
import {
App,
Home,
About,
Contact,
NotFound,
Register,
Login,
ForgotPassword,
ResetPassword,
ConfirmEmail,
Manage,
ManageIndex,
ManageSecurity,
ManageChangePassword,
ManageLogins,
ManageEmail
} from './containers';
export default (store) => {
const requireLogin = (nextState, replace, cb) => {
const { auth: { user } } = store.getState();
if (!user) {
// oops, not logged in, so can't be here!
replace('/login?returnUrl=' +
encodeURIComponent(nextState.location.pathname + nextState.location.search));
}
cb();
};
return (
<Route path="/" component={App}>
{ /* Home (main) route */ }
<IndexRoute component={Home} />
{ /* Routes */ }
<Route path="about" component={About} />
<Route path="contact" component={Contact} />
<Route path="register" components={Register} />
<Route path="login" components={Login} />
<Route path="forgotpassword" components={ForgotPassword} />
<Route path="resetpassword" components={ResetPassword} />
<Route path="confirmemail" components={ConfirmEmail} />
<Route path="manage" component={Manage} onEnter={requireLogin}>
<IndexRoute component={ManageIndex} />
<Route path="security" component={ManageSecurity} />
<Route path="email" component={ManageEmail} />
<Route path="changepassword" component={ManageChangePassword} />
<Route path="logins" component={ManageLogins} />
</Route>
{ /* Catch all route */ }
<Route path="*" component={NotFound} status={404} />
</Route>
);
};
|
react-poc-main/app/components/Card/index.js | Meesayen/react-poc | /**
*
* Card
*
*/
import React from 'react';
import styles from './styles.css';
function Card(props) {
return (
<div className={styles.card}>
{props.content}
</div>
);
}
Card.propTypes = {
content: React.PropTypes.node,
};
export default Card;
|
src/pages/AboutPage.js | numieco/patriot-trading | import React from 'react'
import Header from '../components/Header'
import SideBar from './../components/SideBar'
import Footer from './../components/Footer'
import SinglePostArticle from '../components/SinglePostArticle'
export default class AboutPage extends React.Component {
render () {
return (
<div>
<Header />
<div className='wrapper'>
<div className='container about-container'>
<div className='page-title about-title'>
<h1> About </h1>
</div>
<div className='static-text'>
<p>
Patriot Trading Group was founded in 1996 and serves as a leader
in providing hard assets directly into the hands of its customers.
Patriot has flourished during this time by being a different type of
hard asset company, believing in treating every customer with honesty
and respect while providing a daily education through its radio program and website.
</p>
<p>
What separates Patriot from all others is in how conducts business.
Unlike most of the other gold and silver companies out in the market
place Patriot does NOT have any commission sales people and Patriot
does NOT make outbound calls. That’s right a sales company that
respects your privacy and never cold calls. We don’t sell our customer
information and your privacy always comes first. All of our business
comes from referrals, our radio show and our website.
</p>
<p>
Patriot also believes in educating everyone when it comes to protecting your wealth.
The radio show “Patriot Radio News Hours” is one of the longest running programs on
the radio today. We like to call it “economics with attitude” and the show provides
and entertaining spin on a world gone mad.
</p>
<p>
Our web site <a className='about-link' href='/'>AllAmericanGold.com</a> is full of articles and videos that are
updates daily to provide the latest on what is happening in the world.
Over 10,000 people a day visit our website to provide them with the news.
We like to think of our site as proving news that “comforts the disturbed”
and “disturbs the comfortable”. No matter which one you are we definitely
give you something to think about.
</p>
<p>
If you are looking for a gold company that doesn’t play games and actual
treats you fairly and you want something more than a website with some
prices on it then we are the company for you.
</p>
</div>
</div>
<div className='sidebar-container'>
<SideBar />
</div>
</div>
<Footer />
</div>
)
}
}
|
techCurriculum/ui/solutions/4.3/src/components/Title.js | AnxChow/EngineeringEssentials-group | /**
* Copyright 2017 Goldman Sachs.
* 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';
function Title() {
return (
<div>
<h1>Cards</h1>
<h2>Share your ideas</h2>
</div>
);
}
export default Title;
|
src/Badge/Badge.js | AndriusBil/material-ui | // @flow weak
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { capitalizeFirstLetter } from '../utils/helpers';
const RADIUS = 12;
export const styles = (theme: Object) => ({
root: {
position: 'relative',
display: 'inline-block',
},
badge: {
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
alignContent: 'center',
alignItems: 'center',
position: 'absolute',
top: -RADIUS,
right: -RADIUS,
fontFamily: theme.typography.fontFamily,
fontWeight: theme.typography.fontWeight,
fontSize: RADIUS,
width: RADIUS * 2,
height: RADIUS * 2,
borderRadius: '50%',
backgroundColor: theme.palette.color,
color: theme.palette.textColor,
},
colorPrimary: {
backgroundColor: theme.palette.primary[500],
color: theme.palette.getContrastText(theme.palette.primary[500]),
},
colorAccent: {
backgroundColor: theme.palette.secondary.A200,
color: theme.palette.getContrastText(theme.palette.secondary.A200),
},
});
function Badge(props) {
const { badgeContent, classes, className: classNameProp, color, children, ...other } = props;
const className = classNames(classes.root, classNameProp);
const badgeClassName = classNames(classes.badge, {
[classes[`color${capitalizeFirstLetter(color)}`]]: color !== 'default',
});
return (
<div className={className} {...other}>
{children}
<span className={badgeClassName}>{badgeContent}</span>
</div>
);
}
Badge.propTypes = {
/**
* The content rendered within the badge.
*/
badgeContent: PropTypes.node.isRequired,
/**
* The badge will be added relative to this node.
*/
children: PropTypes.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color: PropTypes.oneOf(['default', 'primary', 'accent']),
};
Badge.defaultProps = {
color: 'default',
};
export default withStyles(styles, { name: 'MuiBadge' })(Badge);
|
frontend/app/js/containers/rules_v2/index.js | serverboards/serverboards | import React from 'react'
import connect from '../connect'
import View from 'app/components/rules_v2'
import i18n from 'app/utils/i18n'
import { rules_v2_list, rules_v2_list_clear } from 'app/actions/rules_v2'
import rpc from 'app/rpc'
import Flash from 'app/flash'
export default connect({
state(state, props){
return {
rules: state.rules_v2.rules,
updateActive: (uuid, is_active) => {
// console.log("Update active?", uuid, is_active)
rpc.call("rules_v2.update", [uuid, {is_active}])
.then( () => Flash.success(
is_active ?
i18n("Rule activated succesfully.") :
i18n("Rule deactivated successfully"))
)
.catch( () => Flash.error(i18n("Error activating rule")) )
},
onRemoveRule(uuid){
rpc.call("rules_v2.delete", [uuid])
.then(() => Flash.success(i18n("Rule removed")))
.catch(Flash.error)
}
}
},
store_enter(state, props){
return [
() => rules_v2_list(state.project.current)
]
},
store_exit(){
return [
rules_v2_list_clear
]
},
subscriptions(state, props){
let subs = []
if (props.project){
subs.push(`rules_v2.updated[${props.project.shortname}]`)
subs.push(`rules_v2.created[${props.project.shortname}]`)
}
return subs
},
loading(state){
if (!state.rules_v2.rules)
return i18n("Rules")
}
})(View)
|
docs/client/components/pages/Counter/CustomCounterEditor/index.js | koaninc/draft-js-plugins | import React, { Component } from 'react';
import Editor, { createEditorStateWithText } from 'draft-js-plugins-editor'; // eslint-disable-line import/no-unresolved
import createCounterPlugin from 'draft-js-counter-plugin'; // eslint-disable-line import/no-unresolved
import editorStyles from './editorStyles.css';
import counterStyles from './counterStyles.css';
const theme = {
counter: counterStyles.counter,
counterOverLimit: counterStyles.counterOverLimit,
};
const counterPlugin = createCounterPlugin({ theme });
const { CharCounter, WordCounter, LineCounter, CustomCounter } = counterPlugin;
const plugins = [counterPlugin];
const text = `This editor has counters below!
Try typing here and watch the numbers go up. 🙌
Note that the color changes when you pass one of the following limits:
- 200 characters
- 30 words
- 10 lines
`;
export default class CustomCounterEditor extends Component {
state = {
editorState: createEditorStateWithText(text),
};
onChange = (editorState) => {
this.setState({ editorState });
};
focus = () => {
this.editor.focus();
};
// eslint-disable-next-line class-methods-use-this
customCountFunction(str) {
const wordArray = str.match(/\S+/g); // matches words according to whitespace
return wordArray ? wordArray.length : 0;
}
render() {
return (
<div>
<div className={editorStyles.editor} onClick={this.focus}>
<Editor
editorState={this.state.editorState}
onChange={this.onChange}
plugins={plugins}
ref={(element) => { this.editor = element; }}
/>
</div>
<div><CharCounter limit={200} /> characters</div>
<div><WordCounter limit={30} /> words</div>
<div><LineCounter limit={10} /> lines</div>
<div>
<CustomCounter limit={40} countFunction={this.customCountFunction} />
<span> words (custom function)</span>
</div>
<br />
<br />
</div>
);
}
}
|
native/app/components/ListPanelLoading.js | cedricium/notes |
import React from 'react';
import { View, ProgressBarAndroid } from 'react-native';
import { COLOR_NOTES_BLUE } from '../utils/constants';
class ListPanelLoading extends React.Component {
render() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<ProgressBarAndroid color={COLOR_NOTES_BLUE} styleAttr="Inverse" />
</View>
);
}
}
export default ListPanelLoading;
|
client/src/App.js | m-m-k/philosophy | import React from 'react';
import {Form, Button, FormControl, FormGroup, ControlLabel, Navbar} from 'react-bootstrap';
class App extends React.Component {
constructor() {
super();
this.state = {
value: '',
path:[],
found: false
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.getData = this.getData.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value.replace("https://en.wikipedia.org/wiki/", "")});
}
handleSubmit(event) {
this.getData();
event.preventDefault();
}
getData() {
fetch('/v1/api/' + this.state.value)
.then(result => result.json())
.then(res => this.setState({path: res.path, found: res.found, loop: res.loop, page: res.page, count: res.count}))
console.log(this.state.path);
}
isFound() {
if(this.state.found) {
return(
<div>
<h3>You Found Philosophy!</h3>
<h4>Hops: {this.state.count}</h4>
<h4>Path: </h4>
</div>
)
} else {
if(this.state.loop) {
return(<h3>Loop found</h3>)
}else {
if(this.state.page){
return(<h3>Unable to Find Page</h3>)
}
}
}
}
render () {
return (
<div>
<Navbar brand="Matt" fixedTop inverse>
<Navbar.Header>
<Navbar.Brand>
<strong>Getting to Philosophy</strong>
</Navbar.Brand>
</Navbar.Header>
</Navbar>
<div>
<form onSubmit={this.handleSubmit}>
<label>
Enter a page:
<input type="text" value={this.state.value} onChange={this.handleChange} />
</label>
<input type="submit" value="Submit" />
</form>
</div>
{this.isFound()}
{this.state.path.map(path =>
<div> {path} </div>)}
</div>
);
}
}
export default App;
|
src/entry/secret.js | liaozhongwu95/blog | import React from 'react'
import ReactDOM from 'react-dom'
import Secret from '../page/secret'
var props = window.APP_PROPS
ReactDOM.render(<Secret {...props}/>, document.getElementById("app")) |
src/web/forms/fields/SubformList/Row.js | asha-nepal/AshaFusionCross | /**
* Copyright 2017 Yuichiro Tsuchiya
*
* 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.
*/
/* @flow */
import React from 'react';
import classNames from 'classnames';
import _get from 'lodash.get';
import type { FormFieldDefinition } from '.';
import { checkVisibility } from '../../utils';
import { TextInputComponent } from '../TextInput';
import { CheckboxComponent } from '../Checkbox';
import { RadioGroupComponent } from '../RadioGroup';
import { SelectComponent } from '../Select';
import fieldify from '../common/fieldify';
// TODO: 共通化
export const fieldComponents = {
textinput: fieldify(TextInputComponent),
check: fieldify(CheckboxComponent),
radio: fieldify(RadioGroupComponent),
select: fieldify(SelectComponent),
};
export default ({
value,
fields,
onChange,
onRemoveItemRequested,
readonly,
}: {
value: Object | string,
fields: Array<FormFieldDefinition>,
onChange?: (path: ?string, newValue: Object) => void,
onRemoveItemRequested?: () => void,
readonly?: boolean,
}) => {
let _value = {};
if (typeof value === 'string') {
// MultiInputからの移行.primary=trueのfieldに当てはめる
const primaryField = fields.find(f => f.primary);
if (primaryField) {
_value[primaryField.field] = value;
}
} else {
_value = value;
}
return (
<div
className="panel-block"
style={{ display: 'block' }} // Workaround: https://github.com/jgthms/bulma/issues/812
>
<div className="columns is-mobile">
<div className="column">
<div className="columns is-mobile is-multiline is-variable is-1">
{fields.map((field, i) => {
if (typeof field.show !== 'undefined'
&& !checkVisibility(_value, null, field.show)) {
return null;
} else if (typeof field.hide !== 'undefined'
&& checkVisibility(_value, null, field.hide)) {
return null;
}
const component = typeof field.class === 'string'
? fieldComponents[field.class] : field.class;
const element = React.createElement(component, {
...field,
readonly,
size: 'small',
value: _get(_value, field.field, field.defaultValue),
onChange: (v => {
if (!onChange) { return; }
onChange(field.field, v);
}),
});
return (
<div
key={i}
className={classNames(
'column',
{ 'is-narrow': i !== fields.length - 1 }
)}
style={field.subformstyle}
>
{element}
</div>
);
})}
</div>
</div>
{onRemoveItemRequested &&
<div
className="column is-narrow"
>
<a
className="delete"
onClick={e => {
e.preventDefault();
if (onRemoveItemRequested) onRemoveItemRequested();
}}
/>
</div>
}
</div>
</div>
);
};
|
src/components/Nav.js | RucaLove/GameifyYoSummah | import React from 'react';
import {Button, Icon, SideNav, SideNavItem} from 'react-materialize';
const Nav = ({
}) => {
return (
<SideNav
trigger={<Button>SIDE NAV DEMO</Button>}
options={{ closeOnClick: true }}
>
<SideNavItem userView
user={{
background: 'img/background.jpg',
image: 'img/yuna.jpg',
name: 'John Doe',
email: '[email protected]'
}}
/>
<SideNavItem subheader>Event Choices</SideNavItem>
<SideNavItem href='#!icon' icon='cloud'>First Link With Icon</SideNavItem>
<SideNavItem href='#!second'>Second Link</SideNavItem>
<SideNavItem divider />
<SideNavItem subheader>Results</SideNavItem>
<SideNavItem waves href='#!third'>Third Link With Waves</SideNavItem>
</SideNav>
)
}
export default Nav
|
test/helpers/shallowRenderHelper.js | icancy/test-gallery-react | /**
* Function to get the shallow output for a given component
* As we are using phantom.js, we also need to include the fn.proto.bind shim!
*
* @see http://simonsmith.io/unit-testing-react-components-without-a-dom/
* @author somonsmith
*/
import React from 'react';
import TestUtils from 'react-addons-test-utils';
/**
* Get the shallow rendered component
*
* @param {Object} component The component to return the output for
* @param {Object} props [optional] The components properties
* @param {Mixed} ...children [optional] List of children
* @return {Object} Shallow rendered output
*/
export default function createComponent(component, props = {}, ...children) {
const shallowRenderer = TestUtils.createRenderer();
shallowRenderer.render(React.createElement(component, props, children.length > 1 ? children : children[0]));
return shallowRenderer.getRenderOutput();
}
|
src/svg-icons/places/smoke-free.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let PlacesSmokeFree = (props) => (
<SvgIcon {...props}>
<path d="M2 6l6.99 7H2v3h9.99l7 7 1.26-1.25-17-17zm18.5 7H22v3h-1.5zM18 13h1.5v3H18zm.85-8.12c.62-.61 1-1.45 1-2.38h-1.5c0 1.02-.83 1.85-1.85 1.85v1.5c2.24 0 4 1.83 4 4.07V12H22V9.92c0-2.23-1.28-4.15-3.15-5.04zM14.5 8.7h1.53c1.05 0 1.97.74 1.97 2.05V12h1.5v-1.59c0-1.8-1.6-3.16-3.47-3.16H14.5c-1.02 0-1.85-.98-1.85-2s.83-1.75 1.85-1.75V2c-1.85 0-3.35 1.5-3.35 3.35s1.5 3.35 3.35 3.35zm2.5 7.23V13h-2.93z"/>
</SvgIcon>
);
PlacesSmokeFree = pure(PlacesSmokeFree);
PlacesSmokeFree.displayName = 'PlacesSmokeFree';
PlacesSmokeFree.muiName = 'SvgIcon';
export default PlacesSmokeFree;
|
step7-unittest/node_modules/react-router/modules/Redirect.js | jintoppy/react-training | import React from 'react'
import invariant from 'invariant'
import { createRouteFromReactElement } from './RouteUtils'
import { formatPattern } from './PatternUtils'
import { falsy } from './PropTypes'
const { string, object } = React.PropTypes
/**
* A <Redirect> is used to declare another URL path a client should
* be sent to when they request a given URL.
*
* Redirects are placed alongside routes in the route configuration
* and are traversed in the same manner.
*/
const Redirect = React.createClass({
statics: {
createRouteFromReactElement(element) {
const route = createRouteFromReactElement(element)
if (route.from)
route.path = route.from
route.onEnter = function (nextState, replace) {
const { location, params } = nextState
let pathname
if (route.to.charAt(0) === '/') {
pathname = formatPattern(route.to, params)
} else if (!route.to) {
pathname = location.pathname
} else {
let routeIndex = nextState.routes.indexOf(route)
let parentPattern = Redirect.getRoutePattern(nextState.routes, routeIndex - 1)
let pattern = parentPattern.replace(/\/*$/, '/') + route.to
pathname = formatPattern(pattern, params)
}
replace({
pathname,
query: route.query || location.query,
state: route.state || location.state
})
}
return route
},
getRoutePattern(routes, routeIndex) {
let parentPattern = ''
for (let i = routeIndex; i >= 0; i--) {
const route = routes[i]
const pattern = route.path || ''
parentPattern = pattern.replace(/\/*$/, '/') + parentPattern
if (pattern.indexOf('/') === 0)
break
}
return '/' + parentPattern
}
},
propTypes: {
path: string,
from: string, // Alias for path
to: string.isRequired,
query: object,
state: object,
onEnter: falsy,
children: falsy
},
/* istanbul ignore next: sanity check */
render() {
invariant(
false,
'<Redirect> elements are for router configuration only and should not be rendered'
)
}
})
export default Redirect
|
src/App.js | cernanb/personal-chef-react-app | import React, { Component } from 'react';
import './App.css';
import { css } from 'glamor';
import styled from 'styled-components';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { Container } from 'semantic-ui-react';
import Nav from './components/Nav';
import Home from './views/Home';
import HouseholdsContainer from './containers/HouseholdsContainer';
import Background from './images/pexels-photo-349609.jpeg';
import Signup from './components/Signup';
import Login from './views/Login';
import { authenticate, authenticationFailure, logout } from './redux/modules/Auth/actions';
import NewHousehold from './components/NewHousehold';
import MealsContainer from './containers/MealsContainer';
import Loading from './components/Loading';
import { fetchMeals } from './redux/modules/Meals/actions';
// const rules = css({
// width: '100%',
// height: 'auto',
// // position: 'fixed',
// top: 55,
// left: 0,
// minHeight: '100%',
// minWidth: '1024px',
// background: `url(${Background}) no-repeat center center fixed`,
// backgroundSize: 'cover',
// display: 'flex',
// justifyContent: 'center',
// color: '#ecf0f1',
// textShadow: '1px 1px #777',
// });
const BackgroundImage = styled.div`
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
z-index: -1;
opacity: 0.7;
background: url(${Background}) no-repeat center center fixed;
background-size: cover;
`
class App extends Component {
constructor(props) {
super(props);
props.fetchMeals();
}
componentDidMount() {
const token = localStorage.getItem('token');
const { authenticate, authenticationFailure } = this.props;
if (token) {
authenticate();
} else {
authenticationFailure();
}
}
render() {
const { loading, logout } = this.props;
if (loading) {
return <Loading />;
}
return (
<Router>
<div>
<BackgroundImage></BackgroundImage>
<Container text>
<Nav logout={logout} />
</Container>
<div>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/households/new" component={NewHousehold} />
<Route path="/meals" component={MealsContainer} />
<Route path="/households" component={HouseholdsContainer} />
<Route path="/signup" component={Signup} />
<Route path="/login" component={Login} />
</Switch>
</div>
</div>
</Router>
);
}
}
App.propTypes = {
fetchMeals: PropTypes.func,
authenticate: PropTypes.func,
authenticationFailure: PropTypes.func,
loading: PropTypes.bool,
logout: PropTypes.func,
};
export default connect(
state => ({
loading: state.auth.loading,
}),
{
authenticate,
authenticationFailure,
logout,
fetchMeals,
}
)(App);
|
app/javascript/mastodon/features/ui/components/boost_modal.js | esetomo/mastodon | import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import Button from '../../../components/button';
import StatusContent from '../../../components/status_content';
import Avatar from '../../../components/avatar';
import RelativeTimestamp from '../../../components/relative_timestamp';
import DisplayName from '../../../components/display_name';
import ImmutablePureComponent from 'react-immutable-pure-component';
const messages = defineMessages({
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
});
@injectIntl
export default class BoostModal extends ImmutablePureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
status: ImmutablePropTypes.map.isRequired,
onReblog: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
componentDidMount() {
this.button.focus();
}
handleReblog = () => {
this.props.onReblog(this.props.status);
this.props.onClose();
}
handleAccountClick = (e) => {
if (e.button === 0) {
e.preventDefault();
this.props.onClose();
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
}
}
setRef = (c) => {
this.button = c;
}
render () {
const { status, intl } = this.props;
return (
<div className='modal-root__modal boost-modal'>
<div className='boost-modal__container'>
<div className='status light'>
<div className='boost-modal__status-header'>
<div className='boost-modal__status-time'>
<a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
</div>
<a onClick={this.handleAccountClick} href={status.getIn(['account', 'url'])} className='status__display-name'>
<div className='status__avatar'>
<Avatar account={status.get('account')} size={48} />
</div>
<DisplayName account={status.get('account')} />
</a>
</div>
<StatusContent status={status} />
</div>
</div>
<div className='boost-modal__action-bar'>
<div><FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <i className='fa fa-retweet' /></span> }} /></div>
<Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} ref={this.setRef} />
</div>
</div>
);
}
}
|
src/js/container/Layout.js | tpucci/jobads-webapp | import React from 'react';
import ScrollSpy from './ScrollSpy';
import Menu from './Menu';
export default class Layout extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="mainLayout">
<ScrollSpy>
<Menu location={this.props.location}/>
</ScrollSpy>
{this.props.children}
</div>
);
}
} |
src/svg-icons/action/visibility-off.js | ruifortes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionVisibilityOff = (props) => (
<SvgIcon {...props}>
<path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"/>
</SvgIcon>
);
ActionVisibilityOff = pure(ActionVisibilityOff);
ActionVisibilityOff.displayName = 'ActionVisibilityOff';
ActionVisibilityOff.muiName = 'SvgIcon';
export default ActionVisibilityOff;
|
src/routes.js | ecovirtual/dclv-calculator | import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './components/App';
// import HomePage from './components/HomePage';
import CalculatorPage from './containers/CalculatorPage'; // eslint-disable-line import/no-named-as-default
import AboutPage from './components/AboutPage';
import NotFoundPage from './components/NotFoundPage';
export default (
<Route path="/" component={App}>
<IndexRoute component={CalculatorPage}/>
// <Route path="fuel-dclv" component={CalculatorPage}/>
<Route path="about" component={AboutPage}/>
<Route path="*" component={NotFoundPage}/>
</Route>
);
|
app/components/H1/index.js | simon-johansson/PB-labz | import React from 'react';
import styles from './styles.css';
function H1(props) {
return (
<h1 className={styles.heading1} {...props} />
);
}
export default H1;
|
tripwreck_mobile/src/components/Search_Components/SearchButton.js | CupNCup/tripwreck | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { searchRestaurant } from '../../actions';
import { Button, CardSection } from '../common';
class SearchButton extends Component {
onButtonPress() {
const { searchInput } = this.props;
this.props.searchRestaurant(searchInput);
}
render() {
return (
<CardSection>
<Button
onPress={this.onButtonPress.bind(this)}
>
Search
</Button>
</CardSection>
)
}
};
const mapStateToProps = (state) => {
const { searchInput } = state;
return searchInput;
}
export default connect(mapStateToProps, { searchRestaurant })(SearchButton);
|
src/pages/family-planning/FamilyPlanning.js | RHoKAustralia/madapt-react-frontend | import React, { Component } from 'react';
import CardGrid from '../../components/cardgrid/CardGrid';
import Card from '../../components/card/Card';
import BirthSpacingIcon from '../../images/icons/familyplanning/birthspacing.png'
import ContraceptionIcon from '../../images/icons/familyplanning/contraception-types.png'
import FertilityIcon from '../../images/icons/familyplanning/fertility.png'
import FamilyPlanningIcon from '../../images/icons/familyplanning/family-planning.png'
import UnplannedPregnancyIcon from '../../images/icons/familyplanning/unplanned-pregnancy.png'
class FamilyPlanning extends Component {
componentDidMount() {
window.analytics.page();
}
render() {
return (
<CardGrid>
<Card
imgSrc={BirthSpacingIcon}
titleText="Birth Spacing and Planning"
linkUrl="/family-planning/birth-spacing" />
<Card
imgSrc={ContraceptionIcon}
titleText="Contraception"
linkUrl="/family-planning/contraception" />
<Card
imgSrc={FertilityIcon}
titleText="Fertility"
linkUrl="#" />
<Card
imgSrc={FamilyPlanningIcon}
titleText="Family Planning"
linkUrl="#" />
<Card
imgSrc={UnplannedPregnancyIcon}
titleText="Unplanned Pregnancy"
linkUrl="#" />
</CardGrid>
)
}
}
export default FamilyPlanning
|
src/js/components/tag-selector.js | donnierayjones/dayone-js-html | import React from 'react';
import ReactDOM from 'react-dom';
import $ from 'jquery';
export default class TagSelector extends React.Component {
constructor(props) {
super(props);
this.state = {
value: ""
};
this.onChange = this.onChange.bind(this);
}
onChange() {
this.setState({
value: $('input:checked', ReactDOM.findDOMNode(this)).val()
});
this.props.onChange();
}
render() {
return (
<tr>
<td>
{this.props.tagName}
</td>
<td className="text-center">
<input type="radio" onChange={this.onChange} name={this.props.tagName} value="" checked={this.state.value == ""} />
</td>
<td className="text-center">
<input type="radio" onChange={this.onChange} name={this.props.tagName} value="include" checked={this.state.value == "include"} />
</td>
<td className="text-center">
<input type="radio" onChange={this.onChange} name={this.props.tagName} value="exclude" checked={this.state.value == "exclude"} />
</td>
</tr>
);
}
};
|
src/components/Menu/components/Header.js | MityaDSCH/MityaDSCH.github.io | import React from 'react'
import Isvg from 'react-inlinesvg'
import { IndexLink, Link } from 'react-router'
import classes from '../styles/Header.scss'
import EmbeddingLogo from '../assets/embeddingLogo.svg'
import FallbackLogo from '../assets/logo.svg'
const p = React.PropTypes
export default class Header extends React.Component {
static propTypes = {
path: p.string.isRequired
}
constructor () {
super()
this.scrollableRoutes = [
'/about',
'/projects'
]
}
render () {
const scrollable = this.scrollableRoutes.filter(route =>
this.props.path.indexOf(route) !== -1
).length > 0
return (
<header
className={classes.header +
(scrollable ? ' ' + classes.scrollable : '')}>
<IndexLink to='/'
className={classes.headerLink}
activeClassName={classes.activeRoute}>
<nav role='navigation'>
<Isvg
src={EmbeddingLogo}
wrapper={React.DOM.div}
className={classes.logoContainer}>
{/* Fallback link */}
<img
alt='Myles Gearon Logo'
src={FallbackLogo} />
</Isvg>
</nav>
</IndexLink>
<Link
to='/about'
className={classes.headerLink + ' ' + classes.textLink}
activeClassName={classes.activeRoute}>
About
</Link>
<Link
to='/projects'
className={classes.headerLink + ' ' + classes.textLink}
activeClassName={classes.activeRoute}>
Projects
</Link>
<Link
to='/contact'
className={classes.headerLink + ' ' + classes.textLink}
activeClassName={classes.activeRoute}>
Contact
</Link>
</header>
)
}
}
|
demo/src/components/field-views/example3-text-field-view.js | tuantle/hypertoxin | 'use strict'; // eslint-disable-line
import { Ht } from 'hypertoxin';
import React from 'react';
import ReactNative from 'react-native'; // eslint-disable-line
import PropTypes from 'prop-types';
// import DefaultTheme from '../../themes/default-theme';
const {
RowLayout,
ColumnLayout,
TextField,
FlatButton,
AreaButton,
IconImage,
HeadlineText,
InfoText
} = Ht;
const RegistrationTextFieldView = (props) => {
const {
shade
} = props;
return (
<RowLayout
shade = { shade }
roomAlignment = 'stretch'
contentTopRoomAlignment = 'center'
contentTopRoomAlignment = 'center'
scrollable = { true }
margin = {{
horizontal: 10
}}
>
<HeadlineText room = 'content-top' > TextField </HeadlineText>
<HeadlineText room = 'content-top' > Registration Example </HeadlineText>
<TextField
room = 'content-middle'
hint = '[email protected]'
label = 'EMAIL'
inputType = 'email-address'
>
<IconImage
room = 'content-left'
source = 'email'
/>
<FlatButton
room = 'content-right'
overlay = 'transparent'
action = 'clear'
corner = 'circular'
>
<IconImage
room = 'content-middle'
source = 'cancel'
/>
</FlatButton>
</TextField>
<ColumnLayout
room = 'content-middle'
roomAlignment = 'center'
contentLeftRoomAlignment = 'stretch'
contentRightRoomAlignment = 'stretch'
>
<TextField
room = 'content-left'
initialValue = 'Fantastic'
label = 'FIRST NAME'
charLimit = { 10 }
>
<IconImage
room = 'content-left'
source = 'profile'
/>
<FlatButton
room = 'content-right'
overlay = 'transparent'
action = 'clear'
corner = 'circular'
>
<IconImage
room = 'content-middle'
source = 'cancel'
/>
</FlatButton>
</TextField>
<TextField
room = 'content-right'
initialValue = 'Fox'
label = 'LAST NAME'
charLimit = { 10 }
>
<FlatButton
room = 'content-right'
overlay = 'transparent'
action = 'clear'
corner = 'circular'
>
<IconImage
room = 'content-middle'
source = 'cancel'
/>
</FlatButton>
</TextField>
</ColumnLayout>
<ColumnLayout
room = 'content-middle'
roomAlignment = 'stretch'
contentMiddleRoomAlignment = 'stretch'
>
<TextField
room = 'content-middle'
label = 'AGE'
inputType = 'numeric'
>
<FlatButton
room = 'content-right'
overlay = 'transparent'
action = 'clear'
corner = 'circular'
>
<IconImage
room = 'content-middle'
source = 'cancel'
/>
</FlatButton>
</TextField>
<TextField
room = 'content-middle'
label = 'GENDER'
initialValue = 'NA'
selectableValues = {[
`NA`,
`MALE`,
`FEMALE`
]}
renderSelectableItem = {(item, onPressSelect) => {
return (
<AreaButton
shade = { shade }
overlay = 'transparent'
size = 'small'
onPress = {() => onPressSelect(item)}
contentRightRoomAlignment = 'start'
margin = {{
horizontal: 10
}}
>
<ColumnLayout
room = 'content-left'
roomAlignment = 'center'
>
<IconImage
room = 'content-left'
source = 'profile'
/>
<InfoText room = 'content-right' indentation = { 10 }>{ item.value }</InfoText>
</ColumnLayout>
{
item.selected ? <IconImage
room = 'content-right'
source = 'check'
/> : null
}
</AreaButton>
);
}}
>
<FlatButton
room = 'content-right'
overlay = 'transparent'
action = 'clear'
corner = 'circular'
>
<IconImage
room = 'content-middle'
source = 'cancel'
/>
</FlatButton>
<FlatButton
room = 'content-right'
overlay = 'transparent'
action = 'show-selection'
corner = 'circular'
>
<IconImage
room = 'content-middle'
source = 'collapse'
/>
</FlatButton>
<FlatButton
room = 'content-right'
overlay = 'transparent'
action = 'hide-selection'
corner = 'circular'
>
<IconImage
room = 'content-middle'
source = 'expand'
/>
</FlatButton>
</TextField>
</ColumnLayout>
<TextField
room = 'content-middle'
label = 'PHONE NUMBER'
inputType = 'phone-pad'
charLimit = { 12 }
onReformat = {(value) => {
return value.split(``).filter((char) => char !== `-`).map((char, index) => {
return index === 2 || index === 5 ? `${char}-` : char;
}).join(``);
}}
>
<FlatButton
room = 'content-right'
overlay = 'transparent'
action = 'clear'
corner = 'circular'
>
<IconImage
room = 'content-middle'
source = 'cancel'
/>
</FlatButton>
</TextField>
</RowLayout>
);
};
RegistrationTextFieldView.propTypes = {
Theme: PropTypes.object,
shade: PropTypes.oneOf([ `light`, `dark` ])
};
export default RegistrationTextFieldView;
|
fall-colors/components/default/float.js | mathisonian/idyll | import React from 'react';
class Float extends React.PureComponent {
render() {
return (
<div className={`float ${this.props.position}`} style={{float: this.props.position, width: this.props.width || '50%'}}>
{this.props.children}
</div>
);
}
}
export default Float;
|
src/index.js | jwmickey/picture-puzzle | import React from 'react';
import ReactDOM from 'react-dom';
import App from './js/components/App';
require('./less/style.less');
ReactDOM.render(<App />, document.getElementById('root'));
|
src/containers/plandetail.js | emreekd/reservationsite | import React, { Component } from 'react';
class PlanDetail extends Component{
constructor(props) {
super(props);
}
render() {
return (
<div>asdas</div>
);
}
}
export default PlanDetail; |
frontend/src/components/Add.js | mqklin/results | import React from 'react';
export default class extends React.Component {
constructor(options) {
super(options);
this.state = {"rate": "1"};
}
addArticle() {
this.props.controller.addArticle(this.state);
}
inputChange(e) {
this.setState({[e.target.getAttribute("data-field")]: e.target.value});
}
render() {
return (
<div className="add">
<div className="add__form">
<div className="add__field">
<span className="add__field__label">Ваше имя</span>
<input type="text" data-field="name" onChange={this.inputChange.bind(this)}/>
<span className="add__field__helper"/>
</div>
<div className="add__field">
<span className="add__field__label">Ссылка на статью</span>
<input type="text" data-field="url" onChange={this.inputChange.bind(this)}/>
<span className="add__field__helper"/>
</div>
<div className="add__field">
<span className="add__field__label">Категории (через пробел)</span>
<input type="text" data-field="categories" onChange={this.inputChange.bind(this)}/>
<span className="add__field__helper"/>
</div>
<div className="add__field">
<span className="add__field__label">Ключевые слова (через пробел)</span>
<input type="text" data-field="keywords" onChange={this.inputChange.bind(this)}/>
<span className="add__field__helper"/>
</div>
<div className="add__field">
<span className="add__field__label">Оценка</span>
<input type="range" data-field="rate" min="1" max="10" defaultValue="1" onChange={this.inputChange.bind(this)}/>
<span className="add__field__helper">{this.state.rate}/10</span>
</div>
</div>
<button type="button" className="add__btn" onClick={this.addArticle.bind(this)}>Добавить</button>
</div>
)
}
} |
src/svg-icons/maps/map.js | hwo411/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsMap = (props) => (
<SvgIcon {...props}>
<path d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM15 19l-6-2.11V5l6 2.11V19z"/>
</SvgIcon>
);
MapsMap = pure(MapsMap);
MapsMap.displayName = 'MapsMap';
MapsMap.muiName = 'SvgIcon';
export default MapsMap;
|
src/common/_navigation_component.js | Bilprospekt/bilprospekt-ui | import React, { Component } from 'react';
var NavigationComponent = React.createClass({
componentDidMount() {
var that = this;
$('#navigation-wrapper ul:first-of-type li').click(function(){
if ($(this).hasClass('dropdown')) {
$(this).toggleClass('show-children');
} else {
$(this).siblings().removeClass('selected');
$(this).addClass('selected');
that._closeNav();
}
});
},
_closeNav() {
$('#navigation-wrapper').removeClass('visible');
$('#site-overflow-holder').removeClass('navigation-visible');
$('#header-wrapper .open').toggleClass('closed open');
},
render() {
// Highlights the navigation
var indexClass = (this.props.view === 'index') ? 'selected' : null ;
var listClass = (this.props.view === 'list') ? 'selected' : null ;
var adminClass = (this.props.view === 'admin') ? 'selected' : null ;
var settingsClass = (this.props.view === 'settings') ? 'selected' : null ;
return (
<div id='navigation-wrapper'>
<div className='nav-top'>
<p className='logo-text'>Bilprospekt</p>
</div>
<div className='navigation-slider'>
<ul>
<p>Hedin Toolbox</p>
<a href='/'><li className={indexClass}><i className='fa fa-wrench' /><span>Verkstad</span></li></a>
<a href='/list'><li className={listClass}><i className='fa fa-align-left' /><span>Listvy</span></li></a>
<a href='/settings'><li className={settingsClass}><i className='fa fa-gear' /><span>Inställningar</span></li></a>
<li className='dropdown'><i className='fa fa-shield' /><span>Admin</span><i className='fa fa-caret-right' />
<ul>
<a href='/admin'><li className={adminClass}><span>Målsättning</span></li></a>
<a href='/admin2'><li><span>Användare</span></li></a>
</ul>
</li>
</ul>
<ul>
<p>Allmänt</p>
<li><i className='fa fa-heartbeat' /><span>Support</span></li>
<li><i className='fa fa-sign-out' /><span>Logga ut</span></li>
</ul>
</div>
</div>
);
}
});
module.exports = NavigationComponent;
|
packages/generator-electron/template/src/renderer/index.js | my-dish/dish | // @flow
import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import App from './containers';
import 'normalize.css';
const rootEl = document.getElementById('root');
const render = () => {
ReactDOM.render((
<AppContainer>
<App />
</AppContainer>),
rootEl
);
};
render();
if (module.hot) {
module.hot.accept('./containers', () => {
render();
});
}
|
examples/simple.js | xiefei89/react-transformable-div | import React from 'react'
import ReactDOM from 'react/lib/ReactDOM'
import TransformableDiv from '../index.jsx'
class Test extends React.Component {
state = {
zoom: 0,
wrapTopOffset: 0,
wrapLeftOffset: 0,
wrapSize: {
width: 960,
height: 540
},
rotate: 0
}
render() {
const {state} = this
return (
<div style={{margin: 20}}>
<ul>
<li>Wheel up to zoom in</li>
<li>Wheel down to zoom out</li>
<li>Drag to move</li>
<li>Click rotate to rotate</li>
</ul>
<div style={{margin: 20}}>
<button onClick={this._handleRotate.bind(this)}>Rotate</button>
</div>
<div style={{position: 'relative', overflow: 'hidden', height: 500}}>
<TransformableDiv
ref="widget"
initWidth="960"
initHeight="540"
rotateWise="anticlockwise"
onDrag={this._update.bind(this)}
onRotate={this._update.bind(this)}
onZoom={this._update.bind(this)}
enableZoom>
<img style={{width: '100%', height: '100%'}} src="http://s.cn.bing.net/az/hprichbg/rb/KansasCropCircles_ZH-CN9416992875_1920x1080.jpg"/>
</TransformableDiv>
</div>
<ul>
<li>zoom: {state.zoom}</li>
<li>rotate: {state.rotate}</li>
<li>size: {`${parseInt(state.wrapSize.width)} * ${parseInt(state.wrapSize.height)}`}</li>
<li>offset: {`${parseInt(state.wrapTopOffset)}, ${parseInt(state.wrapLeftOffset)}`}</li>
</ul>
</div>
)
}
_update(s) {
this.setState({
...s
})
}
_handleRotate() {
this.refs.widget && this.refs.widget.rotate()
}
}
ReactDOM.render(<Test />, document.getElementById('__react-content'))
|
src/components/app.js | tylergraf/react-twitter | import React from 'react';
import Catalog from './catalog/app-catalog';
import HomeTimelinePage from '../containers/HomeTimelinePage';
import Cart from './cart/app-cart';
import CatalogDetail from './product/app-catalogdetail';
import Template from './app-template';
import { Router, Route, IndexRoute } from 'react-router';
export default () => {
return (
<Router>
<Route path="/" component={ Template }>
<IndexRoute component={ HomeTimelinePage }/>
<Route path="cart" component={ Cart }/>
<Route path="item/:item" component={ CatalogDetail } />
</Route>
</Router>
);
};
|
docs/src/Anchor.js | tonylinyy/react-bootstrap | import React from 'react';
const Anchor = React.createClass({
propTypes: {
id: React.PropTypes.string
},
render() {
return (
<a id={this.props.id} href={'#' + this.props.id} className='anchor'>
<span className='anchor-icon'>#</span>
{this.props.children}
</a>
);
}
});
export default Anchor;
|
app/home.js | CKrawczyk/electron-subject-uploader | import React from 'react';
import ProjectListDisplay from './project-list';
const Home = (props, context) => {
let projectList;
if (context.user) {
projectList = <ProjectListDisplay />;
} else {
projectList = (
<div>
Please sign in to see your projects
</div>
);
}
return (
<div>
<h3 className="landing-title">
Zooniverse Subject Uploader
</h3>
{projectList}
</div>
);
};
Home.contextTypes = {
user: React.PropTypes.object,
};
export default Home;
|
src/index.js | jansplichal2/reactnd-project-readable-starter | import React from 'react';
import ReactDOM from 'react-dom'
import App from './components/App'
import {BrowserRouter} from 'react-router-dom';
import {Provider} from 'react-redux';
import store from './store';
ReactDOM.render(<BrowserRouter>
<Provider store={store}>
<App/>
</Provider>
</BrowserRouter>,
document.getElementById('root')); |
admin/client/App/screens/Home/index.js | michaelerobertsjr/keystone | /**
* The Home view is the view one sees at /keystone. It shows a list of all lists,
* grouped by their section.
*/
import React from 'react';
import { Container, Spinner } from 'elemental';
import { connect } from 'react-redux';
import Lists from './components/Lists';
import Section from './components/Section';
import AlertMessages from '../../shared/AlertMessages';
import {
loadCounts,
} from './actions';
var HomeView = React.createClass({
displayName: 'HomeView',
// When everything is rendered, start loading the item counts of the lists
// from the API
componentDidMount () {
this.props.dispatch(loadCounts());
},
getSpinner () {
if (this.props.counts && Object.keys(this.props.counts).length === 0
&& (this.props.error || this.props.loading)) {
return (
<Spinner />
);
}
return null;
},
render () {
const spinner = this.getSpinner();
return (
<Container data-screen-id="home">
<div className="dashboard-header">
<div className="dashboard-heading">{Keystone.brand}</div>
</div>
<div className="dashboard-groups">
{(this.props.error) && (
<AlertMessages
alerts={{ error: { error:
"There is a problem with the network, we're trying to reconnect...",
} }}
/>
)}
{/* Render flat nav */}
{Keystone.nav.flat ? (
<Lists
counts={this.props.counts}
lists={Keystone.lists}
spinner={spinner}
/>
) : (
<div>
{/* Render nav with sections */}
{Keystone.nav.sections.map((navSection) => {
return (
<Section key={navSection.key} id={navSection.key} label={navSection.label}>
<Lists
counts={this.props.counts}
lists={navSection.lists}
spinner={spinner}
/>
</Section>
);
})}
{/* Render orphaned lists */}
{Keystone.orphanedLists.length ? (
<Section label="Other" icon="octicon-database">
<Lists
counts={this.props.counts}
lists={Keystone.orphanedLists}
spinner={spinner}
/>
</Section>
) : null}
</div>
)}
</div>
</Container>
);
},
});
export {
HomeView,
};
export default connect((state) => ({
counts: state.home.counts,
loading: state.home.loading,
error: state.home.error,
}))(HomeView);
|
src/main/webapp/resources/js/components/echarts/heatmapcartesian.js | peterchenhdu/webbf | import React from 'react'
import echarts from 'echarts'
export default class HeatmapCartesian extends React.Component{
constructor(props){
super(props);
}
autoResize() {
var chartdiv = document.getElementById('heatmap-chart');
chartdiv.style.width = '100%';
chartdiv.style.height = '500px';
}
componentDidMount() {
this.autoResize();
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('heatmap-chart'));
var hours = ['12a', '1a', '2a', '3a', '4a', '5a', '6a',
'7a', '8a', '9a','10a','11a',
'12p', '1p', '2p', '3p', '4p', '5p',
'6p', '7p', '8p', '9p', '10p', '11p'];
var days = ['Saturday', 'Friday', 'Thursday',
'Wednesday', 'Tuesday', 'Monday', 'Sunday'];
var data = [[0,0,5],[0,1,1],[0,2,0],[0,3,0],[0,4,0],[0,5,0],[0,6,0],[0,7,0],[0,8,0],[0,9,0],[0,10,0],[0,11,2],[0,12,4],[0,13,1],[0,14,1],[0,15,3],[0,16,4],[0,17,6],[0,18,4],[0,19,4],[0,20,3],[0,21,3],[0,22,2],[0,23,5],[1,0,7],[1,1,0],[1,2,0],[1,3,0],[1,4,0],[1,5,0],[1,6,0],[1,7,0],[1,8,0],[1,9,0],[1,10,5],[1,11,2],[1,12,2],[1,13,6],[1,14,9],[1,15,11],[1,16,6],[1,17,7],[1,18,8],[1,19,12],[1,20,5],[1,21,5],[1,22,7],[1,23,2],[2,0,1],[2,1,1],[2,2,0],[2,3,0],[2,4,0],[2,5,0],[2,6,0],[2,7,0],[2,8,0],[2,9,0],[2,10,3],[2,11,2],[2,12,1],[2,13,9],[2,14,8],[2,15,10],[2,16,6],[2,17,5],[2,18,5],[2,19,5],[2,20,7],[2,21,4],[2,22,2],[2,23,4],[3,0,7],[3,1,3],[3,2,0],[3,3,0],[3,4,0],[3,5,0],[3,6,0],[3,7,0],[3,8,1],[3,9,0],[3,10,5],[3,11,4],[3,12,7],[3,13,14],[3,14,13],[3,15,12],[3,16,9],[3,17,5],[3,18,5],[3,19,10],[3,20,6],[3,21,4],[3,22,4],[3,23,1],[4,0,1],[4,1,3],[4,2,0],[4,3,0],[4,4,0],[4,5,1],[4,6,0],[4,7,0],[4,8,0],[4,9,2],[4,10,4],[4,11,4],[4,12,2],[4,13,4],[4,14,4],[4,15,14],[4,16,12],[4,17,1],[4,18,8],[4,19,5],[4,20,3],[4,21,7],[4,22,3],[4,23,0],[5,0,2],[5,1,1],[5,2,0],[5,3,3],[5,4,0],[5,5,0],[5,6,0],[5,7,0],[5,8,2],[5,9,0],[5,10,4],[5,11,1],[5,12,5],[5,13,10],[5,14,5],[5,15,7],[5,16,11],[5,17,6],[5,18,0],[5,19,5],[5,20,3],[5,21,4],[5,22,2],[5,23,0],[6,0,1],[6,1,0],[6,2,0],[6,3,0],[6,4,0],[6,5,0],[6,6,0],[6,7,0],[6,8,0],[6,9,0],[6,10,1],[6,11,0],[6,12,2],[6,13,1],[6,14,3],[6,15,4],[6,16,0],[6,17,0],[6,18,0],[6,19,0],[6,20,1],[6,21,2],[6,22,2],[6,23,6]];
data = data.map(function (item) {
return [item[1], item[0], item[2] || '-'];
});
// 绘制图表
myChart.setOption( {
title: {
text: '笛卡尔坐标系上的热力图'
},
tooltip: {
position: 'top'
},
animation: false,
grid: {
height: '50%',
y: '10%'
},
xAxis: {
type: 'category',
data: hours,
splitArea: {
show: true
}
},
yAxis: {
type: 'category',
data: days,
splitArea: {
show: true
}
},
visualMap: {
min: 0,
max: 10,
calculable: true,
orient: 'horizontal',
left: 'center',
bottom: '15%'
},
series: [{
name: 'Punch Card',
type: 'heatmap',
data: data,
label: {
normal: {
show: true
}
},
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}]
});
window.onresize = function () {
this.autoResize();
myChart.resize();
}.bind(this);
}
render() {
return (
<div id = "heatmap-chart">
</div>
);
}
}
|
node_modules/@material-ui/core/es/Grid/Grid.js | pcclarke/civ-techs | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _extends from "@babel/runtime/helpers/extends";
// A grid component using the following libs as inspiration.
//
// For the implementation:
// - http://v4-alpha.getbootstrap.com/layout/flexbox-grid/
// - https://github.com/kristoferjoseph/flexboxgrid/blob/master/src/css/flexboxgrid.css
// - https://github.com/roylee0704/react-flexbox-grid
// - https://material.angularjs.org/latest/layout/introduction
//
// Follow this flexbox Guide to better understand the underlying model:
// - https://css-tricks.com/snippets/css/a-guide-to-flexbox/
import React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import withStyles from '../styles/withStyles';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import requirePropFactory from '../utils/requirePropFactory';
const SPACINGS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
function generateGrid(globalStyles, theme, breakpoint) {
const styles = {};
GRID_SIZES.forEach(size => {
const key = `grid-${breakpoint}-${size}`;
if (size === true) {
// For the auto layouting
styles[key] = {
flexBasis: 0,
flexGrow: 1,
maxWidth: '100%'
};
return;
}
if (size === 'auto') {
styles[key] = {
flexBasis: 'auto',
flexGrow: 0,
maxWidth: 'none'
};
return;
} // Keep 7 significant numbers.
const width = `${Math.round(size / 12 * 10e7) / 10e5}%`; // Close to the bootstrap implementation:
// https://github.com/twbs/bootstrap/blob/8fccaa2439e97ec72a4b7dc42ccc1f649790adb0/scss/mixins/_grid.scss#L41
styles[key] = {
flexBasis: width,
flexGrow: 0,
maxWidth: width
};
}); // No need for a media query for the first size.
if (breakpoint === 'xs') {
Object.assign(globalStyles, styles);
} else {
globalStyles[theme.breakpoints.up(breakpoint)] = styles;
}
}
function generateGutter(theme, breakpoint) {
const styles = {};
SPACINGS.forEach(spacing => {
const themeSpacing = theme.spacing(spacing);
if (themeSpacing === 0) {
return;
}
styles[`spacing-${breakpoint}-${spacing}`] = {
margin: -themeSpacing / 2,
width: `calc(100% + ${themeSpacing}px)`,
'& > $item': {
padding: themeSpacing / 2
}
};
});
return styles;
} // Default CSS values
// flex: '0 1 auto',
// flexDirection: 'row',
// alignItems: 'flex-start',
// flexWrap: 'nowrap',
// justifyContent: 'flex-start',
export const styles = theme => _extends({
/* Styles applied to the root element */
root: {},
/* Styles applied to the root element if `container={true}`. */
container: {
boxSizing: 'border-box',
display: 'flex',
flexWrap: 'wrap',
width: '100%'
},
/* Styles applied to the root element if `item={true}`. */
item: {
boxSizing: 'border-box',
margin: '0' // For instance, it's useful when used with a `figure` element.
},
/* Styles applied to the root element if `zeroMinWidth={true}`. */
zeroMinWidth: {
minWidth: 0
},
/* Styles applied to the root element if `direction="column"`. */
'direction-xs-column': {
flexDirection: 'column'
},
/* Styles applied to the root element if `direction="column-reverse"`. */
'direction-xs-column-reverse': {
flexDirection: 'column-reverse'
},
/* Styles applied to the root element if `direction="rwo-reverse"`. */
'direction-xs-row-reverse': {
flexDirection: 'row-reverse'
},
/* Styles applied to the root element if `wrap="nowrap"`. */
'wrap-xs-nowrap': {
flexWrap: 'nowrap'
},
/* Styles applied to the root element if `wrap="reverse"`. */
'wrap-xs-wrap-reverse': {
flexWrap: 'wrap-reverse'
},
/* Styles applied to the root element if `alignItems="center"`. */
'align-items-xs-center': {
alignItems: 'center'
},
/* Styles applied to the root element if `alignItems="flex-start"`. */
'align-items-xs-flex-start': {
alignItems: 'flex-start'
},
/* Styles applied to the root element if `alignItems="flex-end"`. */
'align-items-xs-flex-end': {
alignItems: 'flex-end'
},
/* Styles applied to the root element if `alignItems="baseline"`. */
'align-items-xs-baseline': {
alignItems: 'baseline'
},
/* Styles applied to the root element if `alignContent="center"`. */
'align-content-xs-center': {
alignContent: 'center'
},
/* Styles applied to the root element if `alignContent="flex-start"`. */
'align-content-xs-flex-start': {
alignContent: 'flex-start'
},
/* Styles applied to the root element if `alignContent="flex-end"`. */
'align-content-xs-flex-end': {
alignContent: 'flex-end'
},
/* Styles applied to the root element if `alignContent="space-between"`. */
'align-content-xs-space-between': {
alignContent: 'space-between'
},
/* Styles applied to the root element if `alignContent="space-around"`. */
'align-content-xs-space-around': {
alignContent: 'space-around'
},
/* Styles applied to the root element if `justify="center"`. */
'justify-xs-center': {
justifyContent: 'center'
},
/* Styles applied to the root element if `justify="flex-end"`. */
'justify-xs-flex-end': {
justifyContent: 'flex-end'
},
/* Styles applied to the root element if `justify="space-between"`. */
'justify-xs-space-between': {
justifyContent: 'space-between'
},
/* Styles applied to the root element if `justify="space-around"`. */
'justify-xs-space-around': {
justifyContent: 'space-around'
},
/* Styles applied to the root element if `justify="space-evenly"`. */
'justify-xs-space-evenly': {
justifyContent: 'space-evenly'
}
}, generateGutter(theme, 'xs'), breakpointKeys.reduce((accumulator, key) => {
// Use side effect over immutability for better performance.
generateGrid(accumulator, theme, key);
return accumulator;
}, {}));
const Grid = React.forwardRef((props, ref) => {
const {
alignContent = 'stretch',
alignItems = 'stretch',
classes,
className: classNameProp,
component: Component = 'div',
container = false,
direction = 'row',
item = false,
justify = 'flex-start',
lg = false,
md = false,
sm = false,
spacing = 0,
wrap = 'wrap',
xl = false,
xs = false,
zeroMinWidth = false
} = props,
other = _objectWithoutPropertiesLoose(props, ["alignContent", "alignItems", "classes", "className", "component", "container", "direction", "item", "justify", "lg", "md", "sm", "spacing", "wrap", "xl", "xs", "zeroMinWidth"]);
const className = clsx(classes.root, classNameProp, container && [classes.container, spacing !== 0 && classes[`spacing-xs-${String(spacing)}`]], item && classes.item, zeroMinWidth && classes.zeroMinWidth, direction !== 'row' && classes[`direction-xs-${String(direction)}`], wrap !== 'wrap' && classes[`wrap-xs-${String(wrap)}`], alignItems !== 'stretch' && classes[`align-items-xs-${String(alignItems)}`], alignContent !== 'stretch' && classes[`align-content-xs-${String(alignContent)}`], justify !== 'flex-start' && classes[`justify-xs-${String(justify)}`], xs !== false && classes[`grid-xs-${String(xs)}`], sm !== false && classes[`grid-sm-${String(sm)}`], md !== false && classes[`grid-md-${String(md)}`], lg !== false && classes[`grid-lg-${String(lg)}`], xl !== false && classes[`grid-xl-${String(xl)}`]);
return React.createElement(Component, _extends({
className: className,
ref: ref
}, other));
});
if (process.env.NODE_ENV !== 'production') {
// can't use named function expression since the function body references `Grid`
// which would point to the render function instead of the actual component
Grid.displayName = 'ForwardRef(Grid)';
}
process.env.NODE_ENV !== "production" ? Grid.propTypes = {
/**
* Defines the `align-content` style property.
* It's applied for all screen sizes.
*/
alignContent: PropTypes.oneOf(['stretch', 'center', 'flex-start', 'flex-end', 'space-between', 'space-around']),
/**
* Defines the `align-items` style property.
* It's applied for all screen sizes.
*/
alignItems: PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'stretch', 'baseline']),
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.elementType,
/**
* If `true`, the component will have the flex *container* behavior.
* You should be wrapping *items* with a *container*.
*/
container: PropTypes.bool,
/**
* Defines the `flex-direction` style property.
* It is applied for all screen sizes.
*/
direction: PropTypes.oneOf(['row', 'row-reverse', 'column', 'column-reverse']),
/**
* If `true`, the component will have the flex *item* behavior.
* You should be wrapping *items* with a *container*.
*/
item: PropTypes.bool,
/**
* Defines the `justify-content` style property.
* It is applied for all screen sizes.
*/
justify: PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'space-between', 'space-around', 'space-evenly']),
/**
* Defines the number of grids the component is going to use.
* It's applied for the `lg` breakpoint and wider screens if not overridden.
*/
lg: PropTypes.oneOf([false, 'auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
/**
* Defines the number of grids the component is going to use.
* It's applied for the `md` breakpoint and wider screens if not overridden.
*/
md: PropTypes.oneOf([false, 'auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
/**
* Defines the number of grids the component is going to use.
* It's applied for the `sm` breakpoint and wider screens if not overridden.
*/
sm: PropTypes.oneOf([false, 'auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
/**
* Defines the space between the type `item` component.
* It can only be used on a type `container` component.
*/
spacing: PropTypes.oneOf(SPACINGS),
/**
* Defines the `flex-wrap` style property.
* It's applied for all screen sizes.
*/
wrap: PropTypes.oneOf(['nowrap', 'wrap', 'wrap-reverse']),
/**
* Defines the number of grids the component is going to use.
* It's applied for the `xl` breakpoint and wider screens.
*/
xl: PropTypes.oneOf([false, 'auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
/**
* Defines the number of grids the component is going to use.
* It's applied for all the screen sizes with the lowest priority.
*/
xs: PropTypes.oneOf([false, 'auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
/**
* If `true`, it sets `min-width: 0` on the item.
* Refer to the limitations section of the documentation to better understand the use case.
*/
zeroMinWidth: PropTypes.bool
} : void 0;
const StyledGrid = withStyles(styles, {
name: 'MuiGrid'
})(Grid);
if (process.env.NODE_ENV !== 'production') {
const requireProp = requirePropFactory('Grid');
StyledGrid.propTypes = _extends({}, StyledGrid.propTypes, {
alignContent: requireProp('container'),
alignItems: requireProp('container'),
direction: requireProp('container'),
justify: requireProp('container'),
lg: requireProp('item'),
md: requireProp('item'),
sm: requireProp('item'),
spacing: requireProp('container'),
wrap: requireProp('container'),
xs: requireProp('item'),
zeroMinWidth: requireProp('item')
});
}
export default StyledGrid; |
app/components/CodeEditor.js | dikalikatao/fil | import React from 'react';
import AceEditor from 'react-ace';
import 'brace/mode/python';
import 'brace/mode/ruby';
import 'brace/mode/javascript';
import 'brace/theme/tomorrow_night';
import {getExtension} from 'helpers';
import {byExtension} from 'interpreters';
class CodeEditor extends React.Component {
constructor(props) {
super(props)
this.state = {
buffer: props.value
};
}
componentWillReceiveProps(next) {
this.setState({
buffer: next.value
});
}
handleChange(buffer) {
if (this.props.autoSave) {
this.props.onSave(buffer);
}
this.setState({
buffer: buffer
});
this.props.onChange();
}
getMode(extension) {
return byExtension(extension).editorMode;
}
render() {
let block = "code-screen",
fileName = this.props.currentFile,
extension = getExtension(fileName),
mode = this.getMode(extension);
return (
<AceEditor
width={"auto"}
height={"100%"}
fontSize={17}
mode={mode}
theme="tomorrow_night"
ref={"editor"}
showGutter={false}
className={block + "__editor-wrapper"}
value={this.state.buffer}
highlightActiveLine={false}
editorProps={{
$blockScrolling: Infinity
}}
onChange={this.handleChange.bind(this)} />
);
}
getBuffer() {
return this.state.buffer || this.props.value;
}
}
export default CodeEditor; |
demo/card/card.js | darkyen/react-mdl | import React from 'react';
import Card, { CardTitle, CardText, CardActions, CardMenu } from '../../src/card/Card';
import Button from '../../src/Button';
import IconButton from '../../src/IconButton';
import Icon from '../../src/Icon';
class Demo extends React.Component {
render() {
return (
<div>
<p>Wide card with share menu button</p>
<Card shadowLevel={0} style={{width: '512px'}}>
<CardTitle style={{color: '#fff', height: '176px', background: 'url(http://www.getmdl.io/assets/demos/welcome_card.jpg) center / cover'}}>Welcome</CardTitle>
<CardText>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris sagittis pellentesque lacus eleifend lacinia...
</CardText>
<CardActions border={true}>
<Button colored={true}>Get Started</Button>
</CardActions>
<CardMenu style={{color: '#fff'}}>
<IconButton name="share" />
</CardMenu>
</Card>
<p>Square card</p>
<Card shadowLevel={0} style={{width: '320px', height: '320px'}}>
<CardTitle expand={true} style={{color: '#fff', background: 'url(http://www.getmdl.io/assets/demos/dog.png) bottom right 15% no-repeat #46B6AC'}}>Update</CardTitle>
<CardText>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aenan convallis.
</CardText>
<CardActions border={true}>
<Button colored={true}>View Updates</Button>
</CardActions>
</Card>
<p>Image card</p>
<Card shadowLevel={0} style={{width: '256px', height: '256px', background: 'url(http://www.getmdl.io/assets/demos/image_card.jpg) center / cover'}}>
<CardTitle expand={true} />
<CardActions style={{height: '52px', padding: '16px', background: 'rgba(0,0,0,0.2)'}}>
<span style={{color: '#fff', fontSize: '14px', fontWeight: '500'}}>
Image.jpg
</span>
</CardActions>
</Card>
<p>Event card</p>
<Card shadowLevel={0} style={{width: '256px', height: '256px', background: '#3E4EB8'}}>
<CardTitle expand={true} style={{alignItems: 'flex-start', color: '#fff'}}>
<h4 style={{marginTop: '0'}}>
Featured event:<br />
May 24, 2016<br />
7-11pm
</h4>
</CardTitle>
<CardActions border={true} style={{borderColor: 'rgba(255, 255, 255, 0.2)', display: 'flex', boxSizing: 'border-box', alignItems: 'center', color: '#fff'}}>
<Button colored={true} style={{color: '#fff'}}>Add to Calendar</Button>
<div className="mdl-layout-spacer"></div>
<Icon name="event" />
</CardActions>
</Card>
</div>
);
}
}
React.render(<Demo />, document.getElementById('app'));
|
actor-apps/app-web/src/app/components/activity/UserProfile.react.js | luoxiaoshenghustedu/actor-platform | import _ from 'lodash';
import React from 'react';
import ReactMixin from 'react-mixin';
import { IntlMixin, FormattedMessage } from 'react-intl';
import classnames from 'classnames';
import ContactActionCreators from 'actions/ContactActionCreators';
import DialogActionCreators from 'actions/DialogActionCreators';
import PeerStore from 'stores/PeerStore';
import DialogStore from 'stores/DialogStore';
import AvatarItem from 'components/common/AvatarItem.react';
//import UserProfileContactInfo from 'components/activity/UserProfileContactInfo.react';
import Fold from 'components/common/Fold.React';
const getStateFromStores = (userId) => {
const thisPeer = PeerStore.getUserPeer(userId);
return {
thisPeer: thisPeer,
isNotificationsEnabled: DialogStore.isNotificationsEnabled(thisPeer)
};
};
@ReactMixin.decorate(IntlMixin)
class UserProfile extends React.Component {
static propTypes = {
user: React.PropTypes.object.isRequired
};
constructor(props) {
super(props);
this.state = _.assign({
isActionsDropdownOpen: false
}, getStateFromStores(props.user.id));
DialogStore.addNotificationsListener(this.onChange);
}
componentWillUnmount() {
DialogStore.removeNotificationsListener(this.onChange);
}
componentWillReceiveProps(newProps) {
this.setState(getStateFromStores(newProps.user.id));
}
addToContacts = () => {
ContactActionCreators.addContact(this.props.user.id);
};
removeFromContacts =() => {
ContactActionCreators.removeContact(this.props.user.id);
};
onNotificationChange = (event) => {
DialogActionCreators.changeNotificationsEnabled(this.state.thisPeer, event.target.checked);
};
onChange = () => {
this.setState(getStateFromStores(this.props.user.id));
};
toggleActionsDropdown = () => {
const isActionsDropdownOpen = this.state.isActionsDropdownOpen;
if (!isActionsDropdownOpen) {
this.setState({isActionsDropdownOpen: true});
document.addEventListener('click', this.closeActionsDropdown, false);
} else {
this.closeActionsDropdown();
}
};
closeActionsDropdown = () => {
this.setState({isActionsDropdownOpen: false});
document.removeEventListener('click', this.closeActionsDropdown, false);
};
render() {
const { user } = this.props;
const { isNotificationsEnabled } = this.state;
let actions;
if (user.isContact === false) {
actions = (
<li className="dropdown__menu__item" onClick={this.addToContacts}>
<FormattedMessage message={this.getIntlMessage('addToContacts')}/>
</li>
);
} else {
actions = (
<li className="dropdown__menu__item" onClick={this.removeFromContacts}>
<FormattedMessage message={this.getIntlMessage('removeFromContacts')}/>
</li>
);
}
let dropdownClassNames = classnames('dropdown pull-left', {
'dropdown--opened': this.state.isActionsDropdownOpen
});
const nickname = user.nick ? (
<li>
<svg className="icon icon--pink"
dangerouslySetInnerHTML={{__html: '<use xlink:href="assets/sprite/icons.svg#username"/>'}}/>
<span className="title">{user.nick}</span>
<span className="description">nickname</span>
</li>
) : null;
const email = user.email ? (
<li className="hide">
<i className="material-icons icon icon--blue">mail</i>
<span className="title">{user.email}</span>
<span className="description">email</span>
</li>
) : null;
return (
<div className="activity__body user_profile">
<ul className="profile__list">
<li className="profile__list__item user_profile__meta">
<header>
<AvatarItem image={user.bigAvatar}
placeholder={user.placeholder}
size="big"
title={user.name}/>
<h3 className="user_profile__meta__title">{user.name}</h3>
<div className="user_profile__meta__presence">{user.presence}</div>
</header>
<footer>
<div className={dropdownClassNames}>
<button className="dropdown__button button button--light-blue" onClick={this.toggleActionsDropdown}>
<i className="material-icons">more_horiz</i>
<FormattedMessage message={this.getIntlMessage('actions')}/>
</button>
<ul className="dropdown__menu dropdown__menu--left">
{actions}
</ul>
</div>
</footer>
</li>
<li className="profile__list__item user_profile__contact_info no-p">
<ul className="user_profile__contact_info__list">
{nickname}
<li>
<i className="material-icons icon icon--green">call</i>
<span className="title">{'+' + user.phones[0].number}</span>
<span className="description">mobile</span>
</li>
{email}
</ul>
</li>
<li className="profile__list__item user_profile__media no-p hide">
<Fold icon="attach_file" iconClassName="icon--gray" title={this.getIntlMessage('sharedMedia')}>
<ul>
<li><a>230 Shared Photos and Videos</a></li>
<li><a>49 Shared Links</a></li>
<li><a>49 Shared Files</a></li>
</ul>
</Fold>
</li>
<li className="profile__list__item user_profile__notifications no-p">
<label htmlFor="notifications">
<i className="material-icons icon icon--squash">notifications_none</i>
<FormattedMessage message={this.getIntlMessage('notifications')}/>
<div className="switch pull-right">
<input checked={isNotificationsEnabled}
id="notifications"
onChange={this.onNotificationChange}
type="checkbox"/>
<label htmlFor="notifications"></label>
</div>
</label>
</li>
</ul>
</div>
);
}
}
export default UserProfile;
|
client/scripts/components/config/undo-button/index.js | kuali/research-coi | /*
The Conflict of Interest (COI) module of Kuali Research
Copyright © 2005-2016 Kuali, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
import styles from './style';
import React from 'react';
import ConfigActions from '../../../actions/config-actions';
export default function UndoButton(props) {
return (
<div className={`flexbox row ${styles.container} ${props.className}`} onClick={ConfigActions.undoAll}>
<i className={`fa fa-times-circle ${styles.undoIcon}`} />
<span className={`fill ${styles.undoText}`}>CANCEL AND UNDO CHANGES</span>
</div>
);
}
|
src/RadioGroup/RadioGroup.driver.js | skyiea/wix-style-react | import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-dom/test-utils';
import toArray from 'lodash/toArray';
import {isClassExists} from '../../test/utils';
const radioGroupDriverFactory = ({element, wrapper, component}) => {
const radios = toArray(element.children) || [];
const radioButtons = radios.map(radio => radio.childNodes[0]);
const labels = radios.map(radio => radio.childNodes[1]);
const selectedRadio = radios.find(radio => radio.childNodes[0].checked);
const getRadioByValue = value => radioButtons.find(radioButton => radioButton.value === value.toString());
return {
exists: () => !!element,
selectByValue: value => ReactTestUtils.Simulate.change(getRadioByValue(value)),
selectByIndex: index => ReactTestUtils.Simulate.change(radioButtons[index]),
getRadioValueAt: index => radioButtons[index].value,
getSelectedValue: () => selectedRadio ? selectedRadio.childNodes[0].value : null,
getClassOfLabelAt: index => labels[index].className,
isVerticalDisplay: () => isClassExists(element, 'vertical'),
isHorizontalDisplay: () => isClassExists(element, 'horizontal'),
isButtonType: () => isClassExists(element, 'buttonType'),
spacing: () => radios[0].style._values['margin-bottom'],
lineHeight: () => radios[0].style._values['line-height'],
getNumberOfRadios: () => radios.length,
setProps: props => {
const ClonedWithProps = React.cloneElement(component, Object.assign({}, component.props, props), ...(component.props.children || []));
ReactDOM.render(<div ref={r => element = r}>{ClonedWithProps}</div>, wrapper);
}
};
};
export default radioGroupDriverFactory;
|
src/components/SearchComponent.js | krzysztofkolek/react-github-client | 'use strict';
require('styles//Search.css');
import React from 'react';
import * as SearchAction from '../actions/SearchAction'
import SearchStore from '../stores/SearchStore'
import dispatcher from '../dispatcher/Dispatcher'
import * as MainAction from '../actions/MainAction'
class SearchComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
username: ''
}
}
componentWillMount() {
var self = this;
SearchStore.on('usernamechanged', () => {
MainAction.setComponentsAsVisible();
});
}
onUsernameChange(e) {
this.setState({
username: e.target.value
})
}
onChangeBtnClick() {
SearchAction.changeCurrentUser({ username: this.state.username });
}
render() {
return (
<div className="search-component">
<div>Github client</div>
<div>
<div>
<input type="text" name="username"
placeholder="Enter your username..."
onChange={this.onUsernameChange.bind(this)}
/>
<button onClick={this.onChangeBtnClick.bind(this)}>Search</button>
</div>
</div>
</div>
);
}
}
SearchComponent.displayName = 'SearchComponent';
// Uncomment properties you need
// SearchComponent.propTypes = {};
// SearchComponent.defaultProps = {};
export default SearchComponent;
|
src/client/components/component.react.js | grabbou/este | import React from 'react';
import shallowEqual from 'react-pure-render/shallowEqual';
// import diff from 'immutablediff';
/**
* Purified React.Component. Goodness.
* http://facebook.github.io/react/docs/advanced-performance.html
*/
class Component extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
// TODO: Make whole React Pure, add something like dangerouslySetLocalState.
// https://github.com/gaearon/react-pure-render#known-issues
// https://twitter.com/steida/status/600395820295450624
if (this.context.router) {
const changed = this.pureComponentLastPath !== this.context.router.getCurrentPath();
this.pureComponentLastPath = this.context.router.getCurrentPath();
if (changed) return true;
}
const shouldUpdate =
!shallowEqual(this.props, nextProps) ||
!shallowEqual(this.state, nextState);
// if (shouldUpdate)
// this._logShouldUpdateComponents(nextProps, nextState)
return shouldUpdate;
}
// // Helper to check which component was changed and why.
// _logShouldUpdateComponents(nextProps, nextState) {
// const name = this.constructor.displayName || this.constructor.name
// console.log(`${name} shouldUpdate`)
// // const propsDiff = diff(this.props, nextProps).toJS()
// // const stateDiff = diff(this.state, nextState).toJS()
// // if (propsDiff.length) console.log('props', propsDiff)
// // if (stateDiff.length) console.log('state', stateDiff)
// }
}
Component.contextTypes = {
router: React.PropTypes.func
};
export default Component;
|
src/views/components/shared/tracks.js | EragonJ/Kaku | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactTooltip from 'react-tooltip';
import Track from './track/track';
import NoTrack from './track/no-track';
import L10nSpan from './l10n-span';
import ActionButton from './action-button';
import TrackModeButton from './track-mode-button';
import AddToPlayQueueButton from './add-to-play-queue-button';
class TracksComponent extends Component {
constructor(props) {
super(props);
this.state = {
trackMode: 'square'
};
this._onTrackModeChange = this._onTrackModeChange.bind(this);
}
_onTrackModeChange(mode) {
this.setState({
trackMode: mode
});
}
componentDidUpdate() {
// Only rebuild the tooltip when we are under sqaure more
// this can avoid manipulate DOM tree too much
if (this.state.trackMode === 'square') {
ReactTooltip.rebuild();
}
}
render() {
let {
tracks,
headerL10nId,
headerWording,
headerIconClass,
controls,
onDeleteAllClick,
onPlayAllClick
} = this.props;
let trackMode = this.state.trackMode;
let noTracks = (tracks.length === 0);
// TODO
// right now L10nSpan is just a span, we can extend it so that we can
// also pass plain strings.
let headerSpan;
if (headerL10nId) {
headerSpan = <L10nSpan l10nId={headerL10nId}/>;
}
else {
headerSpan = <span>{headerWording}</span>;
}
let deleteAllButton;
if (controls.deleteAllButton) {
deleteAllButton =
<ActionButton
l10nId='history_clean_all'
buttonClass='btn btn-default clean-button'
iconClass='fa fa-fw fa-trash-o'
isDisabled={noTracks}
onClick={onDeleteAllClick} />
}
let trackModeButton;
if (controls.trackModeButton) {
trackModeButton =
<TrackModeButton
onTrackModeChange={this._onTrackModeChange}/>
}
let playAllButton;
if (controls.playAllButton) {
playAllButton =
<ActionButton
l10nId='component_play_all'
buttonClass='btn btn-default playall-button'
iconClass='fa fa-fw fa-play-circle'
isDisabled={noTracks}
onClick={onPlayAllClick} />
}
let addToPlayQueueButton;
if (controls.addToPlayQueueButton) {
addToPlayQueueButton =
<AddToPlayQueueButton data={tracks}/>
}
let noTracksDiv;
if (noTracks) {
noTracksDiv = <NoTrack/>;
}
return (
<div className="tracks-slot">
<div className="header clearfix">
<h1>
<i className={headerIconClass}></i>
{headerSpan}
</h1>
<div className="control-buttons">
{trackModeButton}
{addToPlayQueueButton}
{deleteAllButton}
{playAllButton}
</div>
</div>
<div className="tracks-component">
{noTracksDiv}
{tracks.map(function(track, index) {
return <Track key={index} data={track} mode={trackMode} index={index}/>;
})}
</div>
</div>
);
}
}
TracksComponent.propTypes = {
headerL10nId: PropTypes.string,
headerWording: PropTypes.string,
headerIconClass: PropTypes.string.isRequired,
controls: PropTypes.object,
tracks: PropTypes.array.isRequired,
onDeleteAllClick: PropTypes.func,
onPlayAllClick: PropTypes.func
};
TracksComponent.defaultProps = {
headerL10nId: '',
headerWording: '',
headerIconClass: '',
controls: {
trackModeButton: true,
playAllButton: true,
addToPlayQueueButton: true,
deleteAllButton: false
},
onDeleteAllClick: function() {},
onPlayAllClick: function() {},
tracks: []
};
module.exports = TracksComponent;
|
features/toolbar/components/Toolbar.native.js | jitsi/jitsi-meet-react | import React from 'react';
import { View } from 'react-native';
import { connect } from 'react-redux';
import {
MEDIA_TYPE,
toggleCameraFacingMode
} from '../../base/media';
import { Container } from '../../base/react';
import { ColorPalette } from '../../base/styles';
import {
AbstractToolbar,
mapStateToProps
} from './AbstractToolbar';
import { styles } from './styles';
import ToolbarButton from './ToolbarButton';
/**
* Implements the conference toolbar on React Native.
*
* @extends AbstractToolbar
*/
class Toolbar extends AbstractToolbar {
/**
* Initializes a new Toolbar instance.
*
* @param {Object} props - The read-only React Component props with which
* the new instance is to be initialized.
*/
constructor(props) {
super(props);
// Bind event handlers so they are only bound once for every instance.
this._onCameraFacingModeToggle
= this._onCameraFacingModeToggle.bind(this);
}
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
const audioButtonStyles = this._getMuteButtonStyles(MEDIA_TYPE.AUDIO);
const videoButtonStyles = this._getMuteButtonStyles(MEDIA_TYPE.VIDEO);
const underlayColor = ColorPalette.buttonUnderlay;
// TODO Use correct Jitsi icon for camera switch button when available.
/* eslint-disable react/jsx-handler-names */
return (
<Container
style = { styles.toolbarContainer }
visible = { this.props.visible }>
<View style = { styles.toggleCameraFacingModeContainer }>
<ToolbarButton
iconName = 'reload'
iconstyle = { styles.whiteIcon }
onClick = { this._onCameraFacingModeToggle }
style = { styles.toggleCameraFacingModeButton }
underlayColor = 'transparent' />
</View>
<View style = { styles.toolbarButtonsContainer }>
<ToolbarButton
iconName = { audioButtonStyles.iconName }
iconStyle = { audioButtonStyles.iconStyle }
onClick = { this._toggleAudio }
style = { audioButtonStyles.buttonStyle } />
<ToolbarButton
iconName = 'hangup'
iconStyle = { styles.whiteIcon }
onClick = { this._onHangup }
style = {{
...styles.toolbarButton,
backgroundColor: ColorPalette.jitsiRed
}}
underlayColor = { underlayColor } />
<ToolbarButton
iconName = { videoButtonStyles.iconName }
iconStyle = { videoButtonStyles.iconStyle }
onClick = { this._toggleVideo }
style = { videoButtonStyles.buttonStyle } />
</View>
</Container>
);
/* eslint-enable react/jsx-handler-names */
}
/**
* Switches between the front/user-facing and rear/environment-facing
* cameras.
*
* @private
* @returns {void}
*/
_onCameraFacingModeToggle() {
this.props.dispatch(toggleCameraFacingMode());
}
}
/**
* Additional properties for various icons, which are now platform-dependent.
* This is done to have common logic of generating styles for web and native.
* TODO As soon as we have common font sets for web and native, this will no
* longer be required.
*/
Object.assign(Toolbar.prototype, {
audioIcon: 'microphone',
audioMutedIcon: 'mic-disabled',
videoIcon: 'webCam',
videoMutedIcon: 'camera-disabled'
});
/**
* Toolbar component's property types.
*
* @static
*/
Toolbar.propTypes = AbstractToolbar.propTypes;
export default connect(mapStateToProps)(Toolbar);
|
examples/sidebar/app.js | ThibWeb/react-router | import React from 'react';
import { Router, Route, Link } from 'react-router';
import data from './data';
var Category = React.createClass({
render() {
var category = data.lookupCategory(this.props.params.category);
return (
<div>
<h1>{category.name}</h1>
{this.props.children || (
<p>{category.description}</p>
)}
</div>
);
}
});
var CategorySidebar = React.createClass({
render() {
var category = data.lookupCategory(this.props.params.category);
return (
<div>
<Link to="/">◀︎ Back</Link>
<h2>{category.name} Items</h2>
<ul>
{category.items.map((item, index) => (
<li key={index}>
<Link to={`/category/${category.name}/${item.name}`}>{item.name}</Link>
</li>
))}
</ul>
</div>
);
}
});
var Item = React.createClass({
render() {
var { category, item } = this.props.params;
var menuItem = data.lookupItem(category, item);
return (
<div>
<h1>{menuItem.name}</h1>
<p>${menuItem.price}</p>
</div>
);
}
});
var Index = React.createClass({
render() {
return (
<div>
<h1>Sidebar</h1>
<p>
Routes can have multiple components, so that all portions of your UI
can participate in the routing.
</p>
</div>
);
}
});
var IndexSidebar = React.createClass({
render() {
return (
<div>
<h2>Categories</h2>
<ul>
{data.getAll().map((category, index) => (
<li key={index}>
<Link to={`/category/${category.name}`}>{category.name}</Link>
</li>
))}
</ul>
</div>
);
}
});
var App = React.createClass({
render() {
var { children } = this.props;
return (
<div>
<div className="Sidebar">
{children ? children.sidebar : <IndexSidebar />}
</div>
<div className="Content">
{children ? children.content : <Index />}
</div>
</div>
);
}
});
React.render((
<Router>
<Route path="/" component={App}>
<Route path="category/:category" components={{content: Category, sidebar: CategorySidebar}}>
<Route path=":item" component={Item} />
</Route>
</Route>
</Router>
), document.getElementById('example'));
|
src/Parser/Warlock/Destruction/Modules/Items/Legendaries/MagistrikeRestraints.js | enragednuke/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import ITEMS from 'common/ITEMS';
import Analyzer from 'Parser/Core/Analyzer';
import Combatants from 'Parser/Core/Modules/Combatants';
import ItemDamageDone from 'Main/ItemDamageDone';
class MagistrikeRestraints extends Analyzer {
static dependencies = {
combatants: Combatants,
};
bonusDmg = 0;
on_initialized() {
this.active = this.combatants.selected.hasWrists(ITEMS.MAGISTRIKE_RESTRAINTS.id);
}
on_byPlayer_damage(event) {
if (event.ability.guid === SPELLS.MAGISTRIKE_RESTRAINTS_CHAOS_BOLT.id) {
this.bonusDmg += event.amount + (event.absorbed || 0);
}
}
item() {
return {
item: ITEMS.MAGISTRIKE_RESTRAINTS,
result: <ItemDamageDone amount={this.bonusDmg} />,
};
}
}
export default MagistrikeRestraints;
|
app/javascript/mastodon/features/report/rules.js | cobodo/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';
import { FormattedMessage } from 'react-intl';
import Button from 'mastodon/components/button';
import Option from './components/option';
const mapStateToProps = state => ({
rules: state.get('rules'),
});
export default @connect(mapStateToProps)
class Rules extends React.PureComponent {
static propTypes = {
onNextStep: PropTypes.func.isRequired,
rules: ImmutablePropTypes.list,
selectedRuleIds: ImmutablePropTypes.set.isRequired,
onToggle: PropTypes.func.isRequired,
};
handleNextClick = () => {
const { onNextStep } = this.props;
onNextStep('statuses');
};
handleRulesToggle = (value, checked) => {
const { onToggle } = this.props;
onToggle(value, checked);
};
render () {
const { rules, selectedRuleIds } = this.props;
return (
<React.Fragment>
<h3 className='report-dialog-modal__title'><FormattedMessage id='report.rules.title' defaultMessage='Which rules are being violated?' /></h3>
<p className='report-dialog-modal__lead'><FormattedMessage id='report.rules.subtitle' defaultMessage='Select all that apply' /></p>
<div>
{rules.map(item => (
<Option
key={item.get('id')}
name='rule_ids'
value={item.get('id')}
checked={selectedRuleIds.includes(item.get('id'))}
onToggle={this.handleRulesToggle}
label={item.get('text')}
multiple
/>
))}
</div>
<div className='flex-spacer' />
<div className='report-dialog-modal__actions'>
<Button onClick={this.handleNextClick} disabled={selectedRuleIds.size < 1}><FormattedMessage id='report.next' defaultMessage='Next' /></Button>
</div>
</React.Fragment>
);
}
}
|
src/pages/imprint.js | JovaniPink/measuredstudios | import React from 'react';
import PropTypes from 'prop-types';
import { graphql } from 'gatsby';
import styled from 'styled-components';
import { MDXRenderer } from 'gatsby-plugin-mdx';
import GlobalStateProvider from '../context/provider';
import ContentWrapper from '../styles/contentWrapper';
import Layout from '../components/layout';
import SEO from '../components/seo';
import { seoTitleSuffix } from '../../config';
const StyledSection = styled.section`
width: 100%;
max-width: 62.5rem;
margin: 0 auto;
padding: 0 2.5rem;
height: auto;
background: ${({ theme }) => theme.colors.background};
h1 {
font-size: 1.5rem;
}
h2 {
font-size: 1.25rem;
}
h3 {
font-size: 1rem;
margin-bottom: 1rem;
}
`;
const StyledContentWrapper = styled(ContentWrapper)`
&& {
width: 100%;
max-width: 36rem;
margin: 0;
padding: 0;
height: 100%;
}
`;
const Imprint = ({ data }) => {
const { body, frontmatter } = data.imprint.edges[0].node;
const { title, seoTitle, useSeoTitleSuffix, useSplashScreen } = frontmatter;
const globalState = {
isIntroDone: useSplashScreen ? false : true,
darkMode: false,
};
return (
<GlobalStateProvider initialState={globalState}>
<Layout>
<SEO
title={
useSeoTitleSuffix
? `${seoTitle} - ${seoTitleSuffix}`
: `${seoTitle}`
}
meta={[{ name: 'robots', content: 'noindex' }]}
/>
<StyledSection id={title}>
<StyledContentWrapper>
<h1 data-testid="heading">{title}</h1>
<MDXRenderer>{body}</MDXRenderer>
</StyledContentWrapper>
</StyledSection>
</Layout>
</GlobalStateProvider>
);
};
Imprint.propTypes = {
data: PropTypes.shape({
imprint: PropTypes.shape({
edges: PropTypes.arrayOf(
PropTypes.shape({
node: PropTypes.shape({
body: PropTypes.string.isRequired,
frontmatter: PropTypes.object.isRequired,
}).isRequired,
}).isRequired
).isRequired,
}).isRequired,
}).isRequired,
};
export default Imprint;
export const pageQuery = graphql`
{
imprint: allMdx(filter: { fileAbsolutePath: { regex: "/imprint/" } }) {
edges {
node {
body
frontmatter {
title
seoTitle
useSeoTitleSuffix
useSplashScreen
}
}
}
}
}
`;
|
packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js | reedsa/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
function load(baseUser) {
return [
{ id: 1, name: '1', ...baseUser },
{ id: 2, name: '2', ...baseUser },
{ id: 3, name: '3', ...baseUser },
{ id: 4, name: '4', ...baseUser },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = { users: [] };
}
async componentDidMount() {
const users = load({ age: 42 });
this.setState({ users });
}
componentDidUpdate() {
this.props.onReady();
}
render() {
return (
<div id="feature-object-spread">
{this.state.users.map(user => (
<div key={user.id}>
{user.name}: {user.age}
</div>
))}
</div>
);
}
}
|
client/components/NoResultsPage.js | HelpAssistHer/help-assist-her | import React from 'react'
import injectSheet from 'react-jss'
import { Link } from 'react-router-dom'
import Button from './Button'
import { Phone, BigPhone, Tablet, Desktop } from './Breakpoints'
import Spacer from './Spacer'
const noResultsMessage = 'No results match your search.'
const buttonText = 'Return to Search'
const NoResults = ({ classes }) => (
<div className={classes.flexCenter}>
<Phone>
<div className={classes.noResultsPhone}>
{noResultsMessage}
<Spacer height="20px" />
<Link to="/">
<Button buttonText={buttonText} />
</Link>
</div>
</Phone>
<BigPhone>
<div className={classes.noResultsPhone}>
{noResultsMessage}
<Spacer height="20px" />
<Link to="/">
<Button buttonText={buttonText} />
</Link>
</div>
</BigPhone>
<Tablet>
<div className={classes.noResultsDesktop}>
{noResultsMessage}
<Link to="/">
<Button buttonText={buttonText} />
</Link>
</div>
</Tablet>
<Desktop>
<div className={classes.noResultsDesktop}>
{noResultsMessage}
<Link to="/">
<Button buttonText={buttonText} />
</Link>
</div>
</Desktop>
</div>
)
const styles = {
flexCenter: {
display: 'flex',
'justify-content': 'center',
},
noResultsPhone: {
width: '100%',
display: 'flex',
'flex-direction': 'column',
'justify-content': 'space-between',
color: '#000000',
'font-family': 'hah-regular',
'font-size': '20px',
'line-height': '23px',
'letter-spacing': '0.25px',
border: '1px solid #3D65F9',
'border-radius': '2px',
'background-color': '#FFFFFF',
padding: '24px',
},
noResultsDesktop: {
'max-width': '700px',
width: '100%',
display: 'flex',
'justify-content': 'space-between',
'align-items': 'center',
color: '#000000',
'font-family': 'hah-regular',
'font-size': '20px',
'line-height': '34px',
border: '1px solid #3D65F9',
'border-radius': '2px',
'background-color': '#FFFFFF',
padding: '40px 80px',
},
}
export default injectSheet(styles)(NoResults)
|
generators/app/templates/app/web/static/js/components/form.js | TFarla/generator-phoenix-react | import React from 'react';
export default ({handleSubmit}) => {
let input;
return (
<form onSubmit={
e => {
e.preventDefault();
handleSubmit(input.value);
input.value = '';
}
}>
<div className='form-group'>
<input
className='form-control'
type="text"
name="message"
ref={node => input = node}
/>
</div>
<div className='form-group'>
<button className='btn btn-default'>submit</button>
</div>
</form>
)
};
|
conserve/src/Map.js | lrobinsonco/conserve | import React from 'react';
import PropTypes from 'prop-types';
import Map from 'google-maps-react';
export class Container extends React.Component {
render() {
if (!this.props.loaded) {
return <div>Loading...</div>
}
return (
<div>Map will go here</div>
)
}
}
export default GoogleApiComponent({
apiKey: AIzaSyAyesbQMyKVVbBgKVi2g6VX7mop2z96jBo
})(Container)
|
data-browser-ui/public/app/components/tableComponents/td/aclComponents/viewAcl.js | CloudBoost/cloudboost | import React from 'react'
import ReactDOM from 'react-dom'
class ViewACL extends React.Component {
constructor(){
super()
this.state = {
}
}
componentDidMount(){
}
render() {
let users = 0
let roles = 0
let all = 0
let str = ''
let write = false
let read = false
if(this.props.aclList){
for(var k in this.props.aclList){
if(this.props.aclList[k].type == 'user' && this.props.aclList[k].id != 'all') users++
if(this.props.aclList[k].type == 'role') roles++
if(this.props.aclList[k].id == 'all') all++
if(this.props.aclList[k].data.write) {
write = true
}
if(this.props.aclList[k].data.read) {
read = true
}
}
}
if(!users && !roles && write){
str = <span>
<i className="fa fa-wikipedia-w" aria-hidden="true"></i>
<span className="color888"> Public Read And Write</span>
</span>
}
else if(!users && !roles && read){
str = <span>
<i className="fa fa-wikipedia-w" aria-hidden="true"></i>
<span className="color888"> Public Read</span>
</span>
} else {
str = <span>
<i className="fa fa-wikipedia-w" aria-hidden="true"></i>
<span className="color888"> { users +' Users ' + roles + ' Roles' }</span>
</span>
}
if(!users && !roles && !all){
str = <span>
<i className="fa fa-minus-circle" aria-hidden="true"></i>
<span className="color888"> No rules specified</span>
</span>
}
return (
<span className="expandleftpspan">{ str }</span>
);
}
}
export default ViewACL; |
components/Navigation/Navigation.js | HashtasticDesign/build | /**
* React Static Boilerplate
* https://github.com/koistya/react-static-boilerplate
* Copyright (c) Konstantin Tarkus (@koistya) | MIT license
*/
import React from 'react';
import './Navigation.scss';
import Link from '../Link';
function Navigation() {
return (
<ul className="navigation" role="menu">
<li className="navigation-item">
<a className="navigation-link" href="/" onClick={Link.handleClick}>Home</a>
</li>
<li className="navigation-item">
<a className="navigation-link" href="/about" onClick={Link.handleClick}>About</a>
</li>
</ul>
);
}
export default Navigation;
|
docs/app/Examples/elements/Input/Variations/InputExampleIconProps.js | ben174/Semantic-UI-React | import React from 'react'
import { Input } from 'semantic-ui-react'
const InputExampleIconProps = () => (
<Input
icon={{ name: 'search', circular: true, link: true }}
placeholder='Search...'
/>
)
export default InputExampleIconProps
|
src/components/Layout/Header.js | 102010cncger/antd-admin | import React from 'react'
import PropTypes from 'prop-types'
import { Menu, Icon, Popover } from 'antd'
import classnames from 'classnames'
import styles from './Header.less'
import Menus from './Menu'
const SubMenu = Menu.SubMenu
const Header = ({ user, logout, switchSider, siderFold, isNavbar, menuPopoverVisible, location, switchMenuPopover, navOpenKeys, changeOpenKeys, menu }) => {
let handleClickMenu = e => e.key === 'logout' && logout()
const menusProps = {
menu,
siderFold: false,
darkTheme: false,
isNavbar,
handleClickNavMenu: switchMenuPopover,
location,
navOpenKeys,
changeOpenKeys,
}
return (
<div className={styles.header}>
{isNavbar
? <Popover placement="bottomLeft" onVisibleChange={switchMenuPopover} visible={menuPopoverVisible} overlayClassName={styles.popovermenu} trigger="click" content={<Menus {...menusProps} />}>
<div className={styles.button}>
<Icon type="bars" />
</div>
</Popover>
: <div
className={styles.button}
onClick={switchSider}
>
<Icon type={classnames({ 'menu-unfold': siderFold, 'menu-fold': !siderFold })} />
</div>}
<div className={styles.rightWarpper}>
<div className={styles.button}>
<Icon type="mail" />
</div>
<Menu mode="horizontal" onClick={handleClickMenu}>
<SubMenu
style={{
float: 'right',
}}
title={<span>
<Icon type="user" />
{user.username}
</span>}
>
<Menu.Item key="logout">
Sign out
</Menu.Item>
</SubMenu>
</Menu>
</div>
</div>
)
}
Header.propTypes = {
menu: PropTypes.array,
user: PropTypes.object,
logout: PropTypes.func,
switchSider: PropTypes.func,
siderFold: PropTypes.bool,
isNavbar: PropTypes.bool,
menuPopoverVisible: PropTypes.bool,
location: PropTypes.object,
switchMenuPopover: PropTypes.func,
navOpenKeys: PropTypes.array,
changeOpenKeys: PropTypes.func,
}
export default Header
|
src/flipper/Card.js | rudyyazdi/site | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { cardFlip } from './actions';
const _Card = ({ isFlipped, isGuessed, id, pairId, onClick }) => {
const isVisible = isFlipped || isGuessed;
const outerStyle = {
cursor: 'pointer',
backgroundImage: `url(https://api.adorable.io/avatars/100/rw${pairId}.png)`,
backgroundSize: 'cover'
};
const innerStyle = {
width: '100%',
height: '100%',
backgroundColor: isVisible ? 'transparent' : 'black'
};
const onClickHandler = () => {
onClick(id);
};
// if the number of cells are odd we need to skip one cell.
if (pairId === -1) {
return (
<div />
);
}
return (
<div style={outerStyle} onClick={onClickHandler}>
<div style={innerStyle} />
</div>
);
};
_Card.propTypes = {
id: PropTypes.number.isRequired,
pairId: PropTypes.number.isRequired,
isFlipped: PropTypes.bool,
isGuessed: PropTypes.bool,
onClick: PropTypes.func.isRequired
};
_Card.defaultProps = {
isFlipped: false,
isGuessed: false
};
const mapDispatchToProps = (dispatch) => ({
onClick: (id) => dispatch(cardFlip(id))
});
export { _Card };
export default connect(null, mapDispatchToProps)(_Card);
|
src/components/services/content/WebviewCrashHandler.js | GustavoKatel/franz | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import Button from '../../ui/Button';
const messages = defineMessages({
headline: {
id: 'service.crashHandler.headline',
defaultMessage: '!!!Oh no!',
},
text: {
id: 'service.crashHandler.text',
defaultMessage: '!!!{name} has caused an error.',
},
action: {
id: 'service.crashHandler.action',
defaultMessage: '!!!Reload {name}',
},
autoReload: {
id: 'service.crashHandler.autoReload',
defaultMessage: '!!!Trying to automatically restore {name} in {seconds} seconds',
},
});
export default @observer class WebviewCrashHandler extends Component {
static propTypes = {
name: PropTypes.string.isRequired,
reload: PropTypes.func.isRequired,
};
static contextTypes = {
intl: intlShape,
};
state = {
countdown: 10000,
}
countdownInterval = null;
countdownIntervalTimeout = 1000;
componentDidMount() {
const { reload } = this.props;
this.countdownInterval = setInterval(() => {
this.setState(prevState => ({
countdown: prevState.countdown - this.countdownIntervalTimeout,
}));
if (this.state.countdown <= 0) {
reload();
clearInterval(this.countdownInterval);
}
}, this.countdownIntervalTimeout);
}
render() {
const { name, reload } = this.props;
const { intl } = this.context;
return (
<div className="services__info-layer">
<h1>{intl.formatMessage(messages.headline)}</h1>
<p>{intl.formatMessage(messages.text, { name })}</p>
<Button
// label={`Reload ${name}`}
label={intl.formatMessage(messages.action, { name })}
buttonType="inverted"
onClick={() => reload()}
/>
<p className="footnote">
{intl.formatMessage(messages.autoReload, {
name,
seconds: this.state.countdown / 1000,
})}
</p>
</div>
);
}
}
|
renderer/components/UI/Button.js | LN-Zap/zap-desktop | import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { Button as BaseButton, Flex, Box } from 'rebass/styled-components'
import Spinner from './Spinner'
const Wrapper = styled(BaseButton)`
transition: all 0.25s;
outline: none;
font-weight: 300;
line-height: '18px';
white-space: nowrap;
text-align: ${({ justify }) => justify};
&:disabled {
opacity: 0.5;
}
&:hover:enabled {
cursor: pointer;
}
`
Wrapper.displayName = 'Button'
/**
* @name Button
* @example
* <Button><Basic button</Button>
*/
const Button = React.forwardRef((props, ref) => {
const {
children,
isActive,
isDisabled,
isProcessing,
size,
variant,
className,
sx,
icon: Icon,
...rest
} = props
const sizes = {
small: {
x: 3,
y: 2,
},
medium: {
x: 5,
y: 3,
},
large: {
x: 5,
y: 3,
},
}
const dimensions = sizes[size] || sizes.medium
if (variant === 'secondary') {
dimensions.x = 0
}
const fontWeight = variant === 'menu' && !isActive ? 'light ' : 'normal'
const fontSize = size === 'large' ? 'l' : 'm'
const borderRadius = variant === 'secondary' ? 0 : 5
// support custom styled and styled-components
const wrapperClasses = [className, isActive ? 'active' : null]
.filter(cls => Boolean(cls))
.join(' ')
return (
<Wrapper
ref={ref}
className={wrapperClasses}
disabled={isDisabled}
px={dimensions.x}
py={dimensions.y}
{...rest}
sx={{
borderRadius,
...sx,
}}
variant={variant}
>
{isProcessing || Icon ? (
<Flex alignItems="center" justifyContent="center">
{isProcessing ? <Spinner height="0.8em" width="0.8em" /> : Icon && <Icon />}
<Box fontSize={fontSize} fontWeight={fontWeight} ml={2}>
{children}
</Box>
</Flex>
) : (
<Box fontSize={fontSize} fontWeight={fontWeight}>
{children}
</Box>
)}
</Wrapper>
)
})
Button.displayName = 'Button'
Button.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
icon: PropTypes.func,
isActive: PropTypes.bool,
isDisabled: PropTypes.bool,
isProcessing: PropTypes.bool,
justify: PropTypes.oneOf(['left', 'right', 'center']),
size: PropTypes.oneOf(['small', 'medium', 'large']),
sx: PropTypes.object,
variant: PropTypes.string,
}
Button.defaultProps = {
size: 'medium',
justify: 'center',
variant: 'normal',
}
export default Button
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.