path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
imports/old/signup/accountType.js
jiyuu-llc/jiyuu
import React from 'react'; const AccountType = () => ({ aTypeNext(){ var data = $( "select#accountSel option:selected").val(); if(data){ Session.set('aType', data); FlowRouter.go("/register/2"); }else{ alert("Please select an option"); } }, render() { return ( <div id="jiyuu"> <h2 className="question">What kind of user are you?</h2> <div id="question-card" className="form-group"> <div id="questionInputContain"> <center> <select className="form-control" id="accountSel"> <option value="EverydayUser">Everyday User</option> <option value="PublicFigure">Public Figure</option> <option value="News/MediaOutlet">News/Media Outlet</option> <option value="Business">Business</option> </select> </center> </div> <div className="qnext" onClick={this.aTypeNext.bind(this)}> <i className="fa fa-caret-right" aria-hidden="true"/> </div> </div> </div> ); } }); export default AccountType;
src/components/interactive/TextAreaInput.js
mrozilla/mrozilla.cz
// โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ // import // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ import React from 'react'; import { func } from 'prop-types'; import { Input } from '~components/primitives/Input'; // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ // component // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ export default function TextAreaInput({ onChange, ...rest }) { const autoResize = (element) => { const { style } = element; // prevent no-param-reassign eslint error const { borderTopWidth, borderBottomWidth } = window.getComputedStyle(element); const extraHeight = parseInt(borderTopWidth, 10) + parseInt(borderBottomWidth, 10); style.height = 'inherit'; // reset scrollHeight when deleting text style.height = `${element.scrollHeight + extraHeight}px`; // resize element to accommodate potential scroll }; const handleChange = (event) => { autoResize(event.target); onChange(event); }; return <Input as="textarea" onChange={handleChange} {...rest} />; } TextAreaInput.propTypes = { onChange: func, }; TextAreaInput.defaultProps = { onChange: () => {}, };
final/webapp/src/components/Dashboard/Card/Card.js
wasong/cmpt433
import React from 'react' import Radium from 'radium' import Status from '../Status' const styles = { root: { display: 'flex', height: '100%', position: 'relative', alignItems: 'center', padding: '0 10px', }, component: { flex: 10, display: 'flex', }, } const Card = ({ children, statusType }) => ( <div style={styles.root}> <div style={styles.component}>{children}</div> <Status type={statusType} /> </div> ) Card.defaultProps = { statusType: 'error', } export default Radium(Card)
docs/app/Examples/elements/Header/Types/HeaderPageHeadersExample.js
jamiehill/stardust
import React from 'react' import { Header } from 'stardust' const HeaderPageHeadersExamples = () => ( <div> <Header as='h1'> First Header </Header> <Header as='h2'> Second Header </Header> <Header as='h3'> Third Header </Header> <Header as='h4'> Fourth Header </Header> <Header as='h5'> Fifth Header </Header> <Header as='h6'> Sixth Header </Header> </div> ) export default HeaderPageHeadersExamples
src/icons/font/LocalOfferIcon.js
skystebnicki/chamel
import React from 'react'; import PropTypes from 'prop-types'; import FontIcon from '../../FontIcon'; import ThemeService from '../../styles/ChamelThemeService'; /** * LocalOffer button * * @param props * @param context * @returns {ReactDOM} * @constructor */ const LocalOfferIcon = (props, context) => { let theme = context.chamelTheme && context.chamelTheme.fontIcon ? context.chamelTheme.fontIcon : ThemeService.defaultTheme.fontIcon; return ( <FontIcon {...props} className={theme.iconLocalOffer}> {'local_offer'} </FontIcon> ); }; /** * An alternate theme may be passed down by a provider */ LocalOfferIcon.contextTypes = { chamelTheme: PropTypes.object, }; export default LocalOfferIcon;
text-dream/webapp/src/components/bodies/TokenSearchBodyComponent.js
PAIR-code/interpretability
/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ import React from 'react'; import {connect} from 'react-redux'; import PropTypes from 'prop-types'; import * as d3 from 'd3'; import {getColor} from '../../colors'; const margin = {top: 20, right: 20, bottom: 20, left: 100}; /** * Provides a Body Component for the Similar Embeddings Card. */ class TokenSearchBodyComponent extends React.Component { /** * Draws the chart once the component has mounted. */ componentDidMount() { this.drawGraph(); } /** * When this component updates, probably the dimensions have changed, * therefore, redraw the chart. */ componentDidUpdate() { this.drawGraph(); } /** * Renders the component. * * @return {jsx} the component to be rendered. */ render() { return ( <svg width="100%" height="100%" className={'tokenSearchComponent' + this.props.elementIndex}/> ); } /** * Draw the chart into the svg. */ drawGraph() { // Calculate the dimensions of the chart const sideSubstitute = 20 + margin.right + margin.left; const vertSubstitute = 120 + margin.top + margin.bottom; const width = this.props.cardDimensions.width > sideSubstitute ? this.props.cardDimensions.width - sideSubstitute : 20; const height = this.props.cardDimensions.height > vertSubstitute ? this.props.cardDimensions.height - vertSubstitute : 20; const svg = d3.select('.tokenSearchComponent' + this.props.elementIndex); // Remove any old chart svg.select('g').remove(); // Set up the scales and axes for the chart const tops = this.props.dreamingElement.tops; const maxActivation = tops[0].activation; let minActivation = 0; for (const top of tops) { minActivation = top.activation < minActivation ? top.activation : minActivation; } const xScaleActivation = d3.scaleLinear().domain([minActivation, maxActivation]).range([0, width]); const yScale = d3.scaleBand() .range([0, height]) .padding(0.1) .domain(tops.map(function(d) { return d.token; })); const yAxis = d3.axisLeft(yScale); // The group where the chart content lives in const mainGroup = svg.append('g').attr( 'transform', 'translate(' + margin.left + ',' + margin.top + ')'); // Add the activation bars to the chart mainGroup.selectAll('bar') .data(tops) .enter() .append('rect') .style('fill', getColor('activation')) .attr('x', 0) .attr( 'width', function(d) { return xScaleActivation(d.activation); }) .attr( 'y', function(d) { return yScale(d.token); }) .attr('height', yScale.bandwidth()); // Add a label to each of the bars mainGroup.selectAll('text') .data(tops) .enter() .append('text') .attr('y', function(d) { return yScale(d.token) + yScale.bandwidth() / 2 + 5; }) .attr('x', function(d) { return 3; }) .text(function(d) { return d.activation.toFixed(4); }); // Left axis of the bar chart mainGroup.append('g') .attr('class', 'yAxis') .call(yAxis) .selectAll('text') .style('font-size', '0.875rem'); } } TokenSearchBodyComponent.propTypes = { dreamingElement: PropTypes.object.isRequired, elementIndex: PropTypes.number.isRequired, cardDimensions: PropTypes.object.isRequired, }; /** * Mapping the state that this component needs to its props. * * @param {object} state - the application state from where to get needed props. * @param {object} ownProps - optional own properties needed to acess state. * @return {object} the props for this component. */ function mapStateToProps(state, ownProps) { return { cardDimensions: state.cardDimensions, }; } export default connect(mapStateToProps)(TokenSearchBodyComponent);
app/js/pages/Yao_qing_han.js
arcsecw/auto_writing
import React from 'react'; import { Container, Input, ButtonToolbar, Tabs, DateTimeInput, Button, ModalTrigger, } from 'amazeui-react'; import {Editor, EditorState} from 'draft-js'; import { withRouter } from 'react-router' import { myConfig } from '../components/config.js'; import {post} from '../components/Call' import View from '../components/View' var Yao_qing_han = withRouter(React.createClass( { getInitialState(){ return { parms:{ p1:'20', p2:'2016-11-15 09:00', p3:'ๅŒ—ไบฌไฟกๆฏ็ง‘ๆŠ€ๅคงๅญฆ', p4:'ๅŒๅญฆไผš็ญนๅค‡็ป„', type:'Meeting', }, form_data:{}, showModal: false, } }, close() { this.setState({showModal: false,form_data:{}}); }, open() { this.setState({showModal: true}); }, is_good(str){ if(str.length>0){ return 'success' } return 'error' }, validation_all(){ var a = this.state.parms for (let k in a ){ if(this.is_good(a[k])=='error'){ return false } } return true }, handle_submit(e){ e.preventDefault(); if (this.validation_all()){ var form1 = new FormData() for(let k in this.state.parms){ form1.append(k,this.state.parms[k]) } this.setState({form_data:form1},()=>{ this.open() }) }else{ this.forceUpdate() } }, render() { return ( <Container> <form className="am-form" id = 'myform'> <Input type="text" label="ๆฏ•ไธšๅ‘จๅนด" placeholder={this.state.parms['p1']} onChange = {(e)=>{this.state.parms['p1']=e.target.value}} validation = {this.is_good(this.state.parms['p1'])} /> <Input type="text" label="่šไผšๆ—ถ้—ด" placeholder={this.state.parms['p2']} onChange = {(e)=>{this.state.parms['p2']=e.target.value}} validation = {this.is_good(this.state.parms['p2'])} /> <Input type="text" label="่šไผšๅœฐ็‚น" placeholder={this.state.parms['p3']} onChange = {(e)=>{this.state.parms['p3']=e.target.value}} validation = {this.is_good(this.state.parms['p3'])} /> <Input type="text" label="่ฝๆฌพ" placeholder={this.state.parms['p4']} onChange = {(e)=>{this.state.parms['p4']=e.target.value}} validation = {this.is_good(this.state.parms['p4'])} /> <ButtonToolbar> <Input type = "submit" value="ๆไบค" standalone onClick={this.handle_submit} /> <Input type="reset" value="้‡็ฝฎ" amStyle="danger" standalone /> </ButtonToolbar> </form> <ModalTrigger modal={<View api_path='sc' form_data = {this.state.form_data} start_run = {this.state.showModal}/>} show={this.state.showModal} onClose={this.close} /> </Container> ) } }) ) export default Yao_qing_han
src/svg-icons/action/done-all.js
mit-cml/iot-website-source
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionDoneAll = (props) => ( <SvgIcon {...props}> <path d="M18 7l-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41L6 19l1.41-1.41L1.83 12 .41 13.41z"/> </SvgIcon> ); ActionDoneAll = pure(ActionDoneAll); ActionDoneAll.displayName = 'ActionDoneAll'; ActionDoneAll.muiName = 'SvgIcon'; export default ActionDoneAll;
app/javascript/mastodon/features/ui/components/modal_loading.js
pixiv/mastodon
import React from 'react'; import LoadingIndicator from '../../../components/loading_indicator'; // Keep the markup in sync with <BundleModalError /> // (make sure they have the same dimensions) const ModalLoading = () => ( <div className='modal-root__modal error-modal'> <div className='error-modal__body'> <LoadingIndicator /> </div> <div className='error-modal__footer'> <div> <button className='error-modal__nav onboarding-modal__skip' /> </div> </div> </div> ); export default ModalLoading;
packages/icons/src/md/av/RemoveFromQueue.js
suitejs/suitejs
import React from 'react'; import IconBase from '@suitejs/icon-base'; function MdRemoveFromQueue(props) { return ( <IconBase viewBox="0 0 48 48" {...props}> <path d="M42 6c2.21 0 4 1.79 4 4l-.02 24c0 2.21-1.77 4-3.98 4H32v4H16v-4H6c-2.21 0-4-1.79-4-4V10c0-2.21 1.79-4 4-4h36zm0 28V10H6v24h36zM32 20v4H16v-4h16z" /> </IconBase> ); } export default MdRemoveFromQueue;
blueprints/view/files/__root__/views/__name__View/__name__View.js
danieljwest/ExamGenerator
import React from 'react' type Props = { }; export class <%= pascalEntityName %> extends React.Component { props: Props; render () { return ( <div></div> ) } } export default <%= pascalEntityName %>
node_modules/react-bootstrap/es/ModalHeader.js
acalabano/get-committed
import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import classNames from 'classnames'; import React from 'react'; import PropTypes from 'prop-types'; import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils'; import createChainedFunction from './utils/createChainedFunction'; import CloseButton from './CloseButton'; // TODO: `aria-label` should be `closeLabel`. var propTypes = { /** * Provides an accessible label for the close * button. It is used for Assistive Technology when the label text is not * readable. */ closeLabel: PropTypes.string, /** * Specify whether the Component should contain a close button */ closeButton: PropTypes.bool, /** * A Callback fired when the close button is clicked. If used directly inside * a Modal component, the onHide will automatically be propagated up to the * parent Modal `onHide`. */ onHide: PropTypes.func }; var defaultProps = { closeLabel: 'Close', closeButton: false }; var contextTypes = { $bs_modal: PropTypes.shape({ onHide: PropTypes.func }) }; var ModalHeader = function (_React$Component) { _inherits(ModalHeader, _React$Component); function ModalHeader() { _classCallCheck(this, ModalHeader); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } ModalHeader.prototype.render = function render() { var _props = this.props, closeLabel = _props.closeLabel, closeButton = _props.closeButton, onHide = _props.onHide, className = _props.className, children = _props.children, props = _objectWithoutProperties(_props, ['closeLabel', 'closeButton', 'onHide', 'className', 'children']); var modal = this.context.$bs_modal; var _splitBsProps = splitBsProps(props), bsProps = _splitBsProps[0], elementProps = _splitBsProps[1]; var classes = getClassSet(bsProps); return React.createElement( 'div', _extends({}, elementProps, { className: classNames(className, classes) }), closeButton && React.createElement(CloseButton, { label: closeLabel, onClick: createChainedFunction(modal && modal.onHide, onHide) }), children ); }; return ModalHeader; }(React.Component); ModalHeader.propTypes = propTypes; ModalHeader.defaultProps = defaultProps; ModalHeader.contextTypes = contextTypes; export default bsClass('modal-header', ModalHeader);
src/js/services/lastfm/actions.js
jaedb/Iris
import React from 'react'; import { collate, formatImages, formatTrack, formatArtist, formatAlbum, } from '../../util/format'; import { generateGuid } from '../../util/helpers'; import { makeItemSelector, getItem } from '../../util/selectors'; import URILink from '../../components/URILink'; const coreActions = require('../core/actions'); const uiActions = require('../ui/actions'); export function set(data) { return { type: 'LASTFM_SET', data, }; } /** * Send an ajax request to the LastFM API * * @param dispatch = obj * @param getState = obj * @param params = string, the url params to send * @params signed = boolean, whether we've got a signed request with baked-in api_key * */ const sendRequest = (dispatch, getState, params, signed = false) => new Promise((resolve, reject) => { let url = `https://ws.audioscrobbler.com/2.0/?format=json&${params}`; let http_method = 'GET'; let method = params.substring(params.indexOf('method=') + 7, params.length); method = method.substring(0, method.indexOf('&')); // Signed requests don't need our api_key as the proxy has it's own if (!signed) { url += '&api_key=4320a3ef51c9b3d69de552ac083c55e3'; } else { http_method = 'POST'; } const config = { method: http_method, timeout: 30000, }; const loader_key = generateGuid(); dispatch(uiActions.startLoading(loader_key, `lastfm_${method}`)); function status(response) { dispatch(uiActions.stopLoading(loader_key)); if (response.status >= 200 && response.status < 300) { return Promise.resolve(response); } return Promise.reject(new Error(response.statusText)); } fetch(url, config) .then(status) .then((response) => response.json()) .then((data) => { resolve(data); }) .catch((error) => { reject(error); }); }); /** * Send a SIGNED ajax request to the LastFM API * * @param dispatch = obj * @param getState = obj * @param params = string, the url params to send * @param signed = boolean * */ const sendSignedRequest = (dispatch, getState, params) => new Promise((resolve, reject) => { // Not authorized if (!getState().lastfm.authorization) { reject({ params, error: 'No active LastFM authorization (session)', }); } const loader_key = generateGuid(); let method = params.substring(params.indexOf('method=') + 7, params.length); method = method.substring(0, method.indexOf('&')); dispatch(uiActions.startLoading(loader_key, `lastfm_${method}`)); params += `&sk=${getState().lastfm.authorization.key}`; const url = `${getState().lastfm.authorization_url}?action=sign_request&${params}`; const config = { method: 'GET', timeout: 30000, }; function status(response) { dispatch(uiActions.stopLoading(loader_key)); if (response.status >= 200 && response.status < 300) { return Promise.resolve(response); } return Promise.reject(new Error(response.statusText)); } fetch(url, config) .then(status) .then((response) => response.json()) .then((data) => { // Now we have signed params, we can make the actual request sendRequest(dispatch, getState, data.params, true) .then( (response) => resolve(response), (error) => reject(error), ); }) .catch((error) => { reject(error); }); }); /** * Handle authorization process * */ export function authorizationGranted(data) { data.session.expiry = new Date().getTime() + 3600; return { type: 'LASTFM_AUTHORIZATION_GRANTED', data, }; } export function revokeAuthorization() { return { type: 'LASTFM_AUTHORIZATION_REVOKED', }; } export function importAuthorization(authorization) { return { type: 'LASTFM_IMPORT_AUTHORIZATION', authorization, }; } /** * Non-signed requests * */ export function getMe() { return (dispatch, getState) => { const params = `method=user.getInfo&user=${getState().lastfm.authorization.name}`; sendRequest(dispatch, getState, params) .then( (response) => { if (response.user) { dispatch({ type: 'LASTFM_ME_LOADED', me: response.user, }); } }, (error) => { dispatch(coreActions.handleException( 'Could not get your LastFM profile', error, )); }, ); }; } export function getTrack(uri, callback, alreadyLoadedTrack) { return (dispatch, getState) => { const selector = makeItemSelector(uri); const track = alreadyLoadedTrack || selector(getState()); if (!track || !track.artists) { dispatch(coreActions.handleException( 'Could not get LastFM track', {}, 'Not in index or has no artists', )); return; } const track_name = track.name; const artist_name = encodeURIComponent(track.artists[0].name); let params = `method=track.getInfo&track=${track_name}&artist=${artist_name}`; if (getState().lastfm.authorization) { params += `&username=${getState().lastfm.authorization.name}`; } sendRequest(dispatch, getState, params) .then( (response) => { if (response.track) { const result = formatTrack({ uri: track.uri, ...response.track, ...track, }); dispatch(coreActions.itemLoaded(result)); if (callback) callback(result); } }, ); }; } export function getArtist(uri, name, mbid = false, noLanguage = false) { return (dispatch, getState) => { let params = 'method=artist.getInfo&'; if (mbid) { params += `mbid=${mbid}`; } else { params += `&artist=${encodeURIComponent(name.replace('&', 'and'))}`; } const language = !noLanguage ? window.language : undefined; if (language !== undefined) { params += `&lang=${language}`; } sendRequest(dispatch, getState, params) .then( (response) => { if (response.artist) { if (!noLanguage) { if ( language !== undefined && language !== 'en' && (!response.artist.bio || response.artist.bio.content === '') ) { getArtist(uri, name, mbid, true)(dispatch, getState); return; } } dispatch( coreActions.itemLoaded( formatArtist({ uri, mbid: response.artist.mbid, biography: response.artist.bio.content, biography_publish_date: response.artist.bio.published, biography_link: response.artist.bio.links.link.href, listeners: parseInt(response.artist.stats.listeners, 10), }), ), ); } }, ); }; } export function getAlbum(uri, artist, album, mbid = false) { return (dispatch, getState) => { if (mbid) { var params = `method=album.getInfo&mbid=${mbid}`; } else { artist = encodeURIComponent(artist); album = encodeURIComponent(album); var params = `method=album.getInfo&album=${album}&artist=${artist}`; } sendRequest(dispatch, getState, params) .then( (response) => { if (response.album) { const existing_album = getState().core.items[uri]; const album = { uri, images: response.album.image, listeners: parseInt(response.album.listeners), play_count: parseInt(response.album.playcount), mbid: response.album.mbid, wiki: (response.album.wiki ? response.album.wiki.content : null), wiki_publish_date: (response.album.wiki ? response.album.wiki.published : null), }; // If we've already got some of this album and it has images aready, don't use our ones. // In *most* cases this existing image will be perfectly suffice. This prevents an ugly // flicker when the existing image is replaced by the LastFM one if (existing_album && existing_album.images) { delete album.images; } dispatch(coreActions.itemLoaded(formatAlbum(album))); } }, ); }; } export function getImages(context, uri) { return (dispatch, getState) => { let record = getState().core[context][uri]; if (record) { switch (context) { case 'tracks': if (record.mbid) { var params = `method=album.getInfo&mbid=${record.mbid}`; } else { record = collate(record, { artists: getState().core.artists }); if (record.artists && record.artists.length > 0 && record.album) { var artist = encodeURIComponent(record.artists[0].name); var album = encodeURIComponent(record.album.name); var params = `method=album.getInfo&album=${album}&artist=${artist}`; } } if (params) { sendRequest(dispatch, getState, params) .then( (response) => { if (response.album) { const images = formatImages(response.album.image); dispatch(coreActions.itemLoaded(formatAlbum({ uri, images }))); } }, ); } break; case 'albums': if (record.mbid) { var params = `method=album.getInfo&mbid=${record.mbid}`; } else { record = collate(record, { artists: getState().core.artists }); if (record.artists && record.artists.length > 0) { var artist = encodeURIComponent(record.artists[0].name); var album = encodeURIComponent(record.name); var params = `method=album.getInfo&album=${album}&artist=${artist}`; } } if (params) { sendRequest(dispatch, getState, params) .then( (response) => { if (response.album) { dispatch( coreActions.itemLoaded(formatAlbum({ uri, images: response.album.image })), ); } }, ); } break; default: break; } } }; } /** * Signed requests * */ export function loveTrack(uri) { return (dispatch, getState) => { const asset = getItem(getState(), uri) || {}; if (!asset) { dispatch(coreActions.handleException( 'Could not love LastFM track', asset, 'Could not find track in index', )); return; } if (asset && !asset.artists) { dispatch(coreActions.handleException( 'Could not love LastFM track', asset, 'Track has no artists', )); return; } const artist = encodeURIComponent(asset.artists[0].name); const params = `method=track.love&track=${asset.name}&artist=${artist}`; sendSignedRequest(dispatch, getState, params) .then( () => { dispatch(coreActions.itemLoaded({ uri, userloved: true, })); dispatch(uiActions.createNotification({ content: ( <span> {'Loved '} <URILink type="track" uri={uri}>{asset ? asset.name : type}</URILink> </span> ), })); }, ); }; } export function unloveTrack(uri) { return (dispatch, getState) => { const asset = getItem(getState(), uri) || {}; if (!asset) { dispatch(coreActions.handleException( 'Could not love LastFM track', asset, 'Could not find track in index', )); return; } if (asset && !asset.artists) { dispatch(coreActions.handleException( 'Could not love LastFM track', asset, 'Track has no artists', )); return; } const artist = encodeURIComponent(asset.artists[0].name); const params = `method=track.unlove&track=${asset.name}&artist=${artist}`; sendSignedRequest(dispatch, getState, params) .then( () => { dispatch(coreActions.itemLoaded({ uri, userloved: false, })); dispatch(uiActions.createNotification({ content: ( <span> {'Unloved '} <URILink uri={uri}>{asset ? asset.name : type}</URILink> </span> ), })); }, ); }; } /** * TODO: Currently scrobbling client-side would result in duplicated scrobbles * if the user was authorized across multiple connections. Ideally this would * be handled server-side. Mopidy-Scrobbler currently achieves this. * */ export function scrobble(track) { return (dispatch, getState) => { const track_name = track.name; var artist_name = 'Unknown'; if (track.artists) { artist_name = track.artists[0].name; } var artist_name = encodeURIComponent(artist_name); let params = 'method=track.scrobble'; params += `&track=${track_name}&artist=${artist_name}`; params += `&timestamp=${Math.floor(Date.now() / 1000)}`; sendSignedRequest(dispatch, getState, params) .then( (response) => { console.log('Scrobbled', response); }, (error) => { dispatch(coreActions.handleException( 'Could not scrobble LastFM track', error, (error.description ? error.description : null), )); }, ); }; }
app/react-icons/fa/map-signs.js
scampersand/sonos-front
import React from 'react'; import IconBase from 'react-icon-base'; export default class FaMapSigns extends React.Component { render() { return ( <IconBase viewBox="0 0 40 40" {...this.props}> <g><path d="m39 6.6q0.2 0.3 0.2 0.5t-0.2 0.6l-3.2 3.1q-0.6 0.6-1.5 0.6h-30q-0.6 0-1-0.4t-0.4-1v-5.7q0-0.6 0.4-1t1-0.4h12.8v-1.5q0-0.6 0.5-1t1-0.4h2.8q0.6 0 1 0.4t0.5 1v1.5h11.4q0.9 0 1.5 0.6z m-21.9 20.5h5.8v11.5q0 0.6-0.5 1t-1 0.4h-2.8q-0.6 0-1-0.4t-0.5-1v-11.5z m18.6-10q0.6 0 1 0.5t0.4 1v5.7q0 0.6-0.4 1t-1 0.4h-30q-0.9 0-1.5-0.6l-3.1-3.2q-0.3-0.2-0.3-0.5t0.2-0.5l3.2-3.1q0.6-0.7 1.5-0.7h11.4v-4.2h5.8v4.2h12.8z"/></g> </IconBase> ); } }
pkg/ui/src/components/dashboard/HexagonChart.js
matt-deboer/kuill
import React from 'react' import d3 from 'd3' import ReactFauxDOM from 'react-faux-dom' import PropTypes from 'prop-types' export default class HexagonChart extends React.PureComponent { static propTypes = { /** * Called with an object where keys are the selected items' indicies */ onSelection: PropTypes.func, /** * An array of objects {name, value} */ items: PropTypes.array.isRequired, /** * An object with keys defining the initially selected items */ initialSelection: PropTypes.object, min: PropTypes.number, max: PropTypes.number, buckets: PropTypes.number, colorRange: PropTypes.array, } static defaultProps = { onSelection: function() {}, initialSelection: {}, // colorRange: ['rgb(0,88,229)','rgb(255,155,26)'], } constructor(props) { super(props) this.state = { selected: props.initialSelection, hovered: null, } for (let fn of ['handleSelectHex']) { this[fn] = this[fn].bind(this) } } handleSelectHex = (d) => { let selection = d.properties.index let selected if (d3.event.shiftKey) { selected = {...this.state.selected} if (selection in selected) { delete selected[selection] } else { selected[selection]=true } } else { selected = {} if (Object.keys(this.state.selected).length > 1 || !(selection in this.state.selected)) { selected[selection]=true } } this.setState({selected: selected}) this.props.onSelection(selected) } render() { let { items } = this.props // let itemCount = 30 // let items = [] // for (let i=0; i < itemCount; ++i) { // items.push({name: `i-${i}`, group: group(i, itemCount), label: `${i}_${group(i, itemCount)}`}) // } return this.renderHexChart(items) } /** * * @param {Array} items */ renderHexChart = (items) => { let el = ReactFauxDOM.createElement('div') let height = 100 let itemCount = items.length // how many hexes will fit in each size increment? // TODO: this is currently pinned to maxWidth: 300; need to model it let radius = 15 if (itemCount <= 11) { radius = 26 } else if (itemCount <= 24) { radius = 19 } else if (itemCount <= 40) { radius = 15 } else if (itemCount <= 96) { radius = 10 } else if (itemCount <= 207) { radius = 7 } else { // TODO: too many items; have to start grouping them // together by bins } let rows = Math.floor(height / (1.5 * radius)) let cols = (itemCount - (itemCount % rows)) / rows let width = (cols * radius * 2) + (2 * radius) const dx = radius * 2 * Math.sin(Math.PI / 3); const dy = radius * 1.5; let path_generator = d3.geo.path().projection(d3.geo.transform({ point: function(x, y) { return this.stream.point(x * dx / 2, -(y - (2 - (y & 1)) / 3) * dy / 2) } })) let svg = d3.select(el).append('svg').attr('width', width).attr('height', height) let vis = svg.append('g').attr('transform', `translate(${radius+2},${radius+2})`) let featureCollections = [] let allFeatures = [] let borders = [] let index = 0 let featuresByGroup = {} let hasLabels = false let orderedGroups = [] for (let item of items) { let g = (item.group || '__default__') if (!(g in featuresByGroup)) { orderedGroups.push(g) } let features = featuresByGroup[g] = featuresByGroup[g] || [] let increment = Math.max(Math.floor(((index % rows) - 1) / 2), 0) if (!!item.label) { hasLabels = true } let hex = newHex({ x: Math.ceil(index / rows) + increment, y: -(index % rows), i: index, group: g, label: item.label, classes: item.classes ? item.classes.join(' ') : '', n: neighbors(index, rows, itemCount), }) features.push(hex) allFeatures[index]=hex ++index } for (let g of orderedGroups) { let features = featuresByGroup[g] let fc = { type: 'FeatureCollection', features: features, properties: { group: g, } } featureCollections.push(fc) let points = this.computeBorder(features, allFeatures) borders.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: points, }, properties: { group: g, } }) } for (let fc of featureCollections) { let eachHex = vis.selectAll('.hex.' + fc.properties.group) .data(fc.features).enter() eachHex.append('path') .attr('class', function(d) { return 'hex ' + d.properties.classes}) .attr('d', path_generator) .on('mouseup', this.handleSelectHex) if (hasLabels) { eachHex.append('text') .attr("text-anchor", "middle") .attr("font-size", "7px") .attr("fill", "#FFF") .attr("pointer-events", "none") .attr("x", function(d) { return path_generator.centroid(d)[0] }) .attr("y", function(d) { return path_generator.centroid(d)[1] }) .attr('dy', 4) .text(function(d){return d.properties.label}) } } if (borders.length > 1) { for (let border of borders) { let b = vis.selectAll('.border.'+border.properties.group) .data([border]) .enter() b.append('path') .attr('class', 'border '+border.properties.group) .attr('d', path_generator) .attr("stroke-width", 2) .attr("stroke-linejoin", "round") .attr("fill", "none") } } return el.toReact() } computeBorder = (features, allFeatures) => { let segments = {} let segmentKeysByPoint = {} let firstSegment = null for (let f of features) { for (let j=0; j <6; ++j) { let neighborIndex = f.properties.neighbors[j] let neighbor = allFeatures[neighborIndex] if (!neighbor || f.properties.group !== neighbor.properties.group) { let p1 = f.geometry.coordinates[0][j] let p2 = f.geometry.coordinates[0][(j+1)] let seg = [p1,p2] let key = JSON.stringify(seg) let k1 = JSON.stringify(p1) let k2 = JSON.stringify(p2) let _k1s = segmentKeysByPoint[k1] = segmentKeysByPoint[k1] || [] _k1s.push(key) let _k2s = segmentKeysByPoint[k2] = segmentKeysByPoint[k2] || [] _k2s.push(key) seg._key = key seg._k1 = k1 seg._k2 = k2 segments[key] = seg if (!firstSegment) { firstSegment = seg } } } } let points = [] let prevPointKey = '' let currentSeg = firstSegment points.push(currentSeg[0]) let reversed = false let removeCurrentSegment = function(segs, currentSeg) { let _filter = function(e) { return e !== currentSeg._key } return segs.filter(_filter) } while (!!currentSeg) { delete segments[currentSeg._key] segmentKeysByPoint[currentSeg._k1] = removeCurrentSegment(segmentKeysByPoint[currentSeg._k1], currentSeg) segmentKeysByPoint[currentSeg._k2] = removeCurrentSegment(segmentKeysByPoint[currentSeg._k2], currentSeg) let pointToAdd = prevPointKey === currentSeg._k2 ? currentSeg[0] : currentSeg[1] if (reversed) { points.unshift(pointToAdd) } else { points.push(pointToAdd) } // Now find the next segment let pointKey = prevPointKey === currentSeg._k2 ? currentSeg._k1 : currentSeg._k2 let nextSegKey = segmentKeysByPoint[pointKey][0] prevPointKey = pointKey // should only be one key left now... currentSeg = segments[nextSegKey] if (!currentSeg && !reversed) { reversed = true currentSeg = firstSegment prevPointKey = firstSegment._k1 } } return points } } /** * Calculate the neighboring item indicies * for a given item index; note that some * returned indicies may be out of array bounds * for items, meaning there is no neighbor present * * @param {*} d * @param {*} rows * @param {*} itemCount */ function neighbors(d, rows, itemCount) { let n = [ d - 1 + (rows * (d % rows % 2)), d + rows, d + 1 + (rows * (d % rows % 2)), d + 1 - rows + (rows * (d % rows % 2)), d - rows, d - 1 - rows + (rows * (d % rows % 2)), ] if (d % rows === (rows - 1)) { n[2] = n[3] = -1 } else if (d % rows === 0) { n[0] = n[5] = -1 } return n } // function group(n, itemCount) { // if (n <= (itemCount / 3)) { // return 0 // } else if (n <= (2 * itemCount / 3)) { // return 1 // } else { // return 2 // } // } /** * * create a new hexagon */ function newHex(d) { /* conversion from hex coordinates to rect */ var x, y; x = 2 * (d.x + d.y / 2.0); y = 2 * d.y; return { type: 'Feature', geometry: { type: 'Polygon', coordinates: [[[x, y + 2], [x + 1, y + 1], [x + 1, y], [x, y - 1], [x - 1, y], [x - 1, y + 1], [x, y + 2]]] }, properties: { label: d.label, index: d.i, group: d.group, neighbors: d.n, classes: d.classes, } }; } /** * Tests whether the provided list of segments is contiguous; * i.e., the ending point of one segment matches the starting point of the next segment. * @param {Array} segments an array of line segments, in the form of [[x1,y1],[x2,y2]] */ // function segmentsContiguous(segments) { // let prevSeg = null // let consecutive = 0 // for (let seg of segments) { // if (prevSeg) { // if (prevSeg[1][0] === seg[0][0] && prevSeg[1][1] === seg[0][1]) { // ++consecutive // } else { // console.warn(`break after ${consecutive}: [${prevSeg[1][0]},${prevSeg[1][1]}] !== [${seg[0][0]},${seg[0][1]}]`) // consecutive = 0 // } // } // prevSeg = seg // } // return consecutive === segments.length // }
src/svg-icons/maps/traffic.js
rscnt/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsTraffic = (props) => ( <SvgIcon {...props}> <path d="M20 10h-3V8.86c1.72-.45 3-2 3-3.86h-3V4c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v1H4c0 1.86 1.28 3.41 3 3.86V10H4c0 1.86 1.28 3.41 3 3.86V15H4c0 1.86 1.28 3.41 3 3.86V20c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-1.14c1.72-.45 3-2 3-3.86h-3v-1.14c1.72-.45 3-2 3-3.86zm-8 9c-1.11 0-2-.9-2-2s.89-2 2-2c1.1 0 2 .9 2 2s-.89 2-2 2zm0-5c-1.11 0-2-.9-2-2s.89-2 2-2c1.1 0 2 .9 2 2s-.89 2-2 2zm0-5c-1.11 0-2-.9-2-2 0-1.11.89-2 2-2 1.1 0 2 .89 2 2 0 1.1-.89 2-2 2z"/> </SvgIcon> ); MapsTraffic = pure(MapsTraffic); MapsTraffic.displayName = 'MapsTraffic'; export default MapsTraffic;
app/javascript/mastodon/components/hashtag.js
im-in-space/mastodon
// @ts-check import React from 'react'; import { Sparklines, SparklinesCurve } from 'react-sparklines'; import { FormattedMessage } from 'react-intl'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import Permalink from './permalink'; import ShortNumber from 'mastodon/components/short_number'; import Skeleton from 'mastodon/components/skeleton'; import classNames from 'classnames'; class SilentErrorBoundary extends React.Component { static propTypes = { children: PropTypes.node, }; state = { error: false, }; componentDidCatch () { this.setState({ error: true }); } render () { if (this.state.error) { return null; } return this.props.children; } } /** * Used to render counter of how much people are talking about hashtag * * @type {(displayNumber: JSX.Element, pluralReady: number) => JSX.Element} */ export const accountsCountRenderer = (displayNumber, pluralReady) => ( <FormattedMessage id='trends.counter_by_accounts' defaultMessage='{count, plural, one {{counter} person} other {{counter} people}} talking' values={{ count: pluralReady, counter: <strong>{displayNumber}</strong>, }} /> ); export const ImmutableHashtag = ({ hashtag }) => ( <Hashtag name={hashtag.get('name')} href={hashtag.get('url')} to={`/tags/${hashtag.get('name')}`} people={hashtag.getIn(['history', 0, 'accounts']) * 1 + hashtag.getIn(['history', 1, 'accounts']) * 1} uses={hashtag.getIn(['history', 0, 'uses']) * 1 + hashtag.getIn(['history', 1, 'uses']) * 1} history={hashtag.get('history').reverse().map((day) => day.get('uses')).toArray()} /> ); ImmutableHashtag.propTypes = { hashtag: ImmutablePropTypes.map.isRequired, }; const Hashtag = ({ name, href, to, people, uses, history, className }) => ( <div className={classNames('trends__item', className)}> <div className='trends__item__name'> <Permalink href={href} to={to}> {name ? <React.Fragment>#<span>{name}</span></React.Fragment> : <Skeleton width={50} />} </Permalink> {typeof people !== 'undefined' ? <ShortNumber value={people} renderer={accountsCountRenderer} /> : <Skeleton width={100} />} </div> <div className='trends__item__current'> {typeof uses !== 'undefined' ? <ShortNumber value={uses} /> : <Skeleton width={42} height={36} />} </div> <div className='trends__item__sparkline'> <SilentErrorBoundary> <Sparklines width={50} height={28} data={history ? history : Array.from(Array(7)).map(() => 0)}> <SparklinesCurve style={{ fill: 'none' }} /> </Sparklines> </SilentErrorBoundary> </div> </div> ); Hashtag.propTypes = { name: PropTypes.string, href: PropTypes.string, to: PropTypes.string, people: PropTypes.number, uses: PropTypes.number, history: PropTypes.arrayOf(PropTypes.number), className: PropTypes.string, }; export default Hashtag;
index.ios.js
adriank/snooker
import React from 'react'; import { StyleSheet, Text, View, TouchableHighlight } from 'react-native' // import { Font } from 'expo'; import FontAwesome, { Icons } from 'react-native-fontawesome'; import Balls from './src/components/Balls' //import initial_state from './initialState.json' //import {start} from './src/reducers' export default class App extends React.Component { state = { fontsLoaded: false, } // async componentDidMount() { // await Font.loadAsync({ // 'FontAwesome': require('./assets/fonts/fontawesome-webfont.ttf'), // }); // this.props.fontsLoaded = true // } render() { // start(initial_state) return ( <View style={{ flex: 1 }}> <View style={{ flex:1, backgroundColor: 'green' }}> <Text style={{ color: 'white', fontSize:30}}>Adrians turn2</Text> <Text style={{ color: 'white', fontSize:20}}>Score: 0</Text> </View> <View style={{flex:8, backgroundColor: '#0a6c03'}} > <View style={{height:330}}> <Balls/> </View> <TouchableHighlight style={styles.button} onPress={ (a) => console.log("aaa") } > <Text style={styles.buttonText}>FOUL (-2 pts)</Text> </TouchableHighlight> </View> <View style={{flex:1, backgroundColor: 'white'}} > <TouchableHighlight style={[styles.button, styles.leadboard]} onPress={ (a) => console.log("aaa") } > <View> <Text style={styles.buttonText}>Leadboard</Text> <FontAwesome>{Icons.chevronLeft}</FontAwesome> </View> </TouchableHighlight> </View> </View> ); } } const styles = StyleSheet.create({ buttonText:{ // fontFamily:"FontAwesome", color: "black", fontSize: 16, textAlign: "center" }, button:{ backgroundColor:"white", }, leadboard: { // padding: 25 }, container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, });
src/components/RestaurantSearch.js
rgdelato/instantly-lunch
import React, { Component } from 'react'; export default class RestaurantSearch extends Component { render () { const { searchText, onSearch } = this.props; return ( <div className="restaurant-search"> <input type="text" placeholder="Search..." value={searchText} onChange={(e) => {onSearch(e.target.value)}} /> </div> ); } }
src/js/components/icons/base/AccessWheelchairActive.js
kylebyerly-hp/grommet
// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import CSSClassnames from '../../../utils/CSSClassnames'; import Intl from '../../../utils/Intl'; import Props from '../../../utils/Props'; const CLASS_ROOT = CSSClassnames.CONTROL_ICON; const COLOR_INDEX = CSSClassnames.COLOR_INDEX; export default class Icon extends Component { render () { const { className, colorIndex } = this.props; let { a11yTitle, size, responsive } = this.props; let { intl } = this.context; const classes = classnames( CLASS_ROOT, `${CLASS_ROOT}-access-wheelchair-active`, className, { [`${CLASS_ROOT}--${size}`]: size, [`${CLASS_ROOT}--responsive`]: responsive, [`${COLOR_INDEX}-${colorIndex}`]: colorIndex } ); a11yTitle = a11yTitle || Intl.getMessage(intl, 'access-wheelchair-active'); const restProps = Props.omit(this.props, Object.keys(Icon.propTypes)); return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fillRule="evenodd" d="M21.3413397,10.8818306 C21.6288833,11.1769441 21.7747145,11.5820803 21.7411696,11.992894 L21.140293,19.3655352 C21.0795856,20.1109072 20.4556283,20.6756415 19.7206834,20.6756415 C19.6818322,20.6756415 19.6426099,20.6741201 19.6033134,20.6709288 C18.8183851,20.6068447 18.2338727,19.9187662 18.2978826,19.133875 L18.7660268,13.391538 L16.8416111,13.4987407 C17.3169912,14.467164 17.5843485,15.5562228 17.5843485,16.7078443 C17.5843485,18.6408318 16.8309984,20.3966696 15.6034927,21.7015809 L13.7608612,19.8588381 C14.5182189,19.0258189 14.9805373,17.9198392 14.9805373,16.7078443 C14.9805373,14.1226609 12.8773391,12.0194256 10.2921928,12.0194256 C9.0801979,12.0194256 7.97414402,12.481744 7.14112481,13.2391759 L5.29838197,11.3964331 C6.33189131,10.4242619 7.64845425,9.74998724 9.11170191,9.51135093 L12.6404468,5.49245719 L10.6413343,4.33155889 L8.22313324,6.4886367 C7.63550385,7.01299834 6.7341332,6.96138224 6.20988288,6.37375285 C5.68566967,5.78604924 5.73713734,4.8847157 6.32480383,4.3605396 L9.5144633,1.51530903 C9.9745924,1.10490356 10.6464551,1.03666345 11.1796483,1.34639712 C11.1796483,1.34639712 17.7093255,5.13964207 17.7196784,5.1470264 C18.0567601,5.35764679 18.2761749,5.68730702 18.3556956,6.04962158 C18.5063878,6.57836187 18.3950292,7.17007305 18.0052553,7.61394921 L15.2692312,10.7300251 L20.240889,10.4532797 C20.6516656,10.4307928 21.0536477,10.586643 21.3413397,10.8818306 Z M18.7003471,4.7736539 C17.382003,4.7736539 16.3135016,3.70507827 16.3135016,2.3868455 C16.3135016,1.06868695 17.3820401,4.4408921e-16 18.7003471,4.4408921e-16 C20.0185057,4.4408921e-16 21.08697,1.06868695 21.08697,2.3868455 C21.08697,3.70507827 20.0185057,4.7736539 18.7003471,4.7736539 Z M5.60381122,16.7078072 C5.60381122,19.2929906 7.7070465,21.3962259 10.2922299,21.3962259 C11.266442,21.3962259 12.1720057,21.0971791 12.9225357,20.5866955 L14.7851308,22.4492165 C13.5466414,23.419792 11.9876943,24 10.2922299,24 C6.26480152,24 3,20.7352356 3,16.7078072 C3,15.012417 3.58020795,13.4533215 4.5507464,12.2147949 L6.41337869,14.0773901 C5.9027467,14.8279572 5.60381122,15.7335209 5.60381122,16.7078072 Z"/></svg>; } }; Icon.contextTypes = { intl: PropTypes.object }; Icon.defaultProps = { responsive: true }; Icon.displayName = 'AccessWheelchairActive'; Icon.icon = true; Icon.propTypes = { a11yTitle: PropTypes.string, colorIndex: PropTypes.string, size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']), responsive: PropTypes.bool };
es/catalog/properties/property-read-only.js
cvdlab/react-planner
import React from 'react'; import PropTypes from 'prop-types'; import { FormLabel } from '../../components/style/export'; import PropertyStyle from './shared-property-style'; export default function PropertyReadOnly(_ref) { var value = _ref.value, onUpdate = _ref.onUpdate, configs = _ref.configs, sourceElement = _ref.sourceElement, internalState = _ref.internalState, state = _ref.state; return React.createElement( 'table', { className: 'PropertyReadOnly', style: PropertyStyle.tableStyle }, React.createElement( 'tbody', null, React.createElement( 'tr', null, React.createElement( 'td', { style: PropertyStyle.firstTdStyle }, React.createElement( FormLabel, null, configs.label ) ), React.createElement( 'td', null, React.createElement( 'div', null, value ) ) ) ) ); } PropertyReadOnly.propTypes = { value: PropTypes.any.isRequired, onUpdate: PropTypes.func.isRequired, configs: PropTypes.object.isRequired, sourceElement: PropTypes.object, internalState: PropTypes.object, state: PropTypes.object.isRequired };
src/common/Socket/Hosting.js
Syncano/syncano-dashboard
import React from 'react'; import { colors as Colors } from 'material-ui/styles/'; import SocketWrapper from './SocketWrapper'; const HostingSocket = ({ tooltip = 'Create a Hosting Socket', iconStyle, ...other }) => ( <SocketWrapper {...other} tooltip={tooltip} iconClassName="synicon-socket-hosting" iconStyle={{ color: Colors.orange600, ...iconStyle }} /> ); export default HostingSocket;
src/decorators/withViewport.js
ryanherlihy/react-starter-kit
/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */ import React, { Component } from 'react'; // eslint-disable-line no-unused-vars import EventEmitter from 'eventemitter3'; import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment'; let EE; let viewport = {width: 1366, height: 768}; // Default size for server-side rendering const RESIZE_EVENT = 'resize'; function handleWindowResize() { if (viewport.width !== window.innerWidth || viewport.height !== window.innerHeight) { viewport = {width: window.innerWidth, height: window.innerHeight}; EE.emit(RESIZE_EVENT, viewport); } } function withViewport(ComposedComponent) { return class WithViewport extends Component { constructor() { super(); this.state = { viewport: canUseDOM ? {width: window.innerWidth, height: window.innerHeight} : viewport }; } componentDidMount() { if (!EE) { EE = new EventEmitter(); window.addEventListener('resize', handleWindowResize); window.addEventListener('orientationchange', handleWindowResize); } EE.on('resize', this.handleResize, this); } componentWillUnmount() { EE.removeListener(RESIZE_EVENT, this.handleResize, this); if (!EE.listeners(RESIZE_EVENT, true)) { window.removeEventListener('resize', handleWindowResize); window.removeEventListener('orientationchange', handleWindowResize); EE = null; } } render() { return <ComposedComponent {...this.props} viewport={this.state.viewport}/>; } handleResize(value) { this.setState({viewport: value}); } }; } export default withViewport;
app/javascript/mastodon/components/edited_timestamp/index.js
musashino205/mastodon
import React from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage, injectIntl } from 'react-intl'; import Icon from 'mastodon/components/icon'; import DropdownMenu from './containers/dropdown_menu_container'; import { connect } from 'react-redux'; import { openModal } from 'mastodon/actions/modal'; import RelativeTimestamp from 'mastodon/components/relative_timestamp'; import InlineAccount from 'mastodon/components/inline_account'; const mapDispatchToProps = (dispatch, { statusId }) => ({ onItemClick (index) { dispatch(openModal('COMPARE_HISTORY', { index, statusId })); }, }); export default @connect(null, mapDispatchToProps) @injectIntl class EditedTimestamp extends React.PureComponent { static propTypes = { statusId: PropTypes.string.isRequired, timestamp: PropTypes.string.isRequired, intl: PropTypes.object.isRequired, onItemClick: PropTypes.func.isRequired, }; handleItemClick = (item, i) => { const { onItemClick } = this.props; onItemClick(i); }; renderHeader = items => { return ( <FormattedMessage id='status.edited_x_times' defaultMessage='Edited {count, plural, one {{count} time} other {{count} times}}' values={{ count: items.size - 1 }} /> ); } renderItem = (item, index, { onClick, onKeyPress }) => { const formattedDate = <RelativeTimestamp timestamp={item.get('created_at')} short={false} />; const formattedName = <InlineAccount accountId={item.get('account')} />; const label = item.get('original') ? ( <FormattedMessage id='status.history.created' defaultMessage='{name} created {date}' values={{ name: formattedName, date: formattedDate }} /> ) : ( <FormattedMessage id='status.history.edited' defaultMessage='{name} edited {date}' values={{ name: formattedName, date: formattedDate }} /> ); return ( <li className='dropdown-menu__item edited-timestamp__history__item' key={item.get('created_at')}> <button data-index={index} onClick={onClick} onKeyPress={onKeyPress}>{label}</button> </li> ); } render () { const { timestamp, intl, statusId } = this.props; return ( <DropdownMenu statusId={statusId} renderItem={this.renderItem} scrollable renderHeader={this.renderHeader} onItemClick={this.handleItemClick}> <button className='dropdown-menu__text-button'> <FormattedMessage id='status.edited' defaultMessage='Edited {date}' values={{ date: intl.formatDate(timestamp, { hour12: false, month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }) }} /> <Icon id='caret-down' /> </button> </DropdownMenu> ); } }
components/route.js
ramprasath25/react-app
import React from 'react'; import {Router, Route, IndexRoute, browserHistory} from 'react-router'; import {connect} from 'react-redux'; //Components import Header from '../components/Header'; import Homepage from '../components/Homepage'; import Aboutpage from '../components/Aboutpage'; import Loginpage from '../components/Loginpage'; import Notfoundpage from '../components/Notfoundpage'; import DashTimeLine from '../components/dashboard/DashTimeLine'; import DashAbout from '../components/dashboard/DashAbout'; import DashFriends from '../components/dashboard/DashFriends'; import DashAccount from '../components/dashboard/DashAccount'; import store from '../src/store.js'; class App extends React.Component { componentDidMount() { window.IN.init({ api_key : '81yrfrfgcu5cku', authorize: true }); } render() { const requireAuth = (nextState, replace)=> { const islogin = ((this.props.loginStatus.loginDetails !== '') ? true : false); if(!islogin) { replace('/login'); } } const signIn = (nextState, replace)=> { const islogin = ((this.props.loginStatus.loginDetails !== '') ? true : false); if(islogin) { replace('/dashboard/timeline'); } } return( <Router history={browserHistory}> <Route path='/' component={Header}> <IndexRoute component={Homepage}/> <Route path="/about" component={Aboutpage}/> <Route path='/login' component={Loginpage} onEnter={signIn.bind(this)}/> <Route path="dashboard/timeline" component={DashTimeLine} onEnter={requireAuth.bind(this)}/> <Route path="dashboard/about" component={DashAbout} onEnter={requireAuth.bind(this)}/> <Route path="dashboard/friends" component={DashFriends} onEnter={requireAuth.bind(this)}/> <Route path="dashboard/account" component={DashAccount} onEnter={requireAuth.bind(this)} /> <Route path='*' component={Notfoundpage}/> </Route> </Router> ) } } const mapStateToProps = (state) => { return { loginStatus: state.loginDetails } } const mapDispatchToProps = (dispatch)=> { return { } } export default connect(mapStateToProps, mapDispatchToProps)(App);
app/components/UGHeader/index.js
perry-ugroop/ugroop-react-dup2
import React from 'react'; import CompanyLogo from '../../shareAssets/logo-ugroop.png'; import UGMenuBar from '../../containers/UGMenuBar'; import BSNavWrapper from '../../containers/BootStrap/BSNavWrapper'; import BSNavBar from '../../containers/BootStrap/BSNavBar'; import BSNavBrand from '../../containers/BootStrap/BSNavBrand'; import BSNavCollapse from '../../containers/BootStrap/BSNavCollapse'; import BSNavHeader from '../../containers/BootStrap/BSNavHeader'; function UGHeader() { return ( <BSNavWrapper> <BSNavHeader> <BSNavCollapse label="Toggle navigation" /> <BSNavBrand url="https://www.ugroop.com" alt="Company Logo" image={CompanyLogo} /> </BSNavHeader> <BSNavBar> <UGMenuBar /> </BSNavBar> </BSNavWrapper> ); } export default UGHeader;
src/containers/Dashboard/components/CodeEditor.js
aastein/crypto-trader
import React, { Component } from 'react'; import run from '../../../utils/scriptEnv'; import test from '../../../utils/scriptTestEnv'; export default class CodeEditor extends Component { // only render if script data changed shouldComponentUpdate(nextProps, nextState) { const scriptChanged = JSON.stringify(this.props.script) !== JSON.stringify(nextProps.script); return scriptChanged; } handleTextAreaChange = (event) => { const script = { ...this.props.script, script: event.target.value }; this.props.saveScript(script); } handleInputChange = (event) => { const name = event.target.value; this.props.saveScript({ ...this.props.script, name }); } runScript = (event) => { event.preventDefault(); run(this.props.scriptHeader, this.props.script.script, this.props.products, this.props.profile, this.props.appendLog, this.props.addOrder); } testScript = (event) => { event.preventDefault(); const result = test(this.props.scriptHeader, this.props.script.script, this.props.products, this.props.appendLog); this.props.saveTestResult(result); } deleteScript = (event) => { event.preventDefault(); this.props.deleteScript(this.props.script.id); } render() { return ( <div className="code-editor"> <form onSubmit={this.handleSave}> <div className="code-editor-header"> <span>Script Name:</span> <input className="name-input" type="input" value={this.props.script.name} onChange={this.handleInputChange} /> { this.props.script.id !== 0 && <button className="btn-delete" onClick={this.deleteScript}>Delete</button> } </div> <div className="textarea"> <textarea rows={'3'} cols={'30'} value={this.props.script.script} onChange={this.handleTextAreaChange} /> </div> { this.props.script.id !== 0 && <div className="action-buttons"> <button className="btn-run" onClick={this.runScript}>Run</button> <button className="btn-test" onClick={this.testScript}>Test</button> </div> } </form> </div> ); } }
client/components/ui/modal/cancel-and-submit-buttons.js
bnjbvr/kresus
import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { translate as $t } from '../../../helpers'; import { actions } from '../../../store'; const CancelAndSubmit = connect( null, dispatch => { return { handleCancel() { actions.hideModal(dispatch); } }; } )(props => { // Set the default label inside the component rather than with defaultProps because we need // the language to be set. let submitLabel = props.submitLabel || $t('client.general.save'); return ( <React.Fragment> <button type="button" className="btn" onClick={props.handleCancel}> {$t('client.general.cancel')} </button> <button className="btn success" type="submit" form={props.formId} disabled={props.isSubmitDisabled}> {submitLabel} </button> </React.Fragment> ); }); CancelAndSubmit.propTypes = { // An optional boolean telling whether the submit button is disabled. isSubmitDisabled: PropTypes.bool, // The label to be displayed on the submit button. submitLabel: PropTypes.string, // The form id the submit button relates to. formId: PropTypes.string.isRequired }; CancelAndSubmit.defaultProps = { isSubmitDisabled: false }; export default CancelAndSubmit;
src/svg-icons/action/payment.js
ArcanisCz/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionPayment = (props) => ( <SvgIcon {...props}> <path d="M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z"/> </SvgIcon> ); ActionPayment = pure(ActionPayment); ActionPayment.displayName = 'ActionPayment'; ActionPayment.muiName = 'SvgIcon'; export default ActionPayment;
Router/route-transition/src/App.js
imuntil/React
import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css' import AnimRouter from './router' class App extends Component { render() { return ( <div className="App"> <div className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <h2>Welcome to React</h2> </div> <AnimRouter /> </div> ) } } export default App;
components/svg/Language.js
dawnlabs/carbon
import React from 'react' export default () => ( <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> <path d="M8 0.6875H7.97539C6.02773 0.694531 4.19961 1.45742 2.82148 2.83555C1.44687 4.21719 0.6875 6.04883 0.6875 8C0.6875 9.95117 1.44688 11.7828 2.825 13.1645C4.19961 14.5426 6.03125 15.3055 7.97891 15.3125H8.00352C12.0359 15.3125 15.316 12.0324 15.316 8C15.316 3.96758 12.0324 0.6875 8 0.6875ZM14.3352 7.50781H11.607C11.5754 6.56914 11.4594 5.67266 11.2625 4.82891C11.8637 4.63555 12.4473 4.38945 13.0098 4.09063C13.7832 5.08203 14.2402 6.25625 14.3352 7.50781ZM7.50781 7.50781H5.33516C5.36328 6.64648 5.46875 5.83086 5.64453 5.07852C6.25625 5.21562 6.87852 5.3 7.50781 5.32812V7.50781ZM7.50781 8.49219V10.6684C6.88203 10.6965 6.25625 10.7809 5.64453 10.918C5.46875 10.1656 5.36328 9.35 5.33516 8.49219H7.50781ZM8.49219 8.49219H10.6473C10.6191 9.35 10.5137 10.1656 10.3379 10.9145C9.7332 10.7773 9.11445 10.6965 8.49219 10.6684V8.49219ZM8.49219 7.50781V5.32812C9.11797 5.3 9.73672 5.21562 10.3379 5.08203C10.5137 5.83437 10.6191 6.64648 10.6473 7.50781H8.49219ZM12.3383 3.36289C11.9059 3.57734 11.4594 3.76016 11.0023 3.90781C10.7527 3.15547 10.4363 2.50508 10.0707 1.9918C10.9145 2.28359 11.6844 2.75117 12.3383 3.36289ZM10.0742 4.16094C9.55742 4.27344 9.02656 4.34375 8.49219 4.37188V1.79141C9.08984 2.11484 9.67344 2.9832 10.0742 4.16094ZM7.50781 1.77734V4.36836C6.96641 4.34023 6.43203 4.26992 5.9082 4.15391C6.31602 2.96563 6.90664 2.09727 7.50781 1.77734ZM5.90469 2.00234C5.54258 2.51211 5.22969 3.15898 4.98008 3.9043C4.53008 3.75664 4.08711 3.57383 3.66172 3.36289C4.30859 2.75469 5.07148 2.29063 5.90469 2.00234ZM2.99023 4.09414C3.5457 4.38945 4.12578 4.63555 4.71992 4.82539C4.51953 5.66563 4.40352 6.56562 4.37539 7.5043H1.66836C1.75977 6.25977 2.2168 5.08555 2.99023 4.09414ZM1.66484 8.49219H4.37188C4.40352 9.43086 4.51953 10.3309 4.71641 11.1711C4.12227 11.3645 3.54219 11.6105 2.98672 11.9023C2.2168 10.9145 1.75977 9.74023 1.66484 8.49219ZM3.6582 12.6371C4.08359 12.4262 4.52656 12.2434 4.98008 12.0957C5.22969 12.8445 5.54258 13.4879 5.90469 14.0012C5.07148 13.7059 4.30859 13.2453 3.6582 12.6371ZM5.9082 11.8426C6.43203 11.7266 6.96992 11.6562 7.50781 11.6281V14.2227C6.90312 13.9027 6.31602 13.0309 5.9082 11.8426ZM8.49219 14.2086V11.6246C9.02656 11.6527 9.55742 11.723 10.0742 11.8355C9.67344 13.0168 9.08984 13.8852 8.49219 14.2086ZM10.0742 14.0082C10.4398 13.4949 10.7563 12.8445 11.0059 12.0922C11.4629 12.2398 11.9129 12.4262 12.3418 12.6406C11.6879 13.2488 10.9145 13.7164 10.0742 14.0082ZM13.0098 11.9059C12.4473 11.607 11.8637 11.3609 11.2625 11.1676C11.4594 10.3273 11.5754 9.43086 11.607 8.49219H14.3352C14.2402 9.74023 13.7867 10.9145 13.0098 11.9059Z" fill="white" /> </svg> )
src/svg-icons/notification/airline-seat-flat.js
rhaedes/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let NotificationAirlineSeatFlat = (props) => ( <SvgIcon {...props}> <path d="M22 11v2H9V7h9c2.21 0 4 1.79 4 4zM2 14v2h6v2h8v-2h6v-2H2zm5.14-1.9c1.16-1.19 1.14-3.08-.04-4.24-1.19-1.16-3.08-1.14-4.24.04-1.16 1.19-1.14 3.08.04 4.24 1.19 1.16 3.08 1.14 4.24-.04z"/> </SvgIcon> ); NotificationAirlineSeatFlat = pure(NotificationAirlineSeatFlat); NotificationAirlineSeatFlat.displayName = 'NotificationAirlineSeatFlat'; export default NotificationAirlineSeatFlat;
src/svg-icons/image/looks-two.js
verdan/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageLooksTwo = (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 8c0 1.11-.9 2-2 2h-2v2h4v2H9v-4c0-1.11.9-2 2-2h2V9H9V7h4c1.1 0 2 .89 2 2v2z"/> </SvgIcon> ); ImageLooksTwo = pure(ImageLooksTwo); ImageLooksTwo.displayName = 'ImageLooksTwo'; ImageLooksTwo.muiName = 'SvgIcon'; export default ImageLooksTwo;
client/src/components/dashboard/messaging/message-list.js
joshuaslate/mern-starter
import React, { Component } from 'react'; const moment = require('moment'); import MessageItem from './message-item'; class MessageList extends Component { render() { return ( <div className="messages"> {this.props.displayMessages.map(data => <MessageItem key={data._id} message={data.body} author={data.author} timestamp={moment(data.createdAt).from(moment())} />)} </div> ); } } export default MessageList;
app/components/RangePicker.js
7kfpun/AudienceNetworkReactNative
import React from 'react'; import { StyleSheet, Text, TouchableHighlight, TouchableOpacity, View, } from 'react-native'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import Icon from 'react-native-vector-icons/MaterialIcons'; import moment from 'moment-timezone'; import { getCompareToStartDate, getCompareToEndDate } from '../utils/compareToDate'; import * as dateRangeActions from '../actions/dateRange'; import tracker from '../utils/tracker'; moment.tz.setDefault('America/Los_Angeles'); const styles = StyleSheet.create({ container: { height: 50, flexDirection: 'row', alignItems: 'center', backgroundColor: '#FAFAFA', borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: '#E0E0E0', }, displayBlock: { flex: 6, flexDirection: 'row', padding: 10, alignItems: 'center', }, icon: { height: 40, width: 40, borderRadius: 20, justifyContent: 'center', alignItems: 'center', }, text: { fontSize: 14, }, compareToText: { fontSize: 12, color: '#424242', }, }); const RangePicker = (props) => { const { startDate, endDate, rangeType, isCompareTo, setPreviousDateRange, setNextDateRange, navigation } = props; let rangeShowAs; if (startDate && endDate) { let startYearShowAs = `, ${moment(startDate).year()}`; let endYearShowAs = `, ${moment(endDate).year()}`; if (moment(startDate).year() === moment().year() || moment(startDate).year() === moment(endDate).year()) { startYearShowAs = ''; } if (moment(endDate).year() === moment().year()) { endYearShowAs = ''; } if (moment(startDate).format('L') === moment(endDate).format('L')) { rangeShowAs = `${moment(endDate).format('ddd, MMM DD')}${endYearShowAs}`; } else { rangeShowAs = `${moment(startDate).format('MMM DD')}${startYearShowAs} - ${moment(endDate).format('MMM DD')}${endYearShowAs}`; } } let compareToRangeShowAs; if (isCompareTo) { const compareToStartDate = getCompareToStartDate(startDate, endDate, rangeType); const compareToEndDate = getCompareToEndDate(startDate, endDate, rangeType); let compareToStartYearShowAs = `, ${moment(startDate).year()}`; let compareToEndYearShowAs = `, ${moment(endDate).year()}`; if (moment(compareToStartDate).year() === moment().year() || moment(compareToStartDate).year() === moment(compareToEndDate).year()) { compareToStartYearShowAs = ''; } if (moment(compareToEndDate).year() === moment().year()) { compareToEndYearShowAs = ''; } if (moment(compareToStartDate).format('L') === moment(compareToEndDate).format('L')) { compareToRangeShowAs = `${moment(compareToEndDate).format('ddd, MMM DD')}${compareToEndYearShowAs}`; } else { compareToRangeShowAs = `${moment(compareToStartDate).format('MMM DD')}${compareToStartYearShowAs} - ${moment(compareToEndDate).format('MMM DD')}${compareToEndYearShowAs}`; } } return (<View style={styles.container}> <TouchableOpacity style={styles.displayBlock} onPress={() => { navigation.navigate('DateSettings'); tracker.logEvent('view-date-settings', { category: 'user-event', component: 'range-picker' }); }} > <View> <Text style={styles.text}>{rangeShowAs}</Text> {isCompareTo && <Text style={styles.compareToText}>vs. {compareToRangeShowAs}</Text>} </View> </TouchableOpacity> <TouchableHighlight underlayColor="#EEEEEE" style={styles.icon} onPress={() => { setPreviousDateRange(); tracker.logEvent('go-previous-date-range', { category: 'user-event', component: 'range-picker', value: rangeType }); }} > <Icon name="chevron-left" size={24} color="gray" /> </TouchableHighlight> <TouchableHighlight underlayColor="#EEEEEE" style={styles.icon} onPress={() => { setNextDateRange(); tracker.logEvent('go-next-date-range', { category: 'user-event', component: 'range-picker', value: rangeType }); }} > <Icon name="chevron-right" size={24} color="gray" /> </TouchableHighlight> <TouchableHighlight underlayColor="#EEEEEE" style={styles.icon} onPress={() => { navigation.navigate('DateSettings'); tracker.logEvent('view-date-settings', { category: 'user-event', component: 'range-picker' }); }} > <Icon name="tune" size={20} color="gray" /> </TouchableHighlight> </View>); }; RangePicker.defaultProps = { startDate: null, endDate: null, isCompareTo: false, }; RangePicker.propTypes = { startDate: React.PropTypes.object, endDate: React.PropTypes.object, rangeType: React.PropTypes.string.isRequired, isCompareTo: React.PropTypes.bool, setPreviousDateRange: React.PropTypes.func.isRequired, setNextDateRange: React.PropTypes.func.isRequired, navigation: React.PropTypes.object.isRequired, }; const mapStateToProps = state => ({ startDate: state.dateRange.startDate, endDate: state.dateRange.endDate, rangeType: state.dateRange.rangeType, isCompareTo: state.dateRange.isCompareTo, }); export default connect( mapStateToProps, dispatch => bindActionCreators(dateRangeActions, dispatch), )(RangePicker);
aaf-enrollment/src/components/ShowHidePassword.js
MicroFocus/CX
import PropTypes from 'prop-types'; import React from 'react'; import './ShowHidePassword.scss'; import TextField from './TextField'; import t from '../i18n/locale-keys'; export default class ShowHidePassword extends React.PureComponent { state = { passwordVisible: false }; showHidePassword = () => { this.setState({ passwordVisible: !this.state.passwordVisible }); }; render() { const {autoFocus, disabled, label, name, onChange, placeholder, value} = this.props; if (disabled) { return ( <TextField disabled id={this.props.id} label={label} placeholder={placeholder} value="*****" /> ); } const id = this.props.id || name; const {passwordVisible} = this.state; const labelElement = label ? <label htmlFor={id}>{label}</label> : null; const passwordInputType = passwordVisible ? 'text' : 'password'; const buttonStyle = passwordVisible ? {color: 'red'} : null; const buttonIcon = passwordVisible ? 'unlock_thick' : 'lock_thick'; return ( <div className="ias-input-container show-hide-password"> {labelElement} <input autoComplete="off" autoFocus={autoFocus} id={id} name={name} onChange={onChange} placeholder={placeholder} type={passwordInputType} value={value} /> <button className="ias-button ias-icon-button" disabled={!value} title={t.showHidePasswordLabel()} onClick={this.showHidePassword} style={buttonStyle} type="button" > <i className={'ias-icon ias-icon-' + buttonIcon} /> </button> </div> ); } } ShowHidePassword.defaultProps = { autoFocus: false, disabled: false, placeholder: '' }; ShowHidePassword.propTypes = { autoFocus: PropTypes.bool, disabled: PropTypes.bool, id: PropTypes.string, label: PropTypes.string, name: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, placeholder: PropTypes.string, value: PropTypes.string.isRequired };
router_homemade/with_universal_router/src/routes.js
Muzietto/react-playground
import React from 'react'; import HomePage from './pages/HomePage'; import TaskList from './pages/TaskList'; import TaskDetails from './pages/TaskDetails'; import ErrorPage from './pages/ErrorPage'; import Layout from './pages/TransitioningPageLayout'; const routes = { path: '', async action({ next }) { const page = await next(); if (typeof page !== 'undefined') { return ( <Layout> {page.component} </Layout> ); } }, children: [ {path: '/', action(context) { return {context, component: <HomePage>Gran Birillo</HomePage>} }}, {path: '/task', action(context) { return {context, component: <TaskList />} }}, {path: '/task/:id', action(context) { const {params:{id}} = context; return {context, component: <TaskDetails id={id}>GIOVE</TaskDetails>} }}, {path: '(.*)', action(context) { let code; try { code = context.error.code; } catch (e) { code = 400; } return {context, component: <ErrorPage status={code} />} }}, ] }; export default routes;
packages/material-ui-icons/src/PersonalVideo.js
cherniavskii/material-ui
import React from 'react'; import createSvgIcon from './utils/createSvgIcon'; export default createSvgIcon( <g><path d="M21 3H3c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2zm0 14H3V5h18v12z" /></g> , 'PersonalVideo');
app/javascript/mastodon/features/ui/components/column.js
codl/mastodon
import React from 'react'; import ColumnHeader from './column_header'; import PropTypes from 'prop-types'; import { debounce } from 'lodash'; import { scrollTop } from '../../../scroll'; import { isMobile } from '../../../is_mobile'; export default class Column extends React.PureComponent { static propTypes = { heading: PropTypes.string, icon: PropTypes.string, children: PropTypes.node, active: PropTypes.bool, hideHeadingOnMobile: PropTypes.bool, }; handleHeaderClick = () => { const scrollable = this.node.querySelector('.scrollable'); if (!scrollable) { return; } this._interruptScrollAnimation = scrollTop(scrollable); } scrollTop () { const scrollable = this.node.querySelector('.scrollable'); if (!scrollable) { return; } this._interruptScrollAnimation = scrollTop(scrollable); } handleScroll = debounce(() => { if (typeof this._interruptScrollAnimation !== 'undefined') { this._interruptScrollAnimation(); } }, 200) setRef = (c) => { this.node = c; } render () { const { heading, icon, children, active, hideHeadingOnMobile } = this.props; const showHeading = heading && (!hideHeadingOnMobile || (hideHeadingOnMobile && !isMobile(window.innerWidth))); const columnHeaderId = showHeading && heading.replace(/ /g, '-'); const header = showHeading && ( <ColumnHeader icon={icon} active={active} type={heading} onClick={this.handleHeaderClick} columnHeaderId={columnHeaderId} /> ); return ( <div ref={this.setRef} role='region' aria-labelledby={columnHeaderId} className='column' onScroll={this.handleScroll} > {header} {children} </div> ); } }
example/src/screens/types/Push.js
okarakose/react-native-navigation
import React from 'react'; import { StyleSheet, View, Text } from 'react-native'; class Push extends React.Component { render() { return ( <View style={styles.container}> <Text>Push Screen</Text> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: '#ffffff', }, }); export default Push;
src/svg-icons/maps/streetview.js
skarnecki/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsStreetview = (props) => ( <SvgIcon {...props}> <path d="M12.56 14.33c-.34.27-.56.7-.56 1.17V21h7c1.1 0 2-.9 2-2v-5.98c-.94-.33-1.95-.52-3-.52-2.03 0-3.93.7-5.44 1.83z"/><circle cx="18" cy="6" r="5"/><path d="M11.5 6c0-1.08.27-2.1.74-3H5c-1.1 0-2 .9-2 2v14c0 .55.23 1.05.59 1.41l9.82-9.82C12.23 9.42 11.5 7.8 11.5 6z"/> </SvgIcon> ); MapsStreetview = pure(MapsStreetview); MapsStreetview.displayName = 'MapsStreetview'; export default MapsStreetview;
node_modules/react-bootstrap/src/Grid.js
gitoneman/react-soc
import React from 'react'; import classSet from 'classnames'; const Grid = React.createClass({ propTypes: { fluid: React.PropTypes.bool, componentClass: React.PropTypes.node.isRequired }, getDefaultProps() { return { componentClass: 'div' }; }, render() { let ComponentClass = this.props.componentClass; let className = this.props.fluid ? 'container-fluid' : 'container'; return ( <ComponentClass {...this.props} className={classSet(this.props.className, className)}> {this.props.children} </ComponentClass> ); } }); export default Grid;
src/components/infoWindow.js
martinkwan/HNGRY
/** |========================================================================================== | The component that renders the InfoWindow on the map |------------------------------------------------------------------------------------------ */ import React from 'react'; import Price from './price'; import OpenClose from './openClose'; const InfoWindow = () => <table className="info-window"> <tbody id="info-content"> <tr className="info-window-table-row"> <td id="info-window-name" /> </tr> <tr className="info-window-table-row"> <td id="info-window-address" /> </tr> <tr className="info-window-table-row"> <td> <Price rating={-1} /> &nbsp; <OpenClose /> </td> </tr> </tbody> </table>; export default InfoWindow;
hello world/1.3 - jsx/src/js/index.js
wumouren/react-demo
import React from 'react'; import ReactDom from 'react-dom'; import Header from '../components/header'; import Main from '../components/main'; import Footer from '../components/footer'; class Index extends React.Component { render() { return ( <div> <Header></Header> <Main></Main> <Footer></Footer> </div> ) } } ReactDom.render( <Index/>, document.getElementById('app') )
app/static/src/performer/NewTestForm_modules/NewRecommendationForm.js
SnowBeaver/Vision
import React from 'react'; import FormControl from 'react-bootstrap/lib/FormControl'; import FormGroup from 'react-bootstrap/lib/FormGroup'; import ControlLabel from 'react-bootstrap/lib/ControlLabel'; import Button from 'react-bootstrap/lib/Button'; import Panel from 'react-bootstrap/lib/Panel'; import {findDOMNode} from 'react-dom'; import Modal from 'react-bootstrap/lib/Modal'; import HelpBlock from 'react-bootstrap/lib/HelpBlock'; import {NotificationContainer, NotificationManager} from 'react-notifications'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; import Tooltip from 'react-bootstrap/lib/Tooltip'; import Checkbox from 'react-bootstrap/lib/Checkbox'; import TestTypeSelectField from './TestTypeSelectField'; var items = []; const TextArea = React.createClass({ render: function () { let tooltip = <Tooltip id={this.props.label}>{this.props.label}</Tooltip>; var label = (this.props.label != null) ? this.props.label : ""; var name = (this.props.name != null) ? this.props.name : ""; var value = (this.props.value != null) ? this.props.value : ""; var error = this.props.errors[name]; return ( <OverlayTrigger overlay={tooltip} placement="top"> <FormGroup> <FormControl componentClass="textarea" placeholder={label} name={name} value={value} onChange={this.props.onChange} required={this.props.required} /> <HelpBlock className="warning">{error}</HelpBlock> <FormControl.Feedback /> </FormGroup> </OverlayTrigger> ); } }); const TextField = React.createClass({ _onChange: function (e) { this.props.onChange(e); }, render: function () { let tooltip = <Tooltip id={this.props.label}>{this.props.label}</Tooltip>; var label = (this.props.label != null) ? this.props.label : ""; var name = (this.props.name != null) ? this.props.name : ""; var type = (this.props["data-type"] != null) ? this.props["data-type"]: undefined; var len = (this.props["data-len"] != null) ? this.props["data-len"]: undefined; var validationState = (this.props.errors[name]) ? 'error' : null; var error = this.props.errors[name]; return ( <OverlayTrigger overlay={tooltip} placement="top"> <FormGroup validationState={validationState}> <FormControl type="text" placeholder={label} name={name} data-type={type} data-len={len} onChange={this._onChange} required={this.props.required} /> <HelpBlock className="warning">{error}</HelpBlock> <FormControl.Feedback /> </FormGroup> </OverlayTrigger> ); } }); var NewRecommendationForm = React.createClass({ getInitialState: function () { return { loading: false, errors: {}, equipment_number: '', fields: [ 'name', 'test_type_id', 'code', 'description' ], changedFields: [], public_recommendation: false } }, _create: function () { var fields = this.state.changedFields; var data = {}; for (var i = 0; i < fields.length; i++){ var key= fields[i]; var value = this.state[key]; if (value == ""){ value = null; } data[key] = value; } delete data["public_recommendation"]; // For showing/hiding fields only if (!this.state.public_recommendation) { this._createTestRecommendation(data, this); } else { var that = this; return $.authorizedAjax({ url: '/api/v1.0/recommendation/', type: 'POST', dataType: 'json', contentType: 'application/json', data: JSON.stringify(data), success: function (response, textStatus) { NotificationManager.success("Predefined recommendation has been successfully added"); that.props.onSuccess(response.result, data.test_type_id, "predefined"); }, beforeSend: function () { this.setState({loading: true}); }.bind(this) }) } }, _createTestRecommendation: function (data, that) { // Create test recommendation, do not save to all predefined recommendations data.recommendation_notes = data["description"]; data.test_result_id = this.props.testResultId; data.recommendation_id = this.props.recommendationId; ["code", "name", "description"].forEach(e => delete data[e]); return $.authorizedAjax({ url: '/api/v1.0/test_recommendation/', type: 'POST', dataType: 'json', contentType: 'application/json', data: JSON.stringify(data), success: function (response, textStatus) { NotificationManager.success("Test recommendation has been successfully added"); that.props.onSuccess(response.result, data.test_type_id, "test"); }, beforeSend: function () { this.setState({loading: true}); }.bind(this) }) }, _onSubmit: function (e) { e.preventDefault(); e.stopPropagation(); if (!this.is_valid()){ NotificationManager.error('Please correct the errors'); return false; } var xhr = this._create(); if (xhr){ xhr.done(this._onSuccess) .fail(this._onError) .always(this.hideLoading); } }, hideLoading: function () { this.setState({loading: false}); }, _onSuccess: function (data) { //this.refs.eqtype_form.getDOMNode().reset(); //this.setState(this.getInitialState()); }, _onError: function (data) { var message = "Failed to create"; var res = data.responseJSON; if (res.message) { message = data.responseJSON.message; } if (res.error) { // We get list of errors if (data.status >= 500) { message = res.error.join(". "); } else if (res.error instanceof Object){ // We get object of errors with field names as key for (var field in res.error) { var errorMessage = res.error[field]; if (Array.isArray(errorMessage)) { errorMessage = errorMessage.join(". "); } res.error[field] = errorMessage; } this.setState({ errors: res.error }); } else { message = res.error; } } NotificationManager.error(message); }, _onChange: function (e) { // Do not propagate changes to the parent form // as they are local for this form's state e.stopPropagation(); var state = {}; if (e.target.type == 'checkbox') { state[e.target.name] = e.target.checked; } else if (e.target.type == 'select-one') { state[e.target.name] = e.target.value; } else { state[e.target.name] = e.target.value; } state.changedFields = this.state.changedFields.concat([e.target.name]); var errors = this._validate(e); state = this._updateFieldErrors(e.target.name, state, errors); this.setState(state); }, _validate: function (e) { var errors = []; var error; error = this._validateFieldType(e.target.value, e.target.getAttribute("data-type")); if (error){ errors.push(error); } error = this._validateFieldLength(e.target.value, e.target.getAttribute("data-len")); if (error){ errors.push(error); } return errors; }, _validateFieldType: function (value, type){ var error = ""; if (type != undefined && value){ var typePatterns = { "float": /^(-|\+?)[0-9]+(\.)?[0-9]*$/, "int": /^(-|\+)?(0|[1-9]\d*)$/ }; if (!typePatterns[type].test(value)){ error = "Invalid " + type + " value"; } } return error; }, _validateFieldLength: function (value, length){ var error = ""; if (value && length){ if (value.length > length){ error = "Value should be maximum " + length + " characters long" } } return error; }, _updateFieldErrors: function (fieldName, state, errors){ // Clear existing errors related to the current field as it has been edited state.errors = this.state.errors; delete state.errors[fieldName]; // Update errors with new ones, if present if (Object.keys(errors).length){ state.errors[fieldName] = errors.join(". "); } return state; }, is_valid: function () { return (Object.keys(this.state.errors).length <= 0); }, _formGroupClass: function (field) { var className = "form-group "; if (field) { className += " has-error" } return className; }, handleClick: function() { document.getElementById('test_prof').remove(); }, render: function () { return ( <div className="form-container"> <form method="post" action="#" onSubmit={this._onSubmit} onChange={this._onChange}> <div className="row"> <div className="col-md-4"> <TestTypeSelectField selectedSubtests={this.props.selectedSubtests} testType={this.props.testType} value={this.state.test_type_id} name="test_type_id" handleChange={this._onChange} errors={this.state.errors} required/> </div> <div className="col-md-1"> <Checkbox checked={this.state.public_recommendation} name="public_recommendation">Public</Checkbox> </div> {this.state.public_recommendation ? <div className="col-md-4"> <TextField onChange={this._onChange} label="Name *" name="name" value={this.state.name} errors={this.state.errors} data-len="50" required/> </div> : null } {this.state.public_recommendation ? <div className="col-md-3"> <TextField onChange={this._onChange} label="Code" name="code" value={this.state.code} errors={this.state.errors} data-len="50"/> </div> : null } </div> <div className="row"> <div className="col-md-12"> <TextArea label="Recommendations" name='description' value={this.state.description} onChange={this._onChange} errors={this.state.errors}/> </div> </div> <div className="row"> <div className="col-md-12 "> <Button bsStyle="success" className="btn btn-success pull-right" type="submit" >Add {this.state.public_recommendation ? "Predefined" : "Test"} Recommendation</Button> &nbsp; <Button bsStyle="danger" className="pull-right" onClick={this.props.handleClose} className="pull-right margin-right-xs" >Cancel</Button> </div> </div> </form> </div> ); } }); export default NewRecommendationForm;
packages/bootstrap-shell/src/providers/Theme/with.js
TarikHuber/react-most-wanted
import Context from './Context' import React from 'react' const withContainer = (Component) => { const ChildComponent = (props) => { return ( <Context.Consumer> {(contextProps) => { return <Component {...contextProps} {...props} /> }} </Context.Consumer> ) } return ChildComponent } export default withContainer
src/spares/card/Card.js
korchemkin/spares-uikit
/** * * Spares-uikit * * @author Dmitri Korchemkin * @source https://github.com/korchemkin/spares-uikit */ import React, { Component } from 'react'; import './Card.css'; class Card extends Component { render() { return ( <div className="spares-card">{this.props.children}</div> ); } } export default Card;
examples/official-storybook/stories/addon-links/href.stories.js
kadirahq/react-storybook
import React from 'react'; import { hrefTo } from '@storybook/addon-links'; import { action } from '@storybook/addon-actions'; export default { title: 'Addons/Links/Href', }; export const Log = () => { hrefTo('Addons/Links/Href', 'log').then((href) => action('URL of this story')(href)); return <span>See action logger</span>; }; Log.parameters = { options: { panel: 'storybook/actions/panel', }, };
examples/mul-tag-suggest.js
ddcat1115/select
/* eslint no-console: 0 */ import React from 'react'; import Select, { Option } from 'rc-select'; import 'rc-select/assets/index.less'; import { fetch } from './common/tbFetchSuggest'; import ReactDOM from 'react-dom'; const Search = React.createClass({ getInitialState() { return { data: [], value: [], }; }, onChange(value) { console.log('onChange ', value); this.setState({ value, }); }, onSelect(value) { console.log('select ', value); }, fetchData(value) { fetch(value, (data) => { this.setState({ data, }); }); }, render() { const data = this.state.data; const options = data.map((d) => { return <Option key={d.value}><i>{d.text}</i></Option>; }); return (<div> <h2>multiple suggest</h2> <div> <Select style={{ width: 500 }} labelInValue optionLabelProp="children" value={this.state.value} onChange={this.onChange} tags placeholder="placeholder" notFoundContent="" onSearch={this.fetchData} onSelect={this.onSelect} filterOption={false} > {options} </Select> </div> </div>); }, }); ReactDOM.render(<Search />, document.getElementById('__react-content'));
packages/react-jsx-highstock/src/components/FlagSeries/FlagSeries.js
AlexMayants/react-jsx-highcharts
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Series from 'react-jsx-highcharts/src/components/Series'; class FlagSeries extends Component { static propTypes = { id: PropTypes.string.isRequired }; render () { return ( <Series {...this.props} type="flags" /> ); } } export default FlagSeries;
front/src/components/HeaderButtons.js
carlox18/proyecto2
import React from 'react'; import PropTypes from "prop-types"; import ListButton from './Buttons/ListButton.jsx'; import SortButton from './Buttons/SortButton.jsx'; import ShuffleButton from './Buttons/ShuffleButton.jsx'; import RefreshButton from './Buttons/RefreshButton.jsx'; const propTypes = { view: PropTypes.string, order: PropTypes.string, sortingMethod: PropTypes.string, listClickHandler: PropTypes.func, sortClickHandler: PropTypes.func, shuffleClickHandler: PropTypes.func, refreshClickHandlder: PropTypes.func, }; class HeaderButtons extends React.Component { render() { const { view, listClickHandler } = this.props; const { order, sortingMethod, sortClickHandler, shuffleClickHandler } = this.props; const { refreshClickHandlder } = this.props; return ( <header> <div className = "abs-right"> <SortButton clickHandler = {sortClickHandler} order = {order} active = {sortingMethod === 'chronological'} /> <ShuffleButton clickHandler = {shuffleClickHandler} active = {sortingMethod === 'shuffle'} /> <RefreshButton clickHandler = {refreshClickHandlder} /> </div> </header> ); } } HeaderButtons.propTypes = propTypes; export default HeaderButtons;
src/material-ui/index.js
Wildhoney/ReactShadow
import React from 'react'; import { jssPreset, StylesProvider } from '@material-ui/styles'; import { create } from 'jss'; import { createProxy } from '../'; export default createProxy({}, 'material-ui', ({ root, children }) => { class Main extends React.Component { constructor() { super(); this.state = { node: null }; this.handleRef = (node) => this.setState({ node }); } render() { const jss = create({ ...jssPreset(), insertionPoint: this.state.node, }); return ( <StylesProvider jss={jss}> {this.state.node && <>{children}</>} <div ref={this.handleRef} /> </StylesProvider> ); } } return <Main />; });
app/javascript/app/pages/custom-compare/custom-compare.js
Vizzuality/climate-watch
import React from 'react'; import { connect } from 'react-redux'; import { withRouter } from 'react-router-dom'; import qs from 'query-string'; import { getLocationParamUpdated } from 'utils/navigation'; import PropTypes from 'prop-types'; import Component from './custom-compare-component'; import { getAnchorLinks, getFiltersData, getSelectedTargets, getBackButtonLink, getDocumentsOptionsByCountry, getSelectedCountries, getCountriesDocumentsLoading } from './custom-compare-selectors'; const DEFAULT_DOCUMENT = 'NDC'; const mapStateToProps = (state, { location, route }) => { const search = qs.parse(location.search); const routeData = { location, route }; return { anchorLinks: getAnchorLinks(routeData, { search }), filtersData: getFiltersData(state, { search }), selectedTargets: getSelectedTargets(state, { search }), backButtonLink: getBackButtonLink(null, { search }), documentsByCountry: getDocumentsOptionsByCountry(state, { search }), selectedCountries: getSelectedCountries(state, { search }), accordionDataLoading: state.customCompareAccordion && state.customCompareAccordion.loading, documentsListLoading: getCountriesDocumentsLoading(state) }; }; const CustomCompare = props => { const { history } = props; const updateTargetParams = newTargets => { const params = { name: 'targets', value: newTargets.toString() }; history.replace(getLocationParamUpdated(location, params)); }; const handleCountryFilterChange = (targetKey, newCountry) => { const { selectedTargets, documentsByCountry } = props; const newTargetParams = []; const newCountryDocuments = documentsByCountry && documentsByCountry[newCountry] ? documentsByCountry[newCountry].map(({ value }) => value) : []; const defaultDocument = newCountryDocuments && newCountryDocuments.includes(DEFAULT_DOCUMENT) ? DEFAULT_DOCUMENT : newCountryDocuments[0]; selectedTargets.forEach(({ key, country, document }) => { if (key === targetKey) { newTargetParams.push(`${newCountry}-${defaultDocument || ''}`); } else if (country) newTargetParams.push(`${country}-${document}`); }); updateTargetParams(newTargetParams); }; const handleDocumentFilterChange = (targetKey, newDocument) => { const { selectedTargets } = props; const newTargetParams = []; selectedTargets.forEach(({ key, country, document = '' }) => { if (key === targetKey) newTargetParams.push(`${country}-${newDocument}`); else if (country) newTargetParams.push(`${country}-${document}`); }); updateTargetParams(newTargetParams); }; return ( <Component {...props} handleCountryFilterChange={handleCountryFilterChange} handleDocumentFilterChange={handleDocumentFilterChange} /> ); }; CustomCompare.propTypes = { history: PropTypes.object.isRequired }; export default withRouter(connect(mapStateToProps, null)(CustomCompare));
src/svg-icons/av/subscriptions.js
rhaedes/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let AvSubscriptions = (props) => ( <SvgIcon {...props}> <path d="M20 8H4V6h16v2zm-2-6H6v2h12V2zm4 10v8c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2v-8c0-1.1.9-2 2-2h16c1.1 0 2 .9 2 2zm-6 4l-6-3.27v6.53L16 16z"/> </SvgIcon> ); AvSubscriptions = pure(AvSubscriptions); AvSubscriptions.displayName = 'AvSubscriptions'; export default AvSubscriptions;
src/components/List.js
SaraChicaD/TacoRadarReact
import React from 'react'; import Button from 'react-bootstrap/lib/Button'; import Grid from 'react-bootstrap/lib/Grid'; import Jumbotron from 'react-bootstrap/lib/Jumbotron'; import Row from 'react-bootstrap/lib/Row'; import Col from 'react-bootstrap/lib/Col'; //this is where the results we generate will go
src/svg-icons/editor/strikethrough-s.js
lawrence-yu/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let EditorStrikethroughS = (props) => ( <SvgIcon {...props}> <path d="M7.24 8.75c-.26-.48-.39-1.03-.39-1.67 0-.61.13-1.16.4-1.67.26-.5.63-.93 1.11-1.29.48-.35 1.05-.63 1.7-.83.66-.19 1.39-.29 2.18-.29.81 0 1.54.11 2.21.34.66.22 1.23.54 1.69.94.47.4.83.88 1.08 1.43.25.55.38 1.15.38 1.81h-3.01c0-.31-.05-.59-.15-.85-.09-.27-.24-.49-.44-.68-.2-.19-.45-.33-.75-.44-.3-.1-.66-.16-1.06-.16-.39 0-.74.04-1.03.13-.29.09-.53.21-.72.36-.19.16-.34.34-.44.55-.1.21-.15.43-.15.66 0 .48.25.88.74 1.21.38.25.77.48 1.41.7H7.39c-.05-.08-.11-.17-.15-.25zM21 12v-2H3v2h9.62c.18.07.4.14.55.2.37.17.66.34.87.51.21.17.35.36.43.57.07.2.11.43.11.69 0 .23-.05.45-.14.66-.09.2-.23.38-.42.53-.19.15-.42.26-.71.35-.29.08-.63.13-1.01.13-.43 0-.83-.04-1.18-.13s-.66-.23-.91-.42c-.25-.19-.45-.44-.59-.75-.14-.31-.25-.76-.25-1.21H6.4c0 .55.08 1.13.24 1.58.16.45.37.85.65 1.21.28.35.6.66.98.92.37.26.78.48 1.22.65.44.17.9.3 1.38.39.48.08.96.13 1.44.13.8 0 1.53-.09 2.18-.28s1.21-.45 1.67-.79c.46-.34.82-.77 1.07-1.27s.38-1.07.38-1.71c0-.6-.1-1.14-.31-1.61-.05-.11-.11-.23-.17-.33H21z"/> </SvgIcon> ); EditorStrikethroughS = pure(EditorStrikethroughS); EditorStrikethroughS.displayName = 'EditorStrikethroughS'; EditorStrikethroughS.muiName = 'SvgIcon'; export default EditorStrikethroughS;
js/auth/NewPasswordForm.js
BarberHour/barber-hour
import React, { Component } from 'react'; import { View, Text, StyleSheet, StatusBar, TextInput, Platform } from 'react-native'; import { connect } from 'react-redux'; import t from 'tcomb-form-native'; const Form = t.form.Form; import Button from '../common/Button'; import Toolbar from '../common/Toolbar'; import Login from './Login'; import { newPassword } from '../actions/resetPassword'; class NewPasswordForm extends Component { _newPassword() { let value = this.refs.form.getValue(); // if are any validation errors, value will be null if (value !== null) { this.props.dispatch(newPassword(value, this.props.token)); } } componentDidUpdate() { if (this.props.form.success) { const route = { component: Login, passProps: { skipDeepLinking: true } }; Platform.OS === 'ios' ? this.props.navigator.replace(route) : this.props.navigator.resetTo(route); } } getFormValue() { return { password: this.props.form.password, password_confirmation: this.props.form.password_confirmation }; } render() { const NewPassword = t.struct({ password: t.String, password_confirmation: t.String }); const buttonLabel = this.props.form.isLoading ? 'Alterando...' : 'Alterar'; return( <View style={styles.container}> <StatusBar backgroundColor='#C5C5C5' networkActivityIndicatorVisible={this.props.form.isLoading} /> <Toolbar backIcon navigator={this.props.navigator} /> <View style={styles.innerContainer}> <Text style={styles.title}>Nova senha</Text> <Form ref='form' type={NewPassword} options={this.props.form} value={this.getFormValue()} /> <Button containerStyle={styles.button} text={buttonLabel} onPress={this._newPassword.bind(this)} disabled={this.props.form.isLoading} /> </View> </View> ); } } function select(store) { return { form: store.newPassword }; } export default connect(select)(NewPasswordForm); var styles = StyleSheet.create({ container: { flex: 1, flexDirection: 'column', backgroundColor: 'white', marginTop: Platform.OS === 'ios' ? 55 : 0 }, innerContainer: { padding: 20, }, title: { fontSize: 24, textAlign: 'center' }, button: { marginTop: 20 }, });
pootle/static/js/shared/components/Tab.js
unho/pootle
/* * Copyright (C) Pootle contributors. * * This file is a part of the Pootle project. It is distributed under the GPL3 * or later license. See the LICENSE file for a copy of the license and the * AUTHORS file for copyright and authorship information. */ import cx from 'classnames'; import React from 'react'; import { PureRenderMixin } from 'react-addons-pure-render-mixin'; const Tab = React.createClass({ propTypes: { onClick: React.PropTypes.func, // Required but added dynamically tabIndex: React.PropTypes.number, // Required but added dynamically title: React.PropTypes.string.isRequired, selected: React.PropTypes.bool, }, mixins: [PureRenderMixin], render() { const classes = cx({ TabList__Tab: true, 'TabList__Tab--is-active': this.props.selected, }); const style = { display: 'inline-block', cursor: this.props.selected ? 'default' : 'pointer', }; const props = { style, className: classes, }; if (!this.props.selected) { props.onClick = this.props.onClick.bind(null, this.props.tabIndex); } return ( <li {...props}> {this.props.title} </li> ); }, }); export default Tab;
src/components/ErrorBoundary.js
golemfactory/golem-electron
import React, { Component } from 'react'; import Lottie from 'react-lottie'; const { clipboard, remote } = window.electron; import animData from './../assets/anims/error.json' const defaultOptions = { loop: false, autoplay: true, animationData: animData, rendererSettings: { preserveAspectRatio: 'xMidYMid slice' } }; export default class ErrorBoundary extends Component { constructor(props) { super(props); this.state = { error: null, errorInfo: null }; } componentDidCatch(error, errorInfo){ this.catchError(error, errorInfo) } _copyLogs = () => { const logTemplate = ` Electron: ${remote.app.getVersion()} ${this.state.error.toString()} ${this.state.errorInfo.componentStack} ` clipboard.writeText(logTemplate); } catchError = (error, errorInfo) => { this.setState({ error, errorInfo }) } handleError = () => { return ( <div className="error-boundary"> <div className="animContainer"> <Lottie options={defaultOptions}/> </div> <div className="error-boundary__content"> <h2>Something went wrong.</h2> <div className="snippet"> {this.state.error && this.state.error.toString()} <br /> {this.state.errorInfo.componentStack} </div> <div> <span>Please copy the log and let us know about the issue.</span> </div> </div> <div className="action-bar"> <span className="action-bar__element" onClick={this._copyLogs}> <span className="icon-logs"/> <u>copy log</u> </span> <a className="action-bar__element" href="https://chat.golem.network"> <span className="icon-chat"/> <u>golem chat</u> </a> </div> </div> ) } render() { if (this.state.errorInfo) return this.handleError() return this.props.children; } }
admin/src/components/AltText.js
wustxing/keystone
import React from 'react'; import blacklist from 'blacklist'; import vkey from 'vkey'; var AltText = React.createClass({ getDefaultProps () { return { component: 'span', modifier: '<alt>', normal: '', modified: '' }; }, getInitialState () { return { modified: false }; }, componentDidMount () { document.body.addEventListener('keydown', this.handleKeyDown, false); document.body.addEventListener('keyup', this.handleKeyUp, false); }, componentWillUnmount () { document.body.removeEventListener('keydown', this.handleKeyDown); document.body.removeEventListener('keyup', this.handleKeyUp); }, handleKeyDown (e) { if (vkey[e.keyCode] !== this.props.modifier) return; this.setState({ modified: true }); }, handleKeyUp (e) { if (vkey[e.keyCode] !== this.props.modifier) return; this.setState({ modified: false }); }, render () { var props = blacklist(this.props, 'component', 'modifier', 'normal', 'modified'); return React.createElement(this.props.component, props, this.state.modified ? this.props.modified : this.props.normal); } }); module.exports = AltText;
src/components/AlertMessageComponent.js
derickwarshaw/react-native-jenkins
import React from 'react'; import * as Animatable from 'react-native-animatable'; import { View, Text, StyleSheet } from 'react-native'; import { applicationStyles, metrics, fonts, colors } from '../themes'; import Icon from 'react-native-vector-icons/Ionicons'; const styles = StyleSheet.create({ container: { justifyContent: 'center', marginVertical: metrics.section }, contentContainer: { alignSelf: 'center', alignItems: 'center' }, message: { marginTop: metrics.baseMargin, marginHorizontal: metrics.baseMargin, textAlign: 'center', fontFamily: fonts.base, fontSize: fonts.size.regular, fontWeight: 'bold', color: colors.steel }, icon: { color: colors.steel } }); const AlertMessageComponent = (props) => { const { title } = props; const messageComponent = ( <Animatable.View style={[styles.container, props.style]} delay={800} animation='bounceIn' > <View style={styles.contentContainer}> <Icon name={props.icon || 'ios-alert'} size={metrics.icons.large} style={styles.icon} /> <Text allowFontScaling={false} style={styles.message}>{title && title.toUpperCase()}</Text> </View> </Animatable.View> ); return props.show ? messageComponent : null; }; AlertMessageComponent.defaultProps = { show: true }; AlertMessageComponent.PropTypes = { title: React.PropTypes.string.isRequired, style: React.PropTypes.object, icon: React.PropTypes.string, show: React.PropTypes.bool }; export default AlertMessageComponent;
blueocean-material-icons/src/js/components/svg-icons/action/shopping-basket.js
jenkinsci/blueocean-plugin
import React from 'react'; import SvgIcon from '../../SvgIcon'; const ActionShoppingBasket = (props) => ( <SvgIcon {...props}> <path d="M17.21 9l-4.38-6.56c-.19-.28-.51-.42-.83-.42-.32 0-.64.14-.83.43L6.79 9H2c-.55 0-1 .45-1 1 0 .09.01.18.04.27l2.54 9.27c.23.84 1 1.46 1.92 1.46h13c.92 0 1.69-.62 1.93-1.46l2.54-9.27L23 10c0-.55-.45-1-1-1h-4.79zM9 9l3-4.4L15 9H9zm3 8c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"/> </SvgIcon> ); ActionShoppingBasket.displayName = 'ActionShoppingBasket'; ActionShoppingBasket.muiName = 'SvgIcon'; export default ActionShoppingBasket;
frontend/Categories/Container.js
fdemian/Morpheus
import React from 'react'; import { connect } from 'react-redux'; import Categories from './Categories'; import loadCategories, {createCategory, deleteCategory} from './Actions'; const mapStateToProps = (state) => { return { categories: state.categories.items, isFetching: state.categories.isFetching, error: state.categories.error, isLoggedIn: state.session.loggedIn } } const mapDispatchToProps = (dispatch, ownProps) => { return { onLoad: () => { dispatch(loadCategories()); }, onCreate: (name) => { dispatch(createCategory(name)); }, onDelete: (id) => { dispatch(deleteCategory(id)); } } } const Container = connect( mapStateToProps, mapDispatchToProps )(Categories) export default Container;
frontend/src/components/projeto.js
dataprev/cidadao360
import React, { Component } from 'react'; import { Jumbotron, Button } from 'reactstrap'; import { Link } from 'react-router-dom'; import logo from '../images/logo.svg'; class Project extends Component { componentDidMount() { document.body.classList.toggle('background-bsb'); document.getElementById("mainNavbar").classList.toggle("navbar-transparent"); } componentWillUnmount() { document.body.classList.toggle('background-bsb'); document.getElementById("mainNavbar").classList.toggle("navbar-transparent"); } render() { let isAuthenticated = localStorage.getItem('authenticated'); if (!isAuthenticated) { return ( <div> <Jumbotron className="jumbotron-transparent center-text"> {/* <h1 className="display-3">Cidadรฃo 360ยบ</h1> */} <img src={logo} /> <br /> <br /> <p className="lead">Acesse suas informaรงรตes governamentais de maneira fรกcil e unificada.</p> <hr className="my-2" /> <p>O aplicativo Cidadรฃo 360ยบ permite ao cidadรฃo brasileiro acessar informaรงรตes dos mais diversos contextos, agregadas de maneira simples e organizada.</p> <p className="lead"> <Link to="/login" className="btn btn-primary">Acessar com o Cidadรฃo BR</Link> </p> </Jumbotron> </div> ); } else { return ( <div> <Jumbotron className="jumbotron-transparent center-text"> {/* <h1 className="display-3">Cidadรฃo 360ยบ</h1> */} <img src={logo} /> <br /> <br /> <p className="lead">Acesse suas informaรงรตes governamentais de maneira fรกcil e unificada.</p> <hr className="my-2" /> <p>O aplicativo Cidadรฃo 360ยบ permite ao cidadรฃo brasileiro acessar informaรงรตes dos mais diversos contextos, agregadas de maneira simples e organizada.</p> <p className="lead"> <Link to="/context" className="btn btn-primary">Acessar o dashboard</Link> </p> </Jumbotron> </div> ); } } } export default Project;
app/components/eventDetails.js
misakimatsumoto2524/merj
import React from 'react' import moment from 'moment'; import Paper from 'material-ui/Paper'; let styles = { root: { float: 'left', marginBottom: 24, marginRight: 24, width: 300, border: 'solid 1px #d9d9d9', height: 150, overflow: 'hidden', background: '#f2f2f2', padding: 15, } }; let EventDetails = (props) => { return ( <Paper id="eventDetails" style={styles.root} zDepth={1}> <div style={styles.container}> <h3>{props.activeEvent.title}</h3> <div>{moment(props.activeEvent.date) .format('MMMM DD, YYYY')}</div> <div>{props.activeEvent.time}</div> <br /> <div>{props.activeEvent.location}</div> </div> </Paper> ); } export { EventDetails }
clients/packages/admin-client/src/pages/admin/communities/settings/domain/page.connected.js
nossas/bonde-client
// // @route /community/domain // import React from 'react'; import urljoin from 'url-join'; export default class extends React.Component { componentDidMount() { window.location.href = urljoin(process.env.REACT_APP_DOMAIN_ADMIN_CANARY || "", '/community/domains'); } render() { return ( <p>Redirecionando para admin-canary</p> ); } }
stories/index.js
panacholn/pagination
import React from 'react'; import { storiesOf } from '@kadira/storybook'; import { MemoryRouter } from 'react-router'; import Pagination from '../src/index'; const genUrl = (page) => `/${page}`; storiesOf('Pagination', module) .addDecorator(story => ( <MemoryRouter initialEntries={['/']}>{story()}</MemoryRouter> )) .add('default', () => ( <Pagination pageCount={15} pageRangeDisplayed={5} page={8} genUrl={genUrl} /> )) .add('first page', () => ( <Pagination pageCount={15} pageRangeDisplayed={5} page={1} genUrl={genUrl} /> )) .add('second page', () => ( <Pagination pageCount={15} pageRangeDisplayed={5} page={2} genUrl={genUrl} /> )) .add('before last page', () => ( <Pagination pageCount={15} pageRangeDisplayed={5} page={14} genUrl={genUrl} /> )) .add('last page', () => ( <Pagination pageCount={15} pageRangeDisplayed={5} page={15} genUrl={genUrl} /> ));
src/components/common/sectionheader.js
liuyuanquan/kankan
import React from 'react'; class SectionHeader extends React.Component { render() { return ( <div className='sectionheader'> { this.props.header.map((item, index, arr) => { return item.show ? <div className={index === 0 ? 'leftarea' : 'rightarea'} key={index}> <h2> <a href='javascript:;'> {item.title} </a> </h2> <div className='subtitle'> { item.subtitle.map((item, index, arr) => { return <span key={index}> <a href='javascript:;'>{item}</a> { index !== arr.length - 1 ? '|' : '' } </span> }) } { item.more ? <span className='more'><a href='javascript:;'>ๆ›ดๅคš></a></span> : null} </div> </div> : null }) } </div> ) } } export default SectionHeader;
web/src/client/pages/movie.react.js
neozhangthe1/framedrop-web
/** * Created by yutao on 15/10/20. */ import './discover.styl'; import DocumentTitle from 'react-document-title'; import Component from 'react-pure-render/component'; import DynamicScripts from '../../server/lib/dynamicscript.js' import React from 'react'; import {FormattedHTMLMessage} from 'react-intl'; import {Link} from 'react-router'; import Header from '../app/header.react.js' import FrameList from '../movie/frameList.react.js' import PoiList from '../movie/poiList.react.js' import Wizard from '../wizard/wizard.react.js'; import ReactDOM from 'react-dom' import ReactTabs from '../lib/react-tabs' let Tab = ReactTabs.Tab; let Tabs = ReactTabs.Tabs; let TabList = ReactTabs.TabList; let TabPanel = ReactTabs.TabPanel; export default class Movie extends Component { static propTypes = { actions: React.PropTypes.object.isRequired, discover: React.PropTypes.object.isRequired, msg: React.PropTypes.object.isRequired } componentDidMount() { } render() { const {actions, source: {pois, frames, offset}, msg: {discover: msg}, users: {viewer}} = this.props; let id = this.props.params.id; return ( <DocumentTitle title={msg.title}> <div className="wrapper header-fixed header-fixed-space"> <div className="header-v6 header-classic-white header-sticky"> <Header tab={"discover"} {...{viewer}} /> </div> <div className="content-xs"> <div className="discover-nav"> <Tabs > <TabList> <Tab> <a href="#home-1" data-toggle="tab" className="push"> <i className="icon-tag"> </i> ๆ ‡่ฎฐ </a> </Tab> <Tab> <a href="#home-1" data-toggle="tab" className="push"> <i className="icon-photo"> </i> ๅ›พ็‰‡ </a> </Tab> <Tab> <a href="#home-1" data-toggle="tab" className="push"> <i className="icon-layers"> </i> ้˜Ÿๅˆ— </a> </Tab> <Tab> <a href="#home-1" data-toggle="tab" className="push"> <i className="icon-star"> </i> ๆ”ถ่— </a> </Tab> </TabList> <TabPanel> <div className="frame-items-waterfall"> <PoiList {...{id, actions, pois, offset}}/> </div> </TabPanel> <TabPanel> <div className="frame-items-waterfall"> <FrameList {...{id, actions, frames, offset}} /> </div> </TabPanel> <TabPanel> <h2>Hello from Baz</h2> </TabPanel> <TabPanel> <h2>Hello aafrom Baz</h2> </TabPanel> </Tabs> </div> <Wizard /> </div> </div> </DocumentTitle> ); } }
src/backward/Widgets/Button.js
sampsasaarela/NativeBase
/* @flow */ import React, { Component } from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import { connectStyle } from 'native-base-shoutem-theme'; import _ from 'lodash'; import variables from '../../theme/variables/platform'; import { Icon } from './Icon'; import mapPropsToStyleNames from '../../Utils/mapPropsToStyleNames'; import computeProps from '../../Utils/computeProps'; import { Text } from './Text'; class Button extends Component { getInitialStyle() { return { borderedBtn: { borderWidth: (this.props.bordered) ? 1 : undefined, borderRadius: (this.props.rounded && this.props.bordered) ? variables.borderRadiusLarge : 2, }, }; } iconPresent() { let iconComponentPresent = false; React.Children.forEach(this.props.children, (child) => { if (child.type === Icon) { iconComponentPresent = true; } }); return iconComponentPresent; } prepareRootProps() { const defaultProps = { style: this.getInitialStyle().borderedBtn, }; return computeProps(this.props, defaultProps); } renderChildren() { if (typeof this.props.children === 'string') { return <Text style={this.props.textStyle}>{(Platform.OS === 'ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text>; } else if (this.props.children.type === Icon) { return React.cloneElement(this.props.children); } else if (Array.isArray(this.props.children)) { const newChildren = []; const childrenArray = React.Children.toArray(this.props.children); let iconElement = []; iconElement = _.remove(childrenArray, (item) => { if (item.type === Icon) { return true; } return null; }); if (this.props.iconRight) { if (childrenArray[0].type === undefined) { newChildren.push(<Text key="label">{(Platform.OS === 'ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key="label">{(Platform.OS === 'ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(React.cloneElement(iconElement[0])); } else if (this.props.iconLeft || iconElement.length > 0) { newChildren.push(React.cloneElement(iconElement[0])); if (childrenArray[0].type === undefined) { newChildren.push(<Text key="label">{(Platform.OS === 'ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key="label">{(Platform.OS === 'ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text>{this.props.children}</Text>; } return newChildren; } return React.cloneElement(this.props.children); } render() { return ( <TouchableOpacity ref={(c) => { this._root = c; }} {...this.prepareRootProps()} activeOpacity={0.5} > {this.renderChildren()} </TouchableOpacity> ); } } Button.propTypes = { ...TouchableOpacity.propTypes, style: React.PropTypes.object, textStyle: React.PropTypes.object, block: React.PropTypes.bool, primary: React.PropTypes.bool, transparent: React.PropTypes.bool, success: React.PropTypes.bool, danger: React.PropTypes.bool, warning: React.PropTypes.bool, info: React.PropTypes.bool, bordered: React.PropTypes.bool, disabled: React.PropTypes.bool, rounded: React.PropTypes.bool, large: React.PropTypes.bool, small: React.PropTypes.bool, inputButton: React.PropTypes.bool, tabButton: React.PropTypes.bool, }; const StyledButton = connectStyle('NativeBase.Button', {}, mapPropsToStyleNames)(Button); export { StyledButton as Button, };
src/svg-icons/maps/tram.js
owencm/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsTram = (props) => ( <SvgIcon {...props}> <path d="M19 16.94V8.5c0-2.79-2.61-3.4-6.01-3.49l.76-1.51H17V2H7v1.5h4.75l-.76 1.52C7.86 5.11 5 5.73 5 8.5v8.44c0 1.45 1.19 2.66 2.59 2.97L6 21.5v.5h2.23l2-2H14l2 2h2v-.5L16.5 20h-.08c1.69 0 2.58-1.37 2.58-3.06zm-7 1.56c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5-4.5H7V9h10v5z"/> </SvgIcon> ); MapsTram = pure(MapsTram); MapsTram.displayName = 'MapsTram'; MapsTram.muiName = 'SvgIcon'; export default MapsTram;
frontend/src/Activity/History/Details/HistoryDetailsModal.js
Radarr/Radarr
import PropTypes from 'prop-types'; import React from 'react'; import Button from 'Components/Link/Button'; import SpinnerButton from 'Components/Link/SpinnerButton'; import Modal from 'Components/Modal/Modal'; 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 { kinds } from 'Helpers/Props'; import translate from 'Utilities/String/translate'; import HistoryDetails from './HistoryDetails'; import styles from './HistoryDetailsModal.css'; function getHeaderTitle(eventType) { switch (eventType) { case 'grabbed': return 'Grabbed'; case 'downloadFailed': return 'Download Failed'; case 'downloadFolderImported': return 'Movie Imported'; case 'movieFileDeleted': return 'Movie File Deleted'; case 'movieFileRenamed': return 'Movie File Renamed'; case 'downloadIgnored': return 'Download Ignored'; default: return 'Unknown'; } } function HistoryDetailsModal(props) { const { isOpen, eventType, sourceTitle, data, isMarkingAsFailed, shortDateFormat, timeFormat, onMarkAsFailedPress, onModalClose } = props; return ( <Modal isOpen={isOpen} onModalClose={onModalClose} > <ModalContent onModalClose={onModalClose}> <ModalHeader> {getHeaderTitle(eventType)} </ModalHeader> <ModalBody> <HistoryDetails eventType={eventType} sourceTitle={sourceTitle} data={data} shortDateFormat={shortDateFormat} timeFormat={timeFormat} /> </ModalBody> <ModalFooter> { eventType === 'grabbed' && <SpinnerButton className={styles.markAsFailedButton} kind={kinds.DANGER} isSpinning={isMarkingAsFailed} onPress={onMarkAsFailedPress} > Mark as Failed </SpinnerButton> } <Button onPress={onModalClose} > {translate('Close')} </Button> </ModalFooter> </ModalContent> </Modal> ); } HistoryDetailsModal.propTypes = { isOpen: PropTypes.bool.isRequired, eventType: PropTypes.string.isRequired, sourceTitle: PropTypes.string.isRequired, data: PropTypes.object.isRequired, isMarkingAsFailed: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, onMarkAsFailedPress: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired }; HistoryDetailsModal.defaultProps = { isMarkingAsFailed: false }; export default HistoryDetailsModal;
js/app.js
batter/react-weather-widget
import React from 'react'; import Weather from './components/weather'; window.React = React; React.render(<Weather />, document.getElementById('application'));
src/parser/druid/feral/CHANGELOG.js
FaideWW/WoWAnalyzer
import React from 'react'; import { Anatta336 } from 'CONTRIBUTORS'; import SPELLS from 'common/SPELLS'; import SpellLink from 'common/SpellLink'; export default [ { date: new Date('2018-10-10'), changes: <>Added tracking to Feral for the <SpellLink id={SPELLS.WILD_FLESHRENDING.id} /> Azerite trait.</>, contributors: [Anatta336], }, { date: new Date('2018-10-05'), changes: <React.Fragment>Added tracking for using <SpellLink id={SPELLS.SHADOWMELD.id} /> to buff <SpellLink id={SPELLS.RAKE.id} /> damage.</React.Fragment>, contributors: [Anatta336], }, { date: new Date('2018-08-11'), changes: <>Added tracking for wasted energy from <SpellLink id={SPELLS.TIGERS_FURY.id} /> and a breakdown of how energy is spent.</>, contributors: [Anatta336], }, { date: new Date('2018-08-05'), changes: <>Added a checklist for Feral.</>, contributors: [Anatta336], }, { date: new Date('2018-07-22'), changes: <>Corrected <SpellLink id={SPELLS.SAVAGE_ROAR_TALENT.id} /> to only claim credit for damage from abilities it affects in 8.0.1</>, contributors: [Anatta336], }, { date: new Date('2018-07-15'), changes: <>Fixed bugs with combo generation from AoE attacks and detecting when <SpellLink id={SPELLS.PRIMAL_FURY.id} /> waste is unavoidable.</>, contributors: [Anatta336], }, { date: new Date('2018-07-15'), changes: <>Added tracking for how <SpellLink id={SPELLS.BLOODTALONS_TALENT.id} /> charges are used.</>, contributors: [Anatta336], }, { date: new Date('2018-07-15'), changes: 'Added tracking of time spent at maximum energy.', contributors: [Anatta336], }, { date: new Date('2018-07-15'), changes: <>Added tracking for number of targets hit by <SpellLink id={SPELLS.SWIPE_CAT.id} />, <SpellLink id={SPELLS.THRASH_FERAL.id} />, and <SpellLink id={SPELLS.BRUTAL_SLASH_TALENT.id} />.</>, contributors: [Anatta336], }, ];
src/application-list.js
slx-dev/react-testing
import React from 'react'; import Application from './application'; import {Row,Col} from 'reactstrap'; export default class ApplicationList extends React.Component { render() { return ( <Row> { this.props.data.map(function(application) { return ( <div className="application-cols" key={application.id}> <Col key={application.id} md={3}> <Application name={application.name} key={application.id} id={application.id} shortDescription={application.shortDescription} imageUrl={application.imageUrl}> {application.shortDescription} </Application> </Col> </div> ); }) } </Row>); } }
src/icons/IosSunny.js
fbfeix/react-icons
import React from 'react'; import IconBase from './../components/IconBase/IconBase'; export default class IosSunny extends React.Component { render() { if(this.props.bare) { return <g> <style type="text/css"> .st0{fill:#010101;} </style> <g> <rect x="247" y="96" class="st0" width="18" height="56"></rect> <rect x="247" y="356" class="st0" width="18" height="60"></rect> <rect x="360" y="247" class="st0" width="56" height="18"></rect> <rect x="96" y="247" class="st0" width="60" height="18"></rect> <rect x="339" y="317.4" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 834.4009 337.0126)" class="st0" width="16.8" height="47.8"></rect> <rect x="162.2" y="140.7" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 407.7248 160.277)" class="st0" width="16.8" height="47.9"></rect> <rect x="339" y="140.7" transform="matrix(0.7071 0.7071 -0.7071 0.7071 218.1171 -197.4504)" class="st0" width="16.8" height="47.8"></rect> <rect x="162.2" y="317.4" transform="matrix(0.707 0.7072 -0.7072 0.707 291.3531 -20.7056)" class="st0" width="16.8" height="47.9"></rect> <path class="st0" d="M256,331.8c-41.8,0-75.8-34-75.8-75.8s34-75.8,75.8-75.8c41.8,0,75.8,34,75.8,75.8S297.8,331.8,256,331.8z"></path> </g> </g>; } return <IconBase> <style type="text/css"> .st0{fill:#010101;} </style> <g> <rect x="247" y="96" class="st0" width="18" height="56"></rect> <rect x="247" y="356" class="st0" width="18" height="60"></rect> <rect x="360" y="247" class="st0" width="56" height="18"></rect> <rect x="96" y="247" class="st0" width="60" height="18"></rect> <rect x="339" y="317.4" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 834.4009 337.0126)" class="st0" width="16.8" height="47.8"></rect> <rect x="162.2" y="140.7" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 407.7248 160.277)" class="st0" width="16.8" height="47.9"></rect> <rect x="339" y="140.7" transform="matrix(0.7071 0.7071 -0.7071 0.7071 218.1171 -197.4504)" class="st0" width="16.8" height="47.8"></rect> <rect x="162.2" y="317.4" transform="matrix(0.707 0.7072 -0.7072 0.707 291.3531 -20.7056)" class="st0" width="16.8" height="47.9"></rect> <path class="st0" d="M256,331.8c-41.8,0-75.8-34-75.8-75.8s34-75.8,75.8-75.8c41.8,0,75.8,34,75.8,75.8S297.8,331.8,256,331.8z"></path> </g> </IconBase>; } };IosSunny.defaultProps = {bare: false}
src/components/Project/index.js
ryapapap/projects
import React from 'react' import Link from 'gatsby-link' import LinkedInIcon from 'react-icons/lib/fa/linkedin-square'; import TwitterIcon from 'react-icons/lib/fa/twitter'; import GithubIcon from 'react-icons/lib/fa/github'; import EmailIcon from 'react-icons/lib/fa/envelope'; import { rhythm } from '../../utils/typography' /* TODO: - remove even more css from temp.css (and rename it) - remember nav 'home' - mobile for bio.. */ function TagList(props) { return (<ul style={{ display: 'flex', justifyContent: 'center', flexWrap: 'wrap', listStyle: 'none', color: '#666', margin: '0 10px 15px', padding: 0, }} > {props.tags.map((tag, i) => <li key={i} style={{ borderRadius: 3, fontSize: 14, margin: 3, padding: '0 7px', textTransform: 'uppercase', fontWeight: 'bold', }} > {tag} </li>) } </ul>); } function ProjectLink(props) { const style = { display: 'flex', flexFlow: 'column', alignItems: 'center', justifyContent: 'center', color: 'black', backgroundColor: 'white', textDecoration: 'none', borderRadius: 2, borderCollapse: 'separate', transition: 'all 0.3s', maxWidth: 250, backgroundImage: 'none', }; // Use react router if it's an internal link, // or a direct link if it's not (supa clunky) if (props.url) { return (<a href={props.url} style={style} className="project-card">{props.children}</a>); } else { return (<Link to={props.link} style={style} className="project-card">{props.children}</Link>); } } export default function Project(props) { return (<div style={{ padding: 20, pageBreakInside: 'avoid', breakInside: 'avoid', }} > <ProjectLink {...props}> {props.thumbnail && <img src={props.thumbnail.publicURL} style={{ width: '100%', maxHeight: 150, objectFit: 'cover', marginBottom: 0, borderTopLeftRadius: 2, borderTopRightRadius: 2, }} alt="" />} <h3>{props.title}</h3> <TagList tags={props.tags} /> </ProjectLink> </div>); }
dapp/src/shared/dao/tokenAcl/components/main.js
airalab/DAO-IPCI
import React from 'react' import { Link } from 'react-router' import { translate } from 'react-i18next' import { Layout } from '../../main/components' import Form from '../containers/formFunc' const timeConverter = (timestamp) => { const a = new Date(timestamp * 1000); const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; const year = a.getFullYear(); const month = months[a.getMonth()]; const date = a.getDate(); const hour = a.getHours(); const min = a.getMinutes(); const sec = a.getSeconds(); const time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec; return time; } const Main = (props) => { const { address, name, totalSupply, balance, aclGroup, timestamp, period, t } = props const menu = (<div className="btn-group" style={{ marginBottom: 10 }}> <Link to={'/dao/token-acl/emission/' + address} className="btn btn-default">{t('menuEmission')}</Link> <Link to={'/dao/token-acl/transfer/' + address} className="btn btn-default">{t('menuSend')}</Link> <Link to={'/dao/token-acl/approve/' + address} className="btn btn-default">{t('menuApprove')}</Link> <Link to={'/dao/token-acl/set-period/' + address} className="btn btn-default">{t('menuSetPeriod')}</Link> </div>) return (<Layout title={t('titlePrefix') + ' ' + name} address={address} menu={menu}> <p><b>{t('allTokens')}</b>: {totalSupply}</p> <p><b>{t('myBalance')}</b>: {balance}</p> <p><b>{t('groupAuditors')}</b>: {aclGroup}</p> <p><b>{t('endDate')}</b>: {(timestamp > 0) ? timeConverter(timestamp) : '-'}</p> <p><b>{t('period')}</b>: {(period > 0) ? (period / 60 / 60 / 24) + ' day' : '-'}</p> <div className="panel panel-default"> <div className="panel-heading">{t('Balance')}</div> <div className="panel-body"> <Form address={address} action="balanceOf" /> </div> </div> </Layout>) } export default translate(['tokenAcl'])(Main)
platform/ui/src/components/quickSwitch/StudiesItem.js
OHIF/Viewers
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import './StudiesItem.styl'; export class StudiesItem extends Component { static propTypes = { onClick: PropTypes.func.isRequired, studyData: PropTypes.object.isRequired, active: PropTypes.bool, }; render() { const { StudyDate, StudyDescription, modalities, studyAvailable, } = this.props.studyData; const activeClass = this.props.active ? ' active' : ''; const hasDescriptionAndDate = StudyDate && StudyDescription; return ( <div className={`studyBrowseItem${activeClass}`} onClick={this.props.onClick} > <div className="studyItemBox"> <div className="studyModality"> <div className="studyModalityText" style={this.getModalitiesStyle()} > {modalities} </div> </div> <div className="studyText"> {hasDescriptionAndDate ? ( <React.Fragment> <div className="studyDate">{StudyDate}</div> <div className="studyDescription">{StudyDescription}</div> </React.Fragment> ) : ( <div className="studyAvailability"> {studyAvailable ? ( <React.Fragment>N/A</React.Fragment> ) : ( <React.Fragment>Click to load</React.Fragment> )} </div> )} </div> </div> </div> ); } getModalitiesStyle = () => { return {}; }; }
src/svg-icons/av/movie.js
pradel/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let AvMovie = (props) => ( <SvgIcon {...props}> <path d="M18 4l2 4h-3l-2-4h-2l2 4h-3l-2-4H8l2 4H7L5 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4h-4z"/> </SvgIcon> ); AvMovie = pure(AvMovie); AvMovie.displayName = 'AvMovie'; export default AvMovie;
src/js/containers/AlternatePageContainer/AlternatePageContainer.js
shane-arthur/react-redux-and-more-boilerplate
import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { PageMappings } from '../../constants/other-constants/PageMappings'; import { apiMappings } from '../../constants/other-constants/ApiMappings'; import { getData } from '../../data/dataFetcher'; import React, { Component } from 'react'; // eslint-disable-line import/first import Radium, { StyleRoot } from 'radium'; // eslint-disable-line import/first import * as ViewActions from '../../actions'; import PictureSelector from '../PictureSelector/PictureSelector'; import PageSwitcher from '../../components/PageSwitcher/PageSwitcher'; import PictureGridContainer from '../PictureGridContainer/PictureGridContainer'; @Radium // eslint-disable-line class AlternatePageContainer extends Component { static fetchData() { return getData(apiMappings.OTHERPAGE_API); } render() { // eslint-disable-next-line react/jsx-filename-extension return (<StyleRoot> <div> <PageSwitcher linkAddress={''} /> <div style={{ textAlign: 'center' }}> <PictureSelector items={this.props.otherpage.items} selectedPictureId={this.props.otherpage.selectedPictureId} actions={this.props.actions} pageId={PageMappings.OTHERPAGE} pictureMappings={this.props.otherpage.pictureMappings} /> <PictureGridContainer items={this.props.otherpage.items} pictureList={this.props.otherpage.pictureList} pictureMappings={this.props.otherpage.pictureMappings} pageId={PageMappings.OTHERPAGE} onClick={this.props.actions.setPictureToDisplay} /> </div> </div> </StyleRoot> ); } } function mapStateToProps(state) { return { otherpage: state[PageMappings.OTHERPAGE], }; } function mapDispatchToProps(dispatch) { return { actions: bindActionCreators(ViewActions, dispatch), }; } export default connect(mapStateToProps, mapDispatchToProps)(AlternatePageContainer);
src/components/CompanyDetails/index.js
honeypotio/techmap
import React from 'react'; import PropTypes from 'prop-types'; import { getThemeColor } from '../../utils'; import Content from './Content'; import PaneSubHeader from '../PaneSubHeader'; import Tag from '../Tag'; const CompanyDetails = props => { const { companies } = props.globalStore; const id = props.params.company; const company = companies.find( company => company.name === decodeURIComponent(id) ) || {}; const themeColor = getThemeColor(company.industry); return ( <div> <PaneSubHeader title={company.name} meta={company.industry} backButton="true" /> <Content> <p> {company.technology.map((technology, idx) => ( <Tag key={idx}>{technology}</Tag> ))} </p> <p> <a href={`https://maps.google.com/?q=${encodeURIComponent(company.station)}%20station%20london`} target="_blank" rel="noopener noreferrer" > <svg fill="#3685d6" height="18" viewBox="0 0 24 24" width="30" xmlns="http://www.w3.org/2000/svg" > <g> <path d="M0 0h24v24H0z" fill="none" /> <path d="M16.49 15.5v-1.75L14 16.25l2.49 2.5V17H22v-1.5z" /> <path d="M19.51 19.75H14v1.5h5.51V23L22 20.5 19.51 18z" /> <g> <path d="M9.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM5.75 8.9L3 23h2.1l1.75-8L9 17v6h2v-7.55L8.95 13.4l.6-3C10.85 12 12.8 13 15 13v-2c-1.85 0-3.45-1-4.35-2.45l-.95-1.6C9.35 6.35 8.7 6 8 6c-.25 0-.5.05-.75.15L2 8.3V13h2V9.65l1.75-.75" /> </g> </g> </svg> {company.station} </a> </p> <p> <a href={`https://maps.google.com/?q=${encodeURIComponent(company.address)}`} target="_blank" rel="noopener noreferrer" > <svg width="30" height="18" viewBox="0 0 13 18" xmlns="http://www.w3.org/2000/svg" > <path d="M4.36 12.89C5.73 15.37 6.5 18 6.5 18s.86-2.373 2.33-5.11C10.095 10.54 12 7.9 12 6.5 12 3.46 9.538 1 6.5 1S1 3.462 1 6.5c0 1.523 1.98 3.887 3.36 6.39z" stroke="#000" strokeWidth=".5" fill={themeColor} /> </svg> <address>{company.address}</address> </a> </p> <p> <a href="https://github.com/honeypotio/techmap" target="_blank" rel="noopener noreferrer" > <svg fill="currentColor" height="18" viewBox="0 0 24 24" width="30" xmlns="http://www.w3.org/2000/svg" > <path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" /> </svg> Suggest an edit </a> </p> </Content> </div> ); }; CompanyDetails.propTypes = { globalStore: PropTypes.object }; export default CompanyDetails;
clients/packages/admin-client/src/pages/admin/mobilizations/widgets/pressure/settings/autofire/page.js
nossas/bonde-client
import PropTypes from 'prop-types'; import React from 'react'; import { Loading } from '../../../../../../../components/await'; import { FormAutofire } from '../../../../../../../mobilizations/widgets/components'; const PressureSettingsAutofirePage = (props) => !props.widget ? <Loading /> : <FormAutofire {...props} />; PressureSettingsAutofirePage.propTypes = { // Injected by redux-form fields: PropTypes.object.isRequired, // Injected by container mobilization: PropTypes.object.isRequired, widget: PropTypes.object.isRequired, asyncWidgetUpdate: PropTypes.func.isRequired, }; export default PressureSettingsAutofirePage;
Realization/frontend/czechidm-acc/src/content/wizard/SystemWizardDetail.js
bcvsolutions/CzechIdMng
import { Basic, ComponentService } from 'czechidm-core'; import React from 'react'; import IdmContext from 'czechidm-core/src/context/idm-context'; import DefaultSystemWizard from './connectorType/DefaultSystemWizard'; const componentService = new ComponentService(); /** * Detail of a system wizard. * * @author Vรญt ล vanda * @since 10.7.0 */ export default class SystemWizardDetail extends Basic.AbstractContextComponent { constructor(props, context) { super(props, context); this.wizardContext = {}; } render() { const {show, connectorType, closeWizard, reopened} = this.props; const wizardContext = this.wizardContext; let ConnectorTypeComponent = DefaultSystemWizard; if (connectorType) { const component = componentService.getConnectorTypeComponent(connectorType.id); if (component) { ConnectorTypeComponent = component.component; } } return ( <Basic.Div rendered={!!show}> <IdmContext.Provider value={{...this.context, wizardContext}}> <ConnectorTypeComponent match={this.props.match} modal reopened={reopened} closeWizard={closeWizard} connectorType={connectorType} show={!!show}/> </IdmContext.Provider> </Basic.Div> ); } } SystemWizardDetail.defaultProps = { reopened: false // Defines if the wizard use for create new system or for reopen existed. };
pyxley/assets/jsx/layout.js
stitchfix/pyxley
import React from 'react'; import ReactDOM from 'react-dom'; import {Navs} from 'pyxley'; import {ChartManager} from './chartmanager'; class App extends React.Component { constructor(props) { super(props); this.state = { layouts: [], navlinks: [], brand: "" }; } get_layout() { let path = window.location.pathname.replace("/", ""); path = path.length > 0 ? path : "antiquing"; $.get(this.props.url.concat(path, "/"), function(result){ this.setState({ layouts: result.layouts }) }.bind(this)); } get_paths() { $.get(this.props.url, function(result){ this.setState({ navlinks: result.navlinks, brand: result.brand }) }.bind(this)); } componentWillMount() { this.get_layout(); this.get_paths(); } render() { const {children} = this.props const child = children && React.cloneElement( React.Children.only(children), this.state ) return ( <div> <Navs navlinks={this.state.navlinks} brand={this.state.brand} /> <div className="container">{child}</div> </div> ) } } App.defaultProps = { url: "/api/props/" } ReactDOM.render( <App> <ChartManager /> </App>, document.getElementById("component_id") );
src/components/AboutPage.js
oshalygin/react-slingshot
import React from 'react'; import {Link} from 'react-router'; import '../styles/about-page.css'; // Since this component is simple and static, there's no parent container for it. const AboutPage = () => { return ( <div> <h2 className="alt-header">About</h2> <p> This example app is part of the <a href="https://github.com/coryhouse/react-slingshot">React-Slingshot starter kit</a>. </p> <p> <Link to="/badlink">Click this bad link</Link> to see the 404 page. </p> </div> ); }; export default AboutPage;
test/fixtures/variable-comment-annotation/actual.js
oliviertassinari/babel-plugin-transform-react-remove-prop-types
import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import FooComponent from './FooComponent' const Foo = connect(() => {}, () => {})(FooComponent); Foo.propTypes /* remove-proptypes */ = { bar: PropTypes.string.isRequired, } export default Foo
imports/ui/pages/Miscellaneous/Terms/Terms.js
haraneesh/mydev
import React from 'react'; import Page from '../../Page/Page'; const Terms = () => ( <div className="Terms"> <Page title="Terms of Service" subtitle="Last updated April 1st, 2021" page="terms" /> </div> ); export default Terms;
src/playerinfo/PlayerInfo.js
FredBoat/fredboat.com
import React, { Component } from 'react'; import "./PlayerInfo.css"; import PlayingBar from "./PlayingBar"; import fallback from "./fallback.svg" class PlayerInfo extends Component { websocket = null; emptyState = {player: null, receivedTime: null}; constructor(props) { super(props); this.state = this.emptyState; this.connect(props); setInterval(() => { if (this.websocket.readyState === this.websocket.CLOSED) this.connect(props) }, 2000); } render() { let topTrack = null; let nextTrack = null; console.log(this.state.player); if (this.state.player != null) { topTrack = this.state.player.queue[0]; nextTrack = this.state.player.queue[1]; } let image = null; if (topTrack != null && topTrack.image != null) { image = (<img className="PlayerInfo-image" src={topTrack != null ? topTrack.image : ""} alt=""/>) } else { image = (<img className="PlayerInfo-image" src={fallback} alt=""/>) } return ( <div className="PlayerInfo-page"> <div className="PlayerInfo"> {image} <div className="PlayerInfo-right"> <div className="PlayerInfo-track-name"> {topTrack == null ? "The queue is empty" : topTrack.name} </div> <PlayingBar track={topTrack} receivedTime={this.state.receivedTime} receivedPos={this.state.player != null ? this.state.player.playingPos : null}/> <div className="PlayerInfo-coming-up"> {nextTrack != null ? "Next: " + nextTrack.name : ""} </div> </div> </div> </div> ) } connect(props) { const instance = this; this.websocket = new WebSocket("wss://gateway.fredboat.com/playerinfo/" + props.guild); this.websocket.onmessage = function (msg) { instance.setState({ player: JSON.parse(msg.data), receivedTime: new Date() / 1000 }, null) }; this.websocket.onclose = () => { console.log("Websocket disconnected"); instance.setState(instance.emptyState) }; this.websocket.onabort = (event) => { console.log("Websocket errored ", event); instance.setState(instance.emptyState) } } } export default PlayerInfo;
packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js
dsopel94/create-react-app
/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ import React from 'react'; import { abstract } from './assets/abstract.json'; export default () => <summary id="feature-json-inclusion">{abstract}</summary>;
src/animations/flip/app.js
SodhanaLibrary/react-examples
import React from 'react'; import './app.css'; import classNames from 'classNames'; export default class App extends React.Component { constructor(props) { super(props); this.animate = this.animate.bind(this); this.state = { animate:false } } animate() { this.setState({ animate:!this.state.animate }) } render() { return ( <div> <button onClick={this.animate}>Animate</button> <div style={{ height:this.state.animate ? '0px':'71px' }} className={classNames({"parent--fold":this.state.animate}, "parent")}> <div className="child"> <div>Hi this is sample text</div> <br/> <br/> <div>Hi this is sample text</div> </div> </div> </div> ) } }
app/components/elements/common/DialogManager/index.stories.js
GolosChain/tolstoy
import React from 'react'; import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import DialogManager from './index'; import './index.scss'; storiesOf('DialogManager', module).add('open dialog', () => ( <div> <button onClick={openDialog}>Open Dialog</button> <DialogManager /> </div> )); function openDialog() { DialogManager.showDialog({ component: ({ someProp }) => ( <div style={{ width: 400, height: 100, background: '#fff' }}> {someProp} </div> ), props: { someProp: 'Hello', }, onClose: action('onClose'), }); }
pnpm-cached/.pnpm-store/1/registry.npmjs.org/react-bootstrap/0.31.0/es/DropdownToggle.js
Akkuma/npm-cache-benchmark
import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Button from './Button'; import SafeAnchor from './SafeAnchor'; import { bsClass as setBsClass } from './utils/bootstrapUtils'; var propTypes = { noCaret: PropTypes.bool, open: PropTypes.bool, title: PropTypes.string, useAnchor: PropTypes.bool }; var defaultProps = { open: false, useAnchor: false, bsRole: 'toggle' }; var DropdownToggle = function (_React$Component) { _inherits(DropdownToggle, _React$Component); function DropdownToggle() { _classCallCheck(this, DropdownToggle); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } DropdownToggle.prototype.render = function render() { var _props = this.props, noCaret = _props.noCaret, open = _props.open, useAnchor = _props.useAnchor, bsClass = _props.bsClass, className = _props.className, children = _props.children, props = _objectWithoutProperties(_props, ['noCaret', 'open', 'useAnchor', 'bsClass', 'className', 'children']); delete props.bsRole; var Component = useAnchor ? SafeAnchor : Button; var useCaret = !noCaret; // This intentionally forwards bsSize and bsStyle (if set) to the // underlying component, to allow it to render size and style variants. // FIXME: Should this really fall back to `title` as children? return React.createElement( Component, _extends({}, props, { role: 'button', className: classNames(className, bsClass), 'aria-haspopup': true, 'aria-expanded': open }), children || props.title, useCaret && ' ', useCaret && React.createElement('span', { className: 'caret' }) ); }; return DropdownToggle; }(React.Component); DropdownToggle.propTypes = propTypes; DropdownToggle.defaultProps = defaultProps; export default setBsClass('dropdown-toggle', DropdownToggle);
oversee/static/src/js/setup/components/ColumnSettings.js
bpsagar/oversee
import React from 'react' import Modal from './Modal' const BLEND_MODES = [ 'normal', 'multiply', 'screen', 'overlay', 'darken', 'lighten', 'color-dodge', 'color-burn', 'hard-light', 'soft-light', 'difference', 'exclusion', 'hue', 'saturation', 'color', 'luminosity' ] class ColumnSettings extends React.Component { getCurrentBlendMode = () => { return this.props.properties.blend_mode || 'normal' } handleBlendModeChange = (e) => { this.props.updateProperty('blend_mode', e.target.value) } handleLoopChange = (e) => { if (e.target.checked) { this.props.updateProperty('loop', true) } else { this.props.updateProperty('loop', false) } } handleLoopPointChange = (e) => { if (isNaN(e.target.value)) { return; } this.props.updateProperty('loop_point', parseInt(e.target.value, 10)) } render = () => ( <Modal onClose={this.props.hide} title="Settings"> <div> <label> Blend Mode <select value={this.getCurrentBlendMode()} onChange={this.handleBlendModeChange}> {BLEND_MODES.map(mode => <option key={mode} value={mode}>{mode}</option> )} </select> </label> </div> {this.props.asset.type == 'video' && <div> <div> <label> <input type="checkbox" checked={this.props.properties.loop || false} onChange={this.handleLoopChange} /> Loop Video </label> </div> <div> <label> Loop Point <input type="text" value={this.props.properties.loop_point || 0} onChange={this.handleLoopPointChange} /> </label> </div> </div> } <div className="vspacing"> <div className="pull-right"> <button className="button outline" onClick={this.props.delete}>Delete</button> <button className="button" onClick={this.props.hide}>Okay</button> </div> <div className="clearfix"></div> </div> </Modal> ) } export default ColumnSettings
src/components/examples/exampleHideShow.js
Jguardado/ComponentBase
import React, { Component } from 'react'; export default class HideShow extends Component { constructor(props) { super(props); this.state = { visible: false, }; this.show = this.show.bind(this); this.hide = this.hide.bind(this); } show() { this.setState({ visible: true }); } hide() { this.setState({ visible: false }); } render() { if (this.state.visible) { return ( <div className='center'> <legend className='headingtext'>Example Hide/Show</legend> <div className='exampleHideShow'> <button className='btn btn-success' onClick={ this.hide.bind(this)}>Make things appear</button> </div> </div> ); } if (!this.state.visible) { return ( <div className='center'> <legend className='headingtext'>Example Hide/Show</legend> <div className='exampleHideShow2'> <button className='btn btn-success' onClick={ this.show.bind(this)}>Click Here</button> </div> </div> ); } } }
react/Apps/airways-app/src/components/flight.js
rcapde/reactjs-Apps
import React, { Component } from 'react'; import '../assets/App.css'; class Flight extends Component { handleClick(){ console.log("selected") } render() { return ( <div className="flight-box"> <span>{this.props.hourDeparture}</span> <span><hr width="200" /> </span> <span>{this.props.hourArrival}</span> <span></span> <span></span> <span>{this.props.price}</span> <span><button className="btnselect" onClick={this.handleClick.bind(this)}>Select</button></span> </div> ); } } export default Flight
client/pages/viewerpage/pdfviewer.js
mickael-kerjean/nuage
import React from 'react'; import { MenuBar } from './menubar'; import "./pdfviewer.scss" export const PDFViewer = (props) => { return ( <div className="component_pdfviewer"> <MenuBar title={props.filename} download={props.data} /> <div className="pdfviewer_container" > <embed src={props.data+"#toolbar=0"} type="application/pdf" style={{height: '100%', width: '100%'}}></embed> </div> </div> ); }
examples/huge-apps/routes/Course/routes/Announcements/components/Sidebar.js
clloyd/react-router
/*globals COURSES:true */ import React from 'react' import { Link } from 'react-router' class AnnouncementsSidebar extends React.Component { render() { let { announcements } = COURSES[this.props.params.courseId] return ( <div> <h3>Sidebar Assignments</h3> <ul> {announcements.map(announcement => ( <li key={announcement.id}> <Link to={`/course/${this.props.params.courseId}/announcements/${announcement.id}`}> {announcement.title} </Link> </li> ))} </ul> </div> ) } } export default AnnouncementsSidebar
src/svg-icons/maps/add-location.js
kittyjumbalaya/material-components-web
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsAddLocation = (props) => ( <SvgIcon {...props}> <path d="M12 2C8.14 2 5 5.14 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.86-3.14-7-7-7zm4 8h-3v3h-2v-3H8V8h3V5h2v3h3v2z"/> </SvgIcon> ); MapsAddLocation = pure(MapsAddLocation); MapsAddLocation.displayName = 'MapsAddLocation'; MapsAddLocation.muiName = 'SvgIcon'; export default MapsAddLocation;
src/components/app.js
ydsood/policyPrototype
import React, { Component } from 'react'; import SearchBar from './searchbar'; import PolicyMainPanel from './policy/policy_main_panel'; import ResultList from './result_list'; import {Grid, Row, Col} from 'react-bootstrap'; export default class App extends Component { render() { return ( <div> <SearchBar /> <Grid> <Row > <Col xs={12} md={8}><PolicyMainPanel /></Col> <Col xs={6} md={4}><ResultList /></Col> </Row> </Grid> </div> ); } }