path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
analysis/demonhunterhavoc/src/modules/talents/TrailofRuin.js | anom0ly/WoWAnalyzer | import { formatThousands } from 'common/format';
import SPELLS from 'common/SPELLS';
import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
import Events from 'parser/core/Events';
import STATISTIC_ORDER from 'parser/ui/STATISTIC_ORDER';
import TalentStatisticBox from 'parser/ui/TalentStatisticBox';
import React from 'react';
/**
* Example Report: https://www.warcraftlogs.com/reports/RMPgqbz1BxpG9X8H/#fight=2&source=10
*/
class TrailofRuin extends Analyzer {
damage = 0;
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTalent(SPELLS.TRAIL_OF_RUIN_TALENT.id);
if (!this.active) {
return;
}
this.addEventListener(
Events.damage.by(SELECTED_PLAYER).spell(SPELLS.TRAIL_OF_RUIN_DAMAGE),
this.trailOfRuinDot,
);
}
trailOfRuinDot(event) {
this.damage += event.amount;
}
statistic() {
return (
<TalentStatisticBox
talent={SPELLS.TRAIL_OF_RUIN_TALENT.id}
position={STATISTIC_ORDER.OPTIONAL(6)}
value={this.owner.formatItemDamageDone(this.damage)}
tooltip={`${formatThousands(this.damage)} Total damage`}
/>
);
}
}
export default TrailofRuin;
|
Lumino/js/screens/TemperatureForm.js | evonove/lumino | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { reduxForm, change, submit } from 'redux-form';
import { View, Button, Alert } from 'react-native';
import { Picker } from 'native-base';
import styles from './style';
import { onTempControllerSubmit } from './validation';
import LightSettingsForm from '../components/ControllerForm/LightSettingsForm';
import TempControllerForm from '../components/ControllerForm/TempControllerForm';
import HeaderButton from '../components/HeaderButton/HeaderButton';
import GradientHeader from '../components/GradientHeader/GradientHeader';
/**
* Controller settings
*/
class TemperatureFormComponent extends React.Component {
componentDidMount() {
// If there are no gateways, alert the user and send him back
if (!this.props.gateways || this.props.gateways.length === 0) {
Alert.alert('Create at least one gateway first!');
this.props.navigation.goBack();
} else if (!this.props.initialValues) {
// Hack to fix a bug on the Picker component. Sometimes if the user never
// changes Picker selected Item it won't be set as initialValue.
// We call redux-form `change` action to trigger the first selection
// if we are in a new controller form
this.props.navigation.dispatch(
change('tempController', 'gateway', this.props.gateways[0].id),
);
// Controller type is a custom component and needs to be initialized too
this.props.navigation.dispatch(
change('tempController', 'type', 'temp')
);
}
}
render() {
// Map list of gateways to Picker.Item components
const gatewaysItems = this.props.gateways.map(
(gateway, index) => (
<Picker.Item
key={index}
label={gateway.name}
value={gateway.id}
/>
),
);
// If there is no initialValues it means we are creating a new controller,
// so no need to show the delete button (we hide it with css)
const deleteViewable = !this.props.initialValues ? { display: 'none' } : styles.deleteController;
return (
<View style={styles.container}>
<TempControllerForm gateways={gatewaysItems} />
<View style={deleteViewable}>
<Button
onPress={() => this.props.onDelete(this.props.initialValues)}
color="#DD3924"
title="Delete controller"
accessibilityLabel="Delete temperature controller"
/>
</View>
</View>
);
}
}
TemperatureFormComponent.propTypes = {
gateways: PropTypes.arrayOf(PropTypes.object).isRequired,
navigation: PropTypes.object.isRequired,
initialValues: PropTypes.object,
onDelete: PropTypes.func.isRequired,
};
const mapStateToProps = (state, { navigation, initialValues }) => {
const confirmDelete = (controller) => {
const deleteAction = {
type: 'DELETE_TEMP_CONTROLLER',
controller: controller.id,
};
navigation.dispatch(deleteAction);
navigation.goBack();
}
const onDelete = (controller) => {
Alert.alert(
'Confirm delete',
'This will permanently delete this controller, confirm?',
[
{ text: 'Cancel', style: 'cancel' },
{ text: 'Delete', onPress: () => confirmDelete(controller), style: 'destructive' },
],
)
}
return {
gateways: state.gateways,
onDelete,
...navigation.state.params,
}
};
// Wrap into reduxForm for form handling
let TempForm = reduxForm({
form: 'tempController',
enableReinitialize: true,
onSubmit: onTempControllerSubmit,
})(TemperatureFormComponent);
TempForm = connect(mapStateToProps)(TempForm);
/**
* StackNavigation options for TempForm component
*/
TempForm.navigationOptions = ({ navigation }) => {
const { state, dispatch } = navigation;
const { params } = state;
// Custom submit function
const onPress = () => dispatch(submit('tempController'));
// If there are initialValues, we set the title to 'EDIT' and send the edit action
// otherwise we create a new controller
let title = 'New temperature controller';
if (params && params.initialValues && params.initialValues.id) {
title = 'Edit temperature controller';
}
return {
title,
header: props => <GradientHeader {...props} />,
headerTintColor: 'white',
headerRight: <HeaderButton onPress={onPress} text="Save" />,
};
};
export default TempForm;
|
docs/src/app/app.js | hwo411/material-ui | import React from 'react';
import {render} from 'react-dom';
import {Router, useRouterHistory} from 'react-router';
import AppRoutes from './AppRoutes';
import injectTapEventPlugin from 'react-tap-event-plugin';
import {createHashHistory} from 'history';
// Helpers for debugging
window.React = React;
window.Perf = require('react-addons-perf');
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
/**
* Render the main app component. You can read more about the react-router here:
* https://github.com/reactjs/react-router/blob/master/docs/guides/README.md
*/
render(
<Router
history={useRouterHistory(createHashHistory)({queryKey: false})}
onUpdate={() => window.scrollTo(0, 0)}
>
{AppRoutes}
</Router>
, document.getElementById('app'));
|
frontend/js/components/ecosystems/SurveyCreatorGeneral.js | Code4HR/okcandidate-platform | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Card from './../atoms/Card';
import TextField from './../organisms/TextField';
import RadioButtons from './../organisms/RadioButtons';
import Checkbox from './../molecules/Checkbox';
import Tray from './../molecules/Tray';
import Icon from './../atoms/Icon';
import {
fetchQuestionTypes,
setSurveyName,
setSurveyStartDate,
setSurveyEndDate,
selectQuestionType,
toggleRegionLimit,
toggleCategorySort,
submitSurveyGeneral,
updateSurveyGeneralInfo,
fetchSurveyGeneralInfo
} from './../../redux/actions/survey-creator-general-actions';
import {
gotoRoute
} from './../../redux/actions/router-actions';
class SurveyCreatorGeneral extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
this.props.dispatch(fetchQuestionTypes());
if (this.props.params.id) {
this.props.dispatch(fetchSurveyGeneralInfo(this.props.params.id));
}
}
setSurveyName(event) {
this.props.dispatch(setSurveyName(event.target.value));
}
setStartDate(event) {
this.props.dispatch(setSurveyStartDate(event.target.value));
}
setEndDate(event) {
this.props.dispatch(setSurveyEndDate(event.target.value));
}
setSelectedType(index) {
this.props.dispatch(selectQuestionType(index));
}
toggleRegionLimit(event) {
this.props.dispatch(toggleRegionLimit());
}
toggleCategorySort(event) {
this.props.dispatch(toggleCategorySort());
}
submitSurveyGeneral() {
if (this.props.general.id) {
return this.props.dispatch(updateSurveyGeneralInfo(this.props.general));
}
return this.props.dispatch(submitSurveyGeneral(this.props.general));
}
gotoNextPage() {
gotoRoute(`/admin/survey/${this.props.params.id}/offices`);
}
render() {
return (
<Card>
<h2>General</h2>
<TextField
onChange={this.setSurveyName.bind(this)}
value={this.props.general.name}
error={this.props.general.nameError}
name="survey-name"
label="Survey Name"
help="A memorable name for the survey"
type="text" />
<div className="text-field-row">
<TextField
onChange={this.setStartDate.bind(this)}
value={this.props.general.startDate}
error={this.props.general.startDateError}
name="start-date"
label="Start Date"
help="mm/dd/yyyy"
type="text" />
<TextField
onChange={this.setEndDate.bind(this)}
value={this.props.general.endDate}
error={this.props.general.endDateError}
name="end-date"
label="End Date"
help="mm/dd/yyyy"
type="text" />
</div>
<RadioButtons
onChange={this.setSelectedType.bind(this)}
selected={this.props.general.QuestionTypeId}
error={this.props.general.QuestionTypeIdError}
options={this.props.general.questionTypes}
help="What kind of questions will voters and candidates see?"
name="Question Type" />
<Checkbox
onChange={this.toggleRegionLimit.bind(this)}
checked={this.props.general.regionLimit}
help="Should voters in different districts see different candidates?"
label="Limit by region?"/>
<Checkbox
onChange={this.toggleCategorySort.bind(this)}
checked={this.props.general.categorySort}
help="Should survey takers be invited to sort categories by priority?"
label="Show Category Sort?" />
<Tray>
<button
onClick={this.submitSurveyGeneral.bind(this)}
className="submit">
{ this.props.general.id && 'Update' || 'Submit' }
</button>
{ this.props.general.id &&
<button
onClick={this.gotoNextPage.bind(this)}>
Offices <Icon>keyboard_arrow_right</Icon>
</button>
}
</Tray>
</Card>
);
}
}
SurveyCreatorGeneral.propTypes = {
general: PropTypes.object,
dispatch: PropTypes.func,
params: PropTypes.object
};
export default connect(
state => ({
general: state.surveyCreator.general
})
)(SurveyCreatorGeneral);
|
node_modules/react-icons/go/mortar-board.js | bairrada97/festival |
import React from 'react'
import Icon from 'react-icon-base'
const GoMortarBoard = props => (
<Icon viewBox="0 0 40 40" {...props}>
<g><path d="m19.6 23l-9.6-3v6.3s4.5 3.7 10 3.7 10-1.2 10-3.7v-6.3l-9.6 3c-0.2 0-0.6 0-0.9 0h0.1z m0.7-16c-0.2 0-0.4 0-0.5 0l-19.1 5.9c-0.9 0.3-0.9 1.4 0 1.7l4.3 1.4v4.4c-0.7 0.4-1.2 1.2-1.2 2.1 0 0.5 0.1 0.9 0.3 1.3-0.2 0.3-0.4 0.8-0.4 1.2v6.5c0 1.4 5.1 1.4 5.1 0v-6.5c0-0.4-0.2-0.9-0.4-1.2 0.2-0.4 0.3-0.8 0.3-1.3 0-0.9-0.5-1.7-1.2-2.1v-3.6l12.2 3.8c0.2 0 0.4 0 0.5 0l19.1-5.9c0.9-0.3 0.9-1.5 0-1.7l-19-6z m-0.3 8c-1.3 0-2.5-0.5-2.5-1.2s1.2-1.3 2.5-1.3 2.5 0.5 2.5 1.3-1.1 1.2-2.5 1.2z"/></g>
</Icon>
)
export default GoMortarBoard
|
Libraries/Modal/Modal.js | Maxwell2022/react-native | /**
* 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 Modal
* @flow
*/
'use strict';
const AppContainer = require('AppContainer');
const I18nManager = require('I18nManager');
const Platform = require('Platform');
const React = require('React');
const PropTypes = require('prop-types');
const StyleSheet = require('StyleSheet');
const View = require('View');
const deprecatedPropType = require('deprecatedPropType');
const requireNativeComponent = require('requireNativeComponent');
const RCTModalHostView = requireNativeComponent('RCTModalHostView', null);
/**
* The Modal component is a simple way to present content above an enclosing view.
*
* _Note: If you need more control over how to present modals over the rest of your app,
* then consider using a top-level Navigator._
*
* ```javascript
* import React, { Component } from 'react';
* import { Modal, Text, TouchableHighlight, View } from 'react-native';
*
* class ModalExample extends Component {
*
* state = {
* modalVisible: false,
* }
*
* setModalVisible(visible) {
* this.setState({modalVisible: visible});
* }
*
* render() {
* return (
* <View style={{marginTop: 22}}>
* <Modal
* animationType={"slide"}
* transparent={false}
* visible={this.state.modalVisible}
* onRequestClose={() => {alert("Modal has been closed.")}}
* >
* <View style={{marginTop: 22}}>
* <View>
* <Text>Hello World!</Text>
*
* <TouchableHighlight onPress={() => {
* this.setModalVisible(!this.state.modalVisible)
* }}>
* <Text>Hide Modal</Text>
* </TouchableHighlight>
*
* </View>
* </View>
* </Modal>
*
* <TouchableHighlight onPress={() => {
* this.setModalVisible(true)
* }}>
* <Text>Show Modal</Text>
* </TouchableHighlight>
*
* </View>
* );
* }
* }
* ```
*/
class Modal extends React.Component {
static propTypes = {
/**
* The `animationType` prop controls how the modal animates.
*
* - `slide` slides in from the bottom
* - `fade` fades into view
* - `none` appears without an animation
*
* Default is set to `none`.
*/
animationType: PropTypes.oneOf(['none', 'slide', 'fade']),
/**
* The `transparent` prop determines whether your modal will fill the entire view. Setting this to `true` will render the modal over a transparent background.
*/
transparent: PropTypes.bool,
/**
* The `hardwareAccelerated` prop controls whether to force hardware acceleration for the underlying window.
* @platform android
*/
hardwareAccelerated: PropTypes.bool,
/**
* The `visible` prop determines whether your modal is visible.
*/
visible: PropTypes.bool,
/**
* The `onRequestClose` callback is called when the user taps the hardware back button.
* @platform android
*/
onRequestClose: Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func,
/**
* The `onShow` prop allows passing a function that will be called once the modal has been shown.
*/
onShow: PropTypes.func,
animated: deprecatedPropType(
PropTypes.bool,
'Use the `animationType` prop instead.'
),
/**
* The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations.
* On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field.
* @platform ios
*/
supportedOrientations: PropTypes.arrayOf(PropTypes.oneOf(['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'])),
/**
* The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed.
* The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation.
* @platform ios
*/
onOrientationChange: PropTypes.func,
};
static defaultProps = {
visible: true,
hardwareAccelerated: false,
};
static contextTypes = {
rootTag: PropTypes.number,
};
render(): ?React.Element<any> {
if (this.props.visible === false) {
return null;
}
const containerStyles = {
backgroundColor: this.props.transparent ? 'transparent' : 'white',
};
let animationType = this.props.animationType;
if (!animationType) {
// manually setting default prop here to keep support for the deprecated 'animated' prop
animationType = 'none';
if (this.props.animated) {
animationType = 'slide';
}
}
const innerChildren = __DEV__ ?
( <AppContainer rootTag={this.context.rootTag}>
{this.props.children}
</AppContainer>) :
this.props.children;
return (
<RCTModalHostView
animationType={animationType}
transparent={this.props.transparent}
hardwareAccelerated={this.props.hardwareAccelerated}
onRequestClose={this.props.onRequestClose}
onShow={this.props.onShow}
style={styles.modal}
onStartShouldSetResponder={this._shouldSetResponder}
supportedOrientations={this.props.supportedOrientations}
onOrientationChange={this.props.onOrientationChange}
>
<View style={[styles.container, containerStyles]}>
{innerChildren}
</View>
</RCTModalHostView>
);
}
// We don't want any responder events bubbling out of the modal.
_shouldSetResponder(): boolean {
return true;
}
}
const side = I18nManager.isRTL ? 'right' : 'left';
const styles = StyleSheet.create({
modal: {
position: 'absolute',
},
container: {
position: 'absolute',
[side] : 0,
top: 0,
}
});
module.exports = Modal;
|
client/src/components/dashboard/common/ChatIconPopup.js | no-stack-dub-sack/alumni-network | import { Popup } from 'semantic-ui-react';
import propTypes from 'prop-types';
import React from 'react';
const ChatIconPopup = ({
ChatIcon,
disableChat,
initiatePrivateChat,
username
}) => {
const chatIcon = (
<ChatIcon
className="comments icon"
disableChat={disableChat}
onClick={(e) => {
!disableChat && initiatePrivateChat(username);
e.stopPropagation();
}
} />
);
return (
<Popup
content={disableChat
? `${username} does not have a Gitter account`
: `Start a Gitter chat with ${username}`}
flowing
inverted
position="bottom left"
trigger={chatIcon} />
);
}
ChatIconPopup.propTpes = {
ChatIcon: propTypes.element.isRequired,
disableChat: propTypes.bool.isRequired,
initiatePrivateChat: propTypes.func.isRequired,
username: propTypes.string.isRequired,
}
export default ChatIconPopup;
|
src/components/common/svg-icons/notification/sms.js | abzfarah/Pearson.NAPLAN.GnomeH | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NotificationSms = (props) => (
<SvgIcon {...props}>
<path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM9 11H7V9h2v2zm4 0h-2V9h2v2zm4 0h-2V9h2v2z"/>
</SvgIcon>
);
NotificationSms = pure(NotificationSms);
NotificationSms.displayName = 'NotificationSms';
NotificationSms.muiName = 'SvgIcon';
export default NotificationSms;
|
app/components/feed-content-pane/feed-content-view.js | derycktse/reedee | import React from 'react'
import styles from './feed-content-view.css'
function createMarkup(content) {
return { __html: content };
}
const FeedContentView = ({ content }) => {
return (
<div className={styles['feeds-content']}>
<div dangerouslySetInnerHTML={createMarkup(content)}>
</div>
</div>
)
}
export default FeedContentView
|
src/components/Share/index.js | hasibsahibzada/quran.com-frontend | import React from 'react';
import { ShareButtons, generateShareIcon } from 'react-share';
import styled from 'styled-components';
import * as customPropTypes from 'customPropTypes';
import FbDefault from '../../../static/images/FB-grn.png';
import TwitterDefault from '../../../static/images/Twitter-grn.png';
const { FacebookShareButton, TwitterShareButton } = ShareButtons;
const FacebookIcon = generateShareIcon('facebook');
const TwitterIcon = generateShareIcon('twitter');
const Container = styled.div`
position: relative;
top: 7px;
display: inline-block;
.iconContainer {
display: inline-block;
&:last-child {
padding-left: 5px;
}
&:hover {
cursor: pointer;
}
}
`;
const FacebookButton = styled(FacebookShareButton)`
background-image: url(${FbDefault});
background-repeat: no-repeat;
background-size: 12px;
padding-top: 1px;
`;
const TwitterButton = styled(TwitterShareButton)`
background-image: url(${TwitterDefault});
background-repeat: no-repeat;
background-size: 21px;
`;
const Share = ({ chapter, verse }) => {
// Fallback to Surah Id
let path;
if (verse) {
const translations = (verse.translations || [])
.map(translation => translation.resourceId)
.join(',');
path = `${verse.chapterId}/${verse.verseNumber}?translations=${translations}`;
} else {
path = chapter.chapterNumber;
}
const shareUrl = `https://quran.com/${path}`;
const title = verse
? `Surah ${chapter.nameSimple} [${verse.verseKey}]`
: `Surah ${chapter.nameSimple}`;
const iconProps = verse ? { iconBgStyle: { fill: '#d1d0d0' } } : {};
return (
<Container>
<FacebookButton
url={shareUrl}
title={title}
windowWidth={670}
windowHeight={540}
>
<FacebookIcon size={24} round {...iconProps} />
</FacebookButton>
<TwitterButton url={shareUrl} title={title}>
<TwitterIcon size={24} round {...iconProps} />
</TwitterButton>
</Container>
);
};
Share.propTypes = {
chapter: customPropTypes.surahType.isRequired,
verse: customPropTypes.verseType
};
export default Share;
|
app/javascript/mastodon/components/autosuggest_hashtag.js | glitch-soc/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import ShortNumber from 'mastodon/components/short_number';
import { FormattedMessage } from 'react-intl';
export default class AutosuggestHashtag extends React.PureComponent {
static propTypes = {
tag: PropTypes.shape({
name: PropTypes.string.isRequired,
url: PropTypes.string,
history: PropTypes.array,
}).isRequired,
};
render() {
const { tag } = this.props;
const weeklyUses = tag.history && (
<ShortNumber
value={tag.history.reduce((total, day) => total + day.uses * 1, 0)}
/>
);
return (
<div className='autosuggest-hashtag'>
<div className='autosuggest-hashtag__name'>
#<strong>{tag.name}</strong>
</div>
{tag.history !== undefined && (
<div className='autosuggest-hashtag__uses'>
<FormattedMessage
id='autosuggest_hashtag.per_week'
defaultMessage='{count} per week'
values={{ count: weeklyUses }}
/>
</div>
)}
</div>
);
}
}
|
src/pages/NotFound.js | DIYAbility/Capacita-Controller-Interface | import React, { Component } from 'react';
import { PageHeader } from 'react-bootstrap';
class NotFound extends Component {
render() {
return (
<div className="page">
<PageHeader>Page Not Found!</PageHeader>
</div>
);
}
}
export default NotFound;
|
app/javascript/components/RoundMap/CompetitorsList/CompetitorResult/Direction.js | skyderby/skyderby | import React from 'react'
import styled from 'styled-components'
import PropTypes from 'prop-types'
const Direction = ({ className, direction }) => (
<span className={className}>
<i className="far fa-compass" />
{direction}°
</span>
)
Direction.propTypes = {
className: PropTypes.string.isRequired,
direction: PropTypes.number.isRequired
}
export default styled(Direction)`
margin-right: 5px;
i {
font-size: 10px;
}
`
|
react-flux-mui/js/material-ui/src/svg-icons/action/timeline.js | pbogdan/react-flux-mui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionTimeline = (props) => (
<SvgIcon {...props}>
<path d="M23 8c0 1.1-.9 2-2 2-.18 0-.35-.02-.51-.07l-3.56 3.55c.05.16.07.34.07.52 0 1.1-.9 2-2 2s-2-.9-2-2c0-.18.02-.36.07-.52l-2.55-2.55c-.16.05-.34.07-.52.07s-.36-.02-.52-.07l-4.55 4.56c.05.16.07.33.07.51 0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2c.18 0 .35.02.51.07l4.56-4.55C8.02 9.36 8 9.18 8 9c0-1.1.9-2 2-2s2 .9 2 2c0 .18-.02.36-.07.52l2.55 2.55c.16-.05.34-.07.52-.07s.36.02.52.07l3.55-3.56C19.02 8.35 19 8.18 19 8c0-1.1.9-2 2-2s2 .9 2 2z"/>
</SvgIcon>
);
ActionTimeline = pure(ActionTimeline);
ActionTimeline.displayName = 'ActionTimeline';
ActionTimeline.muiName = 'SvgIcon';
export default ActionTimeline;
|
src/charts/base-chart.js | WaldoJeffers/react-dc | import React from 'react'
export default class BaseChart extends React.Component{
render(){
return <div ref={chart => this.chart = chart}></div>
}
}
|
src/svg-icons/editor/format-textdirection-r-to-l.js | IsenrichO/mui-with-arrows | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorFormatTextdirectionRToL = (props) => (
<SvgIcon {...props}>
<path d="M10 10v5h2V4h2v11h2V4h2V2h-8C7.79 2 6 3.79 6 6s1.79 4 4 4zm-2 7v-3l-4 4 4 4v-3h12v-2H8z"/>
</SvgIcon>
);
EditorFormatTextdirectionRToL = pure(EditorFormatTextdirectionRToL);
EditorFormatTextdirectionRToL.displayName = 'EditorFormatTextdirectionRToL';
EditorFormatTextdirectionRToL.muiName = 'SvgIcon';
export default EditorFormatTextdirectionRToL;
|
websocket/client/Client/node_modules/babel-plugin-react-transform/test/fixtures/code-ignore/expected.js | prayuditb/tryout-01 | import React from 'react';
const First = React.createNotClass({
displayName: 'First'
});
class Second extends React.NotComponent {}
|
src/Modal.js | Lucifier129/react-bootstrap |
/* eslint-disable react/prop-types */
import classNames from 'classnames';
import React from 'react';
import ReactDOM from 'react-dom';
import tbsUtils, { bsClass, bsSizes } from './utils/bootstrapUtils';
import { Sizes } from './styleMaps';
import getScrollbarSize from 'dom-helpers/util/scrollbarSize';
import canUseDOM from 'dom-helpers/util/inDOM';
import ownerDocument from 'dom-helpers/ownerDocument';
import events from 'dom-helpers/events';
import elementType from 'react-prop-types/lib/elementType';
import Fade from './Fade';
import ModalDialog from './ModalDialog';
import Body from './ModalBody';
import Header from './ModalHeader';
import Title from './ModalTitle';
import Footer from './ModalFooter';
import BaseModal from 'react-overlays/lib/Modal';
import isOverflowing from 'react-overlays/lib/utils/isOverflowing';
import pick from 'lodash-compat/object/pick';
const Modal = React.createClass({
propTypes: {
...BaseModal.propTypes,
...ModalDialog.propTypes,
/**
* Include a backdrop component. Specify 'static' for a backdrop that doesn't trigger an "onHide" when clicked.
*/
backdrop: React.PropTypes.oneOf(['static', true, false]),
/**
* Close the modal when escape key is pressed
*/
keyboard: React.PropTypes.bool,
/**
* Open and close the Modal with a slide and fade animation.
*/
animation: React.PropTypes.bool,
/**
* A Component type that provides the modal content Markup. This is a useful prop when you want to use your own
* styles and markup to create a custom modal component.
*/
dialogComponent: elementType,
/**
* When `true` The modal will automatically shift focus to itself when it opens, and replace it to the last focused element when it closes.
* Generally this should never be set to false as it makes the Modal less accessible to assistive technologies, like screen-readers.
*/
autoFocus: React.PropTypes.bool,
/**
* When `true` The modal will prevent focus from leaving the Modal while open.
* Consider leaving the default value here, as it is necessary to make the Modal work well with assistive technologies,
* such as screen readers.
*/
enforceFocus: React.PropTypes.bool,
/**
* Hide this from automatic props documentation generation.
* @private
*/
bsStyle: React.PropTypes.string,
/**
* When `true` The modal will show itself.
*/
show: React.PropTypes.bool,
/**
* A callback fired when the header closeButton or non-static backdrop is
* clicked. Required if either are specified.
*/
onHide: React.PropTypes.func
},
childContextTypes: {
'$bs_onModalHide': React.PropTypes.func
},
getDefaultProps() {
return {
...BaseModal.defaultProps,
bsClass: 'modal',
animation: true,
dialogComponent: ModalDialog,
};
},
getInitialState() {
return {
modalStyles: {}
};
},
getChildContext() {
return {
$bs_onModalHide: this.props.onHide
};
},
componentWillUnmount() {
events.off(window, 'resize', this.handleWindowResize);
},
render() {
let {
className
, children
, dialogClassName
, animation
, ...props } = this.props;
let { modalStyles } = this.state;
let inClass = { in: props.show && !animation };
let Dialog = props.dialogComponent;
let parentProps = pick(props,
Object.keys(BaseModal.propTypes).concat(
['onExit', 'onExiting', 'onEnter', 'onEntered']) // the rest are fired in _onHide() and _onShow()
);
let modal = (
<Dialog
key="modal"
ref={ref => this._modal = ref}
{...props}
style={modalStyles}
className={classNames(className, inClass)}
dialogClassName={dialogClassName}
onClick={props.backdrop === true ? this.handleDialogClick : null}
>
{ this.props.children }
</Dialog>
);
return (
<BaseModal
{...parentProps}
show={props.show}
ref={ref => {
this._wrapper = (ref && ref.refs.modal);
this._backdrop = (ref && ref.refs.backdrop);
}}
onEntering={this._onShow}
onExited={this._onHide}
backdropClassName={classNames(tbsUtils.prefix(props, 'backdrop'), inClass)}
containerClassName={tbsUtils.prefix(props, 'open')}
transition={animation ? Fade : undefined}
dialogTransitionTimeout={Modal.TRANSITION_DURATION}
backdropTransitionTimeout={Modal.BACKDROP_TRANSITION_DURATION}
>
{ modal }
</BaseModal>
);
},
_onShow(...args) {
events.on(window, 'resize', this.handleWindowResize);
this.setState(
this._getStyles()
);
if (this.props.onEntering) {
this.props.onEntering(...args);
}
},
_onHide(...args) {
events.off(window, 'resize', this.handleWindowResize);
if (this.props.onExited) {
this.props.onExited(...args);
}
},
handleDialogClick(e) {
if (e.target !== e.currentTarget) {
return;
}
this.props.onHide();
},
handleWindowResize() {
this.setState(this._getStyles());
},
_getStyles() {
if (!canUseDOM) {
return {};
}
let node = ReactDOM.findDOMNode(this._modal);
let doc = ownerDocument(node);
let scrollHt = node.scrollHeight;
let bodyIsOverflowing = isOverflowing(ReactDOM.findDOMNode(this.props.container || doc.body));
let modalIsOverflowing = scrollHt > doc.documentElement.clientHeight;
return {
modalStyles: {
paddingRight: bodyIsOverflowing && !modalIsOverflowing ? getScrollbarSize() : void 0,
paddingLeft: !bodyIsOverflowing && modalIsOverflowing ? getScrollbarSize() : void 0
}
};
}
});
Modal.Body = Body;
Modal.Header = Header;
Modal.Title = Title;
Modal.Footer = Footer;
Modal.Dialog = ModalDialog;
Modal.TRANSITION_DURATION = 300;
Modal.BACKDROP_TRANSITION_DURATION = 150;
export default bsSizes([Sizes.LARGE, Sizes.SMALL],
bsClass('modal', Modal)
);
|
index.js | terrylinla/react-native-sketch-canvas | import React from 'react'
import PropTypes from 'prop-types'
import ReactNative, {
View,
Text,
TouchableOpacity,
FlatList,
ViewPropTypes,
} from 'react-native'
import SketchCanvas from './src/SketchCanvas'
import { requestPermissions } from './src/handlePermissions';
export default class RNSketchCanvas extends React.Component {
static propTypes = {
containerStyle: ViewPropTypes.style,
canvasStyle: ViewPropTypes.style,
onStrokeStart: PropTypes.func,
onStrokeChanged: PropTypes.func,
onStrokeEnd: PropTypes.func,
onClosePressed: PropTypes.func,
onUndoPressed: PropTypes.func,
onClearPressed: PropTypes.func,
onPathsChange: PropTypes.func,
user: PropTypes.string,
closeComponent: PropTypes.node,
eraseComponent: PropTypes.node,
undoComponent: PropTypes.node,
clearComponent: PropTypes.node,
saveComponent: PropTypes.node,
strokeComponent: PropTypes.func,
strokeSelectedComponent: PropTypes.func,
strokeWidthComponent: PropTypes.func,
strokeColors: PropTypes.arrayOf(PropTypes.shape({ color: PropTypes.string })),
defaultStrokeIndex: PropTypes.number,
defaultStrokeWidth: PropTypes.number,
minStrokeWidth: PropTypes.number,
maxStrokeWidth: PropTypes.number,
strokeWidthStep: PropTypes.number,
savePreference: PropTypes.func,
onSketchSaved: PropTypes.func,
text: PropTypes.arrayOf(PropTypes.shape({
text: PropTypes.string,
font: PropTypes.string,
fontSize: PropTypes.number,
fontColor: PropTypes.string,
overlay: PropTypes.oneOf(['TextOnSketch', 'SketchOnText']),
anchor: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
position: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
coordinate: PropTypes.oneOf(['Absolute', 'Ratio']),
alignment: PropTypes.oneOf(['Left', 'Center', 'Right']),
lineHeightMultiple: PropTypes.number,
})),
localSourceImage: PropTypes.shape({ filename: PropTypes.string, directory: PropTypes.string, mode: PropTypes.string }),
permissionDialogTitle: PropTypes.string,
permissionDialogMessage: PropTypes.string,
};
static defaultProps = {
containerStyle: null,
canvasStyle: null,
onStrokeStart: () => { },
onStrokeChanged: () => { },
onStrokeEnd: () => { },
onClosePressed: () => { },
onUndoPressed: () => { },
onClearPressed: () => { },
onPathsChange: () => { },
user: null,
closeComponent: null,
eraseComponent: null,
undoComponent: null,
clearComponent: null,
saveComponent: null,
strokeComponent: null,
strokeSelectedComponent: null,
strokeWidthComponent: null,
strokeColors: [
{ color: '#000000' },
{ color: '#FF0000' },
{ color: '#00FFFF' },
{ color: '#0000FF' },
{ color: '#0000A0' },
{ color: '#ADD8E6' },
{ color: '#800080' },
{ color: '#FFFF00' },
{ color: '#00FF00' },
{ color: '#FF00FF' },
{ color: '#FFFFFF' },
{ color: '#C0C0C0' },
{ color: '#808080' },
{ color: '#FFA500' },
{ color: '#A52A2A' },
{ color: '#800000' },
{ color: '#008000' },
{ color: '#808000' }],
alphlaValues: ['33', '77', 'AA', 'FF'],
defaultStrokeIndex: 0,
defaultStrokeWidth: 3,
minStrokeWidth: 3,
maxStrokeWidth: 15,
strokeWidthStep: 3,
savePreference: null,
onSketchSaved: () => { },
text: null,
localSourceImage: null,
permissionDialogTitle: '',
permissionDialogMessage: '',
};
constructor(props) {
super(props)
this.state = {
color: props.strokeColors[props.defaultStrokeIndex].color,
strokeWidth: props.defaultStrokeWidth,
alpha: 'FF'
}
this._colorChanged = false
this._strokeWidthStep = props.strokeWidthStep
this._alphaStep = -1
}
clear() {
this._sketchCanvas.clear()
}
undo() {
return this._sketchCanvas.undo()
}
addPath(data) {
this._sketchCanvas.addPath(data)
}
deletePath(id) {
this._sketchCanvas.deletePath(id)
}
save() {
if (this.props.savePreference) {
const p = this.props.savePreference()
this._sketchCanvas.save(p.imageType, p.transparent, p.folder ? p.folder : '', p.filename, p.includeImage !== false, p.includeText !== false, p.cropToImageSize || false)
} else {
const date = new Date()
this._sketchCanvas.save('png', false, '',
date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + ('0' + date.getDate()).slice(-2) + ' ' + ('0' + date.getHours()).slice(-2) + '-' + ('0' + date.getMinutes()).slice(-2) + '-' + ('0' + date.getSeconds()).slice(-2),
true, true, false)
}
}
nextStrokeWidth() {
if ((this.state.strokeWidth >= this.props.maxStrokeWidth && this._strokeWidthStep > 0) ||
(this.state.strokeWidth <= this.props.minStrokeWidth && this._strokeWidthStep < 0))
this._strokeWidthStep = -this._strokeWidthStep
this.setState({ strokeWidth: this.state.strokeWidth + this._strokeWidthStep })
}
_renderItem = ({ item, index }) => (
<TouchableOpacity style={{ marginHorizontal: 2.5 }} onPress={() => {
if (this.state.color === item.color) {
const index = this.props.alphlaValues.indexOf(this.state.alpha)
if (this._alphaStep < 0) {
this._alphaStep = index === 0 ? 1 : -1
this.setState({ alpha: this.props.alphlaValues[index + this._alphaStep] })
} else {
this._alphaStep = index === this.props.alphlaValues.length - 1 ? -1 : 1
this.setState({ alpha: this.props.alphlaValues[index + this._alphaStep] })
}
} else {
this.setState({ color: item.color })
this._colorChanged = true
}
}}>
{this.state.color !== item.color && this.props.strokeComponent && this.props.strokeComponent(item.color)}
{this.state.color === item.color && this.props.strokeSelectedComponent && this.props.strokeSelectedComponent(item.color + this.state.alpha, index, this._colorChanged)}
</TouchableOpacity>
)
componentDidUpdate() {
this._colorChanged = false
}
async componentDidMount() {
const isStoragePermissionAuthorized = await requestPermissions(
this.props.permissionDialogTitle,
this.props.permissionDialogMessage,
);
}
render() {
return (
<View style={this.props.containerStyle}>
<View style={{ flexDirection: 'row' }}>
<View style={{ flexDirection: 'row', flex: 1, justifyContent: 'flex-start' }}>
{this.props.closeComponent && (
<TouchableOpacity onPress={() => { this.props.onClosePressed() }}>
{this.props.closeComponent}
</TouchableOpacity>)
}
{this.props.eraseComponent && (
<TouchableOpacity onPress={() => { this.setState({ color: '#00000000' }) }}>
{this.props.eraseComponent}
</TouchableOpacity>)
}
</View>
<View style={{ flexDirection: 'row', flex: 1, justifyContent: 'flex-end' }}>
{this.props.strokeWidthComponent && (
<TouchableOpacity onPress={() => { this.nextStrokeWidth() }}>
{this.props.strokeWidthComponent(this.state.strokeWidth)}
</TouchableOpacity>)
}
{this.props.undoComponent && (
<TouchableOpacity onPress={() => { this.props.onUndoPressed(this.undo()) }}>
{this.props.undoComponent}
</TouchableOpacity>)
}
{this.props.clearComponent && (
<TouchableOpacity onPress={() => { this.clear(); this.props.onClearPressed() }}>
{this.props.clearComponent}
</TouchableOpacity>)
}
{this.props.saveComponent && (
<TouchableOpacity onPress={() => { this.save() }}>
{this.props.saveComponent}
</TouchableOpacity>)
}
</View>
</View>
<SketchCanvas
ref={ref => this._sketchCanvas = ref}
style={this.props.canvasStyle}
strokeColor={this.state.color + (this.state.color.length === 9 ? '' : this.state.alpha)}
onStrokeStart={this.props.onStrokeStart}
onStrokeChanged={this.props.onStrokeChanged}
onStrokeEnd={this.props.onStrokeEnd}
user={this.props.user}
strokeWidth={this.state.strokeWidth}
onSketchSaved={(success, path) => this.props.onSketchSaved(success, path)}
onPathsChange={this.props.onPathsChange}
text={this.props.text}
localSourceImage={this.props.localSourceImage}
permissionDialogTitle={this.props.permissionDialogTitle}
permissionDialogMessage={this.props.permissionDialogMessage}
/>
<View style={{ flexDirection: 'row' }}>
<FlatList
data={this.props.strokeColors}
extraData={this.state}
keyExtractor={() => Math.ceil(Math.random() * 10000000).toString()}
renderItem={this._renderItem}
horizontal
showsHorizontalScrollIndicator={false}
/>
</View>
</View>
);
}
};
RNSketchCanvas.MAIN_BUNDLE = SketchCanvas.MAIN_BUNDLE;
RNSketchCanvas.DOCUMENT = SketchCanvas.DOCUMENT;
RNSketchCanvas.LIBRARY = SketchCanvas.LIBRARY;
RNSketchCanvas.CACHES = SketchCanvas.CACHES;
export {
SketchCanvas
} |
frontend/src/Movie/Editor/Delete/DeleteMovieModal.js | Radarr/Radarr | import PropTypes from 'prop-types';
import React from 'react';
import Modal from 'Components/Modal/Modal';
import DeleteMovieModalContentConnector from './DeleteMovieModalContentConnector';
function DeleteMovieModal(props) {
const {
isOpen,
onModalClose,
...otherProps
} = props;
return (
<Modal
isOpen={isOpen}
onModalClose={onModalClose}
>
<DeleteMovieModalContentConnector
{...otherProps}
onModalClose={onModalClose}
/>
</Modal>
);
}
DeleteMovieModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
onModalClose: PropTypes.func.isRequired
};
export default DeleteMovieModal;
|
src/svg-icons/av/volume-off.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let AvVolumeOff = (props) => (
<SvgIcon {...props}>
<path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/>
</SvgIcon>
);
AvVolumeOff = pure(AvVolumeOff);
AvVolumeOff.displayName = 'AvVolumeOff';
AvVolumeOff.muiName = 'SvgIcon';
export default AvVolumeOff;
|
src/svg-icons/editor/format-size.js | IsenrichO/mui-with-arrows | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorFormatSize = (props) => (
<SvgIcon {...props}>
<path d="M9 4v3h5v12h3V7h5V4H9zm-6 8h3v7h3v-7h3V9H3v3z"/>
</SvgIcon>
);
EditorFormatSize = pure(EditorFormatSize);
EditorFormatSize.displayName = 'EditorFormatSize';
EditorFormatSize.muiName = 'SvgIcon';
export default EditorFormatSize;
|
{{cookiecutter.repo_name}}/app/src/views/auth/Login.js | thorgate/django-project-template | import React from 'react';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet-async';
import { connect } from 'react-redux';
import { useTranslation } from 'react-i18next';
import AuthLayout from 'components/layouts/AuthLayout';
import LoginForm from 'forms/auth/Login';
import withView from 'decorators/withView';
import { obtainToken } from 'sagas/auth/obtainTokenSaga';
const Login = ({ onLogin }) => {
const { t } = useTranslation();
return (
<AuthLayout>
<Helmet>
<title>{t('Login')}</title>
</Helmet>
<LoginForm onLogin={onLogin} />
</AuthLayout>
);
};
Login.propTypes = {
onLogin: PropTypes.func.isRequired,
};
const mapDispatchToProps = {
onLogin: obtainToken,
};
const LoginConnector = connect(null, mapDispatchToProps)(Login);
const LoginAsView = withView()(LoginConnector);
export default LoginAsView;
|
enrolment-ui/src/modules/Projects/components/ReqForm.js | overture-stack/enrolment | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { initialize } from 'redux-form';
import RequestProgressBar from '../../Common/RequestProgressBar';
import ReqFormStep1 from './ReqFormStep1';
import ReqFormStep2 from './ReqFormStep2';
import ReqFormStep3 from './ReqFormStep3';
import {
formNextStep,
formPrevStep,
formReset,
showBillingFields,
submitProjectApplication,
} from '../redux';
import { fetchApplicationAndProject } from '../../Applications/redux';
class ReqForm extends Component {
static displayName = 'ReqForm';
constructor(props) {
super(props);
this.onSubmit = this.onSubmit.bind(this);
// Load application/project if there is an id in the URL
this.loadApplicationAndProjectIfId();
// Either load form with application/project data
// or clear it in case of new project
this.InititiateOrClearFormsOnId();
}
componentWillReceiveProps(nextProps) {
const shouldReload = !this.props.project.hasFetched && nextProps.project.hasFetched;
if (shouldReload) {
const applicationData =
nextProps.application.data && nextProps.application.data.billing_contact
? {
...nextProps.application.data,
...this.extractBillingData(nextProps.application.data.billing_contact),
}
: nextProps.application.data;
const data = {
...nextProps.project.data,
...applicationData,
};
this.InititiateOrClearFormsOnId(data);
}
}
onSubmit(data) {
const { profile: { data: { pk } }, submitProjectApplication } = this.props;
const submission = { ...data, user: pk };
submitProjectApplication(submission);
}
checkForAndReturnId() {
const { match: { params: { id = '' } } } = this.props;
const applicationId = id.length > 0 ? id : null;
if (!applicationId) return false;
return applicationId;
}
loadApplicationAndProjectIfId() {
const id = this.checkForAndReturnId();
if (id) this.props.fetchApplicationAndProject(id);
}
InititiateOrClearFormsOnId(newData = {}) {
const id = this.checkForAndReturnId();
// If id load data into form, else reset form to empty (but include daco email)
if (id) {
const applicationData =
this.props.application.data && this.props.application.data.billing_contact
? {
...this.props.application.data,
...this.extractBillingData(this.props.application.data.billing_contact),
}
: this.props.application.data;
const data = {
...this.props.project.data,
...applicationData,
...newData,
};
this.props.initializeForm(data);
} else {
const data = {
daco_email: this.props.profile.data.email,
};
this.props.initializeForm(data);
}
// Reset form pagination in all cases
this.props.formReset();
// If the form has billing data show it
if (this.props.application.data && this.props.application.data.billing_contact)
this.props.showBillingFields();
}
extractBillingData(data) {
return Object.keys(data).reduce((res, key) => {
res[`billing_${key}`] = data[key];
return res;
}, {});
}
render() {
const {
projectRequestForm: { step },
formNextStep,
formPrevStep,
} = this.props;
const steps = ['Principal Investigator', 'Collaboratory Project', 'Acceptance & Signature'];
const disabled = this.checkForAndReturnId() !== false;
return (
<div className="project">
<RequestProgressBar steps={steps} active={step} />
{step === 1 ? <ReqFormStep1 onSubmit={formNextStep} disabled={disabled} /> : null}
{step === 2 ? (
<ReqFormStep2 onSubmit={formNextStep} disabled={disabled} previousPage={formPrevStep} />
) : null}
{step === 3 ? (
<ReqFormStep3 onSubmit={this.onSubmit} disabled={disabled} previousPage={formPrevStep} />
) : null}
</div>
);
}
}
const mapStateToProps = state => {
return {
projectRequestForm: state.projectRequestForm,
profile: state.profile,
application: state.application,
project: state.project,
};
};
const mapDispatchToProps = dispatch => {
return {
formNextStep: () => dispatch(formNextStep()),
formPrevStep: () => dispatch(formPrevStep()),
formReset: () => dispatch(formReset()),
showBillingFields: () => dispatch(showBillingFields()),
fetchApplicationAndProject: id => fetchApplicationAndProject(dispatch, id),
submitProjectApplication: data => submitProjectApplication(dispatch, data),
initializeForm: data => dispatch(initialize('projectRequestForm', data)),
};
};
export default withRouter(
connect(
mapStateToProps,
mapDispatchToProps,
)(ReqForm),
);
|
CMS/redux/components/presentational/title.js | BJCheng/cs554-assignments | import React from 'react';
import { Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarTitle } from 'material-ui/Toolbar';
import FlatButton from 'material-ui/FlatButton';
import ActionAndroid from 'material-ui/svg-icons/action/android';
import ActionFavorite from 'material-ui/svg-icons/action/favorite';
import ContentCreate from 'material-ui/svg-icons/content/create';
import { blue500, yellow300 } from 'material-ui/styles/colors';
class Title extends React.Component {
render() {
const toolbarStyle = {
backgroundColor: blue500,
height: '128px'
};
return (
<Toolbar style={toolbarStyle}>
<ToolbarGroup >
<ToolbarTitle text="Title" style={{ color: '#000000' }} />
</ToolbarGroup>
</Toolbar>
);
}
}
export default Title; |
react_touchable/setup.js | devSC/react-native | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
import TouchableTest from './TouchableTest'
export default class setup extends Component {
render() {
return (
<View style={styles.container}>
<TouchableTest/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 64,
backgroundColor: '#F5FCFF',
},
}); |
docs/src/app/components/pages/components/Popover/ExampleAnimation.js | igorbt/material-ui | import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';
import Popover, {PopoverAnimationVertical} from 'material-ui/Popover';
import Menu from 'material-ui/Menu';
import MenuItem from 'material-ui/MenuItem';
export default class PopoverExampleAnimation extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false,
};
}
handleClick = (event) => {
// This prevents ghost click.
event.preventDefault();
this.setState({
open: true,
anchorEl: event.currentTarget,
});
};
handleRequestClose = () => {
this.setState({
open: false,
});
};
render() {
return (
<div>
<RaisedButton
onClick={this.handleClick}
label="Click me"
/>
<Popover
open={this.state.open}
anchorEl={this.state.anchorEl}
anchorOrigin={{horizontal: 'left', vertical: 'bottom'}}
targetOrigin={{horizontal: 'left', vertical: 'top'}}
onRequestClose={this.handleRequestClose}
animation={PopoverAnimationVertical}
>
<Menu>
<MenuItem primaryText="Refresh" />
<MenuItem primaryText="Help & feedback" />
<MenuItem primaryText="Settings" />
<MenuItem primaryText="Sign out" />
</Menu>
</Popover>
</div>
);
}
}
|
src/svg-icons/action/trending-flat.js | andrejunges/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionTrendingFlat = (props) => (
<SvgIcon {...props}>
<path d="M22 12l-4-4v3H3v2h15v3z"/>
</SvgIcon>
);
ActionTrendingFlat = pure(ActionTrendingFlat);
ActionTrendingFlat.displayName = 'ActionTrendingFlat';
ActionTrendingFlat.muiName = 'SvgIcon';
export default ActionTrendingFlat;
|
app/pages/Character/CharacterSheet/IdentityFeature.js | Technaesthetic/ua-tools | import React from 'react';
import * as CharacterActions from '../../../actions/CharacterActions';
import {ListGroupItem} from 'react-bootstrap';
export default class IdentityFeature extends React.Component {
constructor() {
super();
this.state = {
feature: {},
edit: false
}
}
componentWillMount() {
this.setState({edit: this.props.edit, feature: this.props.feature})
}
componentWillReceiveProps() {
this.setState({edit: this.props.edit, feature: this.props.feature})
}
setEdit(v) {
this.setState({edit: v})
}
render() {
const { feature } = this.props
const textFeature = () => {
return (
<ListGroupItem><strong>{feature.type} {feature.value}</strong></ListGroupItem>
)
}
const editFeature = () => {
const setWidth = function () {
return {display:"inline-block", width: 'auto'}
}
const mainSelect = () => {
return (
<select class="form-control" style={setWidth()} componentClass="select" onChange={this.props.changeFeatureType.bind(this, this.props.index)} value={feature.type}>
<optgroup label="Feature Type">
<option value="Coerces a Meter">Coerces a Meter</option>
<option value="Evaluates a Meter">Evaluates a Meter</option>
<option value="Resist Shocks to Meter">Resist Shocks to Meter</option>
<option value="Provides Firearm Attacks">Provides Firearm Attacks</option>
<option value="Provides Wound Threshold">Provides Wound Threshold</option>
<option value="Provides Initiative">Provides Initiative</option>
<option value="Medical">Medical</option>
<option value="Therapeutic">Therapeutic</option>
<option value="Casts Rituals">Casts Rituals</option>
<option value="Use Gutter Magick">Use Gutter Magick</option>
<option value="Unique">Unique</option>
</optgroup>
</select>
)
}
const meterList = ["Coerces a Meter", "Evaluates a Meter", "Resist Shocks to Meter"]
const meterSelect = () => {
return (
<select class="form-control" style={setWidth()} componentClass="select" onChange={this.props.changeFeatureValue.bind(this, this.props.index)} value={feature.value}>
<optgroup label="Meters">
<option value="helplessness">Helplessness</option>
<option value="isolation">Isolation</option>
<option value="self">Self</option>
<option value="unnatural">Unnatural</option>
<option value="violence">Violence</option>
</optgroup>
</select>
)
}
return (
<ListGroupItem>{mainSelect()} {meterList.indexOf(feature.type) != -1 ? meterSelect() : null}</ListGroupItem>
)
}
if (!this.state.edit) {
return textFeature()
} else {
return editFeature()
}
}
}
|
src/index.js | vihanchaudhry/cake-showdown | import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { createStore, applyMiddleware } from 'redux'
import { Router, browserHistory } from 'react-router'
import thunkMiddleware from 'redux-thunk'
import injectTapEventPlugin from 'react-tap-event-plugin'
import reducers from './reducers'
import routes from './routes'
import cake from './cake'
import './index.css'
injectTapEventPlugin()
const store = createStore(reducers, {
songs: cake.songs.map(song =>
Object.assign({}, song, {
wins: 0,
total: 0
})
),
showdown: {
song1: null,
song2: null
}
}, applyMiddleware(
thunkMiddleware
))
const onRouteUpdate = () => {
// Reset scroll
window.scrollTo(0, 0)
// TODO: log page view
// ReactGA
}
ReactDOM.render(
<Provider store={store}>
<Router history={browserHistory} routes={routes} onUpdate={onRouteUpdate} />
</Provider>,
document.getElementById('root')
)
|
src/svg-icons/notification/mms.js | hwo411/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NotificationMms = (props) => (
<SvgIcon {...props}>
<path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM5 14l3.5-4.5 2.5 3.01L14.5 8l4.5 6H5z"/>
</SvgIcon>
);
NotificationMms = pure(NotificationMms);
NotificationMms.displayName = 'NotificationMms';
NotificationMms.muiName = 'SvgIcon';
export default NotificationMms;
|
yycomponent/pagination/Pagination.js | 77ircloud/yycomponent | import React from 'react';
import { Pagination as _Pagination } from 'antd';
class Pagination extends React.Component{
constructor(props){
super(props);
}
static defaultProps = {
prefixCls: 'ant-pagination',
selectPrefixCls: 'ant-select',
};
render(){
return (<_Pagination {...this.props}/>);
}
}
export default Pagination
|
src/js/components/profile/edit/MultipleFieldsEdit.js | nekuno/client | import PropTypes from 'prop-types';
import React, { Component } from 'react';
import SelectedEdit from './SelectedEdit';
import TextCheckboxes from '../../ui/TextCheckboxes';
import ChoiceEdit from './ChoiceEdit/ChoiceEdit';
import IntegerEdit from '../edit/IntegerEdit';
import LocationEdit from '../edit/LocationEdit';
import TagsAndChoiceEdit from '../edit/TagsAndChoiceEdit';
import MultipleChoicesEdit from './MultipleChoicesEdit/MultipleChoicesEdit';
import MultipleLocationsEdit from '../edit/MultipleLocationsEdit';
import DoubleChoiceEdit from './DoubleChoiceEdit/DoubleChoiceEdit';
import TagEdit from '../edit/TagEdit';
import BirthdayEdit from './BirthdayEdit/BirthdayEdit';
import TextAreaEdit from '../edit/TextAreaEdit';
import translate from '../../../i18n/Translate';
import Framework7Service from '../../../services/Framework7Service';
@translate('MultipleFieldsEdit')
export default class MultipleFieldsEdit extends Component {
static propTypes = {
editKey: PropTypes.string.isRequired,
selected: PropTypes.bool.isRequired,
metadata: PropTypes.object.isRequired,
profile: PropTypes.object,
tags: PropTypes.array,
data: PropTypes.array,
handleChangeEdit: PropTypes.func.isRequired,
handleClickRemoveEdit: PropTypes.func,
};
constructor(props) {
super(props);
this.handleChangeEditAndSave = this.handleChangeEditAndSave.bind(this);
this.onFilterSelect = this.onFilterSelect.bind(this);
this.handleClickAdd = this.handleClickAdd.bind(this);
this.handleClickRemove = this.handleClickRemove.bind(this);
this.handleClickField = this.handleClickField.bind(this);
this.handleClickRemoveEdit = this.handleClickRemoveEdit.bind(this);
this.state = {
profile: props.profile,
selectedEdit: null,
selectedIndex: null,
}
}
componentWillReceiveProps(nextProps) {
const {profile, editKey} = this.props;
if ((!profile || !profile[editKey]) && nextProps.profile) {
this.setState({
profile: nextProps.profile
});
}
}
handleChangeEditAndSave(key, data) {
const {editKey, metadata, strings} = this.props;
let {profile, selectedIndex} = this.state;
profile[editKey] = profile[editKey] || [];
if (null === selectedIndex) {
profile[editKey].push({[key]: data});
this.setState({
selectedIndex: profile[editKey].length - 1,
profile : profile,
selectedEdit: null,
});
} else {
profile[editKey][selectedIndex][key] = data;
this.setState({
profile : profile,
selectedEdit: null,
});
}
let emptyKey;
if (emptyKey = Object.keys(metadata.metadata).find(fieldKey => metadata.metadata[fieldKey].required && profile[editKey].some(profileField => !profileField[fieldKey]))) {
Framework7Service.nekunoApp().alert(metadata.metadata[emptyKey].labelEdit + ' ' + strings.isRequired);
return;
}
this.props.handleChangeEdit(editKey, profile[editKey]);
}
onFilterSelect(key) {
this.setState({
selectedEdit: key,
});
}
handleClickRemoveEdit() {
const {editKey} = this.props;
this.props.handleClickRemoveEdit(editKey);
}
handleClickAdd() {
const {editKey, metadata, strings} = this.props;
let {profile, selectedIndex} = this.state;
if (null === selectedIndex || Object.keys(profile[editKey][selectedIndex]).length > 0) {
profile[editKey] = this.clearVoidItems(profile[editKey], metadata);
if (metadata.max && profile[editKey].length >= metadata.max) {
Framework7Service.nekunoApp().alert(strings.maxChoices.replace("%max%", metadata.max));
return;
}
profile[editKey].push({});
Object.keys(profile[editKey][0]).forEach(field => {
if (this.refs[field] && typeof this.refs[field].clearValue !== 'undefined') {
this.refs[field].clearValue();
}
});
this.setState({
profile : profile,
selectedIndex: profile[editKey].length - 1,
});
}
}
handleClickRemove() {
const {editKey, metadata} = this.props;
let {profile, selectedIndex} = this.state;
if (null !== selectedIndex && Object.keys(profile[editKey][selectedIndex]).length > 0) {
profile[editKey].splice(selectedIndex, 1);
profile[editKey] = this.clearVoidItems(profile[editKey], metadata);
if (profile[editKey][0]) {
Object.keys(profile[editKey][0]).forEach(field => {
if (this.refs[field] && typeof this.refs[field].clearValue !== 'undefined') {
this.refs[field].clearValue();
}
});
}
this.setState({
profile : profile,
selectedIndex: null,
});
this.props.handleChangeEdit(editKey, profile[editKey]);
}
}
handleClickField(key) {
const {editKey, metadata} = this.props;
let {profile} = this.state;
profile[editKey] = this.clearVoidItems(profile[editKey], metadata);
if (profile[editKey] && profile[editKey][key]) {
Object.keys(profile[editKey][key]).forEach(field => {
if (this.refs[field] && typeof this.refs[field].setValue !== 'undefined') {
this.refs[field].setValue(profile[editKey][key][field]);
}
});
this.setState({
profile: profile,
selectedIndex: key
});
} else {
this.setState({
profile: profile,
});
}
}
clearVoidItems = function(fields, metadata) {
if (fields && fields.length > 0) {
fields.forEach((field, index) => {
if (!field || !Object.keys(field).length || Object.keys(metadata.metadata).some(key => metadata.metadata[key].required && !field[key])) {
fields.splice(index, 1);
}
});
}
return fields;
};
renderField(dataArray, metadata, dataName) {
let data = dataArray.hasOwnProperty(dataName) ? dataArray[dataName] : null;
const selected = this.state.selectedEdit === dataName;
if (!metadata.hasOwnProperty(dataName) || metadata[dataName].editable === false) {
return '';
}
let props = {
editKey : dataName,
metadata : metadata[dataName],
selected : selected,
handleClickEdit : this.handleClickEdit
};
let filter = null;
switch (metadata[dataName]['type']) {
case 'choice':
props.data = data ? data : '';
props.handleChangeEdit = this.handleChangeEditAndSave;
filter = <ChoiceEdit {...props} />;
break;
case 'integer':
props.data = data ? parseInt(data) : null;
props.handleClickInput = this.onFilterSelect;
props.handleChangeEdit = this.handleChangeEditAndSave;
filter = <IntegerEdit {...props}/>;
break;
case 'location':
props.data = data ? data : {};
props.handleChangeEdit = this.handleChangeEditAndSave;
filter = <LocationEdit {...props}/>;
break;
case 'tags_and_choice':
props.data = data ? data : [];
props.handleChangeEdit = this.handleChangeEditAndSave;
props.handleClickInput = this.onFilterSelect;
props.tags = this.props.tags;
props.profile = this.props.profile;
props.googleSuggestions = true;
filter = <TagsAndChoiceEdit {...props}/>;
break;
case 'multiple_choices':
props.data = data ? data : [];
props.handleChangeEdit = this.handleChangeEditAndSave;
filter = <MultipleChoicesEdit {...props} />;
break;
case 'multiple_locations':
props.data = data ? data : [];
props.handleChangeEdit = this.handleChangeEditAndSave;
filter = <MultipleLocationsEdit {...props} />;
break;
case 'double_choice':
props.data = data ? data : {};
props.handleChangeEdit = this.handleChangeEditAndSave;
props.handleChangeEditDetail = this.handleChangeEditAndSave;
filter = <DoubleChoiceEdit {...props} />;
break;
case 'tags':
props.data = data ? data : [];
props.handleClickInput = this.onFilterSelect;
props.handleChangeEdit = this.handleChangeEditAndSave;
props.tags = this.props.tags;
props.profile = this.props.profile;
props.googleSuggestions = true;
filter = <TagEdit {...props} />;
break;
case 'birthday':
props.data = data ? data : null;
props.handleChangeEdit = this.handleChangeEditAndSave;
filter = <BirthdayEdit {...props} />;
break;
case 'textarea':
props.data = data ? data : null;
props.ref = dataName;
props.handleChangeEdit = this.handleChangeEditAndSave;
filter = <TextAreaEdit {...props} />;
break;
}
return <div key={dataName} ref={selected ? 'selectedEdit' : ''}>{filter}</div>;
}
renderNotSelectedText = function(data = []) {
let text = '';
for (let value in data) {
if (typeof data[value] === 'string') {
text += data[value];
break;
}
}
return text.length > 40 ? text.substr(0, 37) + '...' : text;
};
render() {
const {editKey, selected, metadata, data, strings} = this.props;
const {profile, selectedIndex} = this.state;
const selectedData = null !== selectedIndex && profile && profile[editKey] && profile[editKey][selectedIndex] ? profile[editKey][selectedIndex] : {};
return(
<SelectedEdit key={selected ? 'selected-filter' : editKey} type={'checkbox'} active={data && data.length > 0} handleClickRemoveEdit={this.props.handleClickRemoveEdit ? this.handleClickRemoveEdit : null}>
<div className="list-block text-multiple-fields">
<div className="multiple-fields-title">{metadata.labelEdit}</div>
</div>
<div className="multiple-fields">
{Object.keys(metadata.metadata).map(key => this.renderField(selectedData, metadata.metadata, key))}
</div>
{/*{null !== selectedIndex ? <div className="remove-multiple-field" onClick={this.handleClickRemove}>{strings.remove} <span className="icon-delete"></span></div> : ''}*/}
{profile[editKey] && profile[editKey].length > 0 ? <div className="add-multiple-field" onClick={this.handleClickAdd}>{strings.add} <span className="icon-plus"></span></div> : ''}
{profile[editKey] && profile[editKey].length > 0 ? profile[editKey].map((value, index) =>
index !== selectedIndex ?
<div className="tags-and-choice-unselected-filter" key={index}>
<TextCheckboxes labels={[{key: index, text: this.renderNotSelectedText(value)}]} values={[index]}
onClickHandler={this.handleClickField} className={'tags-and-choice-filter'}/>
</div>
: null
) : null}
</SelectedEdit>
);
}
}
MultipleFieldsEdit.defaultProps = {
strings: {
minChoices: 'Select at least %min% items',
maxChoices: 'Select up to %max% items',
isRequired: 'is required',
add : 'Add',
remove : 'Remove'
}
}; |
CoreCRM/ClientApp/src/views/Home/WorkBench.js | holmescn/CoreCRM | import React from 'react';
import { connect } from 'dva';
// import styles from './Index.css';
function WorkBench() {
return (
<div>工作动态,或者叫工作台</div>
);
}
WorkBench.propTypes = {
};
export default connect()(WorkBench);
|
src/index.js | wolfgio/charlotte-hotel | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
|
app/routes.js | HachiJiang/FamilyFinanceSite | 'use strict';
import React from 'react';
import { Route, IndexRedirect } from 'react-router';
import App from './containers/App';
import SummaryPage from './containers/summaryPage';
import RecordPage from './containers/RecordPage';
import IncomeStatsPage from './containers/IncomeStatsPage';
import BudgetPage from './containers/BudgetPage';
import DashboardPage from './containers/DashboardPage';
import AccountPage from './containers/AccountPage';
import OutcomePage from './containers/OutcomePage';
import IncomePage from './containers/IncomePage';
import ProjectPage from './containers/ProjectPage';
import MemberPage from './containers/MemberPage';
import DebtorPage from './containers/DebtorPage';
import ProfilePage from './containers/ProfilePage';
import NotFoundPage from './containers/NotFoundPage';
export default function createRoutes() {
return (
<Route path="/" component={ App } >
<IndexRedirect to="summary" />
<Route path="summary" component={ SummaryPage } />
<Route path="records" component={ RecordPage } />
<Route path="incomeStats" component={ IncomeStatsPage } />
<Route path="budgets" component={ BudgetPage } />
<Route path="dashboards" component={ DashboardPage } />
<Route path="accounts" component={ AccountPage } />
<Route path="outcome" component={ OutcomePage } />
<Route path="income" component={ IncomePage } />
<Route path="projects" component={ ProjectPage } />
<Route path="members" component={ MemberPage } />
<Route path="debtors" component={ DebtorPage } />
<Route path="settings" component={ ProfilePage } />
<Route path="*" component={ NotFoundPage } />
</Route>
);
} |
webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js | theforeman/foreman-tasks | import React from 'react';
import PropTypes from 'prop-types';
import { Alert, Button } from 'patternfly-react';
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
export const SelectAllAlert = ({
itemCount,
perPage,
selectAllRows,
unselectAllRows,
allRowsSelected,
}) => {
const selectAllText = (
<React.Fragment>
{sprintf(
'All %s tasks on this page are selected',
Math.min(itemCount, perPage)
)}
<Button bsStyle="link" onClick={selectAllRows}>
{__('Select All')}
<b> {itemCount} </b> {__('tasks.')}
</Button>
</React.Fragment>
);
const undoSelectText = (
<React.Fragment>
{sprintf(__(`All %s tasks are selected. `), itemCount)}
<Button bsStyle="link" onClick={unselectAllRows}>
{__('Undo selection')}
</Button>
</React.Fragment>
);
const selectAlertText = allRowsSelected ? undoSelectText : selectAllText;
return <Alert type="info">{selectAlertText}</Alert>;
};
SelectAllAlert.propTypes = {
allRowsSelected: PropTypes.bool.isRequired,
itemCount: PropTypes.number.isRequired,
perPage: PropTypes.number.isRequired,
selectAllRows: PropTypes.func.isRequired,
unselectAllRows: PropTypes.func.isRequired,
};
|
app/components/AboutPage/AboutPage.js | eguneys/react-redux-todo-app | import React from 'react';
class AboutPage extends React.Component {
render() {
return (
<div>
<h2>About Page</h2>
</div>
);
}
}
export default AboutPage;
|
src/svg-icons/image/assistant.js | verdan/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageAssistant = (props) => (
<SvgIcon {...props}>
<path d="M19 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h4l3 3 3-3h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-5.12 10.88L12 17l-1.88-4.12L6 11l4.12-1.88L12 5l1.88 4.12L18 11l-4.12 1.88z"/>
</SvgIcon>
);
ImageAssistant = pure(ImageAssistant);
ImageAssistant.displayName = 'ImageAssistant';
ImageAssistant.muiName = 'SvgIcon';
export default ImageAssistant;
|
examples/one-khz/app.js | vad3x/react-fm | /* eslint-disable react/jsx-no-bind */
import React, { Component } from 'react';
import { render } from 'react-dom';
import FrequencyMeter from 'react-fm';
class App extends Component {
static propTypes = {
audioContext: React.PropTypes.object,
fileName: React.PropTypes.string
};
static defaultProps = {
audioContext: new AudioContext(),
fileName: '1kHz_44100Hz_16bit_05sec.mp3'
};
constructor(props) {
super(props);
this.state = {
audioSource: null,
audioBuffer: null
};
}
componentDidMount() {
getAudio(this.props.fileName, (data) => {
this.props.audioContext.decodeAudioData(data, (audioBuffer) => {
this.setState({ audioBuffer });
});
});
}
play() {
const { audioContext } = this.props;
const { audioBuffer, audioSource } = this.state;
if (audioBuffer) {
if (audioSource) {
this.stop();
this.setState({ audioSource: null });
}
const audioSource1 = audioContext.createBufferSource();
this.setState({ audioSource: audioSource1 });
audioSource1.buffer = audioBuffer;
audioSource1.connect(audioContext.destination);
audioSource1.start(0, 0);
}
}
stop() {
const { audioSource } = this.state;
if (audioSource) {
audioSource.stop();
}
}
render() {
return (
<div>
<button onClick={this.play.bind(this)}>Play</button>
<button onClick={this.stop.bind(this)}>Stop</button>
<FrequencyMeter
audioSource={this.state.audioSource}
/>
</div>);
}
}
function getAudio(fileName, callback) {
const xhr = new XMLHttpRequest();
xhr.onload = () => {
callback(xhr.response);
};
xhr.open('GET', fileName, true);
xhr.responseType = 'arraybuffer';
xhr.send();
}
render(<App />, document.getElementById('example'));
|
src/components/ErrorPage.js | bradparks/filepizza_javascript_send_files_webrtc | import ErrorStore from '../stores/ErrorStore'
import React from 'react'
import Spinner from './Spinner'
export default class ErrorPage extends React.Component {
constructor() {
super()
this.state = ErrorStore.getState()
this._onChange = () => {
this.setState(ErrorStore.getState())
}
}
componentDidMount() {
ErrorStore.listen(this._onChange)
}
componentWillUnmount() {
ErrorStore.unlisten(this._onChange)
}
render() {
return <div className="page">
<Spinner dir="up" />
<h1 className="with-subtitle">FilePizza</h1>
<p className="subtitle">
<strong>{this.state.status}:</strong> {this.state.message}
</p>
{this.state.stack
? <pre>{this.state.stack}</pre>
: null}
</div>
}
}
|
app/javascript/mastodon/components/column_back_button_slim.js | dwango/mastodon | import React from 'react';
import { FormattedMessage } from 'react-intl';
import ColumnBackButton from './column_back_button';
export default class ColumnBackButtonSlim extends ColumnBackButton {
render () {
return (
<div className='column-back-button--slim'>
<div role='button' tabIndex='0' onClick={this.handleClick} className='column-back-button column-back-button--slim-button'>
<i className='fa fa-fw fa-chevron-left column-back-button__icon' />
<FormattedMessage id='column_back_button.label' defaultMessage='Back' />
</div>
</div>
);
}
}
|
src/parser/druid/balance/modules/talents/StellarFlareUptime.js | FaideWW/WoWAnalyzer | import React from 'react';
import Analyzer from 'parser/core/Analyzer';
import Enemies from 'parser/shared/modules/Enemies';
import SpellLink from 'common/SpellLink';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import { formatPercentage } from 'common/format';
import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';
class StellarFlareUptime extends Analyzer {
static dependencies = {
enemies: Enemies,
};
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTalent(SPELLS.STELLAR_FLARE_TALENT.id);
}
get suggestionThresholds() {
const stellarFlareUptime = this.enemies.getBuffUptime(SPELLS.STELLAR_FLARE_TALENT.id) / this.owner.fightDuration;
return {
actual: stellarFlareUptime,
isLessThan: {
minor: 0.95,
average: 0.9,
major: 0.8,
},
style: 'percentage',
};
}
suggestions(when) {
when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
return suggest(<>Your <SpellLink id={SPELLS.STELLAR_FLARE_TALENT.id} /> uptime can be improved. Try to pay more attention to your Moonfire on the boss.</>)
.icon(SPELLS.STELLAR_FLARE_TALENT.icon)
.actual(`${formatPercentage(actual)}% Stellar Flare uptime`)
.recommended(`>${formatPercentage(recommended)}% is recommended`);
});
}
statistic() {
const stellarFlareUptime = this.enemies.getBuffUptime(SPELLS.STELLAR_FLARE_TALENT.id) / this.owner.fightDuration;
return (
<StatisticBox
icon={<SpellIcon id={SPELLS.STELLAR_FLARE_TALENT.id} />}
value={`${formatPercentage(stellarFlareUptime)} %`}
label="Stellar Flare uptime"
/>
);
}
statisticOrder = STATISTIC_ORDER.OPTIONAL();
}
export default StellarFlareUptime;
|
docs/src/examples/elements/Segment/Types/index.js | Semantic-Org/Semantic-UI-React | import React from 'react'
import { Message } from 'semantic-ui-react'
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'
const SegmentTypesExamples = () => (
<ExampleSection title='Types'>
<ComponentExample
title='Segment'
description='A segment of content.'
examplePath='elements/Segment/Types/SegmentExampleSegment'
/>
<ComponentExample
title='Placeholder Segment'
description='A segment can be used to reserve space for conditionally displayed content.'
examplePath='elements/Segment/Types/SegmentExamplePlaceholder'
suiVersion='2.4.0'
/>
<ComponentExample examplePath='elements/Segment/Types/SegmentExamplePlaceholderInline'>
<Message info>
To use inline-block content inside a placeholder, wrap the content in{' '}
<code>inline</code>.
</Message>
</ComponentExample>
<ComponentExample examplePath='elements/Segment/Types/SegmentExamplePlaceholderGrid' />
<ComponentExample
title='Raised'
description='A segment may be formatted to raise above the page.'
examplePath='elements/Segment/Types/SegmentExampleRaised'
/>
<ComponentExample
title='Stacked'
description='A segment can be formatted to show it contains multiple pages.'
examplePath='elements/Segment/Types/SegmentExampleStacked'
/>
<ComponentExample
title='Piled'
description='A segment can be formatted to look like a pile of pages.'
examplePath='elements/Segment/Types/SegmentExamplePiled'
/>
<ComponentExample
title='Vertical Segment'
description='A vertical segment formats content to be aligned as part of a vertical group.'
examplePath='elements/Segment/Types/SegmentExampleVerticalSegment'
/>
</ExampleSection>
)
export default SegmentTypesExamples
|
src/webview/js/components/elements/element-tree-item.js | julianburr/sketch-debugger | import React, { Component } from 'react';
export default class ElementTreeItem extends Component {
constructor () {
super();
this.state = {
expanded: false
};
}
renderElementName () {
const { element } = this.props;
return (
<span>
<span className="element-class">{element.class}</span>
{element.meta &&
element.meta.name && (
<span className="element-name"> {element.meta.name}</span>
)}
</span>
);
}
renderElement () {
const { element } = this.props;
const { expanded } = this.state;
if (element.children.length > 0) {
return (
<li className={`tree-element ${expanded && 'tree-element-expanded'}`}>
<button
className="btn-expand"
onClick={() => this.setState({ expanded: !expanded })}
>
>
</button>
<span>
<span className="wrap-element">
<span className="wrap-element-open"><</span>
<span className="wrap-element-name">
{this.renderElementName()}
</span>
{element.props &&
Object.keys(element.props).map(key => (
<span className="wrap-element-prop">
{' '}
<span className="wrap-element-prop-name">{key}</span>
<span className="wrap-element-prop-equal">=</span>
<span className="wrap-element-prop-value">
{JSON.stringify(element.props[key])}
</span>
</span>
))}
<span className="wrap-element-close">></span>
</span>
{expanded ? (
element.children.map((e, i) => (
<ElementTreeItem key={i} element={e} />
))
) : (
<span className="wrap-element-child-cnt">
[{element.children.length}]
</span>
)}
<span className="wrap-element">
<span className="wrap-element-open"><</span>
<span className="wrap-element-slash">/</span>
<span className="wrap-element-name">
{this.renderElementName()}
</span>
<span className="wrap-element-close">></span>
</span>
</span>
</li>
);
}
return (
<li className="tree-element">
<span className="wrap-element">
<span className="wrap-element-open"><</span>
<span className="wrap-element-name">{this.renderElementName()}</span>
{element.props &&
Object.keys(element.props).map(key => (
<span className="wrap-element-prop">
{' '}
<span className="wrap-element-prop-name">{key}</span>
<span className="wrap-element-prop-equal">=</span>
<span className="wrap-element-prop-value">
{JSON.stringify(element.props[key])}
</span>
</span>
))}
<span className="wrap-element-slash"> /</span>
<span className="wrap-element-close">></span>
</span>
</li>
);
}
render () {
const { element } = this.props;
return <ul className="element">{this.renderElement()}</ul>;
}
}
|
public/src/components/layouts/Navigation.js | andy1992/react-redux-crud | import React from 'react';
import { Link } from 'react-router';
class NavComponent extends React.Component
{
render() {
return(
<div>
{
(!this.props.isLoggedIn) ?
<nav className="navbar navbar-default navbar-fixed-top">
<div className="container">
<div id="navbar" className="collapse navbar-collapse">
<ul className="nav navbar-nav">
<li><Link to={'/'}>Home</Link></li>
<li><Link to={'/login'}>Sign In</Link></li>
<li><Link to={'/register'}>Sign Up</Link></li>
</ul>
</div>
</div>
</nav>
:
<nav className="navbar navbar-default navbar-fixed-top">
<div className="container">
<div id="navbar" className="collapse navbar-collapse">
<ul className="nav navbar-nav">
<li><Link to={'/'}>Home</Link></li>
<li style={{paddingTop:15}}>Welcome, {this.props.user.email}</li>
<li><Link to={'/change-password'}>Change Password</Link></li>
<li><Link onClick={this.props.signOut}>Sign Out</Link></li>
</ul>
</div>
</div>
</nav>
}
</div>
);
}
}
export default NavComponent; |
example/examples/Overlays.js | parkling/react-native-maps | import React from 'react';
import {
StyleSheet,
View,
Text,
Dimensions,
} from 'react-native';
import MapView from 'react-native-maps';
const { width, height } = Dimensions.get('window');
const ASPECT_RATIO = width / height;
const LATITUDE = 37.78825;
const LONGITUDE = -122.4324;
const LATITUDE_DELTA = 0.0922;
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
const SPACE = 0.01;
class Overlays extends React.Component {
constructor(props) {
super(props);
this.state = {
region: {
latitude: LATITUDE,
longitude: LONGITUDE,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA,
},
circle: {
center: {
latitude: LATITUDE + SPACE,
longitude: LONGITUDE + SPACE,
},
radius: 700,
},
polygon: [
{
latitude: LATITUDE + SPACE,
longitude: LONGITUDE + SPACE,
},
{
latitude: LATITUDE - SPACE,
longitude: LONGITUDE - SPACE,
},
{
latitude: LATITUDE - SPACE,
longitude: LONGITUDE + SPACE,
},
],
polyline: [
{
latitude: LATITUDE + SPACE,
longitude: LONGITUDE - SPACE,
},
{
latitude: LATITUDE - (2 * SPACE),
longitude: LONGITUDE + (2 * SPACE),
},
{
latitude: LATITUDE - SPACE,
longitude: LONGITUDE - SPACE,
},
{
latitude: LATITUDE - (2 * SPACE),
longitude: LONGITUDE - SPACE,
},
],
};
}
render() {
const { region, circle, polygon, polyline } = this.state;
return (
<View style={styles.container}>
<MapView
provider={this.props.provider}
style={styles.map}
initialRegion={region}
>
<MapView.Circle
center={circle.center}
radius={circle.radius}
fillColor="rgba(255, 255, 255, 1)"
strokeColor="rgba(0,0,0,0.5)"
zIndex={2}
strokeWidth={2}
/>
<MapView.Polygon
coordinates={polygon}
fillColor="rgba(0, 200, 0, 0.5)"
strokeColor="rgba(0,0,0,0.5)"
strokeWidth={2}
/>
<MapView.Polyline
coordinates={polyline}
strokeColor="rgba(0,0,200,0.5)"
strokeWidth={3}
lineDashPattern={[5, 2, 3, 2]}
/>
</MapView>
<View style={styles.buttonContainer}>
<View style={styles.bubble}>
<Text>Render circles, polygons, and polylines</Text>
</View>
</View>
</View>
);
}
}
Overlays.propTypes = {
provider: MapView.ProviderPropType,
};
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
...StyleSheet.absoluteFillObject,
},
bubble: {
flex: 1,
backgroundColor: 'rgba(255,255,255,0.7)',
paddingHorizontal: 18,
paddingVertical: 12,
borderRadius: 20,
},
latlng: {
width: 200,
alignItems: 'stretch',
},
button: {
width: 80,
paddingHorizontal: 12,
alignItems: 'center',
marginHorizontal: 10,
},
buttonContainer: {
flexDirection: 'row',
marginVertical: 20,
backgroundColor: 'transparent',
},
});
module.exports = Overlays;
|
static/js/src/dropdown.js | maneeshpal/Missile |
import React from 'react';
import ReactDom from 'react-dom';
import immstruct from 'immstruct';
import Immutable from 'immutable';
import omniscient from 'omniscient';
const { PropTypes, cloneElement } = React;
const component = omniscient.withDefaults({
jsx: true
});
function objectExcept (obj, ...keysNotToCopy) {
const newObj = {};
Object.keys(obj)
.filter(k => keysNotToCopy.indexOf(k) === -1)
.forEach(k => newObj[k] = obj[k]);
return newObj;
}
const structure = immstruct({
items: [{
label: '2012 Camry',
href: 'http://www.google.com'
}]
});
const Trigger = component(function ({ toggle, isOpen, children }) {
return (
<div onClick={toggle} className="trigger">
{children}
</div>
);
});
const StaticOption = component(function ({ children, close }) {
return <li onClick={close}>{children}</li>;
});
const ListItemOption = component(function ({ value, label, onOptionSelect }) {
const propsToPass = objectExcept(this.props, 'onOptionSelect');
return (
<li value={value} onClick={(ev) => onOptionSelect(ev, propsToPass)}>
{label}
</li>
);
});
const Options = component(function ({ isOpen, close, onOptionSelect, children, className }) {
const optionsClass = `options ${isOpen ? 'is-open': ''}`;
const options = React.Children.map(children, (child) => cloneElement(child, { close, onOptionSelect }));
return (
<ul className={optionsClass}>
{options}
</ul>
);
});
const Dropdown = component({
getInitialState () {
return {
isOpen: false
}
},
close () {
this.setState({isOpen : false});
console.log('closed the dropdown');
},
toggle () {
this.setState({isOpen : !this.state.isOpen});
},
selectedOption (ev, listItemProps) {
this.close();
console.log('selected', ...listItemProps);
}
}, function ({ data, className, children: [trigger, options] }) {
//Here im assuming that trigger is the first child, for proof of concept
const triggerWithProps = cloneElement(trigger, {
close: this.close,
toggle: this.toggle,
isOpen: this.state.isOpen
});
const optionsWithProps = cloneElement(options, {
onOptionSelect : this.selectedOption,
isOpen: this.state.isOpen,
close: this.close
});
return (
<div className="dropdown">
{triggerWithProps}
{optionsWithProps}
</div>
);
});
const UserActionsDropDown = component({
onClick (ev) {
console.log('clicked Book Shipment button');
}
}, function ({ userActions }) {
let items = userActions.toList().map((option) =>
<StaticOption key={option.get('label')}>
<a href={option.get('href')}>
{option.get('label')}
</a>
</StaticOption>
);
items = items.push(
<StaticOption>
<button onClick={this.onClick}>Book Shipment</button>
</StaticOption>
);
return (
<Dropdown>
<Trigger>
<div>Select users actions</div>
</Trigger>
<Options>{items}</Options>
</Dropdown>
);
});
let rerendercounter = 0;
const CounterMessage = component(function ({ renderCounts }) {
return (
<div>Congrats, you won ${renderCounts()}, I re-rendered { rerendercounter++ } times</div>
);
});
const CounterIncrementor = component({
getInitialState () {
return ({
amountWon: 1000,
drawCounter : 0
})
},
incrementCounter () {
this.setState({
amountWon : this.state.amountWon + 100
});
},
draw () {
this.setState({drawCounter : this.state.drawCounter + 1 });
},
// Since this func is a mixin, it's reference does on change upon rerender. So, if you pass this func as
// callback to <CounterMessage />, it DOESNOT renrender ever,
// unless there is another prop that changes, triggering the renrender
renderCounts () {
return this.state.amountWon;
}
}, function () {
// Since this func is declared on every render, <CounterMessage /> component is FORCED to rerender everytime
// Bad bad
const renderCounts = () => {
return this.state.amountWon;
}
return (
<div>
<h3>Anti pattern: using callbacks for communication between owner and ownee</h3>
<h4>Lottery, drawn {this.state.drawCounter} times </h4>
<CounterMessage renderCounts={this.renderCounts} />
<button onClick={this.incrementCounter}>Click to Win {this.state.amountWon}</button>
<button onClick={this.draw}>Click to draw</button>
</div>
);
});
const App = component({
getInitialState () {
return {
cursor: structure.cursor()
}
},
componentWillMount () {
structure.on('swap', this.onSwap);
},
componentWillUnmount () {
structure.off('swap', this.onSwap);
},
onSwap (oldSt, newSt, keyPath) {
this.setState({ cursor: structure.cursor() });
}
}, function ({ data }) {
return (
<div>
<h4>events bubble</h4>
<UserActionsDropDown userActions={this.state.cursor.cursor('items')} />
<h4>callback example</h4>
<CounterIncrementor />
</div>
);
});
ReactDom.render(<App />, document.getElementById('react-main-mount'));
|
src/svg-icons/social/notifications-off.js | tan-jerene/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let SocialNotificationsOff = (props) => (
<SvgIcon {...props}>
<path d="M20 18.69L7.84 6.14 5.27 3.49 4 4.76l2.8 2.8v.01c-.52.99-.8 2.16-.8 3.42v5l-2 2v1h13.73l2 2L21 19.72l-1-1.03zM12 22c1.11 0 2-.89 2-2h-4c0 1.11.89 2 2 2zm6-7.32V11c0-3.08-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68c-.15.03-.29.08-.42.12-.1.03-.2.07-.3.11h-.01c-.01 0-.01 0-.02.01-.23.09-.46.2-.68.31 0 0-.01 0-.01.01L18 14.68z"/>
</SvgIcon>
);
SocialNotificationsOff = pure(SocialNotificationsOff);
SocialNotificationsOff.displayName = 'SocialNotificationsOff';
SocialNotificationsOff.muiName = 'SvgIcon';
export default SocialNotificationsOff;
|
src/js/components/NotFound.js | react-beer/the-beer-store-react-es6-firebase-oauth | import React from 'react';
import { Link } from 'react-router';
import { Grid } from 'react-bootstrap';
import Header from './Header';
import Footer from './Footer';
class NotFound extends React.Component {
render() {
return (
<Grid>
<Header />
<div className="msg-error">
<h1 className="text-warning">Page Not Found!</h1>
<p>Go to <Link to="/">Login Page</Link></p>
</div>
<Footer fixedBottom />
</Grid>
);
}
}
export default NotFound;
|
liferay-gsearch-workspace/modules/gsearch-react-web/src/main/resources/META-INF/resources/lib/App.js | peerkar/liferay-gsearch | import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Container, Menu } from 'semantic-ui-react';
import Errors from './containers/Errors/index';
import Facets from './containers/Facets/index';
import Filters from './containers/Filters/index';
import Help from './containers/Help/index';
import Message from './containers/Message/index';
import Pagination from './containers/Pagination/index';
import QuerySuggestions from './containers/QuerySuggestions/index'
import ResultLayout from './containers/ResultLayout/index';
import Results from './containers/Results/index';
import SearchField from './containers/SearchField/index';
import Sort from './containers/Sort/index';
import Stats from './containers/Stats/index'
import GSearchCommonUtil from './utils/GSearchCommonUtil';
import GSearchURLUtil from './utils/GSearchURLUtil';
import { search } from "./store/actions/search";
/**
* Redux mapping.
*
* @param {Object} dispatch
*/
function mapDispatchToProps(dispatch) {
const getSearchResults = search.request;
return bindActionCreators({ getSearchResults }, dispatch);
}
/**
* Liferay GSearch App component.
*/
class App extends React.Component {
constructor(props) {
super(props);
// Do initial query.
this.doInitialQuery();
// Bind functions to this this instance.
this.doInitialQuery = this.doInitialQuery.bind(this);
this.scrollToTop = this.scrollToTop.bind(this);
}
/**
* Does an initial query when request parameters found in the calling URL.
* i.e. this page was probably called through a search bookmark.
*/
doInitialQuery() {
let initialParams = GSearchURLUtil.parseURLParameters();
if (!GSearchCommonUtil.isEmptyObject(initialParams)) {
this.props.getSearchResults(initialParams)
}
}
/**
* Scrolls page to results top.
*/
scrollToTop() {
GSearchCommonUtil.scrollPageTo('.gsearch-results-wrapper', 600);
}
/**
* Render
*/
render() {
return (
<Container fluid className="gsearch-container">
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css" />
<Errors />
<div className="gsearch-centered-wrapper searchfield">
<div className="inner-wrapper">
<Help />
<Message />
<SearchField />
</div>
</div>
<Filters />
<Facets />
<Stats />
<QuerySuggestions />
<div className="gsearch-results-menu-wrapper">
<Menu>
<Sort />
<Menu.Menu position='right'>
<ResultLayout />
</Menu.Menu>
</Menu>
</div>
<div className="gsearch-results-wrapper">
<Results />
</div>
<Pagination scrollToTop={this.scrollToTop} />
</Container >
)
}
}
export default connect(null, mapDispatchToProps)(App);
|
packages/react-error-overlay/src/components/ErrorOverlay.js | peopleticker/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/* @flow */
import React, { Component } from 'react';
import { black } from '../styles';
import type { Node as ReactNode } from 'react';
const overlayStyle = {
position: 'relative',
display: 'inline-flex',
flexDirection: 'column',
height: '100%',
width: '1024px',
maxWidth: '100%',
overflowX: 'hidden',
overflowY: 'auto',
padding: '0.5rem',
boxSizing: 'border-box',
textAlign: 'left',
fontFamily: 'Consolas, Menlo, monospace',
fontSize: '11px',
whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
lineHeight: 1.5,
color: black,
};
type Props = {|
children: ReactNode,
shortcutHandler?: (eventKey: string) => void,
|};
type State = {|
collapsed: boolean,
|};
class ErrorOverlay extends Component<Props, State> {
iframeWindow: window = null;
getIframeWindow = (element: ?HTMLDivElement) => {
if (element) {
const document = element.ownerDocument;
this.iframeWindow = document.defaultView;
}
};
onKeyDown = (e: KeyboardEvent) => {
const { shortcutHandler } = this.props;
if (shortcutHandler) {
shortcutHandler(e.key);
}
};
componentDidMount() {
window.addEventListener('keydown', this.onKeyDown);
if (this.iframeWindow) {
this.iframeWindow.addEventListener('keydown', this.onKeyDown);
}
}
componentWillUnmount() {
window.removeEventListener('keydown', this.onKeyDown);
if (this.iframeWindow) {
this.iframeWindow.removeEventListener('keydown', this.onKeyDown);
}
}
render() {
return (
<div style={overlayStyle} ref={this.getIframeWindow}>
{this.props.children}
</div>
);
}
}
export default ErrorOverlay;
|
examples/with-react-helmet/pages/about.js | nelak/next.js | import React from 'react'
import Helmet from 'react-helmet'
export default class About extends React.Component {
static async getInitialProps ({ req }) {
if (req) {
Helmet.renderStatic()
}
return { title: 'About' }
}
render () {
const { title } = this.props
return (
<div>
<Helmet
title={`${title} | Hello next.js!`}
meta={[{ property: 'og:title', content: title }]}
/>
About the World
</div>
)
}
}
|
src/components/ChannelStrip/interface.js | ramirezd42/schmix | import React, { Component } from 'react';
import { Knob, Switch, Fader } from '../controls';
import styles from './ChannelStrip.scss';
class ChannelStripInterface extends Component {
constructor(props) {
super()
this.state = {
selectedPlugin: null
}
this.addPlugin = evt => {
if(!evt.target.value) {
return
}
props.addPlugin(props.availablePlugins[evt.target.value])
this.setState(() => ({selectedPlugin: null}))
}
this.updatePlugin = evt => props.updatePlugin(evt.target.value)
}
render() {
const pluginOptions = this.props.availablePlugins.map((plugin, index) => ( <option value={index}>{plugin.name}</option>))
return (
<div className={styles.container}>
<Switch
label="Mute"
setValue={this.props.setMute}
value={this.props.mute}
/>
<Knob
label="Pan"
value={this.props.pan}
setValue={this.props.setPan}
min={-1}
max={1}
precision={2}
/>
<select onChange={this.addPlugin} className={styles.plugins}>
<option value={false}>Add plugin</option>
{pluginOptions}
</select>
{/*
{this.props.selectedPlugins.map(plugin => (
<select onChange={this.updatePlugin} value={plugin}>
{pluginOptions}
</select>
))} */}
<Fader
value={this.props.gain}
setValue={this.props.setGain}
label="Gain"
min={0}
max={1}
step={0.01}
/>
</div>
);
}
}
ChannelStripInterface.propTypes = {
gain: React.PropTypes.number,
setGain: React.PropTypes.func,
pan: React.PropTypes.number,
setPan: React.PropTypes.func,
mute: React.PropTypes.bool,
setMute: React.PropTypes.func,
availablePlugins: React.PropTypes.array,
selectedPlugins: React.PropTypes.array,
addPlugin: React.PropTypes.func
};
export default ChannelStripInterface;
|
src/components/Header.js | rokka-io/rokka-dashboard | import PropTypes from 'prop-types'
import React from 'react'
import { Link } from 'react-router-dom'
import { toggleSidebar, logout } from '../state'
import avatarIcon from '../img/avatar-placeholder.svg'
import logoutIcon from '../img/logout-icon.svg'
import cx from 'classnames'
const Header = props => (
<header className="rka-header">
<button
className={cx('rka-link-button rka-header-menu-icon', { 'is-active': props.active })}
onClick={e => {
toggleSidebar()
e.preventDefault()
}}
/>
<Link to="/" className="rka-header-logo" />
<nav className="rka-header-nav">
<div className="rka-user">
<div className="rka-avatar">
<svg className="rka-avatar-icon">
<use xlinkHref={avatarIcon + '#avatar'} />
</svg>
</div>
<span className="rka-username">{props.auth.organization}</span>
</div>
<button
className="rka-link-button rka-logout"
onClick={e => {
e.preventDefault()
logout()
}}
>
<svg className="rka-logout-icon">
<use xlinkHref={logoutIcon + '#logout'} />
</svg>
</button>
</nav>
</header>
)
Header.propTypes = {
auth: PropTypes.shape({
organization: PropTypes.string.isRequired
}).isRequired,
active: PropTypes.bool.isRequired
}
export default Header
|
2048-clone/index.ios.js | reginbald/learning-react-native | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
} from 'react-native';
class Project extends Component {
render() {
return (
<View style={styles.container}>
<View style={{flex: 1, flexDirection: 'row'}} >
<Text style={styles.title}>2048</Text>
<View style={styles.scoreBox}>
<Text style={styles.scoreBoxTitle}>Score</Text>
<Text style={styles.scoreBoxScore}>200</Text>
</View>
<View style={styles.scoreBox}>
<Text style={styles.scoreBoxTitle}>Best</Text>
<Text style={styles.scoreBoxScore}>300</Text>
</View>
</View>
<View>
<Text>Join the numbers and get to the 2048 tile!</Text>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
backgroundColor: '#faf8ef',
},
title: {
fontSize: 30,
fontWeight: 'bold',
margin: 30,
color: '#776e65'
},
scoreBox: {
backgroundColor: '#bbada0',
},
scoreBoxTitle: {
color: '#e3d6c9'
},
scoreBoxScore: {
color: '#ffffff'
}
});
AppRegistry.registerComponent('Project', () => Project);
|
website/src/components/Footer.js | plouc/mozaik | import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
const Root = styled.footer`
color: #fff;
position: relative;
text-align: center;
line-height: 1.4;
//font-family: font-title
@media print {
display: none;
}
${props => {
if (props.isFullWidth) {
return `
padding: 40px 0 40px 300px;
`
}
return `
padding: 40px 0;
`
}}
`
const Inner = styled.div`
max-width: 1200px;
margin: 0 auto;
`
const Link = styled.a`
color: inherit;
text-decoration: none;
transition: 0.2s;
font-weight: bold;
&:hover {
color: #fff;
}
`
/*
@media only screen and (min-width: 769px) {
#footer {
text-align: left;
}
#footer-copyright {
float: left;
}
#footer-links {
float: right;
margin-top: 0;
}
}
*/
const Footer = ({ isFullWidth }) => (
<Root isFullWidth={isFullWidth}>
<Inner>
<div id="footer-copyright">
<Link href="https://github.com/plouc/mozaik">Mozaïk</Link> | Distributed under MIT License |
crafted by <Link href="https://github.com/plouc" target="_blank">Raphaël Benitte</Link> aka <Link
href="https://github.com/plouc">plouc</Link> |
Found an issue with the docs? Report it <Link
href="https://github.com/plouc/mozaik-website/issues/new">here</Link>
</div>
</Inner>
</Root>
)
Footer.propTypes = {
isFullWidth: PropTypes.bool.isRequired,
}
Footer.defaultProps = {
isFullWidth: false
}
export default Footer
|
examples/with-apollo-and-redux-saga/lib/withApollo.js | BlancheXu/test | import React from 'react'
import PropTypes from 'prop-types'
import { ApolloProvider, getDataFromTree } from 'react-apollo'
import Head from 'next/head'
import initApollo from './initApollo'
// Gets the display name of a JSX component for dev tools
function getComponentDisplayName (Component) {
return Component.displayName || Component.name || 'Unknown'
}
export default ComposedComponent => {
return class WithApollo extends React.Component {
static displayName = `WithApollo(${getComponentDisplayName(
ComposedComponent
)})`
static propTypes = {
serverState: PropTypes.object.isRequired
}
static async getInitialProps (ctx) {
// Initial serverState with apollo (empty)
let serverState = {
apollo: {
data: {}
}
}
// Evaluate the composed component's getInitialProps()
let composedInitialProps = {}
if (ComposedComponent.getInitialProps) {
composedInitialProps = await ComposedComponent.getInitialProps(ctx)
}
// Run all GraphQL queries in the component tree
// and extract the resulting data
if (typeof window === 'undefined') {
const apollo = initApollo()
try {
// Run all GraphQL queries
await getDataFromTree(
<ApolloProvider client={apollo}>
<ComposedComponent {...composedInitialProps} />
</ApolloProvider>,
{
router: {
asPath: ctx.asPath,
pathname: ctx.pathname,
query: ctx.query
}
}
)
} catch (error) {
// Prevent Apollo Client GraphQL errors from crashing SSR.
// Handle them in components via the data.error prop:
// https://www.apollographql.com/docs/react/api/react-apollo.html#graphql-query-data-error
}
// getDataFromTree does not call componentWillUnmount
// head side effect therefore need to be cleared manually
Head.rewind()
// Extract query data from the store
const state = {}
// Extract query data from the Apollo store
serverState = Object.assign(state, {
apollo: { data: apollo.cache.extract() }
})
}
return {
serverState,
...composedInitialProps
}
}
constructor (props) {
super(props)
this.apollo = initApollo(props.serverState.apollo.data)
}
render () {
return (
<ApolloProvider client={this.apollo}>
<ComposedComponent {...this.props} />
</ApolloProvider>
)
}
}
}
|
src/components/amount-buttons.js | mozilla/donate.mozilla.org | import React from 'react';
import reactGA from 'react-ga';
import { FormattedMessage, FormattedNumber } from 'react-intl';
import ErrorMessage from './error.js';
import { connect } from 'react-redux';
import { setAmount } from '../actions';
import AmountInput from './amount-input.js';
var AmountButton = React.createClass({
contextTypes: {
intl: React.PropTypes.object
},
propTypes: {
onChange: React.PropTypes.func,
amount: React.PropTypes.string,
value: React.PropTypes.string,
currencyCode: React.PropTypes.string,
showMonthlyNote: React.PropTypes.bool
},
onClickEvent: function(e) {
reactGA.event({
category: "User Flow",
action: "Changed Amount",
label: e.currentTarget.value
});
},
renderPerMonthNote: function() {
if (!this.props.showMonthlyNote) return null;
return <div className="per-month-note"> {this.context.intl.formatMessage({id: "per_month"})}</div>;
},
render: function() {
var checked = false;
if (this.props.value === this.props.amount) {
checked = true;
}
return (
<div className="third">
<input onChange={this.props.onChange}
onClick={this.onClickEvent} checked={checked}
className="amount-radio" type="radio"
name="donation_amount" value={this.props.value}
id={"amount-" + this.props.value} autoComplete="off"
/>
<label htmlFor={"amount-" + this.props.value} className="amount-button large-label-size">
{ this.props.currencyCode && this.props.value ?
<div>
<FormattedNumber
minimumFractionDigits={0}
value={this.props.value}
style="currency"
currency={this.props.currencyCode}
/>
{ this.renderPerMonthNote() }
</div> : <span> </span> }
</label>
</div>
);
}
});
var AmountOtherButton = React.createClass({
contextTypes: {
intl: React.PropTypes.object
},
propTypes: {
checked: React.PropTypes.bool.isRequired,
onRadioChange: React.PropTypes.func,
onInputChange: React.PropTypes.func,
amount: React.PropTypes.string,
currencySymbol: React.PropTypes.string,
placeholder: React.PropTypes.string
},
onRadioClick: function() {
document.querySelector("#amount-other-input").focus();
reactGA.event({
category: "User Flow",
action: "Changed Amount",
label: "Other"
});
},
onInputClick: function() {
document.querySelector("#amount-other").click();
},
onRadioChange: function() {
if (!this.props.checked) {
this.props.onRadioChange();
}
},
renderCurrencySymbol: function() {
var symbol = <span> </span>;
if (this.props.currencySymbol) {
symbol = <div>
<span>{this.props.currencySymbol}</span>
{ this.props.showMonthlyNote && <div className="per-month-note"> {this.context.intl.formatMessage({id: "per_month"})}</div> }
</div>;
}
return symbol;
},
render: function() {
return (
<div className="two-third">
<div className="amount-other-container">
<input id="amount-other" type="radio" name="donation_amount"
checked={this.props.checked}
onClick={this.onRadioClick}
onChange={this.onRadioChange}
value={this.props.amount}
autoComplete="off"
/>
<label htmlFor="amount-other" className="large-label-size">
<span className="currency-symbol-container">
{ this.renderCurrencySymbol() }
</span>
</label>
<div className="amount-other-wrapper">
<AmountInput id="amount-other-input"
className="medium-label-size" type="text"
onInputChange={this.props.onInputChange}
amount={this.props.amount}
onInputClick={this.onInputClick}
placeholder={this.props.placeholder}
/>
</div>
</div>
</div>
);
}
});
var AmountButtons = React.createClass({
contextTypes: {
intl: React.PropTypes.object
},
propTypes: {
name: React.PropTypes.string
},
getInitialState: function() {
return {
// userInputting is used to override checked amount
// buttons while the user is entering an other amount.
userInputting: false
};
},
onChange: function(e) {
this.setAmount(e.currentTarget.value, false);
},
setAmount: function(amount, userInputting) {
this.setState({
userInputting: userInputting
});
this.props.setAmount(amount);
},
otherRadioChange: function() {
this.setAmount("", true);
},
otherInputChange: function(newAmount) {
this.setAmount(newAmount, true);
},
renderErrorMessage: function() {
if (this.props.amountError === 'donation_min_error') {
return (
<FormattedMessage
id={this.props.amountError}
values={{minAmount:
<span>
{ this.props.currency.code ?
<FormattedNumber
maximumFractionDigits={2}
value={this.props.currency.minAmount}
style="currency"
currency={this.props.currency.code}
/> : "" }
</span>
}}
/>
);
}
if (this.props.amountError) {
return this.context.intl.formatMessage({id: this.props.amountError});
}
return "";
},
render: function() {
var otherAmount = "";
var amount = this.props.amount;
var presets = this.props.presets;
var preset = presets.indexOf(amount);
var frequency = this.props.frequency;
var userInputting = this.state.userInputting;
var otherChecked = userInputting || !!(amount && preset < 0);
if (otherChecked) {
otherAmount = amount;
amount = "";
}
var currency = this.props.currency;
var showMonthlyNote;
if (frequency === `monthly`) {
showMonthlyNote = true;
}
presets.sort((a,b) => parseFloat(b) - parseFloat(a));
return (
<div className="amount-buttons">
<div className="row donation-amount-row">
<AmountButton value={presets[0]} currencyCode={currency.code} amount={amount}
onChange={this.onChange} showMonthlyNote={showMonthlyNote}/>
<AmountButton value={presets[1]} currencyCode={currency.code} amount={amount}
onChange={this.onChange} showMonthlyNote={showMonthlyNote}/>
<AmountButton value={presets[2]} currencyCode={currency.code} amount={amount}
onChange={this.onChange} showMonthlyNote={showMonthlyNote}/>
</div>
<div className="row donation-amount-row">
<AmountButton value={presets[3]} currencyCode={currency.code} amount={amount}
onChange={this.onChange} showMonthlyNote={showMonthlyNote}/>
<AmountOtherButton amount={otherAmount}
currencySymbol={currency.symbol}
checked={otherChecked}
onRadioChange={this.otherRadioChange}
onInputChange={this.otherInputChange}
placeholder={this.context.intl.formatMessage({id: "other_amount"})}
showMonthlyNote={showMonthlyNote}
/>
</div>
<ErrorMessage message={this.renderErrorMessage()}/>
</div>
);
}
});
module.exports = connect(
function(state) {
return {
amount: state.donateForm.amount,
presets: state.donateForm.presets,
currency: state.donateForm.currency,
amountError: state.donateForm.amountError,
frequency: state.donateForm.frequency
};
},
function(dispatch) {
return {
setAmount: function(data) {
dispatch(setAmount(data));
}
};
})(AmountButtons);
|
fields/types/date/DateField.js | davibe/keystone | import DateInput from '../../components/DateInput';
import Field from '../Field';
import moment from 'moment';
import React from 'react';
import { Button, InputGroup, FormInput } from 'elemental';
module.exports = Field.create({
displayName: 'DateField',
focusTargetRef: 'dateInput',
// default input format
inputFormat: 'YYYY-MM-DD',
getInitialState () {
return {
value: this.props.value ? this.moment(this.props.value).format(this.inputFormat) : ''
};
},
getDefaultProps () {
return {
formatString: 'Do MMM YYYY'
};
},
moment (value) {
var m = moment(value);
if (this.props.isUTC) m.utc();
return m;
},
// TODO: Move isValid() so we can share with server-side code
isValid (value) {
return moment(value, this.inputFormat).isValid();
},
// TODO: Move format() so we can share with server-side code
format (dateValue, format) {
format = format || this.inputFormat;
return dateValue ? this.moment(this.props.dateValue).format(format) : '';
},
setDate (dateValue) {
this.setState({ value: dateValue });
this.props.onChange({
path: this.props.path,
value: this.isValid(dateValue) ? dateValue : null
});
},
setToday () {
this.setDate(moment().format(this.inputFormat));
},
valueChanged (value) {
this.setDate(value);
},
renderField () {
return (
<InputGroup>
<InputGroup.Section grow>
<DateInput ref="dateInput" name={this.props.path} format={this.inputFormat} value={this.state.value} onChange={this.valueChanged} yearRange={this.props.yearRange} />
</InputGroup.Section>
<InputGroup.Section>
<Button onClick={this.setToday}>Today</Button>
</InputGroup.Section>
</InputGroup>
);
},
renderValue () {
return <FormInput noedit>{this.format(this.props.value, this.props.formatString)}</FormInput>;
}
});
|
src/interface/report/Results/About.js | sMteX/WoWAnalyzer | import React from 'react';
import PropTypes from 'prop-types';
import { Trans, Plural } from '@lingui/macro';
import { Link } from 'react-router-dom';
import isLatestPatch from 'game/isLatestPatch';
import ReadableList from 'interface/common/ReadableList';
import Warning from 'interface/common/Alert/Warning';
import Contributor from 'interface/contributor/Button';
import Panel from 'interface/others/Panel';
class About extends React.PureComponent {
static propTypes = {
config: PropTypes.shape({
spec: PropTypes.shape({
specName: PropTypes.string.isRequired,
className: PropTypes.string.isRequired,
}).isRequired,
description: PropTypes.node.isRequired,
contributors: PropTypes.arrayOf(PropTypes.shape({
nickname: PropTypes.string.isRequired,
})).isRequired,
patchCompatibility: PropTypes.string.isRequired,
}).isRequired,
};
render() {
const { spec, description, contributors, patchCompatibility } = this.props.config;
const contributorinfo = (contributors.length !== 0) ? contributors.map(contributor => <Contributor key={contributor.nickname} {...contributor} />) : <Trans>CURRENTLY UNMAINTAINED</Trans>;
return (
<Panel
title={<Trans>About {spec.specName} {spec.className}</Trans>}
actions={(
<Link to="events">View all events</Link>
)}
>
{description}
<div className="row" style={{ marginTop: '1em' }}>
<div className="col-lg-4" style={{ fontWeight: 'bold', paddingRight: 0 }}>
<Plural
value={contributors.length}
one="Contributor"
other="Contributors"
/>
</div>
<div className="col-lg-8">
<ReadableList>
{contributorinfo}
</ReadableList>
</div>
</div>
<div className="row" style={{ marginTop: '0.5em' }}>
<div className="col-lg-4" style={{ fontWeight: 'bold', paddingRight: 0 }}>
<Trans>Updated for patch</Trans>
</div>
<div className="col-lg-8">
{patchCompatibility}
</div>
</div>
{!isLatestPatch(patchCompatibility) && (
<Warning style={{ marginTop: '1em' }}>
<Trans>The analysis for this spec is outdated. It may be inaccurate for spells that were changed since patch {patchCompatibility}.</Trans>
</Warning>
)}
</Panel>
);
}
}
export default About;
|
node_modules/enzyme/src/ShallowTraversal.js | Oritechnology/pubApp | import React from 'react';
import isEmpty from 'lodash/isEmpty';
import isSubset from 'is-subset';
import functionName from 'function.prototype.name';
import {
propsOfNode,
splitSelector,
isCompoundSelector,
selectorType,
AND,
SELECTOR,
nodeHasType,
nodeHasProperty,
} from './Utils';
export function childrenOfNode(node) {
if (!node) return [];
const maybeArray = propsOfNode(node).children;
const result = [];
React.Children.forEach(maybeArray, (child) => {
if (child !== null && child !== false && typeof child !== 'undefined') {
result.push(child);
}
});
return result;
}
export function hasClassName(node, className) {
let classes = propsOfNode(node).className || '';
classes = String(classes).replace(/\s/g, ' ');
return ` ${classes} `.indexOf(` ${className} `) > -1;
}
export function treeForEach(tree, fn) {
if (tree !== null && tree !== false && typeof tree !== 'undefined') {
fn(tree);
}
childrenOfNode(tree).forEach(node => treeForEach(node, fn));
}
export function treeFilter(tree, fn) {
const results = [];
treeForEach(tree, (node) => {
if (fn(node)) {
results.push(node);
}
});
return results;
}
function pathFilter(path, fn) {
return path.filter(tree => treeFilter(tree, fn).length !== 0);
}
export function pathToNode(node, root) {
const queue = [root];
const path = [];
const hasNode = testNode => node === testNode;
while (queue.length) {
const current = queue.pop();
const children = childrenOfNode(current);
if (current === node) return pathFilter(path, hasNode);
path.push(current);
if (children.length === 0) {
// leaf node. if it isn't the node we are looking for, we pop.
path.pop();
}
queue.push(...children);
}
return null;
}
export function parentsOfNode(node, root) {
return pathToNode(node, root).reverse();
}
export function nodeHasId(node, id) {
return propsOfNode(node).id === id;
}
export { nodeHasProperty };
export function nodeMatchesObjectProps(node, props) {
return isSubset(propsOfNode(node), props);
}
export function buildPredicate(selector) {
switch (typeof selector) {
case 'function':
// selector is a component constructor
return node => node && node.type === selector;
case 'string':
if (isCompoundSelector.test(selector)) {
return AND(splitSelector(selector).map(buildPredicate));
}
switch (selectorType(selector)) {
case SELECTOR.CLASS_TYPE:
return node => hasClassName(node, selector.slice(1));
case SELECTOR.ID_TYPE:
return node => nodeHasId(node, selector.slice(1));
case SELECTOR.PROP_TYPE: {
const propKey = selector.split(/\[([a-zA-Z-]*?)(=|])/)[1];
const propValue = selector.split(/=(.*?)]/)[1];
return node => nodeHasProperty(node, propKey, propValue);
}
default:
// selector is a string. match to DOM tag or constructor displayName
return node => nodeHasType(node, selector);
}
case 'object':
if (!Array.isArray(selector) && selector !== null && !isEmpty(selector)) {
return node => nodeMatchesObjectProps(node, selector);
}
throw new TypeError(
'Enzyme::Selector does not support an array, null, or empty object as a selector',
);
default:
throw new TypeError('Enzyme::Selector expects a string, object, or Component Constructor');
}
}
export function getTextFromNode(node) {
if (node === null || node === undefined) {
return '';
}
if (typeof node === 'string' || typeof node === 'number') {
return String(node);
}
if (node.type && typeof node.type === 'function') {
return `<${node.type.displayName || functionName(node.type)} />`;
}
return childrenOfNode(node).map(getTextFromNode)
.join('')
.replace(/\s+/, ' ');
}
|
stories/color-palette.story.js | fmakdemir/fm-story-book-react-components | import React from 'react';
import ColorPalette from 'components/color-palette';
import { storiesOf, action } from '@kadira/storybook';
// add showcases with .add
storiesOf('ColorPalette', module)
.add('blue color palette', () => (
<ColorPalette color="blue" />
))
.add('red color palette no dropdown', () => (
<ColorPalette color="red" hideDropdown={true}/>
))
.add('green color palette 400px width', () => (
<ColorPalette color="green" width='400px'/>
));
|
lib/components/NodeControl/index.js | gmtDevs/atom-ethereum-interface | 'use babel'
// Copyright 2018 Etheratom Authors
// This file is part of Etheratom.
// Etheratom is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Etheratom 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Etheratom. If not, see <http://www.gnu.org/licenses/>.
import React from 'react';
import { connect } from 'react-redux';
import { setAccounts, setSyncStatus, setMining, setHashrate, setCoinbase } from '../../actions';
import Web3 from 'web3';
import PropTypes from 'prop-types';
class NodeControl extends React.Component {
constructor(props) {
super(props);
this.helpers = props.helpers;
this.state = {
wsProvider: Object.is(props.web3.currentProvider.constructor, Web3.providers.WebsocketProvider),
httpProvider: Object.is(props.web3.currentProvider.constructor, Web3.providers.HttpProvider),
connected: props.web3.currentProvider.connected,
toAddress: '',
amount: 0,
rpcAddress: atom.config.get('etheratom.rpcAddress'),
websocketAddress: atom.config.get('etheratom.websocketAddress')
};
this._refreshSync = this._refreshSync.bind(this);
this.getNodeInfo = this.getNodeInfo.bind(this);
this._handleToAddrrChange = this._handleToAddrrChange.bind(this);
this._handleSend = this._handleSend.bind(this);
this._handleAmountChange = this._handleAmountChange.bind(this);
this._handleWsChange = this._handleWsChange.bind(this);
this._reconnect = this._reconnect.bind(this);
}
async componentDidMount() {
this.getNodeInfo();
}
async _refreshSync() {
const accounts = await this.helpers.getAccounts();
this.props.setAccounts({ accounts });
this.props.setCoinbase(accounts[0]);
this.getNodeInfo();
}
async getNodeInfo() {
// get sync status
const syncStat = await this.helpers.getSyncStat();
this.props.setSyncStatus(syncStat);
// get mining status
const mining = await this.helpers.getMining();
this.props.setMining(mining);
// get hashrate
const hashRate = await this.helpers.getHashrate();
this.props.setHashrate(hashRate);
}
_handleToAddrrChange(event) {
this.setState({ toAddress: event.target.value });
}
_handleAmountChange(event) {
this.setState({ amount: event.target.value });
}
_handleWsChange(event) {
this.setState({ websocketAddress: event.target.value });
}
_reconnect() {
// TODO: set addresses & reconnect web3
/* const { websocketAddress, rpcAddress } = this.state;
atom.config.set('etheratom.rpcAddress', rpcAddress);
atom.config.set('etheratom.websocketAddress', websocketAddress); */
}
async _handleSend() {
try {
const { password } = this.props;
const { toAddress, amount } = this.state;
const txRecipt = await this.helpers.send(toAddress, amount, password);
this.helpers.showTransaction({ head: 'Transaction recipt:', data: txRecipt });
} catch(e) {
this.helpers.showPanelError(e);
}
}
render() {
const { coinbase, status, syncing, mining, hashRate } = this.props;
const { connected, wsProvider, httpProvider, toAddress, amount, rpcAddress, websocketAddress } = this.state;
return (
<div id="NodeControl">
<div id="connections">
<ul className="connection-urls list-group">
<li className='list-item'>
<button className={(wsProvider && connected) ? 'btn btn-success' : 'btn btn-error'}>WS</button>
<input
type="string" placeholder="Address" className="input-text"
value={websocketAddress}
disabled
onChange={this._handleWsChange}
/>
</li>
<li className='list-item'>
<button className={(httpProvider && connected) ? 'btn btn-success' : 'btn btn-error'}>RPC</button>
<input
type="string" placeholder="Address" className="input-text"
disabled
value={rpcAddress}
/>
</li>
<li className='list-item'>
<span className='inline-block highlight'>Connected:</span>
<span className='inline-block'>{ `${connected}` }</span>
</li>
</ul>
</div>
<ul className='list-group'>
<li className='list-item'>
<span className='inline-block highlight'>Coinbase:</span>
<span className='inline-block'>{ coinbase }</span>
</li>
</ul>
{
(Object.keys(status).length > 0 && status instanceof Object) &&
<ul className="list-group">
<li className='list-item'>
<span className='inline-block highlight'>Sync progress:</span>
<progress className='inline-block' max='100' value={ (100 * (status.currentBlock/status.highestBlock)).toFixed(2) }></progress>
<span className='inline-block'>{ (100 * (status.currentBlock/status.highestBlock)).toFixed(2) }%</span>
</li>
<li className='list-item'>
<span className='inline-block highlight'>Current Block:</span>
<span className='inline-block'>{ status.currentBlock }</span>
</li>
<li className='list-item'>
<span className='inline-block highlight'>Highest Block:</span>
<span className='inline-block'>{ status.highestBlock }</span>
</li>
<li className='list-item'>
<span className='inline-block highlight'>Known States:</span>
<span className='inline-block'>{ status.knownStates }</span>
</li>
<li className='list-item'>
<span className='inline-block highlight'>Pulled States</span>
<span className='inline-block'>{ status.pulledStates }</span>
</li>
<li className='list-item'>
<span className='inline-block highlight'>Starting Block:</span>
<span className='inline-block'>{ status.startingBlock }</span>
</li>
</ul>
}
{
!syncing &&
<ul className="list-group">
<li className='list-item'>
<span className='inline-block highlight'>Syncing:</span>
<span className='inline-block'>{ `${syncing}` }</span>
</li>
</ul>
}
<ul className="list-group">
<li className='list-item'>
<span className='inline-block highlight'>Mining:</span>
<span className='inline-block'>{ `${mining}` }</span>
</li>
<li className='list-item'>
<span className='inline-block highlight'>Hashrate:</span>
<span className='inline-block'>{ hashRate }</span>
</li>
</ul>
<button className="btn" onClick={this._refreshSync}>Refresh</button>
<form className="row" onSubmit={this._handleSend}>
<input
type="string" placeholder="To address"
className="input-text"
value={toAddress}
onChange={this._handleToAddrrChange}
/>
<input
type="number" placeholder="Amount"
className="input-text"
value={amount}
onChange={this._handleAmountChange}
/>
<input
className='btn inline-block-tight'
type="submit"
value="Send"
/>
</form>
</div>
);
}
}
NodeControl.propTypes = {
web3: PropTypes.any.isRequired,
helpers: PropTypes.any.isRequired,
syncing: PropTypes.bool,
status: PropTypes.object,
mining: PropTypes.bool,
hashRate: PropTypes.number,
coinbase: PropTypes.number,
setHashrate: PropTypes.func,
setMining: PropTypes.func,
setSyncStatus: PropTypes.func,
setAccounts: PropTypes.func,
setCoinbase: PropTypes.func,
password: PropTypes.string,
};
const mapStateToProps = ({ account, node }) => {
const { coinbase, password } = account;
const { status, syncing, mining, hashRate } = node;
return { coinbase, password, status, syncing, mining, hashRate };
};
export default connect(mapStateToProps, { setAccounts, setCoinbase, setSyncStatus, setMining, setHashrate })(NodeControl);
|
draft-js-video-plugin/src/video/components/DefaultVideoComponent.js | koaninc/draft-js-plugins | import React from 'react';
import PropTypes from 'prop-types';
import utils from '../utils';
const YOUTUBE_PREFIX = 'https://www.youtube.com/embed/';
const VIMEO_PREFIX = 'https://player.vimeo.com/video/';
const getSrc = ({ src }) => {
const {
isYoutube,
getYoutubeSrc,
isVimeo,
getVimeoSrc,
} = utils;
if (isYoutube(src)) {
const { srcID } = getYoutubeSrc(src);
return `${YOUTUBE_PREFIX}${srcID}`;
}
if (isVimeo(src)) {
const { srcID } = getVimeoSrc(src);
return `${VIMEO_PREFIX}${srcID}`;
}
return undefined;
};
const DefaultVideoCompoent = ({
blockProps,
className = '',
style,
theme,
}) => {
const src = getSrc(blockProps);
if (src) {
return (
<div style={style} >
<div className={`${theme.iframeContainer} ${className}`}>
<iframe
className={theme.iframe}
src={src}
frameBorder="0"
allowFullScreen
/>
</div>
</div>
);
}
return (<div className={theme.invalidVideoSrc}>invalid video source</div>);
};
DefaultVideoCompoent.propTypes = {
blockProps: PropTypes.object.isRequired,
className: PropTypes.string,
style: PropTypes.object,
theme: PropTypes.object.isRequired,
};
export default DefaultVideoCompoent;
|
src/svg-icons/maps/place.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsPlace = (props) => (
<SvgIcon {...props}>
<path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>
</SvgIcon>
);
MapsPlace = pure(MapsPlace);
MapsPlace.displayName = 'MapsPlace';
MapsPlace.muiName = 'SvgIcon';
export default MapsPlace;
|
js/components/shared/TabIcon.js | kort/kort-reloaded | /* eslint-disable react/no-multi-comp */
import React from 'react';
import { Image, Platform, StyleSheet, Text, View } from 'react-native';
import I18n from 'react-native-i18n';
const styles = StyleSheet.create({
tabIcon: {
height: 30,
width: 30,
},
caption: {
textAlign: 'center',
fontSize: 8,
},
});
const TabIcon = ({ caption, icon }) => (
<View>
<Image style={styles.tabIcon} source={icon} />
<Text style={styles.caption}>{caption}</Text>
</View>
);
TabIcon.propTypes = {
caption: React.PropTypes.any.isRequired,
icon: React.PropTypes.any.isRequired,
};
const MissionsTabIcon = () => {
const caption = I18n.t('tab_bugmap');
let icon;
if (Platform.OS === 'android') {
icon = require('../../assets/tabIcons/ic_android_missions.png');
} else {
icon = require('../../assets/tabIcons/ic_android_missions.png');
}
return <TabIcon caption={caption} icon={icon} />;
};
const ProfileTabIcon = () => {
const caption = I18n.t('tab_profile');
let icon;
if (Platform.OS === 'android') {
icon = require('../../assets/tabIcons/ic_android_profile.png');
} else {
icon = require('../../assets/tabIcons/ic_android_profile.png');
}
return <TabIcon caption={caption} icon={icon} />;
};
const HighscoreTabIcon = () => {
const caption = I18n.t('tab_highscore');
let icon;
if (Platform.OS === 'android') {
icon = require('../../assets/tabIcons/ic_android_highscore.png');
} else {
icon = require('../../assets/tabIcons/ic_android_highscore.png');
}
return <TabIcon caption={caption} icon={icon} />;
};
const AboutTabIcon = () => {
const caption = I18n.t('tab_about');
let icon;
if (Platform.OS === 'android') {
icon = require('../../assets/tabIcons/ic_android_about.png');
} else {
icon = require('../../assets/tabIcons/ic_android_about.png');
}
return <TabIcon caption={caption} icon={icon} />;
};
module.exports = { MissionsTabIcon, ProfileTabIcon, HighscoreTabIcon, AboutTabIcon };
|
src/components/Main.js | kzerga/apollo-design-docs | require('normalize.css');
require('styles/App.css');
import React from 'react';
let yeomanImage = require('../images/yeoman.png');
class AppComponent extends React.Component {
render() {
return (
<div className="index">
<img src={yeomanImage} alt="Yeoman Generator" />
<div className="notice">Please edit <code>src/components/Main.js</code> to get started!</div>
</div>
);
}
}
AppComponent.defaultProps = {
};
export default AppComponent;
|
JotunheimenPlaces/node_modules/react-native/local-cli/server/middleware/heapCapture/src/heapCapture.js | designrad/Jotunheimen-tracking | /**
* Copyright (c) 2016-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.
*/
'use strict';
/*eslint no-console-disallow: "off"*/
/*global preLoadedCapture:true*/
import ReactDOM from 'react-dom';
import React from 'react';
import {
Aggrow,
AggrowData,
AggrowTable,
StringInterner,
StackRegistry,
} from './index.js';
function RefVisitor(refs, id) {
this.refs = refs;
this.id = id;
}
RefVisitor.prototype = {
moveToEdge: function moveToEdge(name) {
const ref = this.refs[this.id];
if (ref && ref.edges) {
const edges = ref.edges;
for (const edgeId in edges) {
if (edges[edgeId] === name) {
this.id = edgeId;
return this;
}
}
}
this.id = undefined;
return this;
},
moveToFirst: function moveToFirst(callback) {
const ref = this.refs[this.id];
if (ref && ref.edges) {
const edges = ref.edges;
for (const edgeId in edges) {
this.id = edgeId;
if (callback(edges[edgeId], this)) {
return this;
}
}
}
this.id = undefined;
return this;
},
forEachEdge: function forEachEdge(callback) {
const ref = this.refs[this.id];
if (ref && ref.edges) {
const edges = ref.edges;
const visitor = new RefVisitor(this.refs, undefined);
for (const edgeId in edges) {
visitor.id = edgeId;
callback(edges[edgeId], visitor);
}
}
},
getType: function getType() {
const ref = this.refs[this.id];
if (ref) {
return ref.type;
}
return undefined;
},
getRef: function getRef() {
return this.refs[this.id];
},
clone: function clone() {
return new RefVisitor(this.refs, this.id);
},
isDefined: function isDefined() {
return !!this.id;
},
getValue: function getValue() {
const ref = this.refs[this.id];
if (ref) {
if (ref.type === 'string') {
if (ref.value) {
return ref.value;
} else {
const rope = [];
this.forEachEdge((name, visitor) => {
if (name && name.startsWith('[') && name.endsWith(']')) {
const index = parseInt(name.substring(1, name.length - 1), 10);
rope[index] = visitor.getValue();
}
});
return rope.join('');
}
} else if (ref.type === 'ScriptExecutable'
|| ref.type === 'EvalExecutable'
|| ref.type === 'ProgramExecutable') {
return ref.value.url + ':' + ref.value.line + ':' + ref.value.col;
} else if (ref.type === 'FunctionExecutable') {
return ref.value.name + '@' + ref.value.url + ':' + ref.value.line + ':' + ref.value.col;
} else if (ref.type === 'NativeExecutable') {
return ref.value.function + ' ' + ref.value.constructor + ' ' + ref.value.name;
} else if (ref.type === 'Function') {
const executable = this.clone().moveToEdge('@Executable');
if (executable.id) {
return executable.getRef().type + ' ' + executable.getValue();
}
}
}
return '#none';
}
};
function forEachRef(refs, callback) {
const visitor = new RefVisitor(refs, undefined);
for (const id in refs) {
visitor.id = id;
callback(visitor);
}
}
function firstRef(refs, callback) {
for (const id in refs) {
const ref = refs[id];
if (callback(id, ref)) {
return new RefVisitor(refs, id);
}
}
return new RefVisitor(refs, undefined);
}
function getInternalInstanceName(visitor) {
const type = visitor.clone().moveToEdge('_currentElement').moveToEdge('type');
if (type.getType() === 'string') { // element.type is string
return type.getValue();
} else if (type.getType() === 'Function') { // element.type is function
const displayName = type.clone().moveToEdge('displayName');
if (displayName.isDefined()) {
return displayName.getValue(); // element.type.displayName
}
const name = type.clone().moveToEdge('name');
if (name.isDefined()) {
return name.getValue(); // element.type.name
}
type.moveToEdge('@Executable');
if (type.getType() === 'FunctionExecutable') {
return type.getRef().value.name; // element.type symbolicated name
}
}
return '#unknown';
}
function buildReactComponentTree(visitor, registry, strings) {
const ref = visitor.getRef();
if (ref.reactTree || ref.reactParent === undefined) {
return; // has one or doesn't need one
}
const parentVisitor = ref.reactParent;
if (parentVisitor === null) {
ref.reactTree = registry.insert(registry.root, strings.intern(getInternalInstanceName(visitor)));
} else if (parentVisitor) {
const parentRef = parentVisitor.getRef();
buildReactComponentTree(parentVisitor, registry, strings);
let relativeName = getInternalInstanceName(visitor);
if (ref.reactKey) {
relativeName = ref.reactKey + ': ' + relativeName;
}
ref.reactTree = registry.insert(parentRef.reactTree, strings.intern(relativeName));
} else {
throw 'non react instance parent of react instance';
}
}
function markReactComponentTree(refs, registry, strings) {
// annotate all refs that are react internal instances with their parent and name
// ref.reactParent = visitor that points to parent instance,
// null if we know it's an instance, but don't have a parent yet
// ref.reactKey = if a key is used to distinguish siblings
forEachRef(refs, (visitor) => {
const visitorClone = visitor.clone(); // visitor will get stomped on next iteration
const ref = visitor.getRef();
visitor.forEachEdge((edgeName, edgeVisitor) => {
const edgeRef = edgeVisitor.getRef();
if (edgeRef) {
if (edgeName === '_renderedChildren') {
if (ref.reactParent === undefined) {
// ref is react component, even if we don't have a parent yet
ref.reactParent = null;
}
edgeVisitor.forEachEdge((childName, childVisitor) => {
const childRef = childVisitor.getRef();
if (childRef && childName.startsWith('.')) {
childRef.reactParent = visitorClone;
childRef.reactKey = childName;
}
});
} else if (edgeName === '_renderedComponent') {
if (ref.reactParent === undefined) {
ref.reactParent = null;
}
edgeRef.reactParent = visitorClone;
}
}
});
});
// build tree of react internal instances (since that's what has the structure)
// fill in ref.reactTree = path registry node
forEachRef(refs, (visitor) => {
buildReactComponentTree(visitor, registry, strings);
});
// hook in components by looking at their _reactInternalInstance fields
forEachRef(refs, (visitor) => {
const ref = visitor.getRef();
const instanceRef = visitor.moveToEdge('_reactInternalInstance').getRef();
if (instanceRef) {
ref.reactTree = instanceRef.reactTree;
}
});
}
function functionUrlFileName(visitor) {
const executable = visitor.clone().moveToEdge('@Executable');
const ref = executable.getRef();
if (ref && ref.value && ref.value.url) {
const url = ref.value.url;
let file = url.substring(url.lastIndexOf('/') + 1);
if (file.endsWith('.js')) {
file = file.substring(0, file.length - 3);
}
return file;
}
return undefined;
}
function markModules(refs) {
const modules = firstRef(refs, (id, ref) => ref.type === 'CallbackGlobalObject');
modules.moveToEdge('require');
modules.moveToFirst((name, visitor) => visitor.getType() === 'JSActivation');
modules.moveToEdge('modules');
modules.forEachEdge((name, visitor) => {
const ref = visitor.getRef();
visitor.moveToEdge('exports');
if (visitor.getType() === 'Object') {
visitor.moveToFirst((memberName, member) => member.getType() === 'Function');
if (visitor.isDefined()) {
ref.module = functionUrlFileName(visitor);
}
} else if (visitor.getType() === 'Function') {
const displayName = visitor.clone().moveToEdge('displayName');
if (displayName.isDefined()) {
ref.module = displayName.getValue();
}
ref.module = functionUrlFileName(visitor);
}
if (ref && !ref.module) {
ref.module = '#unknown ' + name;
}
});
}
function registerPathToRootBFS(breadth, registry, strings) {
while (breadth.length > 0) {
const nextBreadth = [];
for (let i = 0; i < breadth.length; i++) {
const visitor = breadth[i];
const ref = visitor.getRef();
visitor.forEachEdge((edgeName, edgeVisitor) => {
const edgeRef = edgeVisitor.getRef();
if (edgeRef && edgeRef.rootPath === undefined) {
let pathName = edgeRef.type;
if (edgeName) {
pathName = edgeName + ': ' + pathName;
}
edgeRef.rootPath = registry.insert(ref.rootPath, strings.intern(pathName));
nextBreadth.push(edgeVisitor.clone());
// copy module and react tree forward
if (edgeRef.module === undefined) {
edgeRef.module = ref.module;
}
if (edgeRef.reactTree === undefined) {
edgeRef.reactTree = ref.reactTree;
}
}
});
}
breadth = nextBreadth;
}
}
function registerPathToRoot(capture, registry, strings) {
const refs = capture.refs;
const roots = capture.roots;
markReactComponentTree(refs, registry, strings);
markModules(refs);
let breadth = [];
// BFS from global objects first
forEachRef(refs, (visitor) => {
const ref = visitor.getRef();
if (ref.type === 'CallbackGlobalObject') {
ref.rootPath = registry.insert(registry.root, strings.intern(ref.type));
breadth.push(visitor.clone());
}
});
registerPathToRootBFS(breadth, registry, strings);
breadth = [];
// lower priority, BFS from other roots
for (const id of roots) {
const visitor = new RefVisitor(refs, id);
const ref = visitor.getRef();
if (ref.rootPath === undefined) {
ref.rootPath = registry.insert(registry.root, strings.intern(`root ${id}: ${ref.type}`));
breadth.push(visitor.clone());
}
}
registerPathToRootBFS(breadth, registry, strings);
}
function registerCapture(data, captureId, capture, stacks, strings) {
// NB: capture.refs is potentially VERY large, so we try to avoid making
// copies, even if iteration is a bit more annoying.
let rowCount = 0;
for (const id in capture.refs) { // eslint-disable-line no-unused-vars
rowCount++;
}
for (const id in capture.markedBlocks) { // eslint-disable-line no-unused-vars
rowCount++;
}
const inserter = data.rowInserter(rowCount);
registerPathToRoot(capture, stacks, strings);
const noneString = strings.intern('#none');
const noneStack = stacks.insert(stacks.root, noneString);
forEachRef(capture.refs, (visitor) => {
// want to data.append(value, value, value), not IDs
const ref = visitor.getRef();
const id = visitor.id;
inserter.insertRow(
parseInt(id, 16),
ref.type,
ref.size,
ref.cellSize,
captureId,
ref.rootPath === undefined ? noneStack : ref.rootPath,
ref.reactTree === undefined ? noneStack : ref.reactTree,
visitor.getValue(),
ref.module === undefined ? '#none' : ref.module,
);
});
for (const id in capture.markedBlocks) {
const block = capture.markedBlocks[id];
inserter.insertRow(
parseInt(id, 16),
'Marked Block Overhead',
block.capacity - block.size,
0,
captureId,
noneStack,
noneStack,
'capacity: ' + block.capacity + ', size: ' + block.size + ', granularity: ' + block.cellSize,
'#none',
);
}
inserter.done();
}
if (preLoadedCapture) {
const strings = new StringInterner();
const stacks = new StackRegistry();
const columns = [
{ name: 'id', type: 'int' },
{ name: 'type', type: 'string', strings: strings },
{ name: 'size', type: 'int' },
{ name: 'cell', type: 'int' },
{ name: 'trace', type: 'string', strings: strings },
{ name: 'path', type: 'stack', stacks: stacks, getter: x => strings.get(x), formatter: x => x },
{ name: 'react', type: 'stack', stacks: stacks, getter: x => strings.get(x), formatter: x => x },
{ name: 'value', type: 'string', strings: strings },
{ name: 'module', type: 'string', strings: strings },
];
const data = new AggrowData(columns);
registerCapture(data, 'trace', preLoadedCapture, stacks, strings);
preLoadedCapture = undefined; // let GG clean up the capture
const aggrow = new Aggrow(data);
aggrow.addPointerExpander('Id', 'id');
const typeExpander = aggrow.addStringExpander('Type', 'type');
aggrow.addNumberExpander('Size', 'size');
aggrow.addStringExpander('Trace', 'trace');
const pathExpander = aggrow.addStackExpander('Path', 'path');
const reactExpander = aggrow.addStackExpander('React Tree', 'react');
const valueExpander = aggrow.addStringExpander('Value', 'value');
const moduleExpander = aggrow.addStringExpander('Module', 'module');
aggrow.expander.setActiveExpanders([
pathExpander,
reactExpander,
moduleExpander,
typeExpander,
valueExpander,
]);
const sizeAggregator = aggrow.addSumAggregator('Size', 'size');
const cellAggregator = aggrow.addSumAggregator('Cell Size', 'cell');
const countAggregator = aggrow.addCountAggregator('Count');
aggrow.expander.setActiveAggregators([
cellAggregator,
sizeAggregator,
countAggregator,
]);
ReactDOM.render(<AggrowTable aggrow={aggrow} />, document.body);
}
|
index.js | andy9775/React-Native-CircularProgress | /*
* Coded by: Andy (github.com/andy9775)
*/
'use strict';
import React, { Component } from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
class Filled extends Component {
render() {
var size = this.props.size,
componentColor = this.props.componentColor,
progressBarColor = this.props.progressBarColor,
leftProgressBarRotate = 0, rightProgressBarRotate = 0,
rotate = this.props.rotate >= 360 ? 360 : this.props.rotate,
rightProgressBarColor = this.props.progressBarColor;
if (rotate < 180) {
rightProgressBarRotate = rotate;
leftProgressBarRotate = 0;
} else {
rightProgressBarRotate = 0;
leftProgressBarRotate = rotate - 180;
rightProgressBarColor = progressBarColor;
}
var leftProgressDisplay = (
<View
style={{backgroundColor: 'transparent',position: 'absolute', width: size, height: size,
transform: [{rotate: leftProgressBarRotate + 'deg'}]}}>
<View style={{position: 'absolute', flex:1, width: size/2, height: size,
borderTopLeftRadius: size/2, borderBottomLeftRadius: size/2, backgroundColor: componentColor}}/>
<View style={{position: 'absolute', flex:1, width: size/2, height: size, left: size/2,
borderTopRightRadius: size/2, borderBottomRightRadius: size/2,backgroundColor: progressBarColor}}/>
</View>
);
var rightProgressDisplay = (
<View style={{backgroundColor: 'transparent', position: 'absolute', width: size, height: size,
transform: [{rotate: rightProgressBarRotate + 'deg'}]}}>
<View style={{position: 'absolute', flex:1, width: size/2, height: size,
borderTopLeftRadius: size/2, borderBottomLeftRadius: size/2, backgroundColor: 'transparent'}}/>
{rotate < 180 ? (<View style={{position: 'absolute', flex:1, width: size, height: size, left: size/2,
borderTopRightRadius: size/2, borderBottomRightRadius: size/2, backgroundColor: componentColor}}/>) :
(<View style={{position: 'absolute', flex:1, width: size/2, height: size ,
left: size/2, backgroundColor: progressBarColor,
borderBottomRightRadius: size/2, borderTopRightRadius: size/2}}/>
)}
</View>);
return (
<View style={{width: size, height: size, overflow: 'hidden', borderRadius: size/2}}>
{leftProgressDisplay}
{rightProgressDisplay}
</View>
);
}
}
Filled.propTypes = {
size: PropTypes.number,
rotate: PropTypes.number,
componentColor: PropTypes.string,
progressColor: PropTypes.string
}
class Hollow extends Component {
render(){
var rotateValue = this.props.rotate >= 360 ? 360 : this.props.rotate;
var size = this.props.size,
progressBarWidth = this.props.progressBarWidth,
backgroundColor = this.props.backgroundColor,
progressBarColor = this.props.progressBarColor,
outlineWidth = this.props.outlineWidth || 0,
outlineColor = this.props.outlineColor || 'transparent',
leftRotate = 0, rightRotate = 0;
if (rotateValue < 180) {
rightRotate = rotateValue;
} else {
leftRotate = rotateValue - 180;
}
var leftProgressBar = (
<View
style={{width: size, height: size, backgroundColor: 'transparent', position: 'absolute'}}
key="leftProgressBar"
>
<View style={{width: size/2, height: size, position: 'absolute',
borderBottomLeftRadius: size/2, borderTopLeftRadius: size/2,
borderRightWidth: 0,backgroundColor: backgroundColor,
borderTopWidth: progressBarWidth, borderBottomWidth: progressBarWidth, borderLeftWidth: progressBarWidth,
borderLeftColor: progressBarColor, borderTopColor: progressBarColor, borderBottomColor: progressBarColor}}/>
<View style={{width: size/2, height: size, left: size/2,
position: 'absolute', backgroundColor: backgroundColor}}/>
</View>
);
var rightProgressBar = (
<View
style={{width: size, height: size, backgroundColor: 'transparent', position: 'absolute'}}
key="rightProgressBar"
>
<View style={{width: size/2, height: size, position: 'absolute', backgroundColor: 'transparent'}}/>
<View style={{width: size/2, height: size, position: 'absolute', left: size/2,
borderBottomRightRadius: size/2, borderTopRightRadius: size/2,
borderLeftWidth: 0, backgroundColor: backgroundColor,
borderTopWidth: progressBarWidth, borderBottomWidth: progressBarWidth, borderRightWidth: progressBarWidth,
borderRightColor: progressBarColor, borderTopColor: progressBarColor, borderBottomColor: progressBarColor}}/>
</View>
);
var leftProgressOverlay = (
<View style={{width: size, height: size,position: 'absolute', backgroundColor: 'transparent',
transform: [{rotate: leftRotate + 'deg'}]}}
key="leftProgressOverlay"
>
<View style={{width: size/2, height: size, position: 'absolute', backgroundColor: backgroundColor}}/>
<View
style={{width: size/2, height: size, position: 'absolute', backgroundColor: 'transparent', left: size/2}}/>
</View>
);
var rightProgressOverlay = (
<View style={{width: size, height: size, position: 'absolute', backgroundColor: 'transparent',
transform: [{rotate: rightRotate + 'deg'}]}}
key="rightProgressOverlay"
>
<View style={{width: size/2, height: size, position: 'absolute', backgroundColor: 'transparent'}}/>
<View
style={{width: size/2, height: size, position: 'absolute', backgroundColor: backgroundColor, left: size/2}}/>
</View>
);
var innerView = this.props.innerComponent ? (
<View style={{width: size - progressBarWidth*2, height: size - progressBarWidth*2,
borderRadius: (size - progressBarWidth*2)/2,
overflow: 'hidden', backgroundColor: 'transparent',
position: 'absolute', left: progressBarWidth, top: progressBarWidth,
justifyContent: 'center', alignItems:'center'}}>
{this.props.innerComponent}
</View>
) : (<View/>);
var views;
if (rotateValue < 180) {
views = [leftProgressBar, leftProgressOverlay, rightProgressBar, rightProgressOverlay];
} else {
views = [leftProgressBar, leftProgressOverlay, rightProgressBar];
}
return (
<View
style={{width: size + (outlineWidth * 2), height: size + (outlineWidth * 2), overflow: 'hidden',
borderRadius: (size + (outlineWidth * 2))/2, borderWidth: outlineWidth, borderColor: outlineColor}}>
{views}
{innerView}
</View>
);
}
}
Hollow.propTypes = {
size: PropTypes.number,
progressBarWidth: PropTypes.number,
backgroundColor: PropTypes.string,
progressBarColor: PropTypes.string,
outlineWidth: PropTypes.number,
outlineColor: PropTypes.string,
rotate: PropTypes.number,
innerComponent: PropTypes.element
}
module.exports = {Hollow, Filled};
|
src/react/FacebookAuthWebView.js | laundree/app | // @flow
import React from 'react'
import AuthWebView from './AuthWebView'
import config from '../config'
type Props = { onAuthFailed: () => void, onSuccess: () => void }
const FacebookAuthWebView = ({onAuthFailed, onSuccess}: Props) => <AuthWebView
onAuthFailed={onAuthFailed} onSuccess={onSuccess}
source={{uri: `${config.laundree.host}/auth/facebook?mode=native-app-v2`}} />
export default FacebookAuthWebView
|
src/UserDetails.js | ramalhovfc/fisioManager | import React from 'react';
import {browserHistory} from 'react-router';
import axios from 'axios';
import style from './style';
import Incident from '../model/pojo/incidentPojo';
import IncidentList from './IncidentList';
const LOOKUPS_NEEDED = {
'doctor': true,
'insurance': true,
'pathology': true,
'physiotherapist': true
};
class UserDetails extends React.Component {
constructor() {
super();
this.state = {
user: null,
incidents: null,
tabActiveKey: 1,
lookups: []
};
this.onSelectTab = this.onSelectTab.bind(this);
this.onIncidentSave = this.onIncidentSave.bind(this);
this.onAddNewIncidentClick = this.onAddNewIncidentClick.bind(this);
this.onIncidentDetailsFieldChange = this.onIncidentDetailsFieldChange.bind(this);
this.onDeleteIncidentClick = this.onDeleteIncidentClick.bind(this);
this.onUserDetailsClick = this.onUserDetailsClick.bind(this);
}
componentWillMount() {
let userId = this.props.params.user_id;
let incidentId = this.props.location.query.incidentId;
axios.all([this.getLookups(LOOKUPS_NEEDED), this.getUserDetails(userId, incidentId)])
.catch((error) => {
// this.setState({
// userAddError: (error.response && error.response.data) || 'Ocorreu um erro ao obter lookups'
// });
return Promise.reject();
})
.then(axios.spread((lookups, userDetails) => {
let tabToOpen = this.state.tabActiveKey;
if (incidentId && userDetails.data.incidents) {
for (let i = 0; i < userDetails.data.incidents.length; i++) {
if (incidentId === userDetails.data.incidents[i]["_id"]) {
tabToOpen = i + 1;
break;
}
}
}
for (let i = 0; i < userDetails.data.incidents.length; i++) {
if (userDetails.data.incidents[i].startDate) {
userDetails.data.incidents[i].startDate = userDetails.data.incidents[i].startDate.slice(0, 10);
}
if (userDetails.data.incidents[i].endDate) {
userDetails.data.incidents[i].endDate = userDetails.data.incidents[i].endDate.slice(0, 10);
}
}
this.setState({
lookups: lookups.data,
user: userDetails.data.user,
incidents: userDetails.data.incidents,
tabActiveKey: tabToOpen
});
}));
}
getLookups(lookupsToGet) {
return axios.get(`${this.props.route.lookupsUrl}`, {params: {lookupsToGet}});
}
getUserDetails(userId, incidentId) {
return axios.get(`${this.props.route.userAndIncidentsFindUrl}/${userId}`);
}
onAddNewIncidentClick() {
var incident = new Incident();
incident["_user"] = this.state.user["_id"];
axios.post(`${this.props.route.incidentUrl}`, incident)
.then(res => {
var newIncidents = this.state.incidents.concat(res.data);
this.setState({
incidents: newIncidents,
tabActiveKey: newIncidents.length
});
});
}
onIncidentSave(incident) {
axios.put(`${this.props.route.incidentUrl}/${incident["_id"]}`, incident)
.then(res => {
var incidents = this.state.incidents.slice();
for (let i = 0; i < incidents.length; i++) {
if (incidents[i]["_id"] === res.data["_id"]) {
incidents[i] = res.data;
if (incidents[i].startDate) {
incidents[i].startDate = incidents[i].startDate.slice(0, 10);
}
if (incidents[i].endDate) {
incidents[i].endDate = incidents[i].endDate.slice(0, 10);
}
this.setState({ incidents: incidents });
break;
}
}
axios.post(`${this.props.route.lookupsUrl}`, incident);
});
}
onIncidentDetailsFieldChange(incidentProperty, value, incidentId) {
var incidents = this.state.incidents.slice();
for (let i = 0; i < incidents.length; i++) {
if (incidents[i]["_id"] === incidentId) {
incidents[i][incidentProperty] = value;
incidents[i].needsSaving = true;
this.setState({
incidents: incidents
});
break;
}
}
}
onSelectTab(key) {
this.setState({
tabActiveKey: key
});
}
onDeleteIncidentClick(incident) {
axios.delete(`${this.props.route.incidentUrl}/${incident["_id"]}`)
.then(res => {
var incidents = this.state.incidents.slice();
for (let i = incidents.length - 1; i >= 0; i--) {
if (incidents[i]["_id"] === incident["_id"]) {
incidents.splice(i, 1);
this.setState({
incidents: incidents,
tabActiveKey: (this.state.tabActiveKey - 1) || 1
});
break;
}
}
});
}
onPrintIncidentClick(incidentId) {
browserHistory.push('/print/' + incidentId);
}
onUserDetailsClick(e) {
e.preventDefault();
var allIncidentsAreSaved = true;
for (var incident of this.state.incidents) {
if (incident.needsSaving) {
allIncidentsAreSaved = false;
}
}
if (!allIncidentsAreSaved) {
var r = confirm("Existem fichas não gravadas. Tem a certeza que pretende continuar?");
if (r === true) {
browserHistory.push('/user/edit/' + this.state.user['_id']);
}
} else {
browserHistory.push('/user/edit/' + this.state.user['_id']);
}
}
render() {
if (this.state.user) {
return (
<div style={ style.userDetailsContainer }>
<div className="userDetailsHeader" onClick={ this.onUserDetailsClick }>
<h2 style={ style.usernameInUserDetails }>{ this.state.user.name }</h2>
<dl className="dl-horizontal">
<dt>Telefone</dt>
<dd>{ this.state.user.telephone }</dd>
<dt>Contribuinte</dt>
<dd>{ this.state.user.taxNumber }</dd>
<dt>Sexo</dt>
<dd>{ this.state.user.genre }</dd>
<dt>Morada</dt>
<dd>{ this.state.user.postalAddress }</dd>
<dt>Profissão</dt>
<dd>{ this.state.user.job }</dd>
</dl>
</div>
<IncidentList data={{incidents: this.state.incidents, lookups: this.state.lookups }} tabActiveKey={ this.state.tabActiveKey } onSelectTab={ this.onSelectTab } onIncidentSave={ this.onIncidentSave } onIncidentDetailsFieldChange={ this.onIncidentDetailsFieldChange } onAddNewIncidentClick={ this.onAddNewIncidentClick } onDeleteIncidentClick={ this.onDeleteIncidentClick } onPrintIncidentClick={ this.onPrintIncidentClick } />
</div>
);
}
return ( <div>Loading...</div> );
}
}
export default UserDetails; |
components/NavLinkButton.js | gdad-s-river/harshini-portfolio | import React from 'react'
import { Link } from 'react-router'
import MultiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import RaisedButton from 'material-ui/RaisedButton'
import { browserHistory } from 'react-router'
import "../css/sitefont.css"
// import {}
function onClickHandler(e, whereTo, bulbFrameAnime, triggerArrowClickHandlerGeneric, artistNameAnime, toggleWasNavLinkClicked) {
// call frame and bulb animation animation
const loaderTextPhrase = e.target.textContent;
toggleWasNavLinkClicked(() => {}, loaderTextPhrase);
bulbFrameAnime();
triggerArrowClickHandlerGeneric();
// browserHistory.push(`${whereTo.replace(/\s/g,'')}/`); // this has to be after the bulbAnime is over
}
const RaisedButtonLink = (props) => {
const buttonLinkStyle = {
flex: 1,
padding: "0"
};
const { whereTo, bulbFrameAnime, artistNameAnime, triggerArrowClickHandlerGeneric, toggleWasNavLinkClicked, ...originalNeededProps} = props;
function onClickHandlerWrapper(e) {
onClickHandler(e, whereTo, bulbFrameAnime, triggerArrowClickHandlerGeneric, artistNameAnime, toggleWasNavLinkClicked)
}
const labelStyle = {
fontSize: "1.2rem",
fontFamily: "SiteFont, Arial"
}
const overlayStyle= {
padding: "15px 0"
}
let that = this;
return (
<MultiThemeProvider>
{/* pass animatino callback function here to execute right */}
<Link onClick={ onClickHandlerWrapper }
style={buttonLinkStyle}>
<RaisedButton
{...originalNeededProps}
fullWidth={true}
labelColor= "#fff"
labelStyle={labelStyle}
buttonStyle={{
height: "100%"
}}
overlayStyle={overlayStyle}
style={{
height: "100%"
}}/>
</Link>
</MultiThemeProvider>
)
}
export default RaisedButtonLink
|
examples/react-bootstrap/src/index.js | gaearon/react-hot-loader | import React from 'react';
import { render } from 'react-dom';
import App from './App';
const root = document.createElement('div');
document.body.appendChild(root);
render(<App />, root);
|
packages/icons/src/md/social/WhatsHot.js | suitejs/suitejs | import React from 'react';
import IconBase from '@suitejs/icon-base';
function MdWhatsHot(props) {
return (
<IconBase viewBox="0 0 48 48" {...props}>
<path d="M27 3c7.81 6.25 13 15.87 13 26.66 0 8.84-7.16 16-16 16s-16-7.16-16-16c0-6.77 2.43-12.97 6.45-17.78l-.05.72c0 4.13 3.12 7.47 7.25 7.47s6.83-3.35 6.83-7.47C28.48 8.3 27 3 27 3zm-3.58 36.66c5.3 0 9.6-4.31 9.6-9.6 0-2.77-.41-5.49-1.19-8.07-2.03 2.74-5.69 4.44-9.23 5.15s-5.63 2.99-5.63 6.24c0 3.47 2.89 6.28 6.45 6.28z" />
</IconBase>
);
}
export default MdWhatsHot;
|
examples/cra/src/index.js | sapegin/react-styleguidist | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(<App />, document.getElementById('root'));
|
src/app/components/media/MediaPageLayout.js | meedan/check-web | import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import Media from './Media';
import MediaActionsBar from './MediaActionsBar';
import NextPreviousLinks from './NextPreviousLinks';
const StyledTopBar = styled.div`
display: flex;
flex-wrap: wrap;
width: 60%;
position: absolute;
height: 64px;
right: 0;
top: 0;
display: flex;
align-items: center;
z-index: 2;
padding: 0 16px;
justify-content: space-between;
`;
export default function MediaPageLayout({
listUrl, buildSiblingUrl, listQuery, listIndex, projectId, projectMediaId, view, mediaNavList, count,
}) {
return (
<div>
{buildSiblingUrl ? (
<NextPreviousLinks
buildSiblingUrl={buildSiblingUrl}
listQuery={listQuery}
listIndex={listIndex}
objectType="media"
mediaNavList={mediaNavList}
count={count}
/>
) : null}
<StyledTopBar className="media-search__actions-bar">
<MediaActionsBar
key={`${listUrl}-${projectMediaId}` /* TODO test MediaActionsBar is sane, then nix key */}
listUrl={listUrl}
listQuery={listQuery}
listIndex={listIndex}
projectId={projectId}
projectMediaId={projectMediaId}
/>
</StyledTopBar>
<Media projectId={projectId} projectMediaId={projectMediaId} view={view} />
</div>
);
}
MediaPageLayout.defaultProps = {
listQuery: null,
buildSiblingUrl: null,
listIndex: null,
projectId: null,
view: 'default',
};
MediaPageLayout.propTypes = {
listUrl: PropTypes.string.isRequired,
buildSiblingUrl: PropTypes.func, // null or func(projectMediaId, listIndex) => String|null
listQuery: PropTypes.object, // or null
listIndex: PropTypes.number, // or null
projectId: PropTypes.number, // or null
projectMediaId: PropTypes.number.isRequired,
view: PropTypes.string, // or null
};
|
src/components/movie/MoviePage.js | Tinusw/myMovieCollection | import React from 'react'
import FileBase64 from 'react-file-base64'
import 'slick-carousel/slick/slick.css'
import 'slick-carousel/slick/slick-theme.css'
import './moviePage.scss'
class MoviePage extends React.Component{
constructor(props){
super(props)
this.state = {
files: this.props.movie.images ? this.props.movie.images : []
}
}
submitMovie(data){
data.id = this.props.movie.id;
this.props.createOrUpdateMovie(data)
}
// GetFiles from FileBase64 uploader and set to state
getFiles(files){
// We set initial state here so we can preview uploads
this.setState({ files: files })
}
// Reset state after submit
resetState(){
this.setState({ files: [] })
}
render() {
let title
let director
let genre
let description
let images = this.state.files
return (
<div className="container">
<div className="col-lg-12 text-center">
<h3>Add a new movie to your collection</h3>
</div>
<div className="col-lg-offset-4 col-lg-4 text-center">
<form className='horizontal' onSubmit={e => {
e.preventDefault();
if (!title.value.trim()) {
title.focus()
return
}
if (!director.value.trim()){
title.focus()
return
}
if (!genre.value.trim()){
genre.focus()
return
}
if (!description.value.trim()){
description.focus()
return
}
if(!images.length > 0){
alert('please upload at least one image')
return
}
// Set our form values as an object
var input ={title: title.value, director: director.value, genre: genre.value, description: description.value, images: images}
console.log(input)
this.submitMovie(input)
e.target.reset()
this.resetState()
}}>
<div className="form-group">
<label className="control-label col-sm-3 text-right">Title:</label>
<div className="col-sm-9 text-left">
<input className="form-control" type="text" name="title" placeholder="Snatch" defaultValue={this.props.movie.title} ref={node => title = node}/>
</div>
</div>
<div className="form-group">
<label className="control-label col-sm-3 text-right">Director:</label>
<div className="col-sm-9 text-left">
<input className="form-control" type="text" name="title" defaultValue={this.props.movie.director} placeholder="Guy Ritchie" ref={node => director = node}/>
</div>
</div>
<div className="form-group">
<label className="control-label col-sm-3 text-right">Genre:</label>
<div className="col-sm-9 text-left">
<input className="form-control" type="text" name="title" defaultValue={this.props.movie.genre} placeholder="Crime" ref={node => genre = node}/>
</div>
</div>
<div className="form-group">
<label className="control-label col-sm-3 text-right">description:</label>
<div className="col-sm-9 text-left">
<textarea className="form-control" type="text" name="title" placeholder="A great film" defaultValue={this.props.movie.description} ref={node => description = node}/>
</div>
</div>
<div className="form-group">
<label className="control-label col-sm-3 text-right">Images:</label>
<div className="col-sm-9 text-left">
<FileBase64
multiple={ true }
onDone={ this.getFiles.bind(this) }
/>
</div>
</div>
<div className="form-group">
<div className="col-sm-12 text-center">
<h5 className="hint">You can upload multiple images at the same time </h5>
<input type="submit"/>
</div>
</div>
</form>
</div>
<div className="container">
<div className="row">
<div className="col-lg-12 text-center">
<h2>Preview Images</h2>
</div>
<div className="col-lg-12 text-center">
{this.state.files.map((image, i) =>
<div key={i+'image'} className="col-lg-3">
<img className="img-responsive" src={image.base64}></img>
</div>
)}
</div>
</div>
</div>
</div>
)
}
}
MoviePage.defaultProps = {
movie: {
id: null,
title: '',
director: '',
genre: '',
description: '',
images: '',
files: []
},
createOrUpdateMovie: (movie) => {}
}
export default MoviePage
|
app/javascript/mastodon/features/account_gallery/index.js | mimumemo/mastodon | import React from 'react';
import { connect } from 'react-redux';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { fetchAccount } from '../../actions/accounts';
import { expandAccountMediaTimeline } from '../../actions/timelines';
import LoadingIndicator from '../../components/loading_indicator';
import Column from '../ui/components/column';
import ColumnBackButton from '../../components/column_back_button';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { getAccountGallery } from '../../selectors';
import MediaItem from './components/media_item';
import HeaderContainer from '../account_timeline/containers/header_container';
import { ScrollContainer } from 'react-router-scroll-4';
import LoadMore from '../../components/load_more';
const mapStateToProps = (state, props) => ({
medias: getAccountGallery(state, props.params.accountId),
isLoading: state.getIn(['timelines', `account:${props.params.accountId}:media`, 'isLoading']),
hasMore: state.getIn(['timelines', `account:${props.params.accountId}:media`, 'hasMore']),
});
class LoadMoreMedia extends ImmutablePureComponent {
static propTypes = {
shouldUpdateScroll: PropTypes.func,
maxId: PropTypes.string,
onLoadMore: PropTypes.func.isRequired,
};
handleLoadMore = () => {
this.props.onLoadMore(this.props.maxId);
}
render () {
return (
<LoadMore
disabled={this.props.disabled}
onClick={this.handleLoadMore}
/>
);
}
}
export default @connect(mapStateToProps)
class AccountGallery extends ImmutablePureComponent {
static propTypes = {
params: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
medias: ImmutablePropTypes.list.isRequired,
isLoading: PropTypes.bool,
hasMore: PropTypes.bool,
};
componentDidMount () {
this.props.dispatch(fetchAccount(this.props.params.accountId));
this.props.dispatch(expandAccountMediaTimeline(this.props.params.accountId));
}
componentWillReceiveProps (nextProps) {
if (nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) {
this.props.dispatch(fetchAccount(nextProps.params.accountId));
this.props.dispatch(expandAccountMediaTimeline(this.props.params.accountId));
}
}
handleScrollToBottom = () => {
if (this.props.hasMore) {
this.handleLoadMore(this.props.medias.size > 0 ? this.props.medias.last().getIn(['status', 'id']) : undefined);
}
}
handleScroll = (e) => {
const { scrollTop, scrollHeight, clientHeight } = e.target;
const offset = scrollHeight - scrollTop - clientHeight;
if (150 > offset && !this.props.isLoading) {
this.handleScrollToBottom();
}
}
handleLoadMore = maxId => {
this.props.dispatch(expandAccountMediaTimeline(this.props.params.accountId, { maxId }));
};
handleLoadOlder = (e) => {
e.preventDefault();
this.handleScrollToBottom();
}
render () {
const { medias, shouldUpdateScroll, isLoading, hasMore } = this.props;
let loadOlder = null;
if (!medias && isLoading) {
return (
<Column>
<LoadingIndicator />
</Column>
);
}
if (hasMore && !(isLoading && medias.size === 0)) {
loadOlder = <LoadMore visible={!isLoading} onClick={this.handleLoadOlder} />;
}
return (
<Column>
<ColumnBackButton />
<ScrollContainer scrollKey='account_gallery' shouldUpdateScroll={shouldUpdateScroll}>
<div className='scrollable scrollable--flex' onScroll={this.handleScroll}>
<HeaderContainer accountId={this.props.params.accountId} />
<div role='feed' className='account-gallery__container'>
{medias.map((media, index) => media === null ? (
<LoadMoreMedia
key={'more:' + medias.getIn(index + 1, 'id')}
maxId={index > 0 ? medias.getIn(index - 1, 'id') : null}
onLoadMore={this.handleLoadMore}
/>
) : (
<MediaItem
key={media.get('id')}
media={media}
/>
))}
{loadOlder}
</div>
{isLoading && medias.size === 0 && (
<div className='scrollable__append'>
<LoadingIndicator />
</div>
)}
</div>
</ScrollContainer>
</Column>
);
}
}
|
src/index.js | oklas/component-intl-example | import React from 'react'
import { render } from 'react-dom'
import Root from './containers/Root'
render(
<Root/>,
document.getElementById('root')
)
|
routes.js | hustlzp/react-redux-example | import React from 'react'
import { Route, IndexRoute } from 'react-router'
import App from './containers/App'
import AuthPage from './containers/AuthPage'
import PendingAnonymousQuestionsPage from './containers/PendingAnonymousQuestionsPage'
import DashboardPage from './containers/DashboardPage'
import HomeRecommendationsPage from './containers/HomeRecommendationsPage'
import InvitationCodesPage from './containers/InvitationCodesPage'
import QuestionsPage from './containers/QuestionsPage'
import AnswersPage from './containers/AnswersPage'
import BroadcastSystemNotificationsPage from './containers/BroadcastSystemNotificationsPage'
import ReportsPage from './containers/ReportsPage'
import UsersPage from './containers/UsersPage'
import UserPage from './containers/UserPage'
import VisitorQuestionsReviewPage from './containers/VisitorQuestionsReviewPage'
import * as auth from './auth'
function requireAuth(nextState, replace) {
if (!auth.loggedIn()) {
replace('/auth')
}
}
export default (
<Route path="/" component={App}>
<IndexRoute component={DashboardPage} onEnter={requireAuth}/>
<Route path="homeRecommendations" component={HomeRecommendationsPage} onEnter={requireAuth}/>
<Route path="users" component={UsersPage} onEnter={requireAuth}/>
<Route path="invitationCodes" component={InvitationCodesPage} onEnter={requireAuth}/>
<Route path="reports" component={ReportsPage} onEnter={requireAuth}/>
<Route path="pendingAnonymousQuestionsPage" component={PendingAnonymousQuestionsPage} onEnter={requireAuth}/>
<Route path="visitorQuestions" component={VisitorQuestionsReviewPage} onEnter={requireAuth}/>
<Route path="questions" component={QuestionsPage} onEnter={requireAuth}/>
<Route path="answers" component={AnswersPage} onEnter={requireAuth}/>
<Route path="broadcastSystemNotifications" component={BroadcastSystemNotificationsPage} onEnter={requireAuth}/>
<Route path="user/:id" component={UserPage} onEnter={requireAuth}/>
<Route path="auth" component={AuthPage}/>
</Route>
)
|
packages/mineral-ui-icons/src/IconHd.js | mineral-ui/mineral-ui | /* @flow */
import React from 'react';
import Icon from 'mineral-ui/Icon';
import type { IconProps } from 'mineral-ui/Icon/types';
/* eslint-disable prettier/prettier */
export default function IconHd(props: IconProps) {
const iconProps = {
rtl: false,
...props
};
return (
<Icon {...iconProps}>
<g>
<path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-8 12H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm2-6h4c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1h-4V9zm1.5 4.5h2v-3h-2v3z"/>
</g>
</Icon>
);
}
IconHd.displayName = 'IconHd';
IconHd.category = 'av';
|
src/svg-icons/action/list.js | barakmitz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionList = (props) => (
<SvgIcon {...props}>
<path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/>
</SvgIcon>
);
ActionList = pure(ActionList);
ActionList.displayName = 'ActionList';
ActionList.muiName = 'SvgIcon';
export default ActionList;
|
lib/login-form/index.js | andyfen/react-native-UIKit | import React, { Component } from 'react';
import {
StyleSheet,
View,
} from 'react-native';
import { Button, InputField, FieldError } from '../';
const styles = StyleSheet.create({
form: {
flexDirection: 'column',
justifyContent: 'space-between',
marginTop: 30,
marginBottom: 50,
},
});
export default class LoginForm extends Component {
constructor(props) {
super(props);
this.state = {
email: '',
password: '',
};
this.onEmailChange = this.onEmailChange.bind(this);
this.onPasswordChange = this.onPasswordChange.bind(this);
this.onSubmit = this.onSubmit.bind(this);
}
onEmailChange(text) {
this.setState({
email: text,
});
}
onPasswordChange(text) {
this.setState({
password: text,
});
}
onSubmit() {
this.props.onSubmit(this.state.email, this.state.password);
}
render() {
const {
inputRadius, error, errorMsg, btnBackgroundColor, btnColor, btnRadius,
style, inputStyle, usernameStyle, passwordStyle, btnStyle, btnTextStyle,
errorStyle, errorTextStyle,
} = this.props;
return (
<View style={[ styles.form, style ]}>
<InputField
placeHolder={'email'}
radius={inputRadius}
onChange={this.onEmailChange}
style={[ inputStyle, usernameStyle ]}
/>
<InputField
placeHolder={'password'}
radius={inputRadius}
onChange={this.onPasswordChange}
style={[ inputStyle, passwordStyle ]}
/>
<FieldError
errorMsg={errorMsg}
error={error}
style={errorStyle}
textStyle={errorTextStyle}
/>
<Button
color={btnColor}
backgroundColor={btnBackgroundColor}
onPress={this.onSubmit}
radius={btnRadius}
style={btnStyle}
textStyle={btnTextStyle}
>
Submit
</Button>
</View>
);
}
}
LoginForm.defaultProps = {
error: false,
errorMsg: 'something went wrong',
style: {},
inputStyle: {},
usernameStyle: {},
passwordStyle: {},
btnStyle: {},
btnTextStyle: {},
errorStyle: {},
errorTextStyle: {},
};
LoginForm.propTypes = {
backgroundColor: React.PropTypes.string,
radius: React.PropTypes.number,
color: React.PropTypes.string,
errorMsg: React.PropTypes.string,
onSubmit: React.PropTypes.func,
inputRadius: React.PropTypes.number,
error: React.PropTypes.bool,
btnBackgroundColor: React.PropTypes.string,
btnColor: React.PropTypes.string,
btnRadius: React.PropTypes.number,
};
|
react-client/src/components/RingTag.js | lowtalkers/escape-reality | import {Entity} from 'aframe-react';
import React from 'react';
import 'aframe-bmfont-text-component';
export default props => {
return (
<Entity id='RingTag' scale='.5 .5 .5'
onClick={() => {props.clickFunction(); //// console.log('clickingggggG!!!!')
}}
position={props.position}
rotation={props.rotation}
>
<Entity
id='cube1RingTag'
primitive='a-octahedron'
animation__rot={{property: 'rotation', dir: 'alternate', dur: 6000, loop: 'repeat', to: '0 0 360'}}
animation__opac={{property: 'opacity', dir: 'alternate', dur: 3000, loop: 'repeat', from: .2, to: .5}}
position='0 0 0'
rotation='45 0 45'
easing='easeInOutQuad'
material={{color: '#00BCD4', opacity: 0.6}}
>
</Entity>
<Entity
id='cube2RingTag'
primitive='a-octahedron'
animation__rot={{property: 'rotation', dir: 'alternate', dur: 6000, loop: true, to: '0 360 0'}}
animation__opac={{property: 'opacity', dir: 'alternate', dur: 5000, loop: 'repeat', from: .1, to: .7}}
position='0 0 0'
rotation='45 45 0'
easing='easeInOutQuad'
material={{color: '#00BCD4', opacity: 0.6}}
>
</Entity>
</Entity>
);
};
//e.detail.target.id |
docs/app/Examples/collections/Grid/Variations/GridExampleTextAlignmentCenter.js | aabustamante/Semantic-UI-React | import React from 'react'
import { Grid, Menu } from 'semantic-ui-react'
const GridExampleTextAlignmentCenter = () => (
<Grid textAlign='center' columns={3}>
<Grid.Row>
<Grid.Column>
<Menu fluid vertical>
<Menu.Item className='header'>Cats</Menu.Item>
</Menu>
</Grid.Column>
<Grid.Column>
<Menu fluid vertical>
<Menu.Item className='header'>Dogs</Menu.Item>
<Menu.Item>Poodle</Menu.Item>
<Menu.Item>Cockerspaniel</Menu.Item>
</Menu>
</Grid.Column>
<Grid.Column>
<Menu fluid vertical>
<Menu.Item className='header'>Monkeys</Menu.Item>
</Menu>
</Grid.Column>
</Grid.Row>
</Grid>
)
export default GridExampleTextAlignmentCenter
|
app/javascript/mastodon/features/ui/components/boost_modal.js | theoria24/mastodon | import React from 'react';
import { connect } from 'react-redux';
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';
import Icon from 'mastodon/components/icon';
import AttachmentList from 'mastodon/components/attachment_list';
import PrivacyDropdown from 'mastodon/features/compose/components/privacy_dropdown';
import classNames from 'classnames';
import { changeBoostPrivacy } from 'mastodon/actions/boosts';
const messages = defineMessages({
cancel_reblog: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost' },
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
public_short: { id: 'privacy.public.short', defaultMessage: 'Public' },
unlisted_short: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
});
const mapStateToProps = state => {
return {
privacy: state.getIn(['boosts', 'new', 'privacy']),
};
};
const mapDispatchToProps = dispatch => {
return {
onChangeBoostPrivacy(value) {
dispatch(changeBoostPrivacy(value));
},
};
};
export default @connect(mapStateToProps, mapDispatchToProps)
@injectIntl
class BoostModal extends ImmutablePureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
status: ImmutablePropTypes.map.isRequired,
onReblog: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
onChangeBoostPrivacy: PropTypes.func.isRequired,
privacy: PropTypes.string.isRequired,
intl: PropTypes.object.isRequired,
};
componentDidMount() {
this.button.focus();
}
handleReblog = () => {
this.props.onReblog(this.props.status, this.props.privacy);
this.props.onClose();
}
handleAccountClick = (e) => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
this.props.onClose();
this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`);
}
}
_findContainer = () => {
return document.getElementsByClassName('modal-root__container')[0];
};
setRef = (c) => {
this.button = c;
}
render () {
const { status, privacy, intl } = this.props;
const buttonText = status.get('reblogged') ? messages.cancel_reblog : messages.reblog;
const visibilityIconInfo = {
'public': { icon: 'globe', text: intl.formatMessage(messages.public_short) },
'unlisted': { icon: 'unlock', text: intl.formatMessage(messages.unlisted_short) },
'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
'direct': { icon: 'envelope', text: intl.formatMessage(messages.direct_short) },
};
const visibilityIcon = visibilityIconInfo[status.get('visibility')];
return (
<div className='modal-root__modal boost-modal'>
<div className='boost-modal__container'>
<div className={classNames('status', `status-${status.get('visibility')}`, '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 noreferrer'>
<span className='status__visibility-icon'><Icon id={visibilityIcon.icon} title={visibilityIcon.text} /></span>
<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} />
{status.get('media_attachments').size > 0 && (
<AttachmentList
compact
media={status.get('media_attachments')}
/>
)}
</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 + <Icon id='retweet' /></span> }} /></div>
{status.get('visibility') !== 'private' && !status.get('reblogged') && (
<PrivacyDropdown
noDirect
value={privacy}
container={this._findContainer}
onChange={this.props.onChangeBoostPrivacy}
/>
)}
<Button text={intl.formatMessage(buttonText)} onClick={this.handleReblog} ref={this.setRef} />
</div>
</div>
);
}
}
|
components/Footer.js | DCKT/e-next | // @flow
import React from 'react'
export default (): React$Element<*> => (
<footer className='footer'>
<div className='container'>
<div className='columns'>
<div className='column'>
<h3>ENEXT</h3>
<ul>
<li>
<a>Figure</a>
</li>
</ul>
</div>
<div className='column'>
<h3>Licenses</h3>
<ul>
<li>
<a>License 1</a>
</li>
<li>
<a>License 2</a>
</li>
<li>
<a>License 3</a>
</li>
</ul>
</div>
<div className='column'>
<h3>Informations</h3>
<ul>
<li>
<a>Info 1</a>
</li>
<li>
<a>Info 2</a>
</li>
<li>
<a>Info 3</a>
</li>
</ul>
</div>
</div>
</div>
</footer>
)
|
src/components/property/collapsableField.js | BryceHQ/form-designer | import React from 'react';
import classnames from'classnames';
import _ from 'lodash';
import Colors from 'material-ui/lib/styles/colors';
import Title from './title';
import Editor from './editor';
import Field from './field';
import Actions from '../../actions/actions';
const styles = {
title: {
padding: '2px',
backgroundColor: Colors.grey200,
border: '1px solid #c1dce9',
position: 'relative',
marginBottom: '0.25em',
lineHeight: '20px',
borderRadius: '3px',
},
};
const CollapsableField = React.createClass({
getDefaultProps() {
return {
hiddenKeys: ['key', 'uniqueKey', '_options'],
};
},
getInitialState() {
return {
collaped: false,
};
},
/* 检验属性是否显示
* hidden为object时,{
* targetName: 'type',
* targetValues: ['a', 'b']
* }
* 适用于 当前属性是否显示取决于同级的另一个属性。如果这个属性为某些特定的值,那么当前属性显示。
*/
_isHidden(hidden, data){
if(typeof hidden !== 'object') return hidden;
for(var key in data){
if(!data.hasOwnProperty(key)) continue;
if(key === hidden.targetName){
if(_.isArray(hidden.targetValues)){
return !~hidden.targetValues.indexOf(data[key]);
} else {
return data[key] !== hidden.targetValues;
}
}
}
},
render() {
var {data, options, title, removable, style, formatter, hiddenKeys, onRemove} = this.props;
var {collaped} = this.state;
var elems = [];
if(!data) return (<Field/>);
var index = 0;
if(title){
elems.push(
<Title text = {title} key = {index++} style={styles.title}
index={this.props.index}
data={data}
addable={options && options.defaultChild}
removable={removable}
collaped={collaped}
onTouchTap={this._handleClick}
onAdd={this._handleAdd}
onRemove={onRemove || this._handleRemove}
/>
);
}
var _options = data._options || {};
//data = _.omit(data, this.props.hiddenKeys);
var opt;
if(!collaped){
if(_.isArray(data)){
var me = this;
data.forEach(function(item, i){
elems.push(
<CollapsableField data = {item} options={options && options.childOptions} key = {index++}
title={formatter ? formatter(options && options.childName) : options && options.childName}
removable={options && options.defaultChild}
index={i}
formatter={me.props.formatter}
onRemove={me._handleRemove}
/>
);
});
} else {
for(var key in data){
if(!data.hasOwnProperty(key) || ~hiddenKeys.indexOf(key)) continue;
opt = _options[key];
if(typeof data[key] === 'object'){
elems.push(
<CollapsableField data={data[key]} options={opt} key={index++}
title={formatter ? formatter(key) : key}
index={key}
formatter={this.props.formatter}
/>
);
continue;
}
if(this._isHidden(opt && opt.hidden, data) === true) continue;
elems.push(
<Field label={formatter ? formatter(key) : key} key = {index++}
editable={options && options.keyEditable}
owner={data}
index={key}
onRemove={this._handleRemove}
>
<Editor
onChange={this._handleChange}
autofocus={data.autofocus}
{...(opt && opt.editor)}
owner={data}
target={key}
value={data[key]}
/>
</Field>
);
}
}
}
var rootStyle = {
marginLeft: title ? '0.5em' : 0,
};
return (
<div style = {_.assign(rootStyle, style)}>
{elems}
</div>
);
},
_handleAdd() {
Actions.addChild(this.props.data, this.props.options.defaultChild);
},
_handleRemove(index) {
Actions.removeChild(this.props.data, index);
},
_handleClick() {
this.setState({collaped: !this.state.collaped});
},
_handleChange(value, oldValue) {
Actions.valueChange();
},
});
export default CollapsableField;
|
src/components/Weui/tab/tabbar.js | ynu/ecard-wxe | /**
* Created by n7best
*/
import React from 'react';
import classNames from 'classnames';
export default class TabBar extends React.Component {
render() {
const {children, className, ...others} = this.props;
const cls = classNames({
weui_tabbar: true
}, className);
return (
<div className={cls} {...others}>
{children}
</div>
);
}
} |
app/javascript/mastodon/components/modal_root.js | tootcafe/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import 'wicg-inert';
import { createBrowserHistory } from 'history';
import { multiply } from 'color-blend';
export default class ModalRoot extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
children: PropTypes.node,
onClose: PropTypes.func.isRequired,
backgroundColor: PropTypes.shape({
r: PropTypes.number,
g: PropTypes.number,
b: PropTypes.number,
}),
};
activeElement = this.props.children ? document.activeElement : null;
handleKeyUp = (e) => {
if ((e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27)
&& !!this.props.children) {
this.props.onClose();
}
}
handleKeyDown = (e) => {
if (e.key === 'Tab') {
const focusable = Array.from(this.node.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter((x) => window.getComputedStyle(x).display !== 'none');
const index = focusable.indexOf(e.target);
let element;
if (e.shiftKey) {
element = focusable[index - 1] || focusable[focusable.length - 1];
} else {
element = focusable[index + 1] || focusable[0];
}
if (element) {
element.focus();
e.stopPropagation();
e.preventDefault();
}
}
}
componentDidMount () {
window.addEventListener('keyup', this.handleKeyUp, false);
window.addEventListener('keydown', this.handleKeyDown, false);
this.history = this.context.router ? this.context.router.history : createBrowserHistory();
}
componentWillReceiveProps (nextProps) {
if (!!nextProps.children && !this.props.children) {
this.activeElement = document.activeElement;
this.getSiblings().forEach(sibling => sibling.setAttribute('inert', true));
}
}
componentDidUpdate (prevProps) {
if (!this.props.children && !!prevProps.children) {
this.getSiblings().forEach(sibling => sibling.removeAttribute('inert'));
// Because of the wicg-inert polyfill, the activeElement may not be
// immediately selectable, we have to wait for observers to run, as
// described in https://github.com/WICG/inert#performance-and-gotchas
Promise.resolve().then(() => {
this.activeElement.focus({ preventScroll: true });
this.activeElement = null;
}).catch(console.error);
this._handleModalClose();
}
if (this.props.children && !prevProps.children) {
this._handleModalOpen();
}
if (this.props.children) {
this._ensureHistoryBuffer();
}
}
componentWillUnmount () {
window.removeEventListener('keyup', this.handleKeyUp);
window.removeEventListener('keydown', this.handleKeyDown);
}
_handleModalOpen () {
this._modalHistoryKey = Date.now();
this.unlistenHistory = this.history.listen((_, action) => {
if (action === 'POP') {
this.props.onClose();
}
});
}
_handleModalClose () {
if (this.unlistenHistory) {
this.unlistenHistory();
}
const { state } = this.history.location;
if (state && state.mastodonModalKey === this._modalHistoryKey) {
this.history.goBack();
}
}
_ensureHistoryBuffer () {
const { pathname, state } = this.history.location;
if (!state || state.mastodonModalKey !== this._modalHistoryKey) {
this.history.push(pathname, { ...state, mastodonModalKey: this._modalHistoryKey });
}
}
getSiblings = () => {
return Array(...this.node.parentElement.childNodes).filter(node => node !== this.node);
}
setRef = ref => {
this.node = ref;
}
render () {
const { children, onClose } = this.props;
const visible = !!children;
if (!visible) {
return (
<div className='modal-root' ref={this.setRef} style={{ opacity: 0 }} />
);
}
let backgroundColor = null;
if (this.props.backgroundColor) {
backgroundColor = multiply({ ...this.props.backgroundColor, a: 1 }, { r: 0, g: 0, b: 0, a: 0.7 });
}
return (
<div className='modal-root' ref={this.setRef}>
<div style={{ pointerEvents: visible ? 'auto' : 'none' }}>
<div role='presentation' className='modal-root__overlay' onClick={onClose} style={{ backgroundColor: backgroundColor ? `rgba(${backgroundColor.r}, ${backgroundColor.g}, ${backgroundColor.b}, 0.7)` : null }} />
<div role='dialog' className='modal-root__container'>{children}</div>
</div>
</div>
);
}
}
|
src/js/components/Footer.js | amalbose/axa-media | import React from 'react';
import store from '../store/MovieStore';
import { EventEmitter} from "events"
export default class Footer extends React.Component {
constructor(){
super();
this.state = {
statusVal : '',
percent : 5
}
this.startLoading = this.startLoading.bind(this);
this.endLoading = this.endLoading.bind(this);
this.updateStatus = this.updateStatus.bind(this);
}
componentWillMount(){
store.on("LOADING", this.startLoading);
store.on("LOAD_COMPLETE", this.endLoading);
}
startLoading(){
this.updateStatus("Loading");
}
endLoading(){
this.updateStatus("Completed");
}
updateStatus(statusVal) {
this.setState({
statusVal : statusVal,
percent
})
}
componentWillUnmount(){
store.removeListener("LOADING", this.startLoading);
store.removeListener("LOAD_COMPLETE", this.endLoading);
}
render() {
if(this.state.percent < 5)
this.state.percent = 5;
let progressWidth = this.state.percent+"%";
let footerStatus = '';
if(this.state.statusVal == 'Loading') {
footerStatus = <div id="footerStatus">
<div className="progress-bar progress-bar-success active progress-bar-striped" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" style={{width: progressWidth}}>
{this.state.statusVal}
</div>
</div>
} else {
footerStatus = '';
}
return (
<footer className="footer">
{footerStatus}
</footer>
);
}
} |
demo/src/Toggles.js | kiloe/ui | import React from 'react';
import Doc from './Doc';
import View from '../../package/View';
export default class Toggles extends React.Component {
render(){
let data = [
{
title: 'Default Toggle',
src: Doc.jsx`
<Toggle label="Toggle me" />
`,
info:`
A Toggle is field that can either be true/false
`
},
{
title: 'Disabled Toggle',
src: Doc.jsx`
<Toggle disabled value={true} />
`,
info:`
Toggles can be disabled and the label is optional
`
},
{
title: 'Switch',
src: Doc.jsx`
<Toggle switch label="Turn me on" />
`,
info:`
Add the switch prop to make it look like a switch
`
},
{
title: 'Disabled Switch',
src: Doc.jsx`
<Toggle switch disabled label="Unswitchable" value={true} />
`,
info:`
Disabled switches don't do very much.
`
},
{
title: 'Round Toggle',
src: Doc.jsx`
<Toggle round label="Toggle Me!" />
`,
info:`
Round Toggles are often prefured for 'radio' buttons (see Select)
`
},
{
title: 'Icon Toggle',
src: Doc.jsx`
<View>
<Toggle icon={CloudIcon} label="Enable Clouds" />
<Toggle icon={StarIcon} label="Star this" />
<Toggle icon={FavoriteIcon} label="Heart that" />
</View>
`,
info:`
Set an icon to use it as a toggle switch.
`
},
];
return (
<View scroll>
<View>
{data.map((x,i) => <Doc key={i} title={x.title} src={x.src}>{x.info}</Doc>)}
</View>
</View>
);
}
}
|
app/components/Console.js | fatiherikli/fil | import _ from 'underscore';
import React from 'react';
import OutputLine from 'components/OutputLine';
import ConsoleToolbar from 'components/ConsoleToolbar';
import ErrorLine from 'components/ErrorLine';
export default class Console extends React.Component {
renderLine(line, i) {
return <OutputLine
output={line}
key={i} />
}
render() {
var block = "console",
error = this.props.error;
return (
<div className={block}>
<ConsoleToolbar
className={block + "__toolbar"}
onRun={this.props.onRun} />
<div className={block + "__output"}>
{this.props.lines.map(this.renderLine.bind(this))}
</div>
{error && <ErrorLine error={error} />}
</div>
);
}
}
|
app/components/EarningsTableFooter/index.js | seanng/web-server | /**
*
* EarningsTableFooter
*
*/
import React from 'react';
import styled from 'styled-components';
import { FormattedMessage } from 'react-intl';
import messages from './messages';
const Table = styled.table`
background-color: grey;
color: white;
height: 40px;
margin: 5px;
margin-bottom: 20px;
width: 100%;
`;
function EarningsTableFooter(props) {
return (
<div>
<Table>
<tbody>
<tr className='row'>
<td className='col-sm-6'>TOTAL</td>
<td className='col-sm-2'>{props.roomIncomeTotal}</td>
<td className='col-sm-2'>{props.addIncomeTotal}</td>
<td className='col-sm-2'>{props.roomIncomeTotal + props.addIncomeTotal}</td>
</tr>
</tbody>
</Table>
</div>
);
}
EarningsTableFooter.propTypes = {
};
export default EarningsTableFooter;
|
modules/pages/App.js | edvinerikson/universal-react-kickstarter | import React from 'react';
class App extends React.Component {
static propTypes = {
children: React.PropTypes.any.isRequired,
}
render() {
return (
<div>
{this.props.children}
</div>
);
}
}
export default App;
|
app/containers/Tour/index.js | g00dman5/freemouthmedia | /*
*
* Ttour
*
*/
import React from 'react';
import Helmet from 'react-helmet';
import {Link} from 'react-router';
import Responsive from 'react-responsive';
import NavLeft from 'material-ui/svg-icons/navigation/chevron-left';
import NavRight from 'material-ui/svg-icons/navigation/chevron-right';
import NavUp from 'material-ui/svg-icons/navigation/expand-less';
import NavDown from 'material-ui/svg-icons/navigation/expand-more';
import MoreOver from 'material-ui/svg-icons/navigation/more-horiz';
import MoreUp from 'material-ui/svg-icons/navigation/more-vert';
import BurgerMenu from 'material-ui/svg-icons/navigation/menu';
export default class Ttour extends React.PureComponent {
render() {
const navStyle={
border: "1px solid #bbbbbb",
backgroundColor:"rgba(0, 0, 0, 0.55)",
display: "flex",
flexDirection: "row",
justifyContent: "space-around",
position:"fixed",
width:"100%",
zIndex:"99999",
}
const mobileNav={
border: "1px solid #bbbbbb",
backgroundColor:"rgba(0, 0, 0, 0.55)",
display: "flex",
flexDirection: "row",
justifyContent: "space-around",
position:"fixed",
width:"100%",
zIndex:"99999",
}
const linkStyleM={
textDecoration:"none",
color:"#ffffff",
fontSize:"1.6em",
fontFamily:"'Squada One', cursive",
textTransform:"uppercase",
}
const linkStyle={
textDecoration:"none",
color:"#ffffff",
fontSize:"45px",
fontFamily:"'Squada One', cursive",
textTransform:"uppercase",
}
const NavLeftStyle={
color:"#c0c0c0",
position:"absolute",
top:"50%",
width:"64px",
height:"64px",
left:"0px",
}
const NavRightStyle={
color:"#c0c0c0",
position:"absolute",
top:"50%",
width:"64px",
height:"64px",
right:"0px"
}
const MoreOverStyle={
color:"#c0c0c0",
position:"absolute",
bottom:"30px",
width:"100%",
height:"70px"
}
const MoreUpStyle={
color:"#ffffff",
}
const burgerMenuStyleM={
color:"#c0c0c0",
position:"fixed",
height:"50px",
width:"60px",
top:"25",
left:"0",
margin:"auto",
}
const NavLeftStyleM={
color:"#c0c0c0",
position:"fixed",
top:"50%",
width:"64px",
height:"64px",
left:"-1em"
}
const NavRightStyleM={
color:"#c0c0c0",
position:"fixed",
top:"50%",
width:"64px",
height:"64px",
right:"-.5em"
}
const MoreOverStyleM={
color:"#c0c0c0",
position:"absolute",
bottom:"5px",
width:"100%",
height:"40px"
}
const backgroundwrapper={
backgroundImage:"url(https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/17951615_10203128057598149_4304219126977797958_n.jpg?oh=952eddc11f8cf95272fa41d89a1af6eb&oe=5988D0DF)",
right:"45px",
minHeight:"100vh",
backgroundRepeat:"repeat-y",
backgroundPosition:"center center",
}
const posterGallery={
boxSizing:"content-box",
overflow:"hidden",
display:"block",
paddingLeft:"70px",
paddingRight:"5px",
paddingBottom:"5px",
justifyContent:"center"
}
const posterGalleryM={
boxSizing:"content-box",
overflow:"hidden",
display:"block",
paddingLeft:"5px",
paddingRight:"5px",
paddingBottom:"5px",
}
const posterM={
padding:"2px",
margin:"5px",
width:"162",
height:"250",
float:"left",
overflow:"hidden"
}
const poster={
padding:"2px",
margin:"5px",
width:"162",
height:"250",
float:"left"
}
const bannerImage={
backgroundImage:"url(https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/1002638_10151805886217862_1791576482_n.jpg?oh=24aa96ecc9f9c6c30eacbae56c5eaa8d&oe=598C9243)",
minHeight:"100vh",
maxDeviceWidth:"100%",
backgroundSize:"cover",
backgroundAttachment:"scroll",
display:"block",
zIndex:"99999",
margin:"2px",
}
const bannerText={
position:"absolute",
textTransform:"uppercase",
color:"#ffffff",
fontSize:"130px",
fontFamily:"'Squada One', cursive",
margin:"3px",
border:"2px",
top:"40%",
left:"42%"
}
const bannerImageM={
backgroundImage:"url(https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/182264_491894117861_1912763_n.jpg?oh=2620955cf0890455c8a868039429581d&oe=5981FDBF)",
minHeight:"100vh",
maxDeviceWidth:"100%",
backgroundSize:"cover",
backgroundAttachment:"scroll",
display:"block",
margin:"auto"
}
const bannerTextM={
position:"absolute",
textTransform:"uppercase",
color:"#ffffff",
fontSize:"5em",
fontFamily:"'Squada One', cursive",
margin:"3px",
border:"2px",
top:"60%",
left:"34%"
}
const tableDiv={
boxSizing:"content-box",
padding:"5px",
margin:"5px",
position:"relative"
}
const tableStyle={
textAlign:"center",
clear:"both",
width:"68%",
fontFamily:"'Rubik', sans-serif",
borderSpacing:"10px 10px",
position:"relative",
left:"15%"
}
const tableStyleM={
textAlign:"center",
clear:"both",
width:"100%",
fontFamily:"'Rubik', sans-serif",
borderSpacing:"10px 10px",
}
return (
<div style={backgroundwrapper}>
<Helmet title="Ttour" meta={[ { name: 'description', content: 'Description of Ttour' }]}/>
<Responsive minDeviceWidth={1024}>
<div style={navStyle}>
<Link style={linkStyle} to= '/media'>Media </Link>
<Link style={linkStyle} to= '/'> Home </Link>
<Link style={linkStyle} to= '/tour'>Tour </Link>
<Link style={linkStyle} to= '/shop'>Shop </Link>
</div>
</Responsive>
<Responsive maxDeviceWidth={1023}>
<div style={mobileNav}>
<Link style={linkStyleM} to= '/media'>Media </Link>
<Link style={linkStyleM} to= '/'> Home </Link>
<Link style={linkStyleM} to= '/tour'>Tour </Link>
<Link style={linkStyleM} to= '/shop'>Shop </Link>
</div>
</Responsive>
<header>
<Responsive minDeviceWidth={1024}>
</Responsive>
<Responsive maxDeviceWidth={1023}>
</Responsive>
</header>
<main>
<Responsive minDeviceWidth={1024}>
<div>
<Link to="/"><NavLeft style={NavLeftStyle}/></Link>
<Link to="/shop"><NavRight style={NavRightStyle}/></Link>
</div>
</Responsive>
<Responsive maxDeviceWidth={1023}>
<div>
<Link to="/"><NavLeft style={NavLeftStyleM}/></Link>
<Link to="/shop"><NavRight style={NavRightStyleM}/></Link>
</div>
</Responsive>
</main>
<Responsive minDeviceWidth={1024}>
<div style={bannerImage}>
<h1 style={bannerText}>Tour</h1>
</div>
</Responsive>
<Responsive maxDeviceWidth={1023}>
<div style={bannerImageM}>
<h1 style={bannerTextM}>Tour</h1>
</div>
</Responsive>
<Responsive minDeviceWidth={1024}>
<div tableDiv>
<table style={tableStyle}>
<tbody>
<tr style={{background:"#cccccc"}}>
<td>Dec 31</td>
<td>Atlanta GA</td>
<td>Variety Playhouse</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 30</td>
<td>Athens GA</td>
<td>40 Watt</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr style={{background:"#cccccc"}}>
<td>Dec 29</td>
<td>Carrboro NC</td>
<td>Cat's Cradle</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 22</td>
<td>Knoxville TN</td>
<td>WDVX Studios</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr style={{background:"#cccccc"}}>
<td>Dec 21</td>
<td>Raleigh NC</td>
<td>Pour House Music Hall</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 20</td>
<td>Charlotte NC</td>
<td>The Rabbit Hole</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr style={{background:"#cccccc"}}>
<td>Dec 19</td>
<td>Charleston SC</td>
<td>Charleston Pour House</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 15</td>
<td>Orlando FL</td>
<td>Back Booth</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr style={{background:"#cccccc"}}>
<td>Dec 14</td>
<td>Tampa FL</td>
<td>Ybor Night Lights</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 12</td>
<td>Gainesville FL</td>
<td>The Jam</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
</tbody>
</table>
</div>
</Responsive>
<Responsive maxDeviceWidth={1023}>
<div tableDiv>
<table style={tableStyleM}>
<tbody>
<tr style={{background:"#cccccc"}}>
<td>Dec 31</td>
<td>Atlanta GA</td>
<td>Variety Playhouse</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 30</td>
<td>Athens GA</td>
<td>40 Watt</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr style={{background:"#cccccc"}}>
<td>Dec 29</td>
<td>Carrboro NC</td>
<td>Cat's Cradle</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 22</td>
<td>Knoxville TN</td>
<td>WDVX Studios</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr style={{background:"#cccccc"}}>
<td>Dec 21</td>
<td>Raleigh NC</td>
<td>Pour House Music Hall</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 20</td>
<td>Charlotte NC</td>
<td>The Rabbit Hole</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr style={{background:"#cccccc"}}>
<td>Dec 19</td>
<td>Charleston SC</td>
<td>Charleston Pour House</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 15</td>
<td>Orlando FL</td>
<td>Back Booth</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr style={{background:"#cccccc"}}>
<td>Dec 14</td>
<td>Tampa FL</td>
<td>Ybor Night Lights</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
<tr>
<td>Dec 12</td>
<td>Gainesville FL</td>
<td>The Jam</td>
<Link to="/"><td>Tickets</td></Link>
</tr>
</tbody>
</table>
</div>
</Responsive>
<Responsive minDeviceWidth={1024}>
<div style={posterGallery}>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/1006032_10151586320762862_702843352_n.jpg?oh=c6a7f8402d14d39fed93e4a40f259dfe&oe=598EADC5"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/995720_10151540628512862_1243357349_n.jpg?oh=2cee9c03b2c463f06841a5a404af27c3&oe=597B60A6"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/163753_480314142861_538236_n.jpg?oh=32b9627b752f8783e42eebe8a6f19b59&oe=5980F862"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/22042_279763947861_138539_n.jpg?oh=479ee668d885e42492d87774151f7561&oe=5990947C"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/297255_10150298172717862_72648603_n.jpg?oh=16eb022b9131d6355871742131c75bb5&oe=598BBC43"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t31.0-8/s960x960/883555_10151848614472862_259930318_o.jpg?oh=42e1531210304159cda59a7bb6f5af2c&oe=5983DE12"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/1917798_168195342861_5984679_n.jpg?oh=5676d8db590090ea736d31e16a623aef&oe=598DBD94"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/74183_135602182861_8247101_n.jpg?oh=191aee3121139c889665d9fd041092be&oe=598F4ACF"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/1915563_113201422861_4692371_n.jpg?oh=180ccd779e9aebe22864906feddd4286&oe=5999B755"/>
<img style={poster} src="https://scontent-atl3-1.xx.fbcdn.net/v/t31.0-8/s960x960/913909_10151430783672862_1307538094_o.jpg?oh=06a058f5fe46a8577be8fe87a2464fda&oe=5996C88D"/>
</div>
</Responsive>
<Responsive maxDeviceWidth={1023}>
<div style={posterGalleryM}>
<img style={posterM} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/1006032_10151586320762862_702843352_n.jpg?oh=c6a7f8402d14d39fed93e4a40f259dfe&oe=598EADC5"/>
<img style={posterM} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/995720_10151540628512862_1243357349_n.jpg?oh=2cee9c03b2c463f06841a5a404af27c3&oe=597B60A6"/>
<img style={posterM} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/163753_480314142861_538236_n.jpg?oh=32b9627b752f8783e42eebe8a6f19b59&oe=5980F862"/>
<img style={posterM} src="https://scontent-atl3-1.xx.fbcdn.net/v/t1.0-9/22042_279763947861_138539_n.jpg?oh=479ee668d885e42492d87774151f7561&oe=5990947C"/>
</div>
</Responsive>
</div>
);
}
}
|
src/containers/Sales/CustomDetail/Business/Business.js | UncleYee/crm-ui | import React from 'react';
import Health from './Health';
import Trend from './Trend';
import Usage from './Usage';
export default class Business extends React.Component {
static propTypes = {
tenantId: React.PropTypes.string,
hideStatistical: React.PropTypes.bool
};
constructor(props) {
super(props);
}
render() {
const {tenantId, hideStatistical} = this.props;
return (
<div>
<Health tenantId={tenantId}/>
{!hideStatistical && <Trend tenantId={tenantId}/>}
{!hideStatistical && <Usage tenantId={tenantId}/>}
</div>
);
}
}
|
src/js/components/Helper.js | vbence86/project-bea | import React from 'react';
import classNames from 'classnames';
export const Container = (props) => {
const _className = classNames({
'container': !props.fluid,
'container-fluid': props.fluid,
}, props.className);
return <div {... props} className={_className}> {props.children} </div>;
};
export const Row = (props) => {
const _className = classNames('row', props.className);
return <div {... props} className={_className}>{props.children}</div>;
};
export const Col = (props) => {
const sizeClasses = (props.size || []).map((x) => { return `col-${x}`; }).join(' ');
const _className = classNames(sizeClasses, props.className);
return <div {... props} className={_className}>{props.children}</div>;
};
|
frontend/modules/recipe/components/RecipeHeader.js | rustymyers/OpenEats | import React from 'react'
import PropTypes from 'prop-types'
import Ratings from './Ratings'
const RecipeHeader = ({ photo, title, rating }) => {
if (photo) {
return (
<div className="panel-heading hero-image" style={{backgroundImage: "url(" + photo + ")"}}>
<div className="row title">
<div className="col-xs-12">
<h3>{ title }</h3>
<Ratings stars={ rating }/>
</div>
</div>
<div className="row options print-hidden">
<div className="col-xs-12">
<button className="btn btn-primary btn-sm" onClick={ window.print }>
<span className="glyphicon glyphicon-print" aria-hidden="true"/>
</button>
</div>
</div>
</div>
);
}
return (
<div className="panel-heading">
<div className="row">
<div className="col-xs-12">
<h3>{ title }</h3>
<Ratings stars={ rating }/>
</div>
</div>
</div>
);
};
RecipeHeader.PropTypes = {
photo: PropTypes.object.isRequired,
rating: PropTypes.number.isRequired,
title: PropTypes.string.isRequired,
};
export default RecipeHeader;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.