path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
src/components/Sidebar/Contacts/Contacts.js | nicklanasa/nicklanasa.github.io | // @flow strict
import React from 'react';
import { getContactHref, getIcon } from '../../../utils';
import Icon from '../../Icon';
import styles from './Contacts.module.scss';
type Props = {
contacts: {
[string]: string,
},
};
const Contacts = ({ contacts }: Props) => (
<div className={styles['contacts']}>
<ul className={styles['contacts__list']}>
{Object.keys(contacts).map((name) => (!contacts[name] ? null : (
<li className={styles['contacts__list-item']} key={name}>
<a
className={styles['contacts__list-item-link']}
href={getContactHref(name, contacts[name])}
rel="noopener noreferrer"
target="_blank"
>
<Icon name={name} icon={getIcon(name)} />
</a>
</li>
)))}
</ul>
</div>
);
export default Contacts;
|
src/svg-icons/action/offline-pin.js | kittyjumbalaya/material-components-web | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionOfflinePin = (props) => (
<SvgIcon {...props}>
<path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm5 16H7v-2h10v2zm-6.7-4L7 10.7l1.4-1.4 1.9 1.9 5.3-5.3L17 7.3 10.3 14z"/>
</SvgIcon>
);
ActionOfflinePin = pure(ActionOfflinePin);
ActionOfflinePin.displayName = 'ActionOfflinePin';
ActionOfflinePin.muiName = 'SvgIcon';
export default ActionOfflinePin;
|
wwwroot/app/src/components/base/buttons/Button.js | AlinCiocan/PlanEatSave | import React from 'react';
import classNames from 'classnames';
const Button = (props) => {
const buttonClasses = classNames({
'pes-button': true,
'pes-button--ghost-button': props.ghostButton
});
return (
<button
className={buttonClasses}
onClick={props.onClick}
>
{props.text}
</button>
);
};
export default Button; |
indico/web/client/js/jquery/widgets/track_role_widget.js | mic4ael/indico | // This file is part of Indico.
// Copyright (C) 2002 - 2020 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.
import React from 'react';
import ReactDOM from 'react-dom';
import {TrackACLField} from 'indico/react/components';
(function($) {
$.widget('indico.trackrolewidget', {
options: {
containerElement: null, // the actual widget containing element
permissionsInfo: null,
eventId: null,
eventRoles: null,
categoryRoles: null,
},
_updateValue(newValue, trackId) {
const roleData = JSON.parse(this.element.val());
roleData[trackId] = newValue;
this.element.val(JSON.stringify(roleData));
},
_renderACLField(trackId, value) {
const onChange = newValue => this._updateValue(newValue, trackId);
const element = document.querySelector(`#track-roles-${trackId}`);
const component = React.createElement(TrackACLField, {
value,
permissionInfo: this.options.permissionsInfo,
eventId: this.options.eventId,
eventRoles: this.options.eventRoles,
categoryRoles: this.options.categoryRoles,
onChange,
});
ReactDOM.render(component, element);
},
_create() {
const roleData = JSON.parse(this.element.val());
Object.entries(roleData).forEach(([trackId, value]) => {
trackId = trackId === '*' ? 'global' : trackId;
this._renderACLField(trackId, value);
});
},
});
})(jQuery);
|
src/utils/domUtils.js | azmenak/react-bootstrap | import React from 'react';
let canUseDom = !!(
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
);
/**
* Get elements owner document
*
* @param {ReactComponent|HTMLElement} componentOrElement
* @returns {HTMLElement}
*/
function ownerDocument(componentOrElement) {
let elem = React.findDOMNode(componentOrElement);
return (elem && elem.ownerDocument) || document;
}
function ownerWindow(componentOrElement) {
let doc = ownerDocument(componentOrElement);
return doc.defaultView
? doc.defaultView
: doc.parentWindow;
}
/**
* get the active element, safe in IE
* @return {HTMLElement}
*/
function getActiveElement(componentOrElement){
let doc = ownerDocument(componentOrElement);
try {
return doc.activeElement || doc.body;
} catch (e) {
return doc.body;
}
}
/**
* Shortcut to compute element style
*
* @param {HTMLElement} elem
* @returns {CssStyle}
*/
function getComputedStyles(elem) {
return ownerDocument(elem).defaultView.getComputedStyle(elem, null);
}
/**
* Get elements offset
*
* TODO: REMOVE JQUERY!
*
* @param {HTMLElement} DOMNode
* @returns {{top: number, left: number}}
*/
function getOffset(DOMNode) {
if (window.jQuery) {
return window.jQuery(DOMNode).offset();
}
let docElem = ownerDocument(DOMNode).documentElement;
let box = { top: 0, left: 0 };
// If we don't have gBCR, just use 0,0 rather than error
// BlackBerry 5, iOS 3 (original iPhone)
if ( typeof DOMNode.getBoundingClientRect !== 'undefined' ) {
box = DOMNode.getBoundingClientRect();
}
return {
top: box.top + window.pageYOffset - docElem.clientTop,
left: box.left + window.pageXOffset - docElem.clientLeft
};
}
/**
* Get elements position
*
* TODO: REMOVE JQUERY!
*
* @param {HTMLElement} elem
* @param {HTMLElement?} offsetParent
* @returns {{top: number, left: number}}
*/
function getPosition(elem, offsetParent) {
let offset,
parentOffset;
if (window.jQuery) {
if (!offsetParent) {
return window.jQuery(elem).position();
}
offset = window.jQuery(elem).offset();
parentOffset = window.jQuery(offsetParent).offset();
// Get element offset relative to offsetParent
return {
top: offset.top - parentOffset.top,
left: offset.left - parentOffset.left
};
}
parentOffset = {top: 0, left: 0};
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
if (getComputedStyles(elem).position === 'fixed' ) {
// We assume that getBoundingClientRect is available when computed position is fixed
offset = elem.getBoundingClientRect();
} else {
if (!offsetParent) {
// Get *real* offsetParent
offsetParent = offsetParentFunc(elem);
}
// Get correct offsets
offset = getOffset(elem);
if ( offsetParent.nodeName !== 'HTML') {
parentOffset = getOffset(offsetParent);
}
// Add offsetParent borders
parentOffset.top += parseInt(getComputedStyles(offsetParent).borderTopWidth, 10);
parentOffset.left += parseInt(getComputedStyles(offsetParent).borderLeftWidth, 10);
}
// Subtract parent offsets and element margins
return {
top: offset.top - parentOffset.top - parseInt(getComputedStyles(elem).marginTop, 10),
left: offset.left - parentOffset.left - parseInt(getComputedStyles(elem).marginLeft, 10)
};
}
/**
* Get an element's size
*
* @param {HTMLElement} elem
* @returns {{width: number, height: number}}
*/
function getSize(elem) {
let rect = {
width: elem.offsetWidth || 0,
height: elem.offsetHeight || 0
};
if (typeof elem.getBoundingClientRect !== 'undefined') {
let {width, height} = elem.getBoundingClientRect();
rect.width = width || rect.width;
rect.height = height || rect.height;
}
return rect;
}
/**
* Get parent element
*
* @param {HTMLElement?} elem
* @returns {HTMLElement}
*/
function offsetParentFunc(elem) {
let docElem = ownerDocument(elem).documentElement;
let offsetParent = elem.offsetParent || docElem;
while ( offsetParent && ( offsetParent.nodeName !== 'HTML' &&
getComputedStyles(offsetParent).position === 'static' ) ) {
offsetParent = offsetParent.offsetParent;
}
return offsetParent || docElem;
}
/**
* Cross browser .contains() polyfill
* @param {HTMLElement} elem
* @param {HTMLElement} inner
* @return {bool}
*/
function contains(elem, inner){
function ie8Contains(root, node) {
while (node) {
if (node === root) {
return true;
}
node = node.parentNode;
}
return false;
}
return (elem && elem.contains)
? elem.contains(inner)
: (elem && elem.compareDocumentPosition)
? elem === inner || !!(elem.compareDocumentPosition(inner) & 16)
: ie8Contains(elem, inner);
}
export default {
canUseDom,
contains,
ownerWindow,
ownerDocument,
getComputedStyles,
getOffset,
getPosition,
getSize,
activeElement: getActiveElement,
offsetParent: offsetParentFunc
};
|
src/svg-icons/action/assessment.js | ngbrown/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionAssessment = (props) => (
<SvgIcon {...props}>
<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"/>
</SvgIcon>
);
ActionAssessment = pure(ActionAssessment);
ActionAssessment.displayName = 'ActionAssessment';
ActionAssessment.muiName = 'SvgIcon';
export default ActionAssessment;
|
src/components/ProgressBar/ProgressBar.js | miker169/ps-react-miker169 | import React from 'react';
import PropTypes from 'prop-types';
class ProgressBar extends React.Component {
getColor = (percent) => {
if (this.props.percent === 100) return 'green';
return this.props.percent > 50 ? 'lightgreen' : 'red';
}
getWidthAsPercentOfTotalWidth = () => {
return parseInt(this.props.width * (this.props.percent / 100), 10);
}
render() {
const {percent, width, height} = this.props;
return (
<div style={{border: 'solid 1px lightgray', width: width}}>
<div style={{
width: this.getWidthAsPercentOfTotalWidth(),
height,
backgroundColor: this.getColor(percent)
}} ></div>
</div>
);
}
}
ProgressBar.propTypes = {
/** Percent of progress completed */
percent: PropTypes.number.isRequired,
/** Bar width */
width: PropTypes.number.isRequired,
/** Bar height */
height: PropTypes.number
};
ProgressBar.defaultProps = {
height: 5
};
export default ProgressBar; |
react/examples/Code/React_Redux/src/components/App.js | jsperts/workshop_unterlagen | import React from 'react';
import ClickContainer from '../containers/Click';
function App() {
return <ClickContainer />;
}
export default App;
|
packages/bonde-admin/src/app/context/wrapper.js | ourcities/rebu-client | import React from 'react'
import ApplicationContextTypes from './types'
class Wrapper extends React.Component {
render () {
const { children, component: Component, ...props } = this.props
const { app } = this.context
return (
<Component {...props} app={app}>
{children}
</Component>
)
}
}
Wrapper.contextTypes = ApplicationContextTypes
export default Wrapper
|
app/react-icons/fa/user-secret.js | scampersand/sonos-front | import React from 'react';
import IconBase from 'react-icon-base';
export default class FaUserSecret extends React.Component {
render() {
return (
<IconBase viewBox="0 0 40 40" {...this.props}>
<g><path d="m17.4 34.3l2.1-10-2.1-2.9-2.9-1.4z m5.7 0l2.8-14.3-2.8 1.4-2.2 2.9z m3.5-22.6q0 0 0-0.1-0.3-0.2-2.2-0.2-1.6 0-3.7 0.5-0.2 0-0.5 0t-0.5 0q-2.1-0.5-3.7-0.5-1.9 0-2.1 0.2-0.1 0.1-0.1 0.1 0 0.4 0.1 0.6 0 0.1 0.1 0.2t0.2 0.2q0.1 0.1 0.2 0.5t0.1 0.4 0.2 0.4 0.2 0.4 0.2 0.3 0.3 0.3 0.3 0.2 0.4 0.2 0.4 0.1 0.6 0q0.8 0 1.3-0.2t0.7-0.7 0.3-0.8 0.3-0.6 0.4-0.3h0.3q0.2 0 0.3 0.3t0.3 0.6 0.3 0.8 0.7 0.7 1.4 0.2q0.3 0 0.5 0t0.5-0.1 0.4-0.2 0.3-0.2 0.2-0.3 0.2-0.3 0.2-0.4 0.2-0.4 0.2-0.4 0.1-0.5q0.1-0.1 0.2-0.2t0.2-0.2q0-0.2 0-0.6z m9.3 19.7q0 2.7-1.6 4.2t-4.3 1.5h-19.5q-2.7 0-4.4-1.5t-1.6-4.2q0-1.4 0.1-2.7t0.4-2.8 0.9-2.7 1.4-2.3 2.1-1.7l-2-4.9h4.7q-0.5-1.4-0.5-2.9 0-0.2 0.1-0.7-4.3-0.9-4.3-2.1 0-1.3 4.6-2.2 0.4-1.4 1.2-3t1.6-2.6q0.7-0.8 1.7-0.8 0.6 0 1.8 0.7t1.9 0.7 1.9-0.7 1.9-0.7q0.9 0 1.7 0.8 0.8 1 1.5 2.6t1.2 3q4.7 0.9 4.7 2.2 0 1.2-4.4 2.1 0.2 1.8-0.4 3.6h4.8l-1.9 5q1.5 0.7 2.4 2.2t1.5 3.2 0.7 3.3 0.1 3.4z"/></g>
</IconBase>
);
}
}
|
src/components/cta/CTA.js | djErock/Telemed-Website | import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Connect } from "react-redux";
import { ImportAll } from '../../util/helpers'
const ctaImages = ImportAll(require.context('../../img/cta', false, /\.(png|jpe?g|svg)$/));
import './cta.css';
//@Connect()
class CTA extends Component {
constructor(props) {
super(props);
this.state = {
presets: [{
type: "about",
title: "What is Telemed?",
copy: "Caduceus USA provides your employees with a remote diagnosis and treatment by means of video and telecommunications technology. Our Telemed providers to evaluate, diagnose and treat patients without the need for an in-person visit.",
img: "employee_to_provider.jpg",
altText: "connect employee to provider",
linkText: "Learn More"
},{
type: "contact",
title: "Any Questions?",
copy: "Do you have questions about how Telemed relates to worker's comp, work status or as well as provider certification updates and Caduceus USA network coverage. Give us a call if you have any questions or concerns by clicking the link below.",
img: "questions_about_telemed.jpg",
altText: "questions about telemed",
linkText: "Call Us Today!"
},{
type: "enroll",
title: "Providers are available now",
copy: "We have a large network of certified providers waiting to handle your employees injuries at a moment's notice. All you have to do is click the link below and enroll your company's protocol into our world class Electronic Medical Records system.",
img: "doctors_available_today.jpg",
altText: "doctors available today",
linkText: "Enroll Today"
}],
actionState: {}
}
}
componentDidMount() {
for (var i = 0; i < this.state.presets.length; i++) {
if (this.props.type === this.state.presets[i].type) {
this.setState({actionState: this.state.presets[i]});
}
}
};
componentWillUnmount() {
this.setState({ actionState: {} });
};
render() {
return (
<aside>
<div className={this.state.actionState.type}>
<h2>{this.state.actionState.title}</h2>
<hr />
<img src={ctaImages[this.state.actionState.img]} alt={this.state.actionState.altText} />
<div className="CTAContent">
<p>{this.state.actionState.copy}</p>
<Link className="action" to={this.props.destination}>{this.state.actionState.linkText}</Link>
</div>
</div>
</aside>
);
}
};
export default CTA; |
src/svg-icons/action/done-all.js | hwo411/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionDoneAll = (props) => (
<SvgIcon {...props}>
<path d="M18 7l-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41L6 19l1.41-1.41L1.83 12 .41 13.41z"/>
</SvgIcon>
);
ActionDoneAll = pure(ActionDoneAll);
ActionDoneAll.displayName = 'ActionDoneAll';
ActionDoneAll.muiName = 'SvgIcon';
export default ActionDoneAll;
|
packages/mineral-ui-icons/src/IconFastForward.js | mineral-ui/mineral-ui | /* @flow */
import React from 'react';
import Icon from 'mineral-ui/Icon';
import type { IconProps } from 'mineral-ui/Icon/types';
/* eslint-disable prettier/prettier */
export default function IconFastForward(props: IconProps) {
const iconProps = {
rtl: false,
...props
};
return (
<Icon {...iconProps}>
<g>
<path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/>
</g>
</Icon>
);
}
IconFastForward.displayName = 'IconFastForward';
IconFastForward.category = 'av';
|
src/views/pages/not-found/not-found.js | Metaburn/doocrate | import React from 'react';
import './not-found.css';
import LoaderUnicorn from '../../components/loader-unicorn/loader-unicorn';
import Button from '../../components/button';
const NotFound = () => (
<div className="g-row not-found">
<br />
<h1>404 - איבדת את הדרך. לא מצאנו את הדף הזה.</h1>
<br />
<Button className="button-small">
<a href="/">חזור לדרך המרכזית</a>
</Button>
<LoaderUnicorn isShow={true} />
</div>
);
NotFound.propTypes = {};
export default NotFound;
|
frontend2/src/js/Game/GameContainer.js | cheijken/stonepaperscissors | import React, { Component } from 'react';
class GameContainer extends Component {
constructor(props){
super(props);
}
render() {
return (
<div>
<ul>
<li><a href="">Home</a></li>
<li><a href="">Home</a></li>
<li><a href="">Home</a></li>
</ul>
</div>
);
}
}
export default GameContainer;
|
src/components/Labels.js | jeffslofish/open-source-help-wanted | import React from 'react';
import * as chromatism from 'chromatism';
import PropTypes from 'prop-types';
const Labels = ({ labels }) => {
return (
<div className='issue-labels'>
{labels.map((label, i) => {
const style = {
backgroundColor: '#' + label.color,
color: chromatism.contrastRatio('#' + label.color).hex,
};
return (
<span key={i} className='issue-label' style={style}>
{label.name}
</span>
);
})}
</div>
);
};
Labels.propTypes = {
labels: PropTypes.arrayOf(
PropTypes.shape({
color: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
})
),
};
export default Labels;
|
client/src/components/department/DepartmentForm.js | yegor-sytnyk/contoso-express | import React from 'react';
import TextInput from '../common/TextInput';
import NumberInput from '../common/NumbertInput';
import SelectInput from '../common/SelectInput';
import DateTimePicker from '../common/DateTimePicker';
import _ from 'lodash';
const DepartmentForm = ({department, allInstructors, onChange, errors}) => {
return (
<form>
<TextInput
name="name"
label="Name"
value={department.name}
onChange={onChange}
placeholder="Name"
error={errors.name}
/>
<NumberInput
name="budget"
label="Budget"
value={department.budget.toString()}
onChange={onChange}
error={errors.budget}
/>
<DateTimePicker
name="date"
label="Start Date"
value={department.startDate}
onChange={onChange}
error={errors.date}
/>
<SelectInput
name="instructorId"
label="Administrator"
value={department.instructorId.toString()}
defaultOption="Select Administrator"
options={allInstructors}
onChange={onChange}
error={errors.instructorId}
/>
</form>
);
};
DepartmentForm.propTypes = {
department: React.PropTypes.object.isRequired,
allInstructors: React.PropTypes.array,
onChange: React.PropTypes.func.isRequired,
errors: React.PropTypes.object
};
export default DepartmentForm; |
src-client/scripts/lugg-view-controller.js | PaulRSwift/iLuggit | import Backbone from 'backbone'
import React from 'react'
import $ from 'jquery'
import ACTIONS from './ACTIONS.js'
import STORE from './STORE.js'
import CargoDisplay from './display-cargo-details.js'
import {LuggProfile, LuggView} from './lugg-list.js'
import PackAuthView from './pack-auth-view.js'
import LuggAuthView from './lugg-auth-view.js'
import HomeView from './home-page.js'
import CreateLugg from './create-lugg.js'
import Sandbox from './sandbox.js'
import TruckInfo from './truckinfo.js'
import WhatWeDo from './whatwedo.js'
import Reviews from './reviews.js'
let AppController = React.createClass({
getInitialState: function(){
return STORE.getLuggData()
},
componentWillMount: function(){
let self = this
ACTIONS.fetchLuggData(),
ACTIONS.fetchReview(),
ACTIONS.getCurrentUser()
STORE.onChange(function(){
let newState = STORE.getLuggData()
self.setState(newState)
//console.log('newState', newState)
})
},
render: function(){
console.log("stateeee", this.state);
switch(this.props.routedFrom){
case "CargoDisplay":
return <CargoDisplay newLuggData = {this.state.newLuggData} id={this.props.modelId} />
break;
case "LuggProfile":
return <LuggProfile newLuggData= {this.state.newLuggData}/>
break;
case "HomeView":
return <HomeView />
break;
case "LuggAuthView":
return <LuggAuthView />
break;
case "PackAuthView":
return <PackAuthView />
break;
case "CreateLugg" :
return <CreateLugg newLuggData={this.state.newLuggData} modalWindowInfo ={this.state.modalWindowSettings} />
break;
case "Sandbox":
return <Sandbox />
break;
case "TruckInfo":
return <TruckInfo />
break;
case "WhatWeDo":
return <WhatWeDo />
break;
case "Reviews":
return <Reviews newReviewData = {this.state.newReviewData}/>
break;
default:
return
<div>
<h1>Please Return to the home page</h1>
<a href = "#"><i className = "fa fa-home fa-2x" aria-hidden = "true"></i></a>
</div>
}
}
})
module.exports = AppController
|
src/components/ChatApp/MessageListItem/MessageListItem.react.js | uday96/chat.susi.ai | import React from 'react';
import PropTypes from 'prop-types';
import Emojify from 'react-emojione';
import TextHighlight from 'react-text-highlight';
import {AllHtmlEntities} from 'html-entities';
import $ from 'jquery';
import { imageParse, processText,
renderTiles, drawMap, drawTable,
renderMessageFooter, renderAnchor } from './helperFunctions.react.js';
import VoicePlayer from './VoicePlayer';
import UserPreferencesStore from '../../../stores/UserPreferencesStore';
import * as Actions from '../../../actions/';
import { injectIntl } from 'react-intl';
// Format Date for internationalization
const PostDate = injectIntl(({date, intl}) => (
<span title={intl.formatDate(date, {
year: 'numeric',
month: 'numeric',
day: 'numeric',
})}>
{intl.formatDate(date, {
year: 'numeric',
month: 'numeric',
day: 'numeric',
})}
</span>
));
const entities = new AllHtmlEntities();
class MessageListItem extends React.Component {
constructor(props){
super(props);
this.state = {
play: false,
}
}
// Triggered when the voice player is started
onStart = () => {
this.setState({ play: true });
}
// Triggered when the voice player has finished
onEnd = () => {
this.setState({ play: false });
Actions.resetVoice();
}
render() {
let {message} = this.props;
let latestUserMsgID = null;
if(this.props.latestUserMsgID){
latestUserMsgID = this.props.latestUserMsgID;
}
if(this.props.message.type === 'date'){
return(
<li className='message-list-item'>
<section className='container-date'>
<div className='message-text'>
<PostDate date={message.date}/>
</div>
</section>
</li>
);
}
let stringWithLinks = this.props.message.text;
let replacedText = '';
let markMsgID = this.props.markID;
if(this.props.message.hasOwnProperty('mark')
&& markMsgID) {
let matchString = this.props.message.mark.matchText;
let isCaseSensitive = this.props.message.mark.isCaseSensitive;
if(stringWithLinks){
let htmlText = entities.decode(stringWithLinks);
let imgText = imageParse(htmlText);
let markedText = [];
let matchStringarr = [];
matchStringarr.push(matchString);
imgText.forEach((part,key)=>{
if(typeof(part) === 'string'){
if(this.props.message.id === markMsgID){
markedText.push(
<TextHighlight
key={key}
highlight={matchString}
text={part}
markTag='em'
caseSensitive={isCaseSensitive}
/>
);
}
else{
markedText.push(
<TextHighlight
key={key}
highlight={matchString}
text={part}
caseSensitive={isCaseSensitive}
/>
);
}
}
else{
markedText.push(part);
}
});
replacedText = <Emojify>{markedText}</Emojify>;
};
}
else{
if(stringWithLinks){
replacedText = processText(stringWithLinks);
};
}
let messageContainerClasses = 'message-container ' + message.authorName;
if(this.props.message.hasOwnProperty('response')){
if(Object.keys(this.props.message.response).length > 0){
let data = this.props.message.response;
let actions = this.props.message.actions;
let listItems = [];
let mapIndex = actions.indexOf('map');
let mapAnchor = null;
if(mapIndex>-1){
if(actions.indexOf('anchor')){
let anchorIndex = actions.indexOf('anchor');
let link = data.answers[0].actions[anchorIndex].link;
let text = data.answers[0].actions[anchorIndex].text;
mapAnchor = renderAnchor(text,link);
}
actions = ['map'];
}
let noResultsFound = false;
let lastAction = actions[actions.length - 1];
actions.forEach((action,index)=>{
let showFeedback = lastAction===action;
switch(action){
case 'answer': {
if(actions.indexOf('rss') > -1 || actions.indexOf('websearch') > -1){
showFeedback = true;
}
if(data.answers[0].data[0].type === 'gif'){
let gifSource = data.answers[0].data[0].embed_url;
listItems.push(
<li className='message-list-item' key={action+index}>
<section className={messageContainerClasses}>
<div className='message-text'>
<iframe src={gifSource}
frameBorder="0"
allowFullScreen>
</iframe>
</div>
{renderMessageFooter(message,latestUserMsgID,showFeedback)}
</section>
</li>
);
}
else{
listItems.push(
<li className='message-list-item' key={action+index}>
<section className={messageContainerClasses}>
<div className='message-text'>{replacedText}</div>
{renderMessageFooter(message,latestUserMsgID,showFeedback)}
</section>
</li>
);
}
break
}
case 'anchor': {
let link = data.answers[0].actions[index].link;
let text = data.answers[0].actions[index].text;
listItems.push(
<li className='message-list-item' key={action+index}>
<section className={messageContainerClasses}>
<div className='message-text'>
{renderAnchor(text,link)}
</div>
{renderMessageFooter(message,latestUserMsgID,showFeedback)}
</section>
</li>
);
break
}
case 'map': {
index = mapIndex;
let lat = parseFloat(data.answers[0].actions[index].latitude);
let lng = parseFloat(data.answers[0].actions[index].longitude);
let zoom = parseFloat(data.answers[0].actions[index].zoom);
let mymap;
let mapNotFound = 'Map was not made';
if(isNaN(lat) || isNaN(lng)){
$.ajax({
url: 'https://cors-anywhere.herokuapp.com/http://freegeoip.net/json/',
timeout: 3000,
async: true,
success: function (response) {
mymap = drawMap(response.latitude,response.longitude,zoom);
listItems.push(
<li className='message-list-item' key={action+index}>
<section className={messageContainerClasses} style={{'width' : '80%'}}>
<div className='message-text'>{replacedText}</div>
<div>{mapAnchor}</div>
<br/>
<div>{mymap}</div>
{renderMessageFooter(message,latestUserMsgID,
showFeedback)}
</section>
</li>
);
},
error: function(xhr, status, error) {
mymap = mapNotFound;
}
});
}
else{
mymap = drawMap(lat,lng,zoom);
}
listItems.push(
<li className='message-list-item' key={action+index}>
<section className={messageContainerClasses} style={{'width' : '80%'}}>
<div className='message-text'>{replacedText}</div>
<div>{mapAnchor}</div>
<br/>
<div>{mymap}</div>
{renderMessageFooter(message,latestUserMsgID,showFeedback)}
</section>
</li>
);
break
}
case 'table': {
let coloumns = data.answers[0].actions[index].columns;
let count = data.answers[0].actions[index].count;
let table = drawTable(coloumns,data.answers[0].data,count);
listItems.push(
<li className='message-list-item' key={action+index}>
<section className={messageContainerClasses}>
<div><div className='message-text'>{table}</div></div>
{renderMessageFooter(message,latestUserMsgID,showFeedback)}
</section>
</li>
);
break
}
case 'rss':{
let rssTiles = this.props.message.rssResults;
if(rssTiles.length === 0){
noResultsFound = true;
}
let sliderClass = 'swipe-rss-websearch';
if (window.matchMedia('only screen and (max-width: 768px)').matches){
// for functionality on screens smaller than 768px
sliderClass = '';
}
listItems.push(
<div className={sliderClass} key={action+index}>
{renderTiles(rssTiles)}
</div>
);
break;
}
case 'websearch': {
let websearchTiles = this.props.message.websearchresults;
if(websearchTiles.length === 0){
noResultsFound = true;
}
let sliderClass = 'swipe-rss-websearch';
if (window.matchMedia('only screen and (max-width: 768px)').matches){
// for functionality on screens smaller than 768px
sliderClass = '';
}
listItems.push(
<div className={sliderClass} key={action+index}>
{renderTiles(websearchTiles)}
</div>
);
break;
}
default:
// do nothing
}
});
if(noResultsFound && this.props.message.text === 'I found this on the web:'){
listItems.splice(0,1);
}
// Only set voice Outputs for text responses
let voiceOutput;
if(this.props.message.text!==undefined){
// Remove all hyper links
voiceOutput = this.props.message.text.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '');
}
else{
voiceOutput= '';
}
let locale = document.documentElement.getAttribute('lang');
if(locale === null || locale === undefined){
locale = UserPreferencesStore.getTTSLanguage();
}
let ttsLanguage = this.props.message.lang ?
this.props.message.lang : locale;
return (<div>{listItems}
{ this.props.message.voice &&
(<VoicePlayer
play
text={voiceOutput}
rate={UserPreferencesStore.getSpeechRate()}
pitch={UserPreferencesStore.getSpeechPitch()}
lang={ttsLanguage}
onStart={this.onStart}
onEnd={this.onEnd}
/>)}
</div>);
}
}
return (
<li className='message-list-item'>
<section className={messageContainerClasses}>
<div className='message-text'>{replacedText}</div>
{renderMessageFooter(message,latestUserMsgID,true)}
</section>
</li>
);
}
};
MessageListItem.propTypes = {
message: PropTypes.object,
markID: PropTypes.string,
latestUserMsgID: PropTypes.string,
};
export default MessageListItem;
|
src/components/ChatArea.js | zalmoxisus/react-chat | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import styles from '../chat.scss';
import Message from './message/Message';
export default class ChatArea extends Component {
componentDidMount() {
this.scrollDown = true;
setTimeout(this.updateScrollTop, 0);
}
componentWillReceiveProps() {
const node = this.node;
if (!node) {
this.scrollDown = true;
} else {
const { scrollTop, offsetHeight, scrollHeight } = node;
this.scrollDown = Math.abs(scrollHeight - (scrollTop + offsetHeight)) < 50;
}
}
componentDidUpdate() {
this.updateScrollTop();
}
getRef = node => {
this.node = node;
this.updateScrollTop();
};
updateScrollTop = () => {
if (!this.scrollDown || !this.node) return;
this.node.scrollTop = this.node.scrollHeight;
};
render() {
const { messages, ...rest } = this.props;
return (
<div ref={this.getRef} className={styles.container}>
{messages.map(message =>
<Message
key={message._id}
message={message}
{...rest}
/>
)}
</div>
);
}
}
ChatArea.propTypes = {
messages: PropTypes.array.isRequired,
user: PropTypes.shape({
id: PropTypes.any
}).isRequired,
showAvatars: PropTypes.bool,
avatarPreviewPosition: PropTypes.string,
updateInputValue: PropTypes.func,
UserMenu: PropTypes.any,
onTranslate: PropTypes.func,
translateLanguages: PropTypes.array,
nativeLng: PropTypes.string,
handleModal: PropTypes.func,
voices: PropTypes.array,
manageMessage: PropTypes.func,
ban: PropTypes.func
};
|
src/routes/UIElement/dataTable/index.js | cuijiaxu/react-front | import React from 'react'
import { DataTable } from '../../../components'
import { Table, Row, Col, Card, Select } from 'antd'
class DataTablePage extends React.Component {
constructor (props) {
super(props)
this.state = { filterCase: {
gender: '',
} }
}
handleSelectChange = (gender) => {
this.setState({
filterCase: {
gender,
},
})
}
render () {
const { filterCase } = this.state
const staticDataTableProps = {
dataSource: [{ key: '1', name: 'John Brown', age: 24, address: 'New York' }, { key: '2', name: 'Jim Green', age: 23, address: 'London' }],
columns: [{ title: 'name', dataIndex: 'name' }, { title: 'Age', dataIndex: 'age' }, { title: 'Address', dataIndex: 'address' }],
pagination: false,
}
const fetchDataTableProps = {
fetch: {
url: 'https://randomuser.me/api',
data: {
results: 10,
testPrams: 'test',
},
dataKey: 'results',
},
columns: [
{ title: 'Name', dataIndex: 'name', render: (text) => `${text.first} ${text.last}` },
{ title: 'Phone', dataIndex: 'phone' },
{ title: 'Gender', dataIndex: 'gender' },
],
rowKey: 'registered',
}
const caseChangeDataTableProps = {
fetch: {
url: 'https://randomuser.me/api',
data: {
results: 10,
testPrams: 'test',
...filterCase,
},
dataKey: 'results',
},
columns: [
{ title: 'Name', dataIndex: 'name', render: (text) => `${text.first} ${text.last}` },
{ title: 'Phone', dataIndex: 'phone' },
{ title: 'Gender', dataIndex: 'gender' },
],
rowKey: 'registered',
}
return (<div className="content-inner">
<Row gutter={32}>
<Col lg={12} md={24}>
<Card title="默认">
<DataTable pagination={false} />
</Card>
</Col>
<Col lg={12} md={24}>
<Card title="静态数据">
<DataTable
{...staticDataTableProps}
/>
</Card>
</Col>
<Col lg={12} md={24}>
<Card title="远程数据">
<DataTable
{...fetchDataTableProps}
/>
</Card>
</Col>
<Col lg={12} md={24}>
<Card title="参数变化">
<Select placeholder="Please select gender" allowClear onChange={this.handleSelectChange} style={{ width: 200, marginBottom: 16 }}>
<Select.Option value="male">Male</Select.Option>
<Select.Option value="female">Female</Select.Option>
</Select>
<DataTable
{...caseChangeDataTableProps}
/>
</Card>
</Col>
</Row>
<h2 style={{ margin: '16px 0' }}>Props</h2>
<Row>
<Col lg={18} md={24}>
<Table
rowKey={(record, key) => key}
pagination={false}
bordered
scroll={{ x: 800 }}
columns={[
{
title: '参数',
dataIndex: 'props',
},
{
title: '说明',
dataIndex: 'desciption',
},
{
title: '类型',
dataIndex: 'type',
},
{
title: '默认值',
dataIndex: 'default',
},
]}
dataSource={[
{
props: 'fetch',
desciption: '远程获取数据的参数',
type: 'Object',
default: '后面有空加上',
}]}
/>
</Col>
</Row>
</div>)
}
}
export default DataTablePage
|
src/routes.js | qandobooking/booking-frontend | import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './containers/App';
import ShopsListPage from './containers/ShopsListPage';
import ShopDetailPage from './containers/ShopDetailPage';
import ServiceBooking from './containers/ServiceBooking';
import ServiceBookingCaledarPage from './containers/ServiceBookingCaledarPage';
import ServiceBookingAtDatePage from './containers/ServiceBookingAtDatePage';
import ServiceBookingRangePage from './containers/ServiceBookingRangePage';
import IncomingUserBookingsPage from './containers/IncomingUserBookingsPage';
import HistoryUserBookingsPage from './containers/HistoryUserBookingsPage';
import UserBookingDetailPage from './containers/UserBookingDetailPage';
import ProfilePage from './containers/ProfilePage';
import SignupPage from './containers/SignupPage';
import NotFoundPage from './components/NotFoundPage';
import Spinner from './components/Spinner';
import { UserAuthWrapper } from 'redux-auth-wrapper';
import { routerActions } from 'react-router-redux';
const UserAuthSpinner = (props) => <Spinner fullpage />;
const UserIsAuthenticated = UserAuthWrapper({
authSelector: state => state.auth.user,
authenticatingSelector: state => state.auth.loading,
redirectAction: routerActions.replace,
wrapperDisplayName: 'UserIsAuthenticated',
LoadingComponent: UserAuthSpinner,
failureRedirectPath: '/',
allowRedirectBack: false,
});
export default (
<Route path="/" component={App}>
<IndexRoute component={ShopsListPage} />
<Route path="profile" component={UserIsAuthenticated(ProfilePage)} />
<Route path="my-bookings/incoming(/:view)" component={UserIsAuthenticated(IncomingUserBookingsPage)} />
<Route path="my-bookings/history" component={UserIsAuthenticated(HistoryUserBookingsPage)} />
<Route path="my-bookings/:bookingId" component={UserIsAuthenticated(UserBookingDetailPage)} />
<Route path="signup" component={SignupPage} />
<Route path=":shopDomainName" component={ShopDetailPage} />
<Route path=":shopDomainName/booking/:serviceId" component={ServiceBooking} >
<IndexRoute component={ServiceBookingCaledarPage} />
<Route path="at/:bookingDate" component={ServiceBookingAtDatePage} />
<Route path="book/:rangeStart/:rangeEnd" component={UserIsAuthenticated(ServiceBookingRangePage)} />
</Route>
<Route path="*" component={NotFoundPage} />
</Route>
);
|
src/client/components/todos/todoitem.js | vacuumlabs/todolist | import PureComponent from '../../../lib/purecomponent';
import React from 'react';
import classnames from 'classnames';
import immutable from 'immutable';
import {deleteTodo} from '../../todos/actions';
export default class TodoItem extends PureComponent {
render() {
const todo = this.props.todo;
return (
<li className={classnames({editing: false})}>
<label>{todo.get('title')}</label>
<button onClick={() => deleteTodo(todo)}>x</button>
</li>
);
}
}
TodoItem.propTypes = {
todo: React.PropTypes.instanceOf(immutable.Map)
};
|
app/components/Icons/MaleIcon.js | Tetraib/player.rauks.org | import React from 'react'
import SvgIcon from 'material-ui/SvgIcon'
const MaleIcon = (props) => (
<SvgIcon {...props}>
<path d='M17.654,2l-0.828,1.449h2.069l-3.828,3.829C11.633,4.711,6.8,5.234,3.994,8.475 c-2.806,3.241-2.631,8.099,0.4,11.13s7.89,3.206,11.131,0.4c3.24-2.807,3.764-7.639,1.197-11.073l3.828-3.829v2.07L22,6.346V2 H17.654z M10.204,7.898c3.257,0,5.897,2.641,5.897,5.898c0,3.257-2.641,5.897-5.897,5.897c-3.257,0-5.898-2.641-5.898-5.897 C4.306,10.539,6.947,7.898,10.204,7.898L10.204,7.898z'/>
</SvgIcon>
)
export default MaleIcon
|
demo/src/index.js | cammcguinness/react-bibliography | import React from 'react'
import {render} from 'react-dom'
import Component from '../../src'
var bib = `@article{ashlock2011search,
title={Search-based procedural generation of maze-like levels},
author={Ashlock, Daniel and Lee, Colin and McGuinness, Cameron},
journal={IEEE Transactions on Computational Intelligence and AI in Games},
volume={3},
number={3},
pages={260--273},
year={2011},
publisher={IEEE}
}
@article{ashlock2011simultaneous,
title={Simultaneous dual level creation for games},
author={Ashlock, Daniel and Lee, Colin and McGuinness, Cameron},
journal={IEEE Computational Intelligence Magazine},
volume={6},
number={2},
pages={26--37},
year={2011},
publisher={IEEE}
}
@inproceedings{mcguinness2011decomposing,
title={Decomposing the level generation problem with tiles},
author={McGuinness, Cameron and Ashlock, Daniel},
booktitle={Evolutionary Computation (CEC), 2011 IEEE Congress on},
pages={849--856},
year={2011},
organization={IEEE}
}
@inproceedings{mcguinness2011incorporating,
title={Incorporating required structure into tiles},
author={McGuinness, Cameron and Ashlock, Daniel},
booktitle={Computational Intelligence and Games (CIG), 2011 IEEE Conference on},
pages={16--23},
year={2011},
organization={IEEE}
}
@inproceedings{ashlock2013landscape,
title={Landscape automata for search based procedural content generation},
author={Ashlock, Daniel and McGuinness, Cameron},
booktitle={Computational Intelligence in Games (CIG), 2013 IEEE Conference on},
pages={1--8},
year={2013},
organization={IEEE}
}
@inproceedings{ashlock2012representation,
title={Representation in evolutionary computation},
author={Ashlock, Daniel and McGuinness, Cameron and Ashlock, Wendy},
booktitle={IEEE World Congress on Computational Intelligence},
pages={77--97},
year={2012},
organization={Springer Berlin Heidelberg}
}
@inproceedings{ashlock2014automatic,
title={Automatic generation of fantasy role-playing modules},
author={Ashlock, Daniel and McGuinness, Cameron},
booktitle={Computational Intelligence and Games (CIG), 2014 IEEE Conference on},
pages={1--8},
year={2014},
organization={IEEE}
}
@inproceedings{mcguinness2012statistical,
title={Statistical Analyses of Representation Choice in Level Generation},
author={McGuinness, Cameron},
booktitle={Computational Intelligence and Games},
year={2012},
organization={IEEE}
}
@phdthesis{mcguinness2016monte,
title={Monte Carlo Tree Search: Analysis and Applications},
author={McGuinness, Cameron},
year={2016}
}
@inproceedings{mcguinness2016classification,
title={Classification of Monte Carlo tree search variants},
author={McGuinness, Cameron},
booktitle={Evolutionary Computation (CEC), 2016 IEEE Congress on},
pages={357--363},
year={2016},
organization={IEEE}
}
@inproceedings{ashlock2015evolving,
title={Evolving point packings in the plane},
author={Ashlock, Daniel and Hingston, Philip and McGuinness, Cameron},
booktitle={Australasian Conference on Artificial Life and Computational Intelligence},
pages={297--309},
year={2015},
organization={Springer International Publishing}
}
@inproceedings{mcguinness2016multiple,
title={Multiple pass Monte Carlo tree search},
author={McGuinness, Cameron},
booktitle={Evolutionary Computation (CEC), 2016 IEEE Congress on},
pages={1555--1561},
year={2016},
organization={IEEE}
}
@inproceedings{ashlock2015interactive,
title={Interactive evolution instead of default parameters},
author={Ashlock, Daniel and McGuinness, Cameron and O'Neill, Joseph},
booktitle={Computational Intelligence in Bioinformatics and Computational Biology (CIBCB), 2015 IEEE Conference on},
pages={1--8},
year={2015},
organization={IEEE}
}
@inproceedings{ashlock2015chaos,
title={Chaos automata for sequence visualization},
author={Ashlock, Daniel and McGuinness, Cameron and Ashlock, Wendy},
booktitle={Computational Intelligence in Bioinformatics and Computational Biology (CIBCB), 2015 IEEE Conference on},
pages={1--8},
year={2015},
organization={IEEE}
}
@article{ashlock2graph,
title={Graph-Based Search for Game Design},
author={Ashlock, Daniel and McGuinness, Cameron},
journal={Game \& Puzzle Design, vol. 2, no. 2, 2016 (Colour)},
pages={68},
publisher={Lulu. com}
}
`;
let Demo = React.createClass({
render() {
return <div>
<h1>react-bibliography Demo</h1>
<Component bibtex={bib}/>
</div>
}
})
render(<Demo/>, document.querySelector('#demo'))
|
src/svg-icons/editor/merge-type.js | mtsandeep/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorMergeType = (props) => (
<SvgIcon {...props}>
<path d="M17 20.41L18.41 19 15 15.59 13.59 17 17 20.41zM7.5 8H11v5.59L5.59 19 7 20.41l6-6V8h3.5L12 3.5 7.5 8z"/>
</SvgIcon>
);
EditorMergeType = pure(EditorMergeType);
EditorMergeType.displayName = 'EditorMergeType';
EditorMergeType.muiName = 'SvgIcon';
export default EditorMergeType;
|
frontend/src/Settings/ImportLists/ImportListExclusions/EditImportListExclusionModalContent.js | geogolem/Radarr | import PropTypes from 'prop-types';
import React from 'react';
import Form from 'Components/Form/Form';
import FormGroup from 'Components/Form/FormGroup';
import FormInputGroup from 'Components/Form/FormInputGroup';
import FormLabel from 'Components/Form/FormLabel';
import Button from 'Components/Link/Button';
import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton';
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
import ModalBody from 'Components/Modal/ModalBody';
import ModalContent from 'Components/Modal/ModalContent';
import ModalFooter from 'Components/Modal/ModalFooter';
import ModalHeader from 'Components/Modal/ModalHeader';
import { inputTypes, kinds } from 'Helpers/Props';
import translate from 'Utilities/String/translate';
import styles from './EditImportListExclusionModalContent.css';
function EditImportListExclusionModalContent(props) {
const {
id,
isFetching,
error,
isSaving,
saveError,
item,
onInputChange,
onSavePress,
onModalClose,
onDeleteImportExclusionPress,
...otherProps
} = props;
const {
movieTitle = '',
tmdbId,
movieYear
} = item;
return (
<ModalContent onModalClose={onModalClose}>
<ModalHeader>
{id ? translate('EditListExclusion') : translate('AddListExclusion')}
</ModalHeader>
<ModalBody className={styles.body}>
{
isFetching &&
<LoadingIndicator />
}
{
!isFetching && !!error &&
<div>
{translate('UnableToAddANewListExclusionPleaseTryAgain')}
</div>
}
{
!isFetching && !error &&
<Form
{...otherProps}
>
<FormGroup>
<FormLabel>{translate('TMDBId')}</FormLabel>
<FormInputGroup
type={inputTypes.NUMBER}
name="tmdbId"
helpText={translate('TmdbIdHelpText')}
{...tmdbId}
onChange={onInputChange}
/>
</FormGroup>
<FormGroup>
<FormLabel>{translate('MovieTitle')}</FormLabel>
<FormInputGroup
type={inputTypes.TEXT}
name="movieTitle"
helpText={translate('MovieTitleHelpText')}
{...movieTitle}
onChange={onInputChange}
/>
</FormGroup>
<FormGroup>
<FormLabel>{translate('MovieYear')}</FormLabel>
<FormInputGroup
type={inputTypes.NUMBER}
name="movieYear"
helpText={translate('MovieYearHelpText')}
{...movieYear}
onChange={onInputChange}
/>
</FormGroup>
</Form>
}
</ModalBody>
<ModalFooter>
{
id &&
<Button
className={styles.deleteButton}
kind={kinds.DANGER}
onPress={onDeleteImportExclusionPress}
>
{translate('Delete')}
</Button>
}
<Button
onPress={onModalClose}
>
{translate('Cancel')}
</Button>
<SpinnerErrorButton
isSpinning={isSaving}
error={saveError}
onPress={onSavePress}
>
{translate('Save')}
</SpinnerErrorButton>
</ModalFooter>
</ModalContent>
);
}
EditImportListExclusionModalContent.propTypes = {
id: PropTypes.number,
isFetching: PropTypes.bool.isRequired,
error: PropTypes.object,
isSaving: PropTypes.bool.isRequired,
saveError: PropTypes.object,
item: PropTypes.object.isRequired,
onInputChange: PropTypes.func.isRequired,
onSavePress: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
onDeleteImportExclusionPress: PropTypes.func
};
export default EditImportListExclusionModalContent;
|
src/components/ListResults.js | gbuszmicz/giphyapp | import React, { Component } from 'react';
import {
StyleSheet,
ListView
} from 'react-native';
import ListResultItem from './ListResultItem';
export default class ListResults extends Component {
constructor(props) {
super(props);
this._renderCell = this._renderCell.bind(this);
let { entries } = this.props;
const rowHasChanged = (r1, r2) => r1 !== r2;
let ds = new ListView.DataSource({rowHasChanged});
this.state = {
dataSource: ds.cloneWithRows(entries),
canLoadMore: true
};
}
_renderCell(rowData) {
const imageAnimated = ( // Sometimes ['fixed_height_small'].url is emtpy
rowData.images['fixed_height_small'].url == '' ?
rowData.images['fixed_height'].url :
rowData.images['fixed_height_small'].url
);
const imageStill = (
rowData.images['fixed_height_small_still'].url == '' ?
rowData.images['fixed_height_still'].url :
rowData.images['fixed_height_small_still'].url
);
return (
<ListResultItem still={imageStill} animated={imageAnimated} />
)
}
// _loadMoreAsync() { // For pagination. Not used
// console.log("outside InteractionManager")
// InteractionManager.runAfterInteractions(() => {
// console.log("is loading moooore...")
// });
// }
render() {
return (
<ListView
contentContainerStyle={styles.content}
dataSource={this.state.dataSource}
renderRow={this._renderCell}
scrollRenderAheadDistance={500}
enableEmptySections
initialListSize={15}
pageSize={3}
/>
)
}
}
ListResults.propTypes = {
entries: React.PropTypes.array
}
const styles = StyleSheet.create({
content: {
justifyContent: 'space-around',
flexDirection: 'row',
flexWrap: 'wrap'
},
item: {
backgroundColor: 'red',
margin: 1
}
}); |
src/containers/NotFound.js | cape-io/acf-client | import React from 'react'
export default function NotFound() {
return (
<div className="container">
<h1>Doh! 404!</h1>
<p>These are <em>not</em> the droids you are looking for!</p>
</div>
)
}
|
src/svg-icons/device/signal-wifi-3-bar.js | rscnt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceSignalWifi3Bar = (props) => (
<SvgIcon {...props}>
<path fillOpacity=".3" d="M12.01 21.49L23.64 7c-.45-.34-4.93-4-11.64-4C5.28 3 .81 6.66.36 7l11.63 14.49.01.01.01-.01z"/><path d="M3.53 10.95l8.46 10.54.01.01.01-.01 8.46-10.54C20.04 10.62 16.81 8 12 8c-4.81 0-8.04 2.62-8.47 2.95z"/>
</SvgIcon>
);
DeviceSignalWifi3Bar = pure(DeviceSignalWifi3Bar);
DeviceSignalWifi3Bar.displayName = 'DeviceSignalWifi3Bar';
export default DeviceSignalWifi3Bar;
|
react/components-communicate-through-reflux/src/components/LoadingTracker/LoadingTracker.js | kunukn/sandbox-web | import React from 'react';
import {LOADING_STATES, LOADING_TYPES, LOADING_CONFIG} from '../../utils';
class LoadingTracker extends React.Component {
constructor(props) {
super(props);
this.state = {
loadingType: LOADING_TYPES.SHORT,
};
}
componentDidMount() {
setTimeout(() => {
this.setState({loadingType: LOADING_TYPES.LONG})
}, LOADING_CONFIG.LONG_LOADING_START_TIME)
}
render() {
const {name, loadingState, ignoreLoadingTracker} = this.props;
if (ignoreLoadingTracker) {
return React.Children.only(this.props.children);
}
const isLongLoading = this.state.loadingType === LOADING_TYPES.LONG;
const isLoadingState = loadingState === LOADING_STATES.LOADING;
const isErrorState = loadingState === LOADING_STATES.LOADINGERROR;
if (loadingState) {
return (
<div className="loading-tracker">
{isLoadingState && <div className="loading-tracker__overlay">
<div className="loading-tracker__box">
<div className="load-bar">
<div className="load-bar__item"></div>
<div className="load-bar__item"></div>
</div>
<span className="loading-tracker__name">{name}
</span>
<span className="loading-tracker__message">please wait... {isLongLoading && ' long loading'}</span>
</div>
</div>}
{isErrorState && <div className="loading-tracker__overlay loading-tracker__overlay--is-error">
<div className="loading-tracker__box">
<span className="loading-tracker__name">{name}
</span>
<span className="loading-tracker__message">Error, please try again later.</span>
</div>
</div>}
{this.props.children}
</div>
);
}
return React.Children.only(this.props.children);
}
}
export default LoadingTracker;
|
examples/todomvc/src/components/Layout.js | lore/lore | import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import { connect } from 'lore-hook-connect';
import PayloadStates from '../constants/PayloadStates';
import Filters from '../constants/Filters';
import TodoFooter from './Footer';
import TodoItem from './TodoItem';
import Credits from './Credits';
const ENTER_KEY = 13;
export default connect(function(getState, props) {
const location = props.location;
return {
todos: getState('todo.findAll', {
exclude: function(model) {
return model.state === PayloadStates.DELETED;
}
}),
nowShowing: location.query.filter
};
})(
createReactClass({
displayName: 'Home',
getInitialState: function () {
return {
editing: null,
newTodo: ''
};
},
propTypes: {
todos: PropTypes.object.isRequired,
nowShowing: PropTypes.string.isRequired
},
handleChange: function (event) {
this.setState({
newTodo: event.target.value
});
},
handleNewTodoKeyDown: function (event) {
const { newTodo } = this.state;
if (event.keyCode !== ENTER_KEY) {
return;
}
event.preventDefault();
const val = newTodo.trim();
if (val) {
lore.actions.todo.create({
title: val,
isCompleted: false
});
this.setState({
newTodo: ''
});
}
},
toggleAll: function (event) {
const { todos } = this.props;
const checked = event.target.checked;
todos.data.forEach(function(todo) {
lore.actions.todo.update(todo, {
isCompleted: checked
})
});
},
toggle: function (todoToToggle) {
lore.actions.todo.update(todoToToggle, {
isCompleted: !todoToToggle.data.isCompleted
});
},
destroy: function (todo) {
lore.actions.todo.destroy(todo);
},
edit: function (todo) {
this.setState({
editing: todo.id
});
},
save: function (todoToSave, text) {
lore.actions.todo.update(todoToSave, {
title: text
});
this.setState({
editing: null
});
},
cancel: function () {
this.setState({
editing: null
});
},
clearCompleted: function () {
const { todos } = this.props;
todos.data.forEach(function(todo) {
if (todo.data.isCompleted) {
lore.actions.todo.destroy(todo);
}
});
},
render: function () {
const { todos } = this.props;
let footer;
let main;
const shownTodos = todos.data.filter(function (todo) {
switch (this.props.nowShowing) {
case Filters.ACTIVE_TODOS:
return !todo.data.isCompleted;
case Filters.COMPLETED_TODOS:
return todo.data.isCompleted;
default:
return true;
}
}, this);
const todoItems = shownTodos.map(function (todo) {
return (
<TodoItem
key={todo.id || todo.cid}
todo={todo}
onToggle={this.toggle.bind(this, todo)}
onDestroy={this.destroy.bind(this, todo)}
onEdit={this.edit.bind(this, todo)}
editing={this.state.editing === todo.id}
onSave={this.save.bind(this, todo)}
onCancel={this.cancel}
/>
);
}, this);
const activeTodoCount = _.reduce(todos.data, function (accum, todo) {
return todo.data.isCompleted ? accum : accum + 1;
}, 0);
const completedCount = todos.data.length - activeTodoCount;
if (activeTodoCount || completedCount) {
footer =
<TodoFooter
count={activeTodoCount}
completedCount={completedCount}
nowShowing={this.props.nowShowing}
onClearCompleted={this.clearCompleted}
/>;
}
if (todos.data.length) {
main = (
<section className="main">
<input
className="toggle-all"
type="checkbox"
onChange={this.toggleAll}
checked={activeTodoCount === 0}
/>
<ul className="todo-list">
{todoItems}
</ul>
</section>
);
}
return (
<div>
<div className="todoapp">
<header className="header">
<h1>todos</h1>
<input
className="new-todo"
placeholder="What needs to be done?"
value={this.state.newTodo}
onKeyDown={this.handleNewTodoKeyDown}
onChange={this.handleChange}
autoFocus={true}
/>
</header>
{main}
{footer}
</div>
<Credits />
</div>
);
}
})
);
|
src/main.js | commute-sh/commute-web | import React from 'react'
import ReactDOM from 'react-dom'
import createStore from './store/createStore'
import AppContainer from './containers/AppContainer'
// Needed for onTouchTap
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();
// ========================================================
// Store Instantiation
// ========================================================
const initialState = window.___INITIAL_STATE__
const store = createStore(initialState)
// ========================================================
// Render Setup
// ========================================================
const MOUNT_NODE = document.getElementById('root')
let render = () => {
const routes = require('./routes/index').default(store)
ReactDOM.render(
<AppContainer store={store} routes={routes} />,
MOUNT_NODE
)
}
// ========================================================
// Developer Tools Setup
// ========================================================
if (__DEV__) {
if (window.devToolsExtension) {
window.devToolsExtension.open()
}
}
// This code is excluded from production bundle
if (__DEV__) {
if (module.hot) {
// Development render functions
const renderApp = render
const renderError = (error) => {
const RedBox = require('redbox-react').default
ReactDOM.render(<RedBox error={error} />, MOUNT_NODE)
}
// Wrap render in try/catch
render = () => {
try {
renderApp()
} catch (error) {
renderError(error)
}
}
// Setup hot module replacement
module.hot.accept('./routes/index', () =>
setImmediate(() => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE)
render()
})
)
}
}
// ========================================================
// Go!
// ========================================================
render()
|
src/browser/auth/SignInError.js | reedlaw/read-it | // @flow
import type { State } from '../../common/types';
import React from 'react';
import errorMessages from '../../common/auth/errorMessages';
import firebaseMessages from '../../common/auth/firebaseMessages';
import { FormattedMessage } from 'react-intl';
import { Message } from '../../common/components';
import { connect } from 'react-redux';
const getMessage = error =>
errorMessages[error.name] || firebaseMessages[error.name] || error.toString();
const SignInError = ({ error }) => {
if (!error) return null;
const message = getMessage(error);
return (
<Message backgroundColor="danger">
{typeof message !== 'string'
? <FormattedMessage {...message} values={error.params} />
: error.toString()}
</Message>
);
};
export default connect((state: State) => ({
error: state.auth.error,
}))(SignInError);
|
tests/Rules-isLength-spec.js | yesmeck/formsy-react | import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Formsy from './..';
import { InputFactory } from './utils/TestInput';
const TestInput = InputFactory({
render() {
return <input value={this.getValue()} readOnly/>;
}
});
const TestForm = React.createClass({
render() {
return (
<Formsy.Form>
<TestInput name="foo" validations={this.props.rule} value={this.props.inputValue}/>
</Formsy.Form>
);
}
});
export default {
'isLength:3': {
'should pass with a default value': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:3"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should fail with a string too small': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:3" inputValue="hi"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), false);
test.done();
},
'should fail with a string too long': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:3" inputValue="hi ho happ"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), false);
test.done();
},
'should pass with matching length': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:3" inputValue="foo"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with undefined': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:3" inputValue={undefined}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with null': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:3" inputValue={null}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with empty string': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:3" inputValue=""/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should fail with a number': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:3" inputValue={123}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), false);
test.done();
}
},
'isLength:0': {
'should pass with a default value': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:0"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should fail with a string too small': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:0" inputValue="hi"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), false);
test.done();
},
'should fail with a string too long': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:0" inputValue="hi ho happ"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), false);
test.done();
},
'should pass with matching length': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:0" inputValue=""/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with undefined': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:0" inputValue={undefined}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with null': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:0" inputValue={null}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with empty string': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:0" inputValue=""/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should fail with a number': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm rule="isLength:0" inputValue={123}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), false);
test.done();
}
}
};
|
src/routes/Project/components/Team/Team.js | prescottprue/portfolio | import React from 'react'
import PropTypes from 'prop-types'
import Avatar from 'material-ui/svg-icons/social/person'
import classes from './Team.scss'
export const Team = ({ list }) => (
<div className={classes.container}>
{list.map((person, i) => {
const avatar =
person.icon && person.icon.url ? (
<Avatar src={person.icon.url} />
) : (
<Avatar>{person.name.charAt(0).toUpperCase()}</Avatar>
)
return (
<div className={classes.member} key={`Team-Member-${i}`}>
<a href={person.url}>{avatar}</a>
<span className={classes.memberName}>{person.name}</span>
<span className={classes.memberRole}>{person.role}</span>
</div>
)
})}
</div>
)
Team.propTypes = {
list: PropTypes.array.isRequired
}
export default Team
|
milestones/03-inline-styles/After/src/nav.js | jaketrent/react-drift | import PropTypes from 'prop-types'
import React from 'react'
import styles from './nav-styles.js'
function getPrevStyles(props) {
return props.hasPrevious ? styles.prev : styles.prevHidden
}
function getNextStyles(props) {
return props.hasNext ? styles.next : styles.nextHidden
}
function Nav(props) {
return (
<div style={styles.root}>
<button style={getPrevStyles(props)} onClick={props.onPrevious}>
❮
</button>
<button style={getNextStyles(props)} onClick={props.onNext}>
❯
</button>
</div>
)
}
Nav.propTypes = {
onPrevious: PropTypes.func.isRequired,
onNext: PropTypes.func.isRequired,
hasPrevious: PropTypes.bool,
hasNext: PropTypes.bool
}
export default Nav
|
web/src/main/webapp_source/src/components/Inventory.js | mschvarc/PB138-Inventory-Management | import React, { Component } from 'react';
import InventoryTable from './components/InventoryTable';
class Inventory extends Component {
render() {
var items = this.props.items;
return <div className="page-inventory row">
<div className="small-12 columns">
<h2>Current Inventory</h2>
<InventoryTable items={items} />
</div>
</div>
}
}
export default Inventory;
|
fields/types/email/EmailField.js | jacargentina/keystone | import Field from '../Field';
import React from 'react';
import { FormInput } from 'elemental';
/*
TODO:
- gravatar
- validate email address
*/
module.exports = Field.create({
displayName: 'EmailField',
renderField () {
return (
<FormInput
name={this.props.path}
ref="focusTarget"
value={this.props.value}
onChange={this.valueChanged}
autoComplete="off"
type="email"
/>
);
},
renderValue () {
return this.props.value ? (
<FormInput noedit href={'mailto:' + this.props.value}>{this.props.value}</FormInput>
) : (
<FormInput noedit>(not set)</FormInput>
);
},
});
|
scripts/apps/search/components/fields/slugline.js | darconny/superdesk-client-core | import React from 'react';
import PropTypes from 'prop-types';
import {createMarkUp} from 'apps/search/helpers';
export function slugline(props) {
if (props.item.slugline) {
return React.createElement(
'span',
{className: 'keyword', key: 'slugline',
dangerouslySetInnerHTML: createMarkUp(props.item.slugline)}
);
}
}
slugline.propTypes = {
item: PropTypes.any,
};
|
pkg/interface/publish/src/js/components/lib/notebook-posts.js | ngzax/urbit | import React, { Component } from 'react';
import moment from 'moment';
import { Link } from 'react-router-dom';
import ReactMarkdown from 'react-markdown'
import { cite } from '../../lib/util';
export class NotebookPosts extends Component {
constructor(props){
super(props);
moment.updateLocale('en', {
relativeTime: {
past: function(input) {
return input === 'just now'
? input
: input + ' ago'
},
s : 'just now',
future : 'in %s',
m : '1m',
mm : '%dm',
h : '1h',
hh : '%dh',
d : '1d',
dd : '%dd',
M : '1 month',
MM : '%d months',
y : '1 year',
yy : '%d years',
}
});
}
render() {
const { props } = this;
let notes = [];
for (var i=0; i<props.list.length; i++) {
let noteId = props.list[i];
let note = props.notes[noteId];
if (!note) {
break;
}
let contact = !!(note.author.substr(1) in props.contacts)
? props.contacts[note.author.substr(1)] : false;
let name = note.author;
if (contact) {
name = (contact.nickname.length > 0)
? contact.nickname : note.author;
}
if (name === note.author) {
name = cite(note.author);
}
let comment = "No Comments";
if (note["num-comments"] == 1) {
comment = "1 Comment";
} else if (note["num-comments"] > 1) {
comment = `${note["num-comments"]} Comments`;
}
let date = moment(note["date-created"]).fromNow();
let popout = (props.popout) ? "popout/" : "";
let url = `/~publish/${popout}note/${props.host}/${props.notebookName}/${noteId}`
notes.push(
<Link key={i} to={url}>
<div className="mv6">
<div className="mb1"
style={{overflowWrap: "break-word"}}>
{note.title}
</div>
<p className="mb1"
style={{overflowWrap: "break-word"}}>
<ReactMarkdown
unwrapDisallowed
allowedTypes={['text', 'root', 'break', 'paragraph']}
source={note.snippet} />
</p>
<div className="flex">
<div className={(contact.nickname ? null : "mono") +
" gray2 mr3"}
title={note.author}>{name}</div>
<div className="gray2 mr3">{date}</div>
<div className="gray2">{comment}</div>
</div>
</div>
</Link>
)
}
return (
<div className="flex-col">
{notes}
</div>
);
}
}
export default NotebookPosts
|
src/components/Spinner.js | flydev-labs/react-face-detector | import React from 'react';
class Spinner extends React.Component {
render() {
return (
<div id="spinner" className="spinner">
<div className="cube1"></div>
<div className="cube2"></div>
</div>
);
}
}
export default Spinner; |
src/components/http_request.js | MichalKononenko/OmicronClient | /**
* Created by Michal on 2016-02-17.
*/
import React from 'react';
export const URLEntryForm = ({url_value, on_url_change, on_button_click}) => (
<form>
<div className="form-group">
<label>JSON API URL</label>
<input type="text" className="form-control"
placeholder="URL to Contact"
value={url_value} onChange={on_url_change}
/>
</div>
<div className="form-group">
<button className="btn btn-default" onClick={on_button_click}
type="button">
Run Request
</button>
</div>
</form>
);
export const ResultsBox = ({url_value, test_result}) => (
<div className="container">
<div className="row">
<div className="col-md-8">
<h4>URL:</h4> {url_value}
</div>
<div className="col-md-8">
<p>Result of test:</p>
<p>{JSON.stringify(test_result)}</p>
</div>
</div>
</div>
); |
demo/components/tabs/TabsOptions.js | f0zze/rosemary-ui | import React from 'react';
import Tabs from '../../../src/components/tabs/Tabs';
import OptionsTable from '../../helper/OptionsTable';
export default () => {
let description = {
onBeforeChange: {
values: 'function[tabId,next]',
description: 'called before onChange,if using onBeforeChange dont forget call next function'
},
onChange: {
values: 'function[tabId]',
description: 'called when tab is selected tabId will be passed in'
},
selected: {
values: 'any',
description: 'specifies selected tab'
}
};
let tabDescription = {
tabId: {
values: 'any',
description: 'simple tab id'
},
onEnter: {
values: 'function[callback]',
description: 'called before onChange,can make ajax requests etc. to continue call callback func'
}
};
return (
<div>
Tabs
<OptionsTable component={Tabs} propDescription={description}/>
Tabs.Tab
<OptionsTable component={Tabs.Tab} propDescription={tabDescription}/>
</div>
);
};
|
src/Message.js | tanbo800/react-ui | "use strict"
import React from 'react'
import classnames from 'classnames'
import Overlay from './Overlay'
//import { forEach } from './utils/objects'
import PubSub from 'pubsub-js'
import { requireCss } from './themes'
requireCss('message')
const ADD_MESSAGE = "EB3A79637B40"
const REMOVE_MESSAGE = "73D4EF15DF50"
const CLEAR_MESSAGE = "73D4EF15DF52"
let messages = []
let messageContainer = null
class Item extends React.Component {
static displayName = 'Message.Item'
static propTypes = {
className: React.PropTypes.string,
content: React.PropTypes.any,
dismissed: React.PropTypes.bool,
index: React.PropTypes.number,
onDismiss: React.PropTypes.func,
type: React.PropTypes.string
}
dismiss () {
if (this.props.dismissed) {
return
}
this.props.onDismiss(this.props.index)
}
render () {
let className = classnames(
this.props.className,
'rct-message',
`rct-message-${this.props.type}`,
{ 'dismissed': this.props.dismissed }
)
return (
<div className={className}>
<button type="button" onClick={this.dismiss.bind(this)} className="close">×</button>
{this.props.content}
</div>
)
}
}
export default class Message extends React.Component {
static displayName = 'Message'
static propTypes = {
className: React.PropTypes.string,
messages: React.PropTypes.array
}
static show (content, type) {
if (!messageContainer) {
createContainer()
}
PubSub.publish(ADD_MESSAGE, {
content: content,
type: type || 'info'
})
}
dismiss (index) {
PubSub.publish(REMOVE_MESSAGE, index)
}
clear () {
PubSub.publish(CLEAR_MESSAGE)
}
render () {
let items = this.props.messages.map((msg, i) => {
return (
<Item key={i} index={i} ref={i} onDismiss={this.dismiss} {...msg} />
)
})
let className = classnames(
this.props.className,
'rct-message-container',
{ 'has-message': this.props.messages.length > 0 }
)
return (
<div className={className}>
<Overlay onClick={this.clear.bind(this)} />
{items}
</div>
)
}
}
function renderContainer() {
React.render(<Message messages={messages} />, messageContainer)
}
function createContainer () {
messageContainer = document.createElement('div')
document.body.appendChild(messageContainer)
}
PubSub.subscribe(ADD_MESSAGE, (topic, data) => {
messages = [...messages, data]
renderContainer()
})
PubSub.subscribe(REMOVE_MESSAGE, (topic, index) => {
messages = [
...messages.slice(0, index),
...messages.slice(index + 1)
]
renderContainer()
})
PubSub.subscribe(CLEAR_MESSAGE, () => {
messages = messages.map((m) => {
m.dismissed = true
return m
})
renderContainer()
setTimeout(() => {
messages = []
renderContainer()
}, 400)
})
|
src/js/components/Stream.js | jaedb/Iris | import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as coreActions from '../services/core/actions';
import { SnapStream } from './SnapStream.tsx';
class Stream extends React.Component {
constructor(props) {
super(props);
if (props.enabled && props.streaming_enabled) {
this.start();
}
}
start = () => {
const {
host,
port,
ssl,
} = this.props;
if (this.snapstream) {
this.snapstream.play();
} else {
const baseUrl = `${ssl ? 'wss' : 'ws'}://${host}:${port}`;
this.snapstream = new SnapStream(baseUrl);
}
}
stop = () => {
if (this.snapstream) {
this.snapstream.stop();
this.snapstream = null;
}
}
componentDidUpdate = ({
streaming_enabled: prevStreamingEnabled,
}) => {
const {
enabled,
streaming_enabled,
} = this.props;
if (!prevStreamingEnabled && enabled && streaming_enabled) {
this.start();
}
if (!enabled || !streaming_enabled) {
this.stop();
}
}
render = () => null;
}
const mapStateToProps = (state) => {
const {
snapcast: {
enabled,
streaming_enabled,
host,
port,
ssl,
},
pusher: {
username,
},
} = state;
return {
enabled,
streaming_enabled,
host,
port,
ssl,
username,
};
};
const mapDispatchToProps = (dispatch) => ({
coreActions: bindActionCreators(coreActions, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(Stream);
|
docs/src/components/Link/Link.js | bmatthews/haze-lea | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import PropTypes from 'prop-types';
import history from '../../history';
function isLeftClickEvent(event) {
return event.button === 0;
}
function isModifiedEvent(event) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
}
class Link extends React.Component {
static propTypes = {
to: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
onClick: PropTypes.func,
};
static defaultProps = {
onClick: null,
};
handleClick = event => {
if (this.props.onClick) {
this.props.onClick(event);
}
if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
return;
}
if (event.defaultPrevented === true) {
return;
}
event.preventDefault();
history.push(this.props.to);
};
render() {
const { to, children, ...props } = this.props;
return (
<a href={to} {...props} onClick={this.handleClick}>
{children}
</a>
);
}
}
export default Link;
|
web/src/components/graphql-error-list.js | ajmalafif/ajmalafif.com | import React from 'react'
const GraphQLErrorList = ({errors}) => (
<div>
<h1>GraphQL Error</h1>
{errors.map(error => (
<pre key={error.message}>{error.message}</pre>
))}
</div>
)
export default GraphQLErrorList
|
src/js/components/PageFooter.js | bryanjacquot/theme-designer-capstone | import React, { Component } from 'react';
import Footer from 'grommet/components/Footer';
import Box from 'grommet/components/Box';
import Anchor from 'grommet/components/Anchor';
import Twitter from 'grommet/components/icons/base/SocialTwitter';
import LinkedIn from 'grommet/components/icons/base/SocialLinkedin';
import Email from 'grommet/components/icons/base/SocialEmail';
export default class PageFooter extends Component {
constructor() {
super();
}
render () {
return (
<Footer colorIndex="grey-3-a" pad={{vertical: "small", horizontal: "medium"}}>
<Box direction="row" justify="between">
<div>
Built with <a href="http://grommet.io">Grommet</a> and licensed under the <a href="http://creativecommons.org/licenses/by/4.0/legalcode">Creative Commons Attribution 4.0 International License.</a>
</div>
<Box direction="row" pad={{horizontal: "small", vertical: "none"}}>
<Box pad={{horizontal: "small"}} onClick={this._onTwitter}>
<Anchor icon={<Twitter />} href="https://twitter.com/intent/follow?screen_name=bryanjacquot" />
</Box>
<Box pad={{horizontal: "small"}} onClick={this._onLinkedIn}>
<Anchor icon={<LinkedIn />} href="https://www.linkedin.com/in/bryanjacquot" />
</Box>
<Box pad={{horizontal: "small"}} onClick={this._onEmail}>
<Anchor icon={<Email />} href="mailto:[email protected]?Subject=HCI%20598%20Capstone%20Project" />
</Box>
</Box>
</Box>
</Footer>
);
}
};
|
app/navigators/WalletTabBarConfiguration.js | ixje/neon-wallet-react-native | import React from 'react'
import { TabNavigator, TabBarBottom } from 'react-navigation'
import FAIcons from 'react-native-vector-icons/FontAwesome'
import ENTIcons from 'react-native-vector-icons/Entypo'
import WalletInfo from '../screens/loggedIn/walletInfo'
import TransactionHistory from '../screens/loggedIn/transactionHistory'
const routeConfiguration = {
WalletInfo: {
screen: WalletInfo,
navigationOptions: {
tabBarLabel: 'Wallet',
headerTitle: 'Wallet overview',
tabBarIcon: ({ tintColor, focused }) => <ENTIcons name={'wallet'} size={24} style={{ color: tintColor }} />
}
},
TransactionHistory: {
screen: TransactionHistory,
navigationOptions: {
tabBarLabel: 'Transaction history',
headerTitle: 'Transaction history',
tabBarIcon: ({ tintColor, focused }) => <FAIcons name="history" size={24} style={{ color: tintColor }} />
}
}
}
const tabBarConfiguration = {
// other configs
tabBarOptions: {
activeBackgroundColor: 'white',
inactiveBackgroundColor: 'white',
activeTintColor: '#4D933B', // label and icon color of the active tab
inactiveTintColor: '#979797', // label and icon color of the inactive tab
labelStyle: {
// style object for the labels on the tabbar
fontSize: 12,
color: '#636363'
},
style: {
// style object for the tabbar itself
borderTopColor: '#979797', // seems to set the tabbar top border color on IOS
borderTopWidth: 1
}
},
tabBarComponent: TabBarBottom,
tabBarPosition: 'bottom'
}
export const WalletTabBar = TabNavigator(routeConfiguration, tabBarConfiguration)
|
node_modules/antd/es/radio/group.js | yhx0634/foodshopfront | import _defineProperty from 'babel-runtime/helpers/defineProperty';
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 from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import shallowEqual from 'shallowequal';
import Radio from './radio';
function getCheckedValue(children) {
var value = null;
var matched = false;
React.Children.forEach(children, function (radio) {
if (radio && radio.props && radio.props.checked) {
value = radio.props.value;
matched = true;
}
});
return matched ? { value: value } : undefined;
}
var RadioGroup = function (_React$Component) {
_inherits(RadioGroup, _React$Component);
function RadioGroup(props) {
_classCallCheck(this, RadioGroup);
var _this = _possibleConstructorReturn(this, (RadioGroup.__proto__ || Object.getPrototypeOf(RadioGroup)).call(this, props));
_this.onRadioChange = function (ev) {
var lastValue = _this.state.value;
var value = ev.target.value;
if (!('value' in _this.props)) {
_this.setState({
value: value
});
}
var onChange = _this.props.onChange;
if (onChange && value !== lastValue) {
onChange(ev);
}
};
var value = void 0;
if ('value' in props) {
value = props.value;
} else if ('defaultValue' in props) {
value = props.defaultValue;
} else {
var checkedValue = getCheckedValue(props.children);
value = checkedValue && checkedValue.value;
}
_this.state = {
value: value
};
return _this;
}
_createClass(RadioGroup, [{
key: 'getChildContext',
value: function getChildContext() {
return {
radioGroup: {
onChange: this.onRadioChange,
value: this.state.value,
disabled: this.props.disabled
}
};
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if ('value' in nextProps) {
this.setState({
value: nextProps.value
});
} else {
var checkedValue = getCheckedValue(nextProps.children);
if (checkedValue) {
this.setState({
value: checkedValue.value
});
}
}
}
}, {
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var props = this.props;
var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === undefined ? 'ant-radio-group' : _props$prefixCls,
_props$className = props.className,
className = _props$className === undefined ? '' : _props$className;
var classString = classNames(prefixCls, _defineProperty({}, prefixCls + '-' + props.size, props.size), className);
var children = props.children;
// 如果存在 options, 优先使用
if (props.options && props.options.length > 0) {
children = props.options.map(function (option, index) {
if (typeof option === 'string') {
return React.createElement(
Radio,
{ key: index, disabled: _this2.props.disabled, value: option, onChange: _this2.onRadioChange, checked: _this2.state.value === option },
option
);
} else {
return React.createElement(
Radio,
{ key: index, disabled: option.disabled || _this2.props.disabled, value: option.value, onChange: _this2.onRadioChange, checked: _this2.state.value === option.value },
option.label
);
}
});
}
return React.createElement(
'div',
{ className: classString, style: props.style, onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave },
children
);
}
}]);
return RadioGroup;
}(React.Component);
export default RadioGroup;
RadioGroup.defaultProps = {
disabled: false
};
RadioGroup.childContextTypes = {
radioGroup: PropTypes.any
}; |
node_modules/babel-plugin-react-transform/test/fixtures/code-class-extends-component-with-render-method/expected.js | SpatialMap/SpatialMapDev | import _transformLib from 'transform-lib';
const _components = {
Foo: {
displayName: 'Foo'
}
};
const _transformLib2 = _transformLib({
filename: '%FIXTURE_PATH%',
components: _components,
locals: [],
imports: []
});
function _wrapComponent(id) {
return function (Component) {
return _transformLib2(Component, id);
};
}
import React, { Component } from 'react';
const Foo = _wrapComponent('Foo')(class Foo extends Component {
render() {}
});
|
node_modules/@shoutem/animation/src/drivers/DriverShape.js | tausifmuzaffar/bisApp | import React from 'react';
import { Animated } from 'react-native';
export const DriverShape = React.PropTypes.shape({
value: React.PropTypes.instanceOf(Animated.Value),
});
|
gatsby-strapi-tutorial/cms/plugins/content-manager/admin/src/components/Wysiwyg/link.js | strapi/strapi-examples | /**
*
* Link
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { includes } from 'lodash';
const Link = props => {
const { url, aHref, aInnerHTML } = props.contentState.getEntity(props.entityKey).getData();
let content = aInnerHTML;
if (includes(aInnerHTML, '<img', 'src=')) {
const src = aInnerHTML.split('src="')[1].split('" ')[0];
const width = includes(aInnerHTML, 'width=') ? aInnerHTML.split('width="')[1].split('" ')[0] : '';
const height = includes(aInnerHTML, 'height=') ? aInnerHTML.split('height="')[1].split('" ')[0] : '';
content = <img src={src} alt="img" width={width} height={height} style={{ marginTop: '27px', maxWidth: '100%' }} />;
}
return (
<a
href={url || aHref}
onClick={() => {
window.open(url || aHref, '_blank');
}}
style={{ cursor: 'pointer' }}
>
{content || props.children}
</a>
);
};
Link.defaultProps = {
children: '',
};
Link.propTypes = {
children: PropTypes.node,
contentState: PropTypes.object.isRequired,
entityKey: PropTypes.string.isRequired,
};
export default Link;
|
docs/app/Examples/collections/Grid/Content/GridExampleColumns.js | shengnian/shengnian-ui-react | import React from 'react'
import { Grid, Image } from 'shengnian-ui-react'
const GridExampleColumns = () => (
<Grid>
<Grid.Row>
<Grid.Column width={8}>
<Image src='/assets/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column width={8}>
<Image src='/assets/images/wireframe/paragraph.png' />
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column width={8}>
<Image src='/assets/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column width={8}>
<Image src='/assets/images/wireframe/paragraph.png' />
</Grid.Column>
</Grid.Row>
</Grid>
)
export default GridExampleColumns
|
src/pages/404.js | JovaniPink/measuredstudios | import React from 'react';
import styled from 'styled-components';
import GlobalStateProvider from '../context/provider';
import Layout from '../components/layout';
import SEO from '../components/seo';
import ContentWrapper from '../styles/contentWrapper';
const StyledSection = styled.section`
width: 100%;
max-width: 62.5rem;
margin: 0 auto;
padding: 0 2.5rem;
height: auto;
background: ${({ theme }) => theme.colors.background};
h1 {
font-size: 1.5rem;
}
`;
const StyledContentWrapper = styled(ContentWrapper)`
&& {
width: 100%;
max-width: 36rem;
margin: 0;
padding: 0;
height: 100%;
}
`;
const NotFoundPage = () => {
const globalState = {
isIntroDone: true,
darkMode: false,
};
return (
<GlobalStateProvider initialState={globalState}>
<Layout>
<SEO
title="404: Not found"
meta={[{ name: 'robots', content: 'noindex' }]}
/>
<StyledSection>
<StyledContentWrapper>
<h1 data-testid="heading">NOT FOUND</h1>
<p>You just hit a route that doesn't exist... the sadness.</p>
</StyledContentWrapper>
</StyledSection>
</Layout>
</GlobalStateProvider>
);
};
export default NotFoundPage;
|
src/App/views/UsersList/index.js | ryanswapp/react-starter-template | import React from 'react';
import Actions from 'App/state/actions.js';
import { connect } from 'react-redux';
class UsersList extends React.Component {
constructor(props) {
super(props);
}
componentDidMount () {
const { dispatch } = this.props;
dispatch({type: 'FETCH_USERS_REQUESTED'});
}
render () {
const { users } = this.props;
return (
<div className="container">
<h1>Users List</h1>
<div className="users-list">
<ul className="list-group">
{ users.map((user, i) => {
return <li key={ i } className="list-group-item">{ user.name }</li>;
}) }
</ul>
</div>
</div>
);
}
};
function mapStateToProps(state) {
return {
users: state.users
};
}
export default connect(mapStateToProps)(UsersList);
|
react/FlagHKIcon/FlagHKIcon.js | seekinternational/seek-asia-style-guide | import svgMarkup from './FlagHKIcon.svg';
import React from 'react';
import Icon from '../private/Icon/Icon';
export default function FlagHKIcon(props) {
return <Icon markup={svgMarkup} {...props} />;
}
FlagHKIcon.displayName = 'FlagHKIcon';
|
app/components/BreadcrumbRouter/index.js | danielmoraes/invoices-web-client | import React from 'react'
import { Breadcrumb, BreadcrumbItem } from 'react-bootstrap'
import { LinkContainer } from 'react-router-bootstrap'
import { Route, withRouter } from 'react-router-dom'
const findRouteName = (url, routes) => {
for (let i = 0; i < routes.length; ++i) {
if (url.match(routes[i].path)) {
return routes[i].name
}
}
return null
}
const getPaths = (pathname) => {
const paths = []
pathname.split('/').reduce((p, c) => {
const path = `${p}/${c}`
paths.push(path)
return path
})
return paths
}
const BreadcrumbRouterItem = ({ match, routes }) => {
const routeName = findRouteName(match.url, routes)
return (
routeName ? (
match.isExact ? (
<BreadcrumbItem active>{routeName}</BreadcrumbItem>
) : (
<LinkContainer to={match.url}>
<BreadcrumbItem>{routeName}</BreadcrumbItem>
</LinkContainer>
)
) : null
)
}
const BreadcrumbRouter = ({ location: { pathname }, routes }) => {
const paths = getPaths(pathname)
return (
<Breadcrumb>
{paths.map(p => (
<Route key={p} path={p} render={(props) => (
<BreadcrumbRouterItem routes={routes} {...props} />
)} />
))}
</Breadcrumb>
)
}
export default withRouter(BreadcrumbRouter)
|
src/pages/index.js | itzsaga/slack-list | import React from 'react'
import Layout from '../components/layout'
import ListItem from '../components/listItem'
import LocationBased from '../components/locationBased'
import list from '../data/list'
const IndexPage = ({ location: { pathname } }) => (
<Layout location={pathname}>
<section className="section">
<div className="container">
<div className="content">
<LocationBased locationBased={list.locationBased} />
<div id="it">
<h2>Networks Based around IT</h2>
</div>
<ul>
{list.itBased.map((network) => (
<ListItem item={network} key={network.url} />
))}
</ul>
<div id="programming">
<h2>Networks Based around Programming</h2>
</div>
<ul>
{list.programmingBased.map((network) => (
<ListItem item={network} key={network.url} />
))}
</ul>
<div id="miscellaneous">
<h2>Networks Based around Miscellaneous Topics</h2>
</div>
<ul>
{list.miscellaneousBased.map((network) => (
<ListItem item={network} key={network.url} />
))}
</ul>
</div>
</div>
</section>
</Layout>
)
export default IndexPage
|
public/app/components/online-tab/details-component-config.js | vincent-tr/mylife-home-studio | 'use strict';
import React from 'react';
import * as mui from 'material-ui';
import icons from '../icons';
const DetailsComponentConfig = ({ config }) => (
<div>
<icons.NetConfig style={{verticalAlign: 'middle'}}/>
Configuration:
{config.key}
=
{config.value}
<mui.Divider />
</div>
);
DetailsComponentConfig.propTypes = {
config: React.PropTypes.object.isRequired,
};
export default DetailsComponentConfig;
|
docs/src/app/components/pages/components/FlatButton/ExampleIcon.js | pomerantsev/material-ui | import React from 'react';
import FlatButton from 'material-ui/FlatButton';
import FontIcon from 'material-ui/FontIcon';
import ActionAndroid from 'material-ui/svg-icons/action/android';
import {fullWhite} from 'material-ui/styles/colors';
const style = {
margin: 12,
};
const FlatButtonExampleIcon = () => (
<div>
<FlatButton
icon={<ActionAndroid />}
style={style}
/>
<FlatButton
backgroundColor="#a4c639"
hoverColor="#8AA62F"
icon={<ActionAndroid color={fullWhite} />}
style={style}
/>
<FlatButton
href="https://github.com/callemall/material-ui"
secondary={true}
icon={<FontIcon className="muidocs-icon-custom-github" />}
style={style}
/>
</div>
);
export default FlatButtonExampleIcon;
|
client/src/App.js | hold-the-door-game/Prototypes | import React, { Component } from 'react';
import Prototype03 from './Game/Prototype03';
import './App.css';
class App extends Component {
constructor() {
super();
this.loader = window.PIXI.loader;
this.loader.add('scott_pilgrim_walking_01', 'assets/sprites/scott_pilgrim_walking_01.json');
this.loader.add('scott_pilgrim_idle_01', 'assets/sprites/scott_pilgrim_idle_01.json');
this.loader.add('scott_pilgrim_opening_01', 'assets/sprites/scott_pilgrim_opening_01.json');
this.loader.add('door_01', 'assets/sprites/door_01.json');
this.loader.load();
this.state = {
isLoadComplete: false,
}
}
componentDidMount() {
this.loader.onComplete.add(() => {
this.setState({
isLoadComplete: true,
});
});
}
render() {
if (!this.state.isLoadComplete) {
return null;
}
return (
<Prototype03 />
);
}
}
export default App;
|
src/svg-icons/navigation/apps.js | nathanmarks/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NavigationApps = (props) => (
<SvgIcon {...props}>
<path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"/>
</SvgIcon>
);
NavigationApps = pure(NavigationApps);
NavigationApps.displayName = 'NavigationApps';
NavigationApps.muiName = 'SvgIcon';
export default NavigationApps;
|
lib/carbon-fields/vendor/htmlburger/carbon-fields/assets/js/fields/components/media-gallery/index.js | boquiabierto/wherever-content | /**
* The external dependencies.
*/
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import {
compose,
withHandlers,
setStatic,
withProps
} from 'recompose';
import {
without,
sortBy,
isNumber
} from 'lodash';
/**
* The internal dependencies.
*/
import Field from 'fields/components/field';
import MediaGalleryList from 'fields/components/media-gallery/list';
import EditAttachment from 'fields/components/media-gallery/edit-attachment';
import withStore from 'fields/decorators/with-store';
import withSetup from 'fields/decorators/with-setup';
import { setupMediaBrowser, openMediaBrowser } from 'fields/actions';
import { TYPE_MEDIA_GALLERY, VALIDATION_BASE } from 'fields/constants';
/**
* Render a file upload field with a preview thumbnail of the uploaded file.
*
* @param {Object} props
* @param {String} props.name
* @param {Object} props.field
* @param {Function} props.openBrowser
* @param {Function} props.handleRemoveItem
* @return {React.Element}
*/
export const MediaGalleryField = ({
name,
field,
openBrowser,
sortableOptions,
handleSortItems,
handleRemoveItem,
openEditAttachment,
closeEditAttachment,
updateField,
}) => {
return <Field field={field}>
<div className="carbon-media-gallery">
<MediaGalleryList
prefix={name}
items={field.value}
itemsMeta={field.value_meta}
handleOpenBrowser={openBrowser}
handleEditItem={openEditAttachment}
handleRemoveItem={handleRemoveItem}
openBrowser={openBrowser}
field={field}
sortableOptions={sortableOptions}
onSort={handleSortItems}
/>
{
(field.editMode === 'inline' && field.selected) ?
<EditAttachment
field={field}
attachment={field.selected}
attachmentMeta={field.value_meta[ field.selected ]}
updateField={updateField}
handleCancelEdit={closeEditAttachment}
/> : ''
}
</div>
</Field>;
};
/**
* Validate the props.
*
* @type {Object}
*/
MediaGalleryField.propTypes = {
name: PropTypes.string,
field: PropTypes.shape({
value: PropTypes.array,
value_meta: PropTypes.oneOfType([
PropTypes.array,
PropTypes.object,
]),
value_type: PropTypes.string,
duplicates_allowed: PropTypes.boolean,
selected: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
editMode: PropTypes.string,
edit: PropTypes.shape({
id: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
title: PropTypes.string,
caption: PropTypes.string,
alt: PropTypes.string,
description: PropTypes.string,
artist: PropTypes.string,
album: PropTypes.string,
}),
}),
openBrowser: PropTypes.func,
handleRemoveItem: PropTypes.func,
};
/**
* The enhancer.
*
* @type {Function}
*/
export const enhance = compose(
/**
* Connect to the Redux store.
*/
withStore(undefined, {
setupMediaBrowser,
openMediaBrowser,
}),
/**
* Attach the setup hooks.
*/
withSetup({
componentDidMount() {
const {
field,
ui,
setupField,
setupValidation,
setupMediaBrowser,
} = this.props;
setupField(field.id, field.type, ui);
setupMediaBrowser(field.id);
if (field.required) {
setupValidation(field.id, VALIDATION_BASE);
}
},
}),
/**
* Component Handlers.
*/
withHandlers({
resetCurrentlyEditedAttachment: ({ field, updateField }) => () => {
updateField(field.id, {
selected: null,
edit: {
id: '',
title: '',
alt: '',
caption: '',
description: '',
artist: '',
album: '',
}
})
},
}),
/**
* Pass some handlers to the component.
*/
withHandlers({
openBrowser: ({ field, openMediaBrowser }) => (index) => {
if (isNumber(index)) {
field.selected = index;
}
openMediaBrowser(field.id);
},
handleSortItems: ({ field, setFieldValue }) => newItems => {
newItems = newItems.map(item => parseInt(item, 10));
let index = -1;
let newValue = sortBy(field.value, (item) => {
index++;
return newItems.indexOf(index);
});
setFieldValue(field.id, newValue);
},
handleRemoveItem: ({ field, setFieldValue, resetCurrentlyEditedAttachment }) => (index) => {
field.value.splice(index, 1);
setFieldValue(field.id, field.value);
resetCurrentlyEditedAttachment();
},
openEditAttachment: ({ field, updateField, openMediaBrowser }) => (item) => {
const $container = $(`#${field.parent}`);
// For big containers and non-mobile devices, use the inline edit
// Otherwise, fallback to Media Browser
if ( $container.outerWidth() > 767 ) {
const attachmentMeta = field.value_meta[ item ];
updateField(field.id, {
selected: item,
editMode: 'inline',
edit: {
id: parseInt(item, 10),
title: attachmentMeta.title,
alt: attachmentMeta.alt,
caption: attachmentMeta.caption,
description: attachmentMeta.description,
artist: attachmentMeta.artist || '',
album: attachmentMeta.album || '',
}
});
} else {
updateField(field.id, {
selected: item,
editMode: 'modal',
});
openMediaBrowser(field.id);
}
},
closeEditAttachment: ({ resetCurrentlyEditedAttachment }) => () => {
resetCurrentlyEditedAttachment();
}
}),
/**
* Pass some props to the component.
*/
withProps(({ field, collapseComplexGroup }) => {
const sortableOptions = {
handle: '.carbon-description',
items: '.carbon-media-gallery-list-item',
placeholder: 'carbon-media-gallery-list-item ui-placeholder-highlight',
forcePlaceholderSize: true,
};
return {
sortableOptions,
};
}),
);
export default setStatic('type', [
TYPE_MEDIA_GALLERY,
])(enhance(MediaGalleryField));
|
packages/logos/src/cassandra.js | geek/joyent-portal | import React from 'react';
export default props => (
<svg
id="svg4300"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 42 42"
{...props}
>
<defs>
<style dangerouslySetInnerHTML={{ __html: '.cls-1{fill:#fff}' }} />
</defs>
<title>Artboard 1 copy 15</title>
<path
fill="#1B3240"
d="M42 13.35s-2.6 3-4.5 2.3a10.24 10.24 0 0 0 3-3.4s-3.3 3.4-5.6 2.9a10.87 10.87 0 0 0 3.1-4.5s-2.6 4.1-4.3 4.2a10.74 10.74 0 0 0 2.7-4.1s-2.2 3.2-3.8 3.4c2.3-2 2.3-3.3 2.3-3.3s-2.2 2.8-3.6 3.4c-.2-.1-.3-.2-.5-.3a21.11 21.11 0 0 0 2.2-3.4s-2 2.7-3 3c-.1-.1-.3-.1-.4-.2 0-.4.9-1.5.9-1.5s-1.3 1.2-1.9 1.1h-.1a12.81 12.81 0 0 0 2.2-2.9 13.23 13.23 0 0 1-2.9 2.6c-.1 0-.2-.1-.3-.1l1.2-2.5s-1 2.1-2.5 2.2c-.2 0-.3-.1-.5-.1a6.88 6.88 0 0 0 1.1-1.9s-1.3 2.1-3 1.5c-.4-.1.5-1.1.5-1.1s-1.1 1.1-1.9.9 0-1.5 0-1.5-.9 1.3-1.3 1.8h-.3a3.47 3.47 0 0 1 .2-1.3 6.77 6.77 0 0 1-1.1 1.4h-.5c-.3-.3.1-1.5.1-1.5s-.6 1.7-1 1.6S18 11 18 11a2.89 2.89 0 0 1-.5 1.4 21.76 21.76 0 0 0-4.9 1.4C9.1 15.1 5.2 17.5.7 22c2.9-1.5 4.9-3.4 7.5-5a4.18 4.18 0 0 0-.9 2.7c.1 1.7 1.6 3.2 3.9 4.1-.1 0-.3-.1-.4-.1-4-1.1-7.2.9-10.7-.9.8.6 1.7 1.3 4.4 1.2.9 0 3.8-.1 4.3.3S7 27 7 27s3.9-3.3 4.3-2.2c.2.7-1.1 2.6-1.1 2.6s1.4-1.9 2.4-2.2a1.33 1.33 0 0 1 1.8.5c.3.5-1.6 2.7-1.6 2.7s2.6-2.5 3-2.4 0 2.4 0 2.4 1-2.3 1.5-2.4c.7-.2-1.6 5.3-1.6 5.3s2.8-5.1 3.3-5.2c.9-.2 1.5 3.6 1.5 3.6s-.4-3.3 0-3.5c3-1.3 1.3 5.7 1.3 5.7s2-4.8.8-5.8a6.77 6.77 0 0 1 2.8 5.8s.8-1.8-1.5-6.2c1.3-.1 3.1 3.2 3.1 3.2s-2-3.6-.7-3.7c2.8-.1 3 4.8 3 4.8s.8-.7-1.4-5.6c1.4-.9 4.8 4.5 4.8 4.5s-3.1-5.3-2.6-5.6 2.4 1.7 2.4 1.7-1.4-2-1-2.1 4.1 3.9 4.1 3.9-3.3-4-2.7-4.5c.3-.3 1.2.2 2 .7-1-.8-2.5-1.9-2-2.1 1-.5 3.9 1.3 3.9 1.3s-1.7-1.4-1.5-1.8 3.7 2.2 3.7 2.2-3-2.4-3.2-3 2.4.2 2.4.2-2.8-1.3-2.9-1.7 1.9.4 1.9.4-2.6-2.1-3.2-.4c-.2.3-.3.6-.5.9a2.62 2.62 0 0 0 .2-1.5 2.84 2.84 0 0 0-.4-1.3 7.37 7.37 0 0 0 2.1.9c3.95.35 6.6-3.75 6.6-3.75z"
/>
<path
fill="#1B3240"
d="M34.65 23.05c.6.4 1 .7 1 .7a4.24 4.24 0 0 0-1-.7z"
/>
<path
className="cls-1"
d="M27.25 13.25c-1.5-.2-3.4-.5-5.4-.6a7.07 7.07 0 0 1 3.7 1.2 7.84 7.84 0 0 1-.5 1.4h-.2a.68.68 0 0 0-.7.7.52.52 0 0 0 .2.4 6.73 6.73 0 0 1-1.5 1.4 2.32 2.32 0 0 0-4.6.4v.1a5.41 5.41 0 0 1-2.2-1.5 5.39 5.39 0 0 1 .7-1.3h.3a.79.79 0 0 0 .8-.8.37.37 0 0 0-.1-.3 6.39 6.39 0 0 1 4.6-1.3c-.1 0-.3-.1-.4-.1a5.36 5.36 0 0 0-4.6 1h-.3a.79.79 0 0 0-.8.8v.3a4.73 4.73 0 0 0-.7 1.2 5.36 5.36 0 0 1-1.1-2.7h-.1v.1a5.45 5.45 0 0 0 1 3.1 4.33 4.33 0 0 1-.1.5 6.08 6.08 0 0 0-.1 1.9 1.15 1.15 0 0 0-.6.9.94.94 0 0 0 1 1h.1a7.1 7.1 0 0 0 1 1.4 7 7 0 0 1-4.1-6.4 2.8 2.8 0 0 1 1.6-2.5 24.88 24.88 0 0 0-2.9 1.1 8.52 8.52 0 0 0-.4 2.3c0 4.3 3.9 7.7 8.6 7.7s8.6-3.4 8.6-7.7a4.88 4.88 0 0 0-.8-3.7zm-10.2 8.6a3.88 3.88 0 0 1-.6-1.1.91.91 0 0 0 .3-.7 1.08 1.08 0 0 0-.8-1 5 5 0 0 1 .1-1.7v-.1a6 6 0 0 0 2.5 1.6 2.19 2.19 0 0 0 .3.5 8.32 8.32 0 0 0-1.8 2.5zm2.7 1.3A11 11 0 0 1 18 23c-.2-.2-.4-.3-.5-.5a5.46 5.46 0 0 1 1.8-2.4 2.39 2.39 0 0 0 1.4.5 2.43 2.43 0 0 0 2.2-1.5 6.72 6.72 0 0 1 2.8 1 7.43 7.43 0 0 1-5.95 3.05zm6.1-3.6a5.51 5.51 0 0 0-2.7-1.2 5.51 5.51 0 0 0 1.7-1.7H25a.68.68 0 0 0 .7-.7.76.76 0 0 0-.2-.5 4 4 0 0 0 .3-1.5 2.66 2.66 0 0 1 1 2.1 6.76 6.76 0 0 1-.95 3.5z"
/>
</svg>
);
|
frontend/app_v2/src/common/icons/BackArrow.js | First-Peoples-Cultural-Council/fv-web-ui | import React from 'react'
import PropTypes from 'prop-types'
/**
* @summary BackArrow
* @component
*
* @param {object} props
*
* @returns {node} jsx markup
*/
function BackArrow({ styling }) {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" className={styling}>
<title>BackArrow</title>
<g>
<g>
<path d="M5273.1,2400.1v-2c0-2.8-5-4-9.7-4s-9.7,1.3-9.7,4v2c0,1.8,0.7,3.6,2,4.9l5,4.9c0.3,0.3,0.4,0.6,0.4,1v6.4 c0,0.4,0.2,0.7,0.6,0.8l2.9,0.9c0.5,0.1,1-0.2,1-0.8v-7.2c0-0.4,0.2-0.7,0.4-1l5.1-5C5272.4,2403.7,5273.1,2401.9,5273.1,2400.1z M5263.4,2400c-4.8,0-7.4-1.3-7.5-1.8v0c0.1-0.5,2.7-1.8,7.5-1.8c4.8,0,7.3,1.3,7.5,1.8C5270.7,2398.7,5268.2,2400,5263.4,2400z" />
<path d="M5268.4,2410.3c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1h4.3c0.6,0,1-0.4,1-1c0-0.6-0.4-1-1-1H5268.4z" />
<path d="M5272.7,2413.7h-4.3c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1h4.3c0.6,0,1-0.4,1-1C5273.7,2414.1,5273.3,2413.7,5272.7,2413.7z" />
<path d="M5272.7,2417h-4.3c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1h4.3c0.6,0,1-0.4,1-1C5273.7,2417.5,5273.3,2417,5272.7,2417z" />
</g>
<path d="M97.5,88.7c0-22.6-21.8-53.7-49.4-58.8V11.3L2.5,45.1l45.6,33.8V60C67.4,62,84.6,71.2,97.5,88.7z" />
</g>
</svg>
)
}
// PROPTYPES
const { string } = PropTypes
BackArrow.propTypes = {
styling: string,
}
export default BackArrow
|
src/component/IconSnackbarContent/index.js | dlennox24/ricro-app-template | import IconButton from '@material-ui/core/IconButton';
import SnackbarContent from '@material-ui/core/SnackbarContent';
import withStyles from '@material-ui/core/styles/withStyles';
import classNames from 'classnames';
import IconAlert from 'mdi-material-ui/Alert';
import IconAlertCircle from 'mdi-material-ui/AlertCircle';
import IconCheckCircle from 'mdi-material-ui/CheckCircle';
import IconClose from 'mdi-material-ui/Close';
import IconInformation from 'mdi-material-ui/Information';
import PropTypes from 'prop-types';
import React from 'react';
import styles from './styles';
const variantIcon = {
success: IconCheckCircle,
warning: IconAlert,
error: IconAlertCircle,
info: IconInformation,
};
function IconSnackbarContent({
classes,
className,
disableAction,
disableIcon,
icon,
message,
onClose,
variant,
...other
}) {
variant = variant === 'default' ? null : variant;
const Icon = icon || variantIcon[variant];
disableIcon = disableIcon || Icon == null;
return (
<SnackbarContent
className={classNames(classes[variant], className)}
aria-describedby="snackbar-content"
message={
<span id="snackbar-content" className={classes.message}>
{!disableIcon && <Icon className={classNames(classes.icon, classes.iconVariant)} />}
{message}
</span>
}
action={
!disableAction && [
<IconButton
key="close"
aria-label="Close"
color="inherit"
className={classes.close}
onClick={onClose}
>
<IconClose className={classes.icon} />
</IconButton>,
]
}
{...other}
/>
);
}
IconSnackbarContent.propTypes = {
classes: PropTypes.object.isRequired, // MUI withStyles()
className: PropTypes.string,
disableAction: PropTypes.bool,
disableIcon: PropTypes.bool,
icon: PropTypes.func,
message: PropTypes.node,
onClose: PropTypes.func,
variant: PropTypes.oneOf([
'default',
'primary',
'secondary',
'success',
'warning',
'error',
'info',
]),
};
export default withStyles(styles)(IconSnackbarContent);
|
src/main/internal/adaption/react/useState.js | mcjazzyfunky/js-surface | // external imports
import React from 'react'
// --- useState -----------------------------------------------------
const useState = React.useState
// --- exports ------------------------------------------------------
export default useState
|
index.ios.js | swashcap/LookieHere | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import App from './src/App';
export default class LookieHere extends Component {
render() {
return <App />;
}
}
AppRegistry.registerComponent('LookieHere', () => LookieHere);
|
blueocean-material-icons/src/js/components/svg-icons/action/class.js | jenkinsci/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const ActionClass = (props) => (
<SvgIcon {...props}>
<path d="M18 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 4h5v8l-2.5-1.5L6 12V4z"/>
</SvgIcon>
);
ActionClass.displayName = 'ActionClass';
ActionClass.muiName = 'SvgIcon';
export default ActionClass;
|
src/App/Body/AboutButton.js | ksmithbaylor/emc-license-summarizer | import React from 'react';
import { version } from 'root/package.json';
import RaisedButton from 'material-ui/lib/raised-button';
import FlatButton from 'material-ui/lib/flat-button';
import Dialog from 'material-ui/lib/dialog';
export default class AboutButton extends React.Component {
state = {
dialogIsOpen: false
};
render() {
const okButton = (
<FlatButton
label="OK"
primary
onTouchTap={this.closeDialog}
/>
);
return (
<div style={style.container}>
<RaisedButton
label="About"
onTouchTap={this.openDialog}
/>
<Dialog
title="About this tool"
open={this.state.dialogIsOpen}
actions={[okButton]}
onRequestClose={this.closeDialog}
modal={false}
>
<p>Intelligent Capture License Decoder (version {version})</p>
<p>
{'Concept and specifications by Jim Smith. Designed and implemented by '}
<a href="https://www.linkedin.com/in/ksmithbaylor" target="_blank">
Kevin Smith
</a>.
</p>
</Dialog>
</div>
);
}
closeDialog = () => this.setState({ dialogIsOpen: false });
openDialog = () => this.setState({ dialogIsOpen: true });
}
const style = {
container: {
display: 'inline-block',
marginRight: '0.5em'
}
};
|
modules/RouteUtils.js | BerkeleyTrue/react-router | import React from 'react'
import warning from 'warning'
function isValidChild(object) {
return object == null || React.isValidElement(object)
}
export function isReactChildren(object) {
return isValidChild(object) || (Array.isArray(object) && object.every(isValidChild))
}
function checkPropTypes(componentName, propTypes, props) {
componentName = componentName || 'UnknownComponent'
for (const propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
const error = propTypes[propName](props, propName, componentName)
if (error instanceof Error)
warning(false, error.message)
}
}
}
function createRoute(defaultProps, props) {
return { ...defaultProps, ...props }
}
export function createRouteFromReactElement(element) {
const type = element.type
const route = createRoute(type.defaultProps, element.props)
if (type.propTypes)
checkPropTypes(type.displayName || type.name, type.propTypes, route)
if (route.children) {
const childRoutes = createRoutesFromReactChildren(route.children, route)
if (childRoutes.length)
route.childRoutes = childRoutes
delete route.children
}
return route
}
/**
* Creates and returns a routes object from the given ReactChildren. JSX
* provides a convenient way to visualize how routes in the hierarchy are
* nested.
*
* import { Route, createRoutesFromReactChildren } from 'react-router'
*
* const routes = createRoutesFromReactChildren(
* <Route component={App}>
* <Route path="home" component={Dashboard}/>
* <Route path="news" component={NewsFeed}/>
* </Route>
* )
*
* Note: This method is automatically used when you provide <Route> children
* to a <Router> component.
*/
export function createRoutesFromReactChildren(children, parentRoute) {
const routes = []
React.Children.forEach(children, function (element) {
if (React.isValidElement(element)) {
// Component classes may have a static create* method.
if (element.type.createRouteFromReactElement) {
const route = element.type.createRouteFromReactElement(element, parentRoute)
if (route)
routes.push(route)
} else {
routes.push(createRouteFromReactElement(element))
}
}
})
return routes
}
/**
* Creates and returns an array of routes from the given object which
* may be a JSX route, a plain object route, or an array of either.
*/
export function createRoutes(routes) {
if (isReactChildren(routes)) {
routes = createRoutesFromReactChildren(routes)
} else if (routes && !Array.isArray(routes)) {
routes = [ routes ]
}
return routes
}
|
src/index.js | notifapi/notifapi-web | import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import store from './ui/store';
import Routes from './ui/routes';
import './ui/main.css';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
/** tracer alert and js erros **/
// import Raven from 'raven-js';
//
// // Tracer the error code and warning on production
// Raven.config(process.env.REACT_APP_RAVEN_URL, {
// environment: process.env.REACT_APP_ENVIRONMENT
// }).install();
const ownStore = store();
ReactDOM.render(
<Provider store={ownStore}>
<Router history={browserHistory} routes={Routes} />
</Provider>,
document.getElementById('root')
);
|
docs/src/app/components/pages/components/DatePicker/ExampleToggle.js | rhaedes/material-ui | import React from 'react';
import DatePicker from 'material-ui/DatePicker';
import TextField from 'material-ui/TextField';
import Toggle from 'material-ui/Toggle';
const optionsStyle = {
maxWidth: 255,
marginRight: 'auto',
};
export default class DatePickerExampleToggle extends React.Component {
constructor(props) {
super(props);
const minDate = new Date();
const maxDate = new Date();
minDate.setFullYear(minDate.getFullYear() - 1);
minDate.setHours(0, 0, 0, 0);
maxDate.setFullYear(maxDate.getFullYear() + 1);
maxDate.setHours(0, 0, 0, 0);
this.state = {
minDate: minDate,
maxDate: maxDate,
autoOk: false,
disableYearSelection: false,
};
}
handleChangeMinDate = (event) => {
this.setState({
minDate: new Date(event.target.value),
});
};
handleChangeMaxDate = (event) => {
this.setState({
maxDate: new Date(event.target.value),
});
};
handleToggle = (event, toggled) => {
this.setState({
[event.target.name]: toggled,
});
};
render() {
return (
<div>
<DatePicker
hintText="Ranged Date Picker"
autoOk={this.state.autoOk}
minDate={this.state.minDate}
maxDate={this.state.maxDate}
disableYearSelection={this.state.disableYearSelection}
/>
<div style={optionsStyle}>
<TextField
floatingLabelText="Min Date"
value={this.state.minDate.toDateString()}
onChange={this.handleChangeMinDate}
/>
<TextField
floatingLabelText="Max Date"
value={this.state.maxDate.toDateString()}
onChange={this.handleChangeMaxDate}
/>
<Toggle
name="autoOk"
value="autoOk"
label="Auto Accept"
toggled={this.state.autoOk}
onToggle={this.handleToggle}
/>
<Toggle
name="disableYearSelection"
value="disableYearSelection"
label="Disable Year Selection"
toggled={this.state.disableYearSelection}
onToggle={this.handleToggle}
/>
</div>
</div>
);
}
}
|
packages/react-scripts/fixtures/kitchensink/template/src/features/webpack/LinkedModules.js | Timer/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import './assets/style.css';
import { test, version } from 'test-integrity';
const LinkedModules = () => {
const v = version();
if (!test() || v !== '2.0.0') {
throw new Error('Functionality test did not pass.');
}
return <p id="feature-linked-modules">{v}</p>;
};
export default LinkedModules;
|
server/SSR.js | nathanhood/mmdb | import fs from 'fs';
import { resolve } from 'path';
import React from 'react';
import { ConnectedRouter } from 'react-router-redux';
import { renderToString } from 'react-dom/server';
import { Provider } from 'react-redux';
import { ServerStyleSheet } from 'styled-components';
import createHistory from 'history/createMemoryHistory';
// Import all components
import App from 'containers/App';
import configureStore from 'configureStore';
import initialState from 'initialState';
/**
* Retrieve the template generated by production webpack build,
* inject rendered components and relevant CSS,
* and return fully rendered HTML that is ready for browser
*
* @param {string} html
* @param {string} criticalCSS
* @return {string}
*/
function renderFullPage(html, criticalCSS, preloadedState) { // eslint-disable-line no-unused-vars
const page = fs.readFileSync(resolve(process.cwd() + '/server/templates/index.html'));
return eval('`' + page + '`'); // eslint-disable-line no-eval
}
const renderSkeleton = () => {
return renderFullPage('', '', 'window.__MMDB_PRELOADED_STATE=' + JSON.stringify({ ...initialState }));
}
const render = (data) => {
const sheet = new ServerStyleSheet();
// Create redux store with history
const HISTORY = createHistory();
const STORE = configureStore({ ...initialState, ...data }, HISTORY, true);
const HTML = renderToString(sheet.collectStyles(
<Provider store={STORE}>
<ConnectedRouter history={HISTORY}>
<App />
</ConnectedRouter>
</Provider>
));
return renderFullPage(
HTML,
sheet.getStyleTags(),
'window.__MMDB_PRELOADED_STATE=' + JSON.stringify(STORE.getState())
);
};
export default {
render,
renderSkeleton,
};
|
src/templates/noutati.js | radubrehar/evanghelic.ro | import React from 'react';
import Helmet from 'src/components/Helmet';
import Text from '@app/Text';
import nl2br from 'nl2br';
export default function NoutatiTemplate({
data // this prop will be injected by the GraphQL query we'll write in a bit
}) {
const { markdownRemark: post, site } = data;
return (
<div css={{ paddingTop: 20 }} className="container">
<Helmet title={`${post.frontmatter.title}`} />
<div className="blog-post">
<div className="row">
<Text
className="col "
size="headline"
css={{ marginBottom: 20 }}
dangerouslySetInnerHTML={{ __html: nl2br(post.frontmatter.title) }}
/>
</div>
<Text
size="std-large"
dangerouslySetInnerHTML={{ __html: post.html }}
/>
</div>
</div>
);
}
export const query = graphql`
query NoutatiQuery($slug: String!) {
site {
siteMetadata {
title
}
}
markdownRemark(fields: { slug: { eq: $slug } }) {
html
frontmatter {
title
}
}
}
`;
|
fixtures/flight/src/index.js | rickbeerendonk/react | import React from 'react';
import ReactDOM from 'react-dom';
import ReactFlightDOMClient from 'react-flight-dom-webpack';
import App from './App';
let data = ReactFlightDOMClient.readFromFetch(fetch('http://localhost:3001'));
ReactDOM.render(<App data={data} />, document.getElementById('root'));
|
docs-ui/components/detailedError.stories.js | ifduyue/sentry | import React from 'react';
import {storiesOf} from '@storybook/react';
import {action} from '@storybook/addon-actions';
import {withInfo} from '@storybook/addon-info';
import DetailedError from 'app/components/errors/detailedError';
// eslint-disable-next-line
storiesOf('DetailedError', module)
.add(
'default',
withInfo('Displays a detailed error message')(() => (
<DetailedError heading="Error heading" message="Error message" />
))
)
.add(
'with retry',
withInfo(
'If `onRetry` callback is supplied, will show a "Retry" button in footer'
)(() => (
<DetailedError
onRetry={action('onRetry')}
heading="Error heading"
message="Error message"
/>
))
)
.add(
'hides support links',
withInfo('Hides support links')(() => (
<DetailedError
onRetry={action('onRetry')}
hideSupportLinks
heading="Error heading"
message="Error message"
/>
))
)
.add(
'hides footer',
withInfo('Hides footer if no support links or retry')(() => (
<DetailedError hideSupportLinks heading="Error heading" message="Error message" />
))
);
|
src/routes/not-found/NotFound.js | niketpathak/npk-website | /**
* @author Niket Pathak. (http://www.niketpathak.com/)
*
* Copyright © 2014-present. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import PropTypes from 'prop-types';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './NotFound.css';
class NotFound extends React.Component {
static propTypes = {
title: PropTypes.string.isRequired,
};
render() {
return (
<div className={s.root}>
<div className={s.container}>
<h1>{this.props.title}</h1>
<p>Sorry, the page you were trying to view does not exist.</p>
</div>
</div>
);
}
}
export default withStyles(s)(NotFound);
|
src/components/Chess.js | Korkemoms/amodahl.no | // @flow
import React from 'react'
import '../MyContent.scss'
import '../App.scss'
import ChessGame from 'chess-client'
import DocumentTitle from 'react-document-title'
import MyHeader from '../components/MyHeader'
import {
Grid,
PageHeader
} from 'react-bootstrap'
/* Purely presentational component */
const Chess = (props: {
readMore: ?boolean,
toggleReadMore: ?boolean,
myFetch: Function,
user: ?Object,
token: ?string,
push: Function
}) =>
<DocumentTitle title='Chess game'>
<div>
<MyHeader headline='Chess♘' />
<div className='mycontent'>
<ChessGame
playerUid={props.user ? props.user.uid : null}
playerName={props.user ? props.user.name : null}
myFetch={props.token !== null ? props.myFetch(props.token) : null}
navigate={props.push}
/>
</div>
<div className='mycontent' style={{ marginTop: '10em' }}>
<Grid>
<PageHeader>About this app</PageHeader>
<p>
This app is made with React, Redux and Bootstrap. The API is
implemented with PHP and MySQL.
</p>
<p><small>
<label>{'Client:'}</label> <a href='https://github.com/Korkemoms/chess-client'>
{'https://github.com/Korkemoms/chess-client'}</a>
<br /><label>{'API:'}</label> <a href='https://github.com/Korkemoms/amodahl.no-api'>
{'https://github.com/Korkemoms/amodahl.no-api'}</a>
</small></p>
</Grid>
</div>
</div>
</DocumentTitle>
export default Chess
|
frontend/src/sidebar/FlagsList.js | kamirov/song-synonymizer | import React from 'react';
import { FormControlLabel, FormGroup } from 'material-ui/Form';
import Switch from 'material-ui/Switch';
import PropTypes from 'prop-types'
import Tooltip from 'material-ui/Tooltip';
import ExpansionPanel, { ExpansionPanelDetails, ExpansionPanelSummary, } from 'material-ui/ExpansionPanel';
import Typography from 'material-ui/Typography';
import ExpandMoreIcon from 'material-ui-icons/ExpandMore';
const FlagsList = ({flags, flagDetails, disabled, onChange}) => {
const flagControls = {};
Object.keys(flagDetails).forEach(ruleType => {
flagControls[ruleType] = Object.keys(flagDetails[ruleType]).map((key, idx) => {
const formElement = <FormControlLabel
key={idx}
control={
<Switch
checked={flags[key]}
disabled={flagDetails[ruleType][key].disabled || disabled}
onChange={() => onChange(key)}
/>
}
label={flagDetails[ruleType][key].label}
/>
let returned;
if (flagDetails[ruleType][key].tooltip) {
returned = <Tooltip
key={idx + '-tooltip'}
title={flagDetails[ruleType][key].tooltip}>
{formElement}
</Tooltip>
} else {
returned = formElement;
}
return returned;
});
});
return <div>
<ExpansionPanel>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
<Typography>Rhythm Rules</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<FormGroup>{flagControls.rhythm}</FormGroup>
</ExpansionPanelDetails>
</ExpansionPanel>
<ExpansionPanel>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
<Typography>Word Rules</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<FormGroup>{flagControls.word}</FormGroup>
</ExpansionPanelDetails>
</ExpansionPanel>
</div>
}
FlagsList.propTypes = {
flags: PropTypes.object.isRequired,
flagDetails: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired
}
export default FlagsList; |
client/src/components/MonthSelector.js | Nauktis/inab | import React from 'react';
import ui from 'redux-ui';
import Button from './Button';
import FontAwesome from 'react-fontawesome';
@ui()
class MonthSelector extends React.Component {
static propTypes = {
ui: React.PropTypes.object.isRequired,
updateUI: React.PropTypes.func.isRequired
};
previous() {
const current_month = this.props.ui.month;
if (current_month == 1) {
this.props.updateUI({year: this.props.ui.year - 1, month: 12});
} else {
this.props.updateUI('month', current_month - 1);
}
}
current() {
const d = new Date;
this.props.updateUI({year: d.getFullYear(), month: d.getMonth() + 1});
}
next() {
const current_month = this.props.ui.month;
if (current_month == 12) {
this.props.updateUI({year: this.props.ui.year + 1, month: 1});
} else {
this.props.updateUI('month', current_month + 1);
}
}
render() {
return (
<div className="btn-group" role="group">
<Button onClick={::this.previous}><FontAwesome name='arrow-left' /></Button>
<Button onClick={::this.current}>{this.props.ui.month}-{this.props.ui.year}</Button>
<Button onClick={::this.next}><FontAwesome name='arrow-right' /></Button>
</div>
);
}
}
export default MonthSelector;
|
src/svg-icons/maps/local-bar.js | nathanmarks/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsLocalBar = (props) => (
<SvgIcon {...props}>
<path d="M21 5V3H3v2l8 9v5H6v2h12v-2h-5v-5l8-9zM7.43 7L5.66 5h12.69l-1.78 2H7.43z"/>
</SvgIcon>
);
MapsLocalBar = pure(MapsLocalBar);
MapsLocalBar.displayName = 'MapsLocalBar';
MapsLocalBar.muiName = 'SvgIcon';
export default MapsLocalBar;
|
client/src/components/Draftail/blocks/ImageBlock.js | timorieber/wagtail | import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { DraftUtils } from 'draftail';
import { STRINGS } from '../../../config/wagtailConfig';
import MediaBlock from '../blocks/MediaBlock';
/**
* Editor block to preview and edit images.
*/
class ImageBlock extends Component {
constructor(props) {
super(props);
this.changeAlt = this.changeAlt.bind(this);
}
changeAlt(e) {
const { block, blockProps } = this.props;
const { editorState, onChange } = blockProps;
const data = {
alt: e.target.value,
};
onChange(DraftUtils.updateBlockEntity(editorState, block, data));
}
render() {
const { blockProps } = this.props;
const { entity, onRemoveEntity } = blockProps;
const { src, alt } = entity.getData();
const altLabel = `${STRINGS.ALT_TEXT}: “${alt || ''}”`;
return (
<MediaBlock {...this.props} src={src} alt="">
<p className="ImageBlock__alt">{altLabel}</p>
<button className="button button-secondary no Tooltip__button" onClick={onRemoveEntity}>
{STRINGS.DELETE}
</button>
</MediaBlock>
);
}
}
ImageBlock.propTypes = {
block: PropTypes.object.isRequired,
blockProps: PropTypes.shape({
editorState: PropTypes.object.isRequired,
entity: PropTypes.object,
onChange: PropTypes.func.isRequired,
}).isRequired,
};
export default ImageBlock;
|
app/components/Chat/MessageInput.js | SynapseNetwork/Synapse-Desktop | /* **************************************************************
* Synapse - Desktop Client
* @author Marco Fernandez Pranno <[email protected]>
* @licence MIT
* @link https://github.com/SynapseNetwork/Synapse-Desktop
* @version 1.0
* ************************************************************** */
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { addMessageToSelf } from '../../actions/chatActions';
import { storeMessageRequestKey } from '../../actions/chatActions';
// TODO: Refactor into stateless storing current message in store ?
class MessageInput extends React.Component {
constructor(props){
super(props);
this.handleSend = this.handleSend.bind(this);
this.state = {
message: ''
};
}
handleSend() {
const message = {
text: this.state.message,
time: Date.now(),
emitterId: this.props.emitterId,
receiverId: this.props.receiverId
};
this.props.addMessageToSelf(message, this.props.receiverId);
this.props.storeMessageRequestKey(message);
this.setState({
message: ""
});
}
render() {
return (
<div className="input-message-wrapper">
<textarea
className="materialize-textarea conversation-input"
rows="5"
cols="50"
value={this.state.message}
onKeyPress={(ev) => {
if(ev.key === 'Enter') {
ev.preventDefault();
this.handleSend();
}
}}
onChange={(ev) => { this.setState({ message: ev.target.value })} }
>
</textarea>
<div className="conversation-send-button" onClick={this.handleSend}>
<a className="btn-floating waves-effect waves-light">
<i className="material-icons">send</i>
</a>
</div>
</div>
)
}
};
const mapDispatchToProps = (dispatch) => {
return bindActionCreators({
storeMessageRequestKey,
addMessageToSelf
}, dispatch);
};
export default connect(null, mapDispatchToProps)(MessageInput);
|
src/pages/news/NBA/NewsNBAMarket.js | HeliumLau/Hoop-react | import React from 'react';
import NewsList from 'components/NewsList.js';
export default class NewsNBAMarket extends React.Component {
render() {
const list = [
{
title: '帕森斯晒自己与演员特里-克鲁斯的合照',
lNum: '28',
cNum: '212',
bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg'
},
{
title: '帕森斯晒自己与演员特里-克鲁斯的合照',
lNum: '28',
cNum: '212',
bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg'
},
{
title: '帕森斯晒自己与演员特里-克鲁斯的合照',
lNum: '28',
cNum: '212',
bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg'
},
{
title: '帕森斯晒自己与演员特里-克鲁斯的合照',
lNum: '28',
cNum: '212',
bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg'
},
{
title: '帕森斯晒自己与演员特里-克鲁斯的合照',
lNum: '28',
cNum: '212',
bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg'
},
{
title: '帕森斯晒自己与演员特里-克鲁斯的合照',
lNum: '28',
cNum: '212',
bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg'
},
{
title: '帕森斯晒自己与演员特里-克鲁斯的合照',
lNum: '28',
cNum: '212',
bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg'
},
{
title: '帕森斯晒自己与演员特里-克鲁斯的合照',
lNum: '28',
cNum: '212',
bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg'
}
];
return (
<NewsList list={list} />
)
}
} |
inventapp/src/Inventory/InventoryItems.js | ladanv/learn-react-js | import React from 'react';
import { Link } from 'react-router';
import { FormattedMessage } from 'react-intl';
import { List, ListItem } from '../List';
import styles from './InventoryItems.scss';
const InventoryItems = ({ items }) => {
return (
<div>
<h1 className={styles.title} >
<FormattedMessage
id={'InventoryItems.title'}
defaultMessage={'Inventory items'} />
</h1>
<List>
{items.map((item) => (
<ListItem key={item.id} >
<Link to={item.url} >
<span className={styles.accent} >{item.name}</span>
{item.description ? <span className={styles.secondary} > {item.description}</span> : null}
<span className={styles.secondary} > {item.category}</span>
</Link>
</ListItem>
))}
</List>
</div>
);
}
export default InventoryItems;
|
src/js/components/movies/MovieCard.js | jorgemxm/r-movies | //-----------------------------------
// MovieCard
//-----------------------------------
// Dependencies
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
// Custom Components
import MovieImage from './MovieImage';
import helpers from '../../utils/helpers';
const propTypes = {
Title: PropTypes.string.isRequired,
imdbID: PropTypes.string.isRequired,
Runtime: PropTypes.string.isRequired,
Year: PropTypes.string.isRequired,
Poster: PropTypes.string.isRequired,
Plot: PropTypes.string.isRequired,
Genre: PropTypes.string.isRequired
};
/**
* Helper Method
* @param { Array } Genre - List of Tags
*/
const _printTags = Genre => (
Genre.split(', ').map(tag => (
<div key={ tag } className="control">
<Link
className="button is-small is-outlined"
to={ `/movies/${ helpers.slugify(tag).toLowerCase() }/` }
>
{ tag }
</Link>
</div>
))
);
// const MovieCard = props => (
const MovieCard = ({
Title,
imdbID,
Runtime,
Year,
Poster,
Plot,
Genre
}) => (
<div className={ `tile is-3 is-parent movie-id-${ imdbID }` } >
<div className="card is-flex is-flex-column">
<Link
className="card-image"
to={ `/movie/${ imdbID }/${ helpers.slugify(Title) }` }
>
<MovieImage
src={ helpers.imagify(Poster) }
alt={ Title }
/>
</Link>
<div className="card-content is-flex is-flex-column">
<div className="title is-4"><strong>{ Title }</strong></div>
<div className="subtitle is-6">
{ helpers.formatDuration(Runtime) }
<small className="is-pulled-right">{ Year }</small>
</div>
<div className="content">
{ helpers.dotdotdot(Plot, 80) }
</div>
<div className="card-tags control is-grouped">
{ _printTags(Genre) }
</div>
</div>
</div>
</div>
);
MovieCard.propTypes = propTypes;
export default MovieCard;
|
tagging_interface/src/views/ProjectView/CurationInterface.js | Michael-Stewart-Webdev/annotation-tool | import React from 'react';
import {Component} from 'react';
import _ from 'underscore';
import ControlBar from 'views/SharedComponents/ControlBar';
import getCookie from 'functions/getCookie';
import initAnnotationsArray from 'views/TaggingInterfaceView/initAnnotationsArray';
import Annotation from 'views/TaggingInterfaceView/Annotation';
import {Comment, CommentInput} from 'views/SharedComponents/Comment';
import ProfileIcon from 'views/SharedComponents/ProfileIcon';
import {Word, Sentence} from 'views/TaggingInterfaceView/documentComponents';
import formatDate from 'functions/formatDate';
import BASE_URL from 'globals/base_url';
import _fetch from 'functions/_fetch';
class CurationInterface extends Component {
constructor(props) {
super(props);
this.state = {
documentId: null,
documents: [],
annotations: [],
compiledAnnotation: null, // annotations produced via compiled labels or perhaps machine learning model?
comments: [],
annotatorAgreement: null,
pageNumber: 1,
totalPages: 1,
recentlySaved: false,
changesMade: false,
searchTerm: null,
sortBy: "Annotations",
documentIdQuery: null, // For searching a specific document id via a comment button
entityColourMap: {},
loading: {
querying: true,
saving: false,
}
}
this.commentBoxRef = React.createRef();
this._isMounted = false;
this.refreshDataFn = null;
}
componentWillMount() {
this._isMounted = true;
if(this.props.documentIdQuery) {
this.setState({
documentIdQuery: this.props.documentIdQuery,
}, this.queryAPI);
return;
}
console.log("Loading state:", this.props.prevState)
if(this.props.prevState) {
this.setState(this.props.prevState);
} else {
this.queryAPI();
}
}
componentDidMount() {
}
componentWillUnmount() {
this._isMounted = false;
}
componentDidUpdate(prevProps, prevState) {
if(!_.isEqual(prevState, this.state)) {
console.log("state updated");
this.props.saveState(this.state);
}
}
async queryAPI() {
if(!this._isMounted) return;
await this.setState({
loading: {
querying: true,
saving: false,
}
})
var queryString = 'projects/' + this.props.project_id + "/curation?pageNumber=" + this.state.pageNumber + "&sortBy=" + this.state.sortBy;
if(this.state.searchTerm) {
queryString += "&searchTerm=" + this.state.searchTerm;
}
if(this.state.documentIdQuery) {
queryString += "&documentId=" + this.state.documentIdQuery;
}
var d = await _fetch(queryString, 'GET', this.props.setErrorCode);
this.setState({
documentId: d.documentId,
tokens: d.tokens,
annotations: initAnnotationsArray([d.tokens], d.annotations, this.state.searchTerm, true), //fix
compiledAnnotation: d.compiledAnnotation ? initAnnotationsArray([d.tokens], [d.compiledAnnotation], this.state.searchTerm, true)[0] : null, //fix
comments: d.comments,
users: d.users,
saveTimes: d.saveTimes,
documentIdQuery: null,
annotatorAgreement: d.annotatorAgreement,
entityColourMap: this.initEntityColourMap(d.categoryHierarchy.children),
pageNumber: d.pageNumber,
totalPages: d.totalPages,
loading: {
querying: false,
saving: false,
}
}, () => {
if(this.refreshDataFn) window.clearTimeout(this.refreshDataFn)
this.refreshDataFn = window.setTimeout(this.queryAPI.bind(this), 3000)
})
}
// Search all documents for a specific search term.
searchDocuments(searchTerm) {
this.setState({
pageNumber: 1,
searchTerm: searchTerm,
}, this.queryAPI);
}
submitAnnotations() {
return null;
}
loadPreviousPage() {
if(this.state.loading.querying) return;
if(this.state.pageNumber === 1) return;
this.setState({
pageNumber: this.state.pageNumber - 1,
}, this.queryAPI)
}
loadNextPage() {
if(this.state.loading.querying) return;
if(this.state.pageNumber >= this.state.totalPages) return;
this.setState({
pageNumber: this.state.pageNumber + 1,
}, this.queryAPI)
}
goToPage(pageNumber) {
if(this.state.loading.querying) return;
if(pageNumber < 1 || pageNumber > this.state.totalPages) return;
this.setState({
pageNumber: pageNumber,
}, this.queryAPI);
}
setSortBy(e) {
var sortBy = e.target.value;
this.setState({
sortBy: sortBy,
}, this.queryAPI)
}
// Initialise the entity colour map, which maps entity_class: colour_index, e.g. "Item": 1. Passed to the Word components to colour
// their labels accordingly.
initEntityColourMap(categoryHierarchy) {
var entityColourMap = {}
for(var ec_idx in categoryHierarchy) {
var entityClass = categoryHierarchy[ec_idx];
entityColourMap[entityClass.name] = entityClass.colorId + 1;
}
return entityColourMap;
}
async submitComment(message, next) {
var t = this;
console.log("Message:", message);
const csrfToken = getCookie('csrf-token');
var postBody = {
text: message,
documentId: this.state.documentId,
}
var d = await _fetch('projects/' + this.props.project_id + '/comments/submit', 'POST', this.props.setErrorCode, postBody);
var comments = this.state.comments;
comments.push(d.comment);
this.setState({
comments: comments,
}, () => {
next();
t.commentBoxRef.current.scrollTop = t.commentBoxRef.current.scrollHeight;
});
}
render() {
return (
<div id="tagging-interface">
<div id="sentence-tagging" className="curation-page">
<ControlBar
pageNumber = {this.state.pageNumber}
totalPages = {this.state.totalPages}
totalPagesAvailable = {this.state.totalPages}
recentlySaved={this.state.recentlySaved}
changesMade={this.state.changesMade}
querying={this.state.loading.querying}
saving={this.state.loading.saving}
inSearchMode={this.state.searchTerm}
showSortBy={true}
sortBy={this.state.sortBy}
sortByOptions={["Annotations", "Agreement", "Document Index"]}
setSortBy={this.setSortBy.bind(this)}
searchDocuments={this.searchDocuments.bind(this)}
submitAnnotations={this.submitAnnotations.bind(this)}
loadPreviousPage={this.loadPreviousPage.bind(this)}
loadNextPage={this.loadNextPage.bind(this)}
goToPage={this.goToPage.bind(this)}
curationPage={true}
/>
{
(!this.state.loading.querying && !this.state.tokens) &&
<div className="loading-message no-results-found">No results found.</div>
}
<div className="curation-interface-inner">
<div className="document-window" id="sentence-tagging">
<div className="agreement-score">
<span className="name">Agreement:</span>
{ this.state.annotatorAgreement !== null && <span className="value">{(this.state.annotatorAgreement * 100).toFixed(2)}%</span>}
{ this.state.annotatorAgreement === null && <span className="value na">N/A</span>}
</div>
{
this.state.annotations.map((annotations, index) =>
<CurationDocumentContainer
user={this.state.users[index] || null}
index={index}
tokens={this.state.tokens}
annotations={this.state.annotations[index]}
entityColourMap={this.state.entityColourMap}
displayOnly={true}
saveTime={this.state.saveTimes[index] || null}
/>
)}
{ this.state.compiledAnnotation && <div className="divider"><span></span></div> }
{ this.state.compiledAnnotation &&
<CurationDocumentContainer
specialName={"Compiled labels"}
specialDescription={"These labels are automatically compiled from the annotations above."}
tokens={this.state.tokens}
annotations={this.state.compiledAnnotation}
entityColourMap={this.state.entityColourMap}
displayOnly={true}
/>
}
</div>
<div className="comments-pane">
<div className="comments-wrapper">
{ this.props.user && this.state.comments &&
<div className="comments-inner">
<h3 className={this.state.comments.length === 0 ? "hidden" : ""}>Comments {this.state.comments.length > 0 && "(" + this.state.comments.length + ")"}</h3>
{this.state.comments.length === 0 && <div className="no-comments-yet">No comments yet.</div>}
<div className="comments-even-more-inner" ref={this.commentBoxRef}>
{ this.state.comments.map((comment, i) => <Comment index={i} {...comment} hideDocumentString={true} />) }
</div>
<CommentInput user_profile_icon={this.props.user.profile_icon} submitComment={this.submitComment.bind(this)}/>
</div>
}
</div>
</div>
</div>
</div>
</div>
)
}
}
class CurationDocumentContainer extends Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="document-container">
<div className="document-wrapper">
<div className={"curation-document" + ((!this.props.specialName && !this.props.user) ? " not-yet-annotated" : "")}>
{ !this.props.user && !this.props.specialName &&
<div className="user-col"></div>
}
{ !this.props.specialName && this.props.user &&
<div className="user-col">
<ProfileIcon user={this.props.user}/>
<div>
<div className="username">{this.props.user && this.props.user.username}</div>
<div className="save-time" style={{'display': 'none'}}>{formatDate(this.props.saveTime, {no_hours: true})}</div>
</div>
</div>
}
{ this.props.specialName &&
<div className="user-col">
<div>
<div className="username"><em>{this.props.specialName}</em><i class="fa fa-info-circle" title={this.props.specialDescription}></i></div></div>
</div>
}
<div className="sentence display-only">
<Sentence
index={this.props.index}
words={this.props.tokens}
annotations={this.props.annotations}
entityColourMap={this.props.entityColourMap}
displayOnly={true}
/>
</div>
</div>
</div>
</div>
)
}
}
export default CurationInterface
|
src/svg-icons/action/account-balance-wallet.js | IsenrichO/mui-with-arrows | 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;
|
src/routes/about/index.js | OSDLabs/swd | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import Layout from '../../components/Layout';
import Page from '../../components/Page';
export default {
path: '/about',
async action() {
const data = await require.ensure([], require => require('./about.md'), 'about');
return {
title: data.title,
chunk: 'about',
component: <Layout isLoggedIn={false}><Page {...data} /></Layout>,
};
},
};
|
18-react-router-redux/src/components/show-location.js | iproduct/course-node-express-react | import React from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
@withRouter
@connect()
export default class ShowTheLocation extends React.Component {
static propTypes = {
match: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
history: PropTypes.object.isRequired
}
render() {
const { match, location, history } = this.props;
return (
<div>
<div>You are now at {location.pathname}</div>
<div>Location: {JSON.stringify(location)}</div>
<div>The match is: {JSON.stringify(match)}</div>
<div>The history contains: {JSON.stringify(history)}</div>
</div>
)
}
} |
src/js/components/icons/base/SocialWordpress.js | kylebyerly-hp/grommet | // (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import CSSClassnames from '../../../utils/CSSClassnames';
import Intl from '../../../utils/Intl';
import Props from '../../../utils/Props';
const CLASS_ROOT = CSSClassnames.CONTROL_ICON;
const COLOR_INDEX = CSSClassnames.COLOR_INDEX;
export default class Icon extends Component {
render () {
const { className, colorIndex } = this.props;
let { a11yTitle, size, responsive } = this.props;
let { intl } = this.context;
const classes = classnames(
CLASS_ROOT,
`${CLASS_ROOT}-social-wordpress`,
className,
{
[`${CLASS_ROOT}--${size}`]: size,
[`${CLASS_ROOT}--responsive`]: responsive,
[`${COLOR_INDEX}-${colorIndex}`]: colorIndex
}
);
a11yTitle = a11yTitle || Intl.getMessage(intl, 'social-wordpress');
const restProps = Props.omit(this.props, Object.keys(Icon.propTypes));
return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fill="#21759B" fillRule="evenodd" d="M0,11.99925 C0,16.749 2.76,20.85375 6.76275,22.7985 L1.03875,7.116 C0.3735,8.60775 0,10.25925 0,11.99925 M20.10015,11.394 C20.10015,9.9105 19.5669,8.88375 19.1109,8.085 C18.50265,7.09575 17.9319,6.25875 17.9319,5.27025 C17.9319,4.167 18.76815,3.14025 19.94715,3.14025 C20.0004,3.14025 20.05065,3.147 20.1024,3.15 C17.9679,1.194 15.12315,0 11.9994,0 C7.8069,0 4.11915,2.151 1.9734,5.40825 C2.2554,5.41725 2.5209,5.4225 2.7459,5.4225 C4.00065,5.4225 5.9439,5.27025 5.9439,5.27025 C6.5904,5.232 6.6669,6.183 6.0204,6.25875 C6.0204,6.25875 5.37015,6.33525 4.64715,6.3735 L9.01665,19.371 L11.64315,11.49525 L9.77415,6.3735 C9.12765,6.33525 8.5149,6.25875 8.5149,6.25875 C7.8684,6.2205 7.94415,5.232 8.5914,5.27025 C8.5914,5.27025 10.5729,5.4225 11.7519,5.4225 C13.00665,5.4225 14.9499,5.27025 14.9499,5.27025 C15.59715,5.232 15.6729,6.183 15.0264,6.25875 C15.0264,6.25875 14.3754,6.33525 13.65315,6.3735 L17.98965,19.272 L19.1874,15.273 C19.7049,13.6125 20.10015,12.42075 20.10015,11.394 M12.21015,13.04895 L8.6094,23.5107 C9.6849,23.8272 10.8219,23.9997 11.9994,23.9997 C13.39665,23.9997 14.7369,23.7582 15.98415,23.31945 C15.95265,23.2677 15.92265,23.2137 15.89865,23.15445 L12.21015,13.04895 Z M22.52925,6.242475 C22.581,6.624975 22.61025,7.034475 22.61025,7.476225 C22.61025,8.693475 22.38225,10.062225 21.6975,11.774475 L18.03225,22.371225 C21.6,20.291475 23.99925,16.425975 23.99925,11.999475 C23.99925,9.912975 23.466,7.951725 22.52925,6.242475" stroke="none"/></svg>;
}
};
Icon.contextTypes = {
intl: PropTypes.object
};
Icon.defaultProps = {
responsive: true
};
Icon.displayName = 'SocialWordpress';
Icon.icon = true;
Icon.propTypes = {
a11yTitle: PropTypes.string,
colorIndex: PropTypes.string,
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']),
responsive: PropTypes.bool
};
|
archimate-frontend/src/main/javascript/components/view/edges/view/viewRelationship.js | zhuj/mentha-web-archimate | import React from 'react'
import { CompositionRelationshipWidget } from '../model/compositionRelationship'
import { AggregationRelationshipWidget } from '../model/aggregationRelationship'
import { AssignmentRelationshipWidget } from '../model/assignmentRelationship'
import { RealizationRelationshipWidget } from '../model/realizationRelationship'
import { ServingRelationshipWidget } from '../model/servingRelationship'
import { AccessRelationshipWidget } from '../model/accessRelationship'
import { InfluenceRelationshipWidget } from '../model/influenceRelationship'
import { TriggeringRelationshipWidget } from '../model/triggeringRelationship'
import { FlowRelationshipWidget } from '../model/flowRelationship'
import { SpecializationRelationshipWidget } from '../model/specializationRelationship'
import { AssociationRelationshipWidget } from '../model/associationRelationship'
export const TYPE='viewRelationship';
export const viewRelationshipWidget = (props) => {
const { conceptInfo } = props;
switch(conceptInfo['_tp']) {
case 'compositionRelationship': return (<CompositionRelationshipWidget {...props}/>);
case 'aggregationRelationship': return (<AggregationRelationshipWidget {...props}/>);
case 'assignmentRelationship': return (<AssignmentRelationshipWidget {...props}/>);
case 'realizationRelationship': return (<RealizationRelationshipWidget {...props}/>);
case 'servingRelationship': return (<ServingRelationshipWidget {...props}/>);
case 'accessRelationship': return (<AccessRelationshipWidget {...props}/>);
case 'influenceRelationship': return (<InfluenceRelationshipWidget {...props}/>);
case 'triggeringRelationship': return (<TriggeringRelationshipWidget {...props}/>);
case 'flowRelationship': return (<FlowRelationshipWidget {...props}/>);
case 'specializationRelationship': return (<SpecializationRelationshipWidget {...props}/>);
case 'associationRelationship': return (<AssociationRelationshipWidget {...props}/>);
}
return null;
};
export const relationships = {
['c']:'compositionRelationship',
['g']:'aggregationRelationship',
['i']:'assignmentRelationship',
['r']:'realizationRelationship',
['v']:'servingRelationship',
['a']:'accessRelationship',
['n']:'influenceRelationship',
['t']:'triggeringRelationship',
['f']:'flowRelationship',
['s']:'specializationRelationship',
['o']:'associationRelationship'
}; |
app/index.js | parrajustin/VueElectron_UTEP | import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router, hashHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import routes from './routes';
import configureStore from './store/configureStore';
import './app.global.css';
const store = configureStore();
const history = syncHistoryWithStore(hashHistory, store);
render(
<Provider store={store}>
<Router history={history} routes={routes} />
</Provider>,
document.getElementById('root')
);
|
src/index.js | abraztsov/react-fetch-hoc | import React from 'react';
const fetchData = get => WrappedComponent =>
class extends React.Component {
constructor(props) {
super(props);
this.state = {
fetchedData: {},
fetchedError: {}
};
}
componentDidMount() {
get(this.props)
.then(response => {
if (!response.ok) {
throw Error(response.statusText);
}
return response.json();
})
.then(fetchedData => this.setState({ fetchedData }))
.catch((e) => {
this.setState({ fetchedError: e });
});
}
render() {
const { fetchedData, fetchedError } = this.state;
return <WrappedComponent {...this.props} {...fetchedData} fetchedError={fetchedError} />
}
}
export default fetchData;
|
client/components/RepoSearch.js | nachein/repo-searcher-react-redux | import React from 'react'
import { browserHistory } from 'react-router';
import { search, fetchRepos } from '../actions/actionCreators';
import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
export default class RepoSearch extends React.Component {
componentDidMount() {
this.setState({ searchTerm: ''});
}
render() {
return (
<div className="search">
<h2>Enter user name</h2>
<TextField
hintText="User name"
className="search-box"
onChange={ (e) => this.handleSearchChange(e)}>
</TextField>
<RaisedButton
className="search-submit"
onClick={this.handleClick.bind(this)}>
Search
</RaisedButton>
</div>
)
}
handleClick() {
let userName = this.state.searchTerm;
if(userName)
browserHistory.push(`/user/${userName}`);
}
handleSearchChange(e) {
this.setState({ searchTerm: e.target.value});
}
}
|
app/components/default-settings/Background.js | opensprints/opensprints-electron | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { remote } from 'electron';
const store = remote.getGlobal('wallpaperStore');
const defaultBackground = '../images/open-sprints-bg.jpg';
const wallpaperTemplatePreviews = {
raceScreen: '../images/open-sprints-background.png',
raceClock: '../images/open-sprints-clock.png',
intermissionScreen: '../images/open-sprints-intermission.png'
};
export default class Background extends Component {
static propTypes = {
bKey: PropTypes.string.isRequired
};
constructor(props) {
super(props);
this.state = {
imgSrc: null,
templatePreviewSrc: wallpaperTemplatePreviews[props.bKey],
showPreview: false
};
}
componentDidMount() {
store.getBackground(this.props.bKey, this.onBackgroundLoaded.bind(this));
}
onBackgroundLoaded(err, imgSrc) {
if (err) {
console.error(err);
return;
}
this.setState({ imgSrc });
}
render() {
const { imgSrc, templatePreviewSrc, showPreview } = this.state;
const { bKey } = this.props;
return (
<div
style={{
border: '1px solid #6FDCFF',
position: 'relative'
}}
>
<img
style={{
display: (showPreview ? null : 'none')
}}
width="100%"
alt="bg"
src={templatePreviewSrc}
/>
<img
style={{
display: (showPreview ? 'none' : null)
}}
width="100%"
alt="bg"
src={imgSrc || defaultBackground}
/>
<div
className="text-uppercase unselectable"
style={{
position: 'absolute',
top: '10px',
right: '10px',
textShadow: '-1px 0 #6FDCFF, 0 1px #6FDCFF, 1px 0 #6FDCFF, 0 -1px #6FDCFF',
cursor: 'pointer'
}}
onMouseEnter={() => {
this.setState({
showPreview: true
});
}}
onMouseLeave={() => {
this.setState({
showPreview: false
});
}}
onClick={() => {
store.downloadTemplate(bKey, () => {});
}}
>
<span
style={{
fontSize: '12px',
verticalAlign: 'top',
paddingRight: '10px'
}}
>
PSD Template
</span>
<i className="material-icons">file_download</i>
</div>
<div
style={{
position: 'absolute',
bottom: '5px',
right: '10px'
}}
>
<input
type="file"
className="inputFile"
style={{ display: 'none' }}
accept="image/*"
ref={(input) => { this.input = input; }}
onChange={(e) => {
if (e.target.files.length > 0) {
const file = e.target.files[0];
store.setNewBackground(bKey, file.path, file.name, (err) => {
if (err) {
console.error(err);
return;
}
store.getBackground(bKey, this.onBackgroundLoaded.bind(this));
});
}
}}
/>
<button
style={{
borderColor: '#6FDCFF',
color: '#0079A1',
backgroundColor: 'white',
padding: '3px 27px',
margin: '9px 12px'
}}
className="btn btn-xs btn-primary"
onClick={() => { this.input.click(); }}
>
Change
</button>
<i
style={{
verticalAlign: 'middle',
textShadow: '-1px 0 #6FDCFF, 0 1px #6FDCFF, 1px 0 #6FDCFF, 0 -1px #6FDCFF',
cursor: 'pointer'
}}
className="material-icons unselectable"
onClick={() => {
store.set(bKey, defaultBackground);
store.getBackground(bKey, this.onBackgroundLoaded.bind(this));
}}
>
delete
</i>
</div>
</div>
);
}
}
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.