path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
renderer/components/Tab.js
reactide/reactide
import React from 'react'; import PropTypes from 'prop-types'; const { getFileExt, getCssClassByFileExt } = require('../../lib/file-tree.js'); const Tab = ({ name, isActive, setActiveTab, path, closeTab }) => { return ( <li className={"texteditor tab " + (isActive? "active" : "")} onClick={() => { setActiveTab(path); }} > <div className={"title " + getCssClassByFileExt(getFileExt(name))}>{name}</div> <div className="close-icon" onClick={(event) => { closeTab(path, event); }} /> </li> ); }; export default Tab;
pages/one/One.js
mikayel/react-cv
'use strict'; import './One.css'; import React from 'react' import Header from '../../components/header/Header'; import Navigation from '../../components/navigation/Navigation'; import Footer from '../../components/footer/Footer'; const One = React.createClass({ contextTypes: { appState: React.PropTypes.func }, add: function() { var c = this.context.appState("a") || 0; c++; this.context.appState({"a": c}); }, render() { return <div className="page_one"> <Header /> <Navigation /> <h3>One { this.context.appState("a") }</h3><input type="button" onClick={this.add} value="add" /> <Footer /> </div> } }) module.exports = One;
examples/FourPlayers.js
SBRK/react-gamepad
import React, { Component } from 'react'; import Gamepad from 'react-gamepad' class PlayerCube extends Component { constructor(props) { super(props) this.state = { speedX: 0.0, speedY: 0.0, x: props.x, y: props.y, connected: false, } } componentDidMount() { window.requestAnimationFrame(this.update.bind(this)) } connectHandler(gamepadIndex) { console.log(`Gamepad ${gamepadIndex} connected!`) this.setState({ connected: true }) } disconnectHandler(gamepadIndex) { console.log(`Gamepad ${gamepadIndex} disconnected !`) this.setState({ connected: false }) } update(datetime) { window.requestAnimationFrame(this.update.bind(this)) const frameTime = datetime - this.previousFrameTime this.previousFrameTime = datetime if (isNaN(frameTime)) return const baseSpeed = 300.0 // pixels per second const ratio = baseSpeed * (frameTime / 1000.0) this.setState({ x: this.state.x + (this.state.speedX * ratio), y: this.state.y - (this.state.speedY * ratio) }) } axisChangeHandler(axisName, value, previousValue) { if (axisName === 'LeftStickX') { this.setState({ speedX: value }) } else if (axisName === 'LeftStickY') { this.setState({ speedY: value }) } } getPlayerStyle() { return { height: '50px', width: '50px', background: this.props.color, color: 'white', fontSize: '20px', textAlign: 'center', lineHeight: '50px', position: 'fixed', top: Math.round(this.state.y) + 'px', left: Math.round(this.state.x) + 'px', } } render() { return ( <Gamepad gamepadIndex={this.props.playerIndex} onConnect={this.connectHandler.bind(this)} onDisconnect={this.disconnectHandler.bind(this)} onAxisChange={this.axisChangeHandler.bind(this)} > {this.state.connected && <div id={`player${this.props.playerIndex}`} style={this.getPlayerStyle()}> {this.props.playerIndex} </div> } </Gamepad> ) } } class FourPlayersExample extends Component { render() { return ( <div> <PlayerCube playerIndex={0} color='red' x={300.0} y={200.0} /> <PlayerCube playerIndex={1} color='blue' x={300.0} y={300.0} /> <PlayerCube playerIndex={2} color='green' x={400.0} y={200.0} /> <PlayerCube playerIndex={3} color='black' x={400.0} y={300.0} /> </div> ); } } export default FourPlayersExample
src/components/stack/PreviewSidebar.js
rokka-io/rokka-dashboard
import React from 'react' import PropTypes from 'prop-types' import rokka from '../../rokka' import Alert from '../Alert' import Spinner from '../Spinner' const PreviewSidebar = ({ organization, onChange, previewImage = null, currentPreviewImage = null, error = null, imageLoading = false, stack = 'dynamic/noop' }) => { if (!previewImage) { return null } const format = previewImage.format === 'jpg' ? 'jpg' : 'png' const previewImages = { original: rokka().render.getUrl(organization, previewImage.hash, format), dynamic: currentPreviewImage ? currentPreviewImage.src : rokka().render.getUrl(organization, previewImage.hash, format, stack) } return ( <div className="col-md-5 col-sm-5"> <h3 className="rka-h2 mv-md"> Preview <button onClick={onChange} className="rka-link-button rka-link flo-r txt-sm"> Change picture </button> </h3> <div className="rka-stack-img-container bg-chess mb-xs bor-light txt-c"> <p className="pa-md bg-white txt-l"> Customized <a href={previewImages.dynamic} className="rka-link flo-r" target="_blank" rel="noopener noreferrer" > Open in new window </a> </p> {error ? <Alert alert={{ type: 'error', message: error }} /> : null} {imageLoading ? <Spinner /> : <img src={previewImages.dynamic} alt="Customized" />} </div> <div className="rka-stack-img-container bg-chess bor-light txt-c"> <p className="pa-md bg-white txt-l"> Original <a href={previewImages.original} className="rka-link flo-r" target="_blank" rel="noopener noreferrer" > Open in new window </a> </p> <img src={previewImages.original} alt="Original" /> </div> </div> ) } PreviewSidebar.propTypes = { organization: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, previewImage: PropTypes.shape({ hash: PropTypes.string.isRequired, format: PropTypes.string.isRequired }), currentPreviewImage: PropTypes.shape({ src: PropTypes.string.isRequired }), stack: PropTypes.string, error: PropTypes.string, imageLoading: PropTypes.bool } export default PreviewSidebar
src/svg-icons/av/high-quality.js
matthewoates/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let AvHighQuality = (props) => ( <SvgIcon {...props}> <path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 11H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm7-1c0 .55-.45 1-1 1h-.75v1.5h-1.5V15H14c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v4zm-3.5-.5h2v-3h-2v3z"/> </SvgIcon> ); AvHighQuality = pure(AvHighQuality); AvHighQuality.displayName = 'AvHighQuality'; AvHighQuality.muiName = 'SvgIcon'; export default AvHighQuality;
app/javascript/mastodon/features/list_timeline/index.js
mimumemo/mastodon
import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnBackButton from '../../components/column_back_button'; import ColumnHeader from '../../components/column_header'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; import { connectListStream } from '../../actions/streaming'; import { expandListTimeline } from '../../actions/timelines'; import { fetchList, deleteList } from '../../actions/lists'; import { openModal } from '../../actions/modal'; import MissingIndicator from '../../components/missing_indicator'; import LoadingIndicator from '../../components/loading_indicator'; const messages = defineMessages({ deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' }, deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' }, }); const mapStateToProps = (state, props) => ({ list: state.getIn(['lists', props.params.id]), hasUnread: state.getIn(['timelines', `list:${props.params.id}`, 'unread']) > 0, }); export default @connect(mapStateToProps) @injectIntl class ListTimeline extends React.PureComponent { static contextTypes = { router: PropTypes.object, }; static propTypes = { params: PropTypes.object.isRequired, dispatch: PropTypes.func.isRequired, shouldUpdateScroll: PropTypes.func, columnId: PropTypes.string, hasUnread: PropTypes.bool, multiColumn: PropTypes.bool, list: PropTypes.oneOfType([ImmutablePropTypes.map, PropTypes.bool]), intl: PropTypes.object.isRequired, }; handlePin = () => { const { columnId, dispatch } = this.props; if (columnId) { dispatch(removeColumn(columnId)); } else { dispatch(addColumn('LIST', { id: this.props.params.id })); this.context.router.history.push('/'); } } handleMove = (dir) => { const { columnId, dispatch } = this.props; dispatch(moveColumn(columnId, dir)); } handleHeaderClick = () => { this.column.scrollTop(); } componentDidMount () { const { dispatch } = this.props; const { id } = this.props.params; dispatch(fetchList(id)); dispatch(expandListTimeline(id)); this.disconnect = dispatch(connectListStream(id)); } componentWillUnmount () { if (this.disconnect) { this.disconnect(); this.disconnect = null; } } setRef = c => { this.column = c; } handleLoadMore = maxId => { const { id } = this.props.params; this.props.dispatch(expandListTimeline(id, { maxId })); } handleEditClick = () => { this.props.dispatch(openModal('LIST_EDITOR', { listId: this.props.params.id })); } handleDeleteClick = () => { const { dispatch, columnId, intl } = this.props; const { id } = this.props.params; dispatch(openModal('CONFIRM', { message: intl.formatMessage(messages.deleteMessage), confirm: intl.formatMessage(messages.deleteConfirm), onConfirm: () => { dispatch(deleteList(id)); if (!!columnId) { dispatch(removeColumn(columnId)); } else { this.context.router.history.push('/lists'); } }, })); } render () { const { shouldUpdateScroll, hasUnread, columnId, multiColumn, list } = this.props; const { id } = this.props.params; const pinned = !!columnId; const title = list ? list.get('title') : id; if (typeof list === 'undefined') { return ( <Column> <div className='scrollable'> <LoadingIndicator /> </div> </Column> ); } else if (list === false) { return ( <Column> <ColumnBackButton /> <MissingIndicator /> </Column> ); } return ( <Column ref={this.setRef} label={title}> <ColumnHeader icon='list-ul' active={hasUnread} title={title} onPin={this.handlePin} onMove={this.handleMove} onClick={this.handleHeaderClick} pinned={pinned} multiColumn={multiColumn} > <div className='column-header__links'> <button className='text-btn column-header__setting-btn' tabIndex='0' onClick={this.handleEditClick}> <i className='fa fa-pencil' /> <FormattedMessage id='lists.edit' defaultMessage='Edit list' /> </button> <button className='text-btn column-header__setting-btn' tabIndex='0' onClick={this.handleDeleteClick}> <i className='fa fa-trash' /> <FormattedMessage id='lists.delete' defaultMessage='Delete list' /> </button> </div> <hr /> </ColumnHeader> <StatusListContainer trackScroll={!pinned} scrollKey={`list_timeline-${columnId}`} timelineId={`list:${id}`} onLoadMore={this.handleLoadMore} emptyMessage={<FormattedMessage id='empty_column.list' defaultMessage='There is nothing in this list yet. When members of this list post new statuses, they will appear here.' />} shouldUpdateScroll={shouldUpdateScroll} /> </Column> ); } }
src/components/scene.js
poshaughnessy/react-three-demo
import React from 'react'; import ReactTHREE from 'react-three'; import THREE from 'three'; import Constants from '../constants'; import RobotRobbyComponent from './models/robotRobby'; import RobotMechComponent from './models/robotMech'; const ROBOT_ROBBY_Y = -25, ROBOT_MECH_Y = 0; class SceneComponent extends React.Component { constructor(props) { super(props); this.state = { modelPosition: new THREE.Vector3(0,0,0), modelRotation: 0 }; this._animate = this._animate.bind(this); } componentDidMount() { // Kick off animation this._animate(); } render() { let x = this.state.modelPosition.x, y = this.state.modelPosition.y, z = this.state.modelPosition.z; // Adjust relative positions let robotRobbyPosition = new THREE.Vector3( x, y + ROBOT_ROBBY_Y, z ), robotMechPosition = new THREE.Vector3( x, y + ROBOT_MECH_Y, z ); let modelEuler = new THREE.Euler(0, this.state.modelRotation), modelQuaternion = new THREE.Quaternion().setFromEuler(modelEuler); let CameraElement = React.createElement( ReactTHREE.PerspectiveCamera, // type { // config name: 'camera', fov: 75, aspect: window.innerWidth / window.innerHeight, near: 1, far: 1000, position: new THREE.Vector3(0, 0, 50), lookat: new THREE.Vector3(0, 0, 0) } ); let RobotRobbyElement = React.createElement( RobotRobbyComponent, { position: robotRobbyPosition, quaternion: modelQuaternion, visible: (this.props.robot === Constants.ROBOT.ROBBY), scale: 7 } ); let RobotMechElement = React.createElement( RobotMechComponent, { position: robotMechPosition, quaternion: modelQuaternion, visible: (this.props.robot === Constants.ROBOT.MECH), scale: 5 } ); let AmbientLight = React.createElement( ReactTHREE.AmbientLight, { color: new THREE.Color(0x333333), intensity: 0.5, target: new THREE.Vector3(0, 0, 0) } ); let DirectionalLight = React.createElement( ReactTHREE.DirectionalLight, { color: new THREE.Color(0xFFFFFF), intensity: 1.5, position: new THREE.Vector3(0, 0, 60) } ); return React.createElement( ReactTHREE.Scene, { width: window.innerWidth, height: window.innerHeight, camera: 'camera', antialias: true, background: 0xEEEEEE }, CameraElement, RobotRobbyElement, RobotMechElement, AmbientLight, DirectionalLight ) } _animate() { let spinAmount = this.props.spinSpeed * Constants.SPIN_SPEED_MULTIPLIER; this.setState({modelRotation: this.state.modelRotation + (this.props.spinDirection === Constants.SPIN.LEFT ? spinAmount : -spinAmount)}); requestAnimationFrame(this._animate); } } export default SceneComponent;
generators/app/templates/src/config/initialize.js
127labs/generator-duxedo
import React from 'react' import { browserHistory } from 'react-router' import { syncHistoryWithStore } from 'react-router-redux' import configureStore from 'config/configure-store' export default (ComponentToInitialize) => () => { const store = configureStore({}) const history = syncHistoryWithStore(browserHistory, store) return <ComponentToInitialize store={store} history={history} /> }
src/svg-icons/navigation/chevron-left.js
hwo411/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let NavigationChevronLeft = (props) => ( <SvgIcon {...props}> <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/> </SvgIcon> ); NavigationChevronLeft = pure(NavigationChevronLeft); NavigationChevronLeft.displayName = 'NavigationChevronLeft'; NavigationChevronLeft.muiName = 'SvgIcon'; export default NavigationChevronLeft;
client/components/TinyEditor.js
axax/lunuc
import React from 'react' import PropTypes from 'prop-types' import DomUtil from 'client/util/dom' import Util from '../util' import config from 'gen/config-client' import {openWindow} from '../util/window' const {DEFAULT_LANGUAGE} = config class TinyEditor extends React.Component { static instanceCounter = 0 static loadedStyles = [] isInit = false constructor(props) { super(props) TinyEditor.instanceCounter++ this.instanceId = TinyEditor.instanceCounter this.state = TinyEditor.propsToState(props) } static propsToState(props) { return {value: props.children} } shouldComponentUpdate(props, state) { const readOnlyChanged = props.readOnly !== this.props.readOnly if (readOnlyChanged) { this.isInit = false } else if (this.state.value !== state.value) { } return readOnlyChanged || props.error !== this.props.error } isReadOnly(props) { return props.readOnly !== undefined && (props.readOnly === true || props.readOnly === 'true') } initEditor() { if (!this.isReadOnly(this.props) && !this.isInit) { const assestLoaded = () => { if (!window.tinymce) return this.isInit = true tinymce.init({ selector: '#TinyEditor' + this.instanceId, height: 450, relative_urls: false, remove_script_host: false, convert_urls: false, link_class_list: [ {title: 'None', value: ''}, {title: 'Schwarz', value: 'black'}, { title: 'Button', menu: [ {title: 'Button 1', value: 'button'}, {title: 'Button 2', value: 'button1'}, {title: 'Button 3', value: 'button2'}, {title: 'Button 4', value: 'button3'}, {title: 'Button 5', value: 'button5'} ] }, { title: 'Icon farbig', menu: [ {title: 'Telefon', value: 'icon-phone black'}, {title: 'PDF', value: 'icon-pdf black'}, {title: 'Fax', value: 'icon-fax black'}, {title: 'Email', value: 'icon-email black'}, {title: 'Maps', value: 'icon-maps black'}, {title: 'Website', value: 'icon-website black'}, {title: 'Pfeil nach rechts', value: 'icon-right black'}, {title: 'Popup', value: 'icon-popup black'}, {title: 'Telefon klein', value: 'icon-phone small-icon black'}, {title: 'Fax klein', value: 'icon-fax small-icon black'}, {title: 'Email klein', value: 'icon-email small-icon black'} ] }, { title: 'Icon schwarz', menu: [ {title: 'Telefon', value: 'icon-phone black-icon black'}, {title: 'PDF', value: 'icon-pdf black-icon black'}, {title: 'Fax', value: 'icon-fax black-icon black'}, {title: 'Email', value: 'icon-email black-icon black'}, {title: 'Maps', value: 'icon-maps black-icon black'}, {title: 'Website', value: 'icon-website black-icon black'}, {title: 'Pfeil nach rechts', value: 'icon-right black-icon black'}, {title: 'Popup', value: 'icon-popup black-icon black'}, {title: 'Popup (rechts)', value: 'icon-popup push-icon-left black-icon black'}, ] } ], formats: { // Changes the alignment buttons to add a class to each of the matching selector elements alignleft: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'left'}, aligncenter: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'center'}, alignright: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'right'}, alignjustify: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'full'} }, plugins: [ 'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker', 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking', 'table emoticons template paste help', /*'quickbars'*/ ], quickbars_selection_toolbar: 'bold italic | formatselect | quicklink blockquote', quickbars_insert_toolbar: false, quickbars_image_toolbar: 'alignleft aligncenter alignright | rotateleft rotateright | imageoptions', toolbar: this.props.toolbar || 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | ' + 'bullist numlist outdent indent | link image | print preview media fullpage | ' + 'forecolor backcolor emoticons | help', menu: { favs: {title: 'Tools', items: 'code visualaid | searchreplace | spellchecker | emoticons'} }, menubar: 'favs file edit view insert format tools table help', file_picker_callback: function (callback, value, meta) { let baseFilter // Provide file and text for the link dialog if (meta.filetype == 'file') { //callback('mypage.html', {text: 'My text'}); } // Provide image and alt text for the image dialog if (meta.filetype == 'image') { baseFilter = 'mimeType=image' } // Provide alternative source and posted for the media dialog if (meta.filetype == 'media') { baseFilter = 'mimeType=video' //callback('movie.mp4', {source2: 'alt.ogg', poster: 'image.jpg'}); } const newwindow = openWindow({url:`${_app_.lang !== DEFAULT_LANGUAGE ? '/' + _app_.lang : ''}/admin/types/?noLayout=true&fixType=Media&baseFilter=${encodeURIComponent(baseFilter || '')}`}) setTimeout(() => { newwindow.addEventListener('beforeunload', (e) => { console.log(newwindow.resultValue) if (newwindow.resultValue) { const mediaObj = Util.getImageObject(newwindow.resultValue) // Provide image and alt text for the image dialog if (meta.filetype == 'image') { callback(mediaObj.src, {alt: mediaObj.alt}) } else if (meta.filetype == 'media') { callback(mediaObj.src, {source2: '', poster: ''}) } else { callback(mediaObj.src, {text: mediaObj.alt}) } //_cmsActions.editCmsComponent(rest._key, _json, _scope) /*const source = getComponentByKey(_key, _json) if (source) { if (picker.template) { source.$c = Util.replacePlaceholders(picker.template.replace(/\\\{/g, '{'), newwindow.resultValue) } else { if (!source.p) { source.p = {} } source.p.src = newwindow.resultValue.constructor !== Array ? [newwindow.resultValue] : newwindow.resultValue } setTimeout(() => { _onChange(_json) }, 0) }*/ } }) }, 0) }, init_instance_callback: (editor) => { editor.on('Change', (e) => { const {onChange, name} = this.props if (onChange) { let html = editor.getContent() if (name) { onChange({target: {name, value: html}}) } else { onChange(html) } } }) }, content_css: "/css/tinymce.css" }) } if (!window.tinymce) { DomUtil.addScript('https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.10.2/tinymce.min.js', { onload: assestLoaded }, {ignoreIfExist: true}) } else { assestLoaded() } } } componentDidMount() { setTimeout(() => { this.initEditor() }, (this.instanceId - 1) * 50) /*this.css = document.createElement('style') this.css.innerHTML = ` ` document.body.appendChild(this.css)*/ } componentWillUnmount() { if (window.tinymce) { tinymce.remove('#TinyEditor' + this.instanceId) } //document.body.removeChild(this.css) } componentDidUpdate() { this.initEditor() } render() { const {children, readOnly, toolbar, required, theme, name, placeholder, value, error, ...rest} = this.props if (this.isReadOnly(this.props)) { return <div className="richtext-content" dangerouslySetInnerHTML={{__html: this.state.value}} {...rest}></div> } if (error) { if (!rest.style) { rest.style = {} } rest.style.border = 'solid 1px red' } return <div {...rest}> <textarea id={'TinyEditor' + this.instanceId} style={{visibility: 'hidden', height: '446px'}} defaultValue={this.state.value}/> </div> } } TinyEditor.propTypes = { children: PropTypes.any, onChange: PropTypes.func, className: PropTypes.string, name: PropTypes.string, style: PropTypes.object, toolbar: PropTypes.array, readOnly: PropTypes.any } export default TinyEditor
pwa/src/components/activities/editActivity.js
cmilfont/biohacking
import React from 'react'; import { connect } from 'react-redux' import { withStyles } from 'material-ui/styles'; import ExpansionPanel, { ExpansionPanelDetails, ExpansionPanelSummary, ExpansionPanelActions, } from 'material-ui/ExpansionPanel'; import { TimePicker } from 'material-ui-pickers' import Typography from 'material-ui/Typography'; import Input from 'material-ui/Input'; import ExpandMoreIcon from 'material-ui-icons/ExpandMore'; import Button from 'material-ui/Button'; import Divider from 'material-ui/Divider'; import red from 'material-ui/colors/red'; import blue from 'material-ui/colors/blue'; import ismobile from 'ismobilejs'; import moment from 'moment'; import actions from 'api/actions'; const styles = theme => ({ root: { width: '100%', }, heading: { fontSize: '1.5rem', color: '#607d8b', }, secondaryHeading: { fontSize: theme.typography.pxToRem(15), color: theme.palette.text.secondary, }, icon: { verticalAlign: 'bottom', height: 20, width: 20, }, details: { alignItems: 'center', '& a': { color: blue[500], } }, column: { flexBasis: '33.3%', display: 'flex', }, helper: { borderLeft: `2px solid ${theme.palette.text.lightDivider}`, padding: `${theme.spacing.unit}px ${theme.spacing.unit * 2}px`, }, link: { color: theme.palette.primary[500], textDecoration: 'none', '&:hover': { textDecoration: 'underline', }, }, button: { backgroundColor: red[900], }, bar: { height: '100%', width: 10, marginRight: 5, }, kind: { marginRight: 5, } }); class Activity extends React.Component { pattern = /(?:(?:https?|ftp):\/\/|\b(?:[a-z\d]+\.))(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))?/ig replaceStringToURL = url => (`<a target="_blank" href="${url}">${url}</a>`) transformLink = description => { return description && description.replace(this.pattern, this.replaceStringToURL); } handleTimeChange = (date) => { this.props.onChange({loggedAt: date.format()}); } handleDescriptionChange = (event) => { const description = event.target.value; this.props.onChange({description}); } save = () => { const { id, description, loggedAt } = this.props.activityForm; this.props.saveEditActivity({ id, description, loggedAt }); } textShortenerWhenMobile = (text, length) => ( ismobile.phone && text.length > length ? `${text.substring(0, length)}...` : text ); render() { const { activityForm: { description, loggedAt }, kind, classes, } = this.props; const shortDescription = this.textShortenerWhenMobile(description, 20); const formattedDescription = this.transformLink(description); return ( <ExpansionPanel expanded> <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}> <div className={classes.column}> <div className={classes.bar} style={{backgroundColor: kind.color}} /> <TimePicker value={loggedAt} onChange={this.handleTimeChange} /> </div> <div className={classes.column}> <Typography className={classes.secondaryHeading}> {shortDescription} </Typography> </div> </ExpansionPanelSummary> <ExpansionPanelDetails className={classes.details}> <Typography type="title" className={classes.kind}> {kind.description} </Typography> <Input type="caption" value={formattedDescription} onChange={this.handleDescriptionChange} /> </ExpansionPanelDetails> <Divider /> <ExpansionPanelActions> <Button raised dense color="accent" className={classes.button} onClick={this.props.cancelEditActivity} > CANCEL </Button> <Button raised dense color="accent" onClick={this.save} > SAVE </Button> </ExpansionPanelActions> </ExpansionPanel> ); } } const mapStateToProps = state => ({ activityForm: state.get('activity'), }); const mapDispatchToProps = dispatch => ({ saveEditActivity: payload => { dispatch({ type: actions.SAVE_EDIT_ACTIVITY, payload, }) dispatch({ type: actions.UPDATE_ACTIVITY, payload, }) }, cancelEditActivity: payload => dispatch({ type: actions.CANCEL_EDIT_ACTIVITY, payload, }), onChange: payload => dispatch({ type: actions.UPDATED_ACTIVITY_FORM, payload, }), }); export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(Activity));
app/javascript/mastodon/features/ui/components/column_loading.js
riku6460/chikuwagoddon
import React from 'react'; import PropTypes from 'prop-types'; import Column from '../../../components/column'; import ColumnHeader from '../../../components/column_header'; import ImmutablePureComponent from 'react-immutable-pure-component'; export default class ColumnLoading extends ImmutablePureComponent { static propTypes = { title: PropTypes.oneOfType([PropTypes.node, PropTypes.string]), icon: PropTypes.string, }; static defaultProps = { title: '', icon: '', }; render() { let { title, icon } = this.props; return ( <Column> <ColumnHeader icon={icon} title={title} multiColumn={false} focusable={false} /> <div className='scrollable' /> </Column> ); } }
src/svg-icons/action/delete-forever.js
matthewoates/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionDeleteForever = (props) => ( <SvgIcon {...props}> <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"/> </SvgIcon> ); ActionDeleteForever = pure(ActionDeleteForever); ActionDeleteForever.displayName = 'ActionDeleteForever'; ActionDeleteForever.muiName = 'SvgIcon'; export default ActionDeleteForever;
app/javascript/mastodon/components/autosuggest_input.js
maa123/mastodon
import React from 'react'; import AutosuggestAccountContainer from '../features/compose/containers/autosuggest_account_container'; import AutosuggestEmoji from './autosuggest_emoji'; import AutosuggestHashtag from './autosuggest_hashtag'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import ImmutablePureComponent from 'react-immutable-pure-component'; import classNames from 'classnames'; const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => { let word; let left = str.slice(0, caretPosition).search(/\S+$/); let right = str.slice(caretPosition).search(/\s/); if (right < 0) { word = str.slice(left); } else { word = str.slice(left, right + caretPosition); } if (!word || word.trim().length < 3 || searchTokens.indexOf(word[0]) === -1) { return [null, null]; } word = word.trim().toLowerCase(); if (word.length > 0) { return [left + 1, word]; } else { return [null, null]; } }; export default class AutosuggestInput extends ImmutablePureComponent { static propTypes = { value: PropTypes.string, suggestions: ImmutablePropTypes.list, disabled: PropTypes.bool, placeholder: PropTypes.string, onSuggestionSelected: PropTypes.func.isRequired, onSuggestionsClearRequested: PropTypes.func.isRequired, onSuggestionsFetchRequested: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired, onKeyUp: PropTypes.func, onKeyDown: PropTypes.func, autoFocus: PropTypes.bool, className: PropTypes.string, id: PropTypes.string, searchTokens: PropTypes.arrayOf(PropTypes.string), maxLength: PropTypes.number, }; static defaultProps = { autoFocus: true, searchTokens: ['@', ':', '#'], }; state = { suggestionsHidden: true, focused: false, selectedSuggestion: 0, lastToken: null, tokenStart: 0, }; onChange = (e) => { const [ tokenStart, token ] = textAtCursorMatchesToken(e.target.value, e.target.selectionStart, this.props.searchTokens); if (token !== null && this.state.lastToken !== token) { this.setState({ lastToken: token, selectedSuggestion: 0, tokenStart }); this.props.onSuggestionsFetchRequested(token); } else if (token === null) { this.setState({ lastToken: null }); this.props.onSuggestionsClearRequested(); } this.props.onChange(e); } onKeyDown = (e) => { const { suggestions, disabled } = this.props; const { selectedSuggestion, suggestionsHidden } = this.state; if (disabled) { e.preventDefault(); return; } if (e.which === 229 || e.isComposing) { // Ignore key events during text composition // e.key may be a name of the physical key even in this case (e.x. Safari / Chrome on Mac) return; } switch(e.key) { case 'Escape': if (suggestions.size === 0 || suggestionsHidden) { document.querySelector('.ui').parentElement.focus(); } else { e.preventDefault(); this.setState({ suggestionsHidden: true }); } break; case 'ArrowDown': if (suggestions.size > 0 && !suggestionsHidden) { e.preventDefault(); this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, suggestions.size - 1) }); } break; case 'ArrowUp': if (suggestions.size > 0 && !suggestionsHidden) { e.preventDefault(); this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, 0) }); } break; case 'Enter': case 'Tab': // Select suggestion if (this.state.lastToken !== null && suggestions.size > 0 && !suggestionsHidden) { e.preventDefault(); e.stopPropagation(); this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions.get(selectedSuggestion)); } break; } if (e.defaultPrevented || !this.props.onKeyDown) { return; } this.props.onKeyDown(e); } onBlur = () => { this.setState({ suggestionsHidden: true, focused: false }); } onFocus = () => { this.setState({ focused: true }); } onSuggestionClick = (e) => { const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index')); e.preventDefault(); this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion); this.input.focus(); } componentWillReceiveProps (nextProps) { if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden && this.state.focused) { this.setState({ suggestionsHidden: false }); } } setInput = (c) => { this.input = c; } renderSuggestion = (suggestion, i) => { const { selectedSuggestion } = this.state; let inner, key; if (suggestion.type === 'emoji') { inner = <AutosuggestEmoji emoji={suggestion} />; key = suggestion.id; } else if (suggestion.type ==='hashtag') { inner = <AutosuggestHashtag tag={suggestion} />; key = suggestion.name; } else if (suggestion.type === 'account') { inner = <AutosuggestAccountContainer id={suggestion.id} />; key = suggestion.id; } return ( <div role='button' tabIndex='0' key={key} data-index={i} className={classNames('autosuggest-textarea__suggestions__item', { selected: i === selectedSuggestion })} onMouseDown={this.onSuggestionClick}> {inner} </div> ); } render () { const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, className, id, maxLength } = this.props; const { suggestionsHidden } = this.state; return ( <div className='autosuggest-input'> <label> <span style={{ display: 'none' }}>{placeholder}</span> <input type='text' ref={this.setInput} disabled={disabled} placeholder={placeholder} autoFocus={autoFocus} value={value} onChange={this.onChange} onKeyDown={this.onKeyDown} onKeyUp={onKeyUp} onFocus={this.onFocus} onBlur={this.onBlur} dir='auto' aria-autocomplete='list' id={id} className={className} maxLength={maxLength} /> </label> <div className={`autosuggest-textarea__suggestions ${suggestionsHidden || suggestions.isEmpty() ? '' : 'autosuggest-textarea__suggestions--visible'}`}> {suggestions.map(this.renderSuggestion)} </div> </div> ); } }
src/svg-icons/editor/vertical-align-center.js
rhaedes/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let EditorVerticalAlignCenter = (props) => ( <SvgIcon {...props}> <path d="M8 19h3v4h2v-4h3l-4-4-4 4zm8-14h-3V1h-2v4H8l4 4 4-4zM4 11v2h16v-2H4z"/> </SvgIcon> ); EditorVerticalAlignCenter = pure(EditorVerticalAlignCenter); EditorVerticalAlignCenter.displayName = 'EditorVerticalAlignCenter'; export default EditorVerticalAlignCenter;
src/index.js
piaoyidage/gallery-by-react
import React from 'react' import ReactDOM from 'react-dom' import './index.css' import App from './App' import registerServiceWorker from './registerServiceWorker' ReactDOM.render(<App />, document.getElementById('root')) registerServiceWorker()
docs/app/Examples/modules/Dimmer/Usage/index.js
clemensw/stardust
import React from 'react' import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' const DimmerStatesExamples = () => ( <ExampleSection title='Usage'> <ComponentExample title='Dimmer Events' description='A dimmer can trigger a visibility change on an event.' examplePath='modules/Dimmer/Usage/DimmerExampleEvents' /> <ComponentExample title='Loaders inside Dimmers' description='Any loader inside a dimmer will automatically use an appropriate color to match.' examplePath='modules/Dimmer/Usage/DimmerExampleLoader' /> </ExampleSection> ) export default DimmerStatesExamples
.storybook/PostEditorStories.js
buaya91/just-us-blog
import React from 'react' import { storiesOf, action } from '@kadira/storybook' import PostEditor from '../src/blogpost/editor/PostEditor' import { postDraft, actions } from './testProps' storiesOf('PostEditor', module) .add('', () => ( <PostEditor actions={actions} postDraft={postDraft} /> ))
until_201803/react/modern/router/src/index.js
shofujimoto/examples
import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import MemberListApp from './MembersList' import registerServiceWorker from './registerServiceWorker'; ReactDOM.render(<App />, document.getElementById('root')); ReactDOM.render(<MemberListApp />, document.getElementById('memberList')); registerServiceWorker();
js/jqwidgets/jqwidgets-react/react_jqxtagcloud.js
luissancheza/sice
/* jQWidgets v5.3.2 (2017-Sep) Copyright (c) 2011-2017 jQWidgets. License: http://jqwidgets.com/license/ */ import React from 'react'; const JQXLite = window.JQXLite; export const jqx = window.jqx; export default class JqxTagCloud extends React.Component { componentDidMount() { let options = this.manageAttributes(); this.createComponent(options); }; manageAttributes() { let properties = ['alterTextCase','disabled','displayLimit','displayMember','displayValue','fontSizeUnit','height','maxColor','maxFontSize','maxValueToDisplay','minColor','minFontSize','minValueToDisplay','rtl','sortBy','sortOrder','source','tagRenderer','takeTopWeightedItems','textColor','urlBase','urlMember','valueMember','width']; let options = {}; for(let item in this.props) { if(item === 'settings') { for(let itemTwo in this.props[item]) { options[itemTwo] = this.props[item][itemTwo]; } } else { if(properties.indexOf(item) !== -1) { options[item] = this.props[item]; } } } return options; }; createComponent(options) { if(!this.style) { for (let style in this.props.style) { JQXLite(this.componentSelector).css(style, this.props.style[style]); } } if(this.props.className !== undefined) { let classes = this.props.className.split(' '); for (let i = 0; i < classes.length; i++ ) { JQXLite(this.componentSelector).addClass(classes[i]); } } if(!this.template) { JQXLite(this.componentSelector).html(this.props.template); } JQXLite(this.componentSelector).jqxTagCloud(options); }; setOptions(options) { JQXLite(this.componentSelector).jqxTagCloud('setOptions', options); }; getOptions() { if(arguments.length === 0) { throw Error('At least one argument expected in getOptions()!'); } let resultToReturn = {}; for(let i = 0; i < arguments.length; i++) { resultToReturn[arguments[i]] = JQXLite(this.componentSelector).jqxTagCloud(arguments[i]); } return resultToReturn; }; on(name,callbackFn) { JQXLite(this.componentSelector).on(name,callbackFn); }; off(name) { JQXLite(this.componentSelector).off(name); }; alterTextCase(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('alterTextCase', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('alterTextCase'); } }; disabled(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('disabled', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('disabled'); } }; displayLimit(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('displayLimit', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('displayLimit'); } }; displayMember(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('displayMember', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('displayMember'); } }; displayValue(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('displayValue', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('displayValue'); } }; fontSizeUnit(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('fontSizeUnit', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('fontSizeUnit'); } }; height(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('height', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('height'); } }; maxColor(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('maxColor', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('maxColor'); } }; maxFontSize(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('maxFontSize', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('maxFontSize'); } }; maxValueToDisplay(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('maxValueToDisplay', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('maxValueToDisplay'); } }; minColor(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('minColor', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('minColor'); } }; minFontSize(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('minFontSize', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('minFontSize'); } }; minValueToDisplay(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('minValueToDisplay', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('minValueToDisplay'); } }; rtl(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('rtl', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('rtl'); } }; sortBy(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('sortBy', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('sortBy'); } }; sortOrder(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('sortOrder', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('sortOrder'); } }; source(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('source', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('source'); } }; tagRenderer(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('tagRenderer', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('tagRenderer'); } }; takeTopWeightedItems(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('takeTopWeightedItems', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('takeTopWeightedItems'); } }; textColor(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('textColor', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('textColor'); } }; urlBase(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('urlBase', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('urlBase'); } }; urlMember(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('urlMember', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('urlMember'); } }; valueMember(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('valueMember', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('valueMember'); } }; width(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxTagCloud('width', arg) } else { return JQXLite(this.componentSelector).jqxTagCloud('width'); } }; destroy() { JQXLite(this.componentSelector).jqxTagCloud('destroy'); }; findTagIndex(tag) { return JQXLite(this.componentSelector).jqxTagCloud('findTagIndex', tag); }; getHiddenTagsList() { return JQXLite(this.componentSelector).jqxTagCloud('getHiddenTagsList'); }; getRenderedTags() { return JQXLite(this.componentSelector).jqxTagCloud('getRenderedTags'); }; getTagsList() { return JQXLite(this.componentSelector).jqxTagCloud('getTagsList'); }; hideItem(index) { JQXLite(this.componentSelector).jqxTagCloud('hideItem', index); }; insertAt(index, item) { JQXLite(this.componentSelector).jqxTagCloud('insertAt', index, item); }; removeAt(index) { JQXLite(this.componentSelector).jqxTagCloud('removeAt', index); }; updateAt(index, item) { JQXLite(this.componentSelector).jqxTagCloud('updateAt', index, item); }; showItem(index) { JQXLite(this.componentSelector).jqxTagCloud('showItem', index); }; render() { let id = 'jqxTagCloud' + JQXLite.generateID(); this.componentSelector = '#' + id; return ( <div id={id}>{this.props.value}{this.props.children}</div> ) }; };
app/containers/Store/CartButton.js
ryanwashburne/react-skeleton
// React import PropTypes from 'prop-types'; import React from 'react'; import { LinkContainer } from 'react-router-bootstrap'; // Redux import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import * as storeActions from 'app/reducers/storeReducer'; // UI import { IconMenu, MenuItem, Badge, FloatingActionButton, FlatButton } from 'material-ui'; import { Fa } from 'mdbreact'; class CartButton extends React.Component { render() { const { cart, actions } = this.props; const PADDING_RIGHT = 30; const PADDING_BOTTOM = 45; return ( <IconMenu iconButtonElement={(Object.keys(cart).length > 0) ? <Badge badgeStyle={{ top: 15, right: 15, zIndex: 999 }} secondary badgeContent={Object.keys(cart).length} > <FloatingActionButton> <Fa icon="shopping-cart fa-2x" /> </FloatingActionButton> </Badge> : <FloatingActionButton> <Fa icon="shopping-cart fa-2x" /> </FloatingActionButton> } anchorOrigin={{horizontal: 'right', vertical: 'top'}} targetOrigin={{horizontal: 'right', vertical: 'bottom'}} style={{ margin: 0, top: 'auto', right: (Object.keys(cart).length > 0) ? PADDING_RIGHT - 24 : PADDING_RIGHT, bottom: (Object.keys(cart).length > 0) ? PADDING_BOTTOM - 12 : PADDING_BOTTOM, left: 'auto', position: 'fixed', zIndex: 5, }} > <div> { Object.keys(cart).map((id, i) => { const item = cart[id]; return ( <MenuItem key={i} primaryText={item.name} onTouchTap={() => { actions.removeFromCart(item.id); actions.saveCart(); }} leftIcon={<div><span>x{item.count}</span></div>} desktop /> ); })} <LinkContainer to="/checkout"> <FlatButton icon={<Fa icon="shopping-cart fa-2x" />} label="Checkout" fullWidth primary /> </LinkContainer> </div> </IconMenu> ); } } CartButton.propTypes = { cart: PropTypes.object.isRequired, actions: PropTypes.object.isRequired, }; const mapStateToProps = (state) => { return { cart: state.store.cart, }; }; const mapDispatchToProps = (dispatch) => { return { actions: bindActionCreators({...storeActions}, dispatch) }; }; CartButton = connect( mapStateToProps, mapDispatchToProps )(CartButton); export default CartButton;
examples/todomvc/index.js
tamascsaba/redux
import React from 'react'; import App from './containers/App'; import 'todomvc-app-css/index.css'; React.render( <App />, document.getElementById('root') );
es/Radio/Radio.js
uplevel-technology/material-ui-next
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // weak import React from 'react'; import withStyles from '../styles/withStyles'; import SwitchBase from '../internal/SwitchBase'; import RadioButtonCheckedIcon from '../svg-icons/RadioButtonChecked'; import RadioButtonUncheckedIcon from '../svg-icons/RadioButtonUnchecked'; export const styles = theme => ({ default: { color: theme.palette.text.secondary }, checked: { color: theme.palette.primary[500] }, disabled: { color: theme.palette.action.disabled } }); // eslint-disable-next-line no-unused-vars const Radio = props => React.createElement(SwitchBase, _extends({ inputType: 'radio', icon: React.createElement(RadioButtonUncheckedIcon, null), checkedIcon: React.createElement(RadioButtonCheckedIcon, null) }, props)); Radio.displayName = 'Radio'; export default withStyles(styles, { name: 'MuiRadio' })(Radio);
addons/themes/arcana/layouts/Single.js
rendact/rendact
import $ from 'jquery' import React from 'react'; import gql from 'graphql-tag'; import {graphql} from 'react-apollo'; import moment from 'moment'; import {Link} from 'react-router'; import scrollToElement from 'scroll-to-element'; let Home = React.createClass ({ componentDidMount(){ require('../assets/css/main.css') }, render(){ let { postData, theConfig, data, thePagination, loadDone, isHome } = this.props return ( <div> <div id="page-wrapper"> <div id="header"> <h1><Link id="logo" to={"/"}>{theConfig?theConfig.name:"Rendact"}</Link></h1> <nav id="nav"> {this.props.theMenu()} </nav> </div> <section className="wrapper style1"> <div className="container"> <div id="content"> {postData && <article> <header> <h2>{postData.title && postData.title}</h2> </header> <span className="image featured"> <img src={postData.imageFeatured ? postData.imageFeatured.blobUrl: require('images/logo-128.png') } alt="" /> </span> <p dangerouslySetInnerHTML={{__html: postData.content ? postData.content :""}} /> </article> } </div> </div> </section> <div id="footer"> <div className="container"> <div className="row"> {this.props.footerWidgets && this.props.footerWidgets.map((fw, idx) => <div className="4u 12u(mobile)">{fw}</div>)} </div> </div> <ul className="icons"> <li><a href="#" className="icon fa-twitter"><span className="label">Twitter</span></a></li> <li><a href="#" className="icon fa-facebook"><span className="label">Facebook</span></a></li> <li><a href="#" className="icon fa-github"><span className="label">GitHub</span></a></li> <li><a href="#" className="icon fa-linkedin"><span className="label">LinkedIn</span></a></li> <li><a href="#" className="icon fa-google-plus"><span className="label">Google+</span></a></li> </ul> <div className="copyright"> <ul className="menu"> <li>&copy; Rendact. All rights reserved</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li> </ul> </div> </div> </div> </div> ) } }); export default Home;
src/parser/warlock/demonology/modules/talents/index.js
FaideWW/WoWAnalyzer
import React from 'react'; import Analyzer from 'parser/core/Analyzer'; import StatisticsListBox, { STATISTIC_ORDER } from 'interface/others/StatisticsListBox'; import Dreadlash from './Dreadlash'; import DemonicStrength from './DemonicStrength'; import BilescourgeBombers from './BilescourgeBombers'; import DemonicCalling from './DemonicCalling'; import PowerSiphon from './PowerSiphon'; import Doom from './Doom'; import FromTheShadows from './FromTheShadows'; import SoulStrike from './SoulStrike'; import SummonVilefiend from './SummonVilefiend'; import SoulConduit from './SoulConduit'; import InnerDemons from './InnerDemons'; import GrimoireFelguard from './GrimoireFelguard'; import SacrificedSouls from './SacrificedSouls'; import DemonicConsumption from './DemonicConsumption'; import NetherPortal from './NetherPortal'; class TalentStatisticBox extends Analyzer { static dependencies = { dreadlash: Dreadlash, demonicStrength: DemonicStrength, bilescourgeBombers: BilescourgeBombers, demonicCalling: DemonicCalling, powerSiphon: PowerSiphon, doom: Doom, fromTheShadows: FromTheShadows, soulStrike: SoulStrike, summonVilefiend: SummonVilefiend, soulConduit: SoulConduit, innerDemons: InnerDemons, grimoireFelguard: GrimoireFelguard, sacrificedSouls: SacrificedSouls, demonicConsumption: DemonicConsumption, netherPortal: NetherPortal, }; constructor(...args) { super(...args); // active if at least one module is active and has subStatistic() this.active = Object.keys(this.constructor.dependencies) .filter(name => this[name].subStatistic) .map(name => this[name].active) .includes(true); } statistic() { return ( <StatisticsListBox position={STATISTIC_ORDER.CORE(4)} title="Talents"> { Object.keys(this.constructor.dependencies) .map(name => this[name]) .filter(module => module.active && module.subStatistic) .map(module => module.subStatistic()) } </StatisticsListBox> ); } } export default TalentStatisticBox;
actor-apps/app-web/src/app/components/dialog/MessagesSection.react.js
boyley/actor-platform
import React from 'react'; import _ from 'lodash'; import VisibilityStore from 'stores/VisibilityStore'; import MessageActionCreators from 'actions/MessageActionCreators'; import MessageItem from 'components/common/MessageItem.react'; let _delayed = []; let flushDelayed = () => { _.forEach(_delayed, (p) => { MessageActionCreators.setMessageShown(p.peer, p.message); }); _delayed = []; }; let flushDelayedDebounced = _.debounce(flushDelayed, 30, 100); let lastMessageDate; class MessagesSection extends React.Component { static propTypes = { messages: React.PropTypes.array.isRequired, peer: React.PropTypes.object.isRequired }; componentWillUnmount() { VisibilityStore.removeChangeListener(this.onAppVisibilityChange); } constructor(props) { super(props); VisibilityStore.addChangeListener(this.onAppVisibilityChange); } getMessagesListItem = (message) => { let date = new Date(message.fullDate), dateDivider; const month = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; if (typeof lastMessageDate === 'undefined') { lastMessageDate = new Date(message.fullDate); } const isNewDay = date.getDate() !== lastMessageDate.getDate(); if (isNewDay) { dateDivider = ( <li className="date-divider">{month[date.getMonth()]} {date.getDate()}</li> ); } const messageItem = ( <MessageItem key={message.sortKey} message={message} newDay={isNewDay} onVisibilityChange={this.onMessageVisibilityChange} peer={this.props.peer}/> ); lastMessageDate = new Date(message.fullDate); return [dateDivider, messageItem]; } onAppVisibilityChange = () => { if (VisibilityStore.isVisible) { flushDelayed(); } } onMessageVisibilityChange = (message, isVisible) => { if (isVisible) { _delayed.push({peer: this.props.peer, message: message}); if (VisibilityStore.isVisible) { flushDelayedDebounced(); } } } render() { let messages = _.map(this.props.messages, this.getMessagesListItem); return ( <ul className="messages"> {messages} </ul> ); } } export default MessagesSection;
react/features/toolbar/components/AbstractToolbar.js
bickelj/jitsi-meet
import React, { Component } from 'react'; import { appNavigate } from '../../app'; import { toggleAudioMuted, toggleVideoMuted } from '../../base/media'; import { ColorPalette } from '../../base/styles'; import { styles } from './styles'; /** * Abstract (base) class for the conference toolbar. * * @abstract */ export class AbstractToolbar extends Component { /** * Initializes a new AbstractToolbar instance. * * @param {Object} props - The read-only React Component props with which * the new instance is to be initialized. */ constructor(props) { super(props); // Bind event handlers so they are only bound once for every instance. this._onHangup = this._onHangup.bind(this); this._toggleAudio = this._toggleAudio.bind(this); this._toggleVideo = this._toggleVideo.bind(this); } /** * Gets the styles for a button that toggles the mute state of a specific * media type. * * @param {string} mediaType - The {@link MEDIA_TYPE} associated with the * button to get styles for. * @protected * @returns {{ * buttonStyle: Object, * iconName: string, * iconStyle: Object * }} */ _getMuteButtonStyles(mediaType) { let buttonStyle; let iconName; let iconStyle; if (this.props[`${mediaType}Muted`]) { buttonStyle = { ...styles.toolbarButton, backgroundColor: ColorPalette.buttonUnderlay }; iconName = this[`${mediaType}MutedIcon`]; iconStyle = styles.whiteIcon; } else { buttonStyle = styles.toolbarButton; iconName = this[`${mediaType}Icon`]; iconStyle = styles.icon; } return { buttonStyle, iconName, iconStyle }; } /** * Dispatches action to leave the current conference. * * @protected * @returns {void} */ _onHangup() { // XXX We don't know here which value is effectively/internally used // when there's no valid room name to join. It isn't our business to // know that anyway. The undefined value is our expression of (1) the // lack of knowledge & (2) the desire to no longer have a valid room // name to join. this.props.dispatch(appNavigate(undefined)); } /** * Dispatches action to toggle the mute state of the audio/microphone. * * @protected * @returns {void} */ _toggleAudio() { this.props.dispatch(toggleAudioMuted()); } /** * Dispatches action to toggle the mute state of the video/camera. * * @protected * @returns {void} */ _toggleVideo() { this.props.dispatch(toggleVideoMuted()); } } /** * AbstractToolbar component's property types. * * @static */ AbstractToolbar.propTypes = { audioMuted: React.PropTypes.bool, dispatch: React.PropTypes.func, videoMuted: React.PropTypes.bool, visible: React.PropTypes.bool.isRequired }; /** * Maps parts of media state to component props. * * @param {Object} state - Redux state. * @returns {{ audioMuted: boolean, videoMuted: boolean }} */ export function mapStateToProps(state) { const media = state['features/base/media']; return { audioMuted: media.audio.muted, videoMuted: media.video.muted }; }
app/javascript/mastodon/features/compose/containers/warning_container.js
MitarashiDango/mastodon
import React from 'react'; import { connect } from 'react-redux'; import Warning from '../components/warning'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import { me } from '../../../initial_state'; const buildHashtagRE = () => { try { const HASHTAG_SEPARATORS = '_\\u00b7\\u200c'; const ALPHA = '\\p{L}\\p{M}'; const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}'; return new RegExp( '(?:^|[^\\/\\)\\w])#((' + '[' + WORD + '_]' + '[' + WORD + HASHTAG_SEPARATORS + ']*' + '[' + ALPHA + HASHTAG_SEPARATORS + ']' + '[' + WORD + HASHTAG_SEPARATORS +']*' + '[' + WORD + '_]' + ')|(' + '[' + WORD + '_]*' + '[' + ALPHA + ']' + '[' + WORD + '_]*' + '))', 'iu', ); } catch { return /(?:^|[^\/\)\w])#(\w*[a-zA-Z·]\w*)/i; } }; const APPROX_HASHTAG_RE = buildHashtagRE(); const mapStateToProps = state => ({ needsLockWarning: state.getIn(['compose', 'privacy']) === 'private' && !state.getIn(['accounts', me, 'locked']), hashtagWarning: state.getIn(['compose', 'privacy']) !== 'public' && APPROX_HASHTAG_RE.test(state.getIn(['compose', 'text'])), directMessageWarning: state.getIn(['compose', 'privacy']) === 'direct', }); const WarningWrapper = ({ needsLockWarning, hashtagWarning, directMessageWarning }) => { if (needsLockWarning) { return <Warning message={<FormattedMessage id='compose_form.lock_disclaimer' defaultMessage='Your account is not {locked}. Anyone can follow you to view your follower-only posts.' values={{ locked: <a href='/settings/profile'><FormattedMessage id='compose_form.lock_disclaimer.lock' defaultMessage='locked' /></a> }} />} />; } if (hashtagWarning) { return <Warning message={<FormattedMessage id='compose_form.hashtag_warning' defaultMessage="This post won't be listed under any hashtag as it is unlisted. Only public posts can be searched by hashtag." />} />; } if (directMessageWarning) { const message = ( <span> <FormattedMessage id='compose_form.encryption_warning' defaultMessage='Posts on Mastodon are not end-to-end encrypted. Do not share any dangerous information over Mastodon.' /> <a href='/terms' target='_blank'><FormattedMessage id='compose_form.direct_message_warning_learn_more' defaultMessage='Learn more' /></a> </span> ); return <Warning message={message} />; } return null; }; WarningWrapper.propTypes = { needsLockWarning: PropTypes.bool, hashtagWarning: PropTypes.bool, directMessageWarning: PropTypes.bool, }; export default connect(mapStateToProps)(WarningWrapper);
pages/404.js
fmarcos83/mdocs
/** * React Static Boilerplate * https://github.com/koistya/react-static-boilerplate * Copyright (c) Konstantin Tarkus (@koistya) | MIT license */ import React, { Component } from 'react'; export default class extends Component { render() { return ( <div> <h1>Not Found</h1> <p>The page you're looking for was not found.</p> </div> ); } }
src/kanban/components/KanbanBoardContainer.js
roybailey/research-react
import React, { Component } from 'react'; import {Container} from 'flux/utils'; import KanbanBoard from './KanbanBoard'; import CardActionCreators from '../actions/CardActionCreators'; import CardStore from '../stores/CardStore'; class KanbanBoardContainer extends Component { componentDidMount(){ CardActionCreators.fetchCards(); } render() { let kanbanBoard = this.props.children && React.cloneElement(this.props.children, { cards: this.state.cards, }); return kanbanBoard; } } KanbanBoardContainer.getStores = () => ([CardStore]); KanbanBoardContainer.calculateState = (prevState) => ({ cards: CardStore.getState() }); export default Container.create(KanbanBoardContainer);
src/js/components/Grid/stories/Percentages.js
grommet/grommet
import React from 'react'; import { Box, Grid } from 'grommet'; export const Percentages = () => ( // Uncomment <Grommet> lines when using outside of storybook // <Grommet theme={...}> <Grid fill areas={[ { name: 'nav', start: [0, 0], end: [0, 0] }, { name: 'main', start: [1, 0], end: [1, 0] }, ]} columns={['small', 'flex']} rows={['flex']} gap="small" > <Box gridArea="nav" background="brand" /> <Box gridArea="main" background="brand" /> </Grid> // </Grommet> ); Percentages.args = { full: true, }; export default { title: 'Layout/Grid/Percentages', };
app/assets/scripts/components/partner-edit.js
ASL-19/civicdr
'use strict'; import React from 'react'; import formToObject from 'form-to-object'; import { notificationPrefs, notificationLang, secureChannels, typesOfWork, languages } from '../constants'; const ImplementingPartnerEdit = React.createClass({ displayName: 'ImplementingPartnerEdit', propTypes: { onClose: React.PropTypes.func, onSubmit: React.PropTypes.func, existingImplementingPartner: React.PropTypes.object, roles: React.PropTypes.array }, handleClose: function (e) { e.preventDefault(); this.props.onClose(); }, handleSubmit: function (e) { // Don't send the form // The form will (still) do native HTML5 validation before executing e.preventDefault(); // Assign default empty-array values to each of the multi-option fields const MULTI_OPTION_FIELDS = [ 'notification_prefs', 'notification_languages', 'secure_channels', 'types_of_work', 'languages' ]; const data = formToObject(this.form); MULTI_OPTION_FIELDS.forEach(mof => { if (typeof data[mof] === 'undefined') { data[mof] = []; } if (!Array.isArray(data[mof])) { data[mof] = [data[mof]]; } }); this.props.onSubmit(data); }, render: function () { const isAdmin = this.props.roles && this.props.roles.includes('admin'); return ( <section className='modal modal--xlarge'> <div className='modal__inner modal__form'> <h1 className='inpage__title heading--medium'>Edit Implementing Partner</h1> <form onSubmit={this.handleSubmit} ref={thisForm => { this.form = thisForm; }}> <div className='form__group'> <label className='form__label-dark' htmlFor='form-name'>Name</label> <p className='form__help'>The member of your organization/team who will be managing this ticket.</p> <input type='text' id='form-name' required={true} className='form__control form__control--medium' name='name' defaultValue={this.props.existingImplementingPartner.name} /> </div> {isAdmin ? <div className='form__group'> <label className='form__label-dark' htmlFor='form-openid'>OpenID</label> <input type='text' id='form-openid' required={true} className='form__control form__control--medium' name='openid' defaultValue={this.props.existingImplementingPartner.openid} /> </div> : '' } <div className='form__group'> <label className='form__label-dark' htmlFor='form-location'>Location</label> <p className='form__help'>The location where your organization/team is based.</p> <input type='text' id='form-location' className='form__control form__control--medium' name='location' defaultValue={this.props.existingImplementingPartner.location} /> </div> <div className='form__group'> <label className='form__label-dark' htmlFor='form-contact'>Primary E-mail</label> <p className='form__help'>The primary E-mail address for your organization or team. This will be the default address used for updates about your incidents.</p> <input type='email' id='form-contact' required={true} className='form__control form__control--medium' name='contact' defaultValue={this.props.existingImplementingPartner.contact} /> </div> <div className='form__group'> <label className='form__label-dark' htmlFor='form-email-notifications'>Would you like to receive email notifications for changes to ticket statuses or assignments?</label> <label className='form__option form__option--inline form__option--custom-radio'> <input type='radio' name='email_notification' required={true} value={true} defaultChecked={this.props.existingImplementingPartner.email_notification} /> <span className='form__option__text'>Yes</span> <span className='form__option__ui'></span> </label> <label className='form__option form__option--inline form__option--custom-radio'> <input type='radio' name='email_notification' required={true} value={false} defaultChecked={!this.props.existingImplementingPartner.email_notification} /> <span className='form__option__text'>No</span> <span className='form__option__ui'></span> </label> </div> <div className='form__group checkboxes-light'> <label className='form__label-dark'>Notification Preferences</label> <p className='form__help'>Which informational notifications would you like to receive from CiviCDR? (These do not include platform notifications which can be turned off below.)</p> {notificationPrefs.map(pref => ( <label className='form__option form__option--inline form__option--custom-checkbox' key={'notification_pref-' + pref.name}> <input type='checkbox' name='notification_prefs' value={pref.name} defaultChecked={this.props.existingImplementingPartner.notification_prefs.includes(pref.name)} /> <span className='form__option__text'>{pref.name}</span> <span className='form__option__ui'></span> </label> ))} </div> <div className='form__group checkboxes-light'> <label className='form__label-dark'>Notification Languages</label> <p className='form__help'>Which languages would you like to receive informational notifications in?</p> {notificationLang.map(lang => ( <label className='form__option form__option--inline form__option--custom-checkbox' key={'notification_languages-' + lang}> <input type='checkbox' name='notification_languages' value={lang} defaultChecked={this.props.existingImplementingPartner.notification_languages.includes(lang)} /> <span className='form__option__text'>{lang}</span> <span className='form__option__ui'></span> </label> ))} </div> <div className='form__group checkboxes-light'> <label className='form__label-dark'>Secure Channels</label> <p className='form__help'>Please choose any/all of the alternative secure channels that you are comfortable using to communicate with the CiviCDR team and Service Providers.</p> {secureChannels.map(sc => ( <label className='form__option form__option--inline form__option--custom-checkbox' key={'secure_channel-' + sc}> <input type='checkbox' name='secure_channels' value={sc} defaultChecked={this.props.existingImplementingPartner.secure_channels.includes(sc)} /> <span className='form__option__text'>{sc}</span> <span className='form__option__ui'></span> </label> ))} </div> <div className='form__group'> <label className='form__label-dark' htmlFor='form-internal_level'>Internal Technical Support</label> <p className='form__help'>Provide a brief description of the level of internal technical support you have within your organization/team. This will be used to guide which support services are recommended when you report incidents.</p> <textarea id='form-internal_level' className='form__control' rows='4' name='internal_level' defaultValue={this.props.existingImplementingPartner.internal_level} > </textarea> </div> <div className='form__group checkboxes-light form__group--medium'> <label className='form__label-dark'>Types of Work</label> <p className='form__help'>The type of work that your organization/team conducts. (Choose any/all that apply.)</p> {typesOfWork.map(type => ( <label className='form__option form__option--custom-checkbox' key={'types_of_work-' + type.name}> <input type='checkbox' name='types_of_work' value={type.name} defaultChecked={this.props.existingImplementingPartner.types_of_work.includes(type.name)} /> <span className='form__option__text'>{type.name}</span> <span className='form__option__ui'></span> </label> ))} </div> <div className='form__group checkboxes-light form__group--medium'> <label className='form__label-dark'>Languages</label> <p className='form__help'>The languages spoken by the team members who will be communicating with Service Providers and the CiviCDR team. We will use this to pair you with Service Providers who speak the same languages, and to provide translation support when necessary. (Choose any/all that apply.)</p> {languages.map(language => ( <label className='form__option form__option--custom-checkbox' key={'languages-' + language}> <input type='checkbox' name='languages' value={language} defaultChecked={this.props.existingImplementingPartner.languages.includes(language)} /> <span className='form__option__text'>{language}</span> <span className='form__option__ui'></span> </label> ))} </div> <div className='form__group'> <label className='form__label-dark' htmlFor='form-pgp_key'>PGP Key</label> <p className='form__help'>Provide the public PGP key for the e-mail address provided above. (Optional)</p> <textarea id='form-pgp_key' className='form__control' rows='12' name='pgp_key' defaultValue={this.props.existingImplementingPartner.pgp_key} > </textarea> </div> <footer className='form__footer'> <ul className='form__actions'> <li className='form__actions-item'> <input type='submit' value='Save' className='button button--large button--base'/> </li> <li className='form__actions-item'> <button className='button button--large button--primary' onClick={this.handleClose}> Cancel </button> </li> </ul> </footer> </form> <button className='modal__button-dismiss' title='close' onClick={this.handleClose}></button> </div> </section> ); } }); module.exports = ImplementingPartnerEdit;
src/components/Launcher/index.js
itsravenous/escape-the-board-room
import React from 'react'; import propTypes from 'prop-types'; import Button from '../Button'; import Pager from '../Pager'; import Ticker from '../Ticker'; import './style.css'; export default class Launcher extends React.Component { constructor(props) { super(props); this.state = { showNext: false, } this.onPage = this.onPage.bind(this); this.onTickerFinish = this.onTickerFinish.bind(this); } onPage(pageNumber) { this.setState({ showNext: false, }); } onTickerFinish() { setTimeout(() => { this.setState({ showNext: true, }); }, 1000); } render() { const { boosterCount, evilTeamMember, onButtonPress, shinyTechnology, stubbornTeamMember } = this.props; console.log(onButtonPress) return ( <div className='launcher'> <Pager onPage={this.onPage} showNext={this.state.showNext} > <Ticker key='a' onFinish={this.onTickerFinish} > This is it. The rocket engines beneath the floor have lain dormant for years but are still ready to be activated, still awaiting the day when they can launch the {evilTeamMember} dungeon into the sky and to freedom. </Ticker> <Ticker key='b' onFinish={this.onTickerFinish} > The launch sequence requires simultaneous ignition on all {boosterCount} of its boosters. Unless they are activated at precisely the same time, the injection coils will refuse to align and you will moulder here until the day {stubbornTeamMember} converts to {shinyTechnology}. </Ticker> <div key='c'> <Ticker onFinish={this.onTickerFinish}> Close your eyes, join minds, and ignite. </Ticker> <Button onClick={onButtonPress}>Launch</Button> </div> </Pager> </div> ); } }; Launcher.defaultProps = { onButtonPress: Function.prototype, }; Launcher.propTypes = { onButtonPress: propTypes.func, };
powerauth-webflow/src/main/js/components/login.js
lime-company/powerauth-webflow
/* * Copyright 2016 Wultra s.r.o. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import React from 'react'; import ReactDOM from 'react-dom'; import {connect} from 'react-redux'; // Actions import { authenticate, cancel, initLogin, organizationConfigurationError, selectOrganization } from '../actions/usernamePasswordAuthActions' // Components import {Button, FormControl, FormGroup, Panel, Tab, Tabs} from 'react-bootstrap'; import Spinner from './spinner'; import OperationTimeout from "./operationTimeout"; // i18n import {FormattedMessage} from 'react-intl'; import OrganizationSelect from "./organizationSelect"; /** * Login component handles the user authentication using username and password. */ @connect((store) => { return { context: store.dispatching.context } }) export default class Login extends React.Component { constructor() { super(); this.handleLogin = this.handleLogin.bind(this); this.handleCancel = this.handleCancel.bind(this); this.organizationChanged = this.organizationChanged.bind(this); this.banners = this.banners.bind(this); this.init = this.init.bind(this); this.setDefaultOrganization = this.setDefaultOrganization.bind(this); this.updateButtonState = this.updateButtonState.bind(this); this.state = {signInDisabled: true}; } componentWillMount() { this.init(); } init() { const props = this.props; const setDefaultOrganization = this.setDefaultOrganization; props.dispatch(initLogin(function(initSucceeded) { if (initSucceeded) { // Set the default organization after loading organizations unless chosen organization was previously set if (props.context.chosenOrganizationId === undefined) { setDefaultOrganization(); } } })); } handleLogin(event) { event.preventDefault(); const organizationId = this.props.context.chosenOrganizationId; const usernameField = "username" + "_" + organizationId; const passwordField = "password" + "_" + organizationId; const username = ReactDOM.findDOMNode(this.refs[usernameField]); const password = ReactDOM.findDOMNode(this.refs[passwordField]); this.props.dispatch(authenticate(username.value, password.value, organizationId)); password.value = ""; } handleCancel(event) { event.preventDefault(); const organizationId = this.props.context.chosenOrganizationId; const usernameField = "username" + "_" + organizationId; const passwordField = "password" + "_" + organizationId; const username = ReactDOM.findDOMNode(this.refs[usernameField]); const password = ReactDOM.findDOMNode(this.refs[passwordField]); this.props.dispatch(cancel()); username.value = ""; password.value = ""; } render() { return ( <div id="login"> {this.props.context.loading ? <Spinner/> : <form onSubmit={this.handleLogin}> {this.mainPanel()} </form> } </div> ) } mainPanel() { const organizations = this.props.context.organizations; if (organizations === undefined) { // Organization list is not loaded yet return undefined; } if (organizations.length === 1) { return this.singleOrganization(); } else if (organizations.length > 1 && organizations.length < 4) { return this.fewOrganizations(); } else if (organizations.length >= 4) { return this.manyOrganizations(); } else { this.props.dispatch(organizationConfigurationError()); } } singleOrganization() { const organizations = this.props.context.organizations; return ( <Panel> {this.banners(true)} {this.title()} {this.loginForm(organizations[0].organizationId)} </Panel> ) } fewOrganizations() { const formatMessage = this.props.intl.formatMessage; const organizations = this.props.context.organizations; return ( <Tabs defaultActiveKey={this.props.context.chosenOrganizationId} onSelect={key => this.organizationChanged(key)}> {organizations.map((org) => { return ( <Tab key={org.organizationId} eventKey={org.organizationId} title={formatMessage({id: org.displayNameKey})}> <Panel> {this.banners(org.organizationId === this.props.context.chosenOrganizationId)} {this.title()} {this.loginForm(org.organizationId)} </Panel> </Tab> ) })} </Tabs> ) } manyOrganizations() { const organizations = this.props.context.organizations; const chosenOrganizationId = this.props.context.chosenOrganizationId; const formatMessage = this.props.intl.formatMessage; let chosenOrganization = organizations[0]; organizations.forEach(function (org) { // perform i18n, the select component does not support i18n org.displayName = formatMessage({id: org.displayNameKey}); if (org.organizationId === chosenOrganizationId) { chosenOrganization = org; } }); return ( <Panel> <OrganizationSelect organizations={organizations} chosenOrganization={chosenOrganization} intl={this.props.intl} callback={organization => this.organizationChanged(organization.organizationId)} /> {this.banners(true)} {this.title()} {this.loginForm(chosenOrganizationId)} </Panel> ) } setDefaultOrganization() { const organizations = this.props.context.organizations; let defaultOrganizationId = organizations[0].organizationId; organizations.forEach(function (org) { if (org.default === true) { defaultOrganizationId = org.organizationId; } }); this.props.dispatch(selectOrganization(defaultOrganizationId)); } organizationChanged(organizationId) { this.props.dispatch(selectOrganization(organizationId)); } updateButtonState() { if (this.props.context.chosenOrganizationId === undefined) { return; } const usernameField = "username" + "_" + this.props.context.chosenOrganizationId; const passwordField = "password" + "_" + this.props.context.chosenOrganizationId; if (document.getElementById(usernameField).value.length === 0 || document.getElementById(passwordField).value.length === 0) { if (!this.state.signInDisabled) { this.setState({signInDisabled: true}); } } else { if (this.state.signInDisabled) { this.setState({signInDisabled: false}); } } } banners(timeoutCheckActive) { return ( <OperationTimeout timeoutCheckActive={timeoutCheckActive}/> ) } title() { return ( <FormGroup className="title"> <FormattedMessage id="login.pleaseLogIn"/> </FormGroup> ) } loginForm(organizationId) { const usernameField = "username" + "_" + organizationId; const passwordField = "password" + "_" + organizationId; const formatMessage = this.props.intl.formatMessage; return( <div> {this.props.context.error ? ( <FormGroup className="message-error"> <FormattedMessage id={this.props.context.message}/> {(this.props.context.remainingAttempts > 0) ? ( <div> <FormattedMessage id="authentication.attemptsRemaining"/> {this.props.context.remainingAttempts} </div> ) : ( undefined )} </FormGroup> ) : ( undefined ) } <FormGroup> <FormControl autoComplete="new-password" id={usernameField} ref={usernameField} type="text" maxLength={usernameMaxLength} placeholder={formatMessage({id: 'login.loginNumber'})} autoFocus onChange={this.updateButtonState.bind(this)}/> </FormGroup> <FormGroup> <FormControl autoComplete="new-password" id={passwordField} ref={passwordField} type="password" maxLength={passwordMaxLength} placeholder={formatMessage({id: 'login.password'})} onChange={this.updateButtonState.bind(this)}/> </FormGroup> <FormGroup> <div className="row buttons"> <div className="col-xs-6"> <a href="#" onClick={this.handleCancel} className="btn btn-lg btn-default"> <FormattedMessage id="login.cancel"/> </a> </div> <div className="col-xs-6"> <Button bsSize="lg" type="submit" bsStyle="success" block disabled={this.state.signInDisabled}> <FormattedMessage id="login.signIn"/> </Button> </div> </div> </FormGroup> </div> ) } }
src/Parser/Warlock/Affliction/Modules/Talents/Contagion.js
enragednuke/WoWAnalyzer
import React from 'react'; import Analyzer from 'Parser/Core/Analyzer'; import Enemies from 'Parser/Core/Modules/Enemies'; import Combatants from 'Parser/Core/Modules/Combatants'; import SPELLS from 'common/SPELLS'; import SpellIcon from 'common/SpellIcon'; import { formatNumber, formatPercentage } from 'common/format'; import StatisticBox, { STATISTIC_ORDER } from 'Main/StatisticBox'; import { UNSTABLE_AFFLICTION_DEBUFF_IDS } from '../../Constants'; import getDamageBonus from '../WarlockCore/getDamageBonus'; const CONTAGION_DAMAGE_BONUS = 0.15; class Contagion extends Analyzer { static dependencies = { enemies: Enemies, combatants: Combatants, }; bonusDmg = 0; on_initialized() { this.active = this.combatants.selected.hasTalent(SPELLS.CONTAGION_TALENT.id); } on_byPlayer_damage(event) { const target = this.enemies.getEntity(event); if (!target) { return; } const hasUA = UNSTABLE_AFFLICTION_DEBUFF_IDS.some(x => target.hasBuff(x, event.timestamp)); if (!hasUA) { return; } this.bonusDmg += getDamageBonus(event, CONTAGION_DAMAGE_BONUS); } statistic() { return ( <StatisticBox icon={<SpellIcon id={SPELLS.CONTAGION_TALENT.id} />} value={`${formatNumber(this.bonusDmg / this.owner.fightDuration * 1000)} DPS`} label="Damage contributed" tooltip={`Your Contagion talent contributed ${formatNumber(this.bonusDmg)} total damage (${formatPercentage(this.owner.getPercentageOfTotalDamageDone(this.bonusDmg))} %).`} /> ); } statisticOrder = STATISTIC_ORDER.OPTIONAL(1); } export default Contagion;
routes/Course/routes/Announcements/components/Announcements.js
kalmyk/calc-unit
import React from 'react' class Announcements extends React.Component { render() { return ( <div> <h3>Announcements</h3> {this.props.children || <p>Choose an announcement from the sidebar.</p>} </div> ) } } module.exports = Announcements
src/components/loaders/page/page-loader.js
vFujin/HearthLounge
import React from 'react'; import Loader from "../diamond/loader"; const PageLoader = ({isLoading, error}) => { if (isLoading) { return <Loader/>; } else if (error) { return <div>Sorry, there was a problem loading the page.</div>; } else { return null; } }; export default PageLoader;
src/index.js
antropoloops/looper
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import Sampler from './audio/sampler' import { reducer, log } from "./actions/reducer" import { actions, initialState } from "./actions" import './index.css'; const files = { Q: "A1_1", W: "A1_2", E: "B1_1", A: "B2_1", S: "D1_1", D: "D1_2", Z: "V1_1", X: "V2_1", C: "V2_2" } const sampler = new Sampler(files) const reduce = log(true, reducer(initialState, actions, { sampler })) ReactDOM.render( <App reduce={reduce} />, document.getElementById('root') );
src/parser/monk/mistweaver/modules/talents/RisingMist.js
ronaldpereira/WoWAnalyzer
import React from 'react'; import { STATISTIC_ORDER } from 'interface/others/StatisticBox'; import { formatNumber, formatPercentage } from 'common/format'; import TalentStatisticBox from 'interface/others/TalentStatisticBox'; import SPELLS from 'common/SPELLS'; import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer'; import calculateEffectiveHealing from 'parser/core/calculateEffectiveHealing'; import Events from 'parser/core/Events'; import AbilityTracker from 'parser/shared/modules/AbilityTracker'; import HIT_TYPES from 'game/HIT_TYPES'; import SpellUsable from 'parser/shared/modules/SpellUsable'; import HotTrackerMW from '../core/HotTrackerMW'; const debug = false; const RISING_MIST_EXTENSION = 4000; const UPLIFTED_SPIRITS_REDUCTION = 1000; const UNAFFECTED_SPELLS = [ SPELLS.CRANE_HEAL.id, SPELLS.ENVELOPING_MIST.id, ]; class RisingMist extends Analyzer { static dependencies = { hotTracker: HotTrackerMW, abilityTracker: AbilityTracker, spellUsable: SpellUsable, }; risingMistCount = 0; risingMists = []; efsExtended = 0; remCount = 0; efCount = 0; evmCount = 0; targetCount = 0; trackUplift = false; extraVivCleaves = 0; extraVivHealing = 0; extraVivOverhealing = 0; extraVivAbsorbed = 0; cooldownReductionUsed = 0; cooldownReductionWasted = 0; extraEnvHits = 0; extraEnvBonusHealing = 0; extraMasteryHits = 0 extraMasteryhealing = 0; extraMasteryOverhealing = 0; extraMasteryAbsorbed = 0; masteryTickTock = false; extraEFhealing = 0; extraEFOverhealing = 0; extraEFAbsorbed = 0; constructor(...args) { super(...args); this.active = this.selectedCombatant.hasTalent(SPELLS.RISING_MIST_TALENT.id); this.evmHealingIncrease = this.selectedCombatant.hasTalent(SPELLS.MIST_WRAP_TALENT.id) ? .4 : .3; this.trackUplift = this.selectedCombatant.hasTrait(SPELLS.UPLIFTED_SPIRITS.id); if(!this.active){ return; } this.addEventListener(Events.cast.by(SELECTED_PLAYER).spell(SPELLS.RISING_SUN_KICK), this.extendHots); this.addEventListener(Events.heal.by(SELECTED_PLAYER).spell(SPELLS.VIVIFY), this.handleVivify); this.addEventListener(Events.heal.by(SELECTED_PLAYER), this.calculateEvn);//gotta just look at all heals tbh this.addEventListener(Events.heal.by(SELECTED_PLAYER).spell(SPELLS.GUSTS_OF_MISTS), this.handleMastery); } handleMastery(event){ const targetId = event.targetID; if(!this.hotTracker.hots[targetId] || !this.hotTracker.hots[targetId][SPELLS.ESSENCE_FONT_BUFF.id]){ return; } const object = this.hotTracker.hots[targetId][SPELLS.ESSENCE_FONT_BUFF.id]; if(object.originalEnd < event.timestamp){ if(!this.masteryTickTock){ this.extraMasteryHits += 1; this.extraMasteryhealing += event.amount || 0; this.extraMasteryOverhealing += event.overheal || 0; this.extraMasteryAbsorbed += event.absorbed || 0; } this.masteryTickTock = !this.masteryTickTock; } } calculateEvn(event){ const targetId = event.targetID; const spellId = event.ability.guid; if(!this.hotTracker.hots[targetId] || !this.hotTracker.hots[targetId][SPELLS.ENVELOPING_MIST.id]){ return; } const object = this.hotTracker.hots[targetId][SPELLS.ENVELOPING_MIST.id]; if (UNAFFECTED_SPELLS.includes(spellId)) { return; } if(object.originalEnd < event.timestamp){ this.extraEnvHits += 1; this.extraEnvBonusHealing += calculateEffectiveHealing(event, this.evmHealingIncrease); } } handleVivify(event){ const targetId = event.targetID; if(!this.hotTracker.hots[targetId] || !this.hotTracker.hots[targetId][SPELLS.RENEWING_MIST_HEAL.id]){ return; } const hot = this.hotTracker.hots[targetId][SPELLS.RENEWING_MIST_HEAL.id]; if(hot.originalEnd < event.timestamp && event.timestamp < hot.end){ this.extraVivCleaves += 1; this.extraVivHealing += event.amount || 0; this.extraVivOverhealing += event.overheal || 0; this.extraVivAbsorbed += event.absorbed || 0; if (this.trackUplift && event.hitType === HIT_TYPES.CRIT) { if (this.spellUsable.isOnCooldown(SPELLS.REVIVAL.id)) { this.cooldownReductionUsed += this.spellUsable.reduceCooldown(SPELLS.REVIVAL.id, UPLIFTED_SPIRITS_REDUCTION); } else { this.cooldownReductionWasted += UPLIFTED_SPIRITS_REDUCTION; } } } } extendHots(event) { const spellId = event.ability.guid; if (SPELLS.RISING_SUN_KICK.id !== spellId) { return; } this.risingMistCount += 1; debug && console.log(`risingMist cast #: ${this.risingMistCount}`); const newRisingMist = { name: `RisingMist #${this.risingMistCount}`, healing: 0, procs: 0, duration: 0, }; this.risingMists.push(newRisingMist); let foundEf = false; let foundTarget = false; Object.keys(this.hotTracker.hots).forEach(playerId => { Object.keys(this.hotTracker.hots[playerId]).forEach(spellIdString => { const spellId = Number(spellIdString); const attribution = newRisingMist; this.hotTracker.addExtension(attribution, RISING_MIST_EXTENSION, playerId, spellId, event.timestamp); if (spellId === SPELLS.ESSENCE_FONT_BUFF.id) { foundEf = true; foundTarget = true; this.efCount += 1; } else if (spellId === SPELLS.RENEWING_MIST_HEAL.id) { foundTarget = true; this.remCount += 1; } else if (spellId === SPELLS.ENVELOPING_MIST.id) { foundTarget = true; this.evmCount += 1; } }); }); if (foundEf) { this.efsExtended += 1; } if (foundTarget) { this.targetCount += 1; } } get averageExtension() { return this.risingMistCount === 0 ? 0 : (this.risingMists.reduce((acc, risingMist) => acc + risingMist.duration, 0) / this.risingMistCount) / 1000; } get hotHealing() { const array = this.hotTracker.hotHistory; let value = 0; for (let i = 0; i < array.length; i++) { value += (array[i].healingAfterOriginalEnd || 0); } return value; } get directHealing() { return this.abilityTracker.getAbility(SPELLS.RISING_MIST_HEAL.id).healingEffective; } get totalHealing() { return this.hotHealing + this.directHealing + this.extraMasteryhealing + this.extraVivHealing + this.extraEnvBonusHealing; } get averageHealing() { return this.risingMistCount === 0 ? 0 : this.totalHealing / this.risingMistCount; } get averageTargetsPerRM() { return this.targetCount / this.risingMistCount || 0; } get calculateVivOverHealing(){ return formatPercentage(this.extraVivOverhealing / (this.extraVivHealing + this.extraVivOverhealing)); } get calculateMasteryOverHealing(){ return formatPercentage(this.extraMasteryOverhealing / (this.extraMasteryhealing + this.extraMasteryOverhealing)); } get calculateEFOverHealing(){ return formatPercentage(this.extraEFOverhealing / (this.extraEFhealing + this.extraEFOverhealing)); } statistic() { return ( <TalentStatisticBox talent={SPELLS.RISING_MIST_TALENT.id} position={STATISTIC_ORDER.CORE(10)} value={`${formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.totalHealing))}% total healing`} label="Healing Contributed" tooltip={( <> Your {this.risingMistCount} Rising Sun Kick casts contributed the following healing: <ul> <li>HoT Extension Healing: {formatNumber(this.hotHealing)}</li> <li>Rising Mist Direct Healing: {formatNumber(this.directHealing)}</li> <li>Average HoT Extension Seconds per cast: {this.averageExtension.toFixed(2)}</li> <ul> <li>Essense Font HoTs Extended: {this.efCount}</li> <li>Renewing Mist HoTs Extended: {this.remCount}</li> <li>Enveloping Mist HoTs Extended: {this.evmCount}</li> </ul> Vivify <ul> <li>Extra Cleaves: {this.extraVivCleaves}</li> <li>Extra Healing: {formatNumber(this.extraVivHealing)} ({this.calculateVivOverHealing}% Overhealing)</li> </ul> Enveloping Mist <ul> <li>Extra Hits: {this.extraEnvHits}</li> <li>Extra Healing: {formatNumber(this.extraEnvBonusHealing)}</li> </ul> Mastery <ul> <li>Extra Hits: {this.extraMasteryHits}</li> <li>Extra Healing: {formatNumber(this.extraMasteryhealing)} ({this.calculateMasteryOverHealing}% Overhealing)</li> </ul> {this.trackUplift ? ( <> Uplift <ul> <li>{formatNumber(this.cooldownReductionUsed/1000)||0} Revival Seconds Reduced</li> <li>{formatNumber(this.cooldownReductionWasted/1000)||0} Revival Seconds Reduction Wasted</li> </ul> </> ):<></> } </ul> </> )} /> ); } } export default RisingMist;
src/components/Settings/index.js
nadavspi/UnwiseConnect
import * as togglActions from '../../actions/toggl'; import React, { Component } from 'react'; import Toggl from './Toggl'; import { Link } from 'react-router-dom'; import { connect } from 'react-redux'; import { logout } from '../../actions/auth' class Settings extends Component { saveToggl = (apiKey) => { this.props.dispatch(togglActions.saveKey(apiKey)); } startTimer = () => { this.props.dispatch(togglActions.startTimer({ description: 'Test by UnwiseConnect', })); } render() { return ( <div> <div className="panel-uc panel panel-default"> <div className="panel-uc__heading panel-heading clearfix"> <h4>Settings <small><Link to="/">Go back</Link></small></h4> <div className="panel-uc__manage"> <button onClick={() => this.props.dispatch(logout())} className="btn btn-danger btn-lg" > Logout <span className="glyphicon glyphicon-log-out" aria-hidden="true" ></span> </button> </div> </div> <div className="panel-body"> <h2>Toggl Integration</h2> <div className="row"> <div className="col-md-4"> <Toggl apiKey={this.props.toggl ? this.props.toggl.apiKey : undefined} onSubmit={this.saveToggl} /> </div> <div className="col-md-8"> <p>Having issues with your Toggl API key? Use the button below to test the integration.<br/>It should start a time entry called "Test by UnwiseConnect".</p> <button type="button" className="btn btn-default" onClick={e => this.startTimer()} > Start test timer </button> </div> </div> </div> </div> </div> ); } }; const mapStateToProps = state => state.user; export default connect(mapStateToProps)(Settings);
src/Industry.js
synchon/react-biosummit-17
import React from 'react'; import Tiles from './Tiles'; const Industry = props => { return ( <section className="section animated fadeIn has-text-centered"> <Tiles data={['Agilent Technologies, Bengaluru','Anthem Biosciences Pvt. Ltd., Bengaluru','Biocon, Bengaluru']} /> <Tiles data={['Bioklone Technologies, Chennai','Bhat Biotech Pvt. Ltd., Bengaluru','GE Healthcare, Bengaluru']} /> <Tiles data={['Genewin Pvt. Ltd., Bengaluru','Genotypic Technologies [P] Ltd., Bengaluru','Hi Media, Mumbai']} /> <Tiles data={['Hindustan Unilever Ltd., Bengaluru','HLL Biotech, Chennai','Jodas Pharmaceutical, Hyderabad']} /> <Tiles data={['Kan Biosys, Pune','Labmate Asia, Bengaluru','LifeCell International Pvt. Ltd., Chennai']} /> <Tiles data={['Malladi Drugs and Pharmaceuticals, Ranipet','Microtherapeutics, Chennai','Mylan Biotech, Hosur']} /> <Tiles data={['Novo Nordisk India Pvt. Ltd., Bengaluru','Novozymes, Bengaluru','Omniactive Health Technologies, Mumbai']} /> <Tiles data={['Orchid Pharmaceuticals, Chennai','Organica Biotech. Pvt. Ltd., Mumbai','Pfizer Ltd., Chennai']} /> <Tiles data={['Pharmaceutical Product Development, Bengaluru','Pharma Quality Europe (PQE)','Salem Microbes Pvt. Ltd., Salem']} /> <Tiles data={['Unique Biotech, Hyderabad']} /> </section> ) }; export default Industry;
src/components/Map/AddEcosystem.js
Angular-Toast/habitat
import React, { Component } from 'react'; import { View, TouchableOpacity, Image } from 'react-native'; export default class AddEcosystem extends Component { static navaigationOptions = { title: 'Choose your Ecosystem!' } render() { const { navigate } = this.props.navigation; return ( <View style={{ alignItems: 'center', justifyContent: 'center', flex: 1 }} > {sprites.map((ele, i) => { return ( <TouchableOpacity key={i} onPress={() => {navigate('Title', { avatar: this.props.navigation.state.params.avatar, eco: ele[0] })}}> <Image source={sprites[i][1]} style={{ height: 100, width: 100 }} /> </TouchableOpacity> ) })} </View> ) } } const sprites = [ [0, require("../assets/Ecosystem/toast1.png")], [1, require("../assets/Ecosystem/tree1.png")] ]
index.ios.js
CaiHuan/react_native_zhihu_demo
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; class react_native_zhihu_demo extends Component { render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Welcome to React Native! </Text> <Text style={styles.instructions}> To get started, edit index.ios.js </Text> <Text style={styles.instructions}> Press Cmd+R to reload,{'\n'} Cmd+D or shake for dev menu </Text> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, }); AppRegistry.registerComponent('react_native_zhihu_demo', () => react_native_zhihu_demo);
src/containers/Way.js
osoken/project-train-2016
import React from 'react' import { connect } from 'react-redux' import { Link } from 'react-router' let Way = ( {dispatch, way} ) => ( <div> <div> <div>出発地</div> <div>大岡山駅</div> </div> <img src="" alt=""/> <div> <div>目的地</div> <div>劇団四季(大井町駅)</div> </div> </div> ) let mapStateToProps = (state) => { return state } Way = connect( mapStateToProps )(Way) export default Way
docs/app/Examples/elements/Loader/index.js
shengnian/shengnian-ui-react
import React from 'react' import Types from './Types' import States from './States' import Variations from './Variations' const LoaderExamples = () => ( <div> <Types /> <States /> <Variations /> </div> ) export default LoaderExamples
MARVELous/client/src/js/components/login/loginForm.js
nicksenger/StackAttack2017
import React, { Component } from 'react'; export default class LoginForm extends Component { constructor(props) { super(props); this.state = { alias: '', password: '' }; this.handleSubmit = this.handleSubmit.bind(this); this.handleAliasChange = this.handleAliasChange.bind(this); this.handlePasswordChange = this.handlePasswordChange.bind(this); } handleSubmit(e) { e.preventDefault(); this.props.attempt(this.state.alias, this.state.password); this.setState({ alias: '', password: '' }); } handleAliasChange(e) { e.preventDefault(); this.setState({ alias: e.target.value }); } handlePasswordChange(e) { e.preventDefault(); this.setState({ password: e.target.value }); } render() { return ( <form onSubmit={this.handleSubmit}> <label htmlFor="alias">Username: </label> <input id="alias" type="text" value={this.state.alias} onChange={this.handleAliasChange} /><br /> <label htmlFor="password">Password: </label> <input id="password" type="password" value={this.state.password} onChange={this.handlePasswordChange} /><br /> <input type="submit" value="submit" /><br /> </form> ); } }
blueocean-material-icons/src/js/components/svg-icons/action/perm-phone-msg.js
kzantow/blueocean-plugin
import React from 'react'; import SvgIcon from '../../SvgIcon'; const ActionPermPhoneMsg = (props) => ( <SvgIcon {...props}> <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.58l2.2-2.21c.28-.27.36-.66.25-1.01C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM12 3v10l3-3h6V3h-9z"/> </SvgIcon> ); ActionPermPhoneMsg.displayName = 'ActionPermPhoneMsg'; ActionPermPhoneMsg.muiName = 'SvgIcon'; export default ActionPermPhoneMsg;
src/components/todo/TodoForm.js
ldimitrov/todo_react
import React from 'react'; import PropTypes from 'prop-types'; export const TodoForm = (properties) => ( <form onSubmit={properties.handleSubmit}> <input type="text" onChange={properties.handleInputChange} value={properties.currentTodo} /> </form> ) TodoForm.propTypes = { currentTodo: PropTypes.string.isRequired, handleInputChange: PropTypes.func.isRequired, handleInputSubmit: PropTypes.func.isRequired }
src/svg-icons/notification/do-not-disturb.js
kasra-co/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let NotificationDoNotDisturb = (props) => ( <SvgIcon {...props}> <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8 0-1.85.63-3.55 1.69-4.9L16.9 18.31C15.55 19.37 13.85 20 12 20zm6.31-3.1L7.1 5.69C8.45 4.63 10.15 4 12 4c4.42 0 8 3.58 8 8 0 1.85-.63 3.55-1.69 4.9z"/> </SvgIcon> ); NotificationDoNotDisturb = pure(NotificationDoNotDisturb); NotificationDoNotDisturb.displayName = 'NotificationDoNotDisturb'; NotificationDoNotDisturb.muiName = 'SvgIcon'; export default NotificationDoNotDisturb;
src/svg-icons/social/notifications-active.js
ruifortes/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let SocialNotificationsActive = (props) => ( <SvgIcon {...props}> <path d="M7.58 4.08L6.15 2.65C3.75 4.48 2.17 7.3 2.03 10.5h2c.15-2.65 1.51-4.97 3.55-6.42zm12.39 6.42h2c-.15-3.2-1.73-6.02-4.12-7.85l-1.42 1.43c2.02 1.45 3.39 3.77 3.54 6.42zM18 11c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2v-5zm-6 11c.14 0 .27-.01.4-.04.65-.14 1.18-.58 1.44-1.18.1-.24.15-.5.15-.78h-4c.01 1.1.9 2 2.01 2z"/> </SvgIcon> ); SocialNotificationsActive = pure(SocialNotificationsActive); SocialNotificationsActive.displayName = 'SocialNotificationsActive'; SocialNotificationsActive.muiName = 'SvgIcon'; export default SocialNotificationsActive;
javascripts/index.js
undefinerds/libris
import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; import { Route, IndexRoute, Router, hashHistory } from 'react-router'; import store, { history } from './store'; import routes from './routes'; render( <Provider store={store} history={history}> <Router history={hashHistory} onUpdate={() => window.scrollTo(0, 0)}> { routes } </Router> </Provider>, document.getElementById('root') );
examples/huge-apps/routes/Course/routes/Assignments/routes/Assignment/components/Assignment.js
jbbr/react-router
import React from 'react'; class Assignment extends React.Component { //static loadProps (params, cb) { //cb(null, { //assignment: COURSES[params.courseId].assignments[params.assignmentId] //}); //} render () { //var { title, body } = this.props.assignment; var { courseId, assignmentId } = this.props.params; var { title, body } = COURSES[courseId].assignments[assignmentId] return ( <div> <h4>{title}</h4> <p>{body}</p> </div> ); } } export default Assignment;
es6/DatePicker/basic/DateTable.js
yurizhang/ishow
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import React from 'react'; import PropTypes from 'prop-types'; import { default as Component } from '../../Common/plugs/index.js'; //提供style, classname方法 import { toDate, getFirstDayOfMonth, getDayCountOfMonth, getWeekNumber, getStartDateOfMonth, DAY_DURATION, SELECTION_MODES, deconstructDate, hasClass, getOffsetToWeekOrigin } from '../utils'; import Locale from '../../Common/locale/index'; import '../../Common/css/Date-picker.css'; function isFunction(func) { return typeof func === 'function'; } var clearHours = function clearHours(time) { var cloneDate = new Date(time); cloneDate.setHours(0, 0, 0, 0); return cloneDate.getTime(); }; var _WEEKS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; var DateTable = function (_Component) { _inherits(DateTable, _Component); function DateTable(props) { _classCallCheck(this, DateTable); var _this = _possibleConstructorReturn(this, (DateTable.__proto__ || Object.getPrototypeOf(DateTable)).call(this, props)); _this.state = { tableRows: [[], [], [], [], [], []] }; return _this; } _createClass(DateTable, [{ key: 'WEEKS', value: function WEEKS() { // 0-6 var week = this.getOffsetWeek(); return _WEEKS.slice(week).concat(_WEEKS.slice(0, week)); } }, { key: 'getOffsetWeek', value: function getOffsetWeek() { return this.props.firstDayOfWeek % 7; } }, { key: 'getStartDate', value: function getStartDate() { var ds = deconstructDate(this.props.date); return getStartDateOfMonth(ds.year, ds.month, this.getOffsetWeek()); } }, { key: 'getRows', value: function getRows() { var _props = this.props, date = _props.date, disabledDate = _props.disabledDate, showWeekNumber = _props.showWeekNumber, minDate = _props.minDate, maxDate = _props.maxDate, selectionMode = _props.selectionMode, firstDayOfWeek = _props.firstDayOfWeek; var tableRows = this.state.tableRows; var ndate = new Date(date.getTime()); var day = getFirstDayOfMonth(ndate); // day of first day var dateCountOfMonth = getDayCountOfMonth(ndate.getFullYear(), ndate.getMonth()); // dates count in december is always 31, so offset year is not neccessary var dateCountOfLastMonth = getDayCountOfMonth(ndate.getFullYear(), ndate.getMonth() === 0 ? 11 : ndate.getMonth() - 1); var offsetDaysToWeekOrigin = getOffsetToWeekOrigin(day, firstDayOfWeek); //tableRows: [ [], [], [], [], [], [] ] var rows = tableRows; var count = 1; var firstDayPosition = void 0; var startDate = this.getStartDate(); var now = clearHours(new Date()); for (var i = 0; i < 6; i++) { // rows var row = rows[i]; /* cell: { type: string, one of 'week' | 'normal' text: String, row: number, row index, column: number, column index; inRange: boolean, start: boolean, end: boolean, disabled: boolean } */ if (showWeekNumber) { //prepend week info to the head of each row array if (!row[0]) { row[0] = { type: 'week', text: getWeekNumber(new Date(startDate.getTime() + DAY_DURATION * (i * 7 + 1))) }; } } for (var j = 0; j < 7; j++) { // columns var cell = row[showWeekNumber ? j + 1 : j]; if (!cell) { row[showWeekNumber ? j + 1 : j] = { row: i, column: j, type: 'normal', inRange: false, start: false, end: false }; cell = row[showWeekNumber ? j + 1 : j]; } cell.type = 'normal'; var index = i * 7 + j; //current date offset var time = startDate.getTime() + DAY_DURATION * index; cell.inRange = time >= clearHours(minDate) && time <= clearHours(maxDate); cell.start = minDate && time === clearHours(minDate); cell.end = maxDate && time === clearHours(maxDate); var isToday = time === now; if (isToday) { cell.type = 'today'; } if (i === 0) { //handle first row of date, this row only contains all or some pre-month dates if (j >= offsetDaysToWeekOrigin) { cell.text = count++; if (count === 2) { firstDayPosition = i * 7 + j; } } else { cell.text = dateCountOfLastMonth - offsetDaysToWeekOrigin + j + 1; cell.type = 'prev-month'; } } else { if (count <= dateCountOfMonth) { //in current dates cell.text = count++; if (count === 2) { firstDayPosition = i * 7 + j; } } else { // next month cell.text = count++ - dateCountOfMonth; cell.type = 'next-month'; } } cell.disabled = isFunction(disabledDate) && disabledDate(new Date(time), SELECTION_MODES.DAY); } if (selectionMode === SELECTION_MODES.WEEK) { var start = showWeekNumber ? 1 : 0; var end = showWeekNumber ? 7 : 6; var isWeekActive = this.isWeekActive(row[start + 1]); row[start].inRange = isWeekActive; row[start].start = isWeekActive; row[end].inRange = isWeekActive; row[end].end = isWeekActive; row.isWeekActive = isWeekActive; } } rows.firstDayPosition = firstDayPosition; return rows; } // calc classnames for cell }, { key: 'getCellClasses', value: function getCellClasses(cell) { var _props2 = this.props, selectionMode = _props2.selectionMode, date = _props2.date; var classes = []; if ((cell.type === 'normal' || cell.type === 'today') && !cell.disabled) { classes.push('available'); if (cell.type === 'today') { classes.push('today'); } } else { classes.push(cell.type); } if (selectionMode === 'day' && (cell.type === 'normal' || cell.type === 'today') // following code only highlight date that is the actuall value of the datepicker, but actually it should // be the temp that value use selected && date.getDate() === +cell.text) { // && value // && value.getFullYear() === date.getFullYear() // && value.getMonth() === date.getMonth() // && value.getDate() === Number(cell.text)) { classes.push('current'); } if (cell.inRange && (cell.type === 'normal' || cell.type === 'today' || selectionMode === 'week')) { classes.push('in-range'); if (cell.start) { classes.push('start-date'); } if (cell.end) { classes.push('end-date'); } } if (cell.disabled) { classes.push('disabled'); } return classes.join(' '); } }, { key: 'getMarkedRangeRows', value: function getMarkedRangeRows() { var _props3 = this.props, showWeekNumber = _props3.showWeekNumber, minDate = _props3.minDate, selectionMode = _props3.selectionMode, rangeState = _props3.rangeState; var rows = this.getRows(); if (!(selectionMode === SELECTION_MODES.RANGE && rangeState.selecting && rangeState.endDate instanceof Date)) return rows; var maxDate = rangeState.endDate; for (var i = 0, k = rows.length; i < k; i++) { var row = rows[i]; for (var j = 0, l = row.length; j < l; j++) { if (showWeekNumber && j === 0) continue; var cell = row[j]; var index = i * 7 + j + (showWeekNumber ? -1 : 0); var time = this.getStartDate().getTime() + DAY_DURATION * index; cell.inRange = minDate && time >= clearHours(minDate) && time <= clearHours(maxDate); cell.start = minDate && time === clearHours(minDate.getTime()); cell.end = maxDate && time === clearHours(maxDate.getTime()); } } return rows; } }, { key: 'isWeekActive', value: function isWeekActive(cell) { if (this.props.selectionMode !== SELECTION_MODES.WEEK) return false; if (!this.props.value) return false; var newDate = new Date(this.props.date.getTime()); // date view var year = newDate.getFullYear(); var month = newDate.getMonth(); if (cell.type === 'prev-month') { newDate.setMonth(month === 0 ? 11 : month - 1); newDate.setFullYear(month === 0 ? year - 1 : year); } if (cell.type === 'next-month') { newDate.setMonth(month === 11 ? 0 : month + 1); newDate.setFullYear(month === 11 ? year + 1 : year); } newDate.setDate(parseInt(cell.text, 10)); return getWeekNumber(newDate) === deconstructDate(this.props.value).week; // current date value } }, { key: 'handleMouseMove', value: function handleMouseMove(event) { var _this2 = this; var _props4 = this.props, showWeekNumber = _props4.showWeekNumber, onChangeRange = _props4.onChangeRange, rangeState = _props4.rangeState, selectionMode = _props4.selectionMode; var getDateOfCell = function getDateOfCell(row, column, showWeekNumber) { var startDate = _this2.getStartDate(); return new Date(startDate.getTime() + (row * 7 + (column - (showWeekNumber ? 1 : 0))) * DAY_DURATION); }; if (!(selectionMode === SELECTION_MODES.RANGE && rangeState.selecting)) return; var target = event.target; if (target.tagName !== 'TD') return; var column = target.cellIndex; var row = target.parentNode.rowIndex - 1; rangeState.endDate = getDateOfCell(row, column, showWeekNumber); onChangeRange(rangeState); } }, { key: 'handleClick', value: function handleClick(event) { var target = event.target; if (target.tagName !== 'TD') return; if (hasClass(target, 'disabled') || hasClass(target, 'week')) return; var _props5 = this.props, selectionMode = _props5.selectionMode, date = _props5.date, onPick = _props5.onPick, minDate = _props5.minDate, maxDate = _props5.maxDate, rangeState = _props5.rangeState; var _deconstructDate = deconstructDate(date), year = _deconstructDate.year, month = _deconstructDate.month; if (selectionMode === 'week') { target = target.parentNode.cells[1]; } var cellIndex = target.cellIndex; var rowIndex = target.parentNode.rowIndex - 1; var cell = this.getRows()[rowIndex][cellIndex]; var text = cell.text; var className = target.className; var newDate = new Date(year, month, 1); if (className.indexOf('prev') !== -1) { if (month === 0) { newDate.setFullYear(year - 1); newDate.setMonth(11); } else { newDate.setMonth(month - 1); } } else if (className.indexOf('next') !== -1) { if (month === 11) { newDate.setFullYear(year + 1); newDate.setMonth(0); } else { newDate.setMonth(month + 1); } } newDate.setDate(parseInt(text, 10)); if (selectionMode === SELECTION_MODES.RANGE) { if (rangeState.selecting) { if (newDate < minDate) { rangeState.selecting = true; onPick({ minDate: toDate(newDate), maxDate: null }, false); } else if (newDate >= minDate) { rangeState.selecting = false; onPick({ minDate: minDate, maxDate: toDate(newDate) }, true); } } else { if (minDate && maxDate || !minDate) { // be careful about the rangeState & onPick order // since rangeState is a object, mutate it will make child DateTable see the // changes, but wont trigger a DateTable re-render. but onPick would trigger it. // so a reversed order may cause a bug. rangeState.selecting = true; onPick({ minDate: toDate(newDate), maxDate: null }, false); } } } else if (selectionMode === SELECTION_MODES.DAY || selectionMode === SELECTION_MODES.WEEK) { onPick({ date: newDate }); } } }, { key: 'render', value: function render() { var _this3 = this; var $t = Locale.t; var _props6 = this.props, selectionMode = _props6.selectionMode, showWeekNumber = _props6.showWeekNumber; return React.createElement( 'table', { cellSpacing: '0', cellPadding: '0', onClick: this.handleClick.bind(this), onMouseMove: this.handleMouseMove.bind(this), className: this.classNames('ishow-date-table', { 'is-week-mode': selectionMode === 'week' }) }, React.createElement( 'tbody', null, React.createElement( 'tr', null, showWeekNumber && React.createElement( 'th', null, $t('el.datepicker.week') ), this.WEEKS().map(function (e, idx) { return React.createElement( 'th', { key: idx }, $t('el.datepicker.weeks.' + e) ); }) ), this.getMarkedRangeRows().map(function (row, idx) { return React.createElement( 'tr', { key: idx, className: _this3.classNames('ishow-date-table__row', { 'current': row.isWeekActive }) }, row.map(function (cell, idx) { return React.createElement( 'td', { className: _this3.getCellClasses(cell), key: idx }, cell.type === 'today' ? '今天' : cell.text ); }) ); }) ) ); } }]); return DateTable; }(Component); export default DateTable; DateTable.propTypes = { disabledDate: PropTypes.func, showWeekNumber: PropTypes.bool, //minDate, maxDate: only valid in range mode. control date's start, end info minDate: PropTypes.instanceOf(Date), maxDate: PropTypes.instanceOf(Date), selectionMode: PropTypes.oneOf(Object.keys(SELECTION_MODES).map(function (e) { return SELECTION_MODES[e]; })), // date view model, all visual view derive from this info date: PropTypes.instanceOf(Date).isRequired, // current date value, use picked. value: PropTypes.instanceOf(Date), /* (data, closePannel: boolean)=>() data: if selectionMode = range: // notify when ranges is change minDate: Date|null, maxDate: Date|null if selectionMode = date date: Date if selectionMode = week: year: number week: number, value: string, date: Date */ onPick: PropTypes.func.isRequired, /* ({ endDate: Date, selecting: boolean, })=>() */ onChangeRange: PropTypes.func, rangeState: PropTypes.shape({ endDate: PropTypes.date, selecting: PropTypes.bool }), firstDayOfWeek: PropTypes.range(0, 6) }; DateTable.defaultProps = { selectionMode: 'day', firstDayOfWeek: 0 };
components/base/image.js
dwest-teo/wattos-spaceship-emporium
import React from 'react'; import { Box } from 'axs'; const imageCss = { maxWidth: '100%', borderStyle: 'none' }; const Image = props => ( <Box is="img" {...props} css={imageCss} /> ); Image.displayName = 'Image'; export default Image;
examples/pinterest/app.js
dalexand/react-router
import React from 'react'; import { Router, Route, IndexRoute, Link } from 'react-router'; var PICTURES = [ { id: 0, src: 'http://placekitten.com/601/601' }, { id: 1, src: 'http://placekitten.com/610/610' }, { id: 2, src: 'http://placekitten.com/620/620' } ]; var Modal = React.createClass({ styles: { position: 'fixed', top: '20%', right: '20%', bottom: '20%', left: '20%', padding: 20, boxShadow: '0px 0px 150px 130px rgba(0, 0, 0, 0.5)', overflow: 'auto', background: '#fff' }, render () { return ( <div style={this.styles}> <p><Link to={this.props.returnTo}>Back</Link></p> {this.props.children} </div> ) } }) var App = React.createClass({ componentWillReceiveProps (nextProps) { // if we changed routes... if (( nextProps.location.key !== this.props.location.key && nextProps.location.state && nextProps.location.state.modal )) { // save the old children (just like animation) this.previousChildren = this.props.children } }, render() { var { location } = this.props var isModal = ( location.state && location.state.modal && this.previousChildren ) return ( <div> <h1>Pinterest Style Routes</h1> <div> {isModal ? this.previousChildren : this.props.children } {isModal && ( <Modal isOpen={true} returnTo={location.state.returnTo}> {this.props.children} </Modal> )} </div> </div> ); } }); var Index = React.createClass({ render () { return ( <div> <p> The url `/pictures/:id` can be rendered anywhere in the app as a modal. Simply put `modal: true` in the `state` prop of links. </p> <p> Click on an item and see its rendered as a modal, then copy/paste the url into a different browser window (with a different session, like Chrome -> Firefox), and see that the image does not render inside the overlay. One URL, two session dependent screens :D </p> <div> {PICTURES.map(picture => ( <Link key={picture.id} to={`/pictures/${picture.id}`} state={{ modal: true, returnTo: this.props.location.pathname }}> <img style={{ margin: 10 }} src={picture.src} height="100" /> </Link> ))} </div> <p><Link to="/some/123/deep/456/route">Go to some deep route</Link></p> </div> ) } }) var Deep = React.createClass({ render () { return ( <div> <p>You can link from anywhere really deep too</p> <p>Params stick around: {this.props.params.one} {this.props.params.two}</p> <p> <Link to={`/pictures/0`} state={{ modal: true, returnTo: this.props.location.pathname}}> Link to picture with Modal </Link><br/> <Link to={`/pictures/0`}> Without modal </Link> </p> </div> ) } }) var Picture = React.createClass({ render() { return ( <div> <img src={PICTURES[this.props.params.id].src} style={{ height: '80%' }} /> </div> ); } }); React.render(( <Router> <Route path="/" component={App}> <IndexRoute component={Index}/> <Route path="/pictures/:id" component={Picture}/> <Route path="/some/:one/deep/:two/route" component={Deep}/> </Route> </Router> ), document.getElementById('example'))
src/ModalFooter.js
pandoraui/react-bootstrap
import React from 'react'; import classNames from 'classnames'; class ModalFooter extends React.Component { render() { return ( <div {...this.props} className={classNames(this.props.className, this.props.modalClassName)}> {this.props.children} </div> ); } } ModalFooter.propTypes = { /** * A css class applied to the Component */ modalClassName: React.PropTypes.string }; ModalFooter.defaultProps = { modalClassName: 'modal-footer' }; export default ModalFooter;
docs/src/app/components/pages/components/GridList/Page.js
ruifortes/material-ui
import React from 'react'; import Title from 'react-title-component'; import CodeExample from '../../../CodeExample'; import PropTypeDescription from '../../../PropTypeDescription'; import MarkdownElement from '../../../MarkdownElement'; import gridListReadmeText from './README'; import gridListExampleSimpleCode from '!raw!./ExampleSimple'; import GridListExampleSimple from './ExampleSimple'; import gridListExampleComplexCode from '!raw!./ExampleComplex'; import GridListExampleComplex from './ExampleComplex'; import gridListCode from '!raw!material-ui/GridList/GridList'; import gridTileCode from '!raw!material-ui/GridList/GridTile'; const descriptions = { simple: 'A simple example of a scrollable `GridList` containing a [Subheader](/#/components/subheader).', complex: 'This example demonstrates "featured" tiles, using the `rows` and `cols` props to adjust the size of the ' + 'tile. The tiles have a customised title, positioned at the top and with a custom gradient `titleBackground`.', }; const GridListPage = () => ( <div> <Title render={(previousTitle) => `Grid List - ${previousTitle}`} /> <MarkdownElement text={gridListReadmeText} /> <CodeExample title="Simple example" description={descriptions.simple} code={gridListExampleSimpleCode} > <GridListExampleSimple /> </CodeExample> <CodeExample title="Complex example" description={descriptions.complex} code={gridListExampleComplexCode} > <GridListExampleComplex /> </CodeExample> <PropTypeDescription header="### GridList Properties" code={gridListCode} /> <PropTypeDescription header="### GridTile Properties" code={gridTileCode} /> </div> ); export default GridListPage;
example/src/Screens/Docs/AnimatedSwitch/example.js
maisano/react-router-transition
import React from 'react'; import { Route } from 'react-router-dom'; import { spring, AnimatedSwitch } from 'react-router-transition'; import A from './A'; import B from './B'; import C from './C'; // we need to map the `scale` prop we define below // to the transform style property function mapStyles(styles) { return { opacity: styles.opacity, transform: `scale(${styles.scale})`, }; } // wrap the `spring` helper to use a bouncy config function bounce(val) { return spring(val, { stiffness: 330, damping: 22, }); } // child matches will... const bounceTransition = { // start in a transparent, upscaled state atEnter: { opacity: 0, scale: 1.2, }, // leave in a transparent, downscaled state atLeave: { opacity: bounce(0), scale: bounce(0.8), }, // and rest at an opaque, normally-scaled state atActive: { opacity: bounce(1), scale: bounce(1), }, }; export default () => ( <AnimatedSwitch atEnter={bounceTransition.atEnter} atLeave={bounceTransition.atLeave} atActive={bounceTransition.atActive} mapStyles={mapStyles} className="route-wrapper" > <Route path="/a" component={A} /> <Route path="/b" component={B} /> <Route path="/c" component={C} /> </AnimatedSwitch> );
src/components/H/H1.js
Bandwidth/shared-components
import React from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import get from 'extensions/themeGet'; import userSpacing from 'extensions/userSpacing'; import Skeleton from 'skeletons/Skeleton'; import H2 from './H2'; import H3 from './H3'; import H4 from './H4'; import H5 from './H5'; const H1 = styled.h1.withConfig({ displayName: 'H1' })` color: ${get('colors.primary.default')}; font-weight: 100; font-family: ${get('fonts.brand')}; font-size: 2.5em; margin: ${userSpacing.text}; overflow: hidden; padding: 0; `; H1.propTypes = { /** * Specify a CSS value or an object { top, right, bottom, left } or { vertical, horizontal } to * control the spacing around the heading. Defaults to a large space below the element. */ spacing: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), /** * Adds a class name to the element. */ className: PropTypes.string, /** * Adds an id to the element. */ id: PropTypes.string, }; H1.defaultProps = { spacing: { bottom: 'lg' }, className: "scl-header-1", id: null, }; H1.Skeleton = () => <Skeleton width="200px" height="2.5em" />; H1.H2 = H2; H1.H3 = H3; H1.H4 = H4; H1.H5 = H5; /** * @component */ export default H1;
frontend/src/Components/FileBrowser/FileBrowserModalContent.js
geogolem/Radarr
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import Alert from 'Components/Alert'; import PathInput from 'Components/Form/PathInput'; import Button from 'Components/Link/Button'; import Link from 'Components/Link/Link'; 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 Scroller from 'Components/Scroller/Scroller'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import { kinds, scrollDirections } from 'Helpers/Props'; import translate from 'Utilities/String/translate'; import FileBrowserRow from './FileBrowserRow'; import styles from './FileBrowserModalContent.css'; const columns = [ { name: 'type', label: translate('Type'), isVisible: true }, { name: 'name', label: translate('Name'), isVisible: true } ]; class FileBrowserModalContent extends Component { // // Lifecycle constructor(props, context) { super(props, context); this._scrollerNode = null; this.state = { isFileBrowserModalOpen: false, currentPath: props.value }; } componentDidUpdate(prevProps, prevState) { const { currentPath } = this.props; if ( currentPath !== this.state.currentPath && currentPath !== prevState.currentPath ) { this.setState({ currentPath }); this._scrollerNode.scrollTop = 0; } } // // Control setScrollerRef = (ref) => { if (ref) { this._scrollerNode = ReactDOM.findDOMNode(ref); } else { this._scrollerNode = null; } } // // Listeners onPathInputChange = ({ value }) => { this.setState({ currentPath: value }); } onRowPress = (path) => { this.props.onFetchPaths(path); } onOkPress = () => { this.props.onChange({ name: this.props.name, value: this.state.currentPath }); this.props.onClearPaths(); this.props.onModalClose(); } // // Render render() { const { isFetching, isPopulated, error, parent, directories, files, isWindowsService, onModalClose, ...otherProps } = this.props; const emptyParent = parent === ''; return ( <ModalContent onModalClose={onModalClose} > <ModalHeader> File Browser </ModalHeader> <ModalBody className={styles.modalBody} scrollDirection={scrollDirections.NONE} > { isWindowsService && <Alert className={styles.mappedDrivesWarning} kind={kinds.WARNING} > <Link to="https://wiki.servarr.com/radarr/faq#why-cant-radarr-see-my-files-on-a-remote-server"> {translate('MappedDrivesRunningAsService')} </Link> . </Alert> } <PathInput className={styles.pathInput} placeholder={translate('StartTypingOrSelectAPathBelow')} hasFileBrowser={false} {...otherProps} value={this.state.currentPath} onChange={this.onPathInputChange} /> <Scroller ref={this.setScrollerRef} className={styles.scroller} scrollDirection={scrollDirections.BOTH} > { !!error && <div> {translate('ErrorLoadingContents')} </div> } { isPopulated && !error && <Table horizontalScroll={false} columns={columns} > <TableBody> { emptyParent && <FileBrowserRow type="computer" name="My Computer" path={parent} onPress={this.onRowPress} /> } { !emptyParent && parent && <FileBrowserRow type="parent" name="..." path={parent} onPress={this.onRowPress} /> } { directories.map((directory) => { return ( <FileBrowserRow key={directory.path} type={directory.type} name={directory.name} path={directory.path} onPress={this.onRowPress} /> ); }) } { files.map((file) => { return ( <FileBrowserRow key={file.path} type={file.type} name={file.name} path={file.path} onPress={this.onRowPress} /> ); }) } </TableBody> </Table> } </Scroller> </ModalBody> <ModalFooter> { isFetching && <LoadingIndicator className={styles.loading} size={20} /> } <Button onPress={onModalClose} > {translate('Cancel')} </Button> <Button onPress={this.onOkPress} > {translate('Ok')} </Button> </ModalFooter> </ModalContent> ); } } FileBrowserModalContent.propTypes = { name: PropTypes.string.isRequired, value: PropTypes.string.isRequired, isFetching: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired, error: PropTypes.object, parent: PropTypes.string, currentPath: PropTypes.string.isRequired, directories: PropTypes.arrayOf(PropTypes.object).isRequired, files: PropTypes.arrayOf(PropTypes.object).isRequired, isWindowsService: PropTypes.bool.isRequired, onFetchPaths: PropTypes.func.isRequired, onClearPaths: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired }; export default FileBrowserModalContent;
src/components/auction/board/RemoveBid.js
akeely/twoguysandadream-js
import React from 'react'; export default class RemoveBid extends React.Component { render() { return ( <a href="#" onClick={this.props.removeFunction}> <i className="fa fa-times-circle fa-lg" /> </a> ); }; };
src/website/app/demos/Dropdown/Dropdown/examples/placement.js
mineral-ui/mineral-ui
/* @flow */ import styled from '@emotion/styled'; import React from 'react'; import Button from '../../../../../../library/Button'; import Dropdown from '../../../../../../library/Dropdown'; import data from '../../../Menu/common/menuData'; import type { StyledComponent } from '@emotion/styled-base/src/utils'; const Root: StyledComponent<{ [key: string]: any }> = styled('div')({ height: '400px', display: 'flex', alignItems: 'center', justifyContent: 'center' }); const DemoLayout = (props: Object) => <Root {...props} />; export default { id: 'placement', title: 'Placement', description: `The \`placement\` prop determines the initial placement of the Dropdown content relative to the trigger. The Dropdown will react to viewport edges and scrolling.`, scope: { Button, data, DemoLayout, Dropdown }, source: ` <DemoLayout> <Dropdown placement="bottom-start" data={data} isOpen> <Button>Menu</Button> </Dropdown> </DemoLayout>` };
react/reactRedux/redux-master/examples/todos/src/containers/AddTodo.js
huxinmin/PracticeMakesPerfect
import React from 'react' import { connect } from 'react-redux' import { addTodo } from '../actions' let AddTodo = ({ dispatch }) => { let input return ( <div> <form onSubmit={e => { e.preventDefault() if (!input.value.trim()) { return } dispatch(addTodo(input.value)) input.value = '' }}> <input ref={node => { input = node }} /> <button type="submit"> Add Todo </button> </form> </div> ) } AddTodo = connect()(AddTodo) export default AddTodo
integration/examples/react-reload/app/src/main.js
GoogleContainerTools/skaffold
import React from 'react'; import ReactDOM from 'react-dom'; import { HelloWorld } from './components/HelloWorld.js'; ReactDOM.render( < HelloWorld/>, document.getElementById( 'root' ) );
client/src/components/Header/components/UniversalNav.js
jonathanihm/freeCodeCamp
import React from 'react'; import PropTypes from 'prop-types'; import { Link } from '../../helpers'; import NavLogo from './NavLogo'; import SearchBar from '../../search/searchBar/SearchBar'; import MenuButton from './MenuButton'; import NavLinks from './NavLinks'; import './universalNav.css'; export const UniversalNav = ({ displayMenu, toggleDisplayMenu, menuButtonRef, searchBarRef }) => ( <nav className={'universal-nav nav-padding' + (displayMenu ? ' expand-nav' : '')} id='universal-nav' > <div className={'universal-nav-left' + (displayMenu ? ' display-flex' : '')} > <SearchBar innerRef={searchBarRef} /> </div> <div className='universal-nav-middle'> <Link id='universal-nav-logo' to='/learn'> <NavLogo /> <span className='sr-only'>freeCodeCamp.org</span> </Link> </div> <div className='universal-nav-right main-nav'> <NavLinks displayMenu={displayMenu} /> </div> <MenuButton displayMenu={displayMenu} innerRef={menuButtonRef} onClick={toggleDisplayMenu} /> </nav> ); UniversalNav.displayName = 'UniversalNav'; export default UniversalNav; UniversalNav.propTypes = { displayMenu: PropTypes.bool, menuButtonRef: PropTypes.object, searchBarRef: PropTypes.object, toggleDisplayMenu: PropTypes.func };
src/svg-icons/image/looks-5.js
ArcanisCz/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageLooks5 = (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-2zm-4 6h-4v2h2c1.1 0 2 .89 2 2v2c0 1.11-.9 2-2 2H9v-2h4v-2H9V7h6v2z"/> </SvgIcon> ); ImageLooks5 = pure(ImageLooks5); ImageLooks5.displayName = 'ImageLooks5'; ImageLooks5.muiName = 'SvgIcon'; export default ImageLooks5;
src/index.js
DavidLGoldberg/voting-server-tutorial
import React from 'react'; import ReactDOM from 'react-dom'; import Root from './containers/Root'; import { createHistory } from 'history'; const history = createHistory(); ReactDOM.render( <Root history={history} />, document.getElementById('root') );
src/client/todos/index.react.js
skaldo/este
import Buttons from './buttons.react'; import Component from '../components/component.react'; import DocumentTitle from 'react-document-title'; import NewTodo from './newtodo.react'; import React from 'react'; import ToCheck from './tocheck.react'; import Todos from './todos.react'; export default class TodosIndex extends Component { static propTypes = { actions: React.PropTypes.object.isRequired, msg: React.PropTypes.object.isRequired, todos: React.PropTypes.object.isRequired } render() { const { todos: {newTodo, list}, actions: {todos: actions}, msg: {todos: msg} } = this.props; return ( <DocumentTitle title={msg.title}> <div className="todos-page"> <NewTodo {...{newTodo, actions, msg}} /> <Todos {...{list, actions, msg}} /> <Buttons clearAllEnabled={list.size > 0} {...{actions, msg}} /> <ToCheck msg={msg.toCheck} /> </div> </DocumentTitle> ); } }
docs/src/app/components/pages/components/LinearProgress/ExampleSimple.js
mmrtnz/material-ui
import React from 'react'; import LinearProgress from 'material-ui/LinearProgress'; const LinearProgressExampleSimple = () => ( <LinearProgress mode="indeterminate" /> ); export default LinearProgressExampleSimple;
src/js/components/pending/pending.js
holloway/mahara-mobile
/*jshint esnext: true */ import React from 'react'; import MaharaBaseComponent from '../base.js'; import ExpandCollapse from '../expand-collapse/expand-collapse.js'; import StateStore from '../../state.js'; import {PENDING} from '../../constants.js'; import PendingItem from './pending-item.js'; class Pending extends MaharaBaseComponent { constructor(){ super(); this.deleteAll = this.deleteAll.bind(this); this.uploadAll = this.uploadAll.bind(this); this.renderButtonTray = this.renderButtonTray.bind(this); } render() { return <section> {this.renderPendingUploads()} {this.renderButtonTray()} </section>; } deleteAll(){ var reallyDeleteAll = function(){ StateStore.dispatch({type:PENDING.DELETE_ALL}); } alertify.okBtn(this.gettext("confirm_delete_all_ok_button")) .cancelBtn(this.gettext("button_cancel")) .confirm(this.gettext("confirm_delete_all"), reallyDeleteAll); } uploadAll(){ var journalEntry, that = this, dontReattemptUploadWithinMilliseconds = 1000 * 60 * 10; if(!this.props.pendingUploads || this.props.pendingUploads.length === 0) return; StateStore.dispatch({type:PENDING.UPLOAD_NEXT}); } renderButtonTray(){ if(this.noPendingUploads()) return ""; return <div className="buttonTray"> <button onClick={this.uploadAll} className="uploadAll small">{this.gettext("upload_all_button")}</button> </div> // &nbsp; // <button onClick={this.deleteAll} className="deleteAll small">{this.gettext("delete_all_button")}</button> } noPendingUploads = () => { return (!this.props.pendingUploads || this.props.pendingUploads.length === 0); } renderPendingUploads = () => { var that = this; if(this.noPendingUploads()) return <i className="noPendingUploads">{this.gettext("no_pending_uploads")}</i>; return <div> <h1>{this.gettext('pending_heading')}</h1> {this.props.pendingUploads.map(function(item, i){ return <ExpandCollapse key={item.guid} title={item.title || item.body}> <PendingItem {...item} lang={that.props.lang} lastItem={i === that.props.pendingUploads.length - 1}/> </ExpandCollapse> })} </div> } } export default Pending;
docs/app/Examples/elements/Button/Types/ButtonExampleAnimated.js
Rohanhacker/Semantic-UI-React
import React from 'react' import { Button, Icon } from 'semantic-ui-react' const ButtonExampleAnimated = () => ( <div> <Button animated> <Button.Content visible>Next</Button.Content> <Button.Content hidden> <Icon name='right arrow' /> </Button.Content> </Button> <Button animated='vertical'> <Button.Content hidden>Shop</Button.Content> <Button.Content visible> <Icon name='shop' /> </Button.Content> </Button> <Button animated='fade'> <Button.Content visible> Sign-up for a Pro account </Button.Content> <Button.Content hidden> $12.99 a month </Button.Content> </Button> </div> ) export default ButtonExampleAnimated
src/docs/examples/RangeSlider/ExampleSingleRange.js
austinknight/ui-components
import React from 'react'; import RangeSlider from 'ui-components/RangeSlider'; /** Single Value Range Slider */ export default function ExampleSingleRange() { return <RangeSlider label="Pick a number" minValue={0} maxValue={100} onRangeUpdate={() => {}} /> }
main.js
ferologics/Sigilyfe
/** * Created by vadimdez on 09/02/16. */ import React from 'react'; import { render } from 'react-dom'; import store from './store'; import { Provider } from 'react-redux'; import './styles/main.scss'; import Game from './components/Game'; const renderer = () => { render( <Provider store={store}> <Game /> </Provider>, document.getElementById('app') ); }; renderer();
src/components/About/index.js
evandromacedo/evandromacedo.com
import React from 'react' import { Link, useStaticQuery, graphql } from 'gatsby' import Img from 'gatsby-image' import { BaseContent } from '../../styles/base' import * as S from './styled' const About = () => { const { meWithBeers } = useStaticQuery(graphql` query { meWithBeers: file(relativePath: { eq: "about/me-with-beers.jpg" }) { childImageSharp { fluid(maxWidth: 960, quality: 100) { ...GatsbyImageSharpFluid } } } } `) return ( <BaseContent> <h1>About</h1> <h2 className="description">Me, Skillset, Usage and The blog</h2> <h2>Me</h2> <p> I'm Evandro Macedo, a web developer born in the Northeast of Brazil. I'm a supporter of an independent World Wide Web with open knowledge and information for everyone. </p> <p> I was a kid full of curiosity about computers, raised by the internet and guided by it ever since. Before graduating in Internet Systems Technology, I studied Computer Networks and Chemistry - yeah, I don't know why - but I quickly realized they didn't fit for me. After I started studying how the Web works I was fulfilled with enthusiasm and have found this was the right career to follow. </p> <p> I find myself more interested in web design and programming, so naturally I tend to study more front-end development and client-side stuff in general. I believe that with all the digital inclusion we have today, if every programmer knew a little bit about design and every designer knew a little bit about programming, working without barriers, we could make a faster progress on the internet. </p> <p> Most of the time I'm working with HTML5, CSS3, ES6 and all the things derived from them. New web technologies makes me excited to learn. </p> <p> When I'm not coding probably I'm drinking some beer with my friends, watching a movie/series, playing guitar/bass, reading a book, playing a game or watching some{' '} <Anchor href="https://www.youtube.com/watch?v=5TbUxGZtwGI"> video about the space-time like this one </Anchor>{' '} and having an existencial crisis. </p> <Img alt="Me with beers" fluid={meWithBeers.childImageSharp.fluid} /> <h2>Skillset</h2> <S.ColumnWrapper> <S.Column> <S.ColumnTitle>Currently using and studying:</S.ColumnTitle> <ul> <li>HTML5, CSS3 and ES6+Beyond</li> <li>Git</li> <li>Mobile and Responsive Web Design</li> <li>React / Redux</li> <li>CSS-in-JS (Styled Components)</li> <li>TDD (Jest and Enzyme)</li> <li>Next</li> <li>Gatsby</li> <li>GraphQL (Apollo, Prisma)</li> <li>NodeJS</li> <li>MongoDB</li> </ul> </S.Column> <S.ColumnDivider /> <S.Column> <S.ColumnTitle>Already worked with or studied:</S.ColumnTitle> <ul> <li>AngularJS (1.x)</li> <li>jQuery</li> <li>Sass</li> <li>Bootstrap / Foundation</li> <li>PHP</li> <li>SQL / MySQL / PostgreSQL</li> <li>Python / Django</li> <li>Ruby on Rails</li> <li>Java / JSF</li> <li>Scrum / Kanban</li> </ul> </S.Column> </S.ColumnWrapper> <h2>Usage</h2> <S.ColumnWrapper> <S.Column> <S.ColumnTitle>Hardware:</S.ColumnTitle> <ul> <li>An old MacBook Pro (13", Mid 2012), Intel Core i5, 8GB RAM, 240GB SSD</li> <li>External monitor LG 21,5" 22MP55PQ</li> <li>Magic Keyboard</li> <li>Magic Mouse</li> <li>Apple EarPods</li> </ul> </S.Column> <S.ColumnDivider /> <S.Column> <S.ColumnTitle>Software:</S.ColumnTitle> <ul> <li>Visual Studio Code</li> <li>Hyper Terminal</li> <li>Dracula Theme</li> <li>Sketch for design</li> <li>Spotify for music</li> <li>Evernote for notes</li> </ul> </S.Column> </S.ColumnWrapper> <hr /> <h2>The blog</h2> <p> It was made with the intention of sharing some of my knowledge and document how I solved technical and non-technical problems. The absence of comments in this site is intentional, but you can reach me in any social media if you want to say something. </p> <p> This blog is powered by <Anchor href="https://www.gatsbyjs.org/">Gatsby</Anchor>. The search functionality is powered by{' '} <Anchor href="https://www.algolia.com/">Algolia</Anchor>. You can check more details on <Link to="/how-this-blog-was-built/">how this blog was built</Link>{' '} here. The source code is{' '} <Anchor href="https://github.com/evandromacedo/evandromacedo.com"> publicly available </Anchor>{' '} and you can{' '} <Anchor href="https://github.com/evandromacedo/evandromacedo.com/pulls"> submit a pull request </Anchor>{' '} if you see something wrong. Thank you! </p> </BaseContent> ) } const Anchor = ({ href, children }) => ( <a href={href} target="_blank" rel="noopener noreferrer"> {children} </a> ) export const AboutFooter = () => ( <S.Footer> <Anchor href="https://github.com/evandromacedo">GitHub</Anchor> {' • '} <Anchor href="https://twitter.com/evandromacedo_">Twitter</Anchor> {' • '} <Anchor href="https://www.linkedin.com/in/evandrohcm/">LinkedIn</Anchor> {' • '} <Anchor href="https://instagram.com/evan.macedo">Instagram</Anchor> </S.Footer> ) export default About
client/common/components/AppBarSubNavMenu.js
Haaarp/geo
import React from 'react'; import {Nav} from 'react-bootstrap'; class AppBarSubNavMenu extends React.Component{ render(){ return( <Nav className="sub-nav"> {this.props.children} </Nav> ); } } export default AppBarSubNavMenu;
components/Education.js
davidpham5/resume
import React from 'react' import { WorkExperience } from "./Work-Experience/WorkExperience"; const Education = () => { const { education } = WorkExperience; return ( <div className="mt-8 pl-10"> <h1 className="header font-serif text-4xl border-b mb-2"> {education.header} </h1> <div className="exp"> <h3 className="text-xl font-serif">{education.college}</h3> <ul className="inline-flex mt-1 mb-1"> <li className="font-bold pr-2">{education.major}</li> <li className="text-gray-700 pr-2">{education.degree}</li> <li className="text-gray-700 pr-2">{education.gradDate}</li> </ul> <p className="text-gray-700">{education.funny}</p> </div> </div> ) } export default Education;
src-client/modules/app/containers/ProxySetupModal/index.js
ipselon/structor
/* * Copyright 2017 Alexander Pustovalov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { modelSelector } from './selectors.js'; import { containerActions } from './actions.js'; import { Modal, Button } from 'react-bootstrap'; import { ProxyInput } from 'components'; class Container extends Component { constructor(props) { super(props); this.handleClose = this.handleClose.bind(this); this.handleSave = this.handleSave.bind(this); } handleClose(e){ e.stopPropagation(); e.preventDefault(); this.props.hideModal(); } handleSave(e){ e.stopPropagation(); e.preventDefault(); const { save } = this.props; save(this.urlInputElement.getUrlValue() || null); } render() { const { componentModel, appContainerModel: {proxyURL}, hideModal } = this.props; return ( <Modal show={componentModel.show} onHide={hideModal} dialogClassName="umy-modal-overlay umy-modal-middlesize" backdrop={true} keyboard={true} bsSize="large" ref="dialog" animation={true} > <Modal.Header closeButton={false} aria-labelledby='contained-modal-title' > <Modal.Title id='contained-modal-title'>Proxy URL settings</Modal.Title> </Modal.Header> <Modal.Body> <div style={{padding: "1em"}}> <ProxyInput ref={me => this.urlInputElement = me} urlValue={proxyURL} /> </div> </Modal.Body> <Modal.Footer> <Button onClick={this.handleClose}>Cancel</Button> <Button onClick={this.handleSave} bsStyle="primary">Save changes</Button> </Modal.Footer> </Modal> ); } } export default connect(modelSelector, containerActions)(Container);
src/Home/SparkLines.js
Software-Eng-THU-2015/pacific-rim
import React, { Component } from 'react'; import ControllerChart from './Line'; import classNames from 'classnames'; var $ = jQuery = require('jquery'); import './Frame.css'; export default class SparkLines extends Component { constructor(props){ super(props); console.log(this.props.params.id); this.state = { currentID: 0, }; } handleBtnClick(item){ this.setState({ currentID: item.id, }, function(){ this.refs.chart.updateChart(item.id); }); } componentDidMount(){ this.setState({ currentID: 0, }); } render() { var btns = [ { label: 'week', id: 0,}, { label: 'doubleWeek', id: 1,}, { label: 'month', id: 2,} ]; var Buttons = _.map(btns, (item) => { var BtnClass = classNames({ 'ui button col-xs-4': true, 'teal': item.id == this.state.currentID, }); return ( <div className = {BtnClass} onClick={this.handleBtnClick.bind(this, item)} key = {item.id}>{item.label}</div> ) }); return ( <div> <div className = "ui three top attached buttons" style={{"padding":"10px 10px 10px 10px"}}> {Buttons} </div> <div className = "ui attached segment"> <ControllerChart ref = "chart" id = {this.state.currentID} {...this.props} /> </div> </div> ); } }
examples/with-firebase-functions/src/App.js
jaredpalmer/react-production-starter
import './App.css'; import React from 'react'; const App = () => <div>Welcome to Razzle.</div>; export default App;
src/Card/CollapsedHeader/CollapsedHeader.driver.js
skyiea/wix-style-react
import React from 'react'; import ReactDOM from 'react-dom'; const CollapsedHeaderDriverFactory = ({element, wrapper, component}) => { const title = element.querySelector('[data-hook="title"]'); const subtitle = element.querySelector('[data-hook="subtitle"]'); return { exists: () => !!element, title: () => title && title.innerHTML, subtitle: () => subtitle && subtitle.innerHTML, element: () => element, setProps: props => { const ClonedWithProps = React.cloneElement(component, Object.assign({}, component.props, props), ...(component.props.children || [])); ReactDOM.render(<div ref={r => element = r}>{ClonedWithProps}</div>, wrapper); } }; }; export default CollapsedHeaderDriverFactory;
packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js
mangomint/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 { abstract } from './assets/abstract.json'; export default () => <summary id="feature-json-inclusion">{abstract}</summary>;
src/Mailman.Server/ClientApp/src/components/merge-template/InfoCard.js
coe-google-apps-support/Mailman
import React from 'react' import PropTypes from 'prop-types' import { withStyles } from '@material-ui/core/styles' import Paper from '@material-ui/core/Paper' import MailIcon from '@material-ui/icons/Mail' import Typography from '@material-ui/core/Typography' import List from '@material-ui/core/List' import ListItem from '@material-ui/core/ListItem' import ListItemText from '@material-ui/core/ListItemText' import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction' import InfoCardSidebar from './InfoCardSidebar' const styles = theme => ({ paper: { height: 160, width: 250, }, largeIcon: { width: 50, height: 50, }, text: { maxWidth: 120, }, list: { paddingTop: 30, }, }) const InfoCard = props => { const { classes } = props return ( <div> <Paper className={classes.paper}> <List className={classes.list}> <ListItem> <MailIcon className={classes.largeIcon} /> <ListItemText primary={ <Typography variant="h5" className={classes.text} noWrap={true}> {props.title} </Typography> } /> </ListItem> <ListItemSecondaryAction> <InfoCardSidebar id={props.id} /> </ListItemSecondaryAction> </List> </Paper> </div> ) } InfoCard.propTypes = { classes: PropTypes.object.isRequired, theme: PropTypes.object.isRequired, title: PropTypes.string.isRequired, to: PropTypes.string.isRequired, id: PropTypes.string.isRequired, } export default withStyles(styles, { withTheme: true })(InfoCard)
js/containers/favorites.js
bengaara/simbapp
import React, { Component } from 'react'; import { StatusBar } from 'react-native'; import { connect } from 'react-redux'; import { Container, Header, Title, Content, Text, H3, Button, Icon, Footer, FooterTab, Left, Right, Body } from 'native-base'; import { openDrawer } from '../actions/drawer'; import styles from './styles/login'; class Login extends Component { static propTypes = { openDrawer: React.PropTypes.func, } render() { return ( <Container style={styles.container}> <Header> <Left> <Button transparent onPress={this.props.openDrawer}> <Icon name="ios-menu" /> </Button> </Left> <Body> <Title>Header</Title> </Body> <Right /> </Header> <Content padder> <Text> Content Goes Here </Text> </Content> <Footer> <FooterTab> <Button active full> <Text>Footer</Text> </Button> </FooterTab> </Footer> </Container> ); } } function bindAction(dispatch) { return { openDrawer: () => dispatch(openDrawer()), }; } const mapStateToProps = state => ({ navigation: state.cardNavigation, themeState: state.drawer.themeState, }); export default connect(mapStateToProps, bindAction)(Login);
src/index.js
awkaiser/react-tictactoe
import React from 'react'; import ReactDOM from 'react-dom'; import * as serviceWorker from './serviceWorker'; import App from './components/App'; // TODO: Switch to Concurrent Mode with future React release ReactDOM.render(<App />, document.getElementById('tictactoe')); serviceWorker.register();
20161216/cnode/app/HomePage.js
fengnovo/react-native
import React from 'react'; import { Text, View, ScrollView, Image, RefreshControl, TouchableHighlight, StyleSheet } from 'react-native'; import Detail from './Detail'; class HomePage extends React.Component { constructor(props) { super(props); this.state = { lists: [] } // this._onScrollBeginDrag = this._onScrollBeginDrag.bind(this); // this._onScrollEndDrag = this._onScrollEndDrag.bind(this); // this._onMomentumScrollBegin = this._onMomentumScrollBegin.bind(this); // this._onMomentumScrollEnd = this._onMomentumScrollEnd.bind(this); // this._onRefresh = this._onRefresh.bind(this); } _onScrollBeginDrag() { console.log('开始拖拽'); } _onScrollEndDrag() { console.log('结束拖拽'); } _onMomentumScrollBegin() { console.log('开始滑动'); } _onMomentumScrollEnd() { console.log('滑动结束'); } _onRefresh () { console.log('刷新'); } componentWillMount () { } componentDidMount () { fetch('https://cnodejs.org/api/v1/topics') .then(res => res.json()) .then(data =>{ console.log(data); this.setState({ lists: data.data }); } ) .catch(e=>console.log(e)) .done(); } componentWillUnmount () { } _openPage(id, title) { this.props.navigator.push({ title: '详情', component: Detail, params: { id: id, title: title } }) } render() { let Arr = [], lists = this.state.lists, _this = this; console.log(_this); for (let i in lists){ let list = lists[i]; let row = ( <TouchableHighlight key={list.id} onPress={_this._openPage.bind(this,list.id, list.title)}> <View style={styles.row}> <Image style={styles.imgStyle} source={{uri:list.author.avatar_url}}/> <View style={styles.rightContainer}> <Text style={styles.title}>{list.title}</Text> <Text style={styles.year}>{list.last_reply_at}</Text> </View> </View> </TouchableHighlight> ); Arr.push(row); } return ( <View> <ScrollView > { Arr } </ScrollView> </View> ) } } const styles = StyleSheet.create({ row: { flexDirection: "row", padding: 5, alignItems: "center", backgroundColor: "#F5FCFF" }, imgStyle: { width: 54, height: 80, backgroundColor: "gray" }, rightContainer:{ marginLeft: 10, flex: 1 }, title: { fontSize: 18, marginTop: 3, marginBottom: 3, textAlign: "center" }, year: { marginBottom: 3, textAlign: "center" } }); export default HomePage;
app/components/layout.js
ndnhat/te-starter
'use strict'; import React from 'react'; import { RouteHandler } from 'react-router'; import Header from './shared/header'; import Footer from './shared/footer'; class Layout extends React.Component { constructor(props) { super(props); this._onAuth = this._onAuth.bind(this); this._onUser = this._onUser.bind(this); } _onAuth() { let { router } = this.context; router.transitionTo('login', {}, { nextPath: router.getCurrentPath() }); } _onUser() { } render() { let classes = 'o-layout'; return ( <div className={classes}> <Header /> <RouteHandler /> <Footer /> </div> ); } } Layout.contextTypes = { router: React.PropTypes.func }; export default Layout;
exemplos/ExemploCarousel.js
vitoralvesdev/react-native-componentes
import React, { Component } from 'react'; import { View, StyleSheet, Dimensions } from 'react-native'; import { Carousel } from 'react-native-componentes'; const { width, height } = Dimensions.get('window'); export default class ExemploCarousel extends Component { render() { return( <Carousel paginaAtual={index=>console.log("PÁGINA_ATUAL=>", index)} > <View style={estilos.pagina1}></View> <View style={estilos.pagina2}></View> <View style={estilos.pagina3}></View> </Carousel> ) } } const estilos = StyleSheet.create({ pagina1 : { width, height, backgroundColor: '#BF2222' }, pagina2 : { width, height, backgroundColor: '#2B95FF' }, pagina3 : { width, height, backgroundColor: '#DAF722' } })
src/svg-icons/action/accessible.js
kasra-co/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionAccessible = (props) => ( <SvgIcon {...props}> <circle cx="12" cy="4" r="2"/><path d="M19 13v-2c-1.54.02-3.09-.75-4.07-1.83l-1.29-1.43c-.17-.19-.38-.34-.61-.45-.01 0-.01-.01-.02-.01H13c-.35-.2-.75-.3-1.19-.26C10.76 7.11 10 8.04 10 9.09V15c0 1.1.9 2 2 2h5v5h2v-5.5c0-1.1-.9-2-2-2h-3v-3.45c1.29 1.07 3.25 1.94 5 1.95zm-6.17 5c-.41 1.16-1.52 2-2.83 2-1.66 0-3-1.34-3-3 0-1.31.84-2.41 2-2.83V12.1c-2.28.46-4 2.48-4 4.9 0 2.76 2.24 5 5 5 2.42 0 4.44-1.72 4.9-4h-2.07z"/> </SvgIcon> ); ActionAccessible = pure(ActionAccessible); ActionAccessible.displayName = 'ActionAccessible'; ActionAccessible.muiName = 'SvgIcon'; export default ActionAccessible;
js/ui/ProductsList.js
ahoak/react-cookie-app
import React from 'react' import PropTypes from 'prop-types' const ProductsList = ({ title, children }) => ( <div> <div className="menuHeader"> <h1 className='menuPanel'><strong>{title}</strong></h1> </div> <div>{children}</div> </div> ); ProductsList.propTypes = { children: PropTypes.node, title: PropTypes.string.isRequired, }; export default ProductsList;
examples/simple/components/App.js
lucasterra/react-custom-scrollbars
import random from 'lodash/number/random'; import React, { Component } from 'react'; import { Scrollbars } from 'react-custom-scrollbars'; function getRandomSize() { return { height: random(300, 500), width: random(50, 100) + '%' }; } export default class App extends Component { constructor(props, context) { super(props, context); this.state = getRandomSize(); } componentDidMount() { this.interval = setInterval(() => { this.setState(getRandomSize()); }, 1000); } componentWillUnmount() { clearInterval(this.interval); } render() { return ( <div> <Scrollbars style={{ height: 300, marginBottom: 50}}> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> </Scrollbars> <Scrollbars style={this.state} scrollbarHorizontal={({ style, ...props }) => <div style={{...style, bottom: 0, right: 6, left: 0, backgroundColor: '#d7d7d7' }} {...props}/>} scrollbarVertical={({ style, ...props }) => <div style={{...style, top: 0, right: 0, bottom: 6, backgroundColor: '#d7d7d7' }} {...props}/>} thumbHorizontal={({ style, ...props }) => <div style={{...style, backgroundColor: '#979797' }} {...props}/>} thumbVertical={({ style, ...props }) => <div style={{...style, backgroundColor: '#979797' }} {...props}/>} > <div style={{width: 1000, paddingRight: 10, paddingBottom: 10}}> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> </div> </Scrollbars> </div> ); } }
src/Row.js
modulexcite/react-bootstrap
import React from 'react'; import classNames from 'classnames'; import CustomPropTypes from './utils/CustomPropTypes'; const Row = React.createClass({ propTypes: { /** * You can use a custom element for this component */ componentClass: CustomPropTypes.elementType }, getDefaultProps() { return { componentClass: 'div' }; }, render() { let ComponentClass = this.props.componentClass; return ( <ComponentClass {...this.props} className={classNames(this.props.className, 'row')}> {this.props.children} </ComponentClass> ); } }); export default Row;
eventkit_cloud/ui/static/ui/app/components/Notification/NotificationsDropdown.js
terranodo/eventkit-cloud
import PropTypes from 'prop-types'; import React from 'react'; import { connect } from 'react-redux'; import { withTheme } from '@material-ui/core/styles'; import withWidth, { isWidthUp } from '@material-ui/core/withWidth'; import CircularProgress from '@material-ui/core/CircularProgress'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; import GridList from '@material-ui/core/GridList'; import Paper from '@material-ui/core/Paper'; import NotificationGridItem from './NotificationGridItem'; import { markAllNotificationsAsRead } from '../../actions/notificationsActions'; export class NotificationsDropdown extends React.Component { constructor(props) { super(props); this.handleViewAll = this.handleViewAll.bind(this); } handleViewAll() { if (this.props.onNavigate('/notifications')) { this.props.history.push('/notifications'); } } render() { const { colors } = this.props.theme.eventkit; const { width } = this.props; const styles = { root: { position: 'absolute', top: '80px', left: isWidthUp('md', width) ? '-2px' : '-67px', width: isWidthUp('md', width) ? 'auto' : 'calc(100vw - 6px)', zIndex: '100', transition: 'transform 0.25s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.25s cubic-bezier(0.23, 1, 0.32, 1)', transformOrigin: isWidthUp('md', width) ? '37px -21px' : '101px -21px', ...this.props.style, }, pointer: { position: 'absolute', top: '-12px', left: isWidthUp('md', width) ? '25px' : '89px', width: '25px', height: '25px', background: colors.white, transform: 'rotate(-60deg) skewX(-30deg) scale(1,.866)', borderTopRightRadius: '3px', }, paper: { width: isWidthUp('md', width) ? '633px' : '100%', paddingBottom: isWidthUp('md', width) ? '24px' : '18px', color: colors.black, }, header: { display: 'flex', alignItems: 'center', padding: isWidthUp('md', width) ? '28px 28px 20px' : '18px 18px 18px', }, headerTitle: { fontSize: '22px', textTransform: 'uppercase', flex: '1', }, headerLink: { fontSize: '14px', color: colors.primary, cursor: 'pointer', }, gridList: { width: '100%', padding: isWidthUp('md', width) ? '0 18px' : '0 4px', }, gridItem: { padding: '10px', boxShadow: 'none', borderBottom: `1px solid ${colors.secondary}`, borderRadius: '0', }, noData: { textAlign: 'center', fontSize: '18px', color: colors.text_primary, }, viewAllContainer: { marginTop: isWidthUp('md', width) ? '24px' : '18px', textAlign: 'center', }, viewAll: { color: colors.primary, fontSize: isWidthUp('md', width) ? '22px' : '18px', textTransform: 'uppercase', cursor: 'pointer', }, }; const maxNotifications = isWidthUp('md', width) ? 10 : 8; const notifications = this.props.notifications.notificationsSorted.slice(0, maxNotifications); let body = ( <div className="qa-NotificationsDropdown-NoData" style={styles.noData} > {"You don't have any notifications."} </div> ); if (this.props.loading) { body = ( <div style={{ textAlign: 'center' }}> <CircularProgress color="primary" size={35} /> </div> ); } else if (notifications.length > 0) { body = ( <GridList className="qa-NotificationsDropdown-Grid" cellHeight="auto" style={styles.gridList} spacing={0} cols={1} > {notifications.map((notification, index) => ( <NotificationGridItem key={`Notification-${notification.id}`} paperStyle={{ ...styles.gridItem, borderTop: (index === 0) ? `1px solid ${colors.secondary}` : '', }} notification={notification} history={this.props.history} onView={this.props.onNavigate} /> ))} </GridList> ); } return ( <div style={styles.root}> <div className="qa-NotificationsDropdown-Pointer" style={styles.pointer} /> <ClickAwayListener onClickAway={this.props.onClickAway}> <Paper style={styles.paper}> <div className="qa-NotificationsDropdown-Header" style={styles.header} > <span className="qa-NotificationsDropdown-Header-Title" style={styles.headerTitle} > Notifications </span> <span role="button" tabIndex={0} className="qa-NotificationsDropdown-Header-MarkAllAsRead" style={styles.headerLink} onClick={this.props.markAllNotificationsAsRead} onKeyPress={this.props.markAllNotificationsAsRead} > Mark All As Read </span> </div> {body} <div style={styles.viewAllContainer}> <span role="button" tabIndex={0} className="qa-NotificationsDropdown-ViewAll" style={styles.viewAll} onClick={this.handleViewAll} onKeyPress={this.handleViewAll} > View All </span> </div> </Paper> </ClickAwayListener> </div> ); } } NotificationsDropdown.propTypes = { style: PropTypes.object, notifications: PropTypes.object.isRequired, history: PropTypes.object.isRequired, onNavigate: PropTypes.func, loading: PropTypes.bool.isRequired, markAllNotificationsAsRead: PropTypes.func.isRequired, onClickAway: PropTypes.func.isRequired, theme: PropTypes.object.isRequired, width: PropTypes.string.isRequired, }; NotificationsDropdown.defaultProps = { style: {}, onNavigate: () => true, }; function mapDispatchToProps(dispatch) { return { markAllNotificationsAsRead: () => dispatch(markAllNotificationsAsRead()), }; } export default withWidth()(withTheme(connect(null, mapDispatchToProps)(NotificationsDropdown)));
src/core/router/index.js
dilansri/smart-note-taker
import React from 'react' import { Route, Router, IndexRoute, hashHistory} from 'react-router' import firebase from '../firebase' import App from '../../views/app-container' import Login from '../../views/containers/login' const requireLogin = (nextState,replace,next) => { console.log('require login middleware invokes') if(!firebase.auth().currentUser){ replace('/') } next() } const handleIfLoggedIn = (nextState,replace,next) => { console.log('index route middleware invokes') if(firebase.auth().currentUser){ replace('/notes') } next() } const routes = ( <Router history={hashHistory}> <Route path="/"> <Route path="notes" component={App} onEnter={requireLogin} /> <IndexRoute component={Login} onEnter={handleIfLoggedIn} /> </Route> </Router> ) export default routes
example/src/internal-state.js
Julusian/react-bootstrap-switch
import React from 'react'; import { Col, Button, ButtonGroup, FormGroup } from 'react-bootstrap'; import Switch from '../../src/js/index'; export class InternalState extends React.Component { _clickToggle(){ const val = this.switch.value(); this.switch.value(!val); } _clickOn(){ this.switch.value(true); } _clickOff(){ this.switch.value(false); } _clickGet(){ alert(this.switch.value()); } render(){ return ( <Col xs={6} md={4}> <h3>Internal State</h3> <form> <FormGroup> <Switch ref={e => this.switch = e} /> </FormGroup> <FormGroup> <ButtonGroup> <Button onClick={this._clickToggle.bind(this)} >Toggle</Button> <Button onClick={this._clickOn.bind(this)} >On</Button> <Button onClick={this._clickOff.bind(this)} >Off</Button> <Button onClick={this._clickGet.bind(this)} >Get</Button> </ButtonGroup> </FormGroup> </form> </Col> ); } }
meteor/imports/ui/components/ChartTags.js
globeandmail/chart-tool
import React, { Component } from 'react'; import { Meteor } from 'meteor/meteor'; import slug from 'slug'; import Tags from '../../api/Tags/Tags'; import { Creatable as Select } from 'react-select'; import { withTracker } from 'meteor/react-meteor-data'; import { arrayDiff } from '../../modules/utils'; class ChartTags extends Component { constructor(props) { super(props); this.handleSelectChange = this.handleSelectChange.bind(this); this.handleNewTag = this.handleNewTag.bind(this); } handleSelectChange(selectedOptions) { const newChartTags = selectedOptions.map(s => s.value), oldChartTags = this.props.chartTags.map(s => s.value), tagId = arrayDiff(newChartTags, oldChartTags)[0]; Meteor.call('tags.change', tagId, this.props.chart._id, selectedOptions.map(s => s.label), err => { if (err) { console.log(err); } }); } handleNewTag(event) { const newTag = slug(event.value), newChartTags = this.props.chartTags.map(s => s.label); newChartTags.push(newTag); Meteor.call('tags.create', newTag, this.props.chart._id, newChartTags, err => { if (err) { console.log(err); } }); } render() { return ( <div className='edit-box'> <h3 id='ChartTags' onClick={this.props.toggleCollapseExpand}>Tags</h3> <div className={`unit-edit ${this.props.expandStatus('ChartTags')}`}> <h4>Add a few tags below</h4> { !this.props.loading ? <Select multi={true} className={'edit-tags-select'} value={this.props.chartTags} onChange={this.handleSelectChange} options={this.props.availableTags} onNewOptionClick={this.handleNewTag} /> : null } </div> </div> ); } } export default withTracker(props => { const subscription = Meteor.subscribe('tags'); return { props, loading: !subscription.ready(), chartTags: Tags.find({ tagged: props.chart._id }).fetch().map(t => ({ value: t._id, label: t.tagName })), availableTags: Tags.find().fetch().map(t => ({ value: t._id, label: t.tagName })) }; })(ChartTags);
src/components/Main.js
benawad/nukool
import React from 'react'; const Main = React.createClass({ render() { return ( <div> {React.cloneElement(this.props.children, this.props)} </div> ) } }); export default Main;
app/addons/components/header-breadcrumbs.js
apache/couchdb-fauxton
// Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy of // the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations under // the License. import PropTypes from 'prop-types'; import React from 'react'; import ReactDOM from 'react-dom'; export const Breadcrumbs = ({crumbs}) => { return ( <div className="faux-header__breadcrumbs"> {getChildren(crumbs)} </div> ); }; Breadcrumbs.propTypes = { crumbs: PropTypes.array.isRequired }; const CrumbElement = ({children}) => { return <div className="faux-header__breadcrumbs-element">{children}</div>; }; const Divider = () => { return ( <div className="fonticon-right-open faux-header__breadcrumbs-divider"></div> ); }; function getChildren (crumbs) { const amountDividers = crumbs.length - 1; return crumbs.map((c, i) => { let res = [<CrumbElement key={i}>{c.name}</CrumbElement>]; if (c.link) { res = [ <CrumbElement key={i}> <a className="faux-header__breadcrumbs-link" href={'#/' + c.link}>{c.name}</a> </CrumbElement> ]; } if (!c.name) { return res; } if (i < amountDividers) { res.push(<Divider key={'divider_' + i}/>); } return res; }); }
stories/components/donate/index.js
tal87/operationcode_frontend
import React from 'react'; import { storiesOf } from '@storybook/react'; import Donate from 'shared/components/donate/donate'; storiesOf('shared/components/donate', module) .add('Default', () => ( <Donate /> ));
Rosa_Madeira/Cliente/src/components/common/RefreshIcon.js
victorditadi/IQApp
import React, { Component } from 'react'; import { Text, TouchableOpacity } from 'react-native'; import { Icon } from 'native-base'; const RefreshIcon = () => { return ( <TouchableOpacity> <Icon name='ios-mail' style={Styles.iconStyle}/> </TouchableOpacity> ) } const Styles = { iconStyle: { fontSize: 130, color: '#737373' } }; export { RefreshIcon } ;
app/detail/Detail.js
ccfcheng/recommendation-app
import React, { Component } from 'react'; import { connect } from 'react-redux'; import {Card, CardHeader, CardMedia, CardTitle, CardText} from 'material-ui/Card'; class DetailContainer extends Component { constructor(props) { super(props); this.state = { expanded: false, }; this.handleExpandChange = this.handleExpandChange.bind(this); } handleExpandChange(expanded) { this.setState({expanded: expanded}); } render() { return ( <Detail business={this.props.business} handleExpandChange={this.handleExpandChange} slat={this.props.currentLatitude} slng={this.props.currentLongitude} /> ); } } class Detail extends Component { render() { const { business, slat, slng, } = this.props; const phoneURL = 'tel://' + business.display_phone; const phoneLink = <a href={phoneURL}>{business.display_phone}</a>; const dlat = business.location.coordinate.latitude; const dlng = business.location.coordinate.longitude; const mapURL = 'comgooglemaps://?saddr=' + slat + ',' + slng + '&daddr=' + dlat + ',' + dlng + '&directionsmode=driving'; const mapLink = <a href={mapURL}>{business.location.display_address.join(', ')}</a>; return ( <Card expanded={this.props.expanded} onExpandChange={this.props.handleExpandChange} > <CardHeader title={business.name} subtitle={business.rating + ' stars, ' + business.review_count + ' reviews'} avatar={business.image_url.replace('ms.jpg', 'ss.jpg')} actAsExpander={true} showExpandableButton={true} /> <CardMedia expandable={true} overlay={<CardTitle title={business.categories[0][0]} subtitle={mapLink} />} > <img src={business.image_url.replace('ms.jpg', 'ls.jpg')} /> </CardMedia> <CardTitle subtitle={phoneLink} expandable={true} /> <CardText expandable={true}> {business.snippet_text} </CardText> </Card> ); } } function mapStateToProps(state) { return { currentLatitude: state.search.currentLatitude, currentLongitude: state.search.currentLongitude, }; } export default connect(mapStateToProps)(DetailContainer);