path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
src/ScrollableInkTabBar.js | tinper-bee/bee-tabs | /**
* This source code is quoted from rc-tabs.
* homepage: https://github.com/react-component/tabs
*/
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import InkTabBarNode from './InkTabBarNode';
import TabBarTabsNode from './TabBarTabsNode';
import TabBarRootNode from './TabBarRootNode';
import ScrollableTabBarNode from './ScrollableTabBarNode';
import SaveRef from './SaveRef';
export default class ScrollableInkTabBar extends React.Component {
componentDidMount(){
ReactDOM.findDOMNode(this).addEventListener('DNDclick', (e) => {
if(e && e.detail && e.detail.key){
this.props.onTabClick.call(this, e.detail.key)
}
});
}
componentWillUnmount(){
ReactDOM.findDOMNode(this).removeEventListener('DNDclick',(e) => {
if(e && e.detail && e.detail.key){
this.props.onTabClick.call(this, e.detail.key)
}
});
}
render() {
const { children: renderTabBarNode, ...restProps } = this.props;
return (
<SaveRef>
{(saveRef, getRef) => (
<TabBarRootNode saveRef={saveRef} {...restProps}>
<ScrollableTabBarNode saveRef={saveRef} getRef={getRef} {...restProps}>
<TabBarTabsNode saveRef={saveRef} renderTabBarNode={renderTabBarNode} {...restProps} />
<InkTabBarNode saveRef={saveRef} getRef={getRef} {...restProps} />
</ScrollableTabBarNode>
</TabBarRootNode>
)}
</SaveRef>
);
}
}
ScrollableInkTabBar.propTypes = {
children: PropTypes.func,
};
|
client/node_modules/uu5g03/dist-node/forms-v3/text-button.js | UnicornCollege/ucl.itkpd.configurator | import React from 'react';
import {BaseMixin, ElementaryMixin, Tools} from './../common/common.js';
import InputWrapper from './internal/input-wrapper.js';
import TextInput from './internal/text-input.js';
import TextInputMixin from './mixins/text-input-mixin.js'
import ItemList from './internal/item-list.js';
import Backdrop from './../bricks/backdrop.js';
import './text-button.less';
export const TextButton = React.createClass({
//@@viewOn:mixins
mixins: [
BaseMixin,
ElementaryMixin,
TextInputMixin
],
//@@viewOff:mixins
//@@viewOn:statics
statics: {
tagName: 'UU5.Forms.TextButton',
classNames: {
main: 'uu5-forms-text-button'
}
},
//@@viewOff:statics
//@@viewOn:propTypes
propTypes: {
value: React.PropTypes.string,
buttons: React.PropTypes.arrayOf(React.PropTypes.shape({
glyphicon: React.PropTypes.string,
onClick: React.PropTypes.func,
colorSchema: React.PropTypes.string
})
)
},
//@@viewOff:propTypes
//@@viewOn:getDefaultProps
getDefaultProps () {
return {
value: '',
buttons: null
};
},
//@@viewOff:getDefaultProps
//@@viewOn:standardComponentLifeCycle
componentWillMount(){
if (this.props.onValidate && typeof this.props.onValidate === 'function') {
this._validateOnChange({value: this.state.value, event: null, component: this})
}
return this;
},
componentWillReceiveProps(nextProps) {
if (this.props.controlled) {
this.setFeedback(nextProps.feedback, nextProps.message, nextProps.value)
}
return this;
},
//@@viewOff:standardComponentLifeCycle
//@@viewOn:interface
//@@viewOff:interface
//@@viewOn:overridingMethods
// TODO: tohle je ještě otázka - je potřeba nastavit hodnotu z jiné komponenty (musí být validace) a z onChange (neměla by být validace)
setValue_(value, setStateCallback){
if (this._checkRequired({value: value})) {
if (typeof this.props.onValidate === 'function') {
this._validateOnChange({value: value, event: null, component: this})
} else {
this.props.required ? this.setSuccess(null, value, setStateCallback) : this.setInitial(null, value, setStateCallback);
}
}
return this;
},
//@@viewOff:overridingMethods
//@@viewOn:componentSpecificHelpers
_validateOnChange(opt){
let result = typeof this.props.onValidate === 'function' ? this.props.onValidate(opt) : null;
if (result) {
if (typeof result === 'object') {
if (result.feedback) {
this.setFeedback(result.feedback, result.message, result.value);
} else {
this.setState({value: opt.value});
}
} else {
this.showError('validateError', null, {context: {event: e, func: this.props.onValidate, result: result}});
}
}
return this;
},
_getFeedbackIcon(){
let icon = this.props.required ? this.props.successGlyphicon : null;
switch (this.getFeedback()) {
case 'success':
icon = this.props.successGlyphicon;
break;
case 'warning':
icon = this.props.warningGlyphicon;
break;
case 'error':
icon = this.props.errorGlyphicon;
break;
}
return icon;
},
_getButtons(){
let result = [];
if (!this.isReadOnly()) {
this.props.buttons && this.props.buttons.map((button, key)=> {
let newButton = Tools.merge({}, button);
if (typeof button.onClick === 'function') {
newButton.onClick = ()=> button.onClick({value: this.state.value, component: this});
}
if (this.isDisabled()) {
newButton.disabled = true;
}
result.push(newButton);
});
}
return result;
},
//@@viewOff:componentSpecificHelpers
//@@viewOn:render
render () {
let inputId = this.getId() + '-input';
return (
<div {...this._getInputAttrs()}>
{this.getLabel(inputId)}
{this.getInputWrapper([
<TextInput
id={inputId}
name={this.props.name || inputId}
value={this.state.value}
placeholder={this.props.placeholder}
type='text'
onChange={this.onChange}
onBlur={this.onBlur}
onFocus={this.onFocus}
mainAttrs={this.props.inputAttrs}
disabled={this.isDisabled() || this.isLoading()}
readonly={this.isReadOnly()}
glyphicon={this._getFeedbackIcon()}
loading={this.isLoading()}
/>,
this.state.autocompleteItems && <ItemList {...this._getItemListProps()}>
{this._getChildren()}
</ItemList>,
this.state.autocompleteItems && <Backdrop {...this._getBackdropProps()} />],
this._getButtons())}
</div>
);
}
//@@viewOn:render
});
export default TextButton;
|
poster/src/poster2/index.js | FeifeiyuM/test-repo | import React from 'react'
import { render } from 'react-dom'
import { Router, browserHistory } from 'react-router'
const rootRoute = {
childRoutes: [{
path: '/src/poster2',
component: require('./components/poster'),
}]
}
const rootElem = (<Router history={ browserHistory } routes={rootRoute} />)
render(
rootElem,
document.getElementById('poster')
) |
src/router/index.js | vshao/webapp | import React from 'react'
import { Route, Switch } from 'react-router-dom'
import { E404, E504 } from '@/components/error'
import Home from '@/views/home'
import HotSell from '@/views/hotsell'
export default () => (
<div>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/hotsell" component={HotSell} />
<Route component={E404} />
</Switch>
</div>
)
|
srcjs/components/BookSearchPanel.js | wlainer/react-redux-tutorial | import React from 'react';
import ReactDOM from 'react-dom';
export default class SearchPanel extends React.Component {
constructor() {
super()
this.onSearchChange = this.onSearchChange.bind(this)
this.onClearSearch = this.onClearSearch.bind(this)
this.state = {}
}
render() {
return (
<div className="input-group">
<input placeholder="Find..." ref='search' name='search' type='text' className="form-control" defaultValue={this.props.search} value={this.state.search} onChange={this.onSearchChange } />
<span className="input-group-btn">
<button className="btn btn-default" type="button" onClick={this.onClearSearch}>x</button>
</span>
</div>
)
}
onSearchChange() {
let query = ReactDOM.findDOMNode(this.refs.search).value;
if (this.promise) {
clearInterval(this.promise)
}
this.setState({
search: query
});
this.promise = setTimeout(() => this.props.onSearchChanged(query), 400);
}
onClearSearch() {
this.setState({
search: ''
});
this.props.onSearchChanged(undefined)
}
}
|
examples/breadcrumbs/app.js | tylermcginnis/react-router | import React from 'react'
import { render } from 'react-dom'
import { browserHistory, Router, Route, Link } from 'react-router'
import withExampleBasename from '../withExampleBasename'
import './app.css'
const App = ({ children, routes }) => {
const depth = routes.length
return (
<div>
<aside>
<ul>
<li><Link to={Products.path}>Products</Link></li>
<li><Link to={Orders.path}>Orders</Link></li>
</ul>
</aside>
<main>
<ul className="breadcrumbs-list">
{routes.map((item, index) =>
<li key={index}>
<Link
onlyActiveOnIndex={true}
activeClassName="breadcrumb-active"
to={item.path || ''}>
{item.component.title}
</Link>
{(index + 1) < depth && '\u2192'}
</li>
)}
</ul>
{children}
</main>
</div>
)
}
App.title = 'Home'
App.path = '/'
const Products = () => (
<div className="Page">
<h1>Products</h1>
</div>
)
Products.title = 'Products'
Products.path = '/products'
const Orders = () => (
<div className="Page">
<h1>Orders</h1>
</div>
)
Orders.title = 'Orders'
Orders.path = '/orders'
render((
<Router history={withExampleBasename(browserHistory, __dirname)}>
<Route path={App.path} component={App}>
<Route path={Products.path} component={Products} />
<Route path={Orders.path} component={Orders} />
</Route>
</Router>
), document.getElementById('example'))
|
react-github-battle/app/components/Home.js | guilsa/javascript-stuff | import React from 'react'
import { Link } from 'react-router'
import { transparentBg } from '../styles'
import MainContainer from './MainContainer'
var Home = React.createClass({
render () {
return(
<MainContainer>
<h1>Github Battle</h1>
<p className="lead">Some fancy motto</p>
<Link to="/playerOne">
<button type="button" className="btn btn-lg btn-success">Get Started</button>
</Link>
</MainContainer>
)
}
});
export default Home
|
routes.js | kris1226/clymer-metal-crafts | import React from 'react';
import { Route , Router } from 'react-router';
import App from './containers/App';
import DetailsPage from './containers/DetailsPage';
import ImagesContianer from './containers/ImagesContainer';
import Image from './components/Image';
import createHistory from 'history/lib/createHashHistory';
const history = createHistory();
export default (
<Router history={history}>
<Route path="/" component={App}>
<Route path="image/:imageId" component={DetailsPage} />
<Route path="image/:imageId" component={DetailsPage} />
</Route>
</Router>
)
|
app/react-icons/fa/sliders.js | scampersand/sonos-front | import React from 'react';
import IconBase from 'react-icon-base';
export default class FaSliders extends React.Component {
render() {
return (
<IconBase viewBox="0 0 40 40" {...this.props}>
<g><path d="m10.9 31.4v2.9h-7.9v-2.9h7.9z m7.8-2.8q0.6 0 1 0.4t0.4 1v5.7q0 0.6-0.4 1t-1 0.4h-5.7q-0.6 0-1-0.4t-0.4-1v-5.7q0-0.6 0.4-1t1-0.4h5.7z m3.6-8.6v2.9h-19.3v-2.9h19.3z m-14.3-11.4v2.8h-5v-2.8h5z m29.3 22.8v2.9h-16.4v-2.9h16.4z m-21.4-25.7q0.5 0 1 0.4t0.4 1v5.8q0 0.5-0.4 1t-1 0.4h-5.8q-0.5 0-1-0.4t-0.4-1v-5.8q0-0.5 0.4-1t1-0.4h5.8z m14.2 11.4q0.6 0 1 0.5t0.5 1v5.7q0 0.6-0.5 1t-1 0.4h-5.7q-0.5 0-1-0.4t-0.4-1v-5.7q0-0.6 0.4-1t1-0.5h5.7z m7.2 2.9v2.9h-5v-2.9h5z m0-11.4v2.8h-19.3v-2.8h19.3z"/></g>
</IconBase>
);
}
}
|
app/scripts/components/service.js | kroupaTomass/Rondo-kuchyne | import React from 'react';
import { Link } from 'react-router';
class SectionService extends React.Component{
constructor(props, context) {
super(props);
}
render() {
return (
<section className="services" id="SERVICE">
<div className="container">
<div className="row">
<div className="col-md-3 text-center">
<div className="single_service wow fadeInLeft" data-wow-delay="1s">
<!--i className="icon-chat"></i -->
<img src="images/img-konzultace.png" alt="Rondo Kuchyně" />
<h2>Konzultace</h2>
<p>Sjednejte si s námi schůzku a řekněte nám o vaší vysněné kuchyni či interiérovém nábytku</p>
</div>
</div>
<div className="col-md-3 text-center">
<div className="single_service wow fadeInUp" data-wow-delay="2s">
<!-- i className="icon-pencil"></i -->
<img src="images/img-navrh.png" alt="Rondo Kuchyně" />
<h2>Návrh</h2>
<p>Náš designér se specializací na projektování kuchyní a nábytku vytvoří 3D návrh vaší zakázky přesně podle vašich představ a požadavků</p>
</div>
</div>
<div className="col-md-3 text-center">
<div className="single_service wow fadeInUp" data-wow-delay="3s">
<!--i className="icon-gears"></i -->
<img src="images/img-vyroba.png" alt="Rondo Kuchyně" />
<h2>Výroba na míru</h2>
<p>Vaši potvrzenou zakázku předáváme na dílnu, kde je vyrobena podle domluvených detailů</p>
</div>
</div>
<div className="col-md-3 text-center">
<div className="single_service wow fadeInRight" data-wow-delay="4s">
<!--i className="icon-tools-2"></i -->
<img src="images/img-montaz.png" alt="Rondo Kuchyně" />
<h2>Montáž</h2>
<p>Vaši kuchyni či nábytek ve stanoveném termínu přivezeme a zkompletujeme. A vy už si jen užíváte radost z nového kousku ve vašem domově</p>
</div>
</div>
</div>
</div>
</section>
);
}
}
SectionService.contextTypes = {
router: React.PropTypes.func.isRequired
}
export default SectionService;
|
frontend/src/Movie/Index/Table/MovieStatusCell.js | Radarr/Radarr | import PropTypes from 'prop-types';
import React from 'react';
import Icon from 'Components/Icon';
import VirtualTableRowCell from 'Components/Table/Cells/TableRowCell';
import { icons } from 'Helpers/Props';
import { getMovieStatusDetails } from 'Movie/MovieStatus';
import translate from 'Utilities/String/translate';
import styles from './MovieStatusCell.css';
function MovieStatusCell(props) {
const {
className,
monitored,
status,
component: Component,
...otherProps
} = props;
const statusDetails = getMovieStatusDetails(status);
return (
<Component
className={className}
{...otherProps}
>
<Icon
className={styles.statusIcon}
name={monitored ? icons.MONITORED : icons.UNMONITORED}
title={monitored ? translate('MovieIsMonitored') : translate('MovieIsUnmonitored')}
/>
<Icon
className={styles.statusIcon}
name={statusDetails.icon}
title={`${statusDetails.title}: ${statusDetails.message}`}
/>
</Component>
);
}
MovieStatusCell.propTypes = {
className: PropTypes.string.isRequired,
monitored: PropTypes.bool.isRequired,
status: PropTypes.string.isRequired,
component: PropTypes.elementType
};
MovieStatusCell.defaultProps = {
className: styles.status,
component: VirtualTableRowCell
};
export default MovieStatusCell;
|
js/containers/ApplicationTabs/Activity2/index.js | Seedstars/reactnative-mobile-app-base | import React, { Component } from 'react';
import {
View,
Text,
} from 'react-native';
import styles from './styles';
export default class Activity2 extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.h1}>
Activity2
</Text>
</View>
);
}
}
|
react/features/connection-stats/components/ConnectionStatsTable.js | jitsi/jitsi-meet | /* @flow */
import { withStyles } from '@material-ui/styles';
import clsx from 'clsx';
import React, { Component } from 'react';
import { isMobileBrowser } from '../../../features/base/environment/utils';
import ContextMenu from '../../base/components/context-menu/ContextMenu';
import { translate } from '../../base/i18n';
/**
* The type of the React {@code Component} props of
* {@link ConnectionStatsTable}.
*/
type Props = {
/**
* The audio SSRC of this client.
*/
audioSsrc: number,
/**
* Statistics related to bandwidth.
* {{
* download: Number,
* upload: Number
* }}.
*/
bandwidth: Object,
/**
* Statistics related to bitrate.
* {{
* download: Number,
* upload: Number
* }}.
*/
bitrate: Object,
/**
* The number of bridges (aka media servers) currently used in the
* conference.
*/
bridgeCount: number,
/**
* An object containing the CSS classes.
*/
classes: Object,
/**
* Audio/video codecs in use for the connection.
*/
codec: Object,
/**
* A message describing the connection quality.
*/
connectionSummary: string,
/**
* The end-to-end round-trip-time.
*/
e2eRtt: number,
/**
* Whether or not should display the "Save Logs" link.
*/
enableSaveLogs: boolean,
/**
* Whether or not should display the "Show More" link.
*/
disableShowMoreStats: boolean,
/**
* The endpoint id of this client.
*/
participantId: string,
/**
* Statistics related to frame rates for each ssrc.
* {{
* [ ssrc ]: Number
* }}.
*/
framerate: Object,
/**
* Whether or not the statistics are for local video.
*/
isLocalVideo: boolean,
/**
* Whether or not the statistics are for screen share.
*/
isVirtualScreenshareParticipant: boolean,
/**
* The send-side max enabled resolution (aka the highest layer that is not
* suspended on the send-side).
*/
maxEnabledResolution: number,
/**
* Callback to invoke when the user clicks on the download logs link.
*/
onSaveLogs: Function,
/**
* Callback to invoke when the show additional stats link is clicked.
*/
onShowMore: Function,
/**
* Statistics related to packet loss.
* {{
* download: Number,
* upload: Number
* }}.
*/
packetLoss: Object,
/**
* The region that we think the client is in.
*/
region: string,
/**
* Statistics related to display resolutions for each ssrc.
* {{
* [ ssrc ]: {
* height: Number,
* width: Number
* }
* }}.
*/
resolution: Object,
/**
* The region of the media server that we are connected to.
*/
serverRegion: string,
/**
* Whether or not additional stats about bandwidth and transport should be
* displayed. Will not display even if true for remote participants.
*/
shouldShowMore: boolean,
/**
* Invoked to obtain translated strings.
*/
t: Function,
/**
* The video SSRC of this client.
*/
videoSsrc: number,
/**
* Statistics related to transports.
*/
transport: Array<Object>,
/**
* Whether source name signaling is enabled.
*/
sourceNameSignalingEnabled: boolean
};
/**
* Click handler.
*
* @param {SyntheticEvent} event - The click event.
* @returns {void}
*/
function onClick(event) {
// If the event is propagated to the thumbnail container the participant will be pinned. That's why the propagation
// needs to be stopped.
event.stopPropagation();
}
const styles = theme => {
return {
actions: {
margin: '10px auto',
textAlign: 'center'
},
connectionStatsTable: {
'&, & > table': {
fontSize: '12px',
fontWeight: '400',
'& td': {
padding: '2px 0'
}
},
'& > table': {
whiteSpace: 'nowrap'
},
'& td:nth-child(n-1)': {
paddingLeft: '5px'
},
'& $upload, & $download': {
marginRight: '2px'
}
},
contextMenu: {
position: 'relative',
marginTop: 0,
right: 'auto',
padding: `${theme.spacing(2)}px ${theme.spacing(1)}px`,
marginLeft: `${theme.spacing(1)}px`,
marginRight: `${theme.spacing(1)}px`,
marginBottom: `${theme.spacing(1)}px`
},
download: {},
mobile: {
margin: `${theme.spacing(3)}px`
},
status: {
fontWeight: 'bold'
},
upload: {}
};
};
/**
* React {@code Component} for displaying connection statistics.
*
* @augments Component
*/
class ConnectionStatsTable extends Component<Props> {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
const {
classes,
disableShowMoreStats,
enableSaveLogs,
isVirtualScreenshareParticipant,
isLocalVideo
} = this.props;
const className = clsx(classes.connectionStatsTable, { [classes.mobile]: isMobileBrowser() });
if (isVirtualScreenshareParticipant) {
return this._renderScreenShareStatus();
}
return (
<ContextMenu
className = { classes.contextMenu }
hidden = { false }
inDrawer = { true }>
<div
className = { className }
onClick = { onClick }>
{ this._renderStatistics() }
<div className = { classes.actions }>
{ isLocalVideo && enableSaveLogs ? this._renderSaveLogs() : null}
{ !disableShowMoreStats && this._renderShowMoreLink() }
</div>
{ this.props.shouldShowMore ? this._renderAdditionalStats() : null }
</div>
</ContextMenu>
);
}
/**
* Creates a ReactElement that will display connection statistics for a screen share thumbnail.
*
* @private
* @returns {ReactElement}
*/
_renderScreenShareStatus() {
const { classes } = this.props;
const className = isMobileBrowser() ? 'connection-info connection-info__mobile' : 'connection-info';
return (<ContextMenu
className = { classes.contextMenu }
hidden = { false }
inDrawer = { true }>
<div
className = { className }
onClick = { onClick }>
{ <table className = 'connection-info__container'>
<tbody>
{ this._renderResolution() }
{ this._renderFrameRate() }
</tbody>
</table> }
</div>
</ContextMenu>);
}
/**
* Creates a table as ReactElement that will display additional statistics
* related to bandwidth and transport for the local user.
*
* @private
* @returns {ReactElement}
*/
_renderAdditionalStats() {
const { isLocalVideo } = this.props;
return (
<table>
<tbody>
{ isLocalVideo ? this._renderBandwidth() : null }
{ isLocalVideo ? this._renderTransport() : null }
{ isLocalVideo ? this._renderRegion() : null }
{ this._renderAudioSsrc() }
{ this._renderVideoSsrc() }
{ this._renderParticipantId() }
</tbody>
</table>
);
}
/**
* Creates a table row as a ReactElement for displaying bandwidth related
* statistics.
*
* @private
* @returns {ReactElement}
*/
_renderBandwidth() {
const { classes } = this.props;
const { download, upload } = this.props.bandwidth || {};
return (
<tr>
<td>
{ this.props.t('connectionindicator.bandwidth') }
</td>
<td>
<span className = { classes.download }>
↓
</span>
{ download ? `${download} Kbps` : 'N/A' }
<span className = { classes.upload }>
↑
</span>
{ upload ? `${upload} Kbps` : 'N/A' }
</td>
</tr>
);
}
/**
* Creates a a table row as a ReactElement for displaying bitrate related
* statistics.
*
* @private
* @returns {ReactElement}
*/
_renderBitrate() {
const { classes } = this.props;
const { download, upload } = this.props.bitrate || {};
return (
<tr>
<td>
<span>
{ this.props.t('connectionindicator.bitrate') }
</span>
</td>
<td>
<span className = { classes.download }>
↓
</span>
{ download ? `${download} Kbps` : 'N/A' }
<span className = { classes.upload }>
↑
</span>
{ upload ? `${upload} Kbps` : 'N/A' }
</td>
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying the audio ssrc.
* This will typically be something like "Audio SSRC: 12345".
*
* @returns {JSX.Element}
* @private
*/
_renderAudioSsrc() {
const { audioSsrc, t } = this.props;
return (
<tr>
<td>
<span>{ t('connectionindicator.audio_ssrc') }</span>
</td>
<td>{ audioSsrc || 'N/A' }</td>
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying the video ssrc.
* This will typically be something like "Video SSRC: 12345".
*
* @returns {JSX.Element}
* @private
*/
_renderVideoSsrc() {
const { videoSsrc, t } = this.props;
return (
<tr>
<td>
<span>{ t('connectionindicator.video_ssrc') }</span>
</td>
<td>{ videoSsrc || 'N/A' }</td>
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying the endpoint id.
* This will typically be something like "Endpoint id: 1e8fbg".
*
* @returns {JSX.Element}
* @private
*/
_renderParticipantId() {
const { participantId, t } = this.props;
return (
<tr>
<td>
<span>{ t('connectionindicator.participant_id') }</span>
</td>
<td>{ participantId || 'N/A' }</td>
</tr>
);
}
/**
* Creates a a table row as a ReactElement for displaying codec, if present.
* This will typically be something like "Codecs (A/V): Opus, vp8".
*
* @private
* @returns {ReactElement}
*/
_renderCodecs() {
const { codec, t, sourceNameSignalingEnabled } = this.props;
if (!codec) {
return;
}
let codecString;
if (sourceNameSignalingEnabled) {
codecString = `${codec.audio}, ${codec.video}`;
} else {
// Only report one codec, in case there are multiple for a user.
Object.keys(codec || {})
.forEach(ssrc => {
const { audio, video } = codec[ssrc];
codecString = `${audio}, ${video}`;
});
}
if (!codecString) {
codecString = 'N/A';
}
return (
<tr>
<td>
<span>{ t('connectionindicator.codecs') }</span>
</td>
<td>{ codecString }</td>
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying a summary message
* about the current connection status.
*
* @private
* @returns {ReactElement}
*/
_renderConnectionSummary() {
const { classes } = this.props;
return (
<tr className = { classes.status }>
<td>
<span>{ this.props.t('connectionindicator.status') }</span>
</td>
<td>{ this.props.connectionSummary }</td>
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying end-to-end RTT and
* the region.
*
* @returns {ReactElement}
* @private
*/
_renderE2eRtt() {
const { e2eRtt, t } = this.props;
const str = e2eRtt ? `${e2eRtt.toFixed(0)}ms` : 'N/A';
return (
<tr>
<td>
<span>{ t('connectionindicator.e2e_rtt') }</span>
</td>
<td>{ str }</td>
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying the "connected to"
* information.
*
* @returns {ReactElement}
* @private
*/
_renderRegion() {
const { region, serverRegion, t } = this.props;
let str = serverRegion;
if (!serverRegion) {
return;
}
if (region && serverRegion && region !== serverRegion) {
str += ` from ${region}`;
}
return (
<tr>
<td>
<span>{ t('connectionindicator.connectedTo') }</span>
</td>
<td>{ str }</td>
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying the "bridge count"
* information.
*
* @returns {*}
* @private
*/
_renderBridgeCount() {
const { bridgeCount, t } = this.props;
// 0 is valid, but undefined/null/NaN aren't.
if (!bridgeCount && bridgeCount !== 0) {
return;
}
return (
<tr>
<td>
<span>{ t('connectionindicator.bridgeCount') }</span>
</td>
<td>{ bridgeCount }</td>
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying frame rate related
* statistics.
*
* @private
* @returns {ReactElement}
*/
_renderFrameRate() {
const { framerate, t, sourceNameSignalingEnabled } = this.props;
let frameRateString;
if (sourceNameSignalingEnabled) {
frameRateString = framerate || 'N/A';
} else {
frameRateString = Object.keys(framerate || {})
.map(ssrc => framerate[ssrc])
.join(', ') || 'N/A';
}
return (
<tr>
<td>
<span>{ t('connectionindicator.framerate') }</span>
</td>
<td>{ frameRateString }</td>
</tr>
);
}
/**
* Creates a tables row as a ReactElement for displaying packet loss related
* statistics.
*
* @private
* @returns {ReactElement}
*/
_renderPacketLoss() {
const { classes, packetLoss, t } = this.props;
let packetLossTableData;
if (packetLoss) {
const { download, upload } = packetLoss;
packetLossTableData = (
<td>
<span className = { classes.download }>
↓
</span>
{ download === null ? 'N/A' : `${download}%` }
<span className = { classes.upload }>
↑
</span>
{ upload === null ? 'N/A' : `${upload}%` }
</td>
);
} else {
packetLossTableData = <td>N/A</td>;
}
return (
<tr>
<td>
<span>
{ t('connectionindicator.packetloss') }
</span>
</td>
{ packetLossTableData }
</tr>
);
}
/**
* Creates a table row as a ReactElement for displaying resolution related
* statistics.
*
* @private
* @returns {ReactElement}
*/
_renderResolution() {
const { resolution, maxEnabledResolution, t, sourceNameSignalingEnabled } = this.props;
let resolutionString;
if (sourceNameSignalingEnabled) {
resolutionString = resolution ? `${resolution.width}x${resolution.height}` : 'N/A';
} else {
resolutionString = Object.keys(resolution || {})
.map(ssrc => {
const { width, height } = resolution[ssrc];
return `${width}x${height}`;
})
.join(', ') || 'N/A';
}
if (maxEnabledResolution && maxEnabledResolution < 720) {
const maxEnabledResolutionTitle = t('connectionindicator.maxEnabledResolution');
resolutionString += ` (${maxEnabledResolutionTitle} ${maxEnabledResolution}p)`;
}
return (
<tr>
<td>
<span>{ t('connectionindicator.resolution') }</span>
</td>
<td>{ resolutionString }</td>
</tr>
);
}
/**
* Creates a ReactElement for display a link to save the logs.
*
* @private
* @returns {ReactElement}
*/
_renderSaveLogs() {
return (
<span>
<a
className = 'savelogs link'
onClick = { this.props.onSaveLogs }
role = 'button'
tabIndex = { 0 }>
{ this.props.t('connectionindicator.savelogs') }
</a>
<span> | </span>
</span>
);
}
/**
* Creates a ReactElement for display a link to toggle showing additional
* statistics.
*
* @private
* @returns {ReactElement}
*/
_renderShowMoreLink() {
const translationKey
= this.props.shouldShowMore
? 'connectionindicator.less'
: 'connectionindicator.more';
return (
<a
className = 'showmore link'
onClick = { this.props.onShowMore }
role = 'button'
tabIndex = { 0 }>
{ this.props.t(translationKey) }
</a>
);
}
/**
* Creates a table as a ReactElement for displaying connection statistics.
*
* @private
* @returns {ReactElement}
*/
_renderStatistics() {
const isRemoteVideo = !this.props.isLocalVideo;
return (
<table>
<tbody>
{ this._renderConnectionSummary() }
{ this._renderBitrate() }
{ this._renderPacketLoss() }
{ isRemoteVideo ? this._renderE2eRtt() : null }
{ isRemoteVideo ? this._renderRegion() : null }
{ this._renderResolution() }
{ this._renderFrameRate() }
{ this._renderCodecs() }
{ isRemoteVideo ? null : this._renderBridgeCount() }
</tbody>
</table>
);
}
/**
* Creates table rows as ReactElements for displaying transport related
* statistics.
*
* @private
* @returns {ReactElement[]}
*/
_renderTransport() {
const { t, transport } = this.props;
if (!transport || transport.length === 0) {
const NA = (
<tr key = 'address'>
<td>
<span>{ t('connectionindicator.address') }</span>
</td>
<td>
N/A
</td>
</tr>
);
return [ NA ];
}
const data = {
localIP: [],
localPort: [],
remoteIP: [],
remotePort: [],
transportType: []
};
for (let i = 0; i < transport.length; i++) {
const ip = getIP(transport[i].ip);
const localIP = getIP(transport[i].localip);
const localPort = getPort(transport[i].localip);
const port = getPort(transport[i].ip);
if (!data.remoteIP.includes(ip)) {
data.remoteIP.push(ip);
}
if (!data.localIP.includes(localIP)) {
data.localIP.push(localIP);
}
if (!data.localPort.includes(localPort)) {
data.localPort.push(localPort);
}
if (!data.remotePort.includes(port)) {
data.remotePort.push(port);
}
if (!data.transportType.includes(transport[i].type)) {
data.transportType.push(transport[i].type);
}
}
// All of the transports should be either P2P or JVB
let isP2P = false, isTURN = false;
if (transport.length) {
isP2P = transport[0].p2p;
isTURN = transport[0].localCandidateType === 'relay'
|| transport[0].remoteCandidateType === 'relay';
}
const additionalData = [];
if (isP2P) {
additionalData.push(
<span> (p2p)</span>);
}
if (isTURN) {
additionalData.push(<span> (turn)</span>);
}
// First show remote statistics, then local, and then transport type.
const tableRowConfigurations = [
{
additionalData,
data: data.remoteIP,
key: 'remoteaddress',
label: t('connectionindicator.remoteaddress',
{ count: data.remoteIP.length })
},
{
data: data.remotePort,
key: 'remoteport',
label: t('connectionindicator.remoteport',
{ count: transport.length })
},
{
data: data.localIP,
key: 'localaddress',
label: t('connectionindicator.localaddress',
{ count: data.localIP.length })
},
{
data: data.localPort,
key: 'localport',
label: t('connectionindicator.localport',
{ count: transport.length })
},
{
data: data.transportType,
key: 'transport',
label: t('connectionindicator.transport',
{ count: data.transportType.length })
}
];
return tableRowConfigurations.map(this._renderTransportTableRow);
}
/**
* Creates a table row as a ReactElement for displaying a transport related
* statistic.
*
* @param {Object} config - Describes the contents of the row.
* @param {ReactElement} config.additionalData - Extra data to display next
* to the passed in config.data.
* @param {Array} config.data - The transport statistics to display.
* @param {string} config.key - The ReactElement's key. Must be unique for
* iterating over multiple child rows.
* @param {string} config.label - The text to display describing the data.
* @private
* @returns {ReactElement}
*/
_renderTransportTableRow(config: Object) {
const { additionalData, data, key, label } = config;
return (
<tr key = { key }>
<td>
<span>
{ label }
</span>
</td>
<td>
{ getStringFromArray(data) }
{ additionalData || null }
</td>
</tr>
);
}
}
/**
* Utility for getting the IP from a transport statistics object's
* representation of an IP.
*
* @param {string} value - The transport's IP to parse.
* @private
* @returns {string}
*/
function getIP(value) {
if (!value) {
return '';
}
return value.substring(0, value.lastIndexOf(':'));
}
/**
* Utility for getting the port from a transport statistics object's
* representation of an IP.
*
* @param {string} value - The transport's IP to parse.
* @private
* @returns {string}
*/
function getPort(value) {
if (!value) {
return '';
}
return value.substring(value.lastIndexOf(':') + 1, value.length);
}
/**
* Utility for concatenating values in an array into a comma separated string.
*
* @param {Array} array - Transport statistics to concatenate.
* @private
* @returns {string}
*/
function getStringFromArray(array) {
let res = '';
for (let i = 0; i < array.length; i++) {
res += (i === 0 ? '' : ', ') + array[i];
}
return res;
}
export default translate(withStyles(styles)(ConnectionStatsTable));
|
src/icons/SocialGoogleplusOutline.js | fbfeix/react-icons | import React from 'react';
import IconBase from './../components/IconBase/IconBase';
export default class SocialGoogleplusOutline extends React.Component {
render() {
if(this.props.bare) {
return <g>
<g>
<path d="M223.5,82.1c11.8,9.6,36.4,29.7,36.4,68c0,37.3-21.5,54.9-43.1,71.5c-6.7,6.6-14.4,13.6-14.4,24.7
c0,11.1,7.7,17.2,13.3,21.7l18.5,14.1c22.6,18.6,43.1,35.8,43.1,70.6c0,47.4-46.7,95.2-135,95.2C67.9,448,32,413.2,32,375.9
c0-18.1,9.2-43.8,39.5-61.5c31.8-19.1,75-21.7,98-23.2c-7.2-9.1-15.4-18.7-15.4-34.3c0-8.6,2.6-13.6,5.1-19.7
c-5.6,0.5-11.3,1-16.4,1c-54.4,0-85.2-39.8-85.2-79.1c0-23.2,10.8-48.9,32.9-67.5C119.8,68,154.7,64,182.4,64h105.7l-32.8,18.1
H223.5z M187,305.9c-4.1-0.5-6.7-0.5-11.8-0.5c-4.6,0-32.3,1-53.9,8c-11.3,4-44.1,16.1-44.1,51.9c0,35.8,35.4,61.5,90.3,61.5
c49.3,0,75.4-23.2,75.4-54.4C242.9,346.7,226,333.1,187,305.9 M201.9,210.1c11.8-11.6,12.8-27.7,12.8-36.8
c0-36.3-22.1-92.7-64.7-92.7c-13.3,0-27.7,6.5-35.9,16.6c-8.7,10.6-11.3,24.2-11.3,37.3c0,33.8,20,89.7,64.2,89.7
C179.8,224.3,193.6,218.2,201.9,210.1"></path>
<polygon points="480,142.3 401.7,142.3 401.7,64.1 384,64.1 384,142.3 304.3,142.3 304.3,160.1 384,160.1 384,241 401.7,241
401.7,160.1 480,160.1 "></polygon>
</g>
</g>;
} return <IconBase>
<g>
<path d="M223.5,82.1c11.8,9.6,36.4,29.7,36.4,68c0,37.3-21.5,54.9-43.1,71.5c-6.7,6.6-14.4,13.6-14.4,24.7
c0,11.1,7.7,17.2,13.3,21.7l18.5,14.1c22.6,18.6,43.1,35.8,43.1,70.6c0,47.4-46.7,95.2-135,95.2C67.9,448,32,413.2,32,375.9
c0-18.1,9.2-43.8,39.5-61.5c31.8-19.1,75-21.7,98-23.2c-7.2-9.1-15.4-18.7-15.4-34.3c0-8.6,2.6-13.6,5.1-19.7
c-5.6,0.5-11.3,1-16.4,1c-54.4,0-85.2-39.8-85.2-79.1c0-23.2,10.8-48.9,32.9-67.5C119.8,68,154.7,64,182.4,64h105.7l-32.8,18.1
H223.5z M187,305.9c-4.1-0.5-6.7-0.5-11.8-0.5c-4.6,0-32.3,1-53.9,8c-11.3,4-44.1,16.1-44.1,51.9c0,35.8,35.4,61.5,90.3,61.5
c49.3,0,75.4-23.2,75.4-54.4C242.9,346.7,226,333.1,187,305.9 M201.9,210.1c11.8-11.6,12.8-27.7,12.8-36.8
c0-36.3-22.1-92.7-64.7-92.7c-13.3,0-27.7,6.5-35.9,16.6c-8.7,10.6-11.3,24.2-11.3,37.3c0,33.8,20,89.7,64.2,89.7
C179.8,224.3,193.6,218.2,201.9,210.1"></path>
<polygon points="480,142.3 401.7,142.3 401.7,64.1 384,64.1 384,142.3 304.3,142.3 304.3,160.1 384,160.1 384,241 401.7,241
401.7,160.1 480,160.1 "></polygon>
</g>
</IconBase>;
}
};SocialGoogleplusOutline.defaultProps = {bare: false} |
src/pages/public.js | PLopezD/groupme-playlist | import React from 'react';
import ampersandMixin from 'ampersand-react-mixin';
import { LocalCard } from '../components/card';
import { GridList } from 'material-ui/GridList';
import GmeHeader from '../components/GmeHeader';
import { GmeBottom } from '../components/GmeBottom';
export default React.createClass({
mixins:[ampersandMixin],
getInitialState: function() {
return {
cols: 3,
offset:0,
fetch:true
};
},
render () {
let postHtml;
const { posts } = this.props;
if (posts) {
postHtml = posts.map((post,i)=>{
return (
<LocalCard class='test' post={post} key={i} />
)
})
} else {
postHtml = <div>Fuck all, something's broke</div>;
};
return (
<section>
<GmeHeader {...this.props} />
<div className='container'>
<GridList
cellHeight={450}
cols={this.state.cols}
padding={10}
>
{ postHtml }
</GridList>
</div>
<GmeBottom fetch={this.props.posts.length === 0 }/>
</section>
)
},
componentDidMount() {
this.scrollTimer = null;
window.addEventListener("resize", this.updateDimensions);
// commented out cause fuck pagination
// window.addEventListener("scroll", this.scrollCheck);
},
componentWillMount() {
const width = window.innerWidth;
this.setWidth(width);
},
scrollCheck() {
if (this.scrollTimer) {
clearTimeout(this.scrollTimer); // clear any previous pending timer
}
this.scrollTimer = setTimeout(() => {
if (window.scrollY - 1500 > window.innerHeight) {
this.fetchMore();
}
}, 500);
},
fetchMore() {
console.log('in fetch more')
this.setState({offset:this.state.offset + 1})
this.props.user.fetchData({offset:this.state.offset})
},
updateDimensions(e) {
const width = e.target.innerWidth;
this.setWidth(width);
},
setWidth(width) {
if (width < 500) {
this.setState({cols:1})
} else if (width < 750) {
this.setState({cols:2})
} else {
this.setState({cols:3})
}
}
})
|
app/app.js | jwarning/react-ci-test | /**
* app.js
*
* This is the entry file for the application, only setup and boilerplate
* code.
*/
// Needed for redux-saga es6 generator support
import 'babel-polyfill';
// Import all the third party stuff
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { applyRouterMiddleware, Router, browserHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import FontFaceObserver from 'fontfaceobserver';
import { useScroll } from 'react-router-scroll';
import 'sanitize.css/sanitize.css';
// Import root app
import App from 'containers/App';
// Import selector for `syncHistoryWithStore`
import { makeSelectLocationState } from 'containers/App/selectors';
// Import Language Provider
import LanguageProvider from 'containers/LanguageProvider';
// Load the favicon, the manifest.json file and the .htaccess file
/* eslint-disable import/no-webpack-loader-syntax */
import '!file-loader?name=[name].[ext]!./favicon.ico';
import '!file-loader?name=[name].[ext]!./manifest.json';
import 'file-loader?name=[name].[ext]!./.htaccess'; // eslint-disable-line import/extensions
/* eslint-enable import/no-webpack-loader-syntax */
import configureStore from './store';
// Import i18n messages
import { translationMessages } from './i18n';
// Import CSS reset and Global Styles
import './global-styles';
// Import routes
import createRoutes from './routes';
// Observe loading of Open Sans (to remove open sans, remove the <link> tag in
// the index.html file and this observer)
const openSansObserver = new FontFaceObserver('Open Sans', {});
// When Open Sans is loaded, add a font-family using Open Sans to the body
openSansObserver.load().then(() => {
document.body.classList.add('fontLoaded');
}, () => {
document.body.classList.remove('fontLoaded');
});
// Create redux store with history
// this uses the singleton browserHistory provided by react-router
// Optionally, this could be changed to leverage a created history
// e.g. `const browserHistory = useRouterHistory(createBrowserHistory)();`
const initialState = {};
const store = configureStore(initialState, browserHistory);
// Sync history and store, as the react-router-redux reducer
// is under the non-default key ("routing"), selectLocationState
// must be provided for resolving how to retrieve the "route" in the state
const history = syncHistoryWithStore(browserHistory, store, {
selectLocationState: makeSelectLocationState(),
});
// Set up the router, wrapping all Routes in the App component
const rootRoute = {
component: App,
childRoutes: createRoutes(store),
};
const render = (messages) => {
ReactDOM.render(
<Provider store={store}>
<LanguageProvider messages={messages}>
<Router
history={history}
routes={rootRoute}
render={
// Scroll to top when going to a new page, imitating default browser
// behaviour
applyRouterMiddleware(useScroll())
}
/>
</LanguageProvider>
</Provider>,
document.getElementById('app')
);
};
// Hot reloadable translation json files
if (module.hot) {
// modules.hot.accept does not accept dynamic dependencies,
// have to be constants at compile-time
module.hot.accept('./i18n', () => {
render(translationMessages);
});
}
// Chunked polyfill for browsers without Intl support
if (!window.Intl) {
(new Promise((resolve) => {
resolve(import('intl'));
}))
.then(() => Promise.all([
import('intl/locale-data/jsonp/en.js'),
import('intl/locale-data/jsonp/de.js'),
]))
.then(() => render(translationMessages))
.catch((err) => {
throw err;
});
} else {
render(translationMessages);
}
// Install ServiceWorker and AppCache in the end since
// it's not most important operation and if main code fails,
// we do not want it installed
if (process.env.NODE_ENV === 'production') {
require('offline-plugin/runtime').install(); // eslint-disable-line global-require
}
|
actor-apps/app-web/src/app/components/JoinGroup.react.js | sfshine/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);
|
imports/ui/components/todo-item/Todo.js | juliancwirko/scotty | import React from 'react';
import { connect } from 'react-redux';
import { string, func, bool } from 'prop-types';
import { callRemoveTodo, callEditTodo } from '../../../api/redux/async-actions';
const Todo = (props) => {
const { message, todoId, dispatchCallRemoveTodo, dispatchCallEditTodo, finished } = props;
const handleRemove = () => {
dispatchCallRemoveTodo(todoId);
};
const handleEdit = () => {
dispatchCallEditTodo(todoId);
};
const finishedClass = () => {
if (finished) {
return 'todo-item todo-finished';
}
return 'todo-item';
};
return (
<div className={finishedClass()}>
<input type="checkbox" checked={finished} onChange={handleEdit} />
{message}
<button type="button" onClick={handleRemove}>
<i className="fa fa-times" />
</button>
</div>
);
};
Todo.propTypes = {
message: string.isRequired,
todoId: string.isRequired,
dispatchCallRemoveTodo: func.isRequired,
dispatchCallEditTodo: func.isRequired,
finished: bool,
};
Todo.defaultProps = {
finished: false,
};
const mapStateToProps = () => ({});
const mapDispatchToProps = dispatch => ({
dispatchCallRemoveTodo: _id => dispatch(callRemoveTodo(_id)),
dispatchCallEditTodo: _id => dispatch(callEditTodo(_id)),
});
export default connect(mapStateToProps, mapDispatchToProps)(Todo);
|
components/animals/takinIndicky.adult.js | marxsk/zobro | import React, { Component } from 'react';
import { Text } from 'react-native';
import styles from '../../styles/styles';
import InPageImage from '../inPageImage';
import AnimalText from '../animalText';
import AnimalTemplate from '../animalTemplate';
const IMAGES = [
require('../../images/animals/takinIndicky/01.jpg'),
require('../../images/animals/takinIndicky/02.jpg'),
require('../../images/animals/takinIndicky/03.jpg'),
];
const THUMBNAILS = [
require('../../images/animals/takinIndicky/01-thumb.jpg'),
require('../../images/animals/takinIndicky/02-thumb.jpg'),
require('../../images/animals/takinIndicky/03-thumb.jpg'),
];
var AnimalDetail = React.createClass({
render() {
return (
<AnimalTemplate firstIndex={[2]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator}>
<AnimalText>
Takin indický, latinsky <Text style={styles.italic}>Budorcas taxicolor taxicolor</Text>, je velmi zvláštní sudokopytník čeledi turovitých. V čem tkví jeho zvláštnost? Jaké jiné zvíře připomíná tolik dalších? Je to bizon, pakůň, los nebo kamzík? Právě všechna tato zvířata se svojí určitou vlastností snoubí v jednom takiním těle.
</AnimalText>
<InPageImage indexes={[0]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator} />
<AnimalText>
Bohužel i přes svoji hbitost, připisovanou spíše kamzíkům, je takin na stupních ohrožení zranitelným druhem – těch indických už na světě není více než půl čtvrtého tisíce. Vyskytuje se na jihu Číny, v indickém státě Ásám, v Tibetu a Bhútánu, ale i v Barmě. Obvykle žije ve výšce 2 500 až 4 500 metrů nad mořem. Takini se naštěstí docela činí, takže zatím není všem takiním dnům konec.
</AnimalText>
<InPageImage indexes={[1]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator} />
<AnimalText>
Jedinec takina indického může vážit až 350 kilogramů a v kohoutku měřit i 130 centimetrů, na délku pak 170 až 220 centimetrů. Kůže takina produkuje maz, který mu pomáhá chránit se proti drsným povětrnostním podmínkám panujícím v jeho přirozeném prostředí, zejména proti mlze a dešti. Takin se živí trávou, listy, bambusovými nebo pěnišníkovými výhonky.
</AnimalText>
<AnimalText>
Žije v menších stádech (tvořených deseti až třiceti zvířaty), jeho samice je březí až 220 dní a má obvykle jen jedno mládě. Ve volné přírodě se dožívá dvanácti až patnácti let, v lidské péči i dvaceti let.
</AnimalText>
</AnimalTemplate>
);
}
});
module.exports = AnimalDetail;
|
client/node_modules/uu5g03/doc/main/client/src/bricks/link.js | UnicornCollege/ucl.itkpd.configurator | import React from 'react';
import UU5 from 'uu5';
import './link.css';
export default React.createClass({
//@@viewOn:mixins
mixins: [
UU5.Common.BaseMixin,
UU5.Common.ElementaryMixin,
UU5.Common.ContentMixin
],
//@@viewOff:mixins
//@@viewOn:statics
statics: {
tagName: 'UU5.Doc.Bricks.Link',
classNames: {
main: 'uu5-doc-bricks-link'
},
defaults: {},
limits: {},
calls: {},
warnings: {},
errors: {},
lsi: {},
opt: {}
},
//@@viewOff:statics
//@@viewOn:propTypes
propTypes: {
tagName: React.PropTypes.string,
to: React.PropTypes.string,
onClick: React.PropTypes.func
},
//@@viewOff:propTypes
//@@viewOn:getDefaultProps
getDefaultProps() {
return {
tagName: null,
to: null,
onClick: undefined
};
},
//@@viewOff:getDefaultProps
//@@viewOn:standardComponentLifeCycle
//@@viewOff:standardComponentLifeCycle
//@@viewOn:interface
//@@viewOff:interface
//@@viewOn:overridingMethods
//@@viewOff:overridingMethods
//@@viewOn:componentSpecificHelpers
_getMainProps() {
let props = this.getMainPropsToPass();
props.content = this.props.tagName || this.getContent();
let path = this.props.to;
if (this.props.tagName) {
path = '/components' + this.props.tagName.toLowerCase().replace('uu5', '').replace(/\./g, '/');
}
props.onClick = (link, e) => {
if (e.button === 1 || e.ctrlKey) {
window.open(path, '_blank');
} else {
this.setRoute(path, this.props.onClick);
window.scrollTo(0, 0);
}
};
props.mainAttrs = props.mainAttrs || {};
props.mainAttrs.onMouseUp = (e) => {
e.button === 1 && window.open(path, '_blank');
e.preventDefault();
};
return props;
},
//@@viewOff:componentSpecificHelpers
//@@viewOn:render
render() {
return (
<UU5.Bricks.Link {...this._getMainProps()} >
{this.props.children && React.Children.toArray(this.props.children)}
</UU5.Bricks.Link>
);
}
//@@viewOn:render
}); |
src/router.js | PineconeFM/pinecone-client | /**
* React Static Boilerplate
* https://github.com/kriasoft/react-static-boilerplate
*
* Copyright © 2015-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';
function decodeParam(val) {
if (!(typeof val === 'string' || val.length === 0)) {
return val;
}
try {
return decodeURIComponent(val);
} catch (err) {
if (err instanceof URIError) {
err.message = `Failed to decode param '${val}'`;
err.status = 400;
}
throw err;
}
}
// Match the provided URL path pattern to an actual URI string. For example:
// matchURI({ path: '/posts/:id' }, '/dummy') => null
// matchURI({ path: '/posts/:id' }, '/posts/123') => { id: 123 }
function matchURI(route, path) {
const match = route.pattern.exec(path);
if (!match) {
return null;
}
const params = Object.create(null);
for (let i = 1; i < match.length; i += 1) {
params[route.keys[i - 1].name] = match[i] !== undefined ? decodeParam(match[i]) : undefined;
}
return params;
}
// Find the route matching the specified location (context), fetch the required data,
// instantiate and return a React component
function resolve(routes, context) {
for (const route of routes) { // eslint-disable-line no-restricted-syntax
const params = matchURI(route, context.error ? '/error' : context.pathname);
if (!params) {
continue; // eslint-disable-line no-continue
}
// Check if the route has any data requirements, for example:
// { path: '/tasks/:id', data: { task: 'GET /api/tasks/$id' }, page: './pages/task' }
if (route.data) {
// Load page component and all required data in parallel
const keys = Object.keys(route.data);
return Promise.all([
route.load(),
...keys.map((key) => {
const query = route.data[key];
const method = query.substring(0, query.indexOf(' ')); // GET
let url = query.substr(query.indexOf(' ') + 1); // /api/tasks/$id
// TODO: Optimize
Object.keys(params).forEach((k) => {
url = url.replace(`${k}`, params[k]);
});
return fetch(url, { method }).then(resp => resp.json());
}),
]).then(([Page, ...data]) => {
const props = keys.reduce((result, key, i) => ({ ...result, [key]: data[i] }), {});
return <Page route={{ ...route, params }} error={context.error} {...props} />;
});
}
return route.load().then(Page => <Page route={{ ...route, params }} error={context.error} />);
}
const error = new Error('Page not found');
error.status = 404;
return Promise.reject(error);
}
export default { resolve };
|
src/js/Components/Common/SectionControls.js | mattgordils/DropSplash | import React, { Component } from 'react';
import InlineSVG from 'svg-inline-react/lib';
import Button from 'Components/Common/Button';
import PlusIcon from 'assets/icons/plus-icon';
import ContentPane from 'Components/ContentPane/ContentPane'
import 'sass/components/common/section-controls';
export default class App extends Component {
constructor (props) {
super(props);
this.state = {
showContentPane: false
};
}
toggleContentPane () {
if (this.state.showContentPane === false) {
this.setState({showContentPane: true});
} else {
this.setState({showContentPane: false});
}
}
addContentOptions () {
if(this.state.showContentPane === true) {
return <ContentPane />
}
}
render () {
return (
<div className="ds-section-controls">
<div className="left-controls">
<Button
buttonClass="circle medium button-ripple add-content-button"
icon={PlusIcon}
clickEvent={this.toggleContentPane.bind(this)}
tooltipText="Add Content"
{...this.props}
/>
{this.addContentOptions()}
</div>
<div className="right-controls">
<div className="button-group two-buttons">
<Button
buttonClass="medium"
label="Section Options"
{...this.props}
/>
<Button
buttonClass="medium"
label="Background"
{...this.props}
/>
</div>
</div>
</div>
);
}
} |
src/components/FooterComponent.js | Zcyon/lait | 'use strict';
import React from 'react';
require('styles//Footer.css');
let FooterComponent = () => (
<footer className="footer">
<div className="content has-text-centered">
<p>
<strong>Lait</strong> by Lascario Pacheco. The source code is licensed under MIT.
</p>
</div>
</footer>
);
FooterComponent.displayName = 'FooterComponent';
// Uncomment properties you need
// FooterComponent.propTypes = {};
// FooterComponent.defaultProps = {};
export default FooterComponent;
|
src/components/tools/warnings.js | robzsk/mm.editor | import React, { Component } from 'react';
import PENS from './../../pens';
class Warnings extends Component {
getErrors() {
const { data } = this.props;
let player = false;
let target = false;
const ret = [];
data.forEach(row => {
if (row.indexOf(PENS.PLAYER) !== -1) {
player = true;
}
if (row.indexOf(PENS.TARGET) !== -1) {
target = true;
}
}, []);
if (!player) {
ret.push('Player spawn is not set.');
}
if (!target) {
ret.push('At least one target must be placed.')
}
return ret;
}
render() {
const errors = this.getErrors();
return (
<div className="warnings">
{
errors.map((e, i) => (<div key={i}>Warning: {e}</div>))
}
</div>
)
}
}
export default Warnings;
|
src/pages/talita-kume.js | vitorbarbosa19/ziro-online | import React from 'react'
import BrandGallery from '../components/BrandGallery'
export default () => (
<BrandGallery brand='Talita Kume' />
)
|
src/frontend/components/SignUp/SignUp.js | BaranovNikita/Page-About-Me | import React from 'react';
import { TextField, RaisedButton, CircularProgress } from 'material-ui';
import { isEmpty } from 'lodash';
import signupValidate from '../../../share/validate/signup';
class SignUp extends React.Component {
constructor() {
super();
this.handleChange = this.handleChange.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.handleBlur = this.handleBlur.bind(this);
this.state = {
first_name: '',
last_name: '',
email: '',
password: '',
passwordConfirmation: '',
isLoading: false,
errors: {
first_name: '',
},
};
}
componentWillMount() {
this.setState(this.props.formData);
}
componentWillUnmount() {
this.props.saveFormData(this.state);
}
onSubmit(e) {
e.preventDefault();
this.setState({ isLoading: true });
this.props.userRegisterRequest(this.state)
.then(() => {
this.setState({ isLoading: false, errors: {} });
this.props.clearFormData();
if (this.props.successEvent) {
this.props.successEvent();
}
})
.catch((err) => {
this.setState({ isLoading: false, errors: { ...this.state.errors, ...err.response.data } });
this.props.clearFormData();
});
}
handleChange(e) {
this.setState({ [e.target.name]: e.target.value });
}
handleBlur(e) {
this.setState({ isLoading: true });
const errors = signupValidate(this.state);
if (Object.prototype.hasOwnProperty.call(errors, e.target.name)) {
this.setState({ errors: Object.assign({}, this.state.errors, errors), isLoading: false });
} else {
let newStateError = {};
if (e.target.name === 'email') {
this.props.isUserExists(e.target.value)
.then((response) => {
if (response.data.user) {
this.setState({ errors: { ...this.state.errors, email: 'Already exist!' } });
} else {
newStateError = { ...this.state.errors };
delete newStateError.email;
}
});
} else {
newStateError = { ...this.state.errors };
delete newStateError[e.target.name];
}
this.setState({ errors: newStateError, isLoading: false });
}
}
render() {
return (
<form onSubmit={this.onSubmit}>
<TextField
hintText='First name'
onChange={this.handleChange}
name='first_name' fullWidth
onBlur={this.handleBlur}
value={this.state.first_name}
errorText={this.state.errors.first_name}
/>
<TextField
hintText='Last name'
onChange={this.handleChange}
name='last_name'
fullWidth
value={this.state.last_name}
onBlur={this.handleBlur}
errorText={this.state.errors.last_name}
/>
<TextField
hintText='Email address'
onChange={this.handleChange}
name='email'
fullWidth
value={this.state.email}
onBlur={this.handleBlur}
errorText={this.state.errors.email}
/>
<TextField
hintText='Password'
onChange={this.handleChange}
name='password'
type='password'
fullWidth
value={this.state.password}
onBlur={this.handleBlur}
errorText={this.state.errors.password}
/>
<TextField
hintText='Confirm Password'
onChange={this.handleChange}
name='passwordConfirmation'
type='password'
fullWidth
value={this.state.passwordConfirmation}
onBlur={this.handleBlur}
errorText={this.state.errors.passwordConfirmation}
/>
<RaisedButton
label='Sign Up'
style={{ display: (this.state.isLoading ? 'none' : 'block') }}
type='submit'
primary
disabled={!isEmpty(this.state.errors)}
/>
<CircularProgress
style={{ display: (!this.state.isLoading ? 'none' : 'block'), margin: 'auto' }}
/>
{this.state.errors.message && <div className='error-box'>{this.state.errors.message}</div> }
</form>
);
}
}
SignUp.propTypes = {
userRegisterRequest: React.PropTypes.func.isRequired,
saveFormData: React.PropTypes.func.isRequired,
formData: React.PropTypes.object.isRequired,
clearFormData: React.PropTypes.func.isRequired,
isUserExists: React.PropTypes.func.isRequired,
successEvent: React.PropTypes.func
};
export default SignUp;
|
src/www/js/form-fields/drop-down.js | nickolusroy/react_dnd | import React from 'react';
export class DropDown extends React.Component {
constructor(props) {
super(props);
this.state = {
selection : '',
charData : this.props.charData
};
this.onChange = this.onChange.bind(this);
};
onChange(e) {
this.setState({
selection : e.target.value
});
this.props.onUpdate(e);
};
render() {
let concatClasses = this.props.className+" drop-down form-field"
function getChoiceLabel(choices) {
if (choices.label) {
return choices.label;
} else if (choices.name) {
return choices.name;
}
return "";
}
return <div className={concatClasses}>
<select name={this.props.name} value={this.state.selection} onChange={this.onChange}>
<option value="" defaultValue="selected">{this.props.label}</option>
{this.props.choices.map(choice => <option key={choice.name} data-index={choice.id} value={choice.name}>{getChoiceLabel(choice)}</option>)}
</select>
</div>
}
}
|
app/javascript/mastodon/components/button.js | anon5r/mastonon | 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/common/ui/Link/Link.stories.js | MadeInHaus/react-redux-webpack-starter | import React from 'react';
import { storiesOf } from '@storybook/react';
import { Link } from '@ui';
storiesOf('Global/Link', module)
.add('default', () => <Link href="http://www.google.com">Example</Link>)
.add('router (link)', () => <Link to="/someroute">Example</Link>)
.add('router (navlink)', () => (
<Link to="/someroute" activeClassName="active">
Example
</Link>
));
|
components/Header.js | ViniciusAtaide/edgartccfront | import React from 'react';
import { Nav, Navbar, NavItem, Button } from 'react-bootstrap';
import { Link } from 'react-router';
export default class Header {
static propTypes = {
onlyBrand: React.PropTypes.bool
};
render() {
let { onlyBrand } = this.props;
let center = {
margin: '0 auto',
float: 'none',
textAlign: 'center',
display: 'block'
};
return (
<Navbar eventKey={0} inverse brand={<Link style={onlyBrand ? center : {}} to="/">EdgarTcc</Link>}>
{!onlyBrand ?
<Nav>
<NavItem eventKey={1}><Link to="/alunos">Alunos</Link></NavItem>
<NavItem eventKey={2}><Link to="/professores">Professores</Link></NavItem>
<NavItem eventKey={3} onClick={ () => this.props.logout() }>Logout</NavItem>
</Nav>
:
<div></div>
}
</Navbar>
);
}
} |
node_modules/react-solr-connector/demo/demo.js | SerendpityZOEY/Fixr-RelevantCodeSearch | import React from 'react';
class SolrConnectorDemo extends React.Component {
constructor(props) {
super(props);
this.state = {
solrSearchUrl: "http://localhost:8983/solr/techproducts/select",
query: "memory",
filter: "",
fetchFields: ""
}
}
onSubmit(event) {
event.preventDefault();
let searchParams = {
solrSearchUrl: this.state.solrSearchUrl,
query: this.state.query,
filter: [this.state.filter],
fetchFields: this.state.fetchFields.split(" "),
offset: 0,
limit: 10,
facet: {
manufacturer: {
type: "terms",
field: "manu_id_s",
limit: 20
},
price_range_0_100: {
query: "price:[0 TO 100]"
}
},
highlightParams: {
"hl": "true",
"hl.fl": "name manu",
"hl.snippets": 1,
"hl.fragsize": 500
}
};
this.props.doSearch(searchParams);
}
render() {
return <div>
<form className="inputForm" onSubmit={this.onSubmit.bind(this)}>
<h4>searchParams:</h4>
<p>
solrSearchUrl: {" "}
<input type="text" value={this.state.solrSearchUrl}
onChange={e => {this.setState({ solrSearchUrl: e.target.value })}} />
</p>
<p>
query: {" "}
<input type="text" value={this.state.query}
onChange={e => {this.setState({ query: e.target.value })}} />
{" "}
filter: {" "}
<input type="text" value={this.state.filter}
onChange={e => {this.setState({ filter: e.target.value })}} />
</p>
<p>
fetchFields: {" "}
<input type="text" value={this.state.fetchFields}
onChange={e => {this.setState({ fetchFields: e.target.value })}} />
</p>
<p>
<button type="submit">Search</button>
</p>
</form>
<div className="jsonOutput">
<pre>
this.props.solrConnector: {"\n\n"}
{ JSON.stringify(this.props.solrConnector, null, 2) }
</pre>
</div>
</div>;
}
}
export default SolrConnectorDemo;
|
docs/wp-content/themes/Divi/includes/builder/frontend-builder/gutenberg/controller.js | laurybueno/laurybueno.github.io | import React from 'react';
import placeholder from 'gutenberg/blocks/placeholder';
import { isBuilderUsed, isScriptDebug, getVBUrl } from 'gutenberg/utils/helpers';
import { DIVI, GUTENBERG } from 'gutenberg/constants';
import { registerBlock, unregisterBlock } from 'gutenberg/blocks/registration';
import get from 'lodash/get';
import throttle from 'lodash/throttle';
import isEmpty from 'lodash/isEmpty';
import startsWith from 'lodash/startsWith';
import { __ } from '@wordpress/i18n';
import { applyFilters } from '@wordpress/hooks';
import { dispatch, select, subscribe } from '@wordpress/data';
import { cold } from 'react-hot-loader';
import { RichText } from '@wordpress/editor';
import { renderToString, RawHTML } from '@wordpress/element';
// react-hot-loader replaces the Component with ProxyComponent altering its type.
// Since Gutenberg compares types while serializing content, we need to disable
// hot reloading for RichText and RawHTML
cold(RichText.Content);
cold(RawHTML);
const { setupEditor, editPost } = dispatch('core/editor');
const { isCleanNewPost, getCurrentPost, getEditedPostAttribute, getEditedPostContent, getBlocks } = select('core/editor');
const { getEditorMode } = select('core/edit-post');
const { switchEditorMode } = dispatch('core/edit-post');
const registerPlaceholder = () => registerBlock(placeholder);
const unregisterPlaceholder = () => unregisterBlock(placeholder);
const hasPlaceholder = () => {
const blocks = getBlocks();
if (blocks.length !== 1) {
return false;
}
return get(blocks, '0.name') === placeholder.name;
};
// Throttle this just to avoid potential loops, better safe than sorry.
const switchToVisualMode = throttle(() => switchEditorMode('visual'), 100);
const button = renderToString((
<div className="et-buttons">
<button type="button" className="is-button is-default is-large components-button editor-post-switch-to-divi" data-editor={DIVI}>
{__('Use The Divi Builder')}
</button>
<button type="button" className="is-button is-default is-large components-button editor-post-switch-to-gutenberg" data-editor={GUTENBERG}>
{__('Return To Default Editor')}
</button>
</div>
));
class Controller {
init = () => {
registerPlaceholder();
this.gbContent = '';
this.unsubscribe = subscribe(this.onEditorContentChange);
subscribe(this.onEditorModeChange);
}
onClick = (e) => {
switch (e.target.getAttribute('data-editor')) {
case DIVI: {
this.addPlaceholder(getEditedPostContent());
break;
}
default: {
// Okay, this button was inside the placeholder but then was moved out of it.
// That logic is a massive PITA, no time to refactor so this will have to do for now.
jQuery('#et-switch-to-gutenberg').click();
}
}
}
addPlaceholder = (content = '') => {
registerPlaceholder();
this.gbContent = content;
this.setupEditor(applyFilters('divi.addPlaceholder', content));
}
getGBContent = () => this.gbContent;
setupEditor = (raw, title = false) => {
const post = getCurrentPost();
// Set post content
setupEditor({ ...post, content: { raw } });
if (title !== false && title !== post.title) {
// Set post title
editPost({ title });
}
}
switchEditor = (editor, content) => {
switch (editor) {
case DIVI: {
// Open VB
window.location.href = getVBUrl();
break;
}
default: {
const title = getEditedPostAttribute('title');
// Restore GB content and title (without saving)
this.setupEditor(content, title);
unregisterPlaceholder();
}
}
}
addButton = () => {
// Add the custom button
setTimeout(() => jQuery(button).on('click', 'button', this.onClick).insertAfter('.edit-post-header-toolbar'), 0);
}
onEditorContentChange = () => {
const post = getCurrentPost();
if (isEmpty(post) || !this.unsubscribe) {
// If we don't have a post, GB isn't ready yet
return;
}
this.addButton();
// We only need to do this step once
this.unsubscribe();
this.unsubscribe = false;
const content = get(post, 'content');
if (startsWith(content, `<!-- ${placeholder.tag} `)) {
// Post content already includes placeholder tag, nothing else to do
return;
}
if (isBuilderUsed() || isCleanNewPost()) {
// Add placeholder if post was edited with Divi
if (isScriptDebug()) {
// when SCRIPT_DEBUG is enabled, GB ends up calling `setupEditor` twice for whatever reason
// and this causes our placeholder to be replaced with default GB content.
// Until they fix their code, we need to ensure our own `setupEditor` is called last.
setTimeout(() => this.addPlaceholder(content), 0);
} else {
this.addPlaceholder(content);
}
} else {
// Unregister the placeholder block so it cannot be added via GB add block
unregisterPlaceholder();
}
}
onEditorModeChange = () => {
const mode = getEditorMode();
if (mode === 'text' && hasPlaceholder()) {
switchToVisualMode();
}
}
}
const controller = new Controller();
const getGBContent = controller.getGBContent;
const switchEditor = controller.switchEditor;
controller.init();
export {
getGBContent,
switchEditor,
};
|
src/views/Widget.js | iris-dni/iris-frontend | import 'assets/styles/base.scss';
import React from 'react';
import Helmet from 'react-helmet';
import settings from 'settings';
const TITLE_TEMPLATE = `%s | ${settings.title}`;
export default ({ children }) => (
<div className={'wrapper'}>
<Helmet titleTemplate={TITLE_TEMPLATE} />
<main aria-label='Content'>
{children}
</main>
</div>
);
|
src/components/TextField/TextField.js | macdja38/pvpsite | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './TextField.css';
class TextField extends Component { // eslint-disable-line react/prefer-stateless-function
static propTypes = {
text: PropTypes.string,
placeHolder: PropTypes.string,
callback: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = { text: props.text || '' };
props.callback(this.state.text);
this.onChange = this.onChange.bind(this);
}
onChange(event) {
this.setState({ text: event.target.value });
this.props.callback(event.target.value);
event.preventDefault();
}
render() {
return (
<input
className={s.input}
placeholder={this.props.placeHolder}
value={this.state.text || ''}
onChange={this.onChange}
/>
);
}
}
export default withStyles(s)(TextField);
|
public/js/components/admin/AdminForgotPwd.react.js | MadushikaPerera/Coupley | /**
* Created by Isuru 1 on 24/01/2016.
*/
import React from 'react';
import Avatar from 'material-ui/lib/avatar';
import Card from 'material-ui/lib/card/card';
import CardActions from 'material-ui/lib/card/card-actions';
import CardHeader from 'material-ui/lib/card/card-header';
import CardMedia from 'material-ui/lib/card/card-media';
import CardTitle from 'material-ui/lib/card/card-title';
import FlatButton from 'material-ui/lib/flat-button';
import CardText from 'material-ui/lib/card/card-text';
import TextField from 'material-ui/lib/text-field';
import RaisedButton from 'material-ui/lib/raised-button';
import LoginActions from '../../actions/admin/LoginActions';
import LoginStore from '../../stores/LoginStore';
const err = { color: 'red' };
var validEmail = /\S+@\S+\.\S+/;
const AdminForgot = React.createClass({
sendemail: function () {
let email = this.refs.email.getValue();
let resetemail = {
email: email,
};
LoginActions.resetpassword(resetemail);
if (email.trim() == '') {
document.getElementById('email').innerHTML = '*Email field is empty, Please enter the email!';
this.refs.email.focus();
return false;
} else {
if (!email.match(validEmail)) {
document.getElementById('email').innerHTML = '*Email is invalid, Please enter a correct email!';
this.refs.email.focus();
return false;
} else {
document.getElementById('email').innerHTML = '';
}
}
},
eleminateErrors:function () {
document.getElementById('email').innerHTML = ' ';
},
render: function () {
return (
<div>
<div className="container">
<div className="col-lg-6 col-lg-offset-3 text-center">
<Card style={ { marginTop: 60 } }>
<CardTitle title="Welcome Back.." subtitle="Coupley ™"/>
<CardActions>
<TextField onChange={this.eleminateErrors}
floatingLabelText="Enter your email" ref="email" />
<div style={err} id="email" onChange={this.sendemail}></div>
</CardActions>
<CardText>
<span id="server-error" style={err}> </span>
<br/>
<RaisedButton label="Ok" primary={true} onTouchTap={this.sendemail} />
<a href="/cp-admin#/AdminLogin"> Back to Login </a>
</CardText>
</Card>
</div>
</div>
</div>
);
},
});
export default AdminForgot;
|
code/workspaces/web-app/src/components/stacks/NewStackButton.js | NERC-CEH/datalab | import React from 'react';
import PropTypes from 'prop-types';
import PagePrimaryAction from '../common/buttons/PagePrimaryActionButton';
const NewStackButton = ({ onClick, typeName, labelPrefix = 'Create' }) => (
<PagePrimaryAction aria-label="add" onClick={onClick}>
{`${labelPrefix} ${typeName}`}
</PagePrimaryAction>
);
NewStackButton.propTypes = {
onClick: PropTypes.func.isRequired,
typeName: PropTypes.string.isRequired,
};
export default NewStackButton;
|
src/svg-icons/places/kitchen.js | hai-cea/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let PlacesKitchen = (props) => (
<SvgIcon {...props}>
<path d="M18 2.01L6 2c-1.1 0-2 .89-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.11-.9-1.99-2-1.99zM18 20H6v-9.02h12V20zm0-11H6V4h12v5zM8 5h2v3H8zm0 7h2v5H8z"/>
</SvgIcon>
);
PlacesKitchen = pure(PlacesKitchen);
PlacesKitchen.displayName = 'PlacesKitchen';
PlacesKitchen.muiName = 'SvgIcon';
export default PlacesKitchen;
|
examples/real-world/index.js | PatrickEifler/redux | import 'babel-core/polyfill';
import React from 'react';
import Root from './containers/Root';
import BrowserHistory from 'react-router/lib/BrowserHistory';
React.render(
<Root history={new BrowserHistory()} />,
document.getElementById('root')
);
|
techCurriculum/ui/solutions/5.2/src/App.js | AnxChow/EngineeringEssentials-group | /**
* Copyright 2017 Goldman Sachs.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
import React from 'react';
import Title from './components/Title';
import Card from './components/Card';
import CardForm from './components/CardForm';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
cards: [
{
author: 'John Smith',
text: 'React is so cool!'
},
{
author: 'Jane Doe',
text: 'I use React for all my projects!'
}
]
};
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(author, message) {
const newCard = {author: author, text: message};
const cards = [...this.state.cards, newCard];
this.setState({cards: cards});
}
render() {
const cards = this.state.cards.map((card, index) => (
<Card author={card.author}
text={card.text}
key={index} />
));
return (
<div id='app-body'>
<div id='left-panel'>
<Title />
{ cards }
</div>
<CardForm onSubmit={this.handleSubmit} />
</div>
);
}
}
export default App;
|
client/modules/core/components/.stories/navigation.js | LikeJasper/mantra-plus | import React from 'react';
import { storiesOf } from '@kadira/storybook';
import Context from '../../../../../.storybook/Context';
import Navigation from '../navigation';
storiesOf('core.Navigation', module)
.add('default view', () => (
<Context>
<Navigation />
</Context>
));
|
docs/src/examples/collections/Form/Variations/FormExampleSize.js | Semantic-Org/Semantic-UI-React | import React from 'react'
import { Button, Divider, Form } from 'semantic-ui-react'
const sizes = ['mini', 'tiny', 'small', 'large', 'big', 'huge', 'massive']
const FormExampleSize = () => (
<div>
{sizes.map((size) => (
<Form size={size} key={size}>
<Form.Group widths='equal'>
<Form.Field
label='First name'
control='input'
placeholder='First name'
/>
<Form.Field
label='Last name'
control='input'
placeholder='Last name'
/>
</Form.Group>
<Button type='submit'>Submit</Button>
<Divider hidden />
</Form>
))}
</div>
)
export default FormExampleSize
|
src/packages/@ncigdc/components/Aggregations/FacetResetButton.js | NCI-GDC/portal-ui | // @flow
import React from 'react';
import Link from '@ncigdc/components/Links/Link';
import Undo from '@ncigdc/theme/icons/Undo';
import styled from '@ncigdc/theme/styled';
import withRouter from '@ncigdc/utils/withRouter';
import {
removeFilter,
fieldInCurrentFilters,
} from '@ncigdc/utils/filters/index';
const ShadowedUndoIcon = styled(Undo, {
':hover::before': {
textShadow: ({ theme }) => theme.textShadow,
},
});
const StyledLink = styled(Link, {
':link': {
color: ({ theme }) => theme.greyScale3,
},
':visited': {
color: ({ theme }) => theme.greyScale3,
},
});
const FacetResetButton = ({
field,
currentFilters,
query,
style,
...props
}) => {
const newFilters = removeFilter(field, currentFilters);
const newQuery = {
...query,
offset: 0,
filters: newFilters,
};
const inCurrent = fieldInCurrentFilters({
currentFilters: currentFilters.content || [],
field,
});
return (
inCurrent && (
<StyledLink
className="test-facet-reset-button"
style={{ display: inCurrent ? 'inline' : 'none', ...style }}
query={newQuery}
aria-label="reset"
>
<ShadowedUndoIcon />
</StyledLink>
)
);
};
export default withRouter(FacetResetButton);
|
src/svg-icons/action/account-balance-wallet.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionAccountBalanceWallet = (props) => (
<SvgIcon {...props}>
<path d="M21 18v1c0 1.1-.9 2-2 2H5c-1.11 0-2-.9-2-2V5c0-1.1.89-2 2-2h14c1.1 0 2 .9 2 2v1h-9c-1.11 0-2 .9-2 2v8c0 1.1.89 2 2 2h9zm-9-2h10V8H12v8zm4-2.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"/>
</SvgIcon>
);
ActionAccountBalanceWallet = pure(ActionAccountBalanceWallet);
ActionAccountBalanceWallet.displayName = 'ActionAccountBalanceWallet';
ActionAccountBalanceWallet.muiName = 'SvgIcon';
export default ActionAccountBalanceWallet;
|
client/modules/core/routes.js | gotrecillo/daw-euskalvideo | import React from 'react';
import {mount} from 'react-mounter';
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();
import MainLayout from './components/main_layout';
import HomeLayout from './components/home_layout';
import Login from '../users/containers/login';
import Post from './containers/post';
import NewPost from './containers/newpost';
import NominationsList from '../videos/containers/nominations_list';
import VideoSearcher from '../videos/containers/video_searcher';
import Dashboard from '../dashboard/containers/dashboard';
import Home from '../home/containers/home';
import Profile from '../users/containers/profile';
import Chat from '../chat/containers/chat';
export default function (injectDeps, {FlowRouter, Meteor}) {
const MainLayoutCtx = injectDeps(MainLayout);
const HomeLayoutCtx = injectDeps(HomeLayout);
FlowRouter.route('/', {
name: 'home',
action() {
mount(HomeLayoutCtx, {
content: () => (<Home />)
});
}
});
FlowRouter.route('/login', {
name: 'users.login',
triggersEnter: [ function (context, redirect) {
if (Meteor.userId()) {
redirect('/app');
}
} ],
action() {
mount(MainLayoutCtx, {
content: () => (<Login />)
});
}
});
const appRoutes = FlowRouter.group({
prefix: '/app',
name: 'app',
triggersEnter: [ function (context, redirect) {
if (!Meteor.userId()) {
redirect('/login');
}
} ],
});
appRoutes.route('/', {
name: 'app',
action() {
mount(MainLayoutCtx, {
content: () => (<Dashboard />)
});
}
});
appRoutes.route('/nominations', {
name: 'nominations',
action() {
mount(MainLayoutCtx, {
content: () => (<NominationsList />)
});
}
});
appRoutes.route('/nominate', {
name: 'nominate',
action() {
mount(MainLayoutCtx, {
content: () => (<VideoSearcher />)
});
}
});
appRoutes.route('/profile', {
name: 'profile',
action() {
mount(MainLayoutCtx, {
content: () => (<Profile />)
});
}
});
appRoutes.route('/chat', {
name: 'chat',
action() {
mount(MainLayoutCtx, {
content: () => (<Chat />)
});
}
});
FlowRouter.route('/post/:postId', {
name: 'posts.single',
action({postId}) {
mount(MainLayoutCtx, {
content: () => (<Post postId={postId}/>)
});
}
});
FlowRouter.route('/new-post', {
name: 'newpost',
action() {
mount(MainLayoutCtx, {
content: () => (<NewPost/>)
});
}
});
}
|
test/integration/css-fixtures/single-global/pages/_app.js | JeromeFitz/next.js | import React from 'react'
import App from 'next/app'
import '../styles/global.css'
class MyApp extends App {
render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
export default MyApp
|
elcri.men/src/components/Footer.js | diegovalle/new.crimenmexico | import React from 'react';
import {
FaTwitterSquare,
FaFacebookSquare,
FaGithubSquare,
FaEnvelope,
} from 'react-icons/fa';
import {IconContext} from 'react-icons';
import Obfuscate2 from '../components/Obfuscate';
import {useIntl, FormattedHTMLMessage} from 'react-intl';
function Footer (props) {
const intl = useIntl ();
return (
<IconContext.Provider value={{color: '#333', size: '3em'}}>
<footer
className="footer has-background-white-ter"
style={{marginTop: '5rem'}}
>
<hr />
<div className="container">
<div className="columns">
<div className="column is-4 has-text-centered is-hidden-tablet">
{intl.formatMessage ({id: 'author'})}:
{' '}
<a
className="title is-4 is-size-5"
href="https://www.diegovalle.net/"
>
{intl.formatMessage ({id: 'name'})}
</a>
<hr />
<p>
<FormattedHTMLMessage id='Please visit' />
</p>
</div>
<div className="column is-4">
<div className="level">
<a
className="level-item"
aria-label="Twitter"
href="https://twitter.com/diegovalle"
>
<span className="icon icon is-large"><FaTwitterSquare /></span>
<span className="is-hidden">Twitter</span>
</a>
<a
className="level-item"
aria-label="Facebook"
href="https://facebook.com/diegovalle"
>
{' '}
<span className="icon icon is-large"><FaFacebookSquare /></span>
<span className="is-hidden">Facebook</span>
</a>
</div>
</div>
<div className="column is-4 has-text-centered is-hidden-mobile">
{intl.formatMessage ({id: 'author'})}:
{' '}
<a
className="title is-5 is-size-5"
href="https://www.diegovalle.net/"
>
{intl.formatMessage ({id: 'name'})}
</a>
<hr />
<p>
<FormattedHTMLMessage id='Please visit' />
</p>
</div>
<div className="column is-4 has-text-right">
<div className="level">
<a
className="level-item"
aria-label="GitHub"
href="https://github.com/diegovalle"
>
<span className="icon icon is-large"><FaGithubSquare /></span>
<span className="is-hidden">GitHub</span>
</a>
<Obfuscate2
className="level-item"
aria-label="Mail"
email="ZGllZ29AZGllZ292YWxsZS5uZXQK"
>
<span className="icon icon is-large"><FaEnvelope /></span>
<span className="is-hidden">Mail</span>
</Obfuscate2>
</div>
</div>
</div>
<p className="subtitle has-text-centered is-6">
{intl.formatMessage ({id: '© All rights reserved'})}
</p>
</div>
</footer>
</IconContext.Provider>
);
}
export default Footer;
|
packages/material-ui-icons/src/Adjust.js | AndriusBil/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let Adjust = props =>
<SvgIcon {...props}>
<path d="M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10 10-4.49 10-10S17.51 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3-8c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3z" />
</SvgIcon>;
Adjust = pure(Adjust);
Adjust.muiName = 'SvgIcon';
export default Adjust;
|
examples/_dustbin-interesting/index.js | RallySoftware/react-dnd | 'use strict';
import React from 'react';
import Container from './Container';
const DustbinSorted = React.createClass({
render() {
return (
<div>
<Container />
<hr />
<p>
Several different dustbins can handle several types of items. Note that the last dustbin is special: it can handle files from your hard drive and URLs.
</p>
</div>
);
}
});
export default DustbinSorted; |
src/parser/hunter/beastmastery/modules/spells/azeritetraits/DanceOfDeath.js | sMteX/WoWAnalyzer | import React from 'react';
import Analyzer from 'parser/core/Analyzer';
import { formatNumber, formatPercentage } from 'common/format';
import { calculateAzeriteEffects } from 'common/stats';
import TraitStatisticBox, { STATISTIC_ORDER } from 'interface/others/TraitStatisticBox';
import SPELLS from 'common/SPELLS/index';
import StatTracker from 'parser/shared/modules/StatTracker';
const danceOfDeathStats = traits => Object.values(traits).reduce((obj, rank) => {
const [agility] = calculateAzeriteEffects(SPELLS.DANCE_OF_DEATH.id, rank);
obj.agility += agility;
obj.agility *= 1.2; //Hotfix from 26th September
return obj;
}, {
agility: 0,
});
/**
* Barbed Shot has a chance equal to your critical strike chance to grant you 314 agility for 8 sec.
*
* Example report: https://www.warcraftlogs.com/reports/Nt9KGvDncPmVyjpd#boss=-2&difficulty=0&type=summary&source=9
*/
class DanceOfDeath extends Analyzer {
static dependencies = {
statTracker: StatTracker,
};
agility = 0;
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTrait(SPELLS.DANCE_OF_DEATH.id);
if (!this.active) {
return;
}
const { agility } = danceOfDeathStats(this.selectedCombatant.traitsBySpellId[SPELLS.DANCE_OF_DEATH.id]);
this.agility = agility;
this.statTracker.add(SPELLS.DANCE_OF_DEATH_BUFF.id, {
agility,
});
}
get uptime() {
return this.selectedCombatant.getBuffUptime(SPELLS.DANCE_OF_DEATH_BUFF.id) / this.owner.fightDuration;
}
get avgAgility() {
return this.uptime * this.agility;
}
statistic() {
return (
<TraitStatisticBox
position={STATISTIC_ORDER.OPTIONAL()}
trait={SPELLS.DANCE_OF_DEATH.id}
value={(
<>
{formatNumber(this.avgAgility)} Average Agility <br />
{formatPercentage(this.uptime)}% Uptime
</>
)}
tooltip={<>Dance of Death granted <strong>{this.agility}</strong> Agility for <strong>{formatPercentage(this.uptime)}%</strong> of the fight.</>}
/>
);
}
}
export default DanceOfDeath;
|
platform/ui/src/components/checkbox/checkbox.js | OHIF/Viewers | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import './checkbox.css';
export class Checkbox extends Component {
static propTypes = {
label: PropTypes.string.isRequired,
checked: PropTypes.bool,
onChange: PropTypes.func,
};
constructor(props) {
super(props);
this.state = { checked: !!props.checked, label: props.label };
}
handleChange(e) {
const checked = e.target.checked;
this.setState({ checked });
if (this.props.onChange) this.props.onChange(checked);
}
componentDidUpdate(props) {
const { checked = false, label } = props;
if (this.state.checked !== checked || this.state.label !== label) {
this.setState({
checked,
label,
});
}
}
render() {
let checkbox;
if (this.state.checked) {
checkbox = <span className="ohif-checkbox ohif-checked" />;
} else {
checkbox = <span className="ohif-checkbox" />;
}
return (
<div className="ohif-check-container">
<form>
<label className="ohif-check-label">
<input
type="checkbox"
checked={this.state.checked}
onChange={this.handleChange.bind(this)}
/>
{checkbox}
{this.state.label}
</label>
</form>
</div>
);
}
}
|
src/routes/codes/values/List.js | yunqiangwu/kmadmin | import React from 'react'
import PropTypes from 'prop-types'
import { Table, Modal } from 'antd'
import classnames from 'classnames'
import { DropOption } from 'components'
import { Link } from 'dva/router'
import AnimTableBody from '../../../components/DataTable/AnimTableBody'
import styles from './List.less'
const confirm = Modal.confirm
const List = ({ onDeleteItem, onEditItem, isMotion, location, ...tableProps }) => {
const handleMenuClick = (record, e) => {
if (e.key === '1') {
onEditItem(record)
} else if (e.key === '2') {
confirm({
title: 'Are you sure delete this record?',
onOk () {
onDeleteItem(record.lookupId)
},
})
}
}
const columns = [
{
title: '值',
dataIndex: 'lookupCode',
key: 'lookupCode',
},
{
title: '含义',
dataIndex: 'lookupValue',
key: 'lookupValue',
},
{
title: '排序号',
dataIndex: 'displayOrder',
key: 'displayOrder',
},
{
title: '语言',
dataIndex: 'language',
key: 'language',
},
{
title: '是否启用',
dataIndex: 'enabled',
key: 'enabled',
render (text, record, index) {
return record.enabled ? '是' : '否'
},
},
{
title: '描述',
dataIndex: 'description',
key: 'description',
},
{
title: '操作',
key: 'operation',
render: (text, record) => {
return <DropOption onMenuClick={e => handleMenuClick(record, e)} menuOptions={[{ key: '1', name: '编辑' }, { key: '2', name: '删除' }]} />
},
},
]
const getBodyWrapperProps = {
page: location.query.page,
current: tableProps.pagination.current,
}
const getBodyWrapper = (body) => { return isMotion ? <AnimTableBody {...getBodyWrapperProps} body={body} /> : body }
return (
<div>
<Table
{...tableProps}
className={classnames({ [styles.table]: true, [styles.motion]: isMotion })}
bordered
scroll={{ x: 1024 }}
onRowDoubleClick={(item) => { onEditItem(item) }}
columns={columns}
pagination={false}
simple
rowKey={record => record.lookupId}
getBodyWrapper={getBodyWrapper}
/>
</div>
)
}
List.propTypes = {
onDeleteItem: PropTypes.func,
onEditItem: PropTypes.func,
isMotion: PropTypes.bool,
location: PropTypes.object,
}
export default List
|
app/javascript/mastodon/features/ui/components/alert_bar.js | increments/mastodon | import React from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
export default class AlertBar extends React.Component {
static propTypes = {
isEmailConfirmed: PropTypes.bool.isRequired,
};
render () {
const { isEmailConfirmed } = this.props;
return (
<div className='alert-bar'>
{
(!isEmailConfirmed &&
<div className='alert'>
<i className='fa fa-fw fa-exclamation-triangle' /><FormattedMessage id='alert_bar.email_confirm_alert' defaultMessage='Your email address is not confirmed. Please confirm the sent email.' />
</div>
)
}
</div>
);
}
}
|
node_modules/browser-sync/node_modules/bs-recipes/recipes/webpack.react-transform-hmr/app/js/main.js | aakb/os2web | import React from 'react';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
React.render(<HelloWorld />, document.getElementById('react-root'));
|
src/client.js | ptim/react-redux-universal-hot-example | /**
* THIS IS THE ENTRY POINT FOR THE CLIENT, JUST LIKE server.js IS THE ENTRY POINT FOR THE SERVER.
*/
import 'babel/polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import createHistory from 'history/lib/createBrowserHistory';
import useScroll from 'scroll-behavior/lib/useStandardScroll';
import createStore from './redux/create';
import ApiClient from './helpers/ApiClient';
import io from 'socket.io-client';
import {Provider} from 'react-redux';
import {reduxReactRouter, ReduxRouter} from 'redux-router';
import getRoutes from './routes';
import makeRouteHooksSafe from './helpers/makeRouteHooksSafe';
const client = new ApiClient();
// Three different types of scroll behavior available.
// Documented here: https://github.com/rackt/scroll-behavior
const scrollableHistory = useScroll(createHistory);
const dest = document.getElementById('content');
const store = createStore(reduxReactRouter, makeRouteHooksSafe(getRoutes), scrollableHistory, client, window.__data);
function initSocket() {
const socket = io('', {path: '/api/ws', transports: ['polling']});
socket.on('news', (data) => {
console.log(data);
socket.emit('my other event', { my: 'data from client' });
});
socket.on('msg', (data) => {
console.log(data);
});
return socket;
}
global.socket = initSocket();
const component = (
<ReduxRouter routes={getRoutes(store)} />
);
ReactDOM.render(
<Provider store={store} key="provider">
{component}
</Provider>,
dest
);
if (process.env.NODE_ENV !== 'production') {
window.React = React; // enable debugger
if (!dest || !dest.firstChild || !dest.firstChild.attributes || !dest.firstChild.attributes['data-react-checksum']) {
console.error('Server-side React render was discarded. Make sure that your initial render does not contain any client-side code.');
}
}
if (__DEVTOOLS__ && !window.devToolsExtension) {
const DevTools = require('./containers/DevTools/DevTools');
ReactDOM.render(
<Provider store={store} key="provider">
<div>
{component}
<DevTools />
</div>
</Provider>,
dest
);
}
|
client/src/components/Draftail/decorators/Document.js | torchbox/wagtail | import PropTypes from 'prop-types';
import React from 'react';
import { gettext } from '../../../utils/gettext';
import Icon from '../../Icon/Icon';
import TooltipEntity from '../decorators/TooltipEntity';
const documentIcon = <Icon name="doc-full" />;
const missingDocumentIcon = <Icon name="warning" />;
const Document = (props) => {
const { entityKey, contentState } = props;
const data = contentState.getEntity(entityKey).getData();
const url = data.url || null;
let icon;
let label;
if (!url) {
icon = missingDocumentIcon;
label = gettext('Missing document');
} else {
icon = documentIcon;
label = data.filename || '';
}
return <TooltipEntity {...props} icon={icon} label={label} url={url} />;
};
Document.propTypes = {
entityKey: PropTypes.string.isRequired,
contentState: PropTypes.object.isRequired,
};
export default Document;
|
src/routes.js | annamaz/interview-app-scroll | import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './components/App';
import HomePage from './components/pages/HomePage';
import NotFoundPage from './components/pages/NotFoundPage';
import ScrollPage from './components/pages/ScrollPage';
export default (
<Route path="/" component={App}>
<IndexRoute component={HomePage}/>
<Route path="scroll" component={ScrollPage}/>
<Route path="*" component={NotFoundPage}/>
</Route>
);
|
src/parser/deathknight/unholy/modules/features/Apocalypse.js | fyruna/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import SpellLink from 'common/SpellLink';
import Analyzer from 'parser/core/Analyzer';
import EnemyInstances from 'parser/shared/modules/EnemyInstances';
import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';
class Apocalypse extends Analyzer {
static dependencies = {
enemies: EnemyInstances,
};
totalApocalypseCasts = 0;
apocalypseWoundsPopped = 0;
//Logic that both counts the amount of Apocalypse cast by the player, as well as the amount of wounds popped by those apocalypse.
on_byPlayer_cast(event){
const spellId = event.ability.guid;
if(spellId === SPELLS.APOCALYPSE.id){
this.totalApocalypseCasts+=1;
const target = this.enemies.getEntity(event);
const currentTargetWounds = target && target.hasBuff(SPELLS.FESTERING_WOUND.id) ? target.getBuff(SPELLS.FESTERING_WOUND.id).stacks: 0;
if(currentTargetWounds > 4){
this.apocalypseWoundsPopped=this.apocalypseWoundsPopped + 4;
} else {
this.apocalypseWoundsPopped=this.apocalypseWoundsPopped + currentTargetWounds;
}
}
}
suggestions(when) {
const averageWoundsPopped = (this.apocalypseWoundsPopped/this.totalApocalypseCasts).toFixed(1);
//Getting 6 wounds on every Apocalypse isn't difficult and should be expected
when(averageWoundsPopped).isLessThan(4)
.addSuggestion((suggest, actual, recommended) => {
return suggest(<span>You are casting <SpellLink id={SPELLS.APOCALYPSE.id} /> with too few <SpellLink id={SPELLS.FESTERING_WOUND.id} /> on the target. When casting <SpellLink id={SPELLS.APOCALYPSE.id} />, make sure to have at least 4 <SpellLink id={SPELLS.FESTERING_WOUND.id} /> on the target.</span>)
.icon(SPELLS.APOCALYPSE.icon)
.actual(`An average ${(actual)} of Festering Wounds were popped by Apocalypse`)
.recommended(`${(recommended)} is recommended`)
.regular(recommended - 1).major(recommended - 2);
});
}
statistic() {
const averageWoundsPopped = (this.apocalypseWoundsPopped/this.totalApocalypseCasts).toFixed(1);
return (
<StatisticBox
icon={<SpellIcon id={SPELLS.APOCALYPSE.id} />}
value={`${averageWoundsPopped}`}
label="Average Wounds Popped with Apocalypse"
tooltip={`You popped ${this.apocalypseWoundsPopped} wounds with ${this.totalApocalypseCasts} casts of Apocalypse.`}
/>
);
}
statisticOrder = STATISTIC_ORDER.CORE(6);
}
export default Apocalypse;
|
src/components/SettingsComponent.js | C3-TKO/gaiyo | 'use strict';
import React from 'react';
import FloatingActionButton from 'material-ui/FloatingActionButton';
import ActionSettings from 'material-ui/svg-icons/action/settings';
import FlatButton from 'material-ui/FlatButton';
import Dialog from 'material-ui/Dialog';
import SlideListEditor from './SlideListEditorComponent';
import Snackbar from 'material-ui/Snackbar';
import { defineMessages, injectIntl } from 'react-intl';
require('styles//Settings.scss');
const messages = defineMessages({
close: {
id: 'settings.close',
defaultMessage: 'Close'
},
title: {
id: 'settings.title',
defaultMessage: 'Settings'
},
snackbar: {
id: 'settings.snackbar',
defaultMessage: 'Please add at least one screen to the rotation list!'
}
});
class SettingsComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
dialogOpen: false,
snackbarOpen: false,
timeout: undefined
};
}
componentDidMount() {
const timeToWaitForDBRead = 750;
if(this.props.slides.length === 0) {
const timeout = setTimeout(
() => {
this.setState({
dialogOpen: true,
timeout: undefined
})
}
, timeToWaitForDBRead );
this.setState({timeout: timeout})
}
}
componentWillReceiveProps(nextProps) {
if(nextProps.slides.length > 0) {
clearTimeout(this.state.timeout);
}
}
openDialog = () => {
this.setState({
dialogOpen: true
})
this.props.onMouseLeave();
}
closeDialog = () => {
if(this.props.slides.length !== 0) {
this.setState({
dialogOpen: false
})
}
else {
this.openSnackbar();
}
}
openSnackbar = () => {
this.setState({
snackbarOpen: true
})
}
closeSnackbar = () => {
this.setState({
snackbarOpen: false
})
}
render() {
const {formatMessage} = this.props.intl;
const actions = [
<FlatButton
label={formatMessage(messages.close)}
primary={true}
onTouchTap={this.closeDialog}
/>
];
return (
<div className='settings-component'>
<FloatingActionButton
secondary={true}
mini={true}
onTouchTap={this.openDialog}
onMouseEnter={this.props.onMouseEnter}
onMouseLeave={this.props.onMouseLeave}
>
<ActionSettings />
</FloatingActionButton>
<Dialog
title={formatMessage(messages.title)}
actions={actions}
modal={this.props.slides.length === 0}
open={this.state.dialogOpen}
onRequestClose={this.closeDialog}
autoScrollBodyContent={true}
>
<SlideListEditor />
</Dialog>
<Snackbar
open={this.state.snackbarOpen}
message={formatMessage(messages.snackbar)}
autoHideDuration={6000}
onRequestClose={this.closeSnackbar}
/>
</div>
);
}
}
SettingsComponent.displayName = 'SettingsComponent';
SettingsComponent.propTypes = {
slides: React.PropTypes.array.isRequired,
onMouseEnter: React.PropTypes.func.isRequired,
onMouseLeave: React.PropTypes.func.isRequired
};
export default injectIntl(SettingsComponent);
|
src/interface/statistics/components/BoringSpellValue/index.js | ronaldpereira/WoWAnalyzer | /**
* A simple component that shows the spell icon left and a value right.
* Use this only for things that the player certainly should be familiar with, such as their own spells.
* Do NOT use for items or azerite powers.
*/
import React from 'react';
import PropTypes from 'prop-types';
import SpellIcon from 'common/SpellIcon';
import '../BoringValue.scss';
const BoringSpellValue = ({ spell, value, label, extra, className }) => (
<div className={`flex boring-value ${className || ''}`}>
<div className="flex-sub icon">
<SpellIcon id={spell.id} />
</div>
<div className="flex-main value">
<div>{value}</div>
<small>{label}</small>
{extra}
</div>
</div>
);
BoringSpellValue.propTypes = {
spell: PropTypes.shape({
id: PropTypes.number.isRequired,
}).isRequired,
value: PropTypes.node.isRequired,
label: PropTypes.node.isRequired,
extra: PropTypes.node,
className: PropTypes.string,
};
export default BoringSpellValue;
|
client/containers/EditLocation/EditLocation.js | joshjg/explore | import React from 'react';
import { connect } from 'react-redux';
import Paper from 'material-ui/Paper';
import Subheader from 'material-ui/Subheader';
import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
import S3Uploader from 'react-s3-uploader';
import LinearProgress from 'material-ui/LinearProgress';
import ChipInput from 'material-ui-chip-input';
import NoLogo from '../../components/NoLogo';
import LocationPicker from '../../components/LocationPicker';
import { FETCH_LOCATION_REQUEST } from '../Location/constants';
import { categories } from '../../constants';
import {
setLocationField,
addCategory,
deleteCategory,
putLocation,
} from './actions';
import styles from './EditLocation.css';
const fieldStyle = { display: 'block' };
/**
* NOTE: WILL BE REPLACED WITH A DIALOG COMPONENT WITHIN Location
*/
class EditLocation extends React.Component {
static propTypes = {
params: React.PropTypes.shape({
id: React.PropTypes.string,
}),
name: React.PropTypes.string,
description: React.PropTypes.string,
categories: React.PropTypes.arrayOf(React.PropTypes.string),
logo: React.PropTypes.string,
lat: React.PropTypes.number,
lng: React.PropTypes.number,
street: React.PropTypes.string,
city: React.PropTypes.string,
zip: React.PropTypes.string,
email: React.PropTypes.string,
website: React.PropTypes.string,
contactName: React.PropTypes.string,
phone: React.PropTypes.string,
uploadProgress: React.PropTypes.number,
uploadError: React.PropTypes.bool,
locationPickerOpen: React.PropTypes.bool,
missingField: React.PropTypes.bool,
serverError: React.PropTypes.string,
requestLocation: React.PropTypes.func,
handleChange: React.PropTypes.func,
handleAddCategory: React.PropTypes.func,
handleDeleteCategory: React.PropTypes.func,
handleSubmit: React.PropTypes.func,
};
constructor(props) {
super(props);
props.requestLocation(props.params.id);
}
render = () => (
<Paper className={styles.root}>
<div className={styles.col}>
<Subheader>Location info</Subheader>
<TextField
value={this.props.name || ''}
onChange={e => this.props.handleChange('name', e.target.value)}
floatingLabelText="Location name"
style={fieldStyle}
errorText={(this.props.missingField && !this.props.name) ? 'This field is required' : null}
/>
<TextField
value={this.props.description || ''}
onChange={e => this.props.handleChange('description', e.target.value)}
floatingLabelText="Description"
style={fieldStyle}
multiLine
rows={2}
rowsMax={4}
/>
<ChipInput
value={this.props.categories}
onRequestAdd={chip => this.props.handleAddCategory(chip, this.props.categories)}
onRequestDelete={this.props.handleDeleteCategory}
dataSource={categories}
openOnFocus
listStyle={{ maxHeight: '210px', overflow: 'scroll' }}
floatingLabelText="Categories (one or more required)"
errorText={(this.props.missingField && !this.props.categories.length) ? 'This field is required' : null}
/>
<TextField
value={this.props.street || ''}
onChange={e => this.props.handleChange('street', e.target.value)}
floatingLabelText="Street address"
style={fieldStyle}
/>
<TextField
value={this.props.city || ''}
onChange={e => this.props.handleChange('city', e.target.value)}
floatingLabelText="City"
style={fieldStyle}
/>
<TextField
value={this.props.zip || ''}
onChange={e => this.props.handleChange('zip', e.target.value)}
floatingLabelText="Zip code"
style={fieldStyle}
/>
<div style={{ marginTop: '20px' }}>
{this.props.logo
? <img src={this.props.logo} alt="logo" className={styles.logoThumb} />
: <NoLogo />
}
<RaisedButton
containerElement="label"
secondary
label={this.props.logo ? 'Upload new logo' : 'Upload a logo'}
>
<S3Uploader
signingUrl="/api/s3/sign"
accept="image/*"
onProgress={(val) => {
this.props.handleChange('uploadError', false);
return this.props.handleChange('uploadProgress', val);
}}
onError={() => this.props.handleChange('uploadError', true)}
onFinish={data => this.props.handleChange('logo', `/api${data.publicUrl}`)}
uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
className={styles.fileUpload}
/>
</RaisedButton>
</div>
{this.props.uploadProgress < 100
? <LinearProgress mode="determinate" value={this.props.uploadProgress} />
: null
}
{this.props.uploadError
? <small className={styles.errorText}>
Error uploading your image. Please try again.
</small>
: null
}
</div>
<div className={styles.col}>
<Subheader>Contact info</Subheader>
<TextField
value={this.props.email || ''}
onChange={e => this.props.handleChange('email', e.target.value)}
floatingLabelText="Email Address"
style={fieldStyle}
/>
<TextField
value={this.props.website || ''}
onChange={e => this.props.handleChange('website', e.target.value)}
floatingLabelText="Website URL"
style={fieldStyle}
/>
<TextField
value={this.props.contactName || ''}
onChange={e => this.props.handleChange('contactName', e.target.value)}
floatingLabelText="Contact's full name"
style={fieldStyle}
/>
<TextField
value={this.props.phone || ''}
onChange={e => this.props.handleChange('phone', e.target.value)}
floatingLabelText="Phone number"
style={fieldStyle}
/>
</div>
<div className={styles.button}>
<RaisedButton
label="Submit"
onTouchTap={() => (
(!this.props.name || !this.props.categories)
? this.props.handleChange('missingField', true)
: this.props.handleChange('locationPickerOpen', true)
)}
primary
style={{ float: 'right' }}
/>
</div>
<LocationPicker
open={this.props.locationPickerOpen}
lat={this.props.lat}
lng={this.props.lng}
firstCategory={this.props.categories[0]}
onClickMap={(lat, lng) => {
this.props.handleChange('lat', lat);
this.props.handleChange('lng', lng);
}}
onClickBack={() => this.props.handleChange('locationPickerOpen', false)}
onClickSubmit={() => this.props.handleSubmit(this.props)}
errorText={this.props.serverError}
/>
</Paper>
);
}
const mapStateToProps = state => ({
name: state.editLocation.name,
description: state.editLocation.description,
categories: state.editLocation.categories,
logo: state.editLocation.logo,
lat: state.editLocation.lat,
lng: state.editLocation.lng,
street: state.editLocation.street,
city: state.editLocation.city,
zip: state.editLocation.zip,
email: state.editLocation.email,
website: state.editLocation.website,
contactName: state.editLocation.contactName,
phone: state.editLocation.phone,
uploadProgress: state.editLocation.uploadProgress,
uploadError: state.editLocation.uploadError,
locationPickerOpen: state.editLocation.locationPickerOpen,
missingField: state.editLocation.missingField,
serverError: state.editLocation.serverError,
});
const mapDispatchToProps = dispatch => ({
requestLocation: id => dispatch({ type: FETCH_LOCATION_REQUEST, id }),
handleChange: (field, value) => dispatch(setLocationField(field, value)),
handleAddCategory: (value, currentCategories) => {
if (categories.indexOf(value) !== -1 && currentCategories.indexOf(value) === -1) {
dispatch(addCategory(value));
}
},
handleDeleteCategory: value => dispatch(deleteCategory(value)),
handleSubmit: props => dispatch(putLocation(props)),
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(EditLocation);
|
html.js | danheadforcode/fg-gatsby | import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import { prefixLink } from 'gatsby-helpers'
import { TypographyStyle } from 'react-typography'
import typography from './utils/typography'
const BUILD_TIME = new Date().getTime()
export default class HTML extends React.Component {
propTypes = {
body: React.PropTypes.string
}
render() {
const { body } = this.props
const head = Helmet.rewind()
let css
if (process.env.NODE_ENV === 'production') {
css = (
<style
dangerouslySetInnerHTML={{
__html: require('!raw!./public/styles.css'),
}}
/>
)
}
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
{head.title.toComponent()}
{head.meta.toComponent()}
<TypographyStyle typography={typography} />
{css}
</head>
<body>
<div
id="react-mount"
dangerouslySetInnerHTML={{ __html: body }}
/>
<script src={prefixLink(`/bundle.js?t=${BUILD_TIME}`)} />
<script dangerouslySetInnerHTML={{__html: `
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-159000-24', 'auto');
ga('send', 'pageview');`
}}
/>
</body>
</html>
)
}
}
|
src/routes/home/index.js | arkeros/react-native-starter-kit | /**
* 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 Home from './Home';
import fetch from '../../core/fetch';
export default {
path: '/',
async action() {
const resp = await fetch('/graphql', {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: '{news{title,link,contentSnippet}}',
}),
credentials: 'include',
});
const { data } = await resp.json();
if (!data || !data.news) throw new Error('Failed to load the news feed.');
return {
title: 'React Starter Kit',
component: <Home news={data.news} />,
};
},
};
|
renderer/components/Form/OpenDialogInput.js | LN-Zap/zap-desktop | import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { compose } from 'redux'
import { asField } from 'informed'
import { Flex } from 'rebass/styled-components'
import { withInputValidation, WithOpenDialog } from 'hocs'
import { extractSpaceProps } from 'themes/util'
import { BasicInput } from './Input'
import OpenDialogButton from './OpenDialogButton'
const InnerInput = styled(BasicInput)`
input {
padding-right: 50px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
`
const OpenDialogInput = props => {
const { mode, label, ...rest } = props
const [spaceProps, otherProps] = extractSpaceProps(rest)
return (
<WithOpenDialog
render={({ openDialog }) => (
<Flex {...spaceProps}>
<InnerInput width={1} {...otherProps} label={label} />
<OpenDialogButton
mt={label ? 23 : '1px'}
onClick={async () => {
const result = await openDialog(mode)
// set value only if something was selected to avoid
// overriding an existing state
if (result) {
props.fieldApi.setValue(result)
}
}}
/>
</Flex>
)}
/>
)
}
OpenDialogInput.propTypes = {
fieldApi: PropTypes.object.isRequired,
// electron showOpenDialog feature flags
// https://electronjs.org/docs/api/dialog
// options.properties
label: PropTypes.node,
mode: PropTypes.string,
}
export { OpenDialogInput as BasicOpenDialogInput }
export default compose(withInputValidation, asField)(OpenDialogInput)
|
examples/todomvc/containers/Root.js | hainuo/redux | import React, { Component } from 'react';
import TodoApp from './TodoApp';
import { createStore, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import rootReducer from '../reducers';
const store = createStore(rootReducer);
export default class Root extends Component {
render() {
return (
<Provider store={store}>
{() => <TodoApp /> }
</Provider>
);
}
}
|
src/components/TalentStats.js | dfilipidisz/overwolf-hots-talents | import React from 'react';
import { connect } from 'react-redux';
import AppPopup from './AppPopup';
const lvls = ['1', '4', '7', '10', '13', '16', '20'];
const GraphIcon = ({lvl, openStatDetails}) => {
const open = () => {
openStatDetails(lvl);
};
return (
<i className='fa fa-line-chart' onClick={open} />
);
};
const TalentStats = ({ data, selectedHero, heroTalentFilter, openStatDetails }) => {
const hero = data[selectedHero];
const makeRow = (lvl) => {
let topTalent = null;
let topp = 0;
hero[`lvl${lvl}`].forEach((talent) => {
if (parseFloat(talent[heroTalentFilter]) > topp) {
topp = parseFloat(talent[heroTalentFilter]);
topTalent = Object.assign({}, talent);
}
});
return (
<div className='talent-row' key={`${lvl}-${heroTalentFilter}`}>
<div className='lvl'><span>{lvl}</span></div>
<div className='talent-holder clearfix'>
<div className='img-holder'>
<AppPopup
position='right center'
title={topTalent.title}
>
<div className={`talent-pic ${selectedHero} ${topTalent.id}`} />
</AppPopup>
</div>
<div className='text-holder'>
<p>{heroTalentFilter === 'popularity' ? 'picked' : 'won'}</p>
<p>% of time</p>
</div>
<div className='value-holder'>
<span>{topTalent[heroTalentFilter]}%</span>
</div>
<div className='action-holder'>
<GraphIcon lvl={lvl} openStatDetails={openStatDetails} />
</div>
</div>
</div>
);
};
return (
<div className='talent-stats'>
{lvls.map((lvl) => {
return makeRow(lvl);
})}
</div>
);
}
export default connect(
state => ({
heroTalentFilter: state.app.heroTalentFilter,
})
)(TalentStats);
|
packages/reactor-kitchensink/src/examples/Grid/ReduxGrid/Employees.js | markbrocato/extjs-reactor | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { filterChange } from './actions';
import { Grid, Column, TitleBar, SearchField, Label } from '@extjs/ext-react';
import data from './data';
Ext.require(['Ext.grid.plugin.PagingToolbar']);
class Employees extends Component {
store = Ext.create('Ext.data.Store', {
autoLoad: true,
pageSize: 50,
data: data,
autoDestroy: true
});
componentDidUpdate(prevProps, prevState) {
let { filter } = this.props;
if (filter !== prevProps.filter) {
filter = filter.toLowerCase();
this.store.clearFilter();
this.store.filterBy(record => {
return record.get('first_name').toLowerCase().indexOf(filter) !== -1 ||
record.get('last_name').toLowerCase().indexOf(filter) !== -1 ||
record.get('title').toLowerCase().indexOf(filter) !== -1
});
}
}
render() {
const { dispatch } = this.props;
return (
<Grid
store={this.store}
shadow
plugins={{
gridpagingtoolbar: true
}}
>
<TitleBar title="Employees" docked="top" ui="titlebar-search">
<SearchField
ui="alt"
align="right"
placeholder="Search..."
onChange={(me, value) => dispatch(filterChange(value))}
/>
</TitleBar>
<Column text="ID" dataIndex="id" width="50"/>
<Column text="First Name" dataIndex="first_name" width="150"/>
<Column text="Last Name" dataIndex="last_name" width="150"/>
<Column text="Title" dataIndex="title" flex={1}/>
</Grid>
)
}
}
const mapStateToProps = (state) => {
return { ...state }
};
export default connect(mapStateToProps)(Employees); |
src/docs/examples/HelloWorld/ExampleHelloWorld.js | Shuki-L/ps-react-shuki | import React from 'react';
import HelloWorld from 'ps-react/HelloWorld';
/** Custome message */
export default function ExampleHelloWorld() {
return <HelloWorld message="ps-react users!" />
} |
app/components/home/header/index.js | ayrton/pinata | /* @flow */
import React from 'react';
import Button from 'components/button';
import Svg from 'components/svg';
import styles from './style.css';
/**
* Header component.
*/
export default function Header(): ReactElement {
return (
<header className={styles.header}>
<a className={styles.logo} href="#">
<Svg src={require('./icons/confetti.svg')} />
<img alt="Piñata.Chat" src={require('./icons/logo.png')} title="Piñata.Chat" />
</a>
<h1 className={styles.headline}>Video chat with people like you.</h1>
<h2 className={styles.tagline}>Find people near or far based on your interests.</h2>
<Button className={styles.button}>
get early access
</Button>
</header>
);
}
|
examples/with-redux-thunk/pages/_app.js | BlancheXu/test | import App from 'next/app'
import React from 'react'
import withReduxStore from '../lib/with-redux-store'
import { Provider } from 'react-redux'
class MyApp extends App {
render () {
const { Component, pageProps, reduxStore } = this.props
return (
<Provider store={reduxStore}>
<Component {...pageProps} />
</Provider>
)
}
}
export default withReduxStore(MyApp)
|
src/components/App/App.js | hanshenrik/when.fm | import React, { Component } from 'react';
import ReactHighcharts from 'react-highcharts';
import './App.css';
import hightchartsConfig from '../../config/highcharts.js';
import Footer from '../Footer/Footer.js';
import Header from '../Header/Header.js';
import Search from '../Search/Search.js';
class App extends Component {
constructor(props) {
super(props);
this.state = { chart: null };
}
componentDidMount() {
this.setState({
chart: this.refs.chart.getChart(),
});
}
render() {
return (
<div className="app">
<Header />
<Search chart={this.state.chart} />
<div className="result">
<ReactHighcharts isPureConfig config={hightchartsConfig} ref="chart" />
</div>
<Footer />
</div>
);
}
}
export default App;
|
node_modules/rc-notification/es/Notification.js | ZSMingNB/react-news | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import Animate from 'rc-animate';
import createChainedFunction from 'rc-util/es/createChainedFunction';
import classnames from 'classnames';
import Notice from './Notice';
var seed = 0;
var now = Date.now();
function getUuid() {
return 'rcNotification_' + now + '_' + seed++;
}
var Notification = function (_Component) {
_inherits(Notification, _Component);
function Notification() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, Notification);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Notification.__proto__ || Object.getPrototypeOf(Notification)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
notices: []
}, _this.add = function (notice) {
var key = notice.key = notice.key || getUuid();
_this.setState(function (previousState) {
var notices = previousState.notices;
if (!notices.filter(function (v) {
return v.key === key;
}).length) {
return {
notices: notices.concat(notice)
};
}
});
}, _this.remove = function (key) {
_this.setState(function (previousState) {
return {
notices: previousState.notices.filter(function (notice) {
return notice.key !== key;
})
};
});
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(Notification, [{
key: 'getTransitionName',
value: function getTransitionName() {
var props = this.props;
var transitionName = props.transitionName;
if (!transitionName && props.animation) {
transitionName = props.prefixCls + '-' + props.animation;
}
return transitionName;
}
}, {
key: 'render',
value: function render() {
var _this2 = this,
_className;
var props = this.props;
var noticeNodes = this.state.notices.map(function (notice) {
var onClose = createChainedFunction(_this2.remove.bind(_this2, notice.key), notice.onClose);
return React.createElement(
Notice,
_extends({
prefixCls: props.prefixCls
}, notice, {
onClose: onClose
}),
notice.content
);
});
var className = (_className = {}, _defineProperty(_className, props.prefixCls, 1), _defineProperty(_className, props.className, !!props.className), _className);
return React.createElement(
'div',
{ className: classnames(className), style: props.style },
React.createElement(
Animate,
{ transitionName: this.getTransitionName() },
noticeNodes
)
);
}
}]);
return Notification;
}(Component);
Notification.propTypes = {
prefixCls: PropTypes.string,
transitionName: PropTypes.string,
animation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
style: PropTypes.object
};
Notification.defaultProps = {
prefixCls: 'rc-notification',
animation: 'fade',
style: {
top: 65,
left: '50%'
}
};
Notification.newInstance = function newNotificationInstance(properties) {
var _ref2 = properties || {},
getContainer = _ref2.getContainer,
props = _objectWithoutProperties(_ref2, ['getContainer']);
var div = void 0;
if (getContainer) {
div = getContainer();
} else {
div = document.createElement('div');
document.body.appendChild(div);
}
var notification = ReactDOM.render(React.createElement(Notification, props), div);
return {
notice: function notice(noticeProps) {
notification.add(noticeProps);
},
removeNotice: function removeNotice(key) {
notification.remove(key);
},
component: notification,
destroy: function destroy() {
ReactDOM.unmountComponentAtNode(div);
document.body.removeChild(div);
}
};
};
export default Notification; |
react/features/settings/components/web/audio/AudioSettingsEntry.js | bgrozev/jitsi-meet | // @flow
import React from 'react';
import { Icon, IconCheck, IconExclamationSolid } from '../../../../base/icons';
/**
* The type of the React {@code Component} props of {@link AudioSettingsEntry}.
*/
export type Props = {
/**
* The text for this component.
*/
children: React$Node,
/**
* Flag indicating an error.
*/
hasError?: boolean,
/**
* Flag indicating the selection state.
*/
isSelected: boolean,
};
/**
* React {@code Component} representing an entry for the audio settings.
*
* @returns { ReactElement}
*/
export default function AudioSettingsEntry({ children, hasError, isSelected }: Props) {
const className = `audio-preview-entry ${isSelected
? 'audio-preview-entry--selected' : ''}`;
return (
<div className = { className }>
{isSelected && (
<Icon
className = 'audio-preview-icon audio-preview-icon--check'
color = '#1C2025'
size = { 14 }
src = { IconCheck } />
)}
<span className = 'audio-preview-entry-text'>{children}</span>
{hasError && <Icon
className = 'audio-preview-icon audio-preview-icon--exclamation'
size = { 16 }
src = { IconExclamationSolid } />}
</div>
);
}
|
src/containers/DevToolsWindow.js | Shenseye/fisrt-react-redux-todolist | import React from 'react';
import { createDevTools } from 'redux-devtools';
import LogMonitor from 'redux-devtools-log-monitor';
export default createDevTools(
<LogMonitor />
);
|
modules/Dragable.js | wuct/a4 | import React from 'react'
import { findDOMNode } from 'react-dom'
import emptyFunction from './utils/emptyFunction'
class Dragable extends React.Component {
static defaultProps = {
onDragStart: emptyFunction,
onDraging: emptyFunction,
onDragEnd: emptyFunction,
}
isDraging = false
dragStartPosition = {}
componentDidMount() {
this.DOM = findDOMNode(this)
this.DOM.addEventListener('mousedown', this.onMouseDown)
}
componentWillUnmount() {
this.DOM.removeEventListener('mousedown', this.onMouseDown)
window.removeEventListener('mouseup', this.onMouseUp)
window.removeEventListener('mousemove', this.onMouseMove)
}
onMouseDown = (e) => {
e.stopPropagation()
this.isDraging = true
this.dragStartPosition = {
x0: e.clientX,
y0: e.clientY,
}
this.props.onDragStart(this.dragStartPosition)
window.addEventListener('mouseup', this.onMouseUp)
window.addEventListener('mousemove', this.onMouseMove)
}
onMouseUp = (e) => {
e.stopPropagation()
this.props.onDragEnd({
...this.dragStartPosition,
x1: e.clientX,
y1: e.clientY,
})
this.isDraging = false
this.dragStartPosition = {}
window.removeEventListener('mouseup', this.onMouseUp)
window.removeEventListener('mousemove', this.onMouseMove)
}
onMouseMove = (e) => {
e.stopPropagation()
if (!this.isDraging) return
this.props.onDraging({
...this.dragStartPosition,
x1: e.clientX,
y1: e.clientY,
})
}
render() {
return <g>{this.props.children}</g>
}
}
export default Dragable
|
app/components/ProjectCard/index.js | yagneshmodh/personalApplication | import React from 'react';
import { Card, CardHeader, CardMedia, CardTitle } from 'material-ui/Card';
// import FlatButton from 'material-ui/FlatButton';
import coverImage from '../../common/coverVideo/cover.jpg';
// import baseStyle from '../../common/Style/baseStyle.css';
const componentName = (() =>
<Card>
<CardHeader
title="URL Avatar"
/>
<CardMedia>
<img src={coverImage} alt="Cover" style={{ height: 220 }} />
</CardMedia>
<CardTitle
title="Card title"
subtitle="Card subtitle"
/>
</Card>
);
export default componentName;
|
src/monthpicker/MonthPickerTop.js | buildo/react-semantic-datepicker | import React from 'react';
import t from 'tcomb';
import { props } from 'tcomb-react';
import { pure, skinnable } from '../utils';
import { MomentDate, Mode } from '../utils/model';
import PickerTop from '../PickerTop';
@pure
@skinnable()
@props({
visibleDate: MomentDate,
onChangeMode: t.Function,
changeYear: t.Function,
fixedMode: t.maybe(t.Boolean),
prevIconClassName: t.String,
nextIconClassName: t.String
})
export default class MonthPickerTop extends React.Component {
onChangeMode = () => {
if (!this.props.fixedMode) {
this.props.onChangeMode(Mode('year'));
}
}
getYear = () => this.props.visibleDate.year()
previousDate = () => this.props.changeYear(this.getYear() - 1)
nextDate = () => this.props.changeYear(this.getYear() + 1)
getLocals({ fixedMode }) {
return {
prevIconClassName: this.props.prevIconClassName,
nextIconClassName: this.props.nextIconClassName,
fixed: !!fixedMode,
value: this.getYear(),
handleClick: this.onChangeMode,
previousDate: this.previousDate,
nextDate: this.nextDate
};
}
template(locales) {
return <PickerTop {...locales} />;
}
}
|
examples/async/containers/Root.js | vxsx/redux | import React, { Component } from 'react';
import { Provider } from 'react-redux';
import configureStore from '../store/configureStore';
import AsyncApp from './AsyncApp';
const store = configureStore();
export default class Root extends Component {
render() {
return (
<Provider store={store}>
{() => <AsyncApp />}
</Provider>
);
}
}
|
stories/Modal/index.js | skyiea/wix-style-react | import React from 'react';
import {storiesOf} from '@storybook/react';
import Markdown from '../utils/Components/Markdown';
import CodeExample from '../utils/Components/CodeExample';
import TabbedView from '../utils/Components/TabbedView';
import ReadmeTestKit from '../../src/Modal/README.TESTKIT.md';
import Readme from '../../src/Modal/README.md';
import ExampleControlled from './ExampleControlled';
import ExampleControlledRaw from '!raw-loader!./ExampleControlled';
storiesOf('9. Modals', module)
.add('Modal', () => (
<TabbedView tabs={['API', 'TestKits']}>
<div>
<Markdown source={Readme}/>
<h1>Usage examples</h1>
<CodeExample title="Controlled modal" code={ExampleControlledRaw}>
<ExampleControlled/>
</CodeExample>
</div>
<div>
<Markdown source={ReadmeTestKit}/>
</div>
</TabbedView>
));
|
src/components/SearchLayoutButton/SearchLayoutButton.js | joshblack/carbon-components-react | /**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { settings } from 'carbon-components';
import ListBulleted16 from '@carbon/icons-react/lib/list--bulleted/16';
import Grid16 from '@carbon/icons-react/lib/grid/16';
const { prefix } = settings;
/**
* The layout button for `<Search>`.
*/
class SearchLayoutButton extends Component {
state = { format: 'list' };
static propTypes = {
/**
* The layout.
*/
format: PropTypes.oneOf(['list', 'grid']),
/**
* The a11y label text.
*/
labelText: PropTypes.string,
/**
* The description for the "list" icon.
*/
iconDescriptionList: PropTypes.string,
/**
* The description for the "grid" icon.
*/
iconDescriptionGrid: PropTypes.string,
/**
* The callback called when layout switches.
*/
onChangeFormat: PropTypes.func,
};
static defaultProps = {
labelText: 'Filter',
iconDescriptionList: 'list',
iconDescriptionGrid: 'grid',
};
static getDerivedStateFromProps({ format }, state) {
const { prevFormat } = state;
return prevFormat === format
? null
: {
format: format || 'list',
prevFormat: format,
};
}
/**
* Toggles the button state upon user-initiated event.
*/
toggleLayout = () => {
const format = this.state.format === 'list' ? 'grid' : 'list';
this.setState({ format }, () => {
const { onChangeFormat } = this.props;
if (typeof onChangeFormat === 'function') {
onChangeFormat({ format });
}
});
};
render() {
const { labelText, iconDescriptionList, iconDescriptionGrid } = this.props;
const SearchLayoutButtonIcon = () => {
if (this.state.format === 'list') {
return (
<ListBulleted16
className={`${prefix}--search-view`}
aria-label={iconDescriptionList}
/>
);
}
return (
<Grid16
className={`${prefix}--search-view`}
aria-label={iconDescriptionGrid}
/>
);
};
return (
<button
className={`${prefix}--search-button`}
type="button"
onClick={this.toggleLayout}
aria-label={labelText}
title={labelText}>
<div className={`${prefix}--search__toggle-layout__container`}>
<SearchLayoutButtonIcon />
</div>
</button>
);
}
}
export default SearchLayoutButton;
|
tools/template/index/root/Root.hot.js | SteamerTeam/steamer-react | import { AppContainer } from 'react-hot-loader';
import React from 'react';
import { render } from 'react-dom';
import App from './Root.dev';
const rootEl = document.getElementById('pages');
render(
<AppContainer>
<App />
</AppContainer>,
rootEl
);
if (module.hot) {
module.hot.accept('./Root.dev', () => {
// If you use Webpack 2 in ES modules mode, you can
// use <App /> here rather than require() a <NextApp />.
const NextApp = require('./Root.dev').default;
render(
<AppContainer>
<NextApp />
</AppContainer>,
rootEl
);
});
} |
js/components/ProfileCard.react.js | cs2340-titans/RoastWeb | import React from 'react';
import Card from 'material-ui/lib/card/card';
import CardActions from 'material-ui/lib/card/card-actions';
import CardHeader from 'material-ui/lib/card/card-header';
import CardMedia from 'material-ui/lib/card/card-media';
import CardTitle from 'material-ui/lib/card/card-title';
import RaisedButton from 'material-ui/lib/raised-button';
import CardText from 'material-ui/lib/card/card-text';
import TextField from 'material-ui/lib/text-field';
import {browserHistory, firebaseRef} from '../app';
import LinkStateMixin from 'react-addons-linked-state-mixin';
var reactMixin = require('react-mixin');
class ProfileCard extends React.Component {
constructor(props) {
super(props);
this.state = {
profileRef: firebaseRef.child('profile/' + firebaseRef.getAuth().uid),
profile: {
email: "",
fullname: "",
gtid: "",
major: ""
}
};
this.state.profileRef.on("value", (data) => {
this.state.profile = data.val();
this.setState({profile: data.val()});
});
}
changeState(key, event){
let obj = {};
obj[key] = event.target.value;
let myProfile = {
...this.state.profile,
...obj
};
this.setState({
profile: {
...this.state.profile,
...obj
}});
this.state.profileRef.update(myProfile);
}
render = () => {
return (
<Card>
<CardTitle title="Your Profile" subtitle="View and edit your user profile here. Changes are saved in real time."/>
<CardText>
<TextField
hintText="user@example.com"
floatingLabelText="Email"
onChange={this.changeState.bind(this, 'email')}
value={this.state.profile.email}
/><br/>
<TextField
hintText="George P. Burdell"
floatingLabelText="Full Name"
onChange={this.changeState.bind(this, 'fullname')}
value={this.state.profile.fullname}
/><br/>
<TextField
hintText="90XXXXXXX"
floatingLabelText="GTID"
onChange={this.changeState.bind(this, 'gtid')}
value={this.state.profile.gtid}
/><br/>
<TextField
hintText="Computer Science"
floatingLabelText="Major"
onChange={this.changeState.bind(this, 'major')}
value={this.state.profile.major}
/><br/>
</CardText>
</Card>
);
}
};
export default ProfileCard;/**
* Created by andy on 3/30/16.
*/
|
src/toggle-children.js | reactabular/treetabular | import React from 'react';
import { get } from 'lodash';
import getLevel from './get-level';
import hasChildren from './has-children';
const toggleChildren = ({
getIndex = (rowData) => rowData._index, // Look for index based on convention
getRows,
getShowingChildren,
toggleShowingChildren,
props,
idField = 'id',
parentField,
// Toggling children with a doubleClick would provide better UX
// since toggling with a click makes it difficult to select each item
toggleEvent = 'DoubleClick'
} = {}) => {
if (!getRows) {
throw new Error('tree.toggleChildren - Missing getRows!');
}
if (!getShowingChildren) {
throw new Error('tree.toggleChildren - Missing getShowingChildren!');
}
if (!toggleShowingChildren) {
throw new Error('tree.toggleChildren - Missing toggleShowingChildren!');
}
const toggle = (e, index) => {
e.stopPropagation();
e.preventDefault();
toggleShowingChildren(index);
};
return (value, extra) => {
const { className, ...restProps } = props || {}; // eslint-disable-line react/prop-types
const rows = getRows();
const showingChildren = getShowingChildren(extra);
const index = getIndex(extra.rowData);
const containsChildren = hasChildren({ index, idField, parentField })(rows) ? 'has-children' : '';
const level = getLevel({ index, idField, parentField })(rows);
const hasParent = level > 0 ? 'has-parent' : '';
const hasAutomaticIndentation = get(props, 'indent', true);
const events = {
[`on${toggleEvent}`]: (e) => {
toggle(e, index);
window.getSelection && window.getSelection().removeAllRanges();
}
};
const style = hasAutomaticIndentation ? { paddingLeft: `${level}em` } : {};
return (
<div
style={style}
className={`${containsChildren} ${hasParent} ${className || ''}`}
{...events}
{...restProps}
>
{containsChildren && (
<span
className={showingChildren ? 'show-less' : 'show-more'}
onClick={(e) => toggle(e, index)}
/>
)}
{value}
</div>
);
};
};
export default toggleChildren;
|
src/index.js | easyCZ/easycz.github.io | import React from 'react';
import { render } from 'react-dom';
import { App } from './App';
render(<App />, document.getElementById('root'));
|
tp-4/recursos/boilerplate/src/index.js | jpgonzalezquinteros/sovos-reactivo-2017 | /* eslint-disable import/default */
import React from 'react';
import { render } from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import { Provider } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import App from './pages/layout';
import configureStore from './redux/configureStore';
const store = configureStore();
require('./favicon.ico'); // Tell webpack to load favicon.ico
render(
<AppContainer>
<Provider store={ store }>
<Router>
<App />
</Router>
</Provider>
</AppContainer>,
document.getElementById('app')
);
if (module.hot) {
module.hot.accept('./pages/layout', () => {
const NewApp = require('./pages/layout').default;
render(
<AppContainer>
<Provider store={ store }>
<Router>
<NewApp />
</Router>
</Provider>
</AppContainer>,
document.getElementById('app')
);
});
} |
lib/components/displays/Contactzz.js | sljohnson32/networkr | import React, { Component } from 'react';
import ContactCard from '../ContactCard'
import NewContactForm from './NewContactForm';
export default class Contactzz extends Component {
render() {
const { contactzz, addNewContact, displayContactzz, editContact, onNewContactForm, toggleNewContactForm, selectedContact, setSelectedContact } = this.props;
return (
<div>
<aside className='all-contactzz'>
<section className ='add-new-container'>
<button
className='btn-addnew'
onClick={ () => toggleNewContactForm() }
>Add Contact</button>
</section>
<h3 className='contact-directory'>Contact Directory</h3>
{ contactzz.map((contact, index) => {
const card = <ContactCard
key={ index }
contact={ contact }
selectedContact={ selectedContact }
setSelectedContact={ setSelectedContact }
displayContactzz={ displayContactzz }
/>;
return card;
})
}
</aside>
<section className='contact-info'>
{onNewContactForm ? <NewContactForm
contact={ {} }
addNewContact= { addNewContact }
editContact={ editContact }
editView={ true }
toggleNewContactForm={ toggleNewContactForm }
setSelectedContact={ setSelectedContact }
/> : <div />}
{selectedContact !== null ? <NewContactForm
contact={ selectedContact }
addNewContact= { addNewContact }
editContact={ editContact }
editView={ false }
setSelectedContact={ setSelectedContact }
/> : <div />}
{selectedContact === null && !onNewContactForm ? <h3>Please select a contact from the list on the left to display more details</h3> : <div />}
</section>
</div>
)
}
}
|
Js/Ui/Components/DelayedOnChange/index.js | Webiny/Webiny | import React from 'react';
import _ from 'lodash';
import Webiny from 'webiny';
/**
* This component is used to wrap Input and Textarea components to optimize form re-render.
* These 2 are the only components that trigger form model change on each character input.
* This means, whenever you type a letter an entire form re-renders.
* On complex forms you will feel and see a significant delay if this component is not used.
*
* The logic behind this component is to serve as a middleware between Form and Input/Textarea, and only notify form of a change when
* a user stops typing for given period of time (400ms by default).
*/
class DelayedOnChange extends Webiny.Ui.Component {
constructor(props) {
super(props);
this.delay = null;
this.state = {
value: this.getChildElement(props).props.value
};
this.bindMethods('applyValue,changed');
}
componentWillReceiveProps(props) {
super.componentWillReceiveProps(props);
if (!this.delay) {
this.setState({value: this.getChildElement(props).props.value});
}
}
applyValue(value, callback = _.noop) {
clearTimeout(this.delay);
this.delay = null;
this.realOnChange(value, callback);
}
changed() {
clearTimeout(this.delay);
this.delay = null;
this.delay = setTimeout(() => this.applyValue(this.state.value), this.props.delay);
}
getChildElement(props = null) {
if (!props) {
props = this.props;
}
return React.Children.toArray(props.children)[0];
}
render() {
const childElement = this.getChildElement();
this.realOnChange = childElement.props.onChange;
const props = _.omit(childElement.props, ['onChange']);
props.value = this.state.value;
props.onChange = e => {
const value = _.isString(e) ? e : e.target.value;
this.setState({value}, this.changed);
};
const realOnKeyDown = props.onKeyDown || _.noop;
const realOnBlur = props.onBlur || _.noop;
// Need to apply value if input lost focus
props.onBlur = (e) => {
e.persist();
this.applyValue(e.target.value, () => realOnBlur(e));
};
// Need to listen for TAB key to apply new value immediately, without delay. Otherwise validation will be triggered with old value.
props.onKeyDown = (e) => {
e.persist();
if (e.key === 'Tab') {
this.applyValue(e.target.value, () => realOnKeyDown(e));
} else if (e.key === 'Enter' && props['data-on-enter']) {
this.applyValue(e.target.value, () => realOnKeyDown(e));
} else {
realOnKeyDown(e);
}
};
return React.cloneElement(childElement, props);
}
}
DelayedOnChange.defaultProps = {
delay: 400
};
export default DelayedOnChange; |
assets/javascripts/kitten/components/graphics/logos/goodeedlogo/index.js | KissKissBankBank/kitten | import React from 'react'
import PropTypes from 'prop-types'
import { computeFromRatio } from '../../../../helpers/utils/ratio'
export const GoodeedLogo = ({ color, width, height, ...props }) => {
const DEFAULT_WIDTH = 122
const DEFAULT_HEIGHT = 22
const computed = computeFromRatio({
defaultWidth: DEFAULT_WIDTH,
defaultHeight: DEFAULT_HEIGHT,
width,
height,
})
const viewBox = {
x: DEFAULT_WIDTH,
y: DEFAULT_HEIGHT,
}
return (
<svg
role="img"
aria-label="Goodeed"
width={computed.width}
height={computed.height}
viewBox={`0 0 ${viewBox.x} ${viewBox.y}`}
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<title>Goodeed</title>
<defs>
<linearGradient
x1="100%"
y1="76.906%"
x2="0%"
y2="0%"
id="GoodeedLogo-a"
>
<stop stopColor="#53B1E7" offset="0%" />
<stop stopColor="#75D6FF" offset="100%" />
</linearGradient>
</defs>
<path
d="M761.391 36.1c-.247.238-.676.357-1.287.357H752.1c-.394 0-.64.037-.738.11-.098.073-.148.256-.148.548 0 .876.295 1.607.886 2.19.59.585 1.334.877 2.231.877.918 0 1.859-.48 2.821-1.44.656-.668 1.377-1.002 2.165-1.002.656 0 1.186.178 1.591.532.405.355.607.803.607 1.345 0 1.211-.695 2.238-2.083 3.083-1.389.845-3.078 1.268-5.068 1.268-2.603 0-4.681-.751-6.233-2.253-1.477-1.429-2.252-3.311-2.323-5.646-.242.259-.681.388-1.319.388h-8.004c-.394 0-.64.037-.738.11-.098.073-.148.256-.148.548 0 .876.295 1.607.886 2.19.59.585 1.334.877 2.231.877.918 0 1.859-.48 2.821-1.44.656-.668 1.378-1.002 2.165-1.002.656 0 1.186.178 1.591.532.405.355.607.803.607 1.345 0 1.211-.694 2.238-2.083 3.083-1.389.845-3.078 1.268-5.068 1.268-2.603 0-4.68-.751-6.233-2.253a7.51 7.51 0 01-.605-.659c.01.1.015.204.015.315 0 .647-.164 1.174-.492 1.581-.328.407-.766.61-1.312.61h-.197l-1.148-.188a7.532 7.532 0 00-1.116-.063c-.569 0-1.039.021-1.411.063-.547.063-.842.094-.886.094-.678 0-1.017-.375-1.017-1.126v-1.158c-1.138 1.857-2.844 2.785-5.118 2.785-2.012 0-3.669-.787-4.97-2.363-.82-.99-1.38-2.145-1.684-3.462-.336 1.427-.967 2.617-1.891 3.572-1.455 1.502-3.483 2.253-6.086 2.253-2.712 0-4.806-.73-6.282-2.191-.964-.954-1.614-2.162-1.948-3.624-.337 1.422-.967 2.61-1.89 3.562-1.455 1.502-3.483 2.253-6.085 2.253-2.712 0-4.806-.73-6.282-2.191-1.306-1.291-2.034-3.05-2.184-5.271a1.48 1.48 0 01-.193.012h-.788c-.59 0-.885.473-.885 1.42 0 .4.011.821.033 1.263l.066 1.357c.022.463.033.905.033 1.326 0 1.409-.809 2.114-2.427 2.114-1.531 0-2.296-.512-2.296-1.534v-.188c-1.512 1.15-3.229 1.723-5.154 1.723a9.477 9.477 0 01-4.757-1.267c-1.487-.845-2.57-1.945-3.248-3.302-.874-1.732-1.311-3.745-1.311-6.04 0-3.505.853-6.28 2.559-8.324 1.706-2.045 4.023-3.067 6.954-3.067 2.296 0 4.21.741 5.741 2.222.197-1.231.853-1.846 1.968-1.846 1.356 0 2.034.626 2.034 1.878 0 .209-.044.626-.131 1.252-.131.939-.197 1.575-.197 1.909 0 .376.021.657.066.845.044.668.066 1.044.066 1.127 0 .543-.252.996-.755 1.361s-1.148.548-1.936.548c-1.269 0-2.034-.595-2.296-1.784s-.64-2.008-1.132-2.457c-.492-.448-1.274-.673-2.346-.673-1.422 0-2.521.631-3.297 1.893-.777 1.263-1.164 3.051-1.164 5.367 0 1.961.377 3.489 1.132 4.585.755 1.095 1.799 1.643 3.133 1.643.853 0 1.558-.235 2.116-.704s.837-1.059.837-1.768c0-.877-.383-1.315-1.148-1.315h-.197a1.002 1.002 0 01-.23.031c-.35.042-.547.062-.59.062-.438 0-.809-.182-1.115-.548-.307-.365-.459-.818-.459-1.361 0-.626.219-1.127.656-1.502.437-.375 1.006-.563 1.706-.563.459 0 1.153.058 2.083.172.929.115 1.635.172 2.116.172.722 0 1.52-.063 2.395-.191.7-.101 1.181-.153 1.443-.153.504 0 .938.104 1.3.312.36-1.202.954-2.219 1.783-3.05 1.465-1.471 3.521-2.206 6.167-2.206 2.602 0 4.653.73 6.151 2.19.976.952 1.635 2.135 1.975 3.547.337-1.414.975-2.591 1.912-3.531 1.465-1.471 3.521-2.206 6.167-2.206 2.602 0 4.653.73 6.151 2.19.98.956 1.64 2.144 1.979 3.564.303-1.27.847-2.364 1.629-3.283 1.28-1.502 2.958-2.253 5.036-2.253 1.662 0 3.193.616 4.593 1.846V27.07c0-.751-.274-1.127-.82-1.127-.131 0-.394.021-.787.062a2.996 2.996 0 01-.853.125c-.416 0-.766-.167-1.05-.501-.285-.334-.426-.751-.426-1.252 0-1.335.743-2.003 2.231-2.003.481 0 .831.011 1.05.031.874.084 1.465.125 1.771.125.284 0 .7-.026 1.246-.078.547-.052.951-.078 1.214-.078.547 0 .924.121 1.132.362.208.242.312.687.312 1.337V38.39c0 1.07.208 1.604.623 1.604.131 0 .295-.044.492-.132.131-.058.306-.087.525-.087.233 0 .437.033.613.098-.628-1.187-.941-2.576-.941-4.167 0-2.524.771-4.563 2.313-6.118 1.542-1.554 3.56-2.331 6.053-2.331 2.318 0 4.171.637 5.56 1.909 1.123 1.031 1.793 2.342 2.007 3.934a7.68 7.68 0 011.995-3.512c1.542-1.554 3.559-2.331 6.052-2.331 2.318 0 4.171.637 5.561 1.909 1.074.985 1.732 2.226 1.975 3.724.309-1.218.842-2.272 1.599-3.161 1.279-1.502 2.957-2.253 5.035-2.253 1.662 0 3.193.616 4.593 1.846V27.07c0-.751-.274-1.127-.82-1.127-.131 0-.394.021-.787.062a3.001 3.001 0 01-.853.125c-.416 0-.766-.167-1.05-.501-.285-.334-.426-.751-.426-1.252 0-1.335.743-2.003 2.231-2.003.481 0 .831.011 1.05.031.874.084 1.465.125 1.771.125.284 0 .7-.026 1.246-.078.547-.052.951-.078 1.214-.078.547 0 .924.121 1.132.362.208.242.312.687.312 1.337V38.39c0 1.07.208 1.604.623 1.604.131 0 .295-.044.492-.132.131-.058.306-.087.525-.087.94 0 1.411.532 1.411 1.596 0 .647-.164 1.174-.492 1.581-.328.407-.766.61-1.312.61H779l-1.148-.188a7.526 7.526 0 00-1.115-.063c-.569 0-1.039.021-1.411.063-.547.063-.842.094-.886.094-.678 0-1.017-.375-1.017-1.126v-1.158c-1.138 1.857-2.843 2.785-5.118 2.785-2.012 0-3.669-.787-4.97-2.363-1.219-1.474-1.866-3.309-1.944-5.505zM688.117 31c-.963 0-1.722.402-2.28 1.205-.558.803-.837 1.904-.837 3.301 0 1.419.279 2.525.837 3.317.558.793 1.339 1.189 2.346 1.189 2.034 0 3.051-1.502 3.051-4.507S690.194 31 688.117 31zm16.367 0c-.964 0-1.723.402-2.28 1.205-.558.803-.837 1.904-.837 3.301 0 1.419.279 2.525.837 3.317.558.793 1.339 1.189 2.346 1.189 2.034 0 3.05-1.502 3.05-4.507S706.56 31 704.485 31zm15.926.42c-.81 0-1.471.365-1.985 1.095-.514.731-.803 1.721-.869 2.973v.407c0 1.273.257 2.274.771 3.004.514.731 1.208 1.096 2.083 1.096.962 0 1.744-.396 2.345-1.189.601-.793.902-1.846.902-3.161 0-1.272-.295-2.295-.886-3.067-.59-.772-1.377-1.158-2.361-1.158zm15.353 1.283c0 .125.033.23.098.313.066.083.295.125.689.125h3.674c.328 0 .53-.036.607-.109.076-.073.115-.204.115-.391 0-.542-.251-1.017-.754-1.424-.503-.407-1.094-.61-1.771-.61-.875 0-1.586.324-2.132.97-.351.417-.526.792-.526 1.126zm15.614 0c0 .125.033.23.098.313.066.083.295.125.689.125h3.674c.328 0 .53-.036.607-.109.076-.073.115-.204.115-.391 0-.542-.252-1.017-.755-1.424-.503-.407-1.094-.61-1.771-.61-.875 0-1.586.324-2.132.97-.35.417-.525.792-.525 1.126zm18.109-1.283c-.81 0-1.471.365-1.985 1.095-.514.731-.804 1.721-.869 2.973v.407c0 1.273.256 2.274.771 3.004.513.731 1.208 1.096 2.083 1.096.962 0 1.744-.396 2.345-1.189.601-.793.902-1.846.902-3.161 0-1.272-.295-2.295-.886-3.067-.59-.772-1.377-1.158-2.361-1.158z"
transform="translate(-659 -22)"
fill={color}
/>
</svg>
)
}
GoodeedLogo.propTypes = {
color: PropTypes.string,
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
}
GoodeedLogo.defaultProps = {
color: 'url(#GoodeedLogo-a)',
width: null,
height: null,
}
|
src/components/Header/Header.js | giux78/daf-dataportal | import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux'
import { reset } from 'redux-form'
import fontawesome from '@fortawesome/fontawesome'
import FontAwesomeIcon from '@fortawesome/react-fontawesome'
import { faGlobe } from '@fortawesome/fontawesome-free-solid'
import {
loadDatasets,
updateNotifications,
fetchNotifications,
logout
} from '../../actions'
import { isEditor, isAdmin } from '../../utility'
class Header extends Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleLoadDatasetClick = this.handleLoadDatasetClick.bind(this);
this.toggle = this.toggle.bind(this);
this.toggleSearch = this.toggleSearch.bind(this)
this.toggleCrea = this.toggleCrea.bind(this)
this.mobileSidebarToggle = this.mobileSidebarToggle.bind(this)
this.createDash = this.createDash.bind(this)
// this.createWidget = this.createWidget.bind(this)
this.createStory = this.createStory.bind(this)
this.closeMenu = this.closeMenu.bind(this)
this.toggleAsideMenu = this.toggleAsideMenu.bind(this)
this.state = {
mobile: false,
revealed: false,
dropdownOpen: false,
crea: false,
accento: false,
value: '',
unread : 0,
unreadNotifications: []
};
this.pushToPublic = this.pushToPublic.bind(this)
}
componentWillReceiveProps(nextProps){
if(nextProps.notifications){
var unreadNot = nextProps.notifications.filter(notification =>{
return notification.status===1
})
//console.log(unreadNot)
this.setState({
unread: unreadNot.length,
unreadNotifications: unreadNot
})
}
}
toggleCrea(){
this.setState({
crea: !this.state.crea,
}, () => {
document.addEventListener('click', this.closeMenu);
});
if(this.state.revealed === true)
this.props.openSearch();
}
toggle() {
this.setState({
dropdownOpen: !this.state.dropdownOpen,
}, () => {
document.addEventListener('click', this.closeMenu);
});
if(this.state.revealed === true)
this.props.openSearch();
}
toggleNav() {
this.setState({
navigation: !this.state.navigation,
}, () => {
document.addEventListener('click', this.closeMenu);
});
if(this.state.revealed === true)
this.props.openSearch();
}
sidebarToggle(e) {
e.preventDefault();
document.body.classList.toggle('sidebar-hidden');
}
sidebarMinimize(e) {
e.preventDefault();
document.body.classList.toggle('sidebar-minimized');
}
mobileSidebarToggle(e) {
e.preventDefault();
this.setState({
mobile: !this.state.mobile
})
document.body.classList.toggle('sidebar-mobile-show');
if(this.state.revealed === true)
this.props.openSearch();
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleLoadDatasetClick(event) {
console.log('Search Dataset for: ' + this.refs.auto.value);
event.preventDefault();
const { dispatch, selectDataset } = this.props;
dispatch(loadDatasets(this.refs.auto.state.value, 0, '', '', '', '','metadata_modified%20desc'))
.then(json => {
this.props.history.push('/private/dataset');
})
}
toggleSearch(e){
this.setState({
revealed: !this.state.revealed,
accento: !this.state.accento,
dropdownOpen: false,
crea: false
})
if(this.state.mobile === true)
this.mobileSidebarToggle(e);
this.props.openSearch();
}
crea(){
this.props.history.push('/private/crea')
}
createDash(){
/* this.props.history.push({
pathname: '/dashboard/list',
state: { 'isOpen': true }
}) */
this.props.openModalDash();
this.toggleCrea()
}
createWidget(){
this.props.history.push('/private/charts');
this.toggleCrea()
}
createStory(){
/* this.props.history.push({
pathname: '/userstory/list',
state: { 'isOpen': true }
}) */
this.props.openModalStory();
this.toggleCrea()
}
closeMenu() {
if(this.state.revealed === true)
this.props.openSearch();
this.setState({
mobile: false,
revealed: false,
dropdownOpen: false,
crea: false,
accento: false,
navigation: false
}, () => {
document.removeEventListener('click', this.closeMenu);
});
}
pushToPublic(){
document.removeEventListener('click', this.closeMenu)
this.props.history.push('/')
}
toggleAsideMenu(){
const { dispatch } = this.props
document.body.classList.toggle('aside-menu-xl-show')
document.body.classList.toggle('aside-menu-hidden')
var unreadNot = this.state.unreadNotifications
if(unreadNot.length>0){
unreadNot.map(not => {
not.status = 2
})
console.log(unreadNot)
dispatch(updateNotifications(unreadNot))
.then(json => {
console.log(json)
this.setState({
isLoading: true,
unreadNotifications: []
})
dispatch(fetchNotifications(localStorage.getItem('user'), 20))
.then(json => {
console.log(json)
this.setState({
isLoading: false
})
})
})
}
}
render() {
const { loggedUser, properties } = this.props
let open = this.state.dropdownOpen ? "show" : ""
let revealed = this.state.revealed ? "btn-accento" : "btn-header"
let crea = this.state.crea ? "show" : ""
var navigation = this.state.navigation?" active":""
var show = this.state.navigation?" show":""
return (
<header className="app-header navbar border-0">
<button className="nav-link navbar-toggler sidebar-toggler d-lg-none" onClick={this.mobileSidebarToggle} type="button">☰</button>
{/* <button className="d-md-down-none nav-link navbar-toggler sidebar-toggler" type="button" onClick={this.sidebarMinimize}>☰</button> */}
<ul className="nav navbar-nav d-md-down-none mr-auto">
<li className="nav-item brand">
<Link className="h-100 font-2xl" to={'/private/home'}><img className="img-logo mb-1 pr-3" src="./img/DAF_pittogramma_FU.svg" alt=""/><span className="pl-3 font-weight-bold">DAF {properties.headerSiglaTool}</span></Link>
</li>
{/* <div className={"search-bar " + revealed}>
<form onSubmit={this.handleLoadDatasetClick}>
<input className="search-input" placeholder="Cerca" ref="auto" name="s" id="search_mobile" tabindex="-1" type="text" />
</form>
</div> */}
</ul>
{/* <ul className="nav navbar-nav">
<AutocompleteDataset ref="auto"/>
<button className="btn btn-gray-200" onClick={this.handleLoadDatasetClick}><i className="fa fa-search fa-lg" /> Cerca</button>
</ul> */}
<ul className="navbar-nav ml-auto h-100 mr-2">
<li className="nav-item h-100">
<button className={"w-100 h-100 btn " + revealed} onClick={this.toggleSearch}><i className="fa fa-search fa-lg" /></button>
</li>
<li className="nav-item h-100 mr-3">
<div className={"dropdown h-100 " + crea}>
<button className="w-100 h-100 btn btn-header" onClick={/* this.crea.bind(this) */this.toggleCrea}><i className="fa fa-plus fa-lg"/></button>
<div className={"dropdown-menu m-0 dropdown-menu-right "+ crea} aria-labelledby="dropdownMenuButton">
<h6 className="dropdown-header text-center"><b>Crea</b></h6>
{(isEditor(loggedUser) || isAdmin(loggedUser)) && <button className="dropdown-item" onClick={()=> { const{ dispatch } = this.props; dispatch(reset('wizard')); this.props.history.push('/private/ingestionwizzard'); this.toggleCrea}}><i className="fa fa-table"></i> Nuovo Dataset</button>}
{/* <button className="dropdown-item" onClick={this.createWidget} ><i className="fa fa-chart-bar"></i> Nuovo Widget</button> */}
<button className="dropdown-item" onClick={this.createDash} ><i className="fa fa-columns"></i> Nuova Dashboard</button>
<button className="dropdown-item" onClick={this.createStory} ><i className="fa fa-font"></i> Nuova Storia</button>
</div>
</div>
{/* <button className="w-100 h-100 btn btn-header" onClick={this.crea.bind(this)}><i className="fa fa-plus fa-lg"/></button> */}
</li>
</ul>
<ul className="navbar-nav mr-2">
<li className="nav-item">
<button className="btn btn-primary nav-link text-white" onClick={this.toggleAsideMenu}><i className={this.state.unread===0?"fa fa-bell fa-lg":"far fa-bell fa-lg"} /><span className="badge badge-white badge-pill text-primary">{this.state.unread===0?'':this.state.unread}</span></button>
</li>
</ul>
<ul className="nav navbar-nav mr-2">
<li className="nav-item">
<div className={"dropdown " + open}>
<a className="nav-link" role="button" id="dropdownMenuButton" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false" onClick={this.toggle}>
{/* <img src={'img/avatars/7.jpg'} className="img-avatar pointer" alt="admin@bootstrapmaster.com"/> */}
<i className="fas fa-user-circle fa-2x pointer text-white"/>
</a>
<div className={"dropdown-menu dropdown-menu-right "+ open} aria-labelledby="dropdownMenuButton">
<h6 className="dropdown-header text-center"><b>{loggedUser ? loggedUser.givenname : ''}</b></h6>
<a className="dropdown-item" href="/#/private/profile" onClick={this.toggle}><i className="fa fa-user"></i> Profilo</a>
<a className="dropdown-item" onClick={() => { logout(); this.toggle }} href="/"><i className="fa fa-lock"></i> Logout</a>
</div>
</div>
</li>
</ul>
<ul className="nav navbar-nav h-100">
<li className="nav-item h-100">
<div className={"h-100 dropdown " + show}>
<button className={"h-100 btn btn-accento"+navigation} id="dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" onClick={this.toggleNav.bind(this)}><p className="m-0 p-0 d-md-down-none float-left">Area Privata</p><i className="float-left fa fa-lock fa-lg d-lg-none"/> <i className="fa fa-sort-down ml-2 align-top"/></button>
<div className={"dropdown-menu dropdown-menu-right m-0" + show} aria-labelledby="dropdownMenuButton">
<h6 className="dropdown-header bg-white"><b>VAI A</b></h6>
<button className="dropdown-item bg-light b-l-pvt border-primary pr-5" onClick={this.pushToPublic}>
<div className="row">
<h5 className="col-1 pl-0"><FontAwesomeIcon icon={faGlobe} className="mx-2"/></h5>
<div className="row col-11 ml-1">
<div className="col-12 pl-1"><p className="mb-0"><b>Area pubblica</b></p></div>
<div className="col-12 pl-1">Catalogo open data italiani</div>
</div>
</div>
</button>
</div>
</div>
</li>
</ul>
</header>
)
}
}
function mapStateToProps(state) {
const { loggedUser } = state.userReducer['obj'] || { }
const { properties } = state.propertiesReducer['prop'] || {}
const { notifications, newNotifications } = state.notificationsReducer['notifications'] || {}
return { loggedUser, properties, notifications, newNotifications }
}
export default connect(mapStateToProps)(Header)
|
src/components/PaymentDetailsForm/index.js | bruceli1986/contract-react | import React from 'react'
import PcListItem from './PcListItem'
import formatter from 'utils/formatter.js'
import './style.scss'
/** 申请和修改页面中用到的支付单明细的信息表单*/
class PaymentDetailsForm extends React.Component {
static propTypes = {
pcList: React.PropTypes.arrayOf(React.PropTypes.shape({
poItem: React.PropTypes.string.isRequired,
incurredFcostsTotal: React.PropTypes.number.isRequired,
ptdCommitmentQty: React.PropTypes.number.isRequired,
description: React.PropTypes.string,
unitDescription: React.PropTypes.string,
incurredPrice: React.PropTypes.number,
incurredQtyTotal: React.PropTypes.number,
unitOfMeasure: React.PropTypes.string,
ptdCommitmentFrate: React.PropTypes.number,
currency: React.PropTypes.string
})),
validStatus: React.PropTypes.bool.isRequired,
type: React.PropTypes.string
}
constructor (props, context) {
super(props, context)
this.state = {
searchText: '',
type: '',
value: [],
remark: [],
expand: []
}
}
componentDidMount () {
$(this.refs.typeSwitcher).bootstrapSwitch({
size: 'small',
onText: '全部',
offText: '已填',
offColor: 'primary'
}).on('switchChange.bootstrapSwitch', function (event, state) {
if (state === false) {
this.setState({
type: 'filled'
})
} else {
this.setState({
type: 'all'
})
}
}.bind(this))
}
componentWillReceiveProps (nextProps) {
if (this.props.pcList !== nextProps.pcList) {
var value = nextProps.pcList.map(function (x) {
if (x.unitOfMeasure === 'LOT') {
return (x.incurredFcosts ? x.incurredFcosts : null)
} else {
return (x.incurredQty ? x.incurredQty : null)
}
})
var remark = nextProps.pcList.map(function (x) {
return x.remark ? x.remark : undefined
})
this.setState({
searchText: '',
value: value,
remark: remark,
expand: []
})
}
if (this.state.type !== nextProps.type) {
this.setState({
type: nextProps.type
})
}
}
componentDidUpdate (prevProps, prevState) {
if (this.props.validStatus === true) {
if (!this.isValidate()) {
this.refs.errorMsg.scrollIntoView(false)
return
}
}
$(this.refs.typeSwitcher).bootstrapSwitch('state', this.state.type === 'all')
}
// 根据状态searchText和type来过滤pcList
filterPcList () {
var value = this.state.value
var expand = this.state.expand
var remark = this.state.remark
var result = Object.assign([], this.props.pcList)
result.forEach(function (x, i) {
x.index = i
x.value = value[i]
x.remark = remark[i]
x.expand = expand[i]
})
if (this.state.type === 'filled') {
result = result.filter((x, i) => {
if (value[i] && value[i] !== 0) {
return true
} else {
return false
}
})
}
let text = $.trim(this.state.searchText).toLowerCase()
if (text) {
result = result.filter((x, i) => {
if (x.poItem.toLowerCase().search(text) !== -1 || x.description.toLowerCase().search(text) !== -1) {
return true
} else {
return false
}
})
}
// 将pcList翻倍
var temp = Object.assign([], result)
temp.forEach(function (x, i, a) { result.splice(2 * i, 0, x) })
return result
}
isValidate () {
var validate = this.state.value.some(function (x) { return (x != null && x !== '') })
return validate
}
errorMsg () {
if (this.props.validStatus === true) {
if (!this.isValidate()) {
return '至少需要填写一条支付细项!'
}
}
}
setSearchText = (e) => {
this.setState({searchText: e.target.value})
}
setPcList = (value, index) => {
let pcList = this.state.value
pcList[index] = Number(value)
this.setState({
value: pcList
})
}
setRemark = (value, index) => {
var remark = this.state.remark
remark[index] = value
this.setState({
remark: remark
})
}
setToggle = (value, index) => {
var expand = this.state.expand
expand[index] = value
this.setState({
expand: expand
})
}
// 计算支付总金额
paymentCostSum () {
let sum = 0
var pcList = this.props.pcList
this.state.value.forEach(function (x, index) {
if (pcList[index].unitOfMeasure === 'LOT') {
sum += parseFloat(x || 0)
} else {
sum += parseFloat(x || 0) * pcList[index].ptdCommitmentFrate
}
})
return formatter.formatMoney(sum)
}
// 计算合同总金额
contractSum () {
let sum = 0
this.props.pcList.forEach(function (x) {
sum += x.incurredPrice
})
return formatter.formatMoney(sum)
}
// 计算合同累计支付
contractIncurredSum () {
let sum = 0
this.props.pcList.forEach(function (x) {
sum += x.incurredFcostsTotal
})
return formatter.formatMoney(sum)
}
// 计算合同完成比
contractIncurredPrecent () {
let sum1 = 0
this.props.pcList.forEach(function (x) {
sum1 += x.incurredFcostsTotal
})
if (sum1 !== 0) {
let sum2 = 0
this.props.pcList.forEach(function (x) {
sum2 += x.incurredPrice
})
return formatter.formatPercent(sum1 / sum2)
} else {
return formatter.formatPercent(0)
}
}
render () {
var b = this.filterPcList()
return (
<div className='payment-detail-from'>
<div>
<input style={{marginLeft: '20px', marginRight: '20px', width: '200px', display: 'inline-block'}}
className='form-control' placeholder='BOQ/报价单描述'
value={this.state.searchText} onChange={this.setSearchText} />
<input ref='typeSwitcher' type='checkbox' />
<label ref='errorMsg' className='error' style={{marginLeft: '100px'}}>{this.errorMsg()}</label>
</div>
<div className='table-responsive' style={{maxHeight: '400px'}}>
<table className='table table-hover table-no-bordered' style={{overflowY: 'auto'}}>
<thead>
<tr>
<th style={{textAlign: 'center'}}>BOQ</th>
<th style={{textAlign: 'center'}}>报价单描述</th>
<th style={{textAlign: 'center'}}>报价单编码/描述</th>
<th style={{textAlign: 'center'}}>币种</th>
<th style={{textAlign: 'right'}}>合同数量</th>
<th style={{textAlign: 'right'}}>合同单价</th>
<th style={{textAlign: 'right'}}>合同金额</th>
<th style={{textAlign: 'right'}}>已支付数量</th>
<th style={{textAlign: 'right'}}>已支付金额</th>
</tr>
</thead>
<tbody>
{
b.map((x, index) => {
if (index % 2 === 0) {
return (
<tr key={index}>
<td style={{textAlign: 'center'}}>{x.poItem}</td>
<td style={{textAlign: 'center'}}>{x.description}</td>
<td style={{textAlign: 'center'}}>{x.unitOfMeasure + '/' + x.unitDescription}</td>
<td style={{textAlign: 'center'}}>{x.currency}</td>
<td style={{textAlign: 'right'}}>{x.ptdCommitmentQty}</td>
<td style={{textAlign: 'right'}}>{formatter.formatMoney(x.ptdCommitmentFrate)}</td>
<td style={{textAlign: 'right'}}>{formatter.formatMoney(x.incurredPrice)}</td>
<td style={{textAlign: 'right'}}>{x.incurredQtyTotal}</td>
<td style={{textAlign: 'right'}}>{formatter.formatMoney(x.incurredFcostsTotal)}</td>
</tr>)
} else {
return (
<tr key={index}>
<PcListItem {...x} index={x.index} onChange={this.setPcList}
onRemark={this.setRemark} onToggle={this.setToggle} />
</tr>
)
}
})
}
</tbody>
</table>
</div>
<div className='payment-table-footer container-fluid'>
<div className='row'>
<div className='col-md-3'>
<label>支付总金额:</label><span className='invoice-costs'>{this.paymentCostSum()}</span>
</div>
<div className='col-md-3'>
<label>合同总金额:</label><span>{this.contractSum()}</span>
</div>
<div className='col-md-3'>
<label>合同累计支付:</label><span>{this.contractIncurredSum()}</span>
</div>
<div className='col-md-3'>
<label>合同完成百分比:</label><span>{this.contractIncurredPrecent()}</span>
</div>
</div>
</div>
</div>
)
}
}
PaymentDetailsForm.defaultProps = {
pcList: []
}
export default PaymentDetailsForm
|
js/components/card/card-image.js | YeisonGomez/RNAmanda |
import React, { Component } from 'react';
import { Image, View } from 'react-native';
import { connect } from 'react-redux';
import { actions } from 'react-native-navigation-redux-helpers';
import { Container, Header, Title, Content, Button, Icon, Card, CardItem, Text, Thumbnail, Left, Body, Right, IconNB } from 'native-base';
import { Actions } from 'react-native-router-flux';
import styles from './styles';
const logo = require('../../../img/logo.png');
const cardImage = require('../../../img/drawer-cover.png');
const {
popRoute,
} = actions;
class NHCardImage extends Component {
static propTypes = {
popRoute: React.PropTypes.func,
navigation: React.PropTypes.shape({
key: React.PropTypes.string,
}),
}
popRoute() {
this.props.popRoute(this.props.navigation.key);
}
render() {
return (
<Container style={styles.container}>
<Header>
<Left>
<Button transparent onPress={() => Actions.pop()}>
<Icon name="arrow-back" />
</Button>
</Left>
<Body>
<Title>Card Image</Title>
</Body>
<Right />
</Header>
<Content padder>
<Card style={styles.mb}>
<CardItem>
<Left>
<Thumbnail source={logo} />
<Body>
<Text>NativeBase</Text>
<Text note>GeekyAnts</Text>
</Body>
</Left>
</CardItem>
<CardItem cardBody>
<Image style={{ resizeMode: 'cover', width: null, height: 200, flex: 1 }} source={cardImage} />
</CardItem>
<CardItem style={{ paddingVertical: 0 }}>
<Left>
<Button iconLeft transparent>
<Icon active name="thumbs-up" />
<Text>12 Likes</Text>
</Button>
</Left>
<Body>
<Button iconLeft transparent>
<Icon active name="chatbubbles" />
<Text>4 Comments</Text>
</Button>
</Body>
<Right>
<Text>11h ago</Text>
</Right>
</CardItem>
</Card>
</Content>
</Container>
);
}
}
function bindAction(dispatch) {
return {
popRoute: key => dispatch(popRoute(key)),
};
}
const mapStateToProps = state => ({
navigation: state.cardNavigation,
themeState: state.drawer.themeState,
});
export default connect(mapStateToProps, bindAction)(NHCardImage);
|
packages/node_modules/@webex/react-component-activity-post/src/index.js | adamweeks/react-ciscospark-1 | import React from 'react';
import PropTypes from 'prop-types';
import ActivityItemBase from '@webex/react-component-activity-item-base';
import ActivityText from '@webex/react-component-activity-text';
import AdaptiveCard from '@webex/react-component-adaptive-card';
const propTypes = {
content: PropTypes.string,
displayName: PropTypes.string,
renderedComponent: PropTypes.element,
cards: PropTypes.array,
sdkInstance: PropTypes.object.isRequired,
renderAdaptiveCard: PropTypes.bool,
activityId: PropTypes.string,
intl: PropTypes.object.isRequired
};
const defaultProps = {
content: '',
displayName: '',
renderedComponent: null,
cards: [],
renderAdaptiveCard: false,
activityId: undefined
};
function ActivityPost(props) {
const {
content,
renderedComponent,
displayName,
renderAdaptiveCard,
cards,
sdkInstance,
activityId,
intl
} = props;
return (
<ActivityItemBase {...props}>
{renderAdaptiveCard
? <AdaptiveCard
cards={cards}
displayName={displayName}
sdkInstance={sdkInstance}
activityId={activityId}
intl={intl}
/>
: <ActivityText content={content} displayName={displayName} renderedComponent={renderedComponent} />}
</ActivityItemBase>
);
}
ActivityPost.propTypes = propTypes;
ActivityPost.defaultProps = defaultProps;
export default ActivityPost;
|
packages/react-error-overlay/src/components/Collapsible.js | CodingZeal/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/* @flow */
import React, { Component } from 'react';
import { black } from '../styles';
import type { Element as ReactElement } from 'react';
const _collapsibleStyle = {
color: black,
cursor: 'pointer',
border: 'none',
display: 'block',
width: '100%',
textAlign: 'left',
background: '#fff',
fontFamily: 'Consolas, Menlo, monospace',
fontSize: '1em',
padding: '0px',
lineHeight: '1.5',
};
const collapsibleCollapsedStyle = {
..._collapsibleStyle,
marginBottom: '1.5em',
};
const collapsibleExpandedStyle = {
..._collapsibleStyle,
marginBottom: '0.6em',
};
type Props = {|
children: ReactElement<any>[],
|};
type State = {|
collapsed: boolean,
|};
class Collapsible extends Component<Props, State> {
state = {
collapsed: true,
};
toggleCollaped = () => {
this.setState(state => ({
collapsed: !state.collapsed,
}));
};
render() {
const count = this.props.children.length;
const collapsed = this.state.collapsed;
return (
<div>
<button
onClick={this.toggleCollaped}
style={
collapsed ? collapsibleCollapsedStyle : collapsibleExpandedStyle
}
>
{(collapsed ? '▶' : '▼') +
` ${count} stack frames were ` +
(collapsed ? 'collapsed.' : 'expanded.')}
</button>
<div style={{ display: collapsed ? 'none' : 'block' }}>
{this.props.children}
<button
onClick={this.toggleCollaped}
style={collapsibleExpandedStyle}
>
{`▲ ${count} stack frames were expanded.`}
</button>
</div>
</div>
);
}
}
export default Collapsible;
|
app/javascript/plugins/email_pension/SelectPensionFund.js | SumOfUs/Champaign | //
import $ from 'jquery';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { FormattedMessage } from 'react-intl';
import { find, sortBy } from 'lodash';
import Select from '../../components/SweetSelect/SweetSelect';
import Input from '../../components/SweetInput/SweetInput';
import Button from '../../components/Button/Button';
import FormGroup from '../../components/Form/FormGroup';
import SelectCountry from '../../components/SelectCountry/SelectCountry';
import SuggestFund from './SuggestFund';
import {
changeCountry,
changePensionFunds,
changeFund,
} from '../../state/email_pension/actions';
import { changeCountry as changeConsentCountry } from '../../state/consent';
const SUPPORTED_COUNTRIES = [
'AU',
'BE',
'CA',
'CH',
'DE',
'DK',
'ES',
'FI',
'FR',
'GB',
'IE',
'IS',
'IT',
'NL',
'NO',
'PT',
'SE',
'US',
];
class SelectPensionFund extends Component {
componentWillMount() {
this.getPensionFunds(this.props.country);
}
getPensionFunds = country => {
if (!country) return;
const url = `/api/pension_funds?country=${country.toLowerCase()}`;
$.getJSON(url)
.then(data => {
return data.map(f => ({
...f,
value: f._id,
label: f.fund,
}));
})
.then(this.props.changePensionFunds);
};
onChangeCountry = country => {
this.getPensionFunds(country);
this.props.changeCountry(country);
};
changeFund = _id => {
const contact = find(this.props.pensionFunds, { _id });
this.props.changeFund(contact);
};
render() {
return (
<div className="SelectPensionFund">
<FormGroup>
<SelectCountry
value={this.props.country}
name="country"
filter={SUPPORTED_COUNTRIES}
label={
<FormattedMessage
id="email_tool.form.select_country"
defaultMessage="Select country (default)"
/>
}
className="form-control"
errorMessage={this.props.errors.country}
onChange={this.onChangeCountry}
/>
</FormGroup>
<FormGroup>
<Select
className="form-control"
value={this.props.fundId}
errorMessage={this.props.errors.fund}
label={
<FormattedMessage
id="email_pension.form.select_target"
defaultMessage="Select a fund (default)"
/>
}
name="select-fund"
options={this.props.pensionFunds}
onChange={this.changeFund}
/>
</FormGroup>
<SuggestFund />
</div>
);
}
}
function mapStateToProps(state) {
return {
country: state.emailTarget.country,
pensionFunds: state.emailTarget.pensionFunds,
fundId: state.emailTarget.fundId,
fund: state.emailTarget.fund,
};
}
function mapDispatchToProps(disp) {
return {
changeCountry: country => {
// We could try to have only one place in the state
// with the country (how will that affect other reducers?)
// TODO: Investigate this
disp(changeCountry(country));
disp(changeConsentCountry(country));
},
changePensionFunds: funds => disp(changePensionFunds(funds)),
changeFund: fund => disp(changeFund(fund)),
};
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(SelectPensionFund);
|
app/javascript/mastodon/components/dropdown_menu.js | 8796n/mastodon | import React from 'react';
import Dropdown, { DropdownTrigger, DropdownContent } from 'react-simple-dropdown';
import PropTypes from 'prop-types';
class DropdownMenu extends React.PureComponent {
static propTypes = {
icon: PropTypes.string.isRequired,
items: PropTypes.array.isRequired,
size: PropTypes.number.isRequired,
direction: PropTypes.string,
ariaLabel: PropTypes.string
};
static defaultProps = {
ariaLabel: "Menu"
};
state = {
direction: 'left'
};
setRef = (c) => {
this.dropdown = c;
}
handleClick = (i, e) => {
const { action } = this.props.items[i];
if (typeof action === 'function') {
e.preventDefault();
action();
this.dropdown.hide();
}
}
renderItem = (item, i) => {
if (item === null) {
return <li key={ 'sep' + i } className='dropdown__sep' />;
}
const { text, action, href = '#' } = item;
return (
<li className='dropdown__content-list-item' key={ text + i }>
<a href={href} target='_blank' rel='noopener' onClick={this.handleClick.bind(this, i)} className='dropdown__content-list-link'>
{text}
</a>
</li>
);
}
render () {
const { icon, items, size, direction, ariaLabel } = this.props;
const directionClass = (direction === "left") ? "dropdown__left" : "dropdown__right";
return (
<Dropdown ref={this.setRef}>
<DropdownTrigger className='icon-button' style={{ fontSize: `${size}px`, width: `${size}px`, lineHeight: `${size}px` }} aria-label={ariaLabel}>
<i className={ `fa fa-fw fa-${icon} dropdown__icon` } aria-hidden={true} />
</DropdownTrigger>
<DropdownContent className={directionClass}>
<ul className='dropdown__content-list'>
{items.map(this.renderItem)}
</ul>
</DropdownContent>
</Dropdown>
);
}
}
export default DropdownMenu;
|
src/svg-icons/content/block.js | barakmitz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ContentBlock = (props) => (
<SvgIcon {...props}>
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z"/>
</SvgIcon>
);
ContentBlock = pure(ContentBlock);
ContentBlock.displayName = 'ContentBlock';
ContentBlock.muiName = 'SvgIcon';
export default ContentBlock;
|
src/components/Spinner/index.js | HenriBeck/materialize-react | // @flow strict-local
import React from 'react';
import PropTypes from 'prop-types';
import getNotDeclaredProps from 'react-get-not-declared-props';
import Sheet, { type Data } from './Sheet';
type Props = {
active: boolean,
className: string,
color: 'primary' | 'accent',
};
type State = { animationName: string | null };
export default class Spinner extends React.PureComponent<Props, State> {
static propTypes = {
active: PropTypes.bool,
className: PropTypes.string,
color: PropTypes.oneOf([
'primary',
'accent',
]),
};
static defaultProps = {
active: false,
className: '',
color: 'primary',
};
state = { animationName: null };
static getDerivedStateFromProps(nextProps: Props, state: State): State | null {
if (state.animationName === null && !nextProps.active) {
return null;
}
return { animationName: `Spinner--fade-${nextProps.active ? 'in' : 'out'}` };
}
render() {
const data: Data = {
color: this.props.color,
animationName: this.state.animationName,
};
return (
<Sheet data={data}>
{({ classes }) => (
<div
{...getNotDeclaredProps(this.props, Spinner)}
className={`${classes.spinner} ${this.props.className}`}
>
<div className={classes.container}>
<div className={classes.layer}>
<div className={classes.clipperLeft} />
<div className={classes.clipperRight} />
</div>
</div>
</div>
)}
</Sheet>
);
}
}
|
src/svg-icons/action/supervisor-account.js | barakmitz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionSupervisorAccount = (props) => (
<SvgIcon {...props}>
<path d="M16.5 12c1.38 0 2.49-1.12 2.49-2.5S17.88 7 16.5 7C15.12 7 14 8.12 14 9.5s1.12 2.5 2.5 2.5zM9 11c1.66 0 2.99-1.34 2.99-3S10.66 5 9 5C7.34 5 6 6.34 6 8s1.34 3 3 3zm7.5 3c-1.83 0-5.5.92-5.5 2.75V19h11v-2.25c0-1.83-3.67-2.75-5.5-2.75zM9 13c-2.33 0-7 1.17-7 3.5V19h7v-2.25c0-.85.33-2.34 2.37-3.47C10.5 13.1 9.66 13 9 13z"/>
</SvgIcon>
);
ActionSupervisorAccount = pure(ActionSupervisorAccount);
ActionSupervisorAccount.displayName = 'ActionSupervisorAccount';
ActionSupervisorAccount.muiName = 'SvgIcon';
export default ActionSupervisorAccount;
|
src/svg-icons/file/cloud.js | pancho111203/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let FileCloud = (props) => (
<SvgIcon {...props}>
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"/>
</SvgIcon>
);
FileCloud = pure(FileCloud);
FileCloud.displayName = 'FileCloud';
FileCloud.muiName = 'SvgIcon';
export default FileCloud;
|
index.js | intrepion/redux-form-example-simple | import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import App from './containers/App';
import configureStore from './store/configureStore';
const store = configureStore();
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('app')
);
|
src/helpers/universalRouter.js | rammano3/react-redux-universal-hot-example | import React from 'react';
import Router from 'react-router';
import createRoutes from '../routes';
import {Provider} from 'react-redux';
const getFetchData = (component = {}) => {
return component.WrappedComponent ?
getFetchData(component.WrappedComponent) :
component.fetchData;
};
export function createTransitionHook(store) {
return (nextState, transition, callback) => {
const { params, location: { query } } = nextState;
const promises = nextState.branch
.map(route => route.component) // pull out individual route components
.filter((component) => getFetchData(component)) // only look at ones with a static fetchData()
.map(getFetchData) // pull out fetch data methods
.map(fetchData => fetchData(store, params, query || {})); // call fetch data methods and save promises
Promise.all(promises)
.then(() => {
callback(); // can't just pass callback to then() because callback assumes first param is error
}, (error) => {
callback(error);
});
};
}
export default function universalRouter(location, history, store) {
const routes = createRoutes(store);
return new Promise((resolve, reject) => {
Router.run(routes, location, [createTransitionHook(store)], (error, initialState, transition) => {
if (error) {
return reject(error);
}
if (transition && transition.redirectInfo) {
return resolve({
transition,
isRedirect: true
});
}
if (history) { // only on client side
initialState.history = history;
}
const component = (
<Provider store={store} key="provider">
{() => <Router {...initialState} children={routes}/>}
</Provider>
);
return resolve({
component,
isRedirect: false
});
});
});
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.