path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
public/assets/scripts/containers/common/alerts.js | luisfbmelo/reda | import React from 'react';
import { Component } from 'react';
import { connect } from 'react-redux';
import { removeAlert } from '@/actions/alerts';
import { bindActionCreators } from 'redux';
import AlertBox from '@/components/common/alerts';
function mapStateToProps(state) {
return {
alerts: state.alerts
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators({ removeAlert }, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(AlertBox); |
screens/MainScreen.js | peysal/renatdux | import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
class MainScreen extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Hello Main</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
export default MainScreen;
|
internals/templates/containers/App/index.js | BartoszBazanski/react-100-pushup-challenge | /**
*
* App.react.js
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
* NOTE: while this component should technically be a stateless functional
* component (SFC), hot reloading does not currently support SFCs. If hot
* reloading is not a necessity for you then you can refactor it and remove
* the linting exception.
*/
import React from 'react';
export default class App extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
static propTypes = {
children: React.PropTypes.node,
};
render() {
return (
<div>
{React.Children.toArray(this.props.children)}
</div>
);
}
}
|
src/components/Footer.js | ccoode/timer | import React from 'react'
function Footer({ info }) {
return (
<footer className="site-footer">
<p>{info}</p>
<p>
<a href="https://github.com/ccoode/timer">GitHub</a>
</p>
</footer>
)
}
export default Footer
|
src/components/Timer.js | devoidofgenius/react-pomodoro | import React from 'react';
import TimerDisplay from './TimerDisplay';
import SessionControls from './SessionControls';
import TimerControls from './TimerControls';
import Modal from './Modal';
import notify from '../audio/notify.mp3';
import icon from '../css/images/thumbsup.png';
class Timer extends React.Component {
constructor() {
super();
this.state = {
time: 1500,
sessionTime: 1500,
isPlaying: false,
showModal: false
}
this.setNewTime = this.setNewTime.bind(this);
this.startTimer = this.startTimer.bind(this);
this.pauseTimer = this.pauseTimer.bind(this);
this.decrementTime = this.decrementTime.bind(this);
this.completeSession = this.completeSession.bind(this);
this.toggleModal = this.toggleModal.bind(this);
}
// Requests permission to use Notifications
componentDidMount() {
Notification.requestPermission();
}
// Sets new time state based on values passed into function
setNewTime(newTime) {
// Need to reset Timer;
this.setState({
time: newTime,
sessionTime: newTime,
});
}
// Toggles modal visibility
toggleModal(toggle) {
this.setState({
showModal: toggle
});
}
// Sets isPlaying state value to true and fires decrementTime function inside setInterval on placeholder timer state
startTimer() {
if(!this.state.isPlaying) {
this.setState({
tick: setInterval(this.decrementTime, 1000),
isPlaying: true
});
}
}
// Pause timer by clearInterval and set isPlaying to false
pauseTimer() {
if(this.state.isPlaying) {
clearInterval(this.state.tick);
this.setState({
tick: null,
isPlaying: false
})
}
}
// Runs notify when complete and turns timer off
completeSession() {
const isPlaying = this.state.isPlaying;
if(isPlaying === true) {
clearInterval(this.state.tick);
this.setState({
tick: null,
isPlaying: false
})
}
this.notify();
}
// Decrements the time state value by one
decrementTime() {
const time = this.state.time;
if(time === 0) {
this.completeSession();
return;
}
this.setState({
time: this.state.time - 1
});
}
notify() {
const notification = new Notification('Congratulations!!', {
// Temporary icon needs to be replaced.
icon: icon,
body: 'You completed your session!'
})
setTimeout(notification.close.bind(notification), 10000);
const audio = new Audio(notify);
audio.play();
}
render() {
return (
<div>
<TimerDisplay time={this.state.time}/>
<TimerControls startTimer={this.startTimer} pauseTimer={this.pauseTimer} />
<SessionControls setNewTime={this.setNewTime} toggleModal={this.toggleModal} />
{this.state.showModal ? <Modal currentTime={this.state.sessionTime} setCustomTime={this.setNewTime} toggleModal={this.toggleModal} /> : null}
</div>
);
}
}
export default Timer;
|
NavigationReact/sample/codesplitting/Person.js | grahammendick/navigation | import React from 'react';
import { NavigationBackLink } from 'navigation-react';
export default ({ person }) => (
<div>
<NavigationBackLink distance={1}>
Person Search
</NavigationBackLink>
<div>
<h2>{person.name}</h2>
<div className="label">Date of Birth</div>
<div>{person.dateOfBirth}</div>
<div className="label">Email</div>
<div>{person.email}</div>
<div className="label">Phone</div>
<div>{person.phone}</div>
</div>
</div>
);
|
packages/node_modules/@webex/react-component-space-item/src/index.js | ciscospark/react-ciscospark | import React from 'react';
import PropTypes from 'prop-types';
import {Avatar, Button, SpaceListItem} from '@momentum-ui/react';
import Timer from '@webex/react-component-timer';
import {
getTeamColor,
NOTIFICATIONS_BADGE_MENTION,
NOTIFICATIONS_BADGE_MUTE,
NOTIFICATIONS_BADGE_NONE,
NOTIFICATIONS_BADGE_UNMUTE,
NOTIFICATIONS_BADGE_UNREAD
} from '@webex/react-component-utils';
import './momentum.scss';
const propTypes = {
avatarUrl: PropTypes.string,
badge: PropTypes.string,
callStartTime: PropTypes.number,
hasCalling: PropTypes.bool,
id: PropTypes.string,
isDecrypting: PropTypes.bool,
isUnread: PropTypes.bool,
name: PropTypes.string,
onCallClick: PropTypes.func,
onClick: PropTypes.func,
searchTerm: PropTypes.string,
teamColor: PropTypes.string,
teamName: PropTypes.string,
type: PropTypes.string
};
const defaultProps = {
avatarUrl: '',
badge: NOTIFICATIONS_BADGE_NONE,
callStartTime: undefined,
hasCalling: false,
id: '',
isDecrypting: false,
isUnread: false,
name: '',
onCallClick: () => {},
onClick: () => {},
searchTerm: '',
teamColor: '',
teamName: '',
type: ''
};
function SpaceItem({
avatarUrl,
badge,
callStartTime,
hasCalling,
id,
isUnread,
name,
onClick,
onCallClick,
teamName,
teamColor,
type,
isDecrypting,
searchTerm
}) {
function handleClick() {
return onClick(id);
}
function handleCallClick(e) {
if (type === 'direct' || hasCalling) {
e.stopPropagation();
return onCallClick(id);
}
return false;
}
// Show hover call and join in progress buttons
const hasCallSupport = hasCalling && typeof onCallClick === 'function';
const avatarElement = (
<Avatar
backgroundColor={teamColor ? getTeamColor(teamColor, false) : '#E0E0E0'}
isDecrypting={isDecrypting}
src={avatarUrl}
title={name}
type={type === 'group' ? 'group' : ''}
/>
);
const subheaderElement = (
<div style={{color: getTeamColor(teamColor, false)}}>{teamName}</div>
);
const joinButton = (
hasCallSupport && callStartTime &&
<Button
ariaLabel="Join Call"
color="green"
size={28}
onClick={handleCallClick}
>
{
callStartTime
? <Timer startTime={callStartTime} />
: <div>Now</div>
}
</Button>
);
return (
<SpaceListItem
childrenLeft={avatarElement}
childrenRight={joinButton}
header={name}
isBold={!searchTerm && !isDecrypting && isUnread}
isAlertOn={badge === NOTIFICATIONS_BADGE_UNMUTE}
isUnread={!isDecrypting && badge === NOTIFICATIONS_BADGE_UNREAD}
isMentioned={badge === NOTIFICATIONS_BADGE_MENTION}
isMuted={badge === NOTIFICATIONS_BADGE_MUTE}
isDecrypting={isDecrypting}
subheader={subheaderElement}
onClick={handleClick}
searchTerm={searchTerm}
/>
);
}
SpaceItem.propTypes = propTypes;
SpaceItem.defaultProps = defaultProps;
export default SpaceItem;
|
app/components/CreateGame/Basic.js | cdiezmoran/AlphaStage-2.0 | import React from 'react';
import { func, object, string } from 'prop-types';
import uuid from 'uuid/v4';
import styles from './styles.scss';
const releaseOptions = [
'Released - Game is ready.',
'Beta - Some aspects of the game need polishing.',
'Alpha - Some of the main features are yet to be added.',
'Demo - Only a level or small part of the game.',
'Prototype - Just testing out an idea.'
];
const Basic = (props) => {
const {
title,
shortDescription,
releaseStatus,
platforms,
handleChange,
validatedInputClass
} = props;
const onPlatformClick = (platform) => (e) => {
const event = {
target: {
name: e.target.name,
value: !platform
}
};
handleChange(event);
};
const renderOptions = () => (
releaseOptions.map(value => <option value={value} key={uuid()}>{value}</option>)
);
const { availableWin, availableMac } = platforms;
return (
<div className={styles.Row}>
<div className={styles.ColumnLeft}>
<p className={styles.Title}>Basic Information</p>
</div>
<div className={styles.ColumnRight}>
<div className={styles.InputContainer}>
<label htmlFor="title" className={styles.Tag}>Title</label>
<input
type="text"
id="title"
name="title"
className={validatedInputClass(styles.Input, 'title')}
value={title}
onChange={handleChange}
/>
</div>
<div className={styles.InputContainer}>
<label htmlFor="shortDescription" className={styles.Tag}>Short Description</label>
<input
type="text"
id="shortDescription"
name="shortDescription"
className={validatedInputClass(styles.Input, 'shortDescription')}
value={shortDescription}
onChange={handleChange}
/>
</div>
<div className={styles.InputContainer}>
<label htmlFor="releaseStatus" className={styles.Tag}>Release Status</label>
<select
id="releaseStatus"
name="releaseStatus"
className={styles.Select}
onChange={handleChange}
value={releaseStatus}
>
{renderOptions()}
</select>
</div>
<div className={styles.InputContainer}>
<label htmlFor="platforms" className={styles.Tag}>Platforms</label>
<div className={validatedInputClass(styles.Platforms, 'platforms')} id="platforms">
<button
name="availableWin"
className={[styles.PlatformButton, availableWin ? styles.active : ''].join(' ')}
onClick={onPlatformClick(availableWin)}
>
<i className="fa fa-windows" />
</button>
<button
name="availableMac"
className={[styles.PlatformButton, availableMac ? styles.active : ''].join(' ')}
onClick={onPlatformClick(availableMac)}
>
<i className="fa fa-apple" />
</button>
</div>
</div>
</div>
</div>
);
};
Basic.propTypes = {
title: string.isRequired,
shortDescription: string.isRequired,
releaseStatus: string.isRequired,
platforms: object.isRequired,
handleChange: func.isRequired,
validatedInputClass: func.isRequired
};
export default Basic;
|
React Native/Demos/address_book/Views/message/detail.js | AngryLi/note | /**
* Created by Liyazhou on 16/8/28.
*/
import React from 'react';
import { View, Text, StyleSheet, Image, ScrollView, TouchableOpacity } from 'react-native';
export default class Detail extends React.Component {
render() {
let content = this.props.content;
return <ScrollView>
<View style={styles.content}>
<Text style={{lineHeight:20, }}>{content.message}</Text>
</View>
<View style={[styles.luokuan, {marginTop:25}]}>
<View style={{flex:1}}></View>
<Text style={[styles.text, {color:'#007aff'}]}>{content.username}</Text>
</View>
<View style={styles.luokuan}>
<View style={{flex:1}}></View>
<Text style={[styles.text, {color:'#3bc1ff'}]}>{content.time}</Text>
</View>
</ScrollView>
}
}
const styles = StyleSheet.create({
content: {
marginTop:20,
marginLeft:15,
marginRight:15,
opacity:0.85,
},
luokuan: {
flex:1,
flexDirection:'row',
marginRight:20,
},
text: {
lineHeight:20,
height:90,
},
}); |
addons/info/src/components/markdown/code.js | enjoylife/storybook | import { Prism } from 'global';
import React from 'react';
import PropTypes from 'prop-types';
export class Code extends React.Component {
componentDidMount() {
this.highlight();
}
componentDidUpdate() {
this.highlight();
}
highlight() {
if (typeof Prism !== 'undefined') {
Prism.highlightAll();
}
}
render() {
const codeStyle = {
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
backgroundColor: '#fafafa',
};
const preStyle = {
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
backgroundColor: '#fafafa',
padding: '.5rem',
lineHeight: 1.5,
overflowX: 'scroll',
};
const className = this.props.language ? `language-${this.props.language}` : '';
return (
<pre style={preStyle} className={className}>
<code style={codeStyle} className={className}>
{this.props.code}
</code>
</pre>
);
}
}
Code.propTypes = {
language: PropTypes.string,
code: PropTypes.node,
};
Code.defaultProps = {
language: null,
code: null,
};
export function Pre(props) {
const style = {
fontSize: '.88em',
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
backgroundColor: '#fafafa',
padding: '.5rem',
lineHeight: 1.5,
overflowX: 'scroll',
};
return <pre style={style}>{props.children}</pre>;
}
Pre.propTypes = { children: PropTypes.node };
Pre.defaultProps = { children: null };
export function Blockquote(props) {
const style = {
fontSize: '1.88em',
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
borderLeft: '8px solid #fafafa',
padding: '1rem',
};
return <blockquote style={style}>{props.children}</blockquote>;
}
Blockquote.propTypes = { children: PropTypes.node };
Blockquote.defaultProps = { children: null };
|
src/components/connect-bar.js | CrispyBacon12/facebook-chat | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { addComments } from '../actions';
import facebookConnector from '../services/facebook';
const facebook = facebookConnector();
class ConnectBar extends Component {
constructor(props) {
super(props);
this.state = {videoId: ''};
this.facebook = facebookConnector();
this.onInputChange = this.onInputChange.bind(this);
this.onSubmit = this.onSubmit.bind(this);
}
render() {
return (
<form className="form-inline" onSubmit={this.onSubmit}>
<input className="form-control mr-2" type="text" value={this.state.videoId} onChange={this.onInputChange}/>
<button type="submit" className="btn btn-primary">Connect!</button>
</form>
);
}
onInputChange(event) {
this.setState({videoId: event.target.value});
}
onSubmit(event) {
event.preventDefault();
const connection = this.facebook.connectToStream(this.state.videoId, (comments) => {
this.props.addComments(comments);
});
}
}
function mapDispatchToProps(dispatch) {
return bindActionCreators({addComments}, dispatch);
}
export default connect(null, mapDispatchToProps)(ConnectBar) |
docs/src/app/components/pages/components/DatePicker/ExampleDisableDates.js | nathanmarks/material-ui | import React from 'react';
import DatePicker from 'material-ui/DatePicker';
function disableWeekends(date) {
return date.getDay() === 0 || date.getDay() === 6;
}
function disableRandomDates() {
return Math.random() > 0.7;
}
/**
* `DatePicker` can disable specific dates based on the return value of a callback.
*/
const DatePickerExampleDisableDates = () => (
<div>
<DatePicker hintText="Weekends Disabled" shouldDisableDate={disableWeekends} />
<DatePicker hintText="Random Dates Disabled" shouldDisableDate={disableRandomDates} />
</div>
);
export default DatePickerExampleDisableDates;
|
spec/components/link.js | rubenmoya/react-toolbox | import React from 'react';
import Link from '../../components/link';
const LinkTest = () => (
<section>
<h5>Links</h5>
<p>lorem ipsum...</p>
<Link label="Github" route="http://www.github.com" icon="bookmark" />
<Link label="Inbox" route="http://mail.google.com" icon="inbox" />
</section>
);
export default LinkTest;
|
src/components/OrderSlide/card.js | Restry/vendornew | import React from 'react';
import moment from 'moment';
moment.locale('zh-CN');
import { SLink } from 'components';
const OrderCard = ({item, type}) => {
if (type === 'min') {
return (
<li>
<div className="tit"><span className="name">来源:</span>
<span className="gsname">{item.creator}</span>
<span className="pri fr">参考价:¥<em>{item.price || '无'}</em></span></div>
<div className="con">
<SLink to={'/request/detail/' + item.bid} max={25}>{item.title}</SLink>
</div>
<div className="location">
<div className="time fl">{moment(item.created).format('YYYY/MM/DD HH:mm')}</div>
<div className="weiz fr"></div>
</div>
</li>
);
}
return (
<li rel="zbd">
<div className="odr-items">
<div className="odr-lx zbd"></div>
<div className="odr-b-t">
<div className="name"><SLink to={'/request/detail/' + item.bid} max={25}>{item.title}</SLink></div>
<div className="people"><span>发标人:</span><span>{item.creator}</span></div>
</div>
<div className="odr-b-c">
<dl className="odr-b-list">
<dt>邀请竞标商家</dt>
{item.raceVendors.map((vendor, index) => {
return <dd key={index}>{vendor.name}:{moment(vendor.raceTime).toNow()}</dd>;
})}
</dl>
</div>
<div className="odr-b-b">
<dl>
<dd><i className="jbqx"></i>竞标期限:<span>{moment(item.raceTime).format('YYYY/MM/DD HH:mm')}</span></dd>
<dd><i className="ti"></i>发标时间:<span>{moment(item.raceTime).format('YYYY/MM/DD HH:mm')}</span></dd>
<dd><i className="ti"></i>下单时间:<span>{moment(item.created).format('YYYY/MM/DD HH:mm')}</span></dd>
</dl>
<div className="lxftime"></div>
</div>
</div>
</li>
);
};
export default OrderCard;
|
src/svg-icons/av/videocam-off.js | frnk94/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let AvVideocamOff = (props) => (
<SvgIcon {...props}>
<path d="M21 6.5l-4 4V7c0-.55-.45-1-1-1H9.82L21 17.18V6.5zM3.27 2L2 3.27 4.73 6H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.21 0 .39-.08.54-.18L19.73 21 21 19.73 3.27 2z"/>
</SvgIcon>
);
AvVideocamOff = pure(AvVideocamOff);
AvVideocamOff.displayName = 'AvVideocamOff';
AvVideocamOff.muiName = 'SvgIcon';
export default AvVideocamOff;
|
actor-apps/app-web/src/app/components/JoinGroup.react.js | zillachan/actor-platform | import React from 'react';
import requireAuth from 'utils/require-auth';
import DialogActionCreators from 'actions/DialogActionCreators';
import JoinGroupActions from 'actions/JoinGroupActions';
import JoinGroupStore from 'stores/JoinGroupStore'; // eslint-disable-line
class JoinGroup extends React.Component {
static propTypes = {
params: React.PropTypes.object
};
static contextTypes = {
router: React.PropTypes.func
};
constructor(props) {
super(props);
JoinGroupActions.joinGroup(props.params.token)
.then((peer) => {
this.context.router.replaceWith('/');
DialogActionCreators.selectDialogPeer(peer);
}).catch((e) => {
console.warn(e, 'User is already a group member');
this.context.router.replaceWith('/');
});
}
render() {
return null;
}
}
export default requireAuth(JoinGroup);
|
src/mixins/helpers.js | KilpiBan/react-slick | 'use strict';
import React from 'react';
import ReactTransitionEvents from 'react/lib/ReactTransitionEvents';
import {getTrackCSS, getTrackLeft, getTrackAnimateCSS} from './trackHelper';
import assign from 'object-assign';
var helpers = {
initialize: function (props) {
var slideCount = React.Children.count(props.children);
var listWidth = this.getWidth(this.refs.list.getDOMNode());
var trackWidth = this.getWidth(this.refs.track.getDOMNode());
var slideWidth = this.getWidth(this.getDOMNode())/props.slidesToShow;
var currentSlide = props.rtl ? slideCount - 1 - props.initialSlide : props.initialSlide;
this.setState({
slideCount: slideCount,
slideWidth: slideWidth,
listWidth: listWidth,
trackWidth: trackWidth,
currentSlide: currentSlide
}, function () {
var targetLeft = getTrackLeft(assign({
slideIndex: this.state.currentSlide,
trackRef: this.refs.track
}, props, this.state));
// getCSS function needs previously set state
var trackStyle = getTrackCSS(assign({left: targetLeft}, props, this.state));
this.setState({trackStyle: trackStyle});
this.autoPlay(); // once we're set up, trigger the initial autoplay.
});
},
update: function (props) {
// This method has mostly same code as initialize method.
// Refactor it
var slideCount = React.Children.count(props.children);
var listWidth = this.getWidth(this.refs.list.getDOMNode());
var trackWidth = this.getWidth(this.refs.track.getDOMNode());
var slideWidth = this.getWidth(this.getDOMNode())/props.slidesToShow;
this.setState({
slideCount: slideCount,
slideWidth: slideWidth,
listWidth: listWidth,
trackWidth: trackWidth
}, function () {
var targetLeft = getTrackLeft(assign({
slideIndex: this.state.currentSlide,
trackRef: this.refs.track
}, props, this.state));
// getCSS function needs previously set state
var trackStyle = getTrackCSS(assign({left: targetLeft}, props, this.state));
this.setState({trackStyle: trackStyle});
});
},
getWidth: function getWidth(elem) {
return elem.getBoundingClientRect().width || elem.offsetWidth;
},
adaptHeight: function () {
if (this.props.adaptiveHeight) {
var selector = '[data-index="' + this.state.currentSlide +'"]';
if (this.refs.list) {
var slickList = this.refs.list.getDOMNode();
slickList.style.height = slickList.querySelector(selector).offsetHeight + 'px';
}
}
},
slideHandler: function (index) {
// Functionality of animateSlide and postSlide is merged into this function
// console.log('slideHandler', index);
var targetSlide, currentSlide;
var targetLeft, currentLeft;
var callback;
if (this.state.animating === true || this.state.currentSlide === index) {
return;
}
if (this.props.fade) {
currentSlide = this.state.currentSlide;
if (this.props.beforeChange) {
this.props.beforeChange(currentSlide);
}
// Shifting targetSlide back into the range
if (index < 0) {
targetSlide = index + this.state.slideCount;
} else if (index >= this.state.slideCount) {
targetSlide = index - this.state.slideCount;
} else {
targetSlide = index;
}
if (this.props.lazyLoad && this.state.lazyLoadedList.indexOf(targetSlide) < 0) {
this.setState({
lazyLoadedList: this.state.lazyLoadedList.concat(targetSlide)
});
}
callback = () => {
this.setState({
animating: false
});
if (this.props.afterChange) {
this.props.afterChange(currentSlide);
}
ReactTransitionEvents.removeEndEventListener(this.refs.track.getDOMNode().children[currentSlide], callback);
};
this.setState({
animating: true,
currentSlide: targetSlide
}, function () {
ReactTransitionEvents.addEndEventListener(this.refs.track.getDOMNode().children[currentSlide], callback);
});
this.autoPlay();
return;
}
targetSlide = index;
if (targetSlide < 0) {
if(this.props.infinite === false) {
currentSlide = 0;
} else if (this.state.slideCount % this.props.slidesToScroll !== 0) {
currentSlide = this.state.slideCount - (this.state.slideCount % this.props.slidesToScroll);
} else {
currentSlide = this.state.slideCount + targetSlide;
}
} else if (targetSlide >= this.state.slideCount) {
if(this.props.infinite === false) {
currentSlide = this.state.slideCount - this.props.slidesToShow;
} else if (this.state.slideCount % this.props.slidesToScroll !== 0) {
currentSlide = 0;
} else {
currentSlide = targetSlide - this.state.slideCount;
}
} else {
currentSlide = targetSlide;
}
targetLeft = getTrackLeft(assign({
slideIndex: targetSlide,
trackRef: this.refs.track
}, this.props, this.state));
currentLeft = getTrackLeft(assign({
slideIndex: currentSlide,
trackRef: this.refs.track
}, this.props, this.state));
if (this.props.infinite === false) {
targetLeft = currentLeft;
}
if (this.props.beforeChange) {
this.props.beforeChange(currentSlide);
}
if (this.props.lazyLoad) {
var loaded = true;
var slidesToLoad = [];
for (var i = targetSlide; i < targetSlide + this.props.slidesToShow; i++ ) {
loaded = loaded && (this.state.lazyLoadedList.indexOf(i) >= 0);
if (!loaded) {
slidesToLoad.push(i);
}
}
if (!loaded) {
this.setState({
lazyLoadedList: this.state.lazyLoadedList.concat(slidesToLoad)
});
}
}
// Slide Transition happens here.
// animated transition happens to target Slide and
// non - animated transition happens to current Slide
// If CSS transitions are false, directly go the current slide.
if (this.props.useCSS === false) {
this.setState({
currentSlide: currentSlide,
trackStyle: getTrackCSS(assign({left: currentLeft}, this.props, this.state))
}, function () {
if (this.props.afterChange) {
this.props.afterChange(currentSlide);
}
});
} else {
var nextStateChanges = {
animating: false,
currentSlide: currentSlide,
trackStyle: getTrackCSS(assign({left: currentLeft}, this.props, this.state)),
swipeLeft: null
};
callback = () => {
this.setState(nextStateChanges);
if (this.props.afterChange) {
this.props.afterChange(currentSlide);
}
ReactTransitionEvents.removeEndEventListener(this.refs.track.getDOMNode(), callback);
};
this.setState({
animating: true,
currentSlide: targetSlide,
trackStyle: getTrackAnimateCSS(assign({left: targetLeft}, this.props, this.state))
}, function () {
ReactTransitionEvents.addEndEventListener(this.refs.track.getDOMNode(), callback);
});
}
this.autoPlay();
},
swipeDirection: function (touchObject) {
var xDist, yDist, r, swipeAngle;
xDist = touchObject.startX - touchObject.curX;
yDist = touchObject.startY - touchObject.curY;
r = Math.atan2(yDist, xDist);
swipeAngle = Math.round(r * 180 / Math.PI);
if (swipeAngle < 0) {
swipeAngle = 360 - Math.abs(swipeAngle);
}
if ((swipeAngle <= 45) && (swipeAngle >= 0) || (swipeAngle <= 360) && (swipeAngle >= 315)) {
return (this.props.rtl === false ? 'left' : 'right');
}
if ((swipeAngle >= 135) && (swipeAngle <= 225)) {
return (this.props.rtl === false ? 'right' : 'left');
}
return 'vertical';
},
autoPlay: function () {
var play = () => {
if (this.state.mounted) {
this.slideHandler(this.state.currentSlide + this.props.slidesToScroll);
}
};
if (this.props.autoplay) {
window.clearTimeout(this.state.autoPlayTimer);
this.setState({
autoPlayTimer: window.setTimeout(play, this.props.autoplaySpeed)
});
}
}
};
export default helpers;
|
src/frontend/components/clipList/ClipLayout.js | ChVince/new-record | import React from 'react'
import Clip from './Clip'
class ClipLayout extends React.Component {
constructor(props) {
super(props);
}
render() {
let clipList =[];
if (this.props.clipList && this.props.clipList.length > 0) {
clipList = this.props.clipList.map((clip, index) => {
return(
<div className="
clip-wrapper-1
col-lg-offset-2 col-lg-8
col-md-offset-2 col-md-8" key={index}>
<Clip clip={clip} />
</div>
)
});
}
return (
<div className="row">
{clipList}
</div>
)
}
}
ClipLayout.propTypes = {
clipList: React.PropTypes.array.isRequired
};
export default ClipLayout; |
src/svg-icons/content/link.js | ichiohta/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ContentLink = (props) => (
<SvgIcon {...props}>
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
</SvgIcon>
);
ContentLink = pure(ContentLink);
ContentLink.displayName = 'ContentLink';
ContentLink.muiName = 'SvgIcon';
export default ContentLink;
|
webdebugger/src/components/file-selector-item.js | andywer/postcss-debug | import React from 'react'
import cx from 'classnames'
import { splitFilePath } from '../util/path'
const { Component, PropTypes } = React // rollup doesn't resolve that correctly when importing like this
const FILE_LABEL_MAX_LENGTH = 30
function trimLabel (string, maxLength) {
return string > maxLength ? '...' + string.substr(-maxLength + 3) : string
}
const propTypes = {
commonPath: PropTypes.string.isRequired,
index: PropTypes.number.isRequired,
isSelected: PropTypes.bool,
file: PropTypes.object.isRequired,
onFileSelect: PropTypes.func.isRequired
}
function FileSelectorItem ({ file, index, commonPath, isSelected, onFileSelect }) {
const className = cx('clickable', 'selectable', isSelected && 'selected', 'file__item')
const pathToFile = file.path.replace(commonPath, '')
const label = trimLabel(pathToFile, FILE_LABEL_MAX_LENGTH)
const { basename, path } = splitFilePath(label)
const firstSnapshot = file.snapshots[ 0 ]
const lastSnapshot = file.snapshots[ file.snapshots.length -1 ]
const processingTime = lastSnapshot.timestamp - firstSnapshot.timestamp
const initialContentSize = firstSnapshot.content.length
return (
<li key={index} className={className} onClick={() => onFileSelect(file)} title={file.path}>
<div className="file__icon">
<img src="./assets/file_icon.svg" /> <br />
<span className="file__size">{Math.round(initialContentSize / 100) / 10} kB</span>
</div>
<div className="file__block_info">
<span className="file__basename">{basename}</span>
<span className="file__path">{file.path}</span>
<div className="file__all_timer">
<div className="file__icon_timer">
<img className="icon_timer" src="./assets/time_icon.svg" />
<span className="time_text">{processingTime} ms</span>
</div>
</div>
</div>
<div className="file__action">
<img className="file__action_triangle_right" src="./assets/triangle_right.svg" />
</div>
</li>
)
}
FileSelectorItem.propTypes = propTypes
export default FileSelectorItem
|
src/web.js | madjam002/rebox | /* @flow */
import React from 'react'
import styled, { css } from 'styled-components'
import {
BREAKPOINTS,
calculateSize,
getSpaceBetween,
space,
computeAlignItems,
computeJustifyContent,
} from './common'
import type { BoxProps } from './common'
const px = value => `${value}px`
export const Box = (_props: BoxProps) => {
let props = _props
let isChildABox = false
try {
isChildABox = React.Children.only(props.children).type === Box
} catch (ex) {
// React.Children.only throws an error if more than one child
}
if (isChildABox) {
props = Object.assign({}, _props, React.Children.only(props.children).props)
}
const hasPosition =
props.top != null || props.right != null || props.bottom != null || props.left != null
// is it a spacing container?
if (props.horizontal || props.stacked) {
const flattenedChildren = React.Children.toArray(props.children)
const spaceBetween = getSpaceBetween(props)
const children = flattenedChildren.map(
(child, index) =>
child.props != null ? (
<InternalBox
key={index}
fill={child.props.fill}
w={child.props.w}
h={child.props.h}
__boxIsSpacingChild
__boxParentSpaceBetween={spaceBetween}
{...(child.type === Box ? child.props : {})}
>
{child.type === Box ? child.props.children : child}
</InternalBox>
) : (
<InternalBox key={index} __boxIsSpacingChild __boxParentSpaceBetween={spaceBetween}>
{child}
</InternalBox>
),
)
return (
<StyledBox
{...props}
hasPosition={hasPosition}
isSpacingContainer
spaceBetween={spaceBetween}
>
{children}
</StyledBox>
)
}
return <StyledBox {...props} hasPosition={hasPosition} isSpacingContainer={false} />
}
const InternalBox: any = Box // for some reason we get inexact type incompatibility errors so we alias to any
const getResponsivePropValue = (propValue, breakpointIndex) => {
if (!Array.isArray(propValue)) {
if (breakpointIndex !== 0) return null
return propValue
}
return propValue[breakpointIndex]
}
const calculatePosition = value => {
if (value === true) {
return 0
} else if (value == null || value === false) {
return undefined
}
return px(space(value))
}
const RESPONSIVE_PROP_SELECTOR = {
w: value => ({ width: calculateSize(value) }),
h: value => ({ height: calculateSize(value) }),
top: value => ({ top: calculatePosition(value) }),
right: value => ({ right: calculatePosition(value) }),
bottom: value => ({ bottom: calculatePosition(value) }),
left: value => ({ left: calculatePosition(value) }),
order: value => ({ order: value }),
visible: value => ({ display: value === true ? 'flex' : 'none' }),
}
const RESPONSIVE_PROPS = Object.keys(RESPONSIVE_PROP_SELECTOR)
const getValuesForResponsiveProps = (props, breakpointIndex) => {
const style = {}
for (const propName of RESPONSIVE_PROPS) {
const propValue = props[propName]
if (getResponsivePropValue(propValue, breakpointIndex) != null) {
const propStyleSelector = RESPONSIVE_PROP_SELECTOR[propName]
Object.assign(style, propStyleSelector(getResponsivePropValue(propValue, breakpointIndex)))
}
}
return style
}
const mediaQueries = BREAKPOINTS.map(
(size, breakpointIndex) =>
css`
@media (min-width: ${size}px) {
${props => getValuesForResponsiveProps(props, breakpointIndex + 1)};
}
`,
)
const getSpacingContainerStyle = props => {
const style = {}
const spaceBetweenPx = space(props.spaceBetween)
const isHorizontal = props.horizontal
style.flexDirection = isHorizontal ? 'row' : 'column'
style.margin = `${px(-(spaceBetweenPx / 2))}`
style.alignItems = computeAlignItems(props)
style.justifyContent = computeJustifyContent(props)
if (style.alignItems == null) delete style.alignItems
if (style.justifyContent == null) delete style.justifyContent
if (isHorizontal && props.wrap !== false) {
style.flexWrap = 'wrap'
}
if (isHorizontal) {
style.flexShrink = 1
}
return style
}
const StyledBox = styled.div`
display: flex;
flex-grow: 1;
flex-shrink: 0;
position: ${props => (props.hasPosition ? 'absolute' : 'relative')};
box-sizing: border-box;
flex-direction: column;
${props => props.isSpacingContainer && getSpacingContainerStyle};
${props =>
props.__boxIsSpacingChild &&
css`
padding: ${props => px(space(props.__boxParentSpaceBetween) / 2)};
flex-grow: ${props => (props.fill ? 1 : 0)};
${props => props.fill && css`flex-shrink: 1;`};
`};
${props => getValuesForResponsiveProps(props, 0)} ${mediaQueries};
`
|
index.ios.js | greghe/SettingsModule | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
export default class SettingsModule extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('SettingsModule', () => SettingsModule);
|
node_modules/react-select/examples/src/components/DisabledUpsellOptions.js | Misterdjack/ask-the-principal | import React from 'react';
import Select from 'react-select';
function logChange() {
console.log.apply(console, [].concat(['Select value changed:'], Array.prototype.slice.apply(arguments)));
}
var DisabledUpsellOptions = React.createClass({
displayName: 'DisabledUpsellOptions',
propTypes: {
label: React.PropTypes.string,
},
onLabelClick: function (data, event) {
console.log(data, event);
},
renderLink: function() {
return <a style={{ marginLeft: 5 }} href="/upgrade" target="_blank">Upgrade here!</a>;
},
renderOption: function(option) {
return <span>{option.label} {option.link} </span>;
},
render: function() {
var ops = [
{ label: 'Basic customer support', value: 'basic' },
{ label: 'Premium customer support', value: 'premium' },
{ label: 'Pro customer support', value: 'pro', disabled: true, link: this.renderLink() },
];
return (
<div className="section">
<h3 className="section-heading">{this.props.label}</h3>
<Select
onOptionLabelClick={this.onLabelClick}
placeholder="Select your support level"
options={ops}
optionRenderer={this.renderOption}
onChange={logChange} />
</div>
);
}
});
module.exports = DisabledUpsellOptions;
|
electron/app/components/forms/FormLabel.js | zindlerb/static | import React from 'react';
import classnames from 'classnames';
export default function FormLabel(props) {
return (
<div className={classnames(props.className)}>
<div className="mb1">
<span className="f7">{props.name}:</span>
</div>
{props.children}
</div>
);
}
|
packages/es-components/src/components/controls/textbox/Textarea.js | TWExchangeSolutions/es-components | import React from 'react';
import styled from 'styled-components';
import { useTheme } from '../../util/useTheme';
import ValidationContext from '../ValidationContext';
const TextareaBase = styled.textarea`
border: 1px solid ${props => props.borderColor};
border-radius: 2px;
box-shadow: ${props => props.boxShadow};
box-sizing: border-box;
color: ${props => props.theme.colors.black};
font-size: ${props => props.theme.font.baseFontSize};
font-weight: normal;
line-height: ${props => props.theme.font.baseLineHeight};
min-width: 0;
padding: 6px 12px;
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
&:focus {
border-color: ${props => props.focusBorderColor};
box-shadow: ${props => props.focusBoxShadow};
outline: 0;
}
&:disabled {
background-color: ${props => props.theme.colors.gray2};
cursor: not-allowed;
}
&:read-only {
background-color: transparent;
border: 0;
box-shadow: none;
padding-left: 0;
padding-right: 0;
}
`;
const Textarea = React.forwardRef(function Textarea(props, ref) {
const theme = useTheme();
const validationState = React.useContext(ValidationContext);
return (
<TextareaBase
ref={ref}
{...props}
{...theme.validationInputColor[validationState]}
/>
);
});
export default Textarea;
|
src/index.js | mayacode/react-redux-starter | 'use strict';
if (module.hot) {
module.hot.accept();
}
import React from 'react';
import { render } from 'react-dom';
import Welcome from './app/modules/Page/component/Welcome';
render(<Welcome />, document.getElementById('app'));
|
app/index.js | transparantnederland/relationizer | import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { ReduxRouter } from 'redux-router';
import store from './store';
import './index.css';
render(
<Provider store={store}>
<ReduxRouter />
</Provider>,
document.getElementById('app')
);
|
src/components/common/icons/Thumbnails.js | chejen/GoodJobShare | import React from 'react';
/* eslint-disable */
const Thumbnails = (props) => (
<svg {...props} width="24" height="24" viewBox="0 0 24 24">
<g fillRule="evenodd">
<rect width="6" height="6"/>
<rect width="6" height="6" y="9"/>
<rect width="6" height="6" y="18"/>
<rect width="6" height="6" x="9"/>
<rect width="6" height="6" x="9" y="9"/>
<rect width="6" height="6" x="9" y="18"/>
<rect width="6" height="6" x="18"/>
<rect width="6" height="6" x="18" y="9"/>
<rect width="6" height="6" x="18" y="18"/>
</g>
</svg>
);
/* eslint-enable */
export default Thumbnails;
|
src/js/components/demo/democard.js | axuebin/react-blog | import React from 'react';
import PropTypes from 'prop-types';
export default class DemoCard extends React.Component {
render() {
return (
<div className="demo-democard">
<div className="demo-democard-title">{this.props.name}</div>
<div className="demo-democard-img">
<img src={this.props.img} alt={this.props.name} />
</div>
<div className="demo-democard-desc">
<a target="_blank" rel="noopener noreferrer" href={this.props.demo}>演示地址</a>
<a target="_blank" rel="noopener noreferrer" href={this.props.src}>源代码</a>
</div>
</div>
);
}
}
DemoCard.defaultProps = {
name: 'name',
img: 'img',
demo: 'demo',
src: 'src',
};
DemoCard.propTypes = {
name: PropTypes.string,
img: PropTypes.string,
demo: PropTypes.string,
src: PropTypes.string,
};
|
src/icons/BlankIcon.js | resmio/mantecao | import React from 'react'
import Icon from '../Icon'
const BlankIcon = props => <Icon {...props} />
export default BlankIcon
|
src/admin/index.js | rendact/rendact | import React from 'react';
import concat from 'lodash/concat';
import forEach from 'lodash/forEach';
import AdminHeader from './Header';
import AdminLoading from './AdminLoading';
import Footer from './Footer';
import SideMenu from './SideMenu';
import AdminLTEinit from './lib/app.js';
import {swalert} from '../utils/swalert';
import queries from './query/Content';
import {saveConfig} from '../utils/saveConfig';
import {toggleControlSidebarState, toggleUnsavedDataState, setActivePage, setActiveMenuId, setLogged } from '../actions';
import gql from 'graphql-tag'
import {graphql} from 'react-apollo';
import {connect} from 'react-redux'
import request from 'request';
import Loadable from 'react-loadable';
import {preload} from '../Routes'
const ControlSidebar = Loadable({
loader: () => import(/* webpackChunkName: "controlSidebar" */ './ControlSidebar'),
loading: () => null
})
const PageLoader = Loadable({
loader: () => import(/* webpackChunkName: "pageLoader" */'./PageLoader'),
loading: () => <AdminLoading/>
})
let Admin = React.createClass({
propTypes: {
params: React.PropTypes.object,
page: React.PropTypes.string,
action: React.PropTypes.string,
postId: React.PropTypes.string,
configLoaded: React.PropTypes.bool,
hasUnsavedData: React.PropTypes.bool,
showCtrlSidebar: React.PropTypes.bool,
contentList: React.PropTypes.array,
activeMenu: React.PropTypes.string
},
getDefaultProps: function() {
return {
params: {
page: 'dashboard',
action: ''
},
page: 'dashboard',
action: '',
postId: '',
configLoaded: false,
hasUnsavedData: false,
showCtrlSidebar: false,
contentList: [],
activeMenu: ''
}
},
componentDidMount(){
require ('jquery-ui/themes/base/theme.css');
require ('jquery-ui/themes/base/tooltip.css');
require ('font-awesome/css/font-awesome.css');
require ('../css/ionicons.css');
require ('../css/AdminLTE.css');
require ('../css/skins/_all-skins.min.css');
require ('jquery-ui/ui/widgets/tooltip')
require( 'jquery-ui/ui/core')
require( 'bootstrap/dist/css/bootstrap.css')
require( 'jquery-ui/themes/base/core.css')
require( 'sweetalert2/dist/sweetalert2.css')
require ('bootstrap');
preload();
AdminLTEinit();
if (this.props.page==="themes" && this.props.action==="customize") {
this.props.dispatch(toggleControlSidebarState(false))
} else {
this.props.dispatch(toggleControlSidebarState(true))
}
window.onpopstate = this.onBackButtonEvent;
},
onBackButtonEvent(e){
e.preventDefault();
if (this._reactInternalInstance)
this._reactInternalInstance._context.history.go(0);
},
setUnsavedDataState(state){
this.props.dispatch(toggleUnsavedDataState(state))
},
confirmUnsavedData(callback){
var state = true;
var me = this;
if (!callback)
callback = function() {}
if (this.props.hasUnsavedData) {
swalert('warning','Sure want to navigate away?','You might lost some data',
function(){
callback.call();
state = true;
me.setUnsavedDataState(false);
},
function(){
state = false;
}
);
} else {
callback.call();
state = true;
}
return state;
},
handleProfileClick(e){
e.preventDefault();
this.redirectToPage('profile');
},
redirectToPage(pageId, actionId, postId, tagId, callback){
var me = this;
this.confirmUnsavedData(
function() {
if (postId) {
me.props.dispatch(setActivePage(pageId, actionId, postId))
me._reactInternalInstance._context.history.push('/admin/'+pageId+'/'+actionId+'/'+postId)
} else {
me.props.dispatch(setActivePage(pageId, actionId))
if (actionId)
me._reactInternalInstance._context.history.push('/admin/'+pageId+'/'+actionId)
else
me._reactInternalInstance._context.history.push('/admin/'+pageId)
}
if (callback) callback.call()
});
},
handleMenuClick(pageId, callback){
var me = this;
this.confirmUnsavedData(
function(){
var pg = pageId.split("-");
me.props.dispatch(setActivePage(pg[0], pg[1]?pg[1]:''))
me.props.dispatch(setActiveMenuId(pageId));
callback.call();
}
);
},
handleSignout(e){
e.preventDefault()
this.props.dispatch(setLogged(false, '/login'))
localStorage.removeItem('token');
localStorage.removeItem('userId');
localStorage.removeItem('profile');
localStorage.removeItem('loginType');
localStorage.removeItem('auth0_profile');
localStorage.removeItem('config');
request({url: 'https://rendact.auth0.com/v2/logout'});
window.location.reload()
},
render() {
if (this.props.logged && this.props.configLoaded) {
return (
<div className="wrapper">
<AdminHeader handleSignout={this.handleSignout} onProfileClick={this.handleProfileClick} />
<SideMenu
onClick={this.handleMenuClick}
activeMenu={this.props.page+(this.props.action?'-':'')+this.props.action}
contentList={this.props.contentList}
/>
<PageLoader
pageId={this.props.params.page}
actionId={this.props.params.action}
postId={this.props.params.postId}
handleNav={this.redirectToPage}
handleUnsavedData={this.setUnsavedDataState}
urlParams={this.props.params}
/>
<Footer/>
{ this.props.showCtrlSidebar &&
<ControlSidebar/>
}
<div className="control-sidebar-bg"></div>
</div>
);
} else {
return (
null
)
}
}
});
const mapStateToProps = function(state){
return state.admin||{}
}
Admin = connect(mapStateToProps)(Admin);
Admin = graphql(gql`${queries.getContentListQry("active").query}`, {
props: ({ownProps, data}) => {
if (data.viewer) {
var _dataArr = [];
forEach(data.viewer.allContents.edges, function(item){
var dt = new Date(item.node.createdAt);
var fields = item.node.fields;
if (item.node.customFields) fields = concat(item.node.fields, item.node.customFields)
_dataArr.push({
"postId": item.node.id,
"name": item.node.name,
"fields": fields,
"customFields": item.node.customFields,
"slug": item.node.slug?item.node.slug:"",
"status": item.node.status?item.node.status:"",
"createdAt": dt.getFullYear() + "/" + (dt.getMonth() + 1) + "/" + dt.getDate()
});
});
saveConfig("contentList", _dataArr);
forEach(data.viewer.allOptions.edges, function(item){
saveConfig(item.node.item, item.node.value);
});
return {
configLoaded: true,
contentList: data.viewer.allContents.edges
}
}
}
})(Admin);
export default Admin
|
js/components/App.js | bokuweb/relay-sandbox | import React from 'react';
import Relay from 'react-relay';
class App extends React.Component {
render() {
return (
<div>
<h1>Widget list</h1>
<ul>
{this.props.viewer.widgets.edges.map(edge =>
<li key={edge.node.id}>{edge.node.name} (ID: {edge.node.id})</li>
)}
</ul>
</div>
);
}
}
export default Relay.createContainer(App, {
fragments: {
viewer: () => Relay.QL`
fragment on User {
widgets(first: 10) {
edges {
node {
id,
name,
},
},
},
}
`,
},
});
|
src/components/Navbar/Navbar.js | theopak/alright | /*
* React.js Starter Kit
* Copyright (c) 2014 Konstantin Tarkus (@koistya), KriaSoft LLC.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react'; // eslint-disable-line no-unused-vars
class Navbar {
render() {
return (
<div className="navbar-top" role="navigation">
<div className="container">
<a className="navbar-brand row" href="/">
<img src={require('./logo-small.png')} width="38" height="38" alt="React" />
<span>React.js Starter Kit</span>
</a>
</div>
</div>
);
}
}
export default Navbar;
|
src/app.js | danpersa/remindmetolive-react | require('newrelic');
import express from 'express';
import exphbs from 'express-handlebars';
import path from 'path';
import React from 'react';
import { renderToString } from 'react-dom/server';
import { StaticRouter } from 'react-router-dom';
import Meta from './server/meta';
import SitemapBuilder from './server/sitemapBuilder';
import App from './components/App';
import { isomorphicVars } from './isomorphicVars';
import AssetsMapper from './server/AssetsMapper';
/* eslint-disable no-console */
export default function startExpress() {
const port = 3000;
const theapp = express();
console.log("Starting in production");
// view engine setup
theapp.engine('handlebars', exphbs({defaultLayout: 'main'}));
theapp.set('view engine', 'handlebars');
const currentDir = path.resolve(path.dirname(''));
const meta = new Meta();
const staticDir = path.join(currentDir, 'dist/client');
const imagesDir = path.join(currentDir, 'dist/images');
// assets map
const manifestDir = path.join(currentDir, 'dist/client');
const assetsMapper = new AssetsMapper(manifestDir);
console.log('Static dir: ' + staticDir);
theapp.use(express.static(staticDir));
theapp.use("/images", express.static(imagesDir));
const sitemap = new SitemapBuilder(meta.getMetaPaths()).getSitemap();
theapp.get('/sitemap.xml', function(req, res) {
res.header('Content-Type', 'application/xml');
res.send( sitemap.toString() );
});
theapp.get('/robots.txt', function(req, res) {
res.header('Content-Type', 'text/plain');
res.send('Sitemap: http://www.remindmetolive.com/sitemap.xml');
});
theapp.get('*', (req, res) => {
const context = {};
const markup = renderToString(
<StaticRouter location={req.url} context={context}>
<App />
</StaticRouter>
);
if(context.status === 404) {
res.status(404);
}
if (context.status === 302) {
return res.redirect(302, context.url);
}
// render the index template with the embedded React markup
return res.render('path', {
reactOutput: markup,
meta: meta.getMetaForPath(req.url),
isomorphicVars: JSON.stringify(isomorphicVars),
cssFileName: assetsMapper.getCssFileName(),
jsFileName: assetsMapper.getJsFileName(),
});
});
theapp.listen(port, function(err) {
if (err) {
console.log("There was an error");
console.log(err);
} else {
console.log(`Example app listening on port ${port}!`);
}
});
}
startExpress();
|
fields/types/select/SelectField.js | frontyard/keystone | import Field from '../Field';
import React from 'react';
import Select from 'react-select';
import { FormInput } from '../../../admin/client/App/elemental';
/**
* TODO:
* - Custom path support
*/
module.exports = Field.create({
displayName: 'SelectField',
statics: {
type: 'Select',
},
valueChanged (newValue) {
// TODO: This should be natively handled by the Select component
if (this.props.numeric && typeof newValue === 'string') {
newValue = newValue ? Number(newValue) : undefined;
}
this.props.onChange({
path: this.props.path,
value: newValue,
});
},
renderValue () {
const { ops, value } = this.props;
const selected = ops.find(opt => opt.value === value);
return (
<FormInput noedit>
{selected ? selected.label : null}
</FormInput>
);
},
renderField () {
const { numeric, ops, path, value: val } = this.props;
// TODO: This should be natively handled by the Select component
const options = (numeric)
? ops.map(function (i) {
return { label: i.label, value: String(i.value) };
})
: ops;
const value = (typeof val === 'number')
? String(val)
: val;
return (
<div>
{/* This input element fools Safari's autocorrect in certain situations that completely break react-select */}
<input type="text" style={{ position: 'absolute', width: 1, height: 1, zIndex: -1, opacity: 0 }} tabIndex="-1"/>
<Select
simpleValue
name={this.getInputName(path)}
value={value}
options={options}
onChange={this.valueChanged}
/>
</div>
);
},
});
|
app/javascript/mastodon/components/button.js | nonoz/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
export default class Button extends React.PureComponent {
static propTypes = {
text: PropTypes.node,
onClick: PropTypes.func,
disabled: PropTypes.bool,
block: PropTypes.bool,
secondary: PropTypes.bool,
size: PropTypes.number,
className: PropTypes.string,
style: PropTypes.object,
children: PropTypes.node,
};
static defaultProps = {
size: 36,
};
handleClick = (e) => {
if (!this.props.disabled) {
this.props.onClick(e);
}
}
setRef = (c) => {
this.node = c;
}
focus() {
this.node.focus();
}
render () {
const style = {
padding: `0 ${this.props.size / 2.25}px`,
height: `${this.props.size}px`,
lineHeight: `${this.props.size}px`,
...this.props.style,
};
const className = classNames('button', this.props.className, {
'button-secondary': this.props.secondary,
'button--block': this.props.block,
});
return (
<button
className={className}
disabled={this.props.disabled}
onClick={this.handleClick}
ref={this.setRef}
style={style}
>
{this.props.text || this.props.children}
</button>
);
}
}
|
src/parts/text.js | economist-components/component-blog-post | import React from 'react';
function Text({ text }) {
if (typeof text === 'string') {
return (
<div
className="blog-post__text"
itemProp="description"
/* eslint-disable react/no-danger */
dangerouslySetInnerHTML={{
'__html': text,
}}
/>
);
} else if (text) {
return (
<div
className="blog-post__text"
itemProp="description"
>
{text}
</div>
);
}
}
Text.propTypes = {
text: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.node,
]).isRequired,
};
export default Text;
|
docs/src/Root.js | jakubsikora/react-bootstrap | import React from 'react';
import Router from 'react-router';
const Root = React.createClass({
statics: {
/**
* Get the list of pages that are renderable
*
* @returns {Array}
*/
getPages() {
return [
'index.html',
'introduction.html',
'getting-started.html',
'components.html',
'support.html'
];
}
},
getDefaultProps() {
return {
assetBaseUrl: ''
};
},
childContextTypes: {
metadata: React.PropTypes.object
},
getChildContext(){
return { metadata: this.props.propData };
},
render() {
// Dump out our current props to a global object via a script tag so
// when initialising the browser environment we can bootstrap from the
// same props as what each page was rendered with.
let browserInitScriptObj = {
__html:
`window.INITIAL_PROPS = ${JSON.stringify(this.props)};
// console noop shim for IE8/9
(function (w) {
var noop = function () {};
if (!w.console) {
w.console = {};
['log', 'info', 'warn', 'error'].forEach(function (method) {
w.console[method] = noop;
});
}
}(window));`
};
let head = {
__html: `<title>React-Bootstrap</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="${this.props.assetBaseUrl}/assets/bundle.css" rel="stylesheet">
<link href="${this.props.assetBaseUrl}/assets/favicon.ico?v=2" type="image/x-icon" rel="shortcut icon">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/3.4.0/es5-shim.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/3.4.0/es5-sham.js"></script>
<![endif]-->`
};
return (
<html>
<head dangerouslySetInnerHTML={head} />
<body>
<Router.RouteHandler propData={this.props.propData} />
<script dangerouslySetInnerHTML={browserInitScriptObj} />
<script src={`${this.props.assetBaseUrl}/assets/bundle.js`} />
</body>
</html>
);
}
});
export default Root;
|
src/ui/containers/Utilities/index.js | folkrav/DiceMaster | import './index.scss';
import React, { Component } from 'react';
import Page from 'ui/containers/Page';
class Utilities extends Component {
render() {
return (
<Page title='Utilities'>
<div>Testing</div>
</Page>
);
}
}
export default Utilities;
|
examples/todomvc/src/index.js | gaearon/redux | import React from 'react'
import { render } from 'react-dom'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import App from './components/App'
import reducer from './reducers'
import 'todomvc-app-css/index.css'
const store = createStore(reducer)
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
)
|
react-advanced-boilerplate/app/components/twitter/Tweet.js | rwachtler/react-twitstats | import React from 'react';
export default class Tweet extends React.Component {
constructor(props) {
super(props);
}
render() {
const {key, idstr, text, media, user, topTweet, favorites, retweets, potentialReach} = this.props;
return (
<div key={key} className="panel tweetlist__tweet">
<a href={`https://twitter.com/${user}`}><b>@{user}:</b></a>
<div dangerouslySetInnerHTML={{__html: text}} />
{
media ? media.filter(obj => {
return obj.type === 'photo';
}).map(photo => {
return <img key={photo.media_url} src={photo.media_url} alt="twitter-image" />
}) : null
}
<div className="tweet__stats">
{
favorites ?
<span className="tweet__stats--favorites">
<i>Favorites: </i>
<b>❤︎ {favorites}</b>
</span> : null
}
{
retweets ?
<span className="tweet__stats--retweets">
<i>Retweets: </i>
<b>🔄 {retweets}</b>
</span> : null
}
</div>
{
potentialReach ?
<div className="tweet__potential-reach">
<b>Potential reach: {this.props.potentialReach}</b>
</div> : null
}
<a className="button tiny" target="_blank" href={`https://twitter.com/${user}/status/${idstr}`}>Open Tweet</a>
</div>
);
}
}
Tweet.propTypes = {
idstr: React.PropTypes.string,
text: React.PropTypes.string,
media: React.PropTypes.array,
user: React.PropTypes.string,
favorites: React.PropTypes.number,
retweets: React.PropTypes.number,
potentialReach: React.PropTypes.number
};
|
app/javascript/components/collections/CollectionCardThumbnail.js | avalonmediasystem/avalon | /*
* Copyright 2011-2022, The Trustees of Indiana University and Northwestern
* University. Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* --- END LICENSE_HEADER BLOCK ---
*/
import React from 'react';
const CollectionCardThumbnail = ({ children }) => (
<div className="document-thumbnail">{children}</div>
);
export default CollectionCardThumbnail;
|
app/src/components/Navbar/Navbar.js | RyanCCollins/ryancollins.io | import React from 'react';
import { Link } from 'react-router';
import styles from './Navbar.scss';
import CrownLogo from '../CrownLogo/CrownLogo';
import {
Row,
Column,
TopBar,
TopBarTitle,
TopBarRight,
Menu,
MenuItem
} from 'react-foundation';
import Headroom from 'react-headroom';
const Styles = {
hidden: {
zIndex: 20,
display: 'none'
},
zIndex: {
height: 85,
zIndex: 20
}
};
class Navbar extends React.Component {
render() {
return (
<Headroom className="headroom__wrapper" style={Styles.zIndex}>
<TopBar className={'navbar active'}>
<Row>
<Column className="navbar__center-on-small">
<TopBarTitle className="navbar__title">
<Link to="/">
<CrownLogo />
</Link>
</TopBarTitle>
<TopBarRight className="navbar__right">
<Menu className="menu__centered">
<MenuItem>
<Link to="/portfolio">Portfolio</Link>
</MenuItem>
<MenuItem>
<Link to="/blog">Blog</Link>
</MenuItem>
<MenuItem>
<Link to="/services">Services</Link>
</MenuItem>
</Menu>
</TopBarRight>
</Column>
</Row>
</TopBar>
</Headroom>
);
}
}
export default Navbar;
|
client/src/containers/ChatBox.js | Bekzod13/DrawSketch | import React, { Component } from 'react';
import {inject, observer} from "mobx-react";
import { Form, Input} from "reactstrap";
import "../style/sidebar.css";
import Message from "./Message";
class ChatBox extends Component {
handleGuessChange = e =>
{
this.props.messageStore.setGuess(e.target.value)
};
handleSubmitForm = (e) => {
e.preventDefault();
this.props.userStore.pullUser().then((user) => {
this.props.sendMessage(this.props.messageStore.values.guess);
this.props.messageStore.addGuess(user.username);
});
};
render() {
const { values, messages } = this.props.messageStore;
const renderMessages = messages.map((message, i) => {
return (
<Message
key={i}
username={message.username}
message={message.message}
fromMe={message.fromMe} />
);
});
return (
<div className="chat-box" >
<div className="messages">
{renderMessages}
</div>
<div className="send-messages">
<Form onSubmit={this.handleSubmitForm}>
<Input type="text"
id="message"
placeholder="Enter your guess"
value={values.guess}
onChange={this.handleGuessChange}
required/>
</Form>
</div>
</div>
);
}
}
export default ChatBox = inject('userStore', 'messageStore')(observer(ChatBox))
|
src/components/list.js | RnbWd/lrload-chronic | import React from 'react'
export default React.createClass({
render () {
return (
<ul>
{this.props.items.map((it) => { return <li>item : {it}</li> })}
</ul>
)
}
})
|
examples/filtering/src/index.js | react-tools/react-table | import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
ReactDOM.render(<App />, document.getElementById('root'))
|
demo/components/item.js | c1aphas/rcarousel | import React from 'react';
import * as pt from 'prop-types';
const colors = [
'#f44336',
'#e91e63',
'#9c27b0',
'#673ab7',
'#3f51b5',
'#3f51b5',
'#03a9f4',
'#00bcd4',
'#009688',
'#4caf50',
'#8bc34a',
'#cddc39',
'#ffeb3b',
'#ffc107',
'#ff9800',
'#ff5722',
'#795548',
'#9e9e9e',
'#607d8b',
];
export default class Item extends React.Component {
getRandomColor() {
return colors[Math.round(Math.random() * (colors.length - 1))];
}
render() {
const style = {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'white',
fontSize: '36px',
width: this.props.width,
height: this.props.height,
backgroundColor: this.props.color || this.getRandomColor(),
};
return <div style={style}>{this.props.text}</div>;
}
}
Item.defaultProps = {
width: 100,
height: 100,
text: '',
color: '',
};
Item.propTypes = {
width: pt.number,
height: pt.number,
text: pt.string,
color: pt.string,
};
|
src/components/auth/Signup.js | GustavoKatel/franz | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import { isDevMode, useLiveAPI } from '../../environment';
import Form from '../../lib/Form';
import { required, email, minLength } from '../../helpers/validation-helpers';
import Input from '../ui/Input';
import Radio from '../ui/Radio';
import Button from '../ui/Button';
import Link from '../ui/Link';
import Infobox from '../ui/Infobox';
import { globalError as globalErrorPropType } from '../../prop-types';
const messages = defineMessages({
headline: {
id: 'signup.headline',
defaultMessage: '!!!Sign up',
},
firstnameLabel: {
id: 'signup.firstname.label',
defaultMessage: '!!!Firstname',
},
lastnameLabel: {
id: 'signup.lastname.label',
defaultMessage: '!!!Lastname',
},
emailLabel: {
id: 'signup.email.label',
defaultMessage: '!!!Email address',
},
companyLabel: {
id: 'signup.company.label',
defaultMessage: '!!!Company',
},
passwordLabel: {
id: 'signup.password.label',
defaultMessage: '!!!Password',
},
legalInfo: {
id: 'signup.legal.info',
defaultMessage: '!!!By creating a Franz account you accept the',
},
terms: {
id: 'signup.legal.terms',
defaultMessage: '!!!Terms of service',
},
privacy: {
id: 'signup.legal.privacy',
defaultMessage: '!!!Privacy Statement',
},
submitButtonLabel: {
id: 'signup.submit.label',
defaultMessage: '!!!Create account',
},
loginLink: {
id: 'signup.link.login',
defaultMessage: '!!!Already have an account, sign in?',
},
emailDuplicate: {
id: 'signup.emailDuplicate',
defaultMessage: '!!!A user with that email address already exists',
},
});
export default @observer class Signup extends Component {
static propTypes = {
onSubmit: PropTypes.func.isRequired,
isSubmitting: PropTypes.bool.isRequired,
loginRoute: PropTypes.string.isRequired,
error: globalErrorPropType.isRequired,
};
static contextTypes = {
intl: intlShape,
};
form = new Form({
fields: {
accountType: {
value: 'individual',
validators: [required],
options: [{
value: 'individual',
label: 'Individual',
}, {
value: 'non-profit',
label: 'Non-Profit',
}, {
value: 'company',
label: 'Company',
}],
},
firstname: {
label: this.context.intl.formatMessage(messages.firstnameLabel),
value: '',
validators: [required],
},
lastname: {
label: this.context.intl.formatMessage(messages.lastnameLabel),
value: '',
validators: [required],
},
email: {
label: this.context.intl.formatMessage(messages.emailLabel),
value: '',
validators: [required, email],
},
organization: {
label: this.context.intl.formatMessage(messages.companyLabel),
value: '', // TODO: make required when accountType: company
},
password: {
label: this.context.intl.formatMessage(messages.passwordLabel),
value: '',
validators: [required, minLength(6)],
type: 'password',
},
},
}, this.context.intl);
submit(e) {
e.preventDefault();
this.form.submit({
onSuccess: (form) => {
this.props.onSubmit(form.values());
},
onError: () => {},
});
}
render() {
const { form } = this;
const { intl } = this.context;
const { isSubmitting, loginRoute, error } = this.props;
return (
<div className="auth__scroll-container">
<div className="auth__container auth__container--signup">
<form className="franz-form auth__form" onSubmit={e => this.submit(e)}>
<img
src="./assets/images/logo.svg"
className="auth__logo"
alt=""
/>
<h1>{intl.formatMessage(messages.headline)}</h1>
{isDevMode && !useLiveAPI && (
<Infobox type="warning">
In Dev Mode your data is not persistent. Please use the live app for accesing the production API.
</Infobox>
)}
<Radio field={form.$('accountType')} showLabel={false} />
<div className="grid__row">
<Input field={form.$('firstname')} focus />
<Input field={form.$('lastname')} />
</div>
<Input field={form.$('email')} />
<Input
field={form.$('password')}
showPasswordToggle
scorePassword
/>
{form.$('accountType').value === 'company' && (
<Input field={form.$('organization')} />
)}
{error.code === 'email-duplicate' && (
<p className="error-message center">{intl.formatMessage(messages.emailDuplicate)}</p>
)}
{isSubmitting ? (
<Button
className="auth__button is-loading"
label={`${intl.formatMessage(messages.submitButtonLabel)} ...`}
loaded={false}
disabled
/>
) : (
<Button
type="submit"
className="auth__button"
label={intl.formatMessage(messages.submitButtonLabel)}
/>
)}
<p className="legal">
{intl.formatMessage(messages.legalInfo)}
<br />
<Link
to="https://meetfranz.com/terms"
target="_blank"
className="link"
>
{intl.formatMessage(messages.terms)}
</Link>
&
<Link
to="https://meetfranz.com/privacy"
target="_blank"
className="link"
>
{intl.formatMessage(messages.privacy)}
</Link>
.
</p>
</form>
<div className="auth__links">
<Link to={loginRoute}>{intl.formatMessage(messages.loginLink)}</Link>
</div>
</div>
</div>
);
}
}
|
node_modules/react-router/es6/Redirect.js | Maxwelloff/react-football | 'use strict';
import React from 'react';
import invariant from 'invariant';
import { createRouteFromReactElement as _createRouteFromReactElement } from './RouteUtils';
import { formatPattern } from './PatternUtils';
import { falsy } from './PropTypes';
var _React$PropTypes = React.PropTypes;
var string = _React$PropTypes.string;
var object = _React$PropTypes.object;
/**
* A <Redirect> is used to declare another URL path a client should
* be sent to when they request a given URL.
*
* Redirects are placed alongside routes in the route configuration
* and are traversed in the same manner.
*/
var Redirect = React.createClass({
displayName: 'Redirect',
statics: {
createRouteFromReactElement: function createRouteFromReactElement(element) {
var route = _createRouteFromReactElement(element);
if (route.from) route.path = route.from;
route.onEnter = function (nextState, replace) {
var location = nextState.location;
var params = nextState.params;
var pathname = undefined;
if (route.to.charAt(0) === '/') {
pathname = formatPattern(route.to, params);
} else if (!route.to) {
pathname = location.pathname;
} else {
var routeIndex = nextState.routes.indexOf(route);
var parentPattern = Redirect.getRoutePattern(nextState.routes, routeIndex - 1);
var pattern = parentPattern.replace(/\/*$/, '/') + route.to;
pathname = formatPattern(pattern, params);
}
replace({
pathname: pathname,
query: route.query || location.query,
state: route.state || location.state
});
};
return route;
},
getRoutePattern: function getRoutePattern(routes, routeIndex) {
var parentPattern = '';
for (var i = routeIndex; i >= 0; i--) {
var route = routes[i];
var pattern = route.path || '';
parentPattern = pattern.replace(/\/*$/, '/') + parentPattern;
if (pattern.indexOf('/') === 0) break;
}
return '/' + parentPattern;
}
},
propTypes: {
path: string,
from: string, // Alias for path
to: string.isRequired,
query: object,
state: object,
onEnter: falsy,
children: falsy
},
/* istanbul ignore next: sanity check */
render: function render() {
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, '<Redirect> elements are for router configuration only and should not be rendered') : invariant(false) : undefined;
}
});
export default Redirect; |
examples/todomvc/containers/App.js | madole/redux-devtools | import React, { Component } from 'react';
import TodoApp from './TodoApp';
import { createStore, combineReducers, compose } from 'redux';
import { devTools, persistState } from 'redux-devtools';
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
import { Provider } from 'react-redux';
import * as reducers from '../reducers';
const finalCreateStore = compose(
devTools(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore);
const reducer = combineReducers(reducers);
const store = finalCreateStore(reducer);
if (module.hot) {
module.hot.accept('../reducers', () =>
store.replaceReducer(combineReducers(require('../reducers')))
);
}
export default class App extends Component {
render() {
return (
<div>
<Provider store={store}>
{() => <TodoApp /> }
</Provider>
<DebugPanel top right bottom>
<DevTools store={store}
monitor={LogMonitor}
visibleOnLoad={true} />
</DebugPanel>
</div>
);
}
}
|
source/components/CollapseHandler.js | cloud-walker/react-inspect | import React from 'react'
const Component = class extends React.Component {
static displayName = 'ReactInspectCollapseHandler'
state = {show: false}
constructor() {
super()
this.handleClick = e => {
e.stopPropagation()
this.setState({show: !this.state.show})
}
}
render() {
return (
<span onClick={this.handleClick} style={{cursor: 'pointer'}}>
{this.props.children(this.state.show)}
</span>
)
}
}
export default Component
|
react_ref/index.ios.js | devSC/react-native | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
} from 'react-native';
import setup from './setup'
AppRegistry.registerComponent('react_ref', () => setup);
|
src/routes/education/index.js | zuban/edhunter | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import Layout from '../../components/Layout';
import Education from './Education';
function action() {
return {
chunks: ['education'],
title: 'EdHunter - Концепция перевернутого обучения',
component: (
<Layout>
<Education />
</Layout>
),
};
}
export default action;
|
react/gameday2/components/embeds/EmbedUstream.js | fangeugene/the-blue-alliance | import React from 'react'
import { webcastPropType } from '../../utils/webcastUtils'
const EmbedUstream = (props) => {
const channel = props.webcast.channel
const src = `https://www.ustream.tv/embed/${channel}?html5ui=1`
return (
<iframe
width="100%"
height="100%"
src={src}
scrolling="no"
allowFullScreen
frameBorder="0"
style={{ border: '0 none transparent' }}
/>
)
}
EmbedUstream.propTypes = {
webcast: webcastPropType.isRequired,
}
export default EmbedUstream
|
public/js/components/trends/trendComment.react.js | IsuruDilhan/Coupley | import React from 'react';
import Card from 'material-ui/lib/card/card';
import ListItem from 'material-ui/lib/lists/list-item';
import List from 'material-ui/lib/lists/list';
import Divider from 'material-ui/lib/divider';
import Avatar from 'material-ui/lib/avatar';
let style1={
width: 800,
};
var Comment = React.createClass({
render: function () {
return (
<div style={style1}>
<Card>
<ListItem
leftAvatar={<Avatar src="https://s-media-cache-ak0.pinimg.com/236x/dc/15/f2/dc15f28faef36bc55e64560d000e871c.jpg" />}
primaryText={this.props.cfirstName}
secondaryText={<p>{this.props.comment_txt}</p>}
secondaryTextLines={1} />
<Divider inset={true} />
</Card>
</div>
);
}
});
export default Comment;
|
node_modules/react-bootstrap/es/DropdownToggle.js | caughtclean/but-thats-wrong-blog | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React from 'react';
import classNames from 'classnames';
import Button from './Button';
import SafeAnchor from './SafeAnchor';
import { bsClass as setBsClass } from './utils/bootstrapUtils';
var propTypes = {
noCaret: React.PropTypes.bool,
open: React.PropTypes.bool,
title: React.PropTypes.string,
useAnchor: React.PropTypes.bool
};
var defaultProps = {
open: false,
useAnchor: false,
bsRole: 'toggle'
};
var DropdownToggle = function (_React$Component) {
_inherits(DropdownToggle, _React$Component);
function DropdownToggle() {
_classCallCheck(this, DropdownToggle);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
DropdownToggle.prototype.render = function render() {
var _props = this.props,
noCaret = _props.noCaret,
open = _props.open,
useAnchor = _props.useAnchor,
bsClass = _props.bsClass,
className = _props.className,
children = _props.children,
props = _objectWithoutProperties(_props, ['noCaret', 'open', 'useAnchor', 'bsClass', 'className', 'children']);
delete props.bsRole;
var Component = useAnchor ? SafeAnchor : Button;
var useCaret = !noCaret;
// This intentionally forwards bsSize and bsStyle (if set) to the
// underlying component, to allow it to render size and style variants.
// FIXME: Should this really fall back to `title` as children?
return React.createElement(
Component,
_extends({}, props, {
role: 'button',
className: classNames(className, bsClass),
'aria-haspopup': true,
'aria-expanded': open
}),
children || props.title,
useCaret && ' ',
useCaret && React.createElement('span', { className: 'caret' })
);
};
return DropdownToggle;
}(React.Component);
DropdownToggle.propTypes = propTypes;
DropdownToggle.defaultProps = defaultProps;
export default setBsClass('dropdown-toggle', DropdownToggle); |
test/Placeholder.js | passcod/kitr-helpers | 'use strict'
import { test } from 'tap'
import React from 'react'
test('Placeholder', (t) => {
t.plan(1)
t.ok(<div>world</div>, 'the world is fine')
})
|
docs/app/Examples/views/Card/Content/CardExampleContentBlock.js | ben174/Semantic-UI-React | import React from 'react'
import { Card, Feed } from 'semantic-ui-react'
const CardExampleContentBlock = () => (
<Card>
<Card.Content>
<Card.Header>
Recent Activity
</Card.Header>
</Card.Content>
<Card.Content>
<Feed>
<Feed.Event>
<Feed.Label image='http://semantic-ui.com/images/avatar/small/jenny.jpg' />
<Feed.Content>
<Feed.Date content='1 day ago' />
<Feed.Summary>
You added <a>Jenny Hess</a> to your <a>coworker</a> group.
</Feed.Summary>
</Feed.Content>
</Feed.Event>
<Feed.Event>
<Feed.Label image='http://semantic-ui.com/images/avatar2/small/molly.png' />
<Feed.Content>
<Feed.Date content='3 days ago' />
<Feed.Summary>
You added <a>Molly Malone</a> as a friend.
</Feed.Summary>
</Feed.Content>
</Feed.Event>
<Feed.Event>
<Feed.Label image='http://semantic-ui.com/images/avatar/small/elliot.jpg' />
<Feed.Content date='4 days ago'>
<Feed.Summary>
You added <a>Elliot Baker</a> to your <a>musicians</a> group.
</Feed.Summary>
</Feed.Content>
</Feed.Event>
</Feed>
</Card.Content>
</Card>
)
export default CardExampleContentBlock
|
src/routes.js | mattijsbliek/record-client | import React from 'react';
import {IndexRoute, Route} from 'react-router';
import { isLoaded as isAuthLoaded, load as loadAuth } from 'redux/modules/auth';
import {
App,
Chat,
Home,
Widgets,
About,
Login,
LoginSuccess,
Survey,
NotFound,
} from 'containers';
export default (store) => {
const requireLogin = (nextState, replaceState, cb) => {
function checkAuth() {
const { auth: { user }} = store.getState();
if (!user) {
// oops, not logged in, so can't be here!
replaceState(null, '/');
}
cb();
}
if (!isAuthLoaded(store.getState())) {
store.dispatch(loadAuth()).then(checkAuth);
} else {
checkAuth();
}
};
/**
* Please keep routes in alphabetical order
*/
return (
<Route path="/" component={App}>
{ /* Home (main) route */ }
<IndexRoute component={Home}/>
{ /* Routes requiring login */ }
<Route onEnter={requireLogin}>
<Route path="chat" component={Chat}/>
<Route path="loginSuccess" component={LoginSuccess}/>
</Route>
{ /* Routes */ }
<Route path="about" component={About}/>
<Route path="login" component={Login}/>
<Route path="survey" component={Survey}/>
<Route path="widgets" component={Widgets}/>
{ /* Catch all route */ }
<Route path="*" component={NotFound} status={404} />
</Route>
);
};
|
docs/src/sections/AlertsSection.js | SSLcom/Bootsharp | import React from 'react';
import Anchor from '../Anchor';
import PropTable from '../PropTable';
import ReactPlayground from '../ReactPlayground';
import Samples from '../Samples';
export default function AlertsSection() {
return (
<div className="bs-docs-section">
<h2 className="page-header">
<Anchor id="alerts">Alert messages</Anchor> <small>Alert</small>
</h2>
<p>Basic alert styles.</p>
<ReactPlayground codeText={Samples.AlertBasic} />
<h3><Anchor id="alerts-closeable">Closeable alerts</Anchor></h3>
<p>just pass in a <code>onDismiss</code> function.</p>
<ReactPlayground codeText={Samples.AlertDismissable} />
<div className="bs-callout bs-callout-info">
<h4>Screen Reader Accessibility</h4>
<p>Unlike regular Bootstrap, alerts have an sr-only dismiss button after the content.</p>
</div>
<h3><Anchor id="alerts-auto-closeable">Auto closeable</Anchor></h3>
<p>Auto close after a set time with <code>dismissAfter</code> prop.</p>
<ReactPlayground codeText={Samples.AlertAutoDismissable} />
<h3><Anchor id="alert-props">Props</Anchor></h3>
<PropTable component="Alert"/>
</div>
);
}
|
src/components/TodoList.js | Peizhong/jsdemo | import React from 'react'
import PropTypes from 'prop-types'
import Todo from './Todo'
const TodoList = ({ todos, onTodoClick }) => (
<ul>
{todos.map(todo => (
<Todo key={todo.id} {...todo} onClick={() => onTodoClick(todo.id)} />
))}
</ul>
)
TodoList.propTypes = {
todos: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.number.isRequired,
completed: PropTypes.bool.isRequired,
text: PropTypes.string.isRequired
}).isRequired
).isRequired,
onTodoClick: PropTypes.func.isRequired
}
export default TodoList |
src/components/Features/Features.js | jhabdas/lumpenradio-com | import React from 'react';
import styles from './Features.css';
import withStyles from '../../decorators/withStyles';
import Link from '../Link';
import FeatureList from '../FeatureList';
let data = [
{banner: 'Friday at 2PM - Shows', heroHref: 'http://placehold.it/350x350', headline: 'Catie Olson / Jabberwocky', excerpt: "Mixes from a vast array of music samples and recorded sounds are layered, modified and compiled together to portray parts of the nonsense poem by Lewis Carroll, Jabberwocky, from 1872. These recordings will be whimsical, strange and captivating, In addition Catie Olsen will create a small drawing to pair with each radio set.", linkHref: "http://habd.as"},
{banner: 'Lumpen Magazine - V.25 Issue', heroHref: '', headline: 'Top 40 Cholos', excerpt: "Bacon ipsum dolor amet doner short loin sausage sirloin, meatball fatback chuck strip steak jowl ribeye ham hock. Tri-tip spare ribs biltong, strip steak chicken andouille prosciutto turkey hamburger kevin chuck porchetta boudin shank. Tongue kielbasa tri-tip doner. Kielbasa fatback andouille pig chuck tail shank cupim ham. Flank alcatra ball tip kielbasa spare ribs ham short loin chuck tongue andouille. Pancetta landjaeger pork chop short loin, beef salami tail meatball chuck flank strip steak. Turkey corned beef short ribs ball tip pastrami spare ribs pork chop sausage pancetta cow pork belly ham hock meatloaf.", linkHref: "http://habd.as"},
]
@withStyles(styles)
class Features extends React.Component {
render() {
return (
<div className="Features">
<div className="Features-container">
<FeatureList data={data} />
</div>
</div>
);
}
}
export default Features;
|
modules/RouteUtils.js | ThibWeb/react-router | import React from 'react'
import warning from 'warning'
function isValidChild(object) {
return object == null || React.isValidElement(object)
}
export function isReactChildren(object) {
return isValidChild(object) || (Array.isArray(object) && object.every(isValidChild))
}
function checkPropTypes(componentName, propTypes, props) {
componentName = componentName || 'UnknownComponent'
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
var error = propTypes[propName](props, propName, componentName)
if (error instanceof Error)
warning(false, error.message)
}
}
}
function createRoute(defaultProps, props) {
return { ...defaultProps, ...props }
}
export function createRouteFromReactElement(element) {
var type = element.type
var route = createRoute(type.defaultProps, element.props)
if (type.propTypes)
checkPropTypes(type.displayName || type.name, type.propTypes, route)
if (route.children) {
var childRoutes = createRoutesFromReactChildren(route.children, route)
if (childRoutes.length)
route.childRoutes = childRoutes
delete route.children
}
return route
}
/**
* Creates and returns a routes object from the given ReactChildren. JSX
* provides a convenient way to visualize how routes in the hierarchy are
* nested.
*
* import { Route, createRoutesFromReactChildren } from 'react-router'
*
* var routes = createRoutesFromReactChildren(
* <Route component={App}>
* <Route path="home" component={Dashboard}/>
* <Route path="news" component={NewsFeed}/>
* </Route>
* )
*
* Note: This method is automatically used when you provide <Route> children
* to a <Router> component.
*/
export function createRoutesFromReactChildren(children, parentRoute) {
var routes = []
React.Children.forEach(children, function (element) {
if (React.isValidElement(element)) {
// Component classes may have a static create* method.
if (element.type.createRouteFromReactElement) {
var route = element.type.createRouteFromReactElement(element, parentRoute)
if (route)
routes.push(route)
} else {
routes.push(createRouteFromReactElement(element))
}
}
})
return routes
}
/**
* Creates and returns an array of routes from the given object which
* may be a JSX route, a plain object route, or an array of either.
*/
export function createRoutes(routes) {
if (isReactChildren(routes)) {
routes = createRoutesFromReactChildren(routes)
} else if (!Array.isArray(routes)) {
routes = [ routes ]
}
return routes
}
|
packages/reactor-kitchensink/src/examples/FormFields/TextAreaField/TextAreaField.js | dbuhrman/extjs-reactor | import React from 'react';
import { FormPanel, TextAreaField } from '@extjs/ext-react';
export default function TextAreaFieldExample() {
return (
<FormPanel shadow>
<TextAreaField
label="Description"
width="300"
maxRows={10}
/>
</FormPanel>
)
} |
blueocean-dashboard/src/main/js/components/stories/DownstreamRunsStories.js | kzantow/blueocean-plugin | /* eslint-disable */
import { storiesOf } from '@kadira/storybook';
import React from 'react';
import {ResultItem} from '@jenkins-cd/design-language';
import { DownstreamRunsView } from '../downstream-runs/DownstreamRunsView';
storiesOf('Downstream Build Links', module)
.add('Basic', basic)
;
const strings = {
"common.date.duration.display.format": "M[ month] d[ days] h[ hours] m[ minutes] s[ seconds]",
"common.date.duration.hint.format": "M [month], d [days], h[h], m[m], s[s]",
};
const t = (key) => {
if (!(key in strings)) {
console.log('missing key', key);
strings[key] = key;
}
return strings[key];
};
function basic() {
const runs = [
{
runLink: '/blue/rest/organizations/jenkins/pipelines/downstream1/runs/105/',
runDescription: 'downstream1 #105',
},
{
runLink: '/blue/rest/organizations/jenkins/pipelines/downstream1/runs/106/',
runDescription: 'downstream1 #106',
},
{
runLink: '/blue/rest/organizations/jenkins/pipelines/downstream1/runs/65/',
runDescription: 'downstream2 #65',
runDetails: {
durationInMillis: 26479,
enQueueTime: '2018-01-11T16:36:18.556+1000',
endTime: '2018-01-11T16:36:45.037+1000',
estimatedDurationInMillis: 28904,
id: '13',
organization: 'jenkins',
pipeline: 'Downstream1',
result: 'SUCCESS',
runSummary: 'stable',
startTime: '2018-01-11T16:36:18.558+1000',
state: 'FINISHED',
},
},
{
runLink: '/blue/rest/organizations/jenkins/pipelines/downstream1/runs/11/',
runDescription: 'downstream2 #11',
runDetails: {
durationInMillis: 26479,
enQueueTime: '2018-01-11T16:36:18.556+1000',
endTime: null, //'2018-01-11T16:36:45.037+1000',
estimatedDurationInMillis: 28904,
id: '17',
organization: 'jenkins',
pipeline: 'Downstream2',
result: 'UNKNOWN',
runSummary: 'stable',
startTime: '2018-01-11T16:36:18.558+1000',
state: 'RUNNING',
},
},
{
runLink: '/blue/rest/organizations/jenkins/pipelines/downstream1/runs/66/',
runDescription: 'downstream2 #66',
},
];
return (
<div style={{ padding: '1em' }}>
<strong>Some Excellent Stage</strong>
<div style={{height:'0.5em'}}/>
<ResultItem result="success" label="Alpha" extraInfo="Bravo"/>
<ResultItem result="success" label="Charlie" extraInfo="Delta"/>
<ResultItem result="success" label="Echo" extraInfo="Foxtrot"/>
<ResultItem result="success" label="Golf" extraInfo="Hotel"/>
<div style={{height:'2em'}}/>
<strong>Triggered Builds</strong>
<div style={{height:'0.5em'}}/>
<DownstreamRunsView runs={runs} t={t} />
</div>
);
}
|
client/src/pages/dashboard/ShipTodayItem.js | ccwukong/lfcommerce-react | import React from 'react';
import PropTypes from 'prop-types';
const ShipTodayItem = props => {
const { orderId, customerName, onClick } = props;
return (
<tr style={{ cursor: 'pointer' }} onClick={() => onClick(orderId)}>
<td>{orderId}</td>
<td>{customerName}</td>
</tr>
);
};
ShipTodayItem.propTypes = {
orderId: PropTypes.string.isRequired,
customerName: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
};
export default ShipTodayItem;
|
test/helpers/shallowRenderHelper.js | jiebianng/react-gallery | /**
* Function to get the shallow output for a given component
* As we are using phantom.js, we also need to include the fn.proto.bind shim!
*
* @see http://simonsmith.io/unit-testing-react-components-without-a-dom/
* @author somonsmith
*/
import React from 'react';
import TestUtils from 'react-addons-test-utils';
/**
* Get the shallow rendered component
*
* @param {Object} component The component to return the output for
* @param {Object} props [optional] The components properties
* @param {Mixed} ...children [optional] List of children
* @return {Object} Shallow rendered output
*/
export default function createComponent(component, props = {}, ...children) {
const shallowRenderer = TestUtils.createRenderer();
shallowRenderer.render(React.createElement(component, props, children.length > 1 ? children : children[0]));
return shallowRenderer.getRenderOutput();
}
|
src/components/video_list.js | zyfcjtc/ReactVideoSearch | import React from 'react';
import VideoListItem from './video_list_item';
const VideoList = (props) => {
const videoItems = props.videos.map((video) => {
return (
<VideoListItem
onVideoSelect={props.onVideoSelect}
key={video.etag}
video={video}/>
)
});
return (
<ul className="col-md-4 list-group">
{videoItems}
</ul>
);
};
export default VideoList; |
packages/insights-web/src/scenes/explorer/tags/full-path/index.js | mariusandra/insights | import './styles.scss'
import React from 'react'
import { Icon } from 'antd'
export function FullPath ({ path, rootIcon = 'filter', rootIconTheme = '' }) {
return (
<div className='full-path-explorer-tag'>
{path.split('.').map((part, index) => (
<div key={index} className={index === 0 ? 'root' : 'part'}>
{index > 0 ? <Icon type='link' /> : <Icon type={rootIcon} theme={rootIconTheme} />}
<span style={{ paddingLeft: index > 0 ? 10 : 5 }}>{index > 0 ? '.' : ''}{part}</span>
</div>
))}
</div>
)
}
|
app/components/ToggleOption/index.js | iFatansyReact/react-boilerplate-imagine | /**
*
* ToggleOption
*
*/
import React from 'react';
import { injectIntl, intlShape } from 'react-intl';
const ToggleOption = ({ value, message, intl }) => (
<option value={value}>
{message ? intl.formatMessage(message) : value}
</option>
);
ToggleOption.propTypes = {
value: React.PropTypes.string.isRequired,
message: React.PropTypes.object,
intl: intlShape.isRequired,
};
export default injectIntl(ToggleOption);
|
website/modules/components/Logo.js | d-oliveros/react-router | import React from 'react'
import { Block, Row } from 'jsxstyle'
import { DARK_GRAY } from '../Theme'
import LogoImage from '../logo.png'
const Logo = ({ size = 230, shadow = true }) => (
<Row
background={DARK_GRAY}
width={size+'px'}
height={size+'px'}
alignItems="center"
justifyContent="center"
borderRadius="50%"
boxShadow={shadow ? `2px ${size/20}px ${size/5}px hsla(0, 0%, 0%, 0.35)` : null}
>
<Block position="relative" top="-4%" textAlign="center" width="100%">
<img src={LogoImage} width="75%"/>
</Block>
</Row>
)
export default Logo
|
src/svg-icons/maps/directions-bike.js | w01fgang/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsDirectionsBike = (props) => (
<SvgIcon {...props}>
<path d="M15.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM5 12c-2.8 0-5 2.2-5 5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0 8.5c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5 3.5 1.6 3.5 3.5-1.6 3.5-3.5 3.5zm5.8-10l2.4-2.4.8.8c1.3 1.3 3 2.1 5.1 2.1V9c-1.5 0-2.7-.6-3.6-1.5l-1.9-1.9c-.5-.4-1-.6-1.6-.6s-1.1.2-1.4.6L7.8 8.4c-.4.4-.6.9-.6 1.4 0 .6.2 1.1.6 1.4L11 14v5h2v-6.2l-2.2-2.3zM19 12c-2.8 0-5 2.2-5 5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0 8.5c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5 3.5 1.6 3.5 3.5-1.6 3.5-3.5 3.5z"/>
</SvgIcon>
);
MapsDirectionsBike = pure(MapsDirectionsBike);
MapsDirectionsBike.displayName = 'MapsDirectionsBike';
MapsDirectionsBike.muiName = 'SvgIcon';
export default MapsDirectionsBike;
|
src/components/event/EventRankings.js | tervay/AutoScout | import React from 'react';
import { linkTeam } from '@/js/links';
import { getEventRankings } from '@/js/api';
import Error404 from '../404/Error404';
export default class EventRankings extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {
getEventRankings(this.props.eventKey).then((json) => {
this.setState({ rankings: json });
}).catch((err) => {
this.setState({ error: err });
});
}
render() {
if (this.state.error) {
return <Error404 content={this.state.error.toString()} />;
}
if (this.state.rankings) {
let ranking;
if (this.state.rankings[0].rank) {
ranking = (a, b) => a.rank - b.rank;
} else {
ranking = (a, b) => a.team - b.team;
}
const rows = this.state.rankings.sort(ranking).map((rk) => {
let text = '';
if (rk.elim_alliance !== null) {
const prefix = rk.elim_alliance.seed === null ? rk.elim_alliance.name : rk.elim_alliance.seed;
text = `${prefix} (`;
if (rk.won_event) {
text += 'W';
} else {
text += rk.finish.toUpperCase();
}
text += ')';
}
return (<tr key={rk.id}>
<th>{rk.rank}</th>
<td>{linkTeam(rk.team)}</td>
<td>{`${rk.won}-${rk.lost}-${rk.tied}`}</td>
<td>{text}</td>
</tr>);
});
return (<table className={'table'}>
<thead>
<tr>
<th>Rank</th>
<th>Team</th>
<th>Record</th>
<th>Alliance Seed</th>
</tr>
</thead>
<tbody>
{rows}
</tbody>
</table>);
}
return <div />;
}
}
|
fields/components/columns/InvalidColumn.js | sendyhalim/keystone | import React from 'react';
import ItemsTableCell from '../../components/ItemsTableCell';
import ItemsTableValue from '../../components/ItemsTableValue';
var InvalidColumn = React.createClass({
displayName: 'InvalidColumn',
propTypes: {
col: React.PropTypes.object,
},
renderValue () {
return (
<ItemsTableValue field={this.props.col.type}>
(Invalid Type: {this.props.col.type})
</ItemsTableValue>
);
},
render () {
return (
<ItemsTableCell>
{this.renderValue()}
</ItemsTableCell>
);
},
});
module.exports = InvalidColumn;
|
src/entypo/Language.js | cox-auto-kc/react-entypo | import React from 'react';
import EntypoIcon from '../EntypoIcon';
const iconClass = 'entypo-svgicon entypo--Language';
let EntypoLanguage = (props) => (
<EntypoIcon propClass={iconClass} {...props}>
<path d="M19.753,10.909c-0.624-1.707-2.366-2.726-4.661-2.726c-0.09,0-0.176,0.002-0.262,0.006l-0.016-2.063c0,0,3.41-0.588,3.525-0.607s0.133-0.119,0.109-0.231c-0.023-0.111-0.167-0.883-0.188-0.976c-0.027-0.131-0.102-0.127-0.207-0.109c-0.104,0.018-3.25,0.461-3.25,0.461s-0.012-1.953-0.013-2.078c-0.001-0.125-0.069-0.158-0.194-0.156c-0.125,0.002-0.92,0.014-1.025,0.016c-0.105,0.002-0.164,0.049-0.162,0.148c0.002,0.1,0.033,2.307,0.033,2.307s-3.061,0.527-3.144,0.543c-0.084,0.014-0.17,0.053-0.151,0.143c0.019,0.09,0.19,1.094,0.208,1.172c0.018,0.08,0.072,0.129,0.188,0.107c0.115-0.019,2.924-0.504,2.924-0.504l0.035,2.018c-1.077,0.281-1.801,0.824-2.256,1.303c-0.768,0.807-1.207,1.887-1.207,2.963c0,1.586,0.971,2.529,2.328,2.695c3.162,0.387,5.119-3.06,5.769-4.715c1.097,1.506,0.256,4.354-2.094,5.98c-0.043,0.029-0.098,0.129-0.033,0.207c0.065,0.078,0.541,0.662,0.619,0.756c0.08,0.096,0.206,0.059,0.256,0.023C19.394,15.862,20.545,13.077,19.753,10.909z M12.367,14.097c-0.966-0.121-0.944-0.914-0.944-1.453c0-0.773,0.327-1.58,0.876-2.156c0.335-0.354,0.75-0.621,1.229-0.799l0.082,4.277C13.225,14.097,12.811,14.151,12.367,14.097z M14.794,13.544l0.046-4.109c0.084-0.004,0.166-0.01,0.252-0.01c0.773,0,1.494,0.145,1.885,0.361C17.368,10.003,15.954,12.499,14.794,13.544z M5.844,5.876C5.814,5.782,5.741,5.731,5.648,5.731h-1.95c-0.093,0-0.165,0.051-0.194,0.144c-0.412,1.299-3.48,10.99-3.496,11.041c-0.017,0.051-0.011,0.076,0.062,0.076h1.733c0.075,0,0.099-0.023,0.114-0.072c0.015-0.051,1.008-3.318,1.008-3.318h3.496c0,0,0.992,3.268,1.008,3.318c0.016,0.049,0.039,0.072,0.113,0.072h1.734c0.072,0,0.078-0.025,0.062-0.076C9.324,16.866,6.255,7.175,5.844,5.876z M3.226,12.194l1.447-5.25l1.447,5.25H3.226z"/>
</EntypoIcon>
);
export default EntypoLanguage;
|
src/javascript/client/client.js | realseanp/dolli | import polyfill from 'babel-polyfill'; // eslint-disable-line no-unused-vars
import d from 'debug';
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';
import routes from './components/Routes';
import app from './app';
import fetchRouteData from 'utils/fetchRouteData';
import { provideContext } from 'fluxible-addons-react';
const debug = d('App');
if (window.App.env !== 'production') {
d.enable('App, Fluxible, Fluxible:*');
}
debug('Rehydrating...');
app.rehydrate(window.App, (err, context) => {
let isRehydrating = true;
if (err) {
throw err;
}
debug('React Rendering');
const RouterWithContext = provideContext(Router, app.customContexts);
ReactDOM.render(
<RouterWithContext
context={context.getComponentContext()}
history={browserHistory}
onUpdate={function onUpdate() {
if (isRehydrating) {
isRehydrating = false;
return;
}
fetchRouteData(context, this.state)
.then(() => { /* emit an event? */ })
.catch(fetchDataErr => {
console.error(fetchDataErr.stack);
});
}}
>{routes}</RouterWithContext>,
document.getElementById('app'),
() => {
debug('React Rendered');
}
);
});
|
src/components/PlaylistManager/Panel/MoveToLastAction.js | u-wave/web | import React from 'react';
import PropTypes from 'prop-types';
import { useDispatch } from 'react-redux';
import MoveToLastIcon from '@mui/icons-material/KeyboardArrowDown';
import { moveMedia } from '../../../actions/PlaylistActionCreators';
import { useMediaListContext } from '../../MediaList/BaseMediaList';
import MediaAction from '../../MediaList/MediaAction';
const {
useCallback,
} = React;
function MoveToLastAction({ media }) {
const { playlist, selection } = useMediaListContext();
const dispatch = useDispatch();
const handleClick = useCallback(() => {
const selectedItems = selection.isSelected(media) ? selection.get() : [media];
dispatch(moveMedia(playlist._id, selectedItems, { at: 'end' }));
}, [dispatch, playlist, media, selection]);
return (
<MediaAction onClick={handleClick}>
<MoveToLastIcon />
</MediaAction>
);
}
MoveToLastAction.propTypes = {
media: PropTypes.object.isRequired,
};
export default MoveToLastAction;
|
app/containers/ListPage.js | yesmeck/hotelbar | import { remote } from 'electron'
import React, { Component } from 'react';
import ReactDOM from 'react-dom'
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { watchMonitors, start, stop } from '../actions/monitors'
import List from 'components/List/List'
class ListPage extends Component {
componentWillMount() {
this.props.watchMonitors()
}
componentDidUpdate() {
const dom = ReactDOM.findDOMNode(this)
const bw = remote.getCurrentWindow()
bw.setSize(250, document.body.clientHeight + 10)
}
render() {
const { monitors } = this.props
return (
<List monitors={monitors} />
)
}
}
ListPage = connect(
state => ({
monitors: state.monitors.data
}),
dispatch => bindActionCreators({ watchMonitors }, dispatch)
)(ListPage)
export default ListPage
|
client/src/components/NotFound.js | kukiron/graphql-messaging-app | import React from 'react';
const NotFound = (props) => {
const match = props.match;
return (
<div className="NotFound">404 Not Found</div>
);
};
export default NotFound;
|
src/js/components/icons/base/CloudSoftware.js | odedre/grommet-final | /**
* @description CloudSoftware SVG Icon.
* @property {string} a11yTitle - Accessibility Title. If not set uses the default title of the status icon.
* @property {string} colorIndex - The color identifier to use for the stroke color.
* If not specified, this component will default to muiTheme.palette.textColor.
* @property {xsmall|small|medium|large|xlarge|huge} size - The icon size. Defaults to small.
* @property {boolean} responsive - Allows you to redefine what the coordinates.
* @example
* <svg width="24" height="24" ><path d="M8,23 L16,23 L16,12 L8,12 L8,23 Z M8,16 L16,16 M12,12 L12,16 M6,6 L6,5 C6,2 7.5,1 10,1 L14,1 C16.5,1 18,2.5 18,5 L18,6 C21,6 23,8 23,11 C23,14 21,16 18,16 M14,6 L6,6 C3,6 1,7.5 1,11 C1,14.5 3,16 6,16"/></svg>
*/
// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import CSSClassnames from '../../../utils/CSSClassnames';
import Intl from '../../../utils/Intl';
import Props from '../../../utils/Props';
const CLASS_ROOT = CSSClassnames.CONTROL_ICON;
const COLOR_INDEX = CSSClassnames.COLOR_INDEX;
export default class Icon extends Component {
render () {
const { className, colorIndex } = this.props;
let { a11yTitle, size, responsive } = this.props;
let { intl } = this.context;
const classes = classnames(
CLASS_ROOT,
`${CLASS_ROOT}-cloud-software`,
className,
{
[`${CLASS_ROOT}--${size}`]: size,
[`${CLASS_ROOT}--responsive`]: responsive,
[`${COLOR_INDEX}-${colorIndex}`]: colorIndex
}
);
a11yTitle = a11yTitle || Intl.getMessage(intl, 'cloud-software');
const restProps = Props.omit(this.props, Object.keys(Icon.propTypes));
return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fill="none" stroke="#000" strokeWidth="2" d="M8,23 L16,23 L16,12 L8,12 L8,23 Z M8,16 L16,16 M12,12 L12,16 M6,6 L6,5 C6,2 7.5,1 10,1 L14,1 C16.5,1 18,2.5 18,5 L18,6 C21,6 23,8 23,11 C23,14 21,16 18,16 M14,6 L6,6 C3,6 1,7.5 1,11 C1,14.5 3,16 6,16"/></svg>;
}
};
Icon.contextTypes = {
intl: PropTypes.object
};
Icon.defaultProps = {
responsive: true
};
Icon.displayName = 'CloudSoftware';
Icon.icon = true;
Icon.propTypes = {
a11yTitle: PropTypes.string,
colorIndex: PropTypes.string,
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']),
responsive: PropTypes.bool
};
|
examples/universal/server/server.js | pbarnes/redux | /* eslint-disable no-console, no-use-before-define */
import path from 'path';
import Express from 'express';
import qs from 'qs';
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from '../common/store/configureStore';
import App from '../common/containers/App';
import { fetchCounter } from '../common/api/counter';
const app = new Express();
const port = 3000;
// Use this middleware to server up static files built into dist
app.use(require('serve-static')(path.join(__dirname, '../dist')));
// This is fired every time the server side receives a request
app.use(handleRender);
function handleRender(req, res) {
// Query our mock API asynchronously
fetchCounter(apiResult => {
// Read the counter from the request, if provided
const params = qs.parse(req.query);
const counter = parseInt(params.counter, 10) || apiResult || 0;
// Compile an initial state
const initialState = { counter };
// Create a new Redux store instance
const store = configureStore(initialState);
// Render the component to a string
const html = React.renderToString(
<Provider store={store}>
{ () => <App/> }
</Provider>);
// Grab the initial state from our Redux store
const finalState = store.getState();
// Send the rendered page back to the client
res.send(renderFullPage(html, finalState));
});
}
function renderFullPage(html, initialState) {
return `
<!doctype html>
<html>
<head>
<title>Redux Universal Example</title>
</head>
<body>
<div id="app">${html}</div>
<script>
window.__INITIAL_STATE__ = ${JSON.stringify(initialState)};
</script>
<script src="/bundle.js"></script>
</body>
</html>
`;
}
app.listen(port, (error) => {
if (error) {
console.error(error);
} else {
console.info(`==> 🌎 Listening on port ${port}. Open up http://localhost:${port}/ in your browser.`);
}
});
|
public/js/components/AnthropometricData.js | Vabrins/CadernetaDoIdoso | import React from 'react';
import $ from 'jquery';
import { Link } from 'react-router-dom';
const initialState = {
weight_2_5:'', height_2_5:'', imc_weight_height_2_5:'', calf_perimeter_pp_left_2_5:'', you_have_exp_loss_uni_weight_min_body_last_year_2_5:''
};
class AnthropometricData extends React.Component {
constructor (props) {
super(props);
this.state = initialState;
this.sendForm = this.sendForm.bind(this);
this.setWeight25 = this.setWeight25.bind(this);
this.setHeight25 = this.setHeight25.bind(this);
this.setImc25 = this.setImc25.bind(this);
this.setPp25 = this.setPp25.bind(this);
this.setWeightLoss25 = this.setWeightLoss25.bind(this);
this.calcImc = this.calcImc.bind(this);
}
componentWillMount() {
$.ajax({
url: "/api/v1/anthropometricdata",
dataType: "json",
method: "GET",
success:function(response){
console.log(response);
}.bind(this)
});
}
reset() {
this.setState(initialState);
}
sendForm(evt) {
let that = this;
$.ajax({
url: "/api/v1/anthropometricdata",
contentType: 'application/json',
dataType: 'json',
method: "POST",
data: JSON.stringify({ test: this.state }),
success: function(response){
console.log(response);
that.reset();
alert("Cadastrado com sucesso!");
},
error: function(response){
console.log("erro");
console.log(response);
}.bind(this)
});
}
render () {
return (
<div className="container" >
<form id="anthropometricdata" method="post">
<div className="row">
<div className="col">
<fieldset>
<label>Peso</label><br/>
<input type="text" value={this.state.weight_2_5} onChange={this.setWeight25} maxLength="5" className="answers-73" id="2.5-weight" name="answers[2.5[weight]]" />
<br/><br/>
<label>Altura</label><br/>
<input type="text" value={this.state.height_2_5} onChange={this.setHeight25} maxLength="5" className="answers-74" id="2.5-height" name="answers[2.5[height]]" />
<br/><br/>
<label>IMC</label><br/>
<input type="text" disabled="disabled" value={this.state.imc_weight_height_2_5} onChange={this.setImc25} maxLength="5" className="answers-75" id="2.5-imc" name="answers[2.5[imc]]" />
<br/><br/>
<label>Perímetro da panturrilha (PP) esquerda</label><br/>
<input type="text" value={this.state.calf_perimeter_pp_left_2_5} onChange={this.setPp25} maxLength="5" className="answers-76" id="2.5-pp" name="answers[2.5[pp]]" />
<br/><br/>
<label>Você apresentou perda de peso não intencional* de, no mínimo, 4,5 kg ou de 5% do seu peso corporal no último ano? </label><br/>
<input type="radio" checked={this.state.you_have_exp_loss_uni_weight_min_body_last_year_2_5 === "1"} onChange={this.setWeightLoss25} className="answers-77" id="2.5-weightloss-1" name="answers[2.5[weightloss]]" value="1" />Sim
<input type="radio" checked={this.state.you_have_exp_loss_uni_weight_min_body_last_year_2_5 === "0"} onChange={this.setWeightLoss25} className="answers-77" id="2.5-weightloss-0" name="answers[2.5[weightloss]]" value="0" />Não
<br/><br/>
</fieldset>
</div>
</div>
</form>
<nav aria-label="Dados Antropométricos">
<ul className="pagination justify-content-center">
<li className="page-item">
<Link className="page-link" to="/reactionorallergy" tabIndex="-1"><i className="fa fa-arrow-left" aria-hidden="true"></i></Link>
</li>
<li className="page-item">
<a className="page-link" onClick={this.sendForm}><i className="fa fa-floppy-o" aria-hidden="true"></i></a>
</li>
<li className="page-item">
<Link className="page-link" to="/vulnerableelderly"><i className="fa fa-arrow-right" aria-hidden="true"></i></Link>
</li>
</ul>
</nav>
</div>
)
}
setWeight25(evt) {
this.setState({weight_2_5: evt.target.value});
this.calcImc();
}
setHeight25(evt) {
this.setState({height_2_5: evt.target.value});
this.calcImc();
}
setImc25(evt) {
this.setState({imc_weight_height_2_5: evt.target.value});
}
setPp25(evt) {
this.setState({calf_perimeter_pp_left_2_5: evt.target.value});
}
setWeightLoss25(evt) {
this.setState({you_have_exp_loss_uni_weight_min_body_last_year_2_5: evt.target.value});
}
calcImc() {
const weight = this.state.weight_2_5;
const height = this.state.height_2_5;
const w = weight.toString().length;
const h = height.toString().length;
if ( weight !="" && height !="" && w >= 2 && h >= 3) {
let result = weight/(height * height);
this.setState({imc_weight_height_2_5: result});
} else {
this.setState({imc_weight_height_2_5: '0'});
}
}
}
export default AnthropometricData |
day19_todolist_style/src/components/App.js | eyesofkids/ironman2017 | import React from 'react'
import TodoList from './TodoList'
class App extends React.Component {
render() {
return <TodoList initText="開始輸入文字吧!" />
}
}
// 輸出App模組
export default App
|
src/svg-icons/action/label.js | frnk94/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionLabel = (props) => (
<SvgIcon {...props}>
<path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 1.99 2 1.99L16 19c.67 0 1.27-.33 1.63-.84L22 12l-4.37-6.16z"/>
</SvgIcon>
);
ActionLabel = pure(ActionLabel);
ActionLabel.displayName = 'ActionLabel';
ActionLabel.muiName = 'SvgIcon';
export default ActionLabel;
|
src/PageItem.js | Firfi/meteor-react-bootstrap | import React from 'react';
import classNames from 'classnames';
const PageItem = React.createClass({
propTypes: {
href: React.PropTypes.string,
target: React.PropTypes.string,
title: React.PropTypes.string,
disabled: React.PropTypes.bool,
previous: React.PropTypes.bool,
next: React.PropTypes.bool,
onSelect: React.PropTypes.func,
eventKey: React.PropTypes.any
},
getDefaultProps() {
return {
href: '#'
};
},
render() {
let classes = {
'disabled': this.props.disabled,
'previous': this.props.previous,
'next': this.props.next
};
return (
<li
{...this.props}
className={classNames(this.props.className, classes)}>
<a
href={this.props.href}
title={this.props.title}
target={this.props.target}
onClick={this.handleSelect}
ref="anchor">
{this.props.children}
</a>
</li>
);
},
handleSelect(e) {
if (this.props.onSelect) {
e.preventDefault();
if (!this.props.disabled) {
this.props.onSelect(this.props.eventKey, this.props.href, this.props.target);
}
}
}
});
export default PageItem;
|
src/js/router.js | puffstream/stream-base-product | import React from 'react';
import { HashRouter as Router, Route } from 'react-router-dom';
import Home from './home';
import Posts from './posts';
import Register from './register';
export default (
<Router>
<div>
<Route exact path="/" component={Home} />
<Route path="/posts" component={Posts} />
<Route path="/register" component={Register} />
</div>
</Router>
); |
components/TitleSection/TitleSection.js | cobbweb/golittle.red | import React from 'react';
import PublishedOn from './PublishedOn';
import Subtitle from './Subtitle';
import Title from './Title';
import TitleText from './TitleText';
import Details from './Details';
import Author from './Author';
import css from './TitleSection.scss';
function TitleSection({ children }) {
return <div className="TitleSection">{children}</div>;
}
export default TitleSection;
export {
PublishedOn,
Subtitle,
Title,
TitleText,
Details,
Author
};
|
src/js/forms/payloads/stories/ExchangePayloadForm.js | mosen/micromdm-ui | import React from 'react';
import {createStore, applyMiddleware, compose} from 'redux';
import {combineReducers} from 'redux';
import {reducer as formReducer} from 'redux-form';
import {Provider} from 'react-redux';
import {storiesOf, action} from '@kadira/storybook';
import {deepOrange500} from 'material-ui/styles/colors';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import ExchangePayloadForm from '../ExchangePayloadForm';
const store = createStore(
combineReducers({ form: formReducer }),
{}
);
const muiTheme = getMuiTheme({
palette: {
accent1Color: deepOrange500
}
});
storiesOf('ExchangePayloadForm', module)
.add('default', () => {
'use strict';
return (<MuiThemeProvider muiTheme={muiTheme}>
<Provider store={store}>
<div style={{"width": "800px"}}>
<ExchangePayloadForm />
</div>
</Provider>
</MuiThemeProvider>);
});
|
index.android.js | noblakit01/react-native-dynamic-button | import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import {
Surface,
Shape,
Path
} from 'ReactNativeART';
import {
DynamicButton,
DynamicButtonType
} from './DynamicButton'
export default class Example extends Component {
constructor(props) {
super(props);
this.state = {buttonType: DynamicButtonType.Pause};
}
render() {
return (
<View style={styles.container}>
<DynamicButton style={{width: 300, height: 300}} type={this.state.buttonType} onPress={this._onPress.bind(this)}>
</DynamicButton>
</View>
);
};
_onPress() {
console.log("App ON PRESS");
let buttonType = this.state.buttonType;
switch (buttonType) {
case DynamicButtonType.Play:
this.setState({
buttonType: DynamicButtonType.Pause
})
break;
case DynamicButtonType.Pause:
this.setState({
buttonType: DynamicButtonType.Stop
})
break;
case DynamicButtonType.Stop:
this.setState({
buttonType: DynamicButtonType.Play
})
break;
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});
AppRegistry.registerComponent('Example', () => Example);
|
src/svg-icons/image/flash-auto.js | mtsandeep/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageFlashAuto = (props) => (
<SvgIcon {...props}>
<path d="M3 2v12h3v9l7-12H9l4-9H3zm16 0h-2l-3.2 9h1.9l.7-2h3.2l.7 2h1.9L19 2zm-2.15 5.65L18 4l1.15 3.65h-2.3z"/>
</SvgIcon>
);
ImageFlashAuto = pure(ImageFlashAuto);
ImageFlashAuto.displayName = 'ImageFlashAuto';
ImageFlashAuto.muiName = 'SvgIcon';
export default ImageFlashAuto;
|
src/components/layout/Home.js | aerendon/yik-yak | import React, { Component } from 'react';
import Zones from '../containers/Zones';
import Comments from '../containers/Comments';
class Home extends Component {
render () {
return (
<div className="container">
<div className="row">
<div className="col-md-4">
<Zones />
</div>
<div className="col-md-8">
<Comments />
</div>
</div>
</div>
)
}
}
export default Home |
src/renderer/main.js | niklasi/halland-proxy | import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import App from './components/app'
import configureStore from './store/configureStore'
import injectTapEventPlugin from 'react-tap-event-plugin'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import darkBaseTheme from 'material-ui/styles/baseThemes/darkBaseTheme'
import getMuiTheme from 'material-ui/styles/getMuiTheme'
import { addRequest, addResponse, toggleFilterInput } from './actions'
import perf from 'react-addons-perf'
import { ipcRenderer as ipc } from 'electron'
import { Router, IndexRoute, Route, createMemoryHistory } from 'react-router'
import RequestsContainer from './components/requests'
import HttpMessageDetailsContainer from './components/http-message-details'
import { ADD_REQUEST, ADD_RESPONSE, TOGGLE_FILTER_INPUT } from '../constants/ipcMessages'
injectTapEventPlugin()
ipc.on(ADD_REQUEST, (e, request) => {
store.dispatch(addRequest(request))
})
ipc.on(ADD_RESPONSE, (e, response) => {
store.dispatch(addResponse(response))
})
ipc.on(TOGGLE_FILTER_INPUT, (e) => {
store.dispatch(toggleFilterInput())
})
Object.defineProperty(window, 'perf', { get: () => perf })
const store = configureStore()
const theme = getMuiTheme(darkBaseTheme)
theme.appBar.height = 32
theme.toolbar.backgroundColor = theme.palette.canvasColor
theme.svgIcon.color = theme.palette.primary3Color
const history = createMemoryHistory('/requests')
render(
<Provider store={store}>
<MuiThemeProvider muiTheme={theme}>
<Router history={history}>
<Route path='/' component={App}>
<Route path='requests'>
<IndexRoute component={RequestsContainer} label='Requests' />
<Route path=':id' component={HttpMessageDetailsContainer} label='Details' />
</Route>
</Route>
</Router>
</MuiThemeProvider>
</Provider>, document.getElementById('mount')
)
|
src/Wrapper.js | ryanbaer/busy | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { IntlProvider } from 'react-intl';
import { withRouter } from 'react-router-dom';
import { Layout } from 'antd';
import Cookie from 'js-cookie';
import { getAuthenticatedUser, getLocale } from './reducers';
import { login, logout } from './auth/authActions';
import { getRate, getRewardFund, getTrendingTopics } from './app/appActions';
import Topnav from './components/Navigation/Topnav';
import Transfer from './wallet/Transfer';
import * as reblogActions from './app/Reblog/reblogActions';
import getTranslations, { getAvailableLocale } from './translations';
@withRouter
@connect(
state => ({
user: getAuthenticatedUser(state),
locale: getLocale(state),
}),
{
login,
logout,
getRate,
getRewardFund,
getTrendingTopics,
getRebloggedList: reblogActions.getRebloggedList,
},
)
export default class Wrapper extends React.PureComponent {
static propTypes = {
user: PropTypes.shape().isRequired,
locale: PropTypes.string.isRequired,
children: PropTypes.element.isRequired,
history: PropTypes.shape().isRequired,
login: PropTypes.func,
logout: PropTypes.func,
getRewardFund: PropTypes.func,
getRebloggedList: PropTypes.func,
getRate: PropTypes.func,
getTrendingTopics: PropTypes.func,
};
static defaultProps = {
login: () => {},
logout: () => {},
getRewardFund: () => {},
getRebloggedList: () => {},
getRate: () => {},
getTrendingTopics: () => {},
};
componentWillMount() {
if (Cookie.get('access_token')) {
this.props.login();
}
this.props.getRewardFund();
this.props.getRebloggedList();
this.props.getRate();
this.props.getTrendingTopics();
}
handleMenuItemClick = (key) => {
switch (key) {
case 'logout':
this.props.logout();
break;
case 'activity':
window.open(`https://steemd.com/@${this.props.user.name}`);
break;
case 'replies':
this.props.history.push('/replies');
break;
case 'bookmarks':
this.props.history.push('/bookmarks');
break;
case 'drafts':
this.props.history.push('/drafts');
break;
case 'settings':
this.props.history.push('/settings');
break;
default:
break;
}
};
render() {
const { locale: appLocale, user } = this.props;
const locale = getAvailableLocale(appLocale);
const translations = getTranslations(appLocale);
return (
<IntlProvider key={locale} locale={locale} messages={translations}>
<Layout>
<Layout.Header style={{ position: 'fixed', width: '100%', zIndex: 5 }}>
<Topnav username={user.name} onMenuItemClick={this.handleMenuItemClick} />
</Layout.Header>
<div className="content">
{this.props.children}
<Transfer />
</div>
</Layout>
</IntlProvider>
);
}
}
|
src/svg-icons/image/nature.js | skarnecki/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageNature = (props) => (
<SvgIcon {...props}>
<path d="M13 16.12c3.47-.41 6.17-3.36 6.17-6.95 0-3.87-3.13-7-7-7s-7 3.13-7 7c0 3.47 2.52 6.34 5.83 6.89V20H5v2h14v-2h-6v-3.88z"/>
</SvgIcon>
);
ImageNature = pure(ImageNature);
ImageNature.displayName = 'ImageNature';
export default ImageNature;
|
src/routes/error/index.js | agiron123/react-starter-kit-TDDOList | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import App from '../../components/App';
import ErrorPage from './ErrorPage';
export default {
path: '/error',
action({ render, context, error }) {
return render(
<App context={context} error={error}>
<ErrorPage error={error} />
</App>,
error.status || 500
);
},
};
|
definitions/npm/react-joyride_v1.x.x/flow_v0.16.x-v0.52.x/react-joyride_v1.x.x.js | hansonw/flow-typed | import React from 'react';
type ReactJoyride$LocaleOption = {
back?: string,
close?: string,
last?: string,
next?: string,
skip?: string,
}
type ReactJoyride$DefaultProps = {
debug: bool,
keyboardNavigation: bool,
locale: ReactJoyride$LocaleOption,
resizeDebounce: bool,
resizeDebounceDelay: number,
scrollOffset: number,
scrollToFirstStep: bool,
scrollToSteps: bool,
showBackButton: bool,
showOverlay: bool,
showSkipButton: bool,
showStepsProgress: bool,
steps: any[],
tooltipOffset: number,
type: 'continous'|'single',
}
type ReactJoyride$Props = {
completeCallback?: Function,
debug?: bool,
keyboardNavigation?: bool,
locale?: ReactJoyride$LocaleOption,
resizeDebounce?: bool,
resizeDebounceDelay?: number,
scrollOffset?: number,
scrollToFirstStep?: bool,
scrollToSteps?: bool,
showBackButton?: bool,
showOverlay?: bool,
showSkipButton?: bool,
showStepsProgress?: bool,
stepCallback?: Function,
steps?: any[],
tooltipOffset?: number,
type?: 'continous'|'single',
}
declare module 'react-joyride' {
declare class Joyride extends React.Component {
static defaultProps: ReactJoyride$DefaultProps;
props: ReactJoyride$Props;
}
declare var exports: typeof Joyride;
}
|
docs/src/pages/index.js | mcanthony/nuclear-js | import React from 'react'
import Wrapper from '../layouts/wrapper'
import ItemFilterExample from '../components/item-filter-example'
import UsageExample from '../components/usage-example'
import Nav from '../components/nav'
export default React.createClass({
render() {
return <Wrapper>
<Nav />
<div className="hero hero--bg" id="index-banner">
<div className="container">
<h1 className="header center white-text">NuclearJS</h1>
<div className="row center">
<h3 className="header col s12 light white-text">
Reactive Flux built with ImmutableJS data structures.
</h3>
</div>
<div className="row center">
<iframe src="https://ghbtns.com/github-btn.html?user=optimizely&repo=nuclear-js&type=star&count=true&size=large" frameBorder="0" scrolling="0" width="140px" height="30px"></iframe>
</div>
</div>
</div>
<div className="tour-section">
<div className="container">
<div className="row">
<div className="col s12 m12 l5 valign-wrapper">
<div className="valign">
<h2 className="red-text tour-section--title">
Simple & Elegant Flux
</h2>
<h3 className="tour-section--bullet-title">
Singular application state
</h3>
<p className="tour-section--bullet-item">
All application state is stored in one Immutable Map, similar to <a href="https://github.com/omcljs/om" target="_blank">Om</a>.
</p>
<p className="tour-section--bullet-item">
Stores declaratively register pure functions to handle state changes, massively simplifying testing and debugging state changes.
</p>
<h3 className="tour-section--bullet-title">
Powerful functional dataflow
</h3>
<p className="tour-section--bullet-item">
Compose and transform your data together statelessly and efficiently using a functional lens concept called <strong>Getters</strong>.
</p>
<p className="tour-section--bullet-item">
This allows your views to receive exactly the data they need in a way that is fully decoupled from stores. Best of all, this pattern eliminates the confusing <code>store.waitsFor</code> method found in other Flux implementations.
</p>
<h3 className="tour-section--bullet-title">
Reactive
</h3>
<p className="tour-section--bullet-item">
Any Getter can be observed by a view to be notified whenever its derived value changes.
</p>
<p className="tour-section--bullet-item">
NuclearJS includes tools to integrate with libraries such as React and VueJS out of the box.
</p>
<h3 className="tour-section--bullet-title">
Efficient
</h3>
<p className="tour-section--bullet-item">
Thanks to immutable data, change detection can be efficiently performed at any level of granularity by a constant time reference equality <code>(===)</code> check.
</p>
<p className="tour-section--bullet-item">
Since Getters use pure functions, NuclearJS utilizes memoization to only recompute parts of the dataflow that might change.
</p>
</div>
</div>
<div className="col s12 m12 l6 offset-l1 tour-section--example">
<ItemFilterExample />
</div>
</div>
</div>
</div>
<div className="tour-section tour-section--bg">
<div className="container">
<h2 className="red-text tour-section--title">
Usage:
</h2>
<UsageExample />
</div>
</div>
<div className="tour-section">
<div className="container">
<div className="row">
<div className="col s12 m12 l6 tour-section--info">
<h2 className="red-text tour-section--title">
Tested & Production Ready
</h2>
<h3 className="tour-section--bullet-title">
Maintained by Optimizely
</h3>
<p className="tour-section--bullet-item">
Optimizely has been using NuclearJS in production since 2014 and will offer long term support and a stable API.
</p>
<h3 className="tour-section--bullet-title">
Easy debugging
</h3>
<p className="tour-section--bullet-item">
With NuclearJS' built in logger you can inspect your application state from the beginning of time. NuclearJS makes tracking down difficult bugs
a breeze, allowing you to focus more time writing code.
</p>
<h3 className="tour-section--bullet-title">
Testable
</h3>
<p className="tour-section--bullet-item">
When building with NuclearJS there is never a question of "How do I test this?". There are prescribed testing strategies
for every type of thing you will build with NuclearJS.
</p>
<h3 className="tour-section--bullet-title">
Prescribed code organization structure
</h3>
<p>
For large codebases the prescribed way of organization is to group all stores, actions and getters of the same domain in a module.
</p>
<p>
This method of code organization is extremely portable, making it almost trivial to refactor, split code into multiple bundles and create contracts between modules.
</p>
<p>
In fact, Optimizely's codebase has over 50 modules and is growing everyday. Using this pattern makes it easy for teams to consume other teams modules, leading to
great code reusability.
</p>
</div>
<div className="col s12 m12 l5 offset-l1 tour-section--example">
<img src="assets/img/debug_console.jpg" width="750px" alt="" />
</div>
</div>
</div>
</div>
</Wrapper>
}
})
|
app/containers/FeaturePage/index.js | gihrig/react-boilerplate-logic | /*
* FeaturePage
*
* List all the features
*/
import React from 'react';
import Helmet from 'react-helmet';
import { FormattedMessage } from 'react-intl';
import H1 from 'components/H1';
import messages from './messages';
import List from './List';
import ListItem from './ListItem';
import ListItemTitle from './ListItemTitle';
export default class FeaturePage extends React.Component { // eslint-disable-line react/prefer-stateless-function
// Since state and props are static,
// there's no need to re-render this component
shouldComponentUpdate() {
return false;
}
render() {
return (
<div>
<Helmet
title="Feature Page"
meta={[
{ name: 'description', content: 'Feature page of React.js Boilerplate application' },
]}
/>
<H1>
<FormattedMessage {...messages.header} />
</H1>
<List>
<ListItem>
<ListItemTitle>
<FormattedMessage {...messages.scaffoldingHeader} />
</ListItemTitle>
<p>
<FormattedMessage {...messages.scaffoldingMessage} />
</p>
</ListItem>
<ListItem>
<ListItemTitle>
<FormattedMessage {...messages.feedbackHeader} />
</ListItemTitle>
<p>
<FormattedMessage {...messages.feedbackMessage} />
</p>
</ListItem>
<ListItem>
<ListItemTitle>
<FormattedMessage {...messages.routingHeader} />
</ListItemTitle>
<p>
<FormattedMessage {...messages.routingMessage} />
</p>
</ListItem>
<ListItem>
<ListItemTitle>
<FormattedMessage {...messages.networkHeader} />
</ListItemTitle>
<p>
<FormattedMessage {...messages.networkMessage} />
</p>
</ListItem>
<ListItem>
<ListItemTitle>
<FormattedMessage {...messages.intlHeader} />
</ListItemTitle>
<p>
<FormattedMessage {...messages.intlMessage} />
</p>
</ListItem>
</List>
</div>
);
}
}
|
src/components/Body.js | OpenCollective/frontend | import React from 'react';
export default class Body extends React.Component {
render() {
return (
<main>
<style jsx global>
{`
main {
height: 100%;
width: 100%;
font-family: 'Inter UI', sans-serif;
letter-spacing: -0.2px;
font-weight: 300;
font-size: 1.6rem;
line-height: 1.5;
overflow-x: hidden;
margin: 0;
padding: 0;
}
a {
text-decoration: none !important;
cursor: pointer;
}
h1 {
font-size: 4rem;
letter-spacing: -1.2px;
}
h2,
h3 {
letter-spacing: -0.4px;
}
button {
cursor: pointer;
}
.content {
max-width: 111rem;
padding: 2rem 1.5rem;
margin: 0 auto;
line-height: 1.5;
overflow: hidden;
}
.content p {
text-overflow: ellipsis;
margin: 1.5rem 0;
}
.content h2 {
font-size: 1.8rem;
}
.content h3 {
font-size: 1.7rem;
}
.content > ul {
padding-left: 3rem;
}
.content ul p {
display: initial;
}
.content li {
margin: 1rem 0;
text-align: left;
}
.content img {
max-width: 100%;
}
.content code {
background-color: #f6f8fa;
padding: 0.5rem;
overflow: scroll;
max-width: 100%;
}
.content code:first-child:last-child {
display: inline-block;
padding: 1rem;
}
@media (max-width: 420px) {
.content {
padding: 1rem 1.5rem;
}
}
`}
</style>
{this.props.children}
</main>
);
}
}
|
classic/src/scenes/wbui/ULinkOR/ULinkORAccountSection/ServiceListItem/ServiceListItem.js | wavebox/waveboxapp | import React from 'react'
import PropTypes from 'prop-types'
import shallowCompare from 'react-addons-shallow-compare'
import { Typography, ListItemSecondaryAction, Tooltip, IconButton } from '@material-ui/core'
import { withStyles } from '@material-ui/core/styles'
import ACAvatarCircle2 from '../../../ACAvatarCircle2'
import MailboxServiceBadge from '../../../MailboxServiceBadge'
import classNames from 'classnames'
import TabIcon from '@material-ui/icons/Tab'
import OpenInNewIcon from '@material-ui/icons/OpenInNew'
import ULinkORListItem from '../../ULinkORListItem'
import ULinkORListItemText from '../../ULinkORListItemText'
const privAccountStore = Symbol('privAccountStore')
const styles = {
root: {
paddingTop: 4,
paddingBottom: 4,
paddingRight: 84,
height: 65
},
avatarContainer: {
position: 'relative',
width: 36,
minWidth: 36,
height: 36,
minHeight: 36,
marginRight: 4
},
badge: {
position: 'absolute',
fontWeight: process.platform === 'linux' ? 'normal' : '300',
height: 18,
minWidth: 18,
width: 'auto',
lineHeight: '18px',
fontSize: '10px',
top: -3,
right: -7,
boxShadow: ' 0px 0px 1px 0px rgba(0,0,0,0.8)'
},
badgeFAIcon: {
color: 'white',
fontSize: '10px'
},
badgeContainer: {
display: 'flex',
position: 'relative',
justifyContent: 'center',
alignItems: 'center',
width: 36,
height: 36
},
mailboxAvatar: {
position: 'absolute',
right: -6,
bottom: -1
}
}
@withStyles(styles)
class ServiceListItem extends React.Component {
/* **************************************************************************/
// Class
/* **************************************************************************/
static propTypes = {
serviceId: PropTypes.string.isRequired,
accountStore: PropTypes.object.isRequired,
avatarResolver: PropTypes.func.isRequired,
onOpenInRunningService: PropTypes.func.isRequired,
onOpenInServiceWindow: PropTypes.func.isRequired
}
/* **************************************************************************/
// Lifecycle
/* **************************************************************************/
constructor (props) {
super(props)
this[privAccountStore] = this.props.accountStore
// Generate state
this.state = {
...this.generateServiceState(this.props.serviceId, this[privAccountStore].getState())
}
}
/* **************************************************************************/
// Component lifecycle
/* **************************************************************************/
componentDidMount () {
this[privAccountStore].listen(this.accountUpdated)
}
componentWillUnmount () {
this[privAccountStore].unlisten(this.accountUpdated)
}
componentWillReceiveProps (nextProps) {
if (this.props.accountStore !== nextProps.accountStore) {
console.warn('Changing props.accountStore is not supported in ULinkORAccountResultListItem and will be ignored')
}
if (this.props.serviceId !== nextProps.serviceId) {
this.setState(
this.generateServiceState(nextProps.serviceId, this[privAccountStore].getState())
)
}
}
/* **************************************************************************/
// Data lifecycle
/* **************************************************************************/
accountUpdated = (accountState) => {
this.setState(
this.generateServiceState(this.props.serviceId, accountState)
)
}
generateServiceState (serviceId, accountState) {
const mailbox = accountState.getMailboxForService(serviceId)
const service = accountState.getService(serviceId)
const serviceData = accountState.getServiceData(serviceId)
if (mailbox && service && serviceData) {
const authData = accountState.getMailboxAuthForServiceId(serviceId)
const isServiceSleeping = accountState.isServiceSleeping(serviceId)
return {
membersAvailable: true,
displayName: accountState.resolvedServiceDisplayName(serviceId),
mailboxAvatar: accountState.getMailboxAvatarConfig(mailbox.id),
serviceAvatar: accountState.getServiceAvatarConfig(serviceId),
isServiceSleeping: isServiceSleeping,
supportsUnreadCount: service.supportsUnreadCount,
showBadgeCount: service.showBadgeCount,
unreadCount: serviceData.getUnreadCount(service),
hasUnreadActivity: serviceData.getHasUnreadActivity(service),
supportsUnreadActivity: service.supportsUnreadActivity,
showBadgeActivity: service.showBadgeActivity,
badgeColor: service.badgeColor,
mailboxHasSingleService: mailbox.hasSingleService,
documentTitle: serviceData.documentTitle,
nextUrl: isServiceSleeping
? service.getUrlWithData(serviceData, authData)
: service.url,
mailboxHelperDisplayName: accountState.resolvedMailboxExplicitServiceDisplayName(mailbox.id)
}
} else {
return {
membersAvailable: false
}
}
}
/* **************************************************************************/
// UI Events
/* **************************************************************************/
/**
* Handles a click somewhere in the list item
* @param evt: the event that fired
*/
handleListItemClick = (evt) => {
const { onClick, onOpenInServiceWindow, serviceId } = this.props
onOpenInServiceWindow(evt, serviceId)
if (onClick) { onClick(evt) }
}
/**
* Handles the open in account button being clicked
* @param evt: the event that fired
*/
handleOpenInAccountClick = (evt) => {
evt.preventDefault()
evt.stopPropagation()
const { onOpenInRunningService, serviceId } = this.props
onOpenInRunningService(evt, serviceId)
}
/**
* Handles the open in window button being clicked
* @param evt: the event that fired
*/
handleOpenInWindowClick = (evt) => {
evt.preventDefault()
evt.stopPropagation()
const { onOpenInServiceWindow, serviceId } = this.props
onOpenInServiceWindow(evt, serviceId)
}
/* **************************************************************************/
// Rendering
/* **************************************************************************/
shouldComponentUpdate (nextProps, nextState) {
return shallowCompare(this, nextProps, nextState)
}
render () {
const {
classes,
serviceId,
avatarResolver,
accountStore,
onOpenInRunningService,
onOpenInServiceWindow,
className,
onClick,
...passProps
} = this.props
const {
membersAvailable,
displayName,
mailboxAvatar,
serviceAvatar,
isServiceSleeping,
supportsUnreadCount,
showBadgeCount,
unreadCount,
hasUnreadActivity,
supportsUnreadActivity,
showBadgeActivity,
badgeColor,
mailboxHasSingleService,
documentTitle,
nextUrl,
mailboxHelperDisplayName
} = this.state
if (!membersAvailable) { return false }
return (
<ULinkORListItem
className={classNames(className, classes.root)}
onClick={this.handleListItemClick}
{...passProps}>
<div className={classes.avatarContainer}>
<MailboxServiceBadge
badgeClassName={classes.badge}
className={classes.badgeContainer}
iconClassName={classes.badgeFAIcon}
supportsUnreadCount={supportsUnreadCount}
showUnreadBadge={showBadgeCount}
unreadCount={unreadCount}
supportsUnreadActivity={supportsUnreadActivity}
showUnreadActivityBadge={showBadgeActivity}
hasUnreadActivity={hasUnreadActivity}
color={badgeColor}
isAuthInvalid={false}>
<ACAvatarCircle2
avatar={serviceAvatar}
size={36}
resolver={avatarResolver}
showSleeping={isServiceSleeping}
circleProps={{ showSleeping: false }} />
{!mailboxHasSingleService ? (
<ACAvatarCircle2
avatar={mailboxAvatar}
className={classes.mailboxAvatar}
size={16}
resolver={avatarResolver}
showSleeping={false} />
) : undefined}
</MailboxServiceBadge>
</div>
<ULinkORListItemText
primary={(
<React.Fragment>
{displayName}
{displayName !== mailboxHelperDisplayName ? (
<Typography
inline
color='textSecondary'
component='span'>
{mailboxHelperDisplayName}
</Typography>
) : undefined}
</React.Fragment>
)}
primaryTypographyProps={{ noWrap: true }}
secondary={documentTitle && documentTitle !== displayName ? documentTitle : nextUrl}
secondaryTypographyProps={{ noWrap: true }} />
<ListItemSecondaryAction>
<Tooltip title='Open in existing account tab'>
<IconButton onClick={this.handleOpenInAccountClick}>
<TabIcon />
</IconButton>
</Tooltip>
<Tooltip title='Open in new Window'>
<IconButton onClick={this.handleOpenInWindowClick}>
<OpenInNewIcon />
</IconButton>
</Tooltip>
</ListItemSecondaryAction>
</ULinkORListItem>
)
}
}
export default ServiceListItem
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.