path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
jenkins-design-language/src/js/components/material-ui/svg-icons/hardware/computer.js
alvarolobato/blueocean-plugin
import React from 'react'; import SvgIcon from '../../SvgIcon'; const HardwareComputer = (props) => ( <SvgIcon {...props}> <path d="M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2h-4zM4 6h16v10H4V6z"/> </SvgIcon> ); HardwareComputer.displayName = 'HardwareComputer'; HardwareComputer.muiName = 'SvgIcon'; export default HardwareComputer;
packages/icons/src/md/places/ChildCare.js
suitejs/suitejs
import React from 'react'; import IconBase from '@suitejs/icon-base'; function MdChildCare(props) { return ( <IconBase viewBox="0 0 48 48" {...props}> <path d="M45.89 25.33c-.51 3.02-2.72 5.47-5.61 6.34a18.026 18.026 0 0 1-4.34 5.78C32.76 40.27 28.59 42 24 42s-8.76-1.73-11.94-4.55c-1.81-1.61-3.3-3.57-4.34-5.78-2.89-.87-5.1-3.32-5.61-6.34C2.04 24.9 2 24.45 2 24c0-.45.04-.9.11-1.33a8.022 8.022 0 0 1 5.61-6.34c1.06-2.23 2.56-4.2 4.39-5.82C15.28 7.71 19.44 6 24 6c4.56 0 8.72 1.71 11.89 4.51 1.83 1.61 3.34 3.59 4.39 5.82 2.89.87 5.1 3.32 5.61 6.34.07.43.11.88.11 1.33 0 .45-.04.9-.11 1.33zM38 28c2.2 0 4-1.8 4-4s-1.8-4-4-4c-.2 0-.39.03-.58.06a13.85 13.85 0 0 0-1.72-3.72C33.2 12.53 28.89 10 24 10s-9.2 2.53-11.71 6.34c-.74 1.14-1.33 2.39-1.72 3.72-.18-.03-.37-.06-.57-.06-2.2 0-4 1.8-4 4s1.8 4 4 4c.2 0 .39-.03.58-.06.39 1.33.97 2.58 1.72 3.72C14.8 35.47 19.11 38 24 38s9.2-2.53 11.71-6.34c.74-1.14 1.33-2.39 1.72-3.72.18.03.37.06.57.06zm-23 0h18c-1.52 3.53-4.97 6-9 6s-7.48-2.47-9-6zm14-4.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm-10 0a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z" /> </IconBase> ); } export default MdChildCare;
src/svg-icons/communication/contacts.js
jacklam718/react-svg-iconx
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let CommunicationContacts = (props) => ( <SvgIcon {...props}> <path d="M20 0H4v2h16V0zM4 24h16v-2H4v2zM20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 2.75c1.24 0 2.25 1.01 2.25 2.25s-1.01 2.25-2.25 2.25S9.75 10.24 9.75 9 10.76 6.75 12 6.75zM17 17H7v-1.5c0-1.67 3.33-2.5 5-2.5s5 .83 5 2.5V17z"/> </SvgIcon> ); CommunicationContacts = pure(CommunicationContacts); CommunicationContacts.displayName = 'CommunicationContacts'; CommunicationContacts.muiName = 'SvgIcon'; export default CommunicationContacts;
src/components/Breadcumn/Header.js
flftfqwxf/react-redux-starter-kit
import React from 'react' import { IndexLink, Link } from 'react-router' import './Header.scss' export const Header = () => ( <div> <h1>React Redux Starter Kit</h1> <IndexLink to='/' activeClassName='route--active'> Home </IndexLink> {' · '} <Link to='/counter' activeClassName='route--active'> Counter </Link> </div> ) export default Header
packages/@vega/review-tool/src/components/ManageReviewProcess/ManageReviewProcess.js
VegaPublish/vega-studio
import React from 'react' import {map, switchMap} from 'rxjs/operators' import {combineLatest} from 'rxjs' import lyraClient from 'part:@lyra/base/client' import withPropsStream from '../../../../utils/withPropsStream' import {materializePaths} from 'part:@vega/datastores/document-preview' import ManageReviewItem from './ManageReviewItem' import styles from './styles/ManageReviewProcess.css' import Button from 'part:@lyra/components/buttons/default' import Fieldset from 'part:@lyra/components/fieldsets/default' import schema from 'part:@lyra/base/schema' import {WithFormBuilderValue} from 'part:@lyra/form-builder' import Field from '../Field' import AddReviewItemDialog from './AddReviewItemDialog' import observableWithQuery from '../../util/observableWithQuery' import Spinner from 'part:@lyra/components/loading/spinner' const noop = () => {} const humanReadableDecission = { reject: 'Reject', publish: 'Publish', 'publish-with-revisions': 'Publish with revisions' } function listenReviewItems(reviewProcessId) { const query = `*[_type == "reviewItem" && reviewProcess._ref == "${reviewProcessId}" && !(_id in path('drafts.**'))] |order(_createdAt asc) [0..100] {...,reviewer->{_id,name}}` return observableWithQuery(query) } function loadProps(props$) { return props$.pipe( switchMap(props => combineLatest([ materializePaths(props.reviewProcess, [ '_id', 'completedAt', 'decision' ]), listenReviewItems(props.reviewProcess._id) ]).pipe( map(([reviewProcess, reviewItems]) => ({ ...props, reviewProcess, reviewItems })) ) ) ) } type Props = { reviewProcess: any, reviewItems: any } class ManageReviewProcess extends React.PureComponent<Props, *> { state = { isAddingFinalDecision: false, isAddingReviewer: false, readOnly: false, loading: false } handleAddReviewerClick = () => { this.setState({isAddingReviewer: true}) } handleAddReviewerDialogClose = event => { this.setState({isAddingReviewer: false}) } handleProceedToggle = () => { const {isAddingFinalDecision} = this.state this.setState({isAddingFinalDecision: !isAddingFinalDecision}) } handleToggleReadOnly = event => { this.setState({readOnly: event.target.checked}) } handleSubmit = () => { this.setState({ loading: true }) lyraClient .patch(this.props.reviewProcess._id) .set({completedAt: new Date().toISOString()}) .commit() .then( this.setState({ isAddingFinalDecision: false, readOnly: true, loading: false }) ) } handleFocus = nextFocusPath => { this.setState({focusPath: nextFocusPath}) } render() { const {reviewProcess, reviewItems} = this.props const {completedAt, decision} = reviewProcess const {loading} = this.state // Check if review is comleted const isCompleted = !!completedAt && decision const { readOnly, isAddingReviewer, isAddingFinalDecision, focusPath } = this.state return ( <div className={styles.root}> {isAddingReviewer && ( <AddReviewItemDialog onClose={this.handleAddReviewerDialogClose} reviewProcess={reviewProcess} /> )} <div className={styles.header}> <h2>Reviews</h2> {isCompleted && ( <div className={styles[`decision_${decision}`]}> Decision: <h3 className={styles.status}> {humanReadableDecission[decision] || decision} </h3> </div> )} </div> <ul> {reviewItems.map(reviewItem => ( <ManageReviewItem key={reviewItem._id} reviewItem={reviewItem} readOnly={readOnly} isCompleted={isCompleted} /> ))} </ul> {!readOnly && !isCompleted && ( <div> <Button onClick={this.handleAddReviewerClick}> + Invite reviewer </Button> {isAddingFinalDecision && ( <div> <WithFormBuilderValue documentId={reviewProcess._id} typeName="reviewProcess" schema={schema} > {props => props.isLoading ? ( <Spinner message="Loading…" /> ) : ( <form onSubmit={this.handleProceedToggle}> <Fieldset> {loading && ( <Spinner message="Sending final decision" /> )} <Field fieldName="content" type={props.type} value={props.value} onChange={props.onChange} onFocus={this.handleFocus} onBlur={noop} focusPath={focusPath} /> <br /> <Field fieldName="decision" type={props.type} value={props.value} onChange={props.onChange} onFocus={this.handleFocus} onBlur={noop} focusPath={focusPath} /> <br /> <Button color="primary" onClick={this.handleSubmit}> Submit </Button> <Button onClick={this.handleProceedToggle}> Cancel </Button> </Fieldset> </form> ) } </WithFormBuilderValue> </div> )} {!isAddingFinalDecision && ( <div className={styles.finalDecision}> <Button onClick={this.handleProceedToggle} color="primary" loading={loading} > Proceed to final decision </Button> </div> )} </div> )} {isCompleted && ( <div> <div className={styles.finalDecisionCompleted}> <h2>Final decision made: {humanReadableDecission[decision]}</h2> </div> <WithFormBuilderValue documentId={reviewProcess._id} typeName="reviewProcess" schema={schema} > {props => props.isLoading ? ( <Spinner message="Loading…" /> ) : ( <Field fieldName="content" type={props.type} value={props.value} onChange={props.onChange} onFocus={this.handleFocus} onBlur={noop} readOnly focusPath={focusPath} /> ) } </WithFormBuilderValue> </div> )} </div> ) } } export default withPropsStream(loadProps, ManageReviewProcess)
client/views/setupWizard/Pager.stories.js
VoiSmart/Rocket.Chat
import { action } from '@storybook/addon-actions'; import React from 'react'; import { Pager } from './Pager'; export default { title: 'components/setupWizard/Pager', component: Pager, }; export const _default = () => <Pager disabled={false} isContinueEnabled={false} />; export const withBackButton = () => <Pager onBackClick={action('backClick')} />; export const disabled = () => <Pager disabled onBackClick={action('backClick')} />; export const withContinueDisabled = () => ( <Pager isContinueEnabled={false} onBackClick={action('backClick')} /> );
docs/src/app/components/pages/components/Drawer/ExampleUndocked.js
lawrence-yu/material-ui
import React from 'react'; import Drawer from 'material-ui/Drawer'; import MenuItem from 'material-ui/MenuItem'; import RaisedButton from 'material-ui/RaisedButton'; export default class DrawerUndockedExample extends React.Component { constructor(props) { super(props); this.state = {open: false}; } handleToggle = () => this.setState({open: !this.state.open}); handleClose = () => this.setState({open: false}); render() { return ( <div> <RaisedButton label="Open Drawer" onTouchTap={this.handleToggle} /> <Drawer docked={false} width={200} open={this.state.open} onRequestChange={(open) => this.setState({open})} > <MenuItem onTouchTap={this.handleClose}>Menu Item</MenuItem> <MenuItem onTouchTap={this.handleClose}>Menu Item 2</MenuItem> </Drawer> </div> ); } }
library/src/pivotal-ui-react/tile-layout/tile-layout.js
sjolicoeur/pivotal-ui
import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import {mergeProps} from 'pui-react-helpers'; import 'pui-css-tile-layout'; export class TileLayout extends React.Component { static propTypes = { columns: PropTypes.oneOfType([ PropTypes.number, PropTypes.object ]), noGutter: PropTypes.bool } getColumnClasses = columns => { if (columns instanceof Object) { const classes = []; for (let breakpoint in columns) { if (columns.hasOwnProperty(breakpoint)) { classes.push(`tile-layout-${breakpoint}-${columns[breakpoint]}`); } } return classes; } else { return `tile-layout-xs-${columns}`; } } render() { const {children, columns, noGutter, ...others} = this.props; const classes = classnames( this.getColumnClasses(columns), noGutter ? null : 'tile-gutter', 'tile-layout' ); const props = mergeProps({className: classes}, others); return (<div {...props}> {children} </div>); } } export class TileLayoutItem extends React.Component { render() { return <div {...mergeProps({className: 'tile-item'}, this.props)}/>; } }
components/dataset/header/index.js
sgmap/inspire
import React from 'react' import PropTypes from 'prop-types' import {translate} from 'react-i18next' import MarkdownPreview from '../../markdown-preview' import Warning from '../../warning' import Infos from './infos' import LifeCycle from './life-cycle' const shouldWarn = status => [ 'obsolete', 'underDevelopment' ].includes(status) const Header = ({metadata, i18n: {language}, t}) => ( <div> {shouldWarn(metadata.status) && ( <div className='warning'> <Warning>{t(`warnings.${metadata.status}`)}</Warning> </div> )} <section className='row'> <div className='left'> <h1>{metadata.title}</h1> <Infos metadata={metadata} /> </div> {metadata.inspireTheme && ( <a href={`${metadata.inspireTheme.uri}?lang=${language}`} target='_blank' rel='noopener noreferrer'> <img src={`/static/images/datasets/inspire/${metadata.inspireTheme.id}.svg`} title={metadata.inspireTheme.label[language]} alt={metadata.inspireTheme.label[language]} /> </a> )} </section> <section> {metadata.description ? ( <MarkdownPreview markdown={metadata.description} /> ) : ( <i>{t('noDescription')}</i> )} </section> <section className='origin'> <h5>{t('labels.dataOrigin')}</h5> {metadata.lineage ? ( <MarkdownPreview markdown={metadata.lineage} /> ) : ( <i>{t('common:enums.unknownData.notSpecified', { context: 'female' })}</i> )} </section> <section> <p> <b>{t('labels.purpose')}</b> {metadata.purpose || t('common:enums.unknownData.notSpecified')} </p> <LifeCycle updateFrequency={metadata.updateFrequency} creationDate={metadata.creationDate} status={metadata.status} /> </section> <style jsx>{` @import 'colors'; section:not(:last-child) { margin-bottom: 1em; } .warning { margin-bottom: 1em; } .row { display: flex; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; border-bottom: 1px solid $lightgrey; padding-bottom: 1em; } .origin { border-top: 1px solid $lightgrey; border-bottom: 1px solid $lightgrey; padding: 1em 0; } .left { flex: 1; } h1 { font-size: 1.8rem; font-weight: 500; margin: 0 0 0.6rem 0; } a { display: block; padding-left: 15px; img { width: 40px; } } `}</style> </div> ) Header.propTypes = { metadata: PropTypes.shape({ title: PropTypes.string.isRequired, inspireTheme: PropTypes.shape({ id: PropTypes.string.isRequired, uri: PropTypes.string.isRequired, label: PropTypes.object.isRequired }), updateFrequency: PropTypes.string, creationDate: PropTypes.string, status: PropTypes.string }).isRequired, i18n: PropTypes.shape({ language: PropTypes.string.isRequired }).isRequired, t: PropTypes.func.isRequired } export default translate('dataset')(Header)
pootle/static/js/shared/components/FormValueInput.js
ta2-1/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 React from 'react'; import AutosizeTextarea from './AutosizeTextarea'; const FormValueInput = React.createClass({ propTypes: { handleChange: React.PropTypes.func.isRequired, autosize: React.PropTypes.bool, type: React.PropTypes.string, value: React.PropTypes.string, }, getDefaultProps() { return { autosize: true, }; }, handleChange(e) { this.props.handleChange(e.target.name, e.target.value); }, render() { if (this.props.type === 'textarea') { if (this.props.autosize) { return ( <AutosizeTextarea onChange={this.handleChange} {...this.props} /> ); } return ( <textarea onChange={this.handleChange} {...this.props} /> ); } return <input onChange={this.handleChange} {...this.props} />; }, }); export default FormValueInput;
src/svg-icons/device/brightness-low.js
jacklam718/react-svg-iconx
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let DeviceBrightnessLow = (props) => ( <SvgIcon {...props}> <path d="M20 15.31L23.31 12 20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"/> </SvgIcon> ); DeviceBrightnessLow = pure(DeviceBrightnessLow); DeviceBrightnessLow.displayName = 'DeviceBrightnessLow'; DeviceBrightnessLow.muiName = 'SvgIcon'; export default DeviceBrightnessLow;
client/common/components/ToggleButton.js
Haaarp/geo
import React from 'react'; import uuid from 'uuid'; class ToggleButton extends React.Component { constructor(props){ super(props); this.id = uuid(); } _getButtonClassName(){ return "checkbox-wrap" + (this.props.className ? (' ' + this.props.className) : "") + (this.props.disabled ? " btn-disabled" : ""); } render() { return ( <div className={this._getButtonClassName()}> <input type="checkbox" className="checkbox" id={"checkbox" + this.id} onChange={data => null} checked={this.props.checked} onClick={this.props.onClick} /> <label htmlFor={"checkbox" + this.id}>{this.props.label}</label> </div> ); } } export default ToggleButton;
src/svg-icons/hardware/keyboard.js
skarnecki/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let HardwareKeyboard = (props) => ( <SvgIcon {...props}> <path d="M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2V8zm0 3h2v2h-2v-2zM8 8h2v2H8V8zm0 3h2v2H8v-2zm-1 2H5v-2h2v2zm0-3H5V8h2v2zm9 7H8v-2h8v2zm0-4h-2v-2h2v2zm0-3h-2V8h2v2zm3 3h-2v-2h2v2zm0-3h-2V8h2v2z"/> </SvgIcon> ); HardwareKeyboard = pure(HardwareKeyboard); HardwareKeyboard.displayName = 'HardwareKeyboard'; export default HardwareKeyboard;
src/Parser/Paladin/Holy/Modules/Items/DrapeOfShame.js
hasseboulen/WoWAnalyzer
import React from 'react'; import SPELLS from 'common/SPELLS'; import ITEMS from 'common/ITEMS'; import HIT_TYPES from 'Parser/Core/HIT_TYPES'; import Wrapper from 'common/Wrapper'; import CoreDrapeOfShame, { DRAPE_OF_SHAME_CRIT_EFFECT } from 'Parser/Core/Modules/Items/Legion/DrapeOfShame'; import ItemHealingDone from 'Main/ItemHealingDone'; import StatValues from '../Features/StatValues'; class DrapeOfShame extends CoreDrapeOfShame { static dependencies = { ...CoreDrapeOfShame.dependencies, statValues: StatValues, }; get estimatedItemLevel() { if (!this.owner.finished) { return null; } // My DoS const itemLevel = this.equippedItem.itemLevel; const statsHps = this.statValues.calculateItemStatsHps(this.baseStats, itemLevel); const effectHps = this.healing / this.owner.fightDuration * 1000; const totalHps = statsHps + effectHps; // An estimated DoS let estimatedItemLevel = itemLevel; let estimatedHps = 0; while (estimatedHps < totalHps) { estimatedItemLevel += 5; estimatedHps = this.statValues.calculateItemStatsHps(this.baseStats, estimatedItemLevel); } // We need the `estimatedItemLevel` to *beat* the DoS, so the DoS is worth about 0-5 item levels less return estimatedItemLevel - 5; } on_byPlayer_heal(event) { const spellId = event.ability.guid; if (this.owner.constructor.abilitiesAffectedByHealingIncreases.indexOf(spellId) === -1 || spellId === SPELLS.BEACON_OF_LIGHT_CAST_AND_HEAL.id) { return; } super.on_byPlayer_heal(event); } on_beacon_heal(beaconTransferEvent, healEvent) { const spellId = healEvent.ability.guid; if (this.owner.constructor.abilitiesAffectedByHealingIncreases.indexOf(spellId) === -1 || spellId === SPELLS.BEACON_OF_LIGHT_CAST_AND_HEAL.id) { return; } if (healEvent.hitType !== HIT_TYPES.CRIT) { return; } const amount = beaconTransferEvent.amount; const absorbed = beaconTransferEvent.absorbed || 0; const overheal = beaconTransferEvent.overheal || 0; const raw = amount + absorbed + overheal; const rawNormalPart = raw / this.critEffectBonus.getBonus(healEvent); const rawDrapeHealing = rawNormalPart * DRAPE_OF_SHAME_CRIT_EFFECT; const effectiveHealing = Math.max(0, rawDrapeHealing - overheal); this.healing += effectiveHealing; } item() { const estimatedItemLevel = this.estimatedItemLevel; return { item: ITEMS.DRAPE_OF_SHAME, result: ( <Wrapper> <ItemHealingDone amount={this.healing} /><br /> <img src="/img/ilvl.png" alt="Item level" className="icon" />{' '}{estimatedItemLevel !== null ? `≈${estimatedItemLevel} cloak with similar stats` : 'Calculating...'} </Wrapper> ), }; } } export default DrapeOfShame;
information/blendle-frontend-react-source/app/components/signUp/SignUpContainer.js
BramscoChill/BlendleParser
import { history } from 'byebye'; import { STATUS_OK, STATUS_PENDING, USER_ID_TAKEN } from 'app-constants'; import React from 'react'; import PropTypes from 'prop-types'; import SignUpStore from 'stores/SignUpStore'; import AuthStore from 'stores/AuthStore'; import SignUpActions from 'actions/SignUpActions'; import SignUpForm from './SignUpForm'; import LoginContainer from 'components/login/LoginContainer'; export default class SignUpContainer extends React.Component { static propTypes = { analyticsPayload: PropTypes.object, onSignUp: PropTypes.func, // deprecated, use the SignUpStore or AuthStore // when clicking a 'login' link, like in an 'email exists' error message. // default leads to /login onToLogin: PropTypes.func, // provide extra data to send to the signup and confirmation webservice // this could contain keys like `referrer` or `entry_item` signUpContext: PropTypes.object, buttonHTML: PropTypes.string, verifyEmail: PropTypes.bool, onLogin: PropTypes.func, onToReset: PropTypes.func, showPasswordField: PropTypes.bool, signUpType: PropTypes.string, }; static defaultProps = { verifyEmail: false, analyticsName: 'Signup Form', analyticsPayload: {}, signUpContext: {}, showPasswordField: false, onToLogin() { history.navigate('/login', { trigger: true }); }, }; constructor(props) { super(props); this.state = { signUpStore: SignUpStore.getState(), authStore: AuthStore.getState(), }; SignUpStore.listen(this._onSignUpStore); AuthStore.listen(this._onAuthStore); } componentWillUnmount() { SignUpStore.unlisten(this._onSignUpStore); AuthStore.unlisten(this._onAuthStore); } _onSignUpStore = (storeState) => { if (storeState.status === STATUS_OK) { setTimeout(this.props.onSignUp); } else { this.setState({ signUpStore: storeState }); } }; _onAuthStore = (storeState) => { this.setState({ authStore: storeState }); }; _onSignUp = (email, options) => { const context = { ...this.props.signUpContext, ...options, }; SignUpActions.signUp(email, context, { verifyEmail: this.props.verifyEmail, analyticsPayload: this.props.analyticsPayload, signUpType: this.props.signUpType, }); }; render() { if (this.state.signUpStore.error === USER_ID_TAKEN) { return ( <LoginContainer email={this.state.signUpStore.email} onLogin={this.props.onLogin} onToReset={this.props.onToReset} analyticsPayload={this.props.analyticsPayload} /> ); } return ( <SignUpForm buttonHTML={this.props.buttonHTML} onToLogin={this.props.onToLogin} error={this.state.signUpStore.error} onSignUp={this._onSignUp} isLoading={this.state.signUpStore.status === STATUS_PENDING} showPasswordField={this.props.showPasswordField} /> ); } } // WEBPACK FOOTER // // ./src/js/app/components/signUp/SignUpContainer.js
src/svg-icons/image/blur-on.js
verdan/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageBlurOn = (props) => ( <SvgIcon {...props}> <path d="M6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3 .5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-11 10c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-17c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 5.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm8 .5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3 8.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM14 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-4-12c-.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.5zm0 8.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-4.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-4c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"/> </SvgIcon> ); ImageBlurOn = pure(ImageBlurOn); ImageBlurOn.displayName = 'ImageBlurOn'; ImageBlurOn.muiName = 'SvgIcon'; export default ImageBlurOn;
src/components/EditList.js
p632-sp-2016/eDocLite
/** * Created by parikhv on 4/10/16. */ import React, { Component } from 'react'; import { Input } from 'react-bootstrap'; /** * This class represents the editor dropdown option for bsSize', 'bsStyle', 'ComponentWidth', 'alignment' for the compnent properties */ export default class EditList extends Component { /** * EditList dropdown UI render method */ render() { let { value, name, options, onChange } = this.props; const parse = event => { return {value: {value: event.target.value, options}}; }; return ( <Input type="select" label={name} defaultValue={value} onChange={event => onChange(parse(event))} > {options.map((opt, optKey) => { return ( <option value={opt} key={optKey} >{opt}</option>); })} </Input> ); } }
src/components/Header/NavbarLink.js
cape-io/acf-client
import React from 'react' import { Link } from 'redux-history-sync' function NavbarLink({ children, className, component, href, to }) { const Comp = component || Link let Linkelement = ( <Comp to={to} className={className} activeStyle={{ color: '#A94545', }}> {children} </Comp> ) if (href) { Linkelement = ( <a href={href}> {children} </a> ) } return Linkelement } export default NavbarLink
fields/types/select/SelectColumn.js
w01fgang/keystone
import React from 'react'; import ItemsTableCell from '../../components/ItemsTableCell'; import ItemsTableValue from '../../components/ItemsTableValue'; var SelectColumn = React.createClass({ displayName: 'SelectColumn', propTypes: { col: React.PropTypes.object, data: React.PropTypes.object, linkTo: React.PropTypes.string, }, getValue () { const value = this.props.data.fields[this.props.col.path]; const option = this.props.col.field.ops.filter(i => i.value === value)[0]; return option ? option.label : null; }, render () { const value = this.getValue(); const empty = !value && this.props.linkTo ? true : false; return ( <ItemsTableCell> <ItemsTableValue field={this.props.col.type} to={this.props.linkTo} empty={empty}> {value} </ItemsTableValue> </ItemsTableCell> ); }, }); module.exports = SelectColumn;
actor-apps/app-web/src/app/components/dialog/MessagesSection.react.js
way1989/actor-platform
import React from 'react'; import _ from 'lodash'; import VisibilityStore from 'stores/VisibilityStore'; import MessageActionCreators from 'actions/MessageActionCreators'; import MessageItem from 'components/common/MessageItem.react'; let _delayed = []; let flushDelayed = () => { _.forEach(_delayed, (p) => { MessageActionCreators.setMessageShown(p.peer, p.message); }); _delayed = []; }; let flushDelayedDebounced = _.debounce(flushDelayed, 30, 100); let lastMessageDate; class MessagesSection extends React.Component { static propTypes = { messages: React.PropTypes.array.isRequired, peer: React.PropTypes.object.isRequired }; componentWillUnmount() { VisibilityStore.removeChangeListener(this.onAppVisibilityChange); } constructor(props) { super(props); VisibilityStore.addChangeListener(this.onAppVisibilityChange); } getMessagesListItem = (message) => { let date = new Date(message.fullDate), dateDivider; const month = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; if (typeof lastMessageDate === 'undefined') { lastMessageDate = new Date(message.fullDate); } const isNewDay = date.getDate() !== lastMessageDate.getDate(); if (isNewDay) { dateDivider = ( <li className="date-divider">{month[date.getMonth()]} {date.getDate()}</li> ); } const messageItem = ( <MessageItem key={message.sortKey} message={message} newDay={isNewDay} onVisibilityChange={this.onMessageVisibilityChange} peer={this.props.peer}/> ); lastMessageDate = new Date(message.fullDate); return [dateDivider, messageItem]; } onAppVisibilityChange = () => { if (VisibilityStore.isVisible) { flushDelayed(); } } onMessageVisibilityChange = (message, isVisible) => { if (isVisible) { _delayed.push({peer: this.props.peer, message: message}); if (VisibilityStore.isVisible) { flushDelayedDebounced(); } } } render() { let messages = _.map(this.props.messages, this.getMessagesListItem); return ( <ul className="messages"> {messages} </ul> ); } } export default MessagesSection;
shared/components/game/boardPanel/turnInfo.react.js
marek-sed/cogni
import React from 'react'; import moment from 'moment'; import 'moment-duration-format'; const colorMap = { '': '#383830', Sender: '#f92672', Receiver: '#a6e22e' , Eavesdropper: '#f2971f' } const TurnInfo = ({player: {role}, currentRound: {onTurn}, roundTime}) => { const roleColor = colorMap[role]; const observedRoleColor = '#f5f4f1'; role = role === 'Eavesdropper' ? 'ED' : role; const observedRole = role === 'Sender' ? 'Receiver' : 'Sender'; const mineClassName = onTurn === role ? 'role-mine active-mine' : 'role-mine'; const observedClassName = onTurn === observedRole ? 'role-observed active-observed' : 'role-observed'; const formatTime = (time) => moment.duration(time, 'ms').format('ss'); return ( <div className="turn-info"> <div style={{color: roleColor}} className={mineClassName}>{role}</div> <div className="time">{formatTime(roundTime)}</div> <div style={{color: observedRoleColor}} className={observedClassName}>{observedRole}</div> </div> ) } TurnInfo.defaultProps = { myRole: 'Sender', observedRole: 'Receiver', onTurn: 'Sender' } export default TurnInfo;
examples/react/app/assets/javascripts/components/Counter/renderServer.js
jdlehman/js_render
import {renderToString} from 'react-dom/server'; import React from 'react'; import Counter from './index'; window.renderCounterServer = function(props) { return renderToString(<Counter {...props} />); };
site/pages/APIPage.js
hiddentao/react-dnd
import React from 'react'; import Header from '../components/Header'; import PageBody from '../components/PageBody'; import SideBar from '../components/SideBar'; import StaticHTMLBlock from '../components/StaticHTMLBlock'; import { APIPages } from '../Constants'; export default class APIPage { render() { return ( <div> <Header/> <PageBody hasSidebar> <SideBar groups={APIPages} example={this.props.example} /> <StaticHTMLBlock html={this.props.html} /> </PageBody> </div> ); } }
docs/app/Examples/modules/Sticky/Usage/index.js
shengnian/shengnian-ui-react
import React from 'react' import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' const StickyUsageExamples = () => ( <ExampleSection title='Usage'> <ComponentExample title='Sticky offset' description='Define the offset from the top/bottom of the screen when fixing element to viewport.' examplePath='modules/Sticky/Usage/StickyExampleOffset' /> </ExampleSection> ) export default StickyUsageExamples
src/svg-icons/social/sentiment-satisfied.js
mmrtnz/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let SocialSentimentSatisfied = (props) => ( <SvgIcon {...props}> <circle cx="15.5" cy="9.5" r="1.5"/><circle cx="8.5" cy="9.5" r="1.5"/><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-4c-1.48 0-2.75-.81-3.45-2H6.88c.8 2.05 2.79 3.5 5.12 3.5s4.32-1.45 5.12-3.5h-1.67c-.7 1.19-1.97 2-3.45 2z"/> </SvgIcon> ); SocialSentimentSatisfied = pure(SocialSentimentSatisfied); SocialSentimentSatisfied.displayName = 'SocialSentimentSatisfied'; SocialSentimentSatisfied.muiName = 'SvgIcon'; export default SocialSentimentSatisfied;
client.js
maxmert/rocket-react
import React from 'react'; import Router from 'react-router'; import app from './app/app.jsx'; Router.run(app, Router.HistoryLocation, (Root) => { React.render(React.createElement(Root), document.getElementById('app')); });
frontend/components/ListItem.js
tahosalodge/camping-guide
import React from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; const ListItem = ({ className, place, selectLocation }) => ( <div className={className} onClick={() => selectLocation(place)} role="button" tabIndex={0} > <h1>{place.name}</h1> <p>{place.location}</p> </div> ); ListItem.propTypes = { place: PropTypes.shape({ name: PropTypes.string.isRequired, location: PropTypes.string.isRequired }).isRequired, className: PropTypes.string.isRequired, selectLocation: PropTypes.func.isRequired }; export default styled(ListItem)` padding: 10px 0; cursor: pointer; h1 { font-size: 20px; color: #111; margin-bottom: 10px; } p { font-size: 16px; color: #aaa; } `;
dashboard-ui/app/components/campaign/selectAudience.js
CloudBoost/cloudboost
import React from 'react'; import PropTypes from 'prop-types'; import { Modal, Button } from 'react-bootstrap'; import {} from '../../actions'; import FilterIcon from 'material-ui/svg-icons/content/filter-list'; import IconButton from 'material-ui/IconButton'; import Popover from 'material-ui/Popover'; import Chip from 'material-ui/Chip'; export class SelectAudience extends React.Component { static propTypes = { open: PropTypes.any, buildQuery: PropTypes.any } constructor (props) { super(props); this.state = { showModal: false, value: '', os: ['ios', 'android', 'edge', 'chrome', 'firefox', 'windows'], channels: [], osPop: false, channelPop: false, channelInput: '' }; if (this.props.open) { this.setState({ showModal: true }); } } close = () => this.setState({ showModal: false, value: '' }); open = () => this.setState({ showModal: true }); handleTouchTap = (which) => (event) => { event.preventDefault(); this.state[which] = true; this.state['anchorEl'] = event.currentTarget; this.setState(this.state); }; handleRequestClose = (which) => () => { this.state[which] = false; this.setState(this.state); }; changeHandler = (which) => (e) => { this.state[which] = e.target.value; this.setState(this.state); } addReomoveOS = (which) => (e) => { if (which === 'all') { if (e.target.checked) { this.state.os = ['ios', 'android', 'edge', 'chrome', 'firefox', 'windows']; } else { this.state.os = []; } } else { if (e.target.checked) { this.state.os.push(which); } else { this.state.os = this.state.os.filter(x => x !== which); } } this.setState(this.state); } addChannel = () => { if (this.state.channelInput) { this.state.channels.push(this.state.channelInput); this.setState(this.state); this.setState({ channelInput: '' }); } } removeChannel = (which) => () => { this.state.channels = this.state.channels.filter(x => x !== which); this.setState(this.state); } buildAudienceQuery = () => { let finalQuery = new CB.CloudQuery('Device'); if (this.state.os.length > 0 && this.state.os.length < 6) { finalQuery.equalTo('deviceOS', this.state.os[0]); let osQueries = []; this.state.os.map((x, i) => { let query = new CB.CloudQuery('Device'); query.equalTo('deviceOS', x); osQueries.push(query); }); if (osQueries.length > 0) finalQuery = CB.CloudQuery.or(osQueries, finalQuery); } if (this.state.channels.length > 0) { finalQuery.containedIn('channels', this.state.channels); } this.props.buildQuery(finalQuery, this.state.os, this.state.channels); this.close(); }; render () { return ( <ul> <li className='setup' onClick={this.open}> Modify Audience </li> <Modal show={this.state.showModal} onHide={this.close} dialogClassName='custom-modal select-audience-modal'> <Modal.Header> <span className='modal-title-style'>Select Audience</span> <i className='fa fa-filter modal-icon-style pull-right' /> <div className='modal-title-inner-text'> Target notifications to a specific audience </div> </Modal.Header> <Modal.Body> <div style={{ height: '150px' }} className='audcontdivs'> <div style={{ width: '30%', height: 150, 'backgroundColor': '#f6f7f8', float: 'left' }} className='flex-general-column-wrapper-center'> <span style={{ color: '#353446', fontSize: 17, fontWeight: 500 }}>Channels</span> </div> <div className='secondcontentdivselaud' style={{ height: 150 }}> <input className='inptchannel' type='text' value={this.state.channelInput} onChange={this.changeHandler('channelInput')} /> <button className='inptchannelbtn' onClick={this.addChannel}> Add Channel </button> { this.state.channels.map((x, i) => ( <Chip style={{ backgroundColor: 'rgb(235, 236, 237)' }} className='oschip' key={i} onRequestDelete={this.removeChannel(x)}> { x } </Chip> )) } </div> </div> <div className='audcontdivs'> <div style={{ width: '30%', height: 100, 'backgroundColor': '#f6f7f8', float: 'left' }} className='flex-general-column-wrapper-center os-div'> <span style={{ color: '#353446', fontSize: 17, fontWeight: 500 }}>OS</span> </div> <div className='secondcontentdivselaud os-div'> <IconButton tooltip='Edit OS' className='filtericonmodalaud' onTouchTap={this.handleTouchTap('osPop')}> <FilterIcon /> </IconButton> <Popover open={this.state.osPop} anchorEl={this.state.anchorEl} anchorOrigin={{ horizontal: 'right', vertical: 'top' }} targetOrigin={{ horizontal: 'right', vertical: 'bottom' }} onRequestClose={this.handleRequestClose('osPop')} className='osPop' style={{ padding: '10px 0', overflowY: 'hidden', overflowX: 'hidden' }} > <div className='filterrowplane'> <span className='tailnamefilter'> All Devices <input type='checkbox' checked={this.state.os.length === 6} onChange={this.addReomoveOS('all')} className='checkcardfilter pull-right' /> </span> <span className='tailnamefilter'> IOS <input type='checkbox' checked={this.state.os.indexOf('ios') !== -1} onChange={this.addReomoveOS('ios')} className='checkcardfilter pull-right' /> </span> <span className='tailnamefilter'> Android <input type='checkbox' checked={this.state.os.indexOf('android') !== -1} onChange={this.addReomoveOS('android')} className='checkcardfilter pull-right' /> </span> <span className='tailnamefilter'> Chrome <input type='checkbox' checked={this.state.os.indexOf('chrome') !== -1} onChange={this.addReomoveOS('chrome')} className='checkcardfilter pull-right' /> </span> <span className='tailnamefilter'> Windows <input type='checkbox' checked={this.state.os.indexOf('windows') !== -1} onChange={this.addReomoveOS('windows')} className='checkcardfilter pull-right' /> </span> <span className='tailnamefilter'> Firefox <input type='checkbox' checked={this.state.os.indexOf('firefox') !== -1} onChange={this.addReomoveOS('firefox')} className='checkcardfilter pull-right' /> </span> <span className='tailnamefilter'> Edge <input type='checkbox' checked={this.state.os.indexOf('edge') !== -1} onChange={this.addReomoveOS('edge')} className='checkcardfilter pull-right' /> </span> </div> </Popover> <div className='oschipdiv'> { this.state.os.map((x, i) => ( <Chip style={{ backgroundColor: 'rgb(235, 236, 237)' }} className='oschip' key={i}> { x } </Chip> )) } </div> </div> </div> </Modal.Body> <Modal.Footer> <Button onClick={this.close}>Cancel</Button> <Button bsStyle='primary' onClick={this.buildAudienceQuery}>Select Audience</Button> </Modal.Footer> </Modal> </ul> ); } } export default SelectAudience;
src/components/Footer/Footer.js
licatajustin/preesh
/** * React Starter Kit (https://www.reactstarterkit.com/) * * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import React, { Component } from 'react'; import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './Footer.scss'; import Link from '../Link'; class Footer extends Component { render() { return ( <div className={s.root}> <div className={s.container}> <span className={s.text}>© Your Company</span> <span className={s.spacer}>·</span> <Link className={s.link} to="/">Home</Link> <span className={s.spacer}>·</span> <Link className={s.link} to="/privacy">Privacy</Link> <span className={s.spacer}>·</span> <Link className={s.link} to="/not-found">Not Found</Link> </div> </div> ); } } export default withStyles(Footer, s);
pootle/static/js/admin/components/Search.js
r-o-b-b-i-e/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 ItemTable from './ItemTable'; import SearchBox from './SearchBox'; const Search = React.createClass({ propTypes: { fields: React.PropTypes.array.isRequired, onSearch: React.PropTypes.func.isRequired, onSelectItem: React.PropTypes.func.isRequired, items: React.PropTypes.object.isRequired, selectedItem: React.PropTypes.object, searchLabel: React.PropTypes.string.isRequired, searchPlaceholder: React.PropTypes.string.isRequired, resultsCaption: React.PropTypes.string.isRequired, searchQuery: React.PropTypes.string.isRequired, }, /* Lifecycle */ getInitialState() { return { isLoading: false, }; }, /* State-changing callbacks */ onResultsFetched() { this.setState({ isLoading: false }); }, fetchResults(query) { this.setState({ isLoading: true }); this.props.onSearch(query).then(this.onResultsFetched); }, loadMore() { this.fetchResults(this.props.searchQuery); }, /* Layout */ render() { const { isLoading } = this.state; const { items } = this.props; let loadMoreBtn; if (items.count > 0 && items.length < items.count) { loadMoreBtn = ( <button className="btn" onClick={this.loadMore} > {gettext('Load More')} </button> ); } const resultsClassNames = cx({ 'search-results': true, loading: isLoading, }); return ( <div className="search"> <div className="hd"> <h2>{this.props.searchLabel}</h2> </div> <div className="bd"> <div className="search-box"> <SearchBox onSearch={this.props.onSearch} placeholder={this.props.searchPlaceholder} searchQuery={this.props.searchQuery} /> </div> <div className={resultsClassNames}> {isLoading && this.props.items.length === 0 ? <div>{gettext('Loading...')}</div> : <div> <ItemTable fields={this.props.fields} items={items} resultsCaption={this.props.resultsCaption} selectedItem={this.props.selectedItem} onSelectItem={this.props.onSelectItem} /> {loadMoreBtn} </div> } </div> </div> </div> ); }, }); export default Search;
src/components/button_fillLights.js
JohnDHamm/nog-web
import React, { Component } from 'react'; import values from '../styles/values'; class ButtonFillLights extends Component { render() { const { btnSize, fillColor } = this.props; const circleDia = btnSize / 3.5; const styles = { root: { height: btnSize, width: btnSize, cursor: 'pointer', border: `1px solid ${values.nogGrayText}`, borderRadius: 3, position: 'relative', backgroundColor: '#000' }, circle: { position: 'absolute', width: circleDia, height: circleDia, backgroundColor: fillColor, border: `1px solid ${values.nogDarkGray}`, borderRadius: '50%' } }; return ( <div style={styles.root}> <div style={ Object.assign({}, styles.circle, { top: circleDia / 4, left: (btnSize / 2) - (circleDia / 2) - 1} ) }> </div> <div style={ Object.assign({}, styles.circle, { top: (btnSize / 2) - (circleDia / 2) - 1, left: circleDia / 4} ) }> </div> <div style={ Object.assign({}, styles.circle, { top: (btnSize / 2) - (circleDia / 2) - 1, right: circleDia / 4} ) }> </div> <div style={ Object.assign({}, styles.circle, { bottom: circleDia / 4, left: (btnSize / 2) - (circleDia / 2) - 1} ) }> </div> </div> ); } } export default ButtonFillLights;
examples/async/index.js
bigardone/redux
import 'babel-core/polyfill'; import React from 'react'; import { Provider } from 'react-redux'; import App from './containers/App'; import configureStore from './store/configureStore'; const store = configureStore(); React.render( <Provider store={store}> {() => <App />} </Provider>, document.getElementById('root') );
docs/app/Examples/collections/Form/States/index.js
Rohanhacker/Semantic-UI-React
import React from 'react' import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' const FormStatesExamples = () => ( <ExampleSection title='States'> <ComponentExample title='Loading' description='If a form is in loading state, it will automatically show a loading indicator.' examplePath='collections/Form/States/FormExampleLoading' /> <ComponentExample title='Success' description='If a form is in an success state, it will automatically show any success message blocks.' examplePath='collections/Form/States/FormExampleSuccess' /> <ComponentExample title='Error' description='If a form is in an error state, it will automatically show any error message blocks.' examplePath='collections/Form/States/FormExampleError' /> <ComponentExample title='Warning' description='If a form is in warning state, it will automatically show any warning message block.' examplePath='collections/Form/States/FormExampleWarning' /> <ComponentExample title='Field Error' description='Individual fields may display an error state.' examplePath='collections/Form/States/FormExampleFieldError' /> <ComponentExample title='Disabled Field' description='Individual fields may be disabled.' examplePath='collections/Form/States/FormExampleFieldDisabled' /> <ComponentExample title='Read-Only Field' description='Individual fields may be read only.' examplePath='collections/Form/States/FormExampleFieldReadOnly' /> </ExampleSection> ) export default FormStatesExamples
app/javascript/mastodon/features/public_timeline/index.js
ikuradon/mastodon
import React from 'react'; import { connect } from 'react-redux'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import PropTypes from 'prop-types'; import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; import { expandPublicTimeline } from '../../actions/timelines'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import ColumnSettingsContainer from './containers/column_settings_container'; import { connectPublicStream } from '../../actions/streaming'; const messages = defineMessages({ title: { id: 'column.public', defaultMessage: 'Federated timeline' }, }); const mapStateToProps = (state, { columnId }) => { const uuid = columnId; const columns = state.getIn(['settings', 'columns']); const index = columns.findIndex(c => c.get('uuid') === uuid); const onlyMedia = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'public', 'other', 'onlyMedia']); const onlyRemote = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyRemote']) : state.getIn(['settings', 'public', 'other', 'onlyRemote']); const timelineState = state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`]); return { hasUnread: !!timelineState && timelineState.get('unread') > 0, onlyMedia, onlyRemote, }; }; export default @connect(mapStateToProps) @injectIntl class PublicTimeline extends React.PureComponent { static contextTypes = { router: PropTypes.object, }; static defaultProps = { onlyMedia: false, }; static propTypes = { dispatch: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, columnId: PropTypes.string, multiColumn: PropTypes.bool, hasUnread: PropTypes.bool, onlyMedia: PropTypes.bool, onlyRemote: PropTypes.bool, }; handlePin = () => { const { columnId, dispatch, onlyMedia, onlyRemote } = this.props; if (columnId) { dispatch(removeColumn(columnId)); } else { dispatch(addColumn(onlyRemote ? 'REMOTE' : 'PUBLIC', { other: { onlyMedia, onlyRemote } })); } } handleMove = (dir) => { const { columnId, dispatch } = this.props; dispatch(moveColumn(columnId, dir)); } handleHeaderClick = () => { this.column.scrollTop(); } componentDidMount () { const { dispatch, onlyMedia, onlyRemote } = this.props; dispatch(expandPublicTimeline({ onlyMedia, onlyRemote })); this.disconnect = dispatch(connectPublicStream({ onlyMedia, onlyRemote })); } componentDidUpdate (prevProps) { if (prevProps.onlyMedia !== this.props.onlyMedia || prevProps.onlyRemote !== this.props.onlyRemote) { const { dispatch, onlyMedia, onlyRemote } = this.props; this.disconnect(); dispatch(expandPublicTimeline({ onlyMedia, onlyRemote })); this.disconnect = dispatch(connectPublicStream({ onlyMedia, onlyRemote })); } } componentWillUnmount () { if (this.disconnect) { this.disconnect(); this.disconnect = null; } } setRef = c => { this.column = c; } handleLoadMore = maxId => { const { dispatch, onlyMedia, onlyRemote } = this.props; dispatch(expandPublicTimeline({ maxId, onlyMedia, onlyRemote })); } render () { const { intl, columnId, hasUnread, multiColumn, onlyMedia, onlyRemote } = this.props; const pinned = !!columnId; return ( <Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}> <ColumnHeader icon='globe' active={hasUnread} title={intl.formatMessage(messages.title)} onPin={this.handlePin} onMove={this.handleMove} onClick={this.handleHeaderClick} pinned={pinned} multiColumn={multiColumn} > <ColumnSettingsContainer columnId={columnId} /> </ColumnHeader> <StatusListContainer timelineId={`public${onlyRemote ? ':remote' : ''}${onlyMedia ? ':media' : ''}`} onLoadMore={this.handleLoadMore} trackScroll={!pinned} scrollKey={`public_timeline-${columnId}`} emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other servers to fill it up' />} bindToDocument={!multiColumn} /> </Column> ); } }
src/components/antd/steps/index.js
hyd378008136/olymComponents
import React from 'react'; import PropTypes from 'prop-types'; import RcSteps from 'rc-steps'; export default class Steps extends React.Component { render() { return (React.createElement(RcSteps, Object.assign({}, this.props))); } } Steps.Step = RcSteps.Step; Steps.defaultProps = { prefixCls: 'ant-steps', iconPrefix: 'ant', current: 0, }; Steps.propTypes = { prefixCls: PropTypes.string, iconPrefix: PropTypes.string, current: PropTypes.number, };
src/icons/Document.js
fbfeix/react-icons
import React from 'react'; import IconBase from './../components/IconBase/IconBase'; export default class Document extends React.Component { render() { if(this.props.bare) { return <g> <path d="M399.3,168.9c-0.7-2.9-2-5-3.5-6.8l-83.7-91.7c-1.9-2.1-4.1-3.1-6.6-4.4c-2.9-1.5-6.1-1.6-9.4-1.6H136.2 c-12.4,0-23.7,9.6-23.7,22.9v335.2c0,13.4,11.3,25.9,23.7,25.9h243.1c12.4,0,21.2-12.5,21.2-25.9V178.4 C400.5,174.8,400.1,172.2,399.3,168.9z M305.5,111l58,63.5h-58V111z M144.5,416.5v-320h129v81.7c0,14.8,13.4,28.3,28.1,28.3h66.9 v210H144.5z"></path> </g>; } return <IconBase> <path d="M399.3,168.9c-0.7-2.9-2-5-3.5-6.8l-83.7-91.7c-1.9-2.1-4.1-3.1-6.6-4.4c-2.9-1.5-6.1-1.6-9.4-1.6H136.2 c-12.4,0-23.7,9.6-23.7,22.9v335.2c0,13.4,11.3,25.9,23.7,25.9h243.1c12.4,0,21.2-12.5,21.2-25.9V178.4 C400.5,174.8,400.1,172.2,399.3,168.9z M305.5,111l58,63.5h-58V111z M144.5,416.5v-320h129v81.7c0,14.8,13.4,28.3,28.1,28.3h66.9 v210H144.5z"></path> </IconBase>; } };Document.defaultProps = {bare: false}
src/main/resources/static/bower_components/jqwidgets/jqwidgets-react/react_jqxdatatable.js
dhawal9035/WebPLP
/* jQWidgets v4.5.0 (2017-Jan) Copyright (c) 2011-2017 jQWidgets. License: http://jqwidgets.com/license/ */ import React from 'react'; let jqxDataTable = React.createClass ({ getInitialState: function () { return { value: '' }; }, componentDidMount: function () { let options = this.manageAttributes(); this.createComponent(options); }, manageAttributes: function () { let properties = ['altRows','autoRowHeight','aggregatesHeight','autoShowLoadElement','columnsHeight','columns','columnGroups','columnsResize','columnsReorder','disabled','editable','editSettings','exportSettings','enableHover','enableBrowserSelection','filterable','filterHeight','filterMode','groups','groupsRenderer','height','initRowDetails','incrementalSearch','localization','pagerHeight','pageSize','pageSizeOptions','pageable','pagerPosition','pagerMode','pagerButtonsCount','pagerRenderer','ready','rowDetails','renderToolbar','renderStatusbar','rendering','rendered','rtl','source','sortable','showAggregates','showToolbar','showStatusbar','statusBarHeight','scrollBarSize','selectionMode','serverProcessing','showHeader','theme','toolbarHeight','width']; let options = {}; for(let item in this.props) { if(item === 'settings') { for(let itemTwo in this.props[item]) { options[itemTwo] = this.props[item][itemTwo]; } } else { if(properties.indexOf(item) !== -1) { options[item] = this.props[item]; } } } return options; }, createComponent : function (options) { if(!this.style) { for (let style in this.props.style) { $('#' +this.componentSelector).css(style, this.props.style[style]); } } if(this.props.className !== undefined) { let classes = this.props.className.split(' '); for (let i = 0; i < classes.length; i++ ) { $('#' +this.componentSelector).addClass(classes[i]); } } if(!this.template) { $('#' +this.componentSelector).html(this.props.template); } $('#' +this.componentSelector).jqxDataTable(options); }, generateID : function () { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); }, setOptions: function (options) { $('#' +this.componentSelector).jqxDataTable('setOptions', options); }, getOptions: function () { if(arguments.length === 0) { throw Error('At least one argument expected in getOptions()!'); } let resultToReturn = {}; for(let i = 0; i < arguments.length; i++) { resultToReturn[arguments[i]] = $('#' +this.componentSelector).jqxDataTable(arguments[i]); } return resultToReturn; }, on: function (name,callbackFn) { $('#' +this.componentSelector).on(name,callbackFn); }, off: function (name) { $('#' +this.componentSelector).off(name); }, altRows: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("altRows", arg) } else { return $("#" +this.componentSelector).jqxDataTable("altRows"); } }, autoRowHeight: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("autoRowHeight", arg) } else { return $("#" +this.componentSelector).jqxDataTable("autoRowHeight"); } }, aggregatesHeight: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("aggregatesHeight", arg) } else { return $("#" +this.componentSelector).jqxDataTable("aggregatesHeight"); } }, autoShowLoadElement: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("autoShowLoadElement", arg) } else { return $("#" +this.componentSelector).jqxDataTable("autoShowLoadElement"); } }, columnsHeight: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("columnsHeight", arg) } else { return $("#" +this.componentSelector).jqxDataTable("columnsHeight"); } }, columns: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("columns", arg) } else { return $("#" +this.componentSelector).jqxDataTable("columns"); } }, columnGroups: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("columnGroups", arg) } else { return $("#" +this.componentSelector).jqxDataTable("columnGroups"); } }, columnsResize: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("columnsResize", arg) } else { return $("#" +this.componentSelector).jqxDataTable("columnsResize"); } }, columnsReorder: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("columnsReorder", arg) } else { return $("#" +this.componentSelector).jqxDataTable("columnsReorder"); } }, disabled: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("disabled", arg) } else { return $("#" +this.componentSelector).jqxDataTable("disabled"); } }, editable: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("editable", arg) } else { return $("#" +this.componentSelector).jqxDataTable("editable"); } }, editSettings: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("editSettings", arg) } else { return $("#" +this.componentSelector).jqxDataTable("editSettings"); } }, exportSettings: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("exportSettings", arg) } else { return $("#" +this.componentSelector).jqxDataTable("exportSettings"); } }, enableHover: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("enableHover", arg) } else { return $("#" +this.componentSelector).jqxDataTable("enableHover"); } }, enableBrowserSelection: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("enableBrowserSelection", arg) } else { return $("#" +this.componentSelector).jqxDataTable("enableBrowserSelection"); } }, filterable: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("filterable", arg) } else { return $("#" +this.componentSelector).jqxDataTable("filterable"); } }, filterHeight: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("filterHeight", arg) } else { return $("#" +this.componentSelector).jqxDataTable("filterHeight"); } }, filterMode: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("filterMode", arg) } else { return $("#" +this.componentSelector).jqxDataTable("filterMode"); } }, groups: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("groups", arg) } else { return $("#" +this.componentSelector).jqxDataTable("groups"); } }, groupsRenderer: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("groupsRenderer", arg) } else { return $("#" +this.componentSelector).jqxDataTable("groupsRenderer"); } }, height: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("height", arg) } else { return $("#" +this.componentSelector).jqxDataTable("height"); } }, initRowDetails: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("initRowDetails", arg) } else { return $("#" +this.componentSelector).jqxDataTable("initRowDetails"); } }, incrementalSearch: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("incrementalSearch", arg) } else { return $("#" +this.componentSelector).jqxDataTable("incrementalSearch"); } }, localization: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("localization", arg) } else { return $("#" +this.componentSelector).jqxDataTable("localization"); } }, pagerHeight: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("pagerHeight", arg) } else { return $("#" +this.componentSelector).jqxDataTable("pagerHeight"); } }, pageSize: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("pageSize", arg) } else { return $("#" +this.componentSelector).jqxDataTable("pageSize"); } }, pageSizeOptions: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("pageSizeOptions", arg) } else { return $("#" +this.componentSelector).jqxDataTable("pageSizeOptions"); } }, pageable: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("pageable", arg) } else { return $("#" +this.componentSelector).jqxDataTable("pageable"); } }, pagerPosition: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("pagerPosition", arg) } else { return $("#" +this.componentSelector).jqxDataTable("pagerPosition"); } }, pagerMode: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("pagerMode", arg) } else { return $("#" +this.componentSelector).jqxDataTable("pagerMode"); } }, pagerButtonsCount: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("pagerButtonsCount", arg) } else { return $("#" +this.componentSelector).jqxDataTable("pagerButtonsCount"); } }, pagerRenderer: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("pagerRenderer", arg) } else { return $("#" +this.componentSelector).jqxDataTable("pagerRenderer"); } }, ready: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("ready", arg) } else { return $("#" +this.componentSelector).jqxDataTable("ready"); } }, rowDetails: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("rowDetails", arg) } else { return $("#" +this.componentSelector).jqxDataTable("rowDetails"); } }, renderToolbar: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("renderToolbar", arg) } else { return $("#" +this.componentSelector).jqxDataTable("renderToolbar"); } }, renderStatusbar: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("renderStatusbar", arg) } else { return $("#" +this.componentSelector).jqxDataTable("renderStatusbar"); } }, rendering: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("rendering", arg) } else { return $("#" +this.componentSelector).jqxDataTable("rendering"); } }, rendered: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("rendered", arg) } else { return $("#" +this.componentSelector).jqxDataTable("rendered"); } }, rtl: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("rtl", arg) } else { return $("#" +this.componentSelector).jqxDataTable("rtl"); } }, source: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("source", arg) } else { return $("#" +this.componentSelector).jqxDataTable("source"); } }, sortable: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("sortable", arg) } else { return $("#" +this.componentSelector).jqxDataTable("sortable"); } }, showAggregates: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("showAggregates", arg) } else { return $("#" +this.componentSelector).jqxDataTable("showAggregates"); } }, showToolbar: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("showToolbar", arg) } else { return $("#" +this.componentSelector).jqxDataTable("showToolbar"); } }, showStatusbar: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("showStatusbar", arg) } else { return $("#" +this.componentSelector).jqxDataTable("showStatusbar"); } }, statusBarHeight: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("statusBarHeight", arg) } else { return $("#" +this.componentSelector).jqxDataTable("statusBarHeight"); } }, scrollBarSize: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("scrollBarSize", arg) } else { return $("#" +this.componentSelector).jqxDataTable("scrollBarSize"); } }, selectionMode: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("selectionMode", arg) } else { return $("#" +this.componentSelector).jqxDataTable("selectionMode"); } }, serverProcessing: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("serverProcessing", arg) } else { return $("#" +this.componentSelector).jqxDataTable("serverProcessing"); } }, showHeader: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("showHeader", arg) } else { return $("#" +this.componentSelector).jqxDataTable("showHeader"); } }, theme: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("theme", arg) } else { return $("#" +this.componentSelector).jqxDataTable("theme"); } }, toolbarHeight: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("toolbarHeight", arg) } else { return $("#" +this.componentSelector).jqxDataTable("toolbarHeight"); } }, width: function (arg) { if (arg !== undefined) { $("#" +this.componentSelector).jqxDataTable("width", arg) } else { return $("#" +this.componentSelector).jqxDataTable("width"); } }, addRow: function (rowIndex, rowData, rowPosition) { $("#" +this.componentSelector).jqxDataTable("addRow", rowIndex, rowData, rowPosition); }, addFilter: function (dataField, filerGroup) { return $("#" +this.componentSelector).jqxDataTable("addFilter", dataField, filerGroup); }, applyFilters: function () { $("#" +this.componentSelector).jqxDataTable("applyFilters"); }, beginUpdate: function () { $("#" +this.componentSelector).jqxDataTable("beginUpdate"); }, beginRowEdit: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("beginRowEdit", rowIndex); }, beginCellEdit: function (rowIndex, dataField) { $("#" +this.componentSelector).jqxDataTable("beginCellEdit", rowIndex, dataField); }, clearSelection: function () { $("#" +this.componentSelector).jqxDataTable("clearSelection"); }, clearFilters: function () { $("#" +this.componentSelector).jqxDataTable("clearFilters"); }, clear: function () { $("#" +this.componentSelector).jqxDataTable("clear"); }, destroy: function () { $("#" +this.componentSelector).jqxDataTable("destroy"); }, deleteRow: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("deleteRow", rowIndex); }, endUpdate: function () { $("#" +this.componentSelector).jqxDataTable("endUpdate"); }, ensureRowVisible: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("ensureRowVisible", rowIndex); }, endRowEdit: function (rowIndex, cancelChanges) { $("#" +this.componentSelector).jqxDataTable("endRowEdit", rowIndex, cancelChanges); }, endCellEdit: function (rowIndex, dataField) { $("#" +this.componentSelector).jqxDataTable("endCellEdit", rowIndex, dataField); }, exportData: function (exportDataType) { return $("#" +this.componentSelector).jqxDataTable("exportData", exportDataType); }, focus: function () { $("#" +this.componentSelector).jqxDataTable("focus"); }, getColumnProperty: function (dataField, propertyName) { return $("#" +this.componentSelector).jqxDataTable("getColumnProperty", dataField, propertyName); }, goToPage: function (pageIndex) { $("#" +this.componentSelector).jqxDataTable("goToPage", pageIndex); }, goToPrevPage: function () { $("#" +this.componentSelector).jqxDataTable("goToPrevPage"); }, goToNextPage: function () { $("#" +this.componentSelector).jqxDataTable("goToNextPage"); }, getSelection: function () { return $("#" +this.componentSelector).jqxDataTable("getSelection"); }, getRows: function () { return $("#" +this.componentSelector).jqxDataTable("getRows"); }, getView: function () { return $("#" +this.componentSelector).jqxDataTable("getView"); }, getCellValue: function (rowIndex, dataField) { return $("#" +this.componentSelector).jqxDataTable("getCellValue", rowIndex, dataField); }, hideColumn: function (dataField) { $("#" +this.componentSelector).jqxDataTable("hideColumn", dataField); }, hideDetails: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("hideDetails", rowIndex); }, isBindingCompleted: function () { return $("#" +this.componentSelector).jqxDataTable("isBindingCompleted"); }, lockRow: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("lockRow", rowIndex); }, refresh: function () { $("#" +this.componentSelector).jqxDataTable("refresh"); }, performRender: function () { $("#" +this.componentSelector).jqxDataTable("render"); }, removeFilter: function (dataField) { $("#" +this.componentSelector).jqxDataTable("removeFilter", dataField); }, scrollOffset: function (top, left) { return $("#" +this.componentSelector).jqxDataTable("scrollOffset", top, left); }, setColumnProperty: function (dataField, propertyName, propertyValue) { $("#" +this.componentSelector).jqxDataTable("setColumnProperty", dataField, propertyName, propertyValue); }, showColumn: function (dataField) { $("#" +this.componentSelector).jqxDataTable("showColumn", dataField); }, selectRow: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("selectRow", rowIndex); }, showDetails: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("showDetails", rowIndex); }, setCellValue: function (rowIndex, dataField, value) { $("#" +this.componentSelector).jqxDataTable("setCellValue", rowIndex, dataField, value); }, sortBy: function (dataField, sortOrder) { $("#" +this.componentSelector).jqxDataTable("sortBy", dataField, sortOrder); }, updating: function () { return $("#" +this.componentSelector).jqxDataTable("updating"); }, updateBoundData: function () { $("#" +this.componentSelector).jqxDataTable("updateBoundData"); }, unselectRow: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("unselectRow", rowIndex); }, updateRow: function (rowIndex, rowData) { $("#" +this.componentSelector).jqxDataTable("updateRow", rowIndex, rowData); }, unlockRow: function (rowIndex) { $("#" +this.componentSelector).jqxDataTable("unlockRow", rowIndex); }, render: function () { let id = 'jqxDataTable' + this.generateID() + this.generateID(); this.componentSelector = id; return ( <div id={id}>{this.value ? null : this.props.value}{this.props.children}</div> ) } }); module.exports = jqxDataTable;
src/components/d3charts/MiniPieChart.js
nbuechler/friendly-finder
import React from 'react'; import d3 from 'd3'; export default class MiniPieChart extends React.Component { static defaultProps = { width: 50, height: 50, x: 0, y: 0, } constructor (props) { super(props); this.state = { }; } render () { var {props} = this, {width, height, data} = props; var radius = Math.min(width, height) / 2; var layout = d3.layout.pie()(data); var arcGen = d3.svg.arc() .innerRadius(radius * 0.0) .outerRadius(radius * 0.9); var color = ['#EB493A', '#5078A9', '#8B2E74', '#4E981F', '#D69C30']; return ( <svg {...props} visibility={'hidden'}> <g transform={`translate(${width / 2},${height / 2})`}> {layout.map((d, i) => { return ( <path d={arcGen(d)} key={i} style={{ fill: color[i % 5], stroke: 'black', strokeWidth: '2px', }} /> ); })} </g> </svg> ); } }
react-dev/containers/about.js
InsidiousMind/code.LiquidThink
import React, { Component } from 'react'; import { connect } from 'react-redux'; import { fetchPage } from '../actions/index'; import { Page } from '../components/page'; class About extends Component { componentWillMount() { this.props.fetchPage('About', '/about/'); } render() { if (!this.props.pageInfo) { return ( <div> Loading </div> ); } return ( <Page title={this.props.pageInfo.title} content={this.props.pageInfo.body} /> ); } } function mapStateToProps(state) { return { pageInfo: state.posts.page }; } export default connect(mapStateToProps, { fetchPage })(About);
src/svg-icons/notification/airline-seat-individual-suite.js
nathanmarks/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let NotificationAirlineSeatIndividualSuite = (props) => ( <SvgIcon {...props}> <path d="M7 13c1.65 0 3-1.35 3-3S8.65 7 7 7s-3 1.35-3 3 1.35 3 3 3zm12-6h-8v7H3V7H1v10h22v-6c0-2.21-1.79-4-4-4z"/> </SvgIcon> ); NotificationAirlineSeatIndividualSuite = pure(NotificationAirlineSeatIndividualSuite); NotificationAirlineSeatIndividualSuite.displayName = 'NotificationAirlineSeatIndividualSuite'; NotificationAirlineSeatIndividualSuite.muiName = 'SvgIcon'; export default NotificationAirlineSeatIndividualSuite;
client/components/static/Privacy.js
MusicConnectionMachine/VisualizationG6
import React from 'react' import '../../../style/legal.scss' class Privacy extends React.Component { render () { return ( <div className='container-fluid animated fadeIn legalpage'> <h2>MusicConnectionMachine Privacy Policy</h2> <p>This privacy policy has been compiled to better serve those who are concerned with how their 'Personally identifiable information' (PII) is being used online. PII, as used in US privacy law and information security, is information that can be used on its own or with other information to identify, contact, or locate a single person, or to identify an individual in context. Please read our privacy policy carefully to get a clear understanding of how we collect, use, protect or otherwise handle your Personally Identifiable Information in accordance with our website.</p> <h4>What personal information do we collect from the people that visit our blog, website or app?</h4> <p>We do not collect information from visitors of our site or other details to help you with your experience.</p> <h4>When do we collect information?</h4> <p>We collect information from you when you or enter information on our site.</p> <h4>How do we use your information?</h4> <p>We may use the information we collect from you when you register, make a purchase, sign up for our newsletter, respond to a survey or marketing communication, surf the website, or use certain other site features in the following ways:</p> <ul> <li>To improve our website in order to better serve you.</li> <li>To allow us to better service you in responding to your customer service requests.</li> <li>To administer a contest, promotion, survey or other site feature.</li> </ul> <h4>Do we use 'cookies'?</h4> <p>We do not use cookies for tracking purposes</p> <p>You can choose to have your computer warn you each time a cookie is being sent, or you can choose to turn off all cookies. You do this through your browser (like Internet Explorer) settings. Each browser is a little different, so look at your browser's Help menu to learn the correct way to modify your cookies.</p> <p>If you disable cookies off, some features will be disabled that make your site experience more efficient and some of our services will not function properly.</p> <p>However, you can still place orders.</p> <h3>Third-party disclosure</h3> <p>We do not sell, trade, or otherwise transfer to outside parties your personally identifiable information.</p> <h4>Third-party links</h4> <p>We do not include or offer third-party products or services on our website.</p> <h4>Google</h4> <p>Google's advertising requirements can be summed up by Google's Advertising Principles. They are put in place to provide a positive experience for users. https://support.google.com/adwordspolicy/answer/1316548?hl=en</p> <p>We use Google AdSense Advertising on our website.</p> <p>Google, as a third-party vendor, uses cookies to serve ads on our site. Google's use of the DART cookie enables it to serve ads to our users based on previous visits to our site and other sites on the Internet. Users may opt-out of the use of the DART cookie by visiting the Google Ad and Content Network privacy policy.</p> <p>We have implemented the following:</p> <ul> <li>Google Display Network Impression Reporting</li> <li>Demographics and Interests Reporting</li> </ul> <p>We along with third-party vendors, such as Google use first-party cookies (such as the Google Analytics cookies) and third-party cookies (such as the DoubleClick cookie) or other third-party identifiers together to compile data regarding user interactions with ad impressions and other ad service functions as they relate to our website.</p> <p>Opting out:</p> <p>Users can set preferences for how Google advertises to you using the Google Ad Settings page. Alternatively, you can opt out by visiting the Network Advertising initiative opt out page or permanently using the Google Analytics Opt Out Browser add on.</p> <h4>COPPA (Children Online Privacy Protection Act)</h4> <p>When it comes to the collection of personal information from children under 13, the Children's Online Privacy Protection Act (COPPA) puts parents in control. The Federal Trade Commission, the nation's consumer protection agency, enforces the COPPA Rule, which spells out what operators of websites and online services must do to protect children's privacy and safety online.</p> <p>We do not specifically market to children under 13.</p> <h3>Fair Information Practices</h3> <p>The Fair Information Practices Principles form the backbone of privacy law in the United States and the concepts they include have played a significant role in the development of data protection laws around the globe. Understanding the Fair Information Practice Principles and how they should be implemented is critical to comply with the various privacy laws that protect personal information.</p> <p>In order to be in line with Fair Information Practices we will take the following responsive action, should a data breach occur:</p> <p>We will notify the users via in-site notification</p> <ul> <li>Within 7 business days</li> </ul> <p>We also agree to the Individual Redress Principle, which requires that individuals have a right to pursue legally enforceable rights against data collectors and processors who fail to adhere to the law. This principle requires not only that individuals have enforceable rights against data users, but also that individuals have recourse to courts or government agencies to investigate and/or prosecute non-compliance by data processors.</p> <h4>CAN SPAM Act</h4> <p>The CAN-SPAM Act is a law that sets the rules for commercial email, establishes requirements for commercial messages, gives recipients the right to have emails stopped from being sent to them, and spells out tough penalties for violations.</p> <p>We collect your email address in order to:</p> <p>To be in accordance with CANSPAM we agree to the following:</p> <p>If at any time you would like to unsubscribe from receiving future emails, you can email us at and we will promptly remove you from ALL correspondence.</p> <h3>Contacting Us</h3> <p>If there are any questions regarding this privacy policy you may contact us using the information below.</p> <address> <strong>MusicConnectionMachine</strong><br /> Boltzmannstrasse, 3<br /> Garching, Bayern 85748<br /> Germany<br /> [email protected]<br /> </address> <p>Last Edited on 2017-04-22</p> </div> ) } } export default Privacy
app/components/OutputLine.js
kenwilcox/fil
import React from 'react'; import {parseType} from 'helpers'; import Chunk from 'components/Chunk'; class OutputLine extends React.Component { render() { var block = "console__output"; return ( <div className={block + "__line"}> {this.props.output.map( (chunk, i) => <Chunk key={i} chunk={chunk} /> )} </div> ); } } export default OutputLine;
web/src/js/components/comuns/button.js
helderfarias/ges
'use strict'; import React from 'react'; let Button = React.createClass({ getDefaultProps() { return { icon: '', name: '', target: {} } }, render() { return ( <button type="button" className="btn btn-default btn-md btn-space" onClick={this._onClick}> <i className={this.props.icon}></i> </button> ); }, _onClick() { if (this.props.onClick) { this.props.onClick(this.props.target); } } }); export default Button;
src/pages/news/NBA/NewsNBAFollow.js
HeliumLau/Hoop-react
import React from 'react'; import NewsList from 'components/NewsList.js'; export default class NewsNBAFollow extends React.Component { render() { const list = [ { title: '帕森斯晒自己与演员特里-克鲁斯的合照', lNum: '28', cNum: '212', bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg' }, { title: '帕森斯晒自己与演员特里-克鲁斯的合照', lNum: '28', cNum: '212', bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg' }, { title: '帕森斯晒自己与演员特里-克鲁斯的合照', lNum: '28', cNum: '212', bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg' }, { title: '帕森斯晒自己与演员特里-克鲁斯的合照', lNum: '28', cNum: '212', bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg' }, { title: '帕森斯晒自己与演员特里-克鲁斯的合照', lNum: '28', cNum: '212', bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg' }, { title: '帕森斯晒自己与演员特里-克鲁斯的合照', lNum: '28', cNum: '212', bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg' }, { title: '帕森斯晒自己与演员特里-克鲁斯的合照', lNum: '28', cNum: '212', bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg' }, { title: '帕森斯晒自己与演员特里-克鲁斯的合照', lNum: '28', cNum: '212', bgurl: 'http://img2.imgtn.bdimg.com/it/u=570063258,1608174164&fm=26&gp=0.jpg' } ]; return ( <NewsList list={list} /> ) } }
src/svg-icons/social/sentiment-satisfied.js
barakmitz/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let SocialSentimentSatisfied = (props) => ( <SvgIcon {...props}> <circle cx="15.5" cy="9.5" r="1.5"/><circle cx="8.5" cy="9.5" r="1.5"/><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-4c-1.48 0-2.75-.81-3.45-2H6.88c.8 2.05 2.79 3.5 5.12 3.5s4.32-1.45 5.12-3.5h-1.67c-.7 1.19-1.97 2-3.45 2z"/> </SvgIcon> ); SocialSentimentSatisfied = pure(SocialSentimentSatisfied); SocialSentimentSatisfied.displayName = 'SocialSentimentSatisfied'; SocialSentimentSatisfied.muiName = 'SvgIcon'; export default SocialSentimentSatisfied;
src/svg-icons/action/list.js
igorbt/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionList = (props) => ( <SvgIcon {...props}> <path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/> </SvgIcon> ); ActionList = pure(ActionList); ActionList.displayName = 'ActionList'; ActionList.muiName = 'SvgIcon'; export default ActionList;
src/views/clause/ClauseTable.js
bostontrader/senmaker
// @flow import React from 'react' import ClauseRow from './ClauseRow' function ClauseTable(props:Object):?Object { let clauseTable:?Object = null const clauseRows:Object = [...props.clause.getIn(['dict','coll']).values()].map(clause => ( <ClauseRow key={clause.get('id')} clause={clause} strings={props.strings} /> )) let header:?Object = null if (clauseRows.length > 0) { header = <thead> <tr> <th>Clause</th> <th> </th> </tr> </thead> clauseTable = <table id="clause-list"> {header} <tbody> {clauseRows} </tbody> </table> } return clauseTable } export default ClauseTable
src/entypo/CircularGraph.js
cox-auto-kc/react-entypo
import React from 'react'; import EntypoIcon from '../EntypoIcon'; const iconClass = 'entypo-svgicon entypo--CircularGraph'; let EntypoCircularGraph = (props) => ( <EntypoIcon propClass={iconClass} {...props}> <path d="M17.584,9.372h2c-0.065-1.049-0.293-2.053-0.668-2.984L17.16,7.402C17.384,8.025,17.531,8.685,17.584,9.372z M14.101,1.295c-0.955-0.451-1.99-0.757-3.086-0.87v2.021c0.733,0.097,1.433,0.295,2.084,0.585L14.101,1.295z M16.242,5.622l1.741-1.005c-0.591-0.878-1.33-1.645-2.172-2.285l-1.006,1.742C15.354,4.52,15.836,5.042,16.242,5.622z M10.014,17.571c-4.197,0-7.6-3.402-7.6-7.6c0-3.858,2.877-7.036,6.601-7.526V0.424c-4.833,0.5-8.601,4.583-8.601,9.547c0,5.303,4.298,9.601,9.601,9.601c4.824,0,8.807-3.563,9.486-8.2H17.48C16.822,14.899,13.732,17.571,10.014,17.571z"/> </EntypoIcon> ); export default EntypoCircularGraph;
js/components/tap/index2.js
leehyoumin/asuraCham
'use strict'; //This is a Add project import React, { Component } from 'react'; import { connect } from 'react-redux'; import { popRoute } from '../../actions/route'; import { openDrawer, closeDrawer } from '../../actions/drawer'; import { setIndex } from '../../actions/list'; import { replaceRoute, replaceOrPushRoute } from '../../actions/route'; import { Container, Header, Title, Content, Text,Button, Icon, InputGroup,Input,View,Picker } from 'native-base'; import { AppRegistry, TextInput } from 'react-native'; import myTheme from '../../themes/base-theme'; import RadioForm, {RadioButton, RadioButtonInput, RadioButtonLabel} from 'react-native-simple-radio-button'; var sqlite = require('react-native-android-sqlite') var insertProject = 'INSERT INTO Project(ProjectId,ProjectName,UserId) VALUES (?,?,?)' var ProjectParams = ["","",""] var insertSkill = 'INSERT INTO Skill(ProjectId) VALUES (?)' var projectSelect = 'SELECT * FROM Project' var noParams = [] var skillSelect = 'SELECT * FROM Skill' var radio_props = [ {label: 'start', value: "start" }, {label: 'continue', value: "continue" }, {label: 'finish', value: "finish" } ]; var RadioButtonProject = React.createClass({ getInitialState: function() { return { value: 0, } }, render: function() { return ( <View> <RadioForm radio_props={radio_props} initial={0} onPress={(value) => {this.setState({staTus:value})}} /> </View> ); } }); class Add_Project extends Component { popRoute() { this.props.popRoute(); } replaceRoute(route) { this.props.replaceRoute(route); } navigateTo(route, index) { this.props.closeDrawer(); this.props.setIndex(index); this.props.replaceOrPushRoute(route); } constructor(props) { super(props); this.state = { projectName: '', staTus: '', skill: [], DbLength: 0, descriPtion: '', buttonDisabled: true, syncs: false }; this._insertDB = this._insertDB.bind(this); this._checkskill= this._checkskill.bind(this); } _insertDB() { this._getInformation(); // set params sqlite.exec(sql, ProjectParams) .then((_) => { console.log('row inserted.') } ) } _buttonStyle() { return { backgroundColor: '#6E5BAA', underlayColor: '#51437f', borderColor: '#6E5BAA', disabledColor: '#ababab', textColor: '#ffffff' } } _getInformation() { ProjectParams = [this.state.DbLength,this.state.projectName,"HyeonMin"] console.log(params); } _checkskill() { console.log(this.state.skill); } _checkDB() { sqlite.query(projectSelect,noParams) .then((data) => { data.map((d , i) =>{ console.log(d); }) console.log('retrieved: ', data); this.setState({DbLength: data.length}); } ) } render() { const { props: { name, index, list } } = this; return ( <Container theme={myTheme} style={{backgroundColor: '#565051'}}> <Header> <Button transparent onPress={() => this.replaceRoute('home')}> <Icon name='ios-arrow-back' /> </Button> <Title>{(name) ? name : 'Add Project'}</Title> <Button transparent onPress={this.props.openDrawer}> <Icon name='ios-menu' /> </Button> </Header> <Content padder> <TextInput style={{width: 330, color: '#555555', padding: 10, height: 50, marginBottom: 10, borderColor: '#6E5BAA', borderWidth: 1, borderRadius: 4, alignSelf: 'flex-start', backgroundColor: '#ffffff'}} value={this.state.projectName} onChangeText={(text) => this.setState({projectName: text})} placeholder={'Enter Project Name'} maxLength={12} multiline={false} /> <View style={{flexDirection: 'row'}}> <Text style={{fontSize: 15}}> Status: </Text> <RadioForm radio_props={radio_props} initial={'start'} onPress={(value) => {this.setState({staTus:value})}} /> </View> <View style={{flexDirection: 'row',alignItems: 'center'}}> <Text style={{fontSize: 15}}> Skill: </Text> <Text style={{fontSize: 15}}>{this.state.skill} </Text> <Picker style={{backgroundColor:'white',width: 115,height: 35}} selectedValue={this.state.skill} onValueChange={(lang) => { if(lang != '' ){ var temp = this.state.skill; if (temp.indexOf(lang) === -1){ temp.push(lang); this.setState({skill: temp}); } } } }> <Picker.Item label="Add" value="" /> <Picker.Item label="Java" value="Java" /> <Picker.Item label="JavaScript" value="JavaScript" /> </Picker> </View> <TextInput style={{width: 330, color: '#555555', padding: 10, height: 150, marginTop: 10, borderColor: '#6E5BAA', borderWidth: 1, borderRadius: 4, alignSelf: 'flex-start', backgroundColor: '#ffffff'}} value={this.state.descriPtion} onChangeText={(text) => this.setState({descriPtion: text})} placeholder={'Enter description'} maxLength={100} multiline={false} /> <Button style={{alignSelf: 'center',marginTop: 15}} onPress={this._insertDB}>Create Project</Button> <Button style={{alignSelf: 'center',marginTop: 15}} onPress={this._checkDB}>check db</Button> </Content> </Container> ) } } function bindAction(dispatch) { return { openDrawer: ()=>dispatch(openDrawer()), popRoute: () => dispatch(popRoute()), closeDrawer: ()=>dispatch(closeDrawer()), replaceRoute:(route)=>dispatch(replaceRoute(route)), replaceOrPushRoute:(route)=>dispatch(replaceOrPushRoute(route)), setIndex:(index)=>dispatch(setIndex(index)) } } function mapStateToProps(state) { return { name: state.user.name, index: state.list.selectedIndex, list: state.list.list }; } export default connect(mapStateToProps, bindAction)(Add_Project);
docs/demos/react-hello-world/src/index.js
reTHINK-project/dev-hyperty
// modules import React from 'react'; import ReactDOM from 'react-dom'; import $ from 'jquery'; // CSS import './index.css'; import './App.css'; // React components import ReactObserver from './ReactObserver' // render React component ReactDOM.render( <ReactObserver />, document.getElementById('root') );
app/javascript/mastodon/features/compose/components/navigation_bar.js
im-in-space/mastodon
import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ActionBar from './action_bar'; import Avatar from '../../../components/avatar'; import Permalink from '../../../components/permalink'; import IconButton from '../../../components/icon_button'; import { FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; export default class NavigationBar extends ImmutablePureComponent { static propTypes = { account: ImmutablePropTypes.map.isRequired, onLogout: PropTypes.func.isRequired, onClose: PropTypes.func, }; render () { return ( <div className='navigation-bar'> <Permalink href={this.props.account.get('url')} to={`/@${this.props.account.get('acct')}`}> <span style={{ display: 'none' }}>{this.props.account.get('acct')}</span> <Avatar account={this.props.account} size={48} /> </Permalink> <div className='navigation-bar__profile'> <Permalink href={this.props.account.get('url')} to={`/@${this.props.account.get('acct')}`}> <strong className='navigation-bar__profile-account'>@{this.props.account.get('acct')}</strong> </Permalink> <a href='/settings/profile' className='navigation-bar__profile-edit'><FormattedMessage id='navigation_bar.edit_profile' defaultMessage='Edit profile' /></a> </div> <div className='navigation-bar__actions'> <IconButton className='close' title='' icon='close' onClick={this.props.onClose} /> <ActionBar account={this.props.account} onLogout={this.props.onLogout} /> </div> </div> ); } }
fields/types/password/PasswordFilter.js
lojack/keystone
import React from 'react'; import { SegmentedControl } from 'elemental'; const OPTIONS = [ { label: 'Is Set', value: true }, { label: 'Is NOT Set', value: false } ]; var PasswordFilter = React.createClass({ getInitialState () { return { checked: this.props.value || true }; }, toggleChecked (checked) { this.setState({ checked: checked }); }, render () { return <SegmentedControl equalWidthSegments options={OPTIONS} value={this.state.checked} onChange={this.toggleChecked} />; } }); module.exports = PasswordFilter;
src/svg-icons/image/wb-sunny.js
IsenrichO/mui-with-arrows
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageWbSunny = (props) => ( <SvgIcon {...props}> <path d="M6.76 4.84l-1.8-1.79-1.41 1.41 1.79 1.79 1.42-1.41zM4 10.5H1v2h3v-2zm9-9.95h-2V3.5h2V.55zm7.45 3.91l-1.41-1.41-1.79 1.79 1.41 1.41 1.79-1.79zm-3.21 13.7l1.79 1.8 1.41-1.41-1.8-1.79-1.4 1.4zM20 10.5v2h3v-2h-3zm-8-5c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm-1 16.95h2V19.5h-2v2.95zm-7.45-3.91l1.41 1.41 1.79-1.8-1.41-1.41-1.79 1.8z"/> </SvgIcon> ); ImageWbSunny = pure(ImageWbSunny); ImageWbSunny.displayName = 'ImageWbSunny'; ImageWbSunny.muiName = 'SvgIcon'; export default ImageWbSunny;
src/shared/element-react/dist/npm/es6/src/carousel/Carousel.js
thundernet8/Elune-WWW
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _createClass from 'babel-runtime/helpers/createClass'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import React from 'react'; import throttle from 'throttle-debounce/throttle'; import { Component, PropTypes, Transition, View } from '../../libs'; import { addResizeListener, removeResizeListener } from '../../libs/utils/resize-event'; var Carousel = function (_Component) { _inherits(Carousel, _Component); function Carousel(props) { _classCallCheck(this, Carousel); var _this = _possibleConstructorReturn(this, _Component.call(this, props)); _this.state = { items: [], activeIndex: -1, containerWidth: 0, timer: null, hover: false }; _this.throttledArrowClick = throttle(300, true, function (index) { _this.setActiveItem(index); }); _this.throttledIndicatorHover = throttle(300, function (index) { _this.handleIndicatorHover(index); }); return _this; } Carousel.prototype.getChildContext = function getChildContext() { return { component: this }; }; Carousel.prototype.componentDidMount = function componentDidMount() { addResizeListener(this.refs.root, this.resetItemPosition.bind(this)); if (this.props.initialIndex < this.state.items.length && this.props.initialIndex >= 0) { this.setState({ activeIndex: this.props.initialIndex }); } this.startTimer(); }; Carousel.prototype.componentDidUpdate = function componentDidUpdate(props, state) { if (state.activeIndex != this.state.activeIndex) { this.resetItemPosition(); if (this.props.onChange) { this.props.onChange(this.state.activeIndex, state.activeIndex); } } }; Carousel.prototype.componentWillUnmount = function componentWillUnmount() { removeResizeListener(this.refs.root, this.resetItemPosition.bind(this)); }; Carousel.prototype.handleMouseEnter = function handleMouseEnter() { this.setState({ hover: true }); this.pauseTimer(); }; Carousel.prototype.handleMouseLeave = function handleMouseLeave() { this.setState({ hover: false }); this.startTimer(); }; Carousel.prototype.itemInStage = function itemInStage(item, index) { var length = this.state.items.length; if (index === length - 1 && item.state.inStage && this.state.items[0].state.active || item.state.inStage && this.state.items[index + 1] && this.state.items[index + 1].state.active) { return 'left'; } else if (index === 0 && item.state.inStage && this.state.items[length - 1].state.active || item.state.inStage && this.state.items[index - 1] && this.state.items[index - 1].state.active) { return 'right'; } return false; }; Carousel.prototype.handleButtonEnter = function handleButtonEnter(arrow) { var _this2 = this; this.state.items.forEach(function (item, index) { if (arrow === _this2.itemInStage(item, index)) { item.setState({ hover: true }); } }); }; Carousel.prototype.handleButtonLeave = function handleButtonLeave() { this.state.items.forEach(function (item) { item.setState({ hover: false }); }); }; Carousel.prototype.resetItemPosition = function resetItemPosition() { var _this3 = this; this.state.items.forEach(function (item, index) { item.translateItem(index, _this3.state.activeIndex); }); }; Carousel.prototype.playSlides = function playSlides() { var activeIndex = this.state.activeIndex; if (activeIndex < this.state.items.length - 1) { activeIndex++; } else { activeIndex = 0; } this.setState({ activeIndex: activeIndex }); }; Carousel.prototype.pauseTimer = function pauseTimer() { clearInterval(this.timer); }; Carousel.prototype.startTimer = function startTimer() { if (this.props.interval <= 0 || !this.props.autoplay) return; this.timer = setInterval(this.playSlides.bind(this), Number(this.props.interval)); }; Carousel.prototype.addItem = function addItem(item) { this.state.items.push(item); this.setActiveItem(0); }; Carousel.prototype.removeItem = function removeItem(item) { this.state.items.splice(this.state.items.indexOf(item), 1); this.setActiveItem(0); }; Carousel.prototype.setActiveItem = function setActiveItem(index) { var activeIndex = this.state.activeIndex; if (typeof index === 'string') { var filteredItems = this.state.items.filter(function (item) { return item.props.name === index; }); if (filteredItems.length > 0) { index = this.state.items.indexOf(filteredItems[0]); } } index = Number(index); if (isNaN(index) || index !== Math.floor(index)) { process.env.NODE_ENV !== 'production' && console.warn('[Element Warn][Carousel]index must be an integer.'); return; } var length = this.state.items.length; if (index < 0) { activeIndex = length - 1; } else if (index >= length) { activeIndex = 0; } else { activeIndex = index; } this.setState({ activeIndex: activeIndex }); }; Carousel.prototype.prev = function prev() { this.setActiveItem(this.state.activeIndex - 1); }; Carousel.prototype.next = function next() { this.setActiveItem(this.state.activeIndex + 1); }; Carousel.prototype.handleIndicatorClick = function handleIndicatorClick(index) { this.setState({ activeIndex: index }); }; Carousel.prototype.handleIndicatorHover = function handleIndicatorHover(index) { if (this.props.trigger === 'hover' && index !== this.state.activeIndex) { this.setState({ activeIndex: index }); } }; Carousel.prototype.render = function render() { var _this4 = this; var _props = this.props, height = _props.height, arrow = _props.arrow, indicatorPosition = _props.indicatorPosition; var _state = this.state, hover = _state.hover, activeIndex = _state.activeIndex, items = _state.items; return React.createElement( 'div', { ref: 'root', className: this.className('el-carousel', { 'el-carousel--card': this.iscard }), onMouseEnter: this.handleMouseEnter.bind(this), onMouseLeave: this.handleMouseLeave.bind(this) }, React.createElement( 'div', { className: 'el-carousel__container', style: { height: height } }, React.createElement( Transition, { name: 'carousel-arrow-left', duration: '300' }, arrow !== 'never' && React.createElement( View, { key: arrow === 'always' || hover, show: arrow === 'always' || hover }, React.createElement( 'button', { className: 'el-carousel__arrow el-carousel__arrow--left', onMouseEnter: this.handleButtonEnter.bind(this, 'left'), onMouseLeave: this.handleButtonLeave.bind(this), onClick: this.throttledArrowClick.bind(this, activeIndex - 1) }, React.createElement('i', { className: 'el-icon-arrow-left' }) ) ) ), React.createElement( Transition, { name: 'carousel-arrow-right' }, arrow !== 'never' && React.createElement( View, { key: arrow === 'always' || hover, show: arrow === 'always' || hover }, React.createElement( 'button', { className: 'el-carousel__arrow el-carousel__arrow--right', onMouseEnter: this.handleButtonEnter.bind(this, 'right'), onMouseLeave: this.handleButtonLeave.bind(this), onClick: this.throttledArrowClick.bind(this, activeIndex + 1) }, React.createElement('i', { className: 'el-icon-arrow-right' }) ) ) ), this.props.children ), indicatorPosition !== 'none' && React.createElement( 'ul', { className: this.classNames('el-carousel__indicators', { 'el-carousel__indicators--outside': indicatorPosition === 'outside' || this.iscard }) }, items.map(function (item, index) { return React.createElement( 'li', { key: index, className: _this4.classNames('el-carousel__indicator', { 'is-active': index === activeIndex }), onMouseEnter: _this4.throttledIndicatorHover.bind(_this4, index), onClick: _this4.handleIndicatorClick.bind(_this4, index) }, React.createElement('button', { className: 'el-carousel__button' }) ); }) ) ); }; _createClass(Carousel, [{ key: 'iscard', get: function get() { var type = this.props.type; if (type) { return type === 'card' || type === 'flatcard'; } return false; } }]); return Carousel; }(Component); export default Carousel; Carousel.childContextTypes = { component: PropTypes.any }; Carousel.propTypes = { initialIndex: PropTypes.number, height: PropTypes.string, trigger: PropTypes.string, autoplay: PropTypes.bool, interval: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), indicatorPosition: PropTypes.string, indicator: PropTypes.bool, arrow: PropTypes.string, type: PropTypes.oneOf(['card', 'flatcard']), onChange: PropTypes.func }; Carousel.defaultProps = { initialIndex: 0, trigger: 'hover', autoplay: true, interval: 3000, indicator: true, arrow: 'hover' };
src/routes.js
jetshoji/Asia_Trip
import React from 'react'; import { Route, IndexRoute } from 'react-router'; import App from './components/app'; import Home from './components/home'; import AboutMe from './components/about_me/about_me'; import Videos from './components/videos/videos'; export default ( <Route path="/" component={App}> <IndexRoute component={Home}/> <Route path="about_me" component={AboutMe}/> <Route path="v_logs" component={Videos}/> </Route> )
src/index.js
henrybuilt/react-sticky-table
import React from 'react'; import styled, { css } from 'styled-components'; var getBorder = (props) => `${props.borderWidth === undefined ? '2px' : (props.borderWidth || '0px')} solid ${props.borderColor || '#e5e5e5'}` const Table = styled('div').attrs(() => ({ className: 'sticky-table-table' }))` white-space: nowrap; display: table; box-sizing: border-box; `; Table.displayName = 'Table'; const Cell = styled('div').attrs(() => ({ className: 'sticky-table-cell' }))` display: table-cell; box-sizing: border-box; padding: 0.5rem 0.75rem; background-color: #fff; `; Cell.displayName = 'Cell'; const Row = styled('div').attrs(() => ({ className: 'sticky-table-row' }))` display: table-row; `; Row.displayName = 'Row'; const Wrapper = styled('div').attrs(() => ({ className: 'sticky-table' }))` position: relative; overflow: auto; height: 100%; box-sizing: border-box; & ${Row}:not(:nth-last-child(-n+${props => (props.stickyFooterCount || 0) + 1})) ${Cell} { border-bottom: ${getBorder}; } & ${Row}:nth-child(${props => `-n+${props.stickyHeaderCount}`}) ${Cell} { position: -webkit-sticky; position: sticky; top: 0px; z-index: ${props => props.headerZ || 2}; } & ${Row}:nth-last-child(-n+${props => props.stickyFooterCount}) ${Cell} { position: -webkit-sticky; position: sticky; bottom: 0px; z-index: ${props => props.footerZ || 2}; border-top: ${getBorder}; } & ${Row} ${Cell}:nth-child(-n+${props => props.leftStickyColumnCount}) { position: -webkit-sticky; position: sticky; left: 0px; z-index: ${props => props.leftColumnZ || 2}; border-right: ${getBorder}; } & ${Row} ${Cell}:nth-last-child(-n+${props => props.rightStickyColumnCount}) { position: -webkit-sticky; position: sticky; right: 0px; z-index: ${props => props.rightColumnZ || 2}; border-left: ${getBorder}; } ${props => { var insets = props.stickyInsets; var styles = ''; var i; for (i = 0; i < insets.header.length; i++) { styles += `& ${Row}:nth-child(${i + 1}) ${Cell} { top: ${insets.header[i]}px; }` } for (i = 0; i < insets.footer.length; i++) { styles += `& ${Row}:nth-last-child(${i + 1}) ${Cell} { bottom: ${insets.footer[i]}px; }` } for (i = 0; i < insets.leftColumn.length; i++) { styles += `& ${Row} ${Cell}:nth-child(${i + 1}) { left: ${insets.leftColumn[i]}px; }` } for (i = 0; i < insets.rightColumn.length; i++) { styles += `& ${Row} ${Cell}:nth-last-child(${i + 1}) { right: ${insets.rightColumn[i]}px; }` } return css`${styles}`; }} & ${Row}:nth-child(-n+${props => props.stickyHeaderCount}) ${Cell}:nth-child(-n+${props => props.leftStickyColumnCount}) { z-index: ${props => Math.max(props.headerZ || 2, props.leftColumnZ || 2) + 1}; } & ${Row}:nth-child(-n+${props => props.stickyHeaderCount}) ${Cell}:nth-last-child(-n+${props => props.rightStickyColumnCount}) { z-index: ${props => Math.max(props.headerZ || 2, props.rightColumnZ || 2) + 1}; } & ${Row}:nth-last-child(-n+${props => props.stickyFooterCount}) ${Cell}:nth-child(-n+${props => props.leftStickyColumnCount}) { z-index: ${props => Math.max(props.footerZ || 2, props.leftColumnZ || 2) + 1}; } & ${Row}:nth-last-child(-n+${props => props.stickyFooterCount}) ${Cell}:nth-last-child(-n+${props => props.rightStickyColumnCount}) { z-index: ${props => Math.max(props.footerZ || 2, props.rightColumnZ || 2) + 1}; } `; Wrapper.displayName = 'Wrapper'; class StickyTable extends React.Component { state = { stickyInsets: { header: [], footer: [], leftColumn: [], rightColumn: [] } } componentDidMount() { this.considerSchedulingMultipleStickiesInterval(); } componentDidUpdate() { this.considerSchedulingMultipleStickiesInterval(); } componentWillUnmount() { this.clearMultipleStickiesInterval(); } //HINT schedule an interval to poll cell sizes for changes at 60fps //WARNING avoid doing this unless user has at least 2 stickies somewhere considerSchedulingMultipleStickiesInterval() { var p = this.props; var shouldSchedule = [ p.stickyHeaderCount, p.stickyFooterCount, p.leftStickyColumnCount, p.rightStickyColumnCount ].some(count => count > 1); //HINT clear out stickyInsets of a new interval won't be set if (!shouldSchedule && this.multipleStickiesInterval) { this.setState({stickyInsets: {header: [], footer: [], leftColumn: [], rightColumn: []}}); } this.clearMultipleStickiesInterval(); if (shouldSchedule) { this.multipleStickiesInterval = setInterval(this.checkForStickySizeChanges.bind(this), 1000 / 60); } } clearMultipleStickiesInterval() { if (this.multipleStickiesInterval) { clearInterval(this.multipleStickiesInterval); delete this.multipleStickiesInterval; } } checkForStickySizeChanges() { var s, stickyInsets = {}; var {props, tableNode} = this; var rowNodes = tableNode.querySelectorAll('.sticky-table-row'); var cellNodes = tableNode.querySelectorAll('.sticky-table-cell'); [ ['header', 'height', 'stickyHeaderCount'], ['footer', 'height', 'stickyFooterCount'], ['leftColumn', 'width', 'leftStickyColumnCount'], ['rightColumn', 'width', 'rightStickyColumnCount'] ].forEach(([stickyKey, sizeKey, countPropKey]) => { var insets = []; if (props[countPropKey] > 1) { insets = [0] var count = props[countPropKey]; var netInset = 0; // HINT we only want this loop for the second sticky and up for (s = 1; s < count; s++) { var node = undefined; switch (stickyKey) { case 'header': node = rowNodes[s - 1].childNodes[0]; break; case 'footer': node = rowNodes[rowNodes.length - s].childNodes[0]; break; case 'leftColumn': node = cellNodes[s - 1]; break; case 'rightColumn': node = cellNodes[cellNodes.length - s]; break; } if (node) { var boundingRect = node.getBoundingClientRect(); netInset += boundingRect[sizeKey]; } insets.push(netInset); } } stickyInsets[stickyKey] = insets; }); //HINT avoid a render unless there's actually a change if (JSON.stringify(stickyInsets) !== JSON.stringify(this.state.stickyInsets)) { this.setState({stickyInsets}); } } setTableNodeRef = tableNode => { this.tableNode = tableNode } render() { var {leftStickyColumnCount=1, stickyHeaderCount=1, wrapperRef, children, ...restProps} = this.props; return ( <Wrapper ref={wrapperRef} leftStickyColumnCount={leftStickyColumnCount} stickyHeaderCount={stickyHeaderCount} stickyInsets={this.state.stickyInsets} {...restProps} > <Table ref={this.setTableNodeRef}>{children}</Table> </Wrapper> ); } } export { StickyTable, Table, Row, Cell };
node_modules/react-router/es/Router.js
Rabbit884/reactapp
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } import invariant from 'invariant'; import React from 'react'; import _createTransitionManager from './createTransitionManager'; import { routes } from './InternalPropTypes'; import RouterContext from './RouterContext'; import { createRoutes } from './RouteUtils'; import { createRouterObject as _createRouterObject, assignRouterState } from './RouterUtils'; import warning from './routerWarning'; var _React$PropTypes = React.PropTypes, func = _React$PropTypes.func, object = _React$PropTypes.object; /** * A <Router> is a high-level API for automatically setting up * a router that renders a <RouterContext> with all the props * it needs each time the URL changes. */ var Router = React.createClass({ displayName: 'Router', propTypes: { history: object, children: routes, routes: routes, // alias for children render: func, createElement: func, onError: func, onUpdate: func, // PRIVATE: For client-side rehydration of server match. matchContext: object }, getDefaultProps: function getDefaultProps() { return { render: function render(props) { return React.createElement(RouterContext, props); } }; }, getInitialState: function getInitialState() { return { location: null, routes: null, params: null, components: null }; }, handleError: function handleError(error) { if (this.props.onError) { this.props.onError.call(this, error); } else { // Throw errors by default so we don't silently swallow them! throw error; // This error probably occurred in getChildRoutes or getComponents. } }, createRouterObject: function createRouterObject(state) { var matchContext = this.props.matchContext; if (matchContext) { return matchContext.router; } var history = this.props.history; return _createRouterObject(history, this.transitionManager, state); }, createTransitionManager: function createTransitionManager() { var matchContext = this.props.matchContext; if (matchContext) { return matchContext.transitionManager; } var history = this.props.history; var _props = this.props, routes = _props.routes, children = _props.children; !history.getCurrentLocation ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You have provided a history object created with history v4.x or v2.x ' + 'and earlier. This version of React Router is only compatible with v3 ' + 'history objects. Please change to history v3.x.') : invariant(false) : void 0; return _createTransitionManager(history, createRoutes(routes || children)); }, componentWillMount: function componentWillMount() { var _this = this; this.transitionManager = this.createTransitionManager(); this.router = this.createRouterObject(this.state); this._unlisten = this.transitionManager.listen(function (error, state) { if (error) { _this.handleError(error); } else { // Keep the identity of this.router because of a caveat in ContextUtils: // they only work if the object identity is preserved. assignRouterState(_this.router, state); _this.setState(state, _this.props.onUpdate); } }); }, /* istanbul ignore next: sanity check */ componentWillReceiveProps: function componentWillReceiveProps(nextProps) { process.env.NODE_ENV !== 'production' ? warning(nextProps.history === this.props.history, 'You cannot change <Router history>; it will be ignored') : void 0; process.env.NODE_ENV !== 'production' ? warning((nextProps.routes || nextProps.children) === (this.props.routes || this.props.children), 'You cannot change <Router routes>; it will be ignored') : void 0; }, componentWillUnmount: function componentWillUnmount() { if (this._unlisten) this._unlisten(); }, render: function render() { var _state = this.state, location = _state.location, routes = _state.routes, params = _state.params, components = _state.components; var _props2 = this.props, createElement = _props2.createElement, render = _props2.render, props = _objectWithoutProperties(_props2, ['createElement', 'render']); if (location == null) return null; // Async match // Only forward non-Router-specific props to routing context, as those are // the only ones that might be custom routing context props. Object.keys(Router.propTypes).forEach(function (propType) { return delete props[propType]; }); return render(_extends({}, props, { router: this.router, location: location, routes: routes, params: params, components: components, createElement: createElement })); } }); export default Router;
www/src/pages/index.js
TaitoUnited/taito-cli
import React from 'react'; import styled from '@emotion/styled'; import { css } from '@emotion/react'; import { Link } from 'gatsby'; import theme from '../theme'; import { media } from '../utils'; import SEO from '../components/SEO'; import Spacing from '../components/Spacing'; import Navigation from '../components/Navigation'; import Terminal from '../components/Terminal'; export default () => ( <Wrapper> <SEO /> <Navigation isHome /> <Hero> <Title> <strong>Taito</strong> &nbsp;CLI </Title> <Spacing dir="y" /> <Slogan>An extensible toolkit for DevOps and NoOps.</Slogan> <Spacing dir="y" amount={24} /> <Actions> <Button to="/docs">Get started</Button> <Spacing amount={32} sm={{ amount: 16 }} /> <Button to="/tutorial" variant="light"> See the tutorial </Button> </Actions> </Hero> <Content> <Section> <SectionText> <SectionTitle>Standard command set</SectionTitle> <p> Use the same simple command set from project to project no matter the technology or infrastructure. Easily manage your containers, functions, databases, object storages, and legacy applications wherever they are deployed. Just add a taito configuration file to your project, and you’re good to go. </p> </SectionText> <Spacing amount={24} sm={{ dir: 'y', amount: 32 }} /> <Terminal lines={[ [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>open client:test</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>status:test</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>logs:server:test</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>db copy:dev test</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>db connect:test</Terminal.LineSuffix>, ], ]} /> </Section> <Divider /> <Section> <SectionText> <SectionTitle>Any cloud, hybrid cloud, multicloud</SectionTitle> <p> Deploy your applications to multiple platforms without any extra hassle. Leverage public cloud for fluent collaboration between in-house and external personnel during development. Deploy to on-premises to meet the extra security requirements of a production environment. </p> </SectionText> <Spacing amount={24} sm={{ dir: 'y', amount: 32 }} /> <Terminal lines={[ [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>zone create gcp</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>zone create vmware</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix> project create full-stack-template </Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>env apply:dev</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>env apply:test</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>env apply:canary</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>env apply:prod</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>env merge:dev canary</Terminal.LineSuffix>, ], ]} /> </Section> <Divider /> <Section> <SectionText> <SectionTitle>Simple to use</SectionTitle> <p> Many daily tasks, such as connecting to a database, can be extremely tedious. Before actually connecting to the database, you have to locate the correct database cluster, the correct database in it, and the credentials for database access. You may also have to establish a secure tunnel by using a proxy. </p> <p>With Taito CLI you achieve all this with a one simple command.</p> </SectionText> <Spacing amount={24} sm={{ dir: 'y', amount: 32 }} /> <Terminal lines={[ [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>db connect:test</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.grey[500]}> # </Terminal.LinePrefix>, <Terminal.LineSuffix>Without Taito CLI:</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> cloud_sql_proxy </Terminal.LinePrefix>, <Terminal.LineSuffix> -instances=acme-zone:europe-west1:acme-postgres=tcp:127.0.0.1:5001 </Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> psql </Terminal.LinePrefix>, <Terminal.LineSuffix> psql -h 127.0.0.1 -p 5001 -d acme_chat_test -U acme_chat_test </Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> Password: </Terminal.LinePrefix>, <Terminal.LineSuffix>******************</Terminal.LineSuffix>, ], ]} /> </Section> <Divider /> <Section> <SectionText> <SectionTitle>No lock-in</SectionTitle> <p> Taito CLI is a lightweight wrapper that reduces technology and vendor lock-in by providing a standard command set on top of various platform specific tools. You just run a simple taito command, and Taito CLI runs a number of platform or technology specific commands under the hood based on your configuration. </p> <p> However, you can use all the tools also directly without Taito CLI. Therefore you can stop using Taito CLI at any time, if you like. There is no lock-in with Taito CLI. </p> </SectionText> <Spacing amount={24} sm={{ dir: 'y', amount: 32 }} /> <Terminal lines={[ [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>--verbose status:dev</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> [kubectl] </Terminal.LinePrefix>, ], [ <Terminal.LinePrefix color={theme.info}> kubectl </Terminal.LinePrefix>, <Terminal.LineSuffix> config set-context acme-chat-dev --cluster=gke_my-gcp_europe-west1-c_my-kube1 --user=gke_my-gcp_europe-west1-c_my-kube1 --namespace=acme-chat-dev </Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> kubectl </Terminal.LinePrefix>, <Terminal.LineSuffix> config use-context acme-chat-dev </Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> kubectl </Terminal.LinePrefix>, <Terminal.LineSuffix>get cronjobs</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> kubectl </Terminal.LinePrefix>, <Terminal.LineSuffix>get pods</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> kubectl </Terminal.LinePrefix>, <Terminal.LineSuffix>top pod</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> kubectl </Terminal.LinePrefix>, <Terminal.LineSuffix>{`get pods -o jsonpath="{.items[*].spec.containers[*].image}" | tr -s '[[:space:]]' '\n' | sort | uniq`}</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix color={theme.info}> [helm] </Terminal.LinePrefix>, ], [ <Terminal.LinePrefix color={theme.info}> helm </Terminal.LinePrefix>, <Terminal.LineSuffix> list --namespace acme-chat-dev </Terminal.LineSuffix>, ], ]} /> </Section> <Divider /> <Section> <SectionText> <SectionTitle>All tools included</SectionTitle> <p> Working with modern hybrid cloud environments requires lots of tools. Taito CLI Docker container image contains all the tools you need, and you can upgrade it anytime by running: </p> <InlineCode>taito upgrade</InlineCode> <p> And if you need something special, it is very easy to customize the Taito CLI image with your own requirements. </p> </SectionText> <Spacing amount={24} sm={{ dir: 'y', amount: 32 }} /> <Terminal lines={[ [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>-- terraform apply</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix> -- kubectl get pods --namespace acme-chat-dev </Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix> -- aws ec2 describe-instances </Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>-- az network nic list</Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix> -- gcloud dns managed-zones list </Terminal.LineSuffix>, ], ]} /> </Section> <Divider /> <Section> <SectionText> <SectionTitle>Extensible</SectionTitle> <p> Add Taito CLI support for any technology by implementing a Taito CLI plugin. Create custom commands and share them with your colleagues as Taito CLI extensions. Implement project specific Taito CLI commands with npm or make. </p> </SectionText> <Spacing amount={24} sm={{ dir: 'y', amount: 32 }} /> <Terminal lines={[ [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix> basket add pizza margherita </Terminal.LineSuffix>, ], [ <Terminal.LinePrefix>taito</Terminal.LinePrefix>, <Terminal.LineSuffix>hours add 6.5</Terminal.LineSuffix>, ], ]} /> </Section> <Divider /> <Section> <SectionText> <SectionTitle>Uniform conventions</SectionTitle> <p> Maintain good and uniform conventions by providing reusable infrastructure templates and project templates. Use the same conventions no matter the technology or infrastructure. </p> <p> Customize software development workflows for your organization with custom Taito CLI extensions. </p> </SectionText> <Spacing amount={24} sm={{ dir: 'y', amount: 32 }} /> <Terminal lines={[ [ <Terminal.LinePrefix color={theme.info}> nano </Terminal.LinePrefix>, <Terminal.LineSuffix> ~/.taito/taito-config.sh </Terminal.LineSuffix>, ], <span> taito_global_extensions="[email protected]:MyOrg/myorg-extension.git" </span>, <span>taito_global_plugins="myorg-git-global ..."</span>, ]} /> </Section> </Content> </Wrapper> ); const Wrapper = styled.div` width: 100%; height: 100%; & p { line-height: 1.5; } `; const Hero = styled.div` padding-top: 50px; display: flex; flex-direction: column; justify-content: center; align-items: center; height: 400px; background-color: ${(props) => props.theme.primary[500]}; ${media.sm` height: auto; padding: 88px 16px 32px 16px; justify-content: flex-end; text-align: center; `} `; const Title = styled.h1` font-size: 48px; font-weight: 200; color: #fff; margin: 0px; ${media.sm` font-size: 32px; `} `; const Slogan = styled.h2` font-size: 20px; font-weight: 400; color: #fff; margin: 0; ${media.sm` font-size: 18px; `} `; const Actions = styled.div` display: flex; flex-direction: row; `; const Button = styled(Link)` padding: 8px 24px; background-color: ${(props) => props.theme.primary[300]}; color: ${(props) => props.theme.primary[900]}; text-align: center; text-decoration: none; border: none; border-radius: 99px; font-weight: 500; box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.2); ${(props) => props.variant === 'light' && css` background-color: #fff; color: ${(props) => props.theme.primary[500]}; `} `; const Content = styled.div` max-width: 1100px; background-color: #fff; border-radius: 8px; padding: 23px; min-height: 100vh; box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.2); margin-top: -48px; margin-bottom: 32px; margin-right: auto; margin-left: auto; ${media.sm` padding: 16px; margin-top: 0px; box-shadow: none; `} `; const Section = styled.section` display: flex; flex-direction: row; ${media.sm` flex-direction: column; align-items: center; `} `; const Divider = styled.div` background-color: ${(props) => props.theme.grey[200]}; height: 1px; width: 100%; margin: 64px 0px; ${media.sm` margin: 32px 0px; `} `; const SectionTitle = styled.h3` font-size: 24px; margin-top: 0px; margin-bottom: 16px; color: ${(props) => props.theme.black}; `; const SectionText = styled.div` flex: 1; `; const InlineCode = styled.div` border-radius: 6px; background-color: ${(props) => props.theme.grey[200]}; color: ${(props) => props.theme.grey[700]}; padding: 8px 12px; font-family: Consolas, Menlo, Monaco, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', 'Courier New', Courier, monospace; font-size: 14px; `;
gatsby/src/layouts/index.js
CodeFarmCamp/codefarmcamp.com
import React from 'react' import PropTypes from 'prop-types' import Link from 'gatsby-link' import Helmet from 'react-helmet' import './index.css' const Header = () => ( <div style={{ background: 'rebeccapurple', marginBottom: '1.45rem', }} > <div style={{ margin: '0 auto', maxWidth: 960, padding: '1.45rem 1.0875rem', }} > <h1 style={{ margin: 0 }}> <Link to="/" style={{ color: 'white', textDecoration: 'none', }} > Gatsby </Link> </h1> </div> </div> ) const TemplateWrapper = ({ children }) => ( <div> <Helmet title="Gatsby Default Starter" meta={[ { name: 'description', content: 'Sample' }, { name: 'keywords', content: 'sample, something' }, ]} /> <Header /> <div style={{ margin: '0 auto', maxWidth: 960, padding: '0px 1.0875rem 1.45rem', paddingTop: 0, }} > {children()} </div> </div> ) TemplateWrapper.propTypes = { children: PropTypes.func, } export default TemplateWrapper
app/components/VacancyDetails/index.js
Ratholien/JobReact
import React from 'react'; import { Paper, TextField } from 'material-ui'; class VacancyDetails extends React.Component { constructor(props) { super(props); this.state = { fields: ['op1', 'op2', 'op3'], }; } render() { return ( <Paper className="vacancyDetails"> {this.state.fields.map(field => <TextField value={field} id={field} key={field} fullWidth />)} </Paper> ); } } export default VacancyDetails;
docs/src/IntroductionPage.js
adampickeral/react-bootstrap
import React from 'react'; import CodeExample from './CodeExample'; import NavMain from './NavMain'; import PageHeader from './PageHeader'; import PageFooter from './PageFooter'; const IntroductionPage = React.createClass({ render() { return ( <div> <NavMain activePage="introduction" /> <PageHeader title="Introduction" subTitle="The most popular front-end framework, rebuilt for React."/> <div className="container bs-docs-container"> <div className="row"> <div className="col-md-9" role="main"> <div className="bs-docs-section"> <p className="lead"> React-Bootstrap is a library of reuseable front-end components. You'll get the look-and-feel of Twitter Bootstrap, but with much cleaner code, via Facebook's React.js framework. </p> <p> Let's say you want a small button that says "Something", to trigger the function someCallback. If you were writing a native application, you might write something like: </p> <div className="highlight"> <CodeExample mode="javascript" codeText={ `button(size=SMALL, color=GREEN, text="Something", onClick=someCallback)` } /> </div> <p> With the most popular web front-end framework, Twitter Bootstrap, you'd write this in your HTML: </p> <div className="highlight"> <CodeExample mode="htmlmixed" codeText={ `<button id="something-btn" type="button" class="btn btn-success btn-sm"> Something </button>` } /> </div> <p> And something like <code className="js"> $('#something-btn').click(someCallback); </code> in your Javascript. </p> <p> By web standards this is quite nice, but it's still quite nasty. React-Bootstrap lets you write this: </p> <div className="highlight"> <CodeExample mode="javascript" codeText={ `<Button bsStyle="success" bsSize="small" onClick={someCallback}> Something </Button>` } /> </div> <p> The HTML/CSS implementation details are abstracted away, leaving you with an interface that more closely resembles what you would expect to write in other programming languages. </p> <h2>A better Bootstrap API using React.js</h2> <p> The Bootstrap code is so repetitive because HTML and CSS do not support the abstractions necessary for a nice library of components. That's why we have to write <code>btn</code> three times, within an element called <code>button</code>. </p> <p> <strong> The React.js solution is to write directly in Javascript. </strong> React takes over the page-rendering entirely. You just give it a tree of Javascript objects, and tell it how state is transmitted between them. </p> <p> For instance, we might tell React to render a page displaying a single button, styled using the handy Bootstrap CSS: </p> <div className="highlight"> <CodeExample mode="javascript" codeText={ `var button = React.DOM.button({ className: "btn btn-lg btn-success", children: "Register" }); React.render(button, mountNode);` } /> </div> <p> But now that we're in Javascript, we can wrap the HTML/CSS, and provide a much better API: </p> <div className="highlight"> <CodeExample mode="javascript" codeText={ `var button = ReactBootstrap.Button({ bsStyle: "success", bsSize: "large", children: "Register" }); React.render(button, mountNode);` } /> </div> <p> React-Bootstrap is a library of such components, which you can also easily extend and enhance with your own functionality. </p> <h3>JSX Syntax</h3> <p> While each React component is really just a Javascript object, writing tree-structures that way gets tedious. React encourages the use of a syntactic-sugar called JSX, which lets you write the tree in an HTML-like syntax: </p> <div className="highlight"> <CodeExample mode="javascript" codeText={ `var buttonGroupInstance = ( <ButtonGroup> <DropdownButton bsStyle="success" title="Dropdown"> <MenuItem key="1">Dropdown link</MenuItem> <MenuItem key="2">Dropdown link</MenuItem> </DropdownButton> <Button bsStyle="info">Middle</Button> <Button bsStyle="info">Right</Button> </ButtonGroup> ); React.render(buttonGroupInstance, mountNode);` } /> </div> <p> Some people's first impression of React.js is that it seems messy to mix Javascript and HTML in this way. However, compare the code required to add a dropdown button in the example above to the <a href="http://getbootstrap.com/javascript/#dropdowns"> Bootstrap Javascript</a> and <a href="http://getbootstrap.com/components/#btn-dropdowns"> Components</a> documentation for creating a dropdown button. The documentation is split in two because you have to implement the component in two places in your code: first you must add the HTML/CSS elements, and then you must call some Javascript setup code to wire the component together. </p> <p> The React-Bootstrap component library tries to follow the React.js philosophy that a single piece of functionality should be defined in a single place. View the current React-Bootstrap library on the <a href="/components.html">components page</a>. </p> </div> </div> </div> </div> <PageFooter /> </div> ); } }); export default IntroductionPage;
examples/cra/src/index.js
styleguidist/react-styleguidist
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import './index.css'; ReactDOM.render(<App />, document.getElementById('root'));
test/regressions/tests/List/SimpleListItem.js
AndriusBil/material-ui
// @flow import React from 'react'; import { ListItem, ListItemText } from 'material-ui/List'; export default function SimpleListItem() { return ( <div style={{ background: '#fff', width: 300 }}> <ListItem> <ListItemText primary="Primary" /> </ListItem> <ListItem> <ListItemText primary="Primary" secondary="Secondary" /> </ListItem> <ListItem dense> <ListItemText primary="Primary" /> </ListItem> <ListItem dense> <ListItemText primary="Primary" secondary="Secondary" /> </ListItem> </div> ); }
src/libraries/notResolved.js
kjg531/react-bluekit
import React from 'react'; export default (data) => () => (<div>Unable to resolve: {JSON.stringify(data)}</div>)
examples/js/nextjs/lib/bugsnag.js
bugsnag/bugsnag-js
import React from 'react' import Bugsnag from '@bugsnag/js' import BugsnagPluginReact from '@bugsnag/plugin-react' import getConfig from 'next/config' const { serverRuntimeConfig, publicRuntimeConfig } = getConfig() Bugsnag.start({ apiKey: serverRuntimeConfig.BUGSNAG_API_KEY || publicRuntimeConfig.BUGSNAG_API_KEY, plugins: [new BugsnagPluginReact(React)] }) export default Bugsnag
src/views/icons/AutomationsIcon.js
physiii/home-gateway
import React from 'react'; import IconBase from './IconBase.js'; export const AutomationsIcon = (props) => ( <IconBase {...props} viewBox="0 0 20 22"> <path d="M16.54185892 18.39352399L15.76077 12.74640967l6.06217782 3.5-5.28108891 2.14711432zm1.3839746-4.39711432l1.7320508 1c2.75-4.76313972 1.10288569-10.91025404-3.66025403-13.66025404-2.42487114-1.4-5.13993464-1.69737205-7.59878037-1.03852633l.51243556 1.91243557c1.91243557-.51243557 4.09448638-.29185843 6.0863448.85814157 3.81051178 2.2 5.12820324 7.11769145 2.92820324 10.92820323zM5.45340067 1.59929634l.78108891 5.64711431-6.06217782-3.5 5.28108891-2.14711431zm-1.3839746 4.39711431l-1.7320508-1c-2.75 4.76313972-1.10288569 10.91025404 3.66025403 13.66025404 2.42487113 1.4 5.13993464 1.69737206 7.59878037 1.03852633l-.51243556-1.91243557c-1.91243557.51243557-4.09448638.29185843-6.0863448-.85814157-3.81051178-2.2-5.12820324-7.11769145-2.92820324-10.92820323z" /> <circle cx="11" cy="10" r="4" /> </IconBase> ); export default AutomationsIcon;
client/components/User/AddUserComponent.js
jeggy/trialbee-test
import React from 'react'; import { Button } from 'react-mdl'; import UserDialog from './UserDialogComponent'; import styles from './User.scss'; export default class User extends React.Component { constructor(props) { super(props); this.state = { dialog: false }; } static propTypes = { viewer: React.PropTypes.object.isRequired }; render() { return ( <div> <Button colored onClick={() => { this.setState({dialog: !this.state.dialog}); }} raised ripple className={styles.whiteText} >Add new User</Button> <UserDialog show={this.state.dialog} viewer={this.props.viewer} handleState={() => {this.setState({dialog: !this.state.dialog})}} /> </div> ); } }
admin/client/App/screens/List/components/UpdateForm.js
danielmahon/keystone
import React from 'react'; import Select from 'react-select'; import { findDOMNode } from 'react-dom'; import assign from 'object-assign'; import { Fields } from 'FieldTypes'; import InvalidFieldType from '../../../shared/InvalidFieldType'; import { plural } from '../../../../utils/string'; import { BlankState, Button, Form, Modal } from '../../../elemental'; var UpdateForm = React.createClass({ displayName: 'UpdateForm', propTypes: { isOpen: React.PropTypes.bool, itemIds: React.PropTypes.array, list: React.PropTypes.object, onCancel: React.PropTypes.func, }, getDefaultProps () { return { isOpen: false, }; }, getInitialState () { return { fields: [], }; }, componentDidMount () { this.doFocus(); }, componentDidUpdate () { this.doFocus(); }, doFocus () { if (this.refs.focusTarget) { findDOMNode(this.refs.focusTarget).focus(); } }, getOptions () { const { fields } = this.props.list; return Object.keys(fields).map(key => ({ value: fields[key].path, label: fields[key].label })); }, getFieldProps (field) { var props = assign({}, field); props.value = this.state.fields[field.path]; props.values = this.state.fields; props.onChange = this.handleChange; props.mode = 'create'; props.key = field.path; return props; }, updateOptions (fields) { this.setState({ fields: fields, }, this.doFocus); }, handleChange (value) { console.log('handleChange:', value); }, handleClose () { this.setState({ fields: [], }); this.props.onCancel(); }, renderFields () { const { list } = this.props; const { fields } = this.state; const formFields = []; let focusRef; fields.forEach((fieldOption) => { const field = list.fields[fieldOption.value]; if (typeof Fields[field.type] !== 'function') { formFields.push(React.createElement(InvalidFieldType, { type: field.type, path: field.path, key: field.path })); return; } var fieldProps = this.getFieldProps(field); if (!focusRef) { fieldProps.ref = focusRef = 'focusTarget'; } formFields.push(React.createElement(Fields[field.type], fieldProps)); }); const fieldsUI = formFields.length ? formFields : ( <BlankState heading="Choose a field above to begin" style={{ padding: '3em 2em' }} /> ); return ( <div style={{ borderTop: '1px dashed rgba(0,0,0,0.1)', marginTop: 20, paddingTop: 20 }}> {fieldsUI} </div> ); }, renderForm () { const { itemIds, list } = this.props; const itemCount = plural(itemIds, ('* ' + list.singular), ('* ' + list.plural)); const formAction = `${Keystone.adminPath}/${list.path}`; return ( <Form layout="horizontal" action={formAction} noValidate="true"> <Modal.Header onClose={this.handleClose} showCloseButton text={'Update ' + itemCount} /> <Modal.Body> <Select key="field-select" multi onChange={this.updateOptions} options={this.getOptions()} ref="initialFocusTarget" value={this.state.fields} /> {this.renderFields()} </Modal.Body> <Modal.Footer> <Button color="primary" submit>Update</Button> <Button color="cancel" variant="link" onClick={this.handleClose}>Cancel</Button> </Modal.Footer> </Form> ); }, render () { return ( <Modal.Dialog isOpen={this.props.isOpen} onClose={this.handleClose} backdropClosesModal> {this.renderForm()} </Modal.Dialog> ); }, }); module.exports = UpdateForm;
app/javascript/mastodon/features/community_timeline/index.js
MastodonCloud/mastodon
import React from 'react'; import { connect } from 'react-redux'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import PropTypes from 'prop-types'; import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; import { expandCommunityTimeline } from '../../actions/timelines'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import ColumnSettingsContainer from './containers/column_settings_container'; import { connectCommunityStream } from '../../actions/streaming'; const messages = defineMessages({ title: { id: 'column.community', defaultMessage: 'Local timeline' }, }); const mapStateToProps = (state, { onlyMedia, columnId }) => { const uuid = columnId; const columns = state.getIn(['settings', 'columns']); const index = columns.findIndex(c => c.get('uuid') === uuid); return { hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0, onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']), }; }; @connect(mapStateToProps) @injectIntl export default class CommunityTimeline extends React.PureComponent { static contextTypes = { router: PropTypes.object, }; static defaultProps = { onlyMedia: false, }; static propTypes = { dispatch: PropTypes.func.isRequired, columnId: PropTypes.string, intl: PropTypes.object.isRequired, hasUnread: PropTypes.bool, multiColumn: PropTypes.bool, onlyMedia: PropTypes.bool, }; handlePin = () => { const { columnId, dispatch, onlyMedia } = this.props; if (columnId) { dispatch(removeColumn(columnId)); } else { dispatch(addColumn('COMMUNITY', { other: { onlyMedia } })); } } handleMove = (dir) => { const { columnId, dispatch } = this.props; dispatch(moveColumn(columnId, dir)); } handleHeaderClick = () => { this.column.scrollTop(); } componentDidMount () { const { dispatch, onlyMedia } = this.props; dispatch(expandCommunityTimeline({ onlyMedia })); this.disconnect = dispatch(connectCommunityStream({ onlyMedia })); } componentDidUpdate (prevProps) { if (prevProps.onlyMedia !== this.props.onlyMedia) { const { dispatch, onlyMedia } = this.props; this.disconnect(); dispatch(expandCommunityTimeline({ onlyMedia })); this.disconnect = dispatch(connectCommunityStream({ onlyMedia })); } } componentWillUnmount () { if (this.disconnect) { this.disconnect(); this.disconnect = null; } } setRef = c => { this.column = c; } handleLoadMore = maxId => { const { dispatch, onlyMedia } = this.props; dispatch(expandCommunityTimeline({ maxId, onlyMedia })); } render () { const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props; const pinned = !!columnId; return ( <Column ref={this.setRef}> <ColumnHeader icon='users' active={hasUnread} title={intl.formatMessage(messages.title)} onPin={this.handlePin} onMove={this.handleMove} onClick={this.handleHeaderClick} pinned={pinned} multiColumn={multiColumn} > <ColumnSettingsContainer columnId={columnId} /> </ColumnHeader> <StatusListContainer trackScroll={!pinned} scrollKey={`community_timeline-${columnId}`} timelineId={`community${onlyMedia ? ':media' : ''}`} onLoadMore={this.handleLoadMore} emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />} /> </Column> ); } }
src/components/flash/FlashMessagesList.js
AleksandrRogachev94/chat-vote-go-frontend
import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import FlashMessage from './FlashMessage' import { deleteFlashMessage } from '../../actions/flashMessages' const FlashMessagesList = ({ messages, deleteFlashMessage }) => { const htmlMessages = messages.map(msg => ( <FlashMessage key={msg.id} message={msg} deleteFlashMessage={deleteFlashMessage} /> )) return ( <div> {htmlMessages} </div> ) } FlashMessagesList.propTypes = { messages: PropTypes.array.isRequired, deleteFlashMessage: PropTypes.func.isRequired } const mapStateToProps = (state) => ({ messages: state.flashMessages }) export default connect(mapStateToProps, { deleteFlashMessage })(FlashMessagesList)
fixtures/ssr/src/index.js
maxschmeling/react
import React from 'react'; import {hydrate} from 'react-dom'; import App from './components/App'; hydrate(<App assets={window.assetManifest} />, document);
tp-3/juan-pablo-gonzalez/src/shared/components/columnsSelector/components/columnList/ColumnList.js
jpgonzalezquinteros/sovos-reactivo-2017
import React from 'react'; import PropTypes from 'prop-types'; import { VisibleIcon, HiddenIcon } from '../../../svgIcons/SvgIcons'; // eslint-disable-line import/no-extraneous-dependencies import SovosTooltip from '../../../../../shared/components/sovos-tooltip/SovosTooltip'; import { violet } from '../../../../../theme/PhoenixColors'; import ColumnListItem from './components/ColumnListItem'; import { ItemTypes, DragSourceComponent, WithDragDropContext } from '../../../../../shared/components/dragAndDrop'; const ColumnList = ({ visibleColumns, hiddenColumns, onShowColumn, onHideColumn, onDrop }) => { let switchInfo = {}; const onDragAndDrop = (dragInfo) => { switchInfo = { origin: { isEnabled: dragInfo.origin, position: dragInfo.key }, target: { isEnabled: dragInfo.container, position: dragInfo.target } }; }; const iconStyle = { height: 16, width: 16 }; const getColumnItem = (column, index, visible) => ( <div className="column-selector__column-row" key={ column.key }> <div> <SovosTooltip id={ `col-${index}` } label={ column.label }> <DragSourceComponent id={ index } onEndDrag={ () => { onDrop(switchInfo); } } itemType={ ItemTypes.DNDCOLUMNSELECTOR } elementInfo={ { isVisible: visible } } cantDrag={ visibleColumns.length === 1 } > <ColumnListItem column={ column } visible={ visible } onShowColumn={ onShowColumn } onHideColumn={ onHideColumn } onDragAndDrop={ onDragAndDrop } /> </DragSourceComponent> </SovosTooltip> </div> <div className="column-selector__icon-container"> { visible ? <VisibleIcon style={ iconStyle } color={ violet } onTouchTap={ () => { onHideColumn(column); } } /> : <HiddenIcon style={ iconStyle } color="#7d7d7d" onTouchTap={ () => { onShowColumn(column); } } /> } </div> </div> ); return ( <div className="column-selector__columns-container"> <div className="column-selector__column-group"> { visibleColumns.map((columnName, index) => getColumnItem(columnName, index, true)) } </div> <hr /> <div className="column-selector__column-group"> { hiddenColumns.map((columnName, index) => getColumnItem(columnName, index, false)) } </div> </div> ); }; ColumnList.propTypes = { visibleColumns: PropTypes.arrayOf(PropTypes.object).isRequired, hiddenColumns: PropTypes.arrayOf(PropTypes.object), onHideColumn: PropTypes.func.isRequired, onShowColumn: PropTypes.func.isRequired, onDrop: PropTypes.func.isRequired }; ColumnList.defaultProps = { hiddenColumns: [], }; export default WithDragDropContext(ColumnList);
src/components/SearchResult/SearchResult.js
aos2006/tesDeploy
import React from 'react'; import { ProductItem } from 'components/Product'; import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './searchResult.css'; export const SearchResult = ({ quantity, list }) => ( <div className={s.root}> <h3 className={s.title}>{`${quantity} Searched result`}</h3> {list.map(() => <ProductItem classes={{ root: s.itemList }} />)} </div> ); SearchResult.defaultProps = { quantity: 0, list: [{}, {}], }; export default withStyles(s)(SearchResult);
app/components/IssueIcon/index.js
AnhHT/react-boilerplate
import React from 'react'; function IssueIcon(props) { return ( <svg height="1em" width="0.875em" className={props.className} > <path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7S10.14 13.7 7 13.7 1.3 11.14 1.3 8s2.56-5.7 5.7-5.7m0-1.3C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7S10.86 1 7 1z m1 3H6v5h2V4z m0 6H6v2h2V10z" /> </svg> ); } IssueIcon.propTypes = { className: React.PropTypes.string, }; export default IssueIcon;
node_modules/react-bootstrap/es/MediaBody.js
Chen-Hailin/iTCM.github.io
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 elementType from 'react-prop-types/lib/elementType'; import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils'; var propTypes = { componentClass: elementType }; var defaultProps = { componentClass: 'div' }; var MediaBody = function (_React$Component) { _inherits(MediaBody, _React$Component); function MediaBody() { _classCallCheck(this, MediaBody); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } MediaBody.prototype.render = function render() { var _props = this.props; var Component = _props.componentClass; var className = _props.className; var props = _objectWithoutProperties(_props, ['componentClass', 'className']); var _splitBsProps = splitBsProps(props); var bsProps = _splitBsProps[0]; var elementProps = _splitBsProps[1]; var classes = getClassSet(bsProps); return React.createElement(Component, _extends({}, elementProps, { className: classNames(className, classes) })); }; return MediaBody; }(React.Component); MediaBody.propTypes = propTypes; MediaBody.defaultProps = defaultProps; export default bsClass('media-body', MediaBody);
src/client.js
dailymotion/react-collider
import React from 'react' import Router from 'react-router' import collider from './reactCollider' import {merge} from 'ramda' const defaultOptions = { fetch: null } // Client side rendering var renderPage = function reanderPage(Handler, data) { React.render(React.createElement(Handler, {data: data}), document) } export default function client(routes, options) { options = merge(defaultOptions, options) var fetchHandler = typeof options.fetchHandler === 'function' ? options.fetchHandler : null collider(routes, Router.HistoryLocation, fetchHandler, function(Handler, data) { renderPage(Handler, data) }) }
src/components/GridButton.js
pixelcanvasio/pixelcanvas
/** * Created by arkeros on 31/5/17. * * @flow */ import React from 'react'; import { connect } from 'react-redux'; import FaTh from 'react-icons/lib/fa/th'; import FloatingActionButton from './FloatingActionButton'; import { toggleGrid } from '../actions'; const GridButton = ({ onToggleGrid }) => ( <FloatingActionButton onClick={onToggleGrid}> <FaTh /> </FloatingActionButton> ); // TODO simplify... function mapStateToProps(state: State) { return {}; } function mapDispatchToProps(dispatch) { return { open() { dispatch(toggleGrid()); }, }; } export default connect(mapStateToProps, mapDispatchToProps)(GridButton);
src/routes/About/components/AboutView.js
zhangjianguo1500/f01
import React from 'react' import DuckImage from '../assets/Duck.jpg' import './AboutView.scss' import '../../../styles/font.scss' export const AboutView = () => ( <div> <h4>About Web!</h4> <ul> <li> <a href = "#">添加</a> </li> <li> <a href = "#">添加1</a> </li> </ul> <img alt='This is a about web site, because Redux!' className='duck' src={DuckImage} /> <div> <i className='fi-view'></i> </div> </div> ) export default AboutView
src/js/components/icons/base/Link.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}-link`, className, { [`${CLASS_ROOT}--${size}`]: size, [`${CLASS_ROOT}--responsive`]: responsive, [`${COLOR_INDEX}-${colorIndex}`]: colorIndex } ); a11yTitle = a11yTitle || Intl.getMessage(intl, 'link'); const restProps = Props.omit(this.props, Object.keys(Icon.propTypes)); return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fill="none" stroke="#000" strokeWidth="2" d="M16.1251884,2.42026615 C16.9095797,1.63587482 18.1818354,1.63638083 18.9643331,2.41887857 L21.5811214,5.03566688 C22.3647464,5.81929188 22.3723943,7.08215115 21.5797338,7.87481161 L17.8748116,11.5797338 C17.0904203,12.3641252 15.8181646,12.3636192 15.0356669,11.5811214 L12.4188786,8.96433312 C11.6352536,8.18070812 11.6276057,6.91784885 12.4202662,6.12518839 L16.1251884,2.42026615 Z M6.12518839,12.4202662 C6.90957973,11.6358748 8.18183538,11.6363808 8.96433312,12.4188786 L11.5811214,15.0356669 C12.3647464,15.8192919 12.3723943,17.0821512 11.5797338,17.8748116 L7.87481161,21.5797338 C7.09042027,22.3641252 5.81816462,22.3636192 5.03566688,21.5811214 L2.41887857,18.9643331 C1.63525357,18.1807081 1.6276057,16.9178488 2.42026615,16.1251884 L6.12518839,12.4202662 Z M7,17 L17,7"/></svg>; } }; Icon.contextTypes = { intl: PropTypes.object }; Icon.defaultProps = { responsive: true }; Icon.displayName = 'Link'; Icon.icon = true; Icon.propTypes = { a11yTitle: PropTypes.string, colorIndex: PropTypes.string, size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']), responsive: PropTypes.bool };
src/serverRender.js
wahengchang/react-redux-boilerplate
import 'babel-polyfill' import React from 'react' import ReactDOMServer from 'react-dom/server' import { createStore, compose, applyMiddleware } from 'redux' import thunk from 'redux-thunk' import _reducers from './reducers' import { Provider } from 'react-redux'; import matchConfig from './matchConfig' import { StaticRouter, Route, Switch, matchPath } from 'react-router-dom' function serverRender(req, res) { const composeEnhancers = process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose const store = createStore( _reducers, composeEnhancers(applyMiddleware(thunk)) ) let initState; matchConfig.some(route => { const match = matchPath(req.url, route) if (match) { initState = route.initState } return match }) store.dispatch(initState(store, req, res)) .then(() => { renderStoreRouter(store, req, res) }) } function renderStoreRouter(store, req, res) { const context = {} const componentStr = ReactDOMServer.renderToString( <Provider store={store}> <StaticRouter location={req.url} context={context}> <Switch> { matchConfig.map((route, index) => <Route key={`route${index}`} {...route} />) } </Switch> </StaticRouter> </Provider> ) res.send(renderFullPage(componentStr, store.getState())) } function renderFullPage(html, preloadedState) { let vendorJS = '' let bundleCSS = '' if (process.env.NODE_ENV === 'development') { // do something } else { bundleCSS = '/static/bundle.css' vendorJS = '/static/vendor.js' } return ` <!DOCTYPE html> <html> <head> <title>Redux Hello World</title> <link rel="stylesheet" type="text/css" href=${bundleCSS}> </head> <body> <div id="root">${`<div>${html}</div>`}</div> <script> // WARNING: See the following for security issues around embedding JSON in HTML: // http://redux.js.org/docs/recipes/ServerRendering.html#security-considerations window.__PRELOADED_STATE__ = ${JSON.stringify(preloadedState).replace(/</g, '\\u003c')} </script> <script src=${vendorJS}></script> <script src="/static/bundle.js"></script> </body> </html> ` } module.exports = serverRender
src/components/icons/settings.js
ipfs-shipyard/peerpad
import React from 'react' export default ({ className, style }) => ( <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 149 146.7' className={className} style={style}> <path d='M126,73.35a14.74,14.74,0,0,0-12.17-14.5l-1.28-3.07a14.74,14.74,0,0,0-1.64-18.85,15.05,15.05,0,0,0-18.86-1.65L89,34a14.72,14.72,0,0,0-29,0l-3.07,1.27A14.72,14.72,0,0,0,33.77,47.34a14.59,14.59,0,0,0,2.66,8.45l-1.27,3.07a14.72,14.72,0,0,0,0,29l1.27,3.07a14.74,14.74,0,0,0,1.65,18.86,15.06,15.06,0,0,0,18.86,1.65L60,112.69a14.72,14.72,0,0,0,29,0l3.07-1.28a14.72,14.72,0,0,0,20.5-20.5l1.27-3.07A14.73,14.73,0,0,0,126,73.35Zm-14.72,7.37a3.68,3.68,0,0,0-3.4,2.27l-3,7.17a3.68,3.68,0,0,0,.8,4,7.36,7.36,0,1,1-10.41,10.41,3.68,3.68,0,0,0-4-.8l-7.17,3a3.68,3.68,0,0,0-2.27,3.4,7.36,7.36,0,0,1-14.72,0,3.68,3.68,0,0,0-2.27-3.4l-7.17-3a3.68,3.68,0,0,0-4,.8,7.53,7.53,0,0,1-10.4,0,7.37,7.37,0,0,1,0-10.41,3.68,3.68,0,0,0,.8-4l-3-7.17a3.68,3.68,0,0,0-3.4-2.27,7.36,7.36,0,0,1,0-14.72,3.68,3.68,0,0,0,3.4-2.27l3-7.17a3.68,3.68,0,0,0-.8-4A7.36,7.36,0,0,1,53.69,42.13a3.69,3.69,0,0,0,4,.8l7.17-3a3.69,3.69,0,0,0,2.27-3.4,7.36,7.36,0,0,1,14.72,0A3.69,3.69,0,0,0,84.13,40l7.17,3a3.68,3.68,0,0,0,4-.8,7.53,7.53,0,0,1,10.4,0,7.37,7.37,0,0,1,0,10.41,3.68,3.68,0,0,0-.8,4l3,7.17a3.68,3.68,0,0,0,3.4,2.27,7.36,7.36,0,0,1,0,14.72Z' /> <path d='M92.9,73.35A18.4,18.4,0,1,0,64.39,88.69s.06.07.1.1a18.32,18.32,0,0,0,2.68,1.41c.21.09.43.16.64.24a18.29,18.29,0,0,0,2.49.77c.3.07.59.14.89.19a18.06,18.06,0,0,0,18.65-8s.07-.06.1-.1a18.32,18.32,0,0,0,1.41-2.68c.09-.21.16-.43.24-.64a18.29,18.29,0,0,0,.77-2.49c.07-.3.14-.59.19-.89A18.42,18.42,0,0,0,92.9,73.35Zm-18.4,11a11.05,11.05,0,0,1-2.79-.4c-.25-.07-.5-.15-.74-.23a11,11,0,0,1-7.51-10.41,11,11,0,1,1,21.67,2.79c-.07.25-.15.5-.23.74A11,11,0,0,1,74.5,84.39Z' /> </svg> )
anubis/ui/components/scratchpad/ScratchpadRecordsContainer.js
KawashiroNitori/Anubis
import React from 'react'; import { connect } from 'react-redux'; import Tabs, { TabPane } from 'rc-tabs'; import TabContent from 'rc-tabs/lib/TabContent'; import ScrollableInkTabBar from 'rc-tabs/lib/ScrollableInkTabBar'; import Icon from '../react/IconComponent'; import Panel from './PanelComponent'; import PanelButton from './PanelButtonComponent'; import ScratchpadRecordsTable from './ScratchpadRecordsTableContainer'; import i18n from '../../utils/i18n'; import * as util from '../../misc/Util'; const mapDispatchToProps = (dispatch) => ({ loadSubmissions() { dispatch({ type: 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS', payload: util.get(Context.getSubmissionsUrl), }); }, handleClickClose() { dispatch({ type: 'SCRATCHPAD_UI_SET_VISIBILITY', payload: { uiElement: 'records', visibility: false, }, }); }, handleClickRefresh() { this.loadSubmissions(); }, }); @connect(null, mapDispatchToProps) export default class ScratchpadRecordsContainer extends React.PureComponent { render() { return ( <Panel title={<span><Icon name="flag" /> {i18n('Records')}</span>} > <Tabs className="scratchpad__panel-tab flex-col flex-fill" activeKey={"all"} animation="slide-horizontal" renderTabBar={() => <ScrollableInkTabBar extraContent={ <span> <PanelButton data-tooltip={i18n('Refresh Records')} data-tooltip-pos="top right" onClick={() => this.props.handleClickRefresh()} > {i18n('Refresh')} </PanelButton> <PanelButton onClick={() => this.props.handleClickClose()} > <Icon name="close" /> </PanelButton> </span> } />} renderTabContent={() => <TabContent />} > <TabPane tab={<span>{i18n('All')}</span>} key="all"> <ScratchpadRecordsTable /> </TabPane> </Tabs> </Panel> ); } componentDidMount() { this.props.loadSubmissions(); } }
docs/app/Examples/addons/TextArea/Usage/TextAreaExampleAutoHeightRows.js
aabustamante/Semantic-UI-React
import React from 'react' import { Form, TextArea } from 'semantic-ui-react' const TextAreaExampleAutoHeightRows = () => ( <Form> <TextArea autoHeight placeholder='Try adding multiple lines' rows={1} /> </Form> ) export default TextAreaExampleAutoHeightRows
pootle/static/js/auth/components/RequestPasswordResetForm.js
evernote/zing
/* * Copyright (C) Pootle contributors. * Copyright (C) Zing 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 React from 'react'; import FormElement from 'components/FormElement'; import FormMixin from 'mixins/FormMixin'; import { gotoScreen, requestPasswordReset } from '../actions'; import AuthContent from './AuthContent'; import RequestPasswordResetProgress from './RequestPasswordResetProgress'; const RequestPasswordResetForm = React.createClass({ propTypes: { canRegister: React.PropTypes.bool.isRequired, dispatch: React.PropTypes.func.isRequired, formErrors: React.PropTypes.object.isRequired, isLoading: React.PropTypes.bool.isRequired, }, mixins: [FormMixin], /* Lifecycle */ getInitialState() { this.initialData = { email: '', }; return { formData: Object.assign({}, this.initialData), }; }, componentWillReceiveProps(nextProps) { if (this.state.errors !== nextProps.formErrors) { this.setState({ errors: nextProps.formErrors }); } }, /* Handlers */ handleSignIn(e) { e.preventDefault(); this.props.dispatch(gotoScreen('signIn')); }, handleSignUp(e) { e.preventDefault(); this.props.dispatch(gotoScreen('signUp')); }, handleFormSubmit(e) { e.preventDefault(); this.props.dispatch(requestPasswordReset(this.state.formData)); }, /* Others */ hasData() { return this.state.formData.email !== ''; }, /* Layout */ render() { if (this.props.isLoading) { return <RequestPasswordResetProgress email={this.state.formData.email} />; } const { errors } = this.state; const { formData } = this.state; return ( <AuthContent> <form method="post" onSubmit={this.handleFormSubmit}> <div className="fields"> {this.renderAllFormErrors()} <FormElement autoFocus type="email" label={gettext('Email Address')} help={gettext( 'Enter your email address, and we will send you a ' + 'message with the special link to reset your password.' )} handleChange={this.handleChange} name="email" errors={errors.email} value={formData.email} /> </div> <div className="actions"> <div> <a href="#" onClick={this.handleSignIn}> {gettext('No, thanks')} </a> </div> <div> <input type="submit" className="btn btn-primary" disabled={!this.hasData()} value={gettext('Send Email')} /> </div> {this.props.canRegister && ( <div> <a href="#" onClick={this.handleSignUp}> {gettext('Sign up as a new user')} </a> </div> )} </div> </form> </AuthContent> ); }, }); export default RequestPasswordResetForm;
actor-apps/app-web/src/app/components/modals/create-group/Form.react.js
darioajr/actor-platform
import _ from 'lodash'; import Immutable from 'immutable'; import keymirror from 'keymirror'; import React from 'react'; import { Styles, TextField, FlatButton } from 'material-ui'; import CreateGroupActionCreators from 'actions/CreateGroupActionCreators'; import ContactStore from 'stores/ContactStore'; import ContactItem from './ContactItem.react'; import ActorTheme from 'constants/ActorTheme'; const ThemeManager = new Styles.ThemeManager(); const STEPS = keymirror({ NAME_INPUT: null, CONTACTS_SELECTION: null }); class CreateGroupForm extends React.Component { static displayName = 'CreateGroupForm' static childContextTypes = { muiTheme: React.PropTypes.object }; state = { step: STEPS.NAME_INPUT, selectedUserIds: new Immutable.Set() } getChildContext() { return { muiTheme: ThemeManager.getCurrentTheme() }; } constructor(props) { super(props); ThemeManager.setTheme(ActorTheme); ThemeManager.setComponentThemes({ textField: { textColor: 'rgba(0,0,0,.87)', focusColor: '#68a3e7', backgroundColor: 'transparent', borderColor: '#68a3e7' } }); } render() { let stepForm; switch (this.state.step) { case STEPS.NAME_INPUT: stepForm = ( <form className="group-name" onSubmit={this.onNameSubmit}> <div className="modal-new__body"> <TextField className="login__form__input" floatingLabelText="Group name" fullWidth onChange={this.onNameChange} value={this.state.name}/> </div> <footer className="modal-new__footer text-right"> <FlatButton hoverColor="rgba(74,144,226,.12)" label="Add members" secondary={true} type="submit"/> </footer> </form> ); break; case STEPS.CONTACTS_SELECTION: let contactList = _.map(ContactStore.getContacts(), (contact, i) => { return ( <ContactItem contact={contact} key={i} onToggle={this.onContactToggle}/> ); }); stepForm = ( <form className="group-members" onSubmit={this.onMembersSubmit}> <div className="count">{this.state.selectedUserIds.size} Members</div> <div className="modal-new__body"> <ul className="contacts__list"> {contactList} </ul> </div> <footer className="modal-new__footer text-right"> <FlatButton hoverColor="rgba(74,144,226,.12)" label="Create group" secondary={true} type="submit"/> </footer> </form> ); break; } return stepForm; } onContactToggle = (contact, isSelected) => { if (isSelected) { this.setState({selectedUserIds: this.state.selectedUserIds.add(contact.uid)}); } else { this.setState({selectedUserIds: this.state.selectedUserIds.remove(contact.uid)}); } } onNameChange = event => { event.preventDefault(); this.setState({name: event.target.value}); } onNameSubmit = event => { event.preventDefault(); if (this.state.name) { let name = this.state.name.trim(); if (name.length > 0) { this.setState({step: STEPS.CONTACTS_SELECTION}); } } } onMembersSubmit =event => { event.preventDefault(); CreateGroupActionCreators.createGroup(this.state.name, null, this.state.selectedUserIds.toJS()); } } export default CreateGroupForm;
mobile/js/router/index.js
lovelypig5/wms
import React from 'react' import { AsyncStorage } from 'react-native'; // import SideMenu from 'react-native-side-menu'; // import Menu from '../features/menu'; import Nav from '../features/navigator'; import Entry from '../features'; import LoginButton from '../features/login/button'; import DICT from '../config/dict'; import styles from '../styles'; class Router extends React.Component { constructor(props) { super(props); this.state = { user: '' }; this.initUser = this.initUser.bind(this); } componentDidMount() { this.initUser(); } render() { var initialRoute = { title: '仓储管理系统', back: '', component: Entry, index: 0, right: LoginButton } return <Nav {...this.state} initialRoute={initialRoute} initUser={this.initUser} /> } async initUser() { try { let user = await AsyncStorage.getItem(DICT.LOGINKEY); if (user) { this.setState({ user: JSON.parse(user) }); } } catch (err) { console.error(err); } } } export default Router;
node_modules/react-transition-group/esm/SwitchTransition.js
jerednel/jerednel.github.io
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose"; var _leaveRenders, _enterRenders; import React from 'react'; import PropTypes from 'prop-types'; import { ENTERED, ENTERING, EXITING } from './Transition'; import TransitionGroupContext from './TransitionGroupContext'; function areChildrenDifferent(oldChildren, newChildren) { if (oldChildren === newChildren) return false; if (React.isValidElement(oldChildren) && React.isValidElement(newChildren) && oldChildren.key != null && oldChildren.key === newChildren.key) { return false; } return true; } /** * Enum of modes for SwitchTransition component * @enum { string } */ export var modes = { out: 'out-in', in: 'in-out' }; var callHook = function callHook(element, name, cb) { return function () { var _element$props; element.props[name] && (_element$props = element.props)[name].apply(_element$props, arguments); cb(); }; }; var leaveRenders = (_leaveRenders = {}, _leaveRenders[modes.out] = function (_ref) { var current = _ref.current, changeState = _ref.changeState; return React.cloneElement(current, { in: false, onExited: callHook(current, 'onExited', function () { changeState(ENTERING, null); }) }); }, _leaveRenders[modes.in] = function (_ref2) { var current = _ref2.current, changeState = _ref2.changeState, children = _ref2.children; return [current, React.cloneElement(children, { in: true, onEntered: callHook(children, 'onEntered', function () { changeState(ENTERING); }) })]; }, _leaveRenders); var enterRenders = (_enterRenders = {}, _enterRenders[modes.out] = function (_ref3) { var children = _ref3.children, changeState = _ref3.changeState; return React.cloneElement(children, { in: true, onEntered: callHook(children, 'onEntered', function () { changeState(ENTERED, React.cloneElement(children, { in: true })); }) }); }, _enterRenders[modes.in] = function (_ref4) { var current = _ref4.current, children = _ref4.children, changeState = _ref4.changeState; return [React.cloneElement(current, { in: false, onExited: callHook(current, 'onExited', function () { changeState(ENTERED, React.cloneElement(children, { in: true })); }) }), React.cloneElement(children, { in: true })]; }, _enterRenders); /** * A transition component inspired by the [vue transition modes](https://vuejs.org/v2/guide/transitions.html#Transition-Modes). * You can use it when you want to control the render between state transitions. * Based on the selected mode and the child's key which is the `Transition` or `CSSTransition` component, the `SwitchTransition` makes a consistent transition between them. * * If the `out-in` mode is selected, the `SwitchTransition` waits until the old child leaves and then inserts a new child. * If the `in-out` mode is selected, the `SwitchTransition` inserts a new child first, waits for the new child to enter and then removes the old child. * * **Note**: If you want the animation to happen simultaneously * (that is, to have the old child removed and a new child inserted **at the same time**), * you should use * [`TransitionGroup`](https://reactcommunity.org/react-transition-group/transition-group) * instead. * * ```jsx * function App() { * const [state, setState] = useState(false); * return ( * <SwitchTransition> * <CSSTransition * key={state ? "Goodbye, world!" : "Hello, world!"} * addEndListener={(node, done) => node.addEventListener("transitionend", done, false)} * classNames='fade' * > * <button onClick={() => setState(state => !state)}> * {state ? "Goodbye, world!" : "Hello, world!"} * </button> * </CSSTransition> * </SwitchTransition> * ); * } * ``` * * ```css * .fade-enter{ * opacity: 0; * } * .fade-exit{ * opacity: 1; * } * .fade-enter-active{ * opacity: 1; * } * .fade-exit-active{ * opacity: 0; * } * .fade-enter-active, * .fade-exit-active{ * transition: opacity 500ms; * } * ``` */ var SwitchTransition = /*#__PURE__*/function (_React$Component) { _inheritsLoose(SwitchTransition, _React$Component); function SwitchTransition() { var _this; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; _this.state = { status: ENTERED, current: null }; _this.appeared = false; _this.changeState = function (status, current) { if (current === void 0) { current = _this.state.current; } _this.setState({ status: status, current: current }); }; return _this; } var _proto = SwitchTransition.prototype; _proto.componentDidMount = function componentDidMount() { this.appeared = true; }; SwitchTransition.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) { if (props.children == null) { return { current: null }; } if (state.status === ENTERING && props.mode === modes.in) { return { status: ENTERING }; } if (state.current && areChildrenDifferent(state.current, props.children)) { return { status: EXITING }; } return { current: React.cloneElement(props.children, { in: true }) }; }; _proto.render = function render() { var _this$props = this.props, children = _this$props.children, mode = _this$props.mode, _this$state = this.state, status = _this$state.status, current = _this$state.current; var data = { children: children, current: current, changeState: this.changeState, status: status }; var component; switch (status) { case ENTERING: component = enterRenders[mode](data); break; case EXITING: component = leaveRenders[mode](data); break; case ENTERED: component = current; } return /*#__PURE__*/React.createElement(TransitionGroupContext.Provider, { value: { isMounting: !this.appeared } }, component); }; return SwitchTransition; }(React.Component); SwitchTransition.propTypes = process.env.NODE_ENV !== "production" ? { /** * Transition modes. * `out-in`: Current element transitions out first, then when complete, the new element transitions in. * `in-out`: New element transitions in first, then when complete, the current element transitions out. * * @type {'out-in'|'in-out'} */ mode: PropTypes.oneOf([modes.in, modes.out]), /** * Any `Transition` or `CSSTransition` component. */ children: PropTypes.oneOfType([PropTypes.element.isRequired]) } : {}; SwitchTransition.defaultProps = { mode: modes.out }; export default SwitchTransition;
src/components/TeaserFooter/index.js
iris-dni/iris-frontend
import React from 'react'; import styles from './teaser-footer.scss'; import TeaserMetrics from 'components/TeaserMetrics'; import TeaserInfo from 'components/TeaserInfo'; const TeaserFooter = ({ city, owner, metrics }) => ( <footer className={styles.root}> <div className={styles.info}> <TeaserInfo city={city} owner={owner} /> </div> <div className={styles.metrics}> <TeaserMetrics {...metrics} /> </div> </footer> ); export default TeaserFooter;
test/js/release_test/ViroVideoTest.js
viromedia/viro
'use strict'; import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; import { ViroScene, ViroVideo, ViroOmniLight, ViroSceneNavigator, Materials, ViroText, ViroUtils, Viro360Photo, Viro360Video, ViroImage, ViroMaterials, } from 'react-viro'; var createReactClass = require('create-react-class'); var VIDEO_REF = "videoref"; let polarToCartesian = ViroUtils.polarToCartesian; var localVideo = require("./res/Titan_Touchdown.mp4"); var chromeVideo = require("./res/alphachica.mp4"); var localVideoStereo = require("./res/stereoVid.mp4"); var uriSource = {uri:'https://s3.amazonaws.com/viro.video/Climber1Bottom.mp4'}; var ReleaseMenu = require("./ReleaseMenu.js"); var ViroVideoTest = createReactClass({ getInitialState() { return { videoPaused: false, loopVideo: true, muteVideo: true, volume: 1, showVideo: true, uriVideo:localVideo, } }, render: function() { return ( <ViroScene> <ReleaseMenu sceneNavigator={this.props.sceneNavigator}/> <ViroOmniLight position={[0, 0, 0]} color="#ffffff" attenuationStartDistance={40} attenuationEndDistance={50} /> {this._getViroVideo()} <ViroImage source={require('./res/poi_dot.png')} position={[-1, 0, 0]} transformBehaviors={["billboard"]} onClick={this._showNext} /> <ViroText position={polarToCartesian([2, -10, 0])} text={this._getLoopingText()} style={styles.baseTextTwo} onClick={this._toggleLooping} transformBehaviors={["billboard"]}/> <ViroText position={polarToCartesian([2, -10, -5])} text="Restart" style={styles.baseTextTwo} onClick={this._restartVideo} transformBehaviors={["billboard"]}/> <ViroText position={polarToCartesian([2, -10, -10])} text={"IsVideoPlaying: " + !this.state.videoPaused} style={styles.baseTextTwo} onClick={this._togglePauseVideo} transformBehaviors={["billboard"]}/> <ViroText position={polarToCartesian([2, -10, -15])} text={this._getMuteText()} style={styles.baseTextTwo} onClick={this._muteVideo} transformBehaviors={["billboard"]}/> <ViroText position={polarToCartesian([2, -10, -20])} text="Change Source" style={styles.baseTextTwo} onClick={this._changeVideoSource} transformBehaviors={["billboard"]}/> <ViroText position={polarToCartesian([2, 15, 0])} text={"Change Volume from: " + this.state.volume} style={styles.baseTextTwo} onClick={this._changeVolume} transformBehaviors={["billboard"]}/> </ViroScene> ); }, _showNext() { this.props.sceneNavigator.replace({scene:require('./ViroAnimatedComponentTest')}); }, _getViroVideo() { return ( <ViroVideo ref={VIDEO_REF} width={1.7} height={0.95} position={[0, 1, -2.9]} scale={[1, 1, 1]} paused={this.state.videoPaused} source={this.state.uriVideo} transformBehaviors={["billboard"]} onBufferStart={this._onBufferStart} onBufferEnd={this._onBufferEnd} stereoMode={this.state.uriVideo == localVideoStereo ? "LeftRight":"None"} loop={this.state.loopVideo} muted={this.state.muteVideo} volume={this.state.volume} onFinish={this._onVideoFinished} onUpdateTime={this._onUpdateTime} materials={["chromeKeyedVideo"]} /> ); }, _onBufferStart() { console.log("ViroVideoTest onBufferStart"); }, _onBufferEnd() { console.log("ViroVideoTest onBufferEnd"); }, _onVideoFinished(){ console.log("Viro on video Finished"); }, _onUpdateTime(current, total){ console.log("Viro On time update-> Current: " + current+ ", total: " + total); }, _changeVideoSource() { var newVideoSource; if (this.state.uriVideo == uriSource) { newVideoSource = localVideo; } else if (this.state.uriVideo == localVideo) { newVideoSource = localVideoStereo; } else if (this.state.uriVideo == localVideoStereo) { newVideoSource = chromeVideo; } else { newVideoSource = uriSource; } this.setState({ uriVideo: newVideoSource, }); }, _getMuteText() { return this.state.muteVideo ? "IsMute: True" : "IsMute: False"; }, _muteVideo() { this.setState({ muteVideo: !this.state.muteVideo, }) }, _togglePauseVideo() { this.setState({ videoPaused: !this.state.videoPaused, }) }, _getLoopingText() { return this.state.loopVideo ? "IsLooping: True" : "IsLooping: False"; }, _toggleLooping() { this.setState({ loopVideo: !this.state.loopVideo, }); }, _pauseVideo() { console.log("pausing video!"); this.setState({ videoPaused: true, }) }, _playVideo() { console.log("playing video!"); this.setState({ videoPaused: false, }) }, _changeVolume() { this.setState({ volume: Math.random(), }); }, _restartVideo() { // This tests seeking to a non integer number and seeking in general. this.refs[VIDEO_REF].seekToTime(shouldResetToHalfSecond ? .5 : 0); shouldResetToHalfSecond = !shouldResetToHalfSecond; }, }); var shouldResetToHalfSecond = false; ViroMaterials.createMaterials({ chromeKeyedVideo : { chromaKeyFilteringColor: "#00ff00" }, normalVideo: { lightingModel: "Constant", }, }); var styles = StyleSheet.create({ baseTextTwo: { fontFamily: 'Arial', fontSize: 10, color: '#ffffff', flex: 1, textAlignVertical: 'center', textAlign: 'center', }, }); module.exports = ViroVideoTest;
app/src/client/app/framework/SvgPresentation.js
syrel/Open-Data
/** * Created by syrel on 31.05.17. */ import React from 'react'; import PresentationComponent from './PresentationComponent'; import Presentation from './Presentation'; import ElementQueries from 'css-element-queries'; import $ from 'jquery'; import _ from 'underscore'; class SvgComponent extends PresentationComponent { updateHeight() { if (_.isUndefined(this.refs.svg)) { return; } $(this.refs.svg.parentNode).height(Math.ceil($(this.refs.svg).height())); } componentDidMount() { this.renderSVG(); new ElementQueries.ResizeSensor(this.refs.svg.parentNode.parentNode, _.throttle(this.updateHeight, 100).bind(this)); this.updateHeight(); } componentDidUpdate() { this.renderSVG(); this.updateHeight(); } p(x,y){ return x+" "+y+" "; } roundedRectangle(x, y, w, h, r1, r2, r3, r4){ var strPath = "M" + this.p(x+r1,y); strPath+="L"+this.p(x+w-r2,y)+"Q"+this.p(x+w,y)+this.p(x+w,y+r2); strPath+="L"+this.p(x+w,y+h-r3)+"Q"+this.p(x+w,y+h)+this.p(x+w-r3,y+h); strPath+="L"+this.p(x+r4,y+h)+"Q"+this.p(x,y+h)+this.p(x,y+h-r4); strPath+="L"+this.p(x,y+r1)+"Q"+this.p(x,y)+this.p(x+r1,y); strPath+="Z"; return strPath; } renderSVG() { throw Error('Subclass responsibility'); } render() { return <div style={{ position: 'relative', margin: '0 auto', width: '100%', }}> <svg ref='svg' style={{position: 'absolute'}} viewBox={'0 0 ' + this.props.width + ' ' + this.props.height } preserveAspectRatio='xMidYMid meet' /> </div> } } class SvgPresentation extends Presentation { } SvgPresentation.SvgComponent = SvgComponent; export default SvgPresentation;
src/components/common/svg-icons/editor/title.js
abzfarah/Pearson.NAPLAN.GnomeH
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let EditorTitle = (props) => ( <SvgIcon {...props}> <path d="M5 4v3h5.5v12h3V7H19V4z"/> </SvgIcon> ); EditorTitle = pure(EditorTitle); EditorTitle.displayName = 'EditorTitle'; EditorTitle.muiName = 'SvgIcon'; export default EditorTitle;
packages/material-ui-icons/src/Adb.js
dsslimshaddy/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from 'material-ui/SvgIcon'; let Adb = props => <SvgIcon {...props}> <path d="M5 16c0 3.87 3.13 7 7 7s7-3.13 7-7v-4H5v4zM16.12 4.37l2.1-2.1-.82-.83-2.3 2.31C14.16 3.28 13.12 3 12 3s-2.16.28-3.09.75L6.6 1.44l-.82.83 2.1 2.1C6.14 5.64 5 7.68 5 10v1h14v-1c0-2.32-1.14-4.36-2.88-5.63zM9 9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm6 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z" /> </SvgIcon>; Adb = pure(Adb); Adb.muiName = 'SvgIcon'; export default Adb;
examples/values/src/app.js
quandhz/resaga
import 'babel-polyfill'; import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; import configureStore from './utils/configureStore'; import App from './containers/App'; import { reducer, sagas } from '../../../build'; const store = configureStore({ normaliseStore: reducer('normaliseStore'), }); store.runSaga(sagas[0]); render( <Provider store={store}> <App id={12} childId={11} ids={[11, 12, 13]} extras1={[99]} extras2={[100]} updateId={12} updateChecklist={12} /> </Provider>, document.getElementById('root') );
packages/react-dom/src/client/ReactDOMFiberOption.js
anushreesubramani/react
/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import React from 'react'; import warning from 'fbjs/lib/warning'; function flattenChildren(children) { let content = ''; // Flatten children and warn if they aren't strings or numbers; // invalid types are ignored. // We can silently skip them because invalid DOM nesting warning // catches these cases in Fiber. React.Children.forEach(children, function(child) { if (child == null) { return; } if (typeof child === 'string' || typeof child === 'number') { content += child; } }); return content; } /** * Implements an <option> host component that warns when `selected` is set. */ export function validateProps(element: Element, props: Object) { // TODO (yungsters): Remove support for `selected` in <option>. if (__DEV__) { warning( props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.', ); } } export function postMountWrapper(element: Element, props: Object) { // value="" should make a value attribute (#6219) if (props.value != null) { element.setAttribute('value', props.value); } } export function getHostProps(element: Element, props: Object) { const hostProps = {children: undefined, ...props}; const content = flattenChildren(props.children); if (content) { hostProps.children = content; } return hostProps; }
src/svg-icons/editor/format-align-right.js
andrejunges/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let EditorFormatAlignRight = (props) => ( <SvgIcon {...props}> <path d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"/> </SvgIcon> ); EditorFormatAlignRight = pure(EditorFormatAlignRight); EditorFormatAlignRight.displayName = 'EditorFormatAlignRight'; EditorFormatAlignRight.muiName = 'SvgIcon'; export default EditorFormatAlignRight;
Mr.Mining/MikeTheMiner/Santas_helpers/Sia_wallet/resources/app/plugins/Wallet/js/components/transactionlist.js
patel344/Mr.Miner
import PropTypes from 'prop-types' import React from 'react' import { List } from 'immutable' const TransactionList = ({transactions, ntransactions, actions}) => { if (transactions.size === 0) { return ( <div className="transaction-list"> <h3> No recent transactions </h3> </div> ) } const prettyTimestamp = (timestamp) => { const pad = (n) => String('0'+n).slice(-2) const yesterday = new Date() yesterday.setHours(yesterday.getHours() -24) if (timestamp > yesterday) { return 'Today at ' + pad(timestamp.getHours()) + ':' + pad(timestamp.getMinutes()) } return timestamp.getFullYear() + '-' + pad((timestamp.getMonth()+1)) + '-' + pad(timestamp.getDate()) + ' ' + pad(timestamp.getHours()) + ':' + pad(timestamp.getMinutes()) } const transactionComponents = transactions.take(ntransactions).map((txn, key) => { let valueData = '' if (txn.transactionsums.totalSiacoin.abs().gt(0)) { valueData += txn.transactionsums.totalSiacoin.round(4).toNumber().toLocaleString() + ' SC ' } if (txn.transactionsums.totalSiafund.abs().gt(0)) { valueData += txn.transactionsums.totalSiafund.round(4).toNumber().toLocaleString() + ' SF ' } if (txn.transactionsums.totalMiner.abs().gt(0)) { valueData += txn.transactionsums.totalMiner.round(4).toNumber().toLocaleString() + ' SC (miner) ' } if (valueData === '') { valueData = '0 SC' } return ( <tr key={key}> <td>{txn.confirmed ? prettyTimestamp(txn.confirmationtimestamp) : 'Not Confirmed'}</td> <td>{valueData}</td> <td className="txid">{txn.transactionid}</td> <td>{txn.confirmed ? <i className="fa fa-check-square confirmed-icon"> Confirmed </i> : <i className="fa fa-clock-o unconfirmed-icon"> Unconfirmed </i>}</td> </tr> ) }) const onMoreClick = () => actions.showMoreTransactions() return ( <div className="transaction-list"> <h2> Recent Transactions </h2> <table className="pure-table transaction-table"> <thead> <tr> <th>Date</th> <th>Net Value</th> <th>Transaction ID</th> <th>Confirmation Status</th> </tr> </thead> <tbody> {transactionComponents} </tbody> </table> { transactions.size > ntransactions ? ( <div className="load-more"> <button className="load-more-button" onClick={onMoreClick}>More Transactions</button> </div> ) : null } </div> ) } TransactionList.propTypes = { transactions: PropTypes.instanceOf(List).isRequired, ntransactions: PropTypes.number.isRequired, } export default TransactionList
App.js
mechanizzed/talk-support
import React, { Component } from 'react'; import { Modal, View, Text, Button, TouchableOpacity, TouchableHighlight } from 'react-native'; import styles from './src/styles/styles'; export default class App extends React.Component{ state = { modalYesVisible: false, modalNoVisible: false, } setModalYesVisible(visible){ this.setState({modalYesVisible: visible}); } setModalNoVisible(visible){ this.setState({modalNoVisible: visible}) } render(){ return( <View style={styles.container}> <Modal animationType="slide" visible={this.state.modalYesVisible} onRequestClose={() => {}} > <TouchableHighlight style={styles.buttonYes} onPress={() => {this.setModalYesVisible(!this.state.modalYesVisible)}} > <View style={styles.buttonYes}> <Text style={styles.textButton}>SIM</Text> </View> </TouchableHighlight> </Modal> <Modal animationType="slide" visible={this.state.modalNoVisible} onRequestClose={() => {}} > <TouchableHighlight style={styles.buttonNo} onPress={() => {this.setModalNoVisible(!this.state.modalNoVisible)}} > <View style={styles.buttonNo}> <Text style={styles.textButton}>NÃO</Text> </View> </TouchableHighlight> </Modal> <TouchableOpacity style={styles.buttonYes} onPress={() => { this.setModalYesVisible(!this.state.modalYesVisible) }} > <Text style={styles.textButton}>SIM</Text> </TouchableOpacity> <TouchableOpacity style={styles.buttonNo} onPress={() => { this.setModalNoVisible(!this.state.modalNoVisible) }} > <Text style={styles.textButton}>NÃO</Text> </TouchableOpacity> </View> ); } }
components/Paint/PaintModal.js
slidewiki/slidewiki-platform
import PropTypes from 'prop-types'; import React from 'react'; import {connectToStores} from 'fluxible-addons-react'; import FocusTrap from 'focus-trap-react'; import { Button, Divider, Dropdown, Icon, Input, Modal, Popup, Segment } from 'semantic-ui-react'; import { Image as Img} from 'semantic-ui-react'; import uploadMediaFiles from '../../actions/media/uploadMediaFile'; import updateGraphic from '../../actions/media/updateGraphic'; import finishPaintEdition from '../../actions/paint/finishPaintEdition'; import PaintModalStore from '../../stores/PaintModalStore'; import { fabric } from 'fabric'; import {FormattedMessage, defineMessages} from 'react-intl'; const headerStyle = { 'textAlign': 'center' }; const canvasStyle = { 'height': '0px', 'width': '0px' }; class PaintModal extends React.Component { constructor(props) { super(props); this.state = { modalOpen: false, activeTrap: false, canvasDirty: false, license: false, licenseValue: 'CC0', copyrightHolder: '', alt: '', title: '' }; // this.reader = new FileReader(); this.primaryColor = 'black'; this.secondaryColor = 'black'; this.transparency = 1; this.noActiveObject = true; this.drawingMode = false; this.canvas = null; // For undo - redo // TODO: properly store the object's modifications for undo-redo, also deletions. this.canvas_config = { canvasState : [], currentStateIndex : -1, undoStatus : false, redoStatus : false, undoFinishedStatus : 1, redoFinishedStatus : 1, undoDisabled : true, redoDisabled : true }; this.updateCanvasState = this.updateCanvasState.bind(this); this.clipboard = null; this.canvasOpen = false; // this.handleOpen = this.handleOpen.bind(this); this.handleClose = this.handleClose.bind(this); this.unmountTrap = this.unmountTrap.bind(this); this.startFabric = this.startFabric.bind(this); this.addRect = this.addRect.bind(this); this.addCircle = this.addCircle.bind(this); this.addTriangle = this.addTriangle.bind(this); this.addArrow = this.addArrow.bind(this); this.addText = this.addText.bind(this); this.downloadImg = this.downloadImg.bind(this); this.deleteElement = this.deleteElement.bind(this); this.setDrawingMode = this.setDrawingMode.bind(this); this.setLineWidth = this.setLineWidth.bind(this); this.setTransparency = this.setTransparency.bind(this); this.sendBackwards = this.sendBackwards.bind(this); this.bringForwards= this.bringForwards.bind(this); this.loadImg = this.loadImg.bind(this); this.undo = this.undo.bind(this); this.redo = this.redo.bind(this); this.copyActiveObjects = this.copyActiveObjects.bind(this); this.paste = this.paste.bind(this); this.getDrawedCoordinates = this.getDrawedCoordinates.bind(this); this.showLicense = this.showLicense.bind(this); this.submitPressed = this.submitPressed.bind(this); // Messages this.messages = defineMessages({ paintTitle: { id: 'paintModal.title', defaultMessage: 'Draw your own SVG image' }, primaryColourInput: { id: 'paintModal.primaryColourInput', defaultMessage: 'Primary colour: ' }, secondaryColourInput: { id: 'paintModal.secondaryColourInput', defaultMessage: 'Secondary colour: ' }, lineBorderWidthInput: { // <FormattedMessage id="paintModal.lineBorderWidth" defaultMessage="Line/Border Width:"/> id: 'paintModal.lineBorderWidthInput', defaultMessage: 'Line/Border Width:' }, transparencyInput: { id: 'paintModal.transparencyInput', defaultMessage: 'Object Transparency:' }, drawingMode: { id: 'paintModal.drawingMode', defaultMessage: 'Drawing Mode' }, selectMode: { id: 'paintModal.selectMode', defaultMessage: 'Select Mode' }, addToSlide: { id: 'paintModal.addToSlide', defaultMessage: 'Add to Slide' }, paintHeading: { id: 'oaintModal.paintHeading', defaultMessage: 'Draw and Paint' }, licenseHeading: { id: 'paintModal.licenseHeading', defaultMessage: 'License information' }, undo: { id: 'paintModal.undo', defaultMessage: 'Undo' }, redo: { id: 'paintModal.redo', defaultMessage: 'Redo' }, bringForwards: { id: 'paintModal.bringForwards', defaultMessage: 'Bring Forwards' }, sendBackwards: { id: 'paintModal.sendBackwards', defaultMessage: 'Send Backwards' }, uploadImage: { id: 'paintModal.uploadImage', defaultMessage: 'Upload Image' }, downloadImage: { id: 'paintModal.downloadImage', defaultMessage: 'Download Image' }, clone: { id: 'paintModal.clone', defaultMessage: 'Clone Selected Objects' }, delete: { id: 'paintModal.delete', defaultMessage: 'Delete Selected Objects' }, addCircle: { id: 'paintModal.addCircle', defaultMessage: 'Add Circle' }, addRectangle: { id: 'paintModal.addRectangle', defaultMessage: 'Add Rectangle' }, addTriangle: { id: 'paintModal.addTriangle', defaultMessage: 'Add Triangle' }, addArrow: { id: 'paintModal.addArrow', defaultMessage: 'Add Arrow' }, paintInstruction: { id: 'paintModal.instruction', defaultMessage: 'Draw inside the canvas using the tools provided.' }, copyrightholder: { id: 'paintModal.copyrightholder', defaultMessage: 'Copyrightholder' }, imageAttribution: { id: 'paintModal.imageAttribution', defaultMessage: 'Image created by/ attributed to:' }, imageTitle: { id: 'paintModal.imageTitle', defaultMessage: 'Title:' }, imageTitleAria: { id: 'paintModal.imageTitleAria', defaultMessage: 'Title of the image' }, imageDescription: { id: 'paintModal.imageDescription', defaultMessage: 'Description/Alt Text:' }, imageDescriptionAria: { id: 'paintModal.imageDescriptionAria', defaultMessage: 'Description of the image' }, imageDescriptionQuestion: { id: 'paintModal.imageDescriptionQuestion', defaultMessage: 'What does the picture mean?' }, chooseLicense: { id: 'paintModal.chooseLicense', defaultMessage: 'Choose a license:' }, selectLicense: { id: 'paintModal.selectLicense', defaultMessage: 'Select a license' }, agreementAria: { id: 'paintModal.agreementAria', defaultMessage: 'Agree to terms and conditions' }, agreement1: { id: 'paintModal.agreement1', defaultMessage: 'I confirm that I have the rights to upload this image as per the SlideWiki ' }, agreement2: { id: 'paintModal.agreement2', defaultMessage: 'terms and conditions' }, agreement3: { id: 'paintModal.agreement3', defaultMessage: 'and that the' }, agreement4: { id: 'paintModal.agreement4', defaultMessage: 'license information' }, agreement5: { id: 'paintModal.agreement5', defaultMessage: 'I have provided is correct.' }, paintButton: { id: 'paintModal.paintButton', defaultMessage: 'Paint' }, upload: { id: 'paintModal.upload', defaultMessage: 'Upload' }, cancel: { id: 'paintModal.cancel', defaultMessage: 'Cancel' } }); } componentDidUpdate() { let ele = document.querySelector('#fabriccanvas'); if (ele && !this.canvasOpen) { this.startFabric(); this.canvasOpen = true; } } startFabric(){ this.canvas = new fabric.Canvas('fabriccanvas'); $('#fabriccanvas').css('border', '1px solid #000000'); this.canvas.setHeight(500); this.canvas.setWidth(600); // Adding event listeners to the color inputs. let primaryColorInput = document.getElementById('primaryColor'); let secondaryColorInput = document.getElementById('secondaryColor'); if (primaryColorInput) { primaryColorInput.addEventListener('input', () => { this.primaryColor = primaryColorInput.value; this.canvas.freeDrawingBrush.color = this.primaryColor; }); secondaryColorInput.addEventListener('input', () => { this.secondaryColor = secondaryColorInput.value; }); } /*event handler for the file reader*/ this.reader.onload = (event) => { let imgObj = new Image(); imgObj.src = event.target.result; imgObj.onload = () => { let image = new fabric.Image(imgObj); image.set({ angle: 0, padding: 0, opacity: this.transparency }); this.canvas.centerObject(image); this.canvas.add(image); this.canvas.renderAll(); }; }; this.canvas.on('object:added', (e) => { this.setState({canvasDirty: true}); this.updateCanvasState(); }); this.canvas.on('object:modified', (e) => { this.updateCanvasState(); }); this.canvas.on('object:removed', (e) => { this.updateCanvasState(); }); this.canvas.on('selection:created', (e) => { this.noActiveObject = false; this.forceUpdate(); }); this.canvas.on('selection:cleared', (e) => { this.noActiveObject = true; this.forceUpdate(); }); } updateCanvasState() { if (this.canvas_config.undoStatus === false && this.canvas_config.redoStatus === false) { let jsonData = this.canvas.toJSON(); let canvasAsJson = JSON.stringify(jsonData); if (this.canvas_config.currentStateIndex < this.canvas_config.canvasState.length - 1) { let indexToBeInserted = this.canvas_config.currentStateIndex + 1; this.canvas_config.canvasState[indexToBeInserted] = canvasAsJson; let numberOfElementsToRetain = indexToBeInserted + 1; this.canvas_config.canvasState = this.canvas_config.canvasState.splice(0, numberOfElementsToRetain); this.canvas_config.redoDisabled = true; } else { this.canvas_config.canvasState.push(canvasAsJson); this.canvas_config.undoDisabled = false; } this.canvas_config.currentStateIndex = this.canvas_config.canvasState.length - 1; if ((this.canvas_config.currentStateIndex === this.canvas_config.canvasState.length - 1 ) && this.canvas_config.currentStateIndex !== -1){ this.canvas_config.redoDisabled = true; ///// ojo } } if (this.canvas_config.currentStateIndex >= 0) { this.canvas_config.undoDisabled = false; } } handleOpen(){ $('#app').attr('aria-hidden', 'true'); this.setState({ modalOpen:true, activeTrap:true }); this.setState({canvasDirty: false}); } handleClose(){ $('#app').attr('aria-hidden', 'false'); this.setState({ modalOpen: false, activeTrap: false, license: false, licenseValue: 'CC0', copyrightHolder: '', alt: '', title: '' }); this.canvas = null; this.canvasOpen = false; this.drawingMode = false; this.primaryColor = 'black'; this.secondaryColor = 'black'; this.setState({canvasDirty: false}); this.canvas_config = { canvasState : [], currentStateIndex : -1, undoStatus : false, redoStatus : false, undoFinishedStatus : 1, redoFinishedStatus : 1, undoDisabled : true, redoDisabled : true }; this.context.executeAction(finishPaintEdition); } unmountTrap() { if(this.state.activeTrap){ this.setState({ activeTrap: false }); $('#app').attr('aria-hidden','false'); } } addRect() { let coord = {left: 10, top: 10}; this.canvas.add(new fabric.Rect({ left: coord.left, top: coord.top, fill: this.primaryColor, width: 50, height: 50, opacity: this.transparency, stroke: this.secondaryColor, strokeWidth: this.canvas.freeDrawingBrush.width })); } addCircle() { let coord = {left: 10, top: 10}; this.canvas.add(new fabric.Circle({ left: coord.left, top: coord.top, fill: this.primaryColor, radius: 50, opacity: this.transparency, stroke: this.secondaryColor, strokeWidth: this.canvas.freeDrawingBrush.width })); } addTriangle() { let coord = {left: 10, top: 10}; this.canvas.add(new fabric.Triangle({ left: coord.left, top: coord.top, fill: this.primaryColor, width: 50, height: 50, opacity: this.transparency, stroke: this.secondaryColor, strokeWidth: this.canvas.freeDrawingBrush.width })); } addText(){ //let text = 'Insert your text\n here'; let textSample = new fabric.IText('Insert your text\n here', { left: 55, top: 30, fontFamily: 'helvetica', angle: 0, fill: this.primaryColor, scaleX: 0.5, scaleY: 0.5, fontWeight: '', originX: 'left', hasRotatingPoint: true, centerTransform: true }); this.canvas.add(textSample); this.canvas.renderAll(); } addArrow() { let points = [ {x: 0, y: 20}, {x: 60, y: 20}, {x: 60, y: 10}, {x: 80, y: 40}, {x: 60, y: 70}, {x: 60, y: 60}, {x: 0, y: 60}, {x: 0, y: 20} ]; this.canvas.add(new fabric.Polygon(points, { left: 30, top: 30, fill: this.primaryColor, stroke: this.secondaryColor, opacity: this.transparency, strokeWidth: this.canvas.freeDrawingBrush.width })); } deleteElement() { let activeObjects = this.canvas.getActiveObjects(); this.canvas.discardActiveObject(); if (activeObjects.length) { this.canvas.remove.apply(this.canvas, activeObjects); } } setDrawingMode() { this.drawingMode = !this.drawingMode; this.canvas.isDrawingMode = this.drawingMode; this.forceUpdate(); } setLineWidth(event) { let value = parseInt(event.target.value, 10) || 1; this.canvas.freeDrawingBrush.width = value; this.forceUpdate(); } setTransparency(event) { let value = parseInt(event.target.value, 10) || 1; if( value !== 0 ) { this.transparency = 1 - value/100; } else { this.transparency = 1; } this.forceUpdate(); } sendBackwards() { let actObjects = this.canvas.getActiveObject(); if (actObjects) { this.canvas.sendBackwards(actObjects); } } bringForwards(){ let actObjects = this.canvas.getActiveObject(); if (actObjects) { this.canvas.bringForward(actObjects); } } loadImg(event) { this.reader.readAsDataURL(event.target.files[0]); } downloadImg() { let href = this.canvas.toDataURL({ format: 'png', quality: 1 }); let url = href.replace(/^data:image\/[^;]+/, 'data:application/octet-stream'); let a = document.createElement('a'); a.style = 'display: none'; a.href = url; a.download = 'image.png'; document.body.appendChild(a); a.click(); document.body.removeChild(a); } undo() { this.canvas_config.redoStatus = false; if (this.canvas_config.undoFinishedStatus) { if (this.canvas_config.currentStateIndex === -1) { this.canvas_config.undoStatus = false; this.canvas_config.undoDisabled = true; } else { if (this.canvas_config.canvasState.length >= 1) { this.canvas_config.undoFinishedStatus = 0; if(this.canvas_config.currentStateIndex !== 0) { this.canvas_config.undoStatus = true; this.canvas.loadFromJSON(this.canvas_config.canvasState[this.canvas_config.currentStateIndex - 1], () => { let jsonData = JSON.parse(this.canvas_config.canvasState[this.canvas_config.currentStateIndex - 1]); this.canvas.renderAll(); this.canvas_config.undoStatus = false; this.canvas_config.currentStateIndex -= 1; this.canvas_config.undoDisabled = false; this.canvas_config.redoDisabled = false; this.canvas_config.undoFinishedStatus = 1; }); } else if (this.canvas_config.currentStateIndex === 0) { this.canvas.clear(); this.canvas_config.undoFinishedStatus = 1; this.canvas_config.undoDisabled = true; //this.canvas_config.undoButton.disabled = 'disabled'; this.canvas_config.currentStateIndex -= 1; } } } } if (this.canvas_config.currentStateIndex === -1) { this.canvas_config.undoDisabled = true; } this.forceUpdate(); } redo() { if(this.canvas_config.redoFinishedStatus) { if((this.canvas_config.currentStateIndex === this.canvas_config.canvasState.length - 1) && this.canvas_config.currentStateIndex !== -1) { this.canvas_config.redoDisabled = true; } else { if (this.canvas_config.canvasState.length >= this.canvas_config.currentStateIndex && this.canvas_config.canvasState.length !== 0) { this.canvas_config.redoFinishedStatus = 0; this.canvas_config.redoStatus = true; this.canvas.loadFromJSON(this.canvas_config.canvasState[this.canvas_config.currentStateIndex + 1], () => { let jsonData = JSON.parse(this.canvas_config.canvasState[this.canvas_config.currentStateIndex + 1]); this.canvas.renderAll(); this.canvas_config.redoStatur = false; this.canvas_config.currentStateIndex += 1; if(this.canvas_config.currentStateIndex !== -1) { this.canvas_config.undoDisabled = false; } this.canvas_config.redoFinishedStatus = 1; if((this.canvas_config.currentStateIndex === this.canvas_config.canvasState.length - 1) && this.canvas_config.currentStateIndex !== -1) { this.canvas_config.redoDisabled = true; this.canvas_config.redoStatus = false; } }); } } } } copyActiveObjects() { this.canvas.getActiveObject().clone((cloned) => { this.clipboard = cloned; }); this.paste(); } paste() { this.clipboard.clone( (clonedObj) => { this.canvas.discardActiveObject(); clonedObj.set({ left: clonedObj.left + 10, top: clonedObj.top + 10, evented: true, }); if (clonedObj.type === 'activeSelection') { // active selection needs a reference to the canvas. clonedObj.canvas = this.canvas; clonedObj.forEachObject((obj) => { this.canvas.add(obj); }); // this should solve the unselectability clonedObj.setCoords(); } else { this.canvas.add(clonedObj); } this.clipboard.top += 10; this.clipboard.left += 10; this.canvas.setActiveObject(clonedObj); this.canvas.requestRenderAll(); }); } getDrawedCoordinates(objects) { let coordinates = { minX: 10000, minY: 10000, maxX: 0, maxY: 0 }; for (let i = 0; i < objects.length; i++){ let coords = objects[i].aCoords; for (let coord in coords) { if (coords[coord].x > coordinates.maxX) coordinates.maxX = coords[coord].x; if (coords[coord].y > coordinates.maxY) coordinates.maxY = coords[coord].y; if (coords[coord].x < coordinates.minX) coordinates.minX = coords[coord].x; if (coords[coord].y < coordinates.minY) coordinates.minY = coords[coord].y; } } return coordinates; } showLicense() { let coordinates = this.getDrawedCoordinates(this.canvas.getObjects()); let href = this.canvas.toSVG({ suppressPreamble: true, width: coordinates.maxX - coordinates.minX, height: coordinates.maxY - coordinates.minY, viewBox: { x: coordinates.minX, y: coordinates.minY, width: coordinates.maxX - coordinates.minX, height: coordinates.maxY - coordinates.minY } }); this.setState({ license: true, file: { url: href, format: 'svg+xml', name: 'Image', size: href.length } }); } handleChange(e) { this.setState({ [e.target.name]: e.target.value }); } changeLicense(event, data) { this.setState({ licenseValue: data.value, }); } /*dataURLtoBlob(dataURL) { //http://mitgux.com/send-canvas-to-server-as-file-using-ajax // Decode the dataURL let binary = atob(dataURL.split(',')[1]); // Create 8-bit unsigned array let array = []; for(let i = 0; i < binary.length; i++) { array.push(binary.charCodeAt(i)); } // Return our Blob object return new Blob([new Uint8Array(array)], {type: 'image/svg+xml'}); }*/ submitPressed(e) { e.preventDefault(); if(this.state.copyrightHolder === undefined || this.state.copyrightHolder === ''){this.state.copyrightHolder = this.props.userFullName;} let paintModalState = this.props.PaintModalStore; if(paintModalState.toEdit === 'SVG') { let payload = { url: this.props.PaintModalStore.url, type: 'image/svg+xml', license: this.state.licenseValue, copyrightHolder: this.state.copyrightHolder, title: this.state.title || 'Image', text: this.state.alt, filesize: this.state.file.size, filename: 'Image.svg', bytes: this.state.file.url }; this.context.executeAction(updateGraphic, payload); } else { let payload = { type: 'image/svg+xml', license: this.state.licenseValue, copyrightHolder: this.state.copyrightHolder, title: this.state.title || 'Image', text: this.state.alt, filesize: this.state.file.size, filename: 'Image.svg', bytes: this.state.file.url }; this.context.executeAction(uploadMediaFiles, payload); } this.handleClose(); return false; } componentWillReceiveProps(nextProps) { let src = nextProps.PaintModalStore.url; let ext = null; if (src) ext = src.split('.')[src.split('.').length - 1]; let title = nextProps.PaintModalStore.title ? nextProps.PaintModalStore.title : ''; let alt = nextProps.PaintModalStore.altText ? nextProps.PaintModalStore.altText : ''; this.setState({ title: title, alt: alt }); if(nextProps.PaintModalStore.toEdit && nextProps.PaintModalStore.toEdit !== 'Image'){ this.handleOpen(); let str = nextProps.PaintModalStore.svg; fabric.loadSVGFromString(str, (objects) => { for (let i = 0; i < objects.length; i++){ this.canvas.add(objects[i]); } // Black Magic to render correctly imported SVGs from a Slide... please don't remove, unless // you find a better solution (real solution) let dummy = new fabric.Rect({ width: 20, height: 20, left: 30, top:0 }); this.canvas.add(dummy); this.undo(); // Black Magic ends here. this.canvas.renderAll(); }); } else if (nextProps.PaintModalStore.toEdit) { this.handleOpen(); fabric.Image.fromURL(nextProps.PaintModalStore.url, (oImg) => { this.canvas.add(oImg); this.canvas.renderAll(); }); } } handleKeyPress = (event, param) => { if(event.key === 'Enter'){ // console.log('enter key'); if(param === 'handlePaintOpen') { this.handleOpen(); } } } render() { this.context.getUser().username; let submitButtonText = this.context.intl.formatMessage(this.messages.addToSlide); let submitButtonIcon = 'arrow right'; let modePadding = {'paddingBottom': '1.5em', 'paddingTop': '1.5em'}; let saveHandler= this.showLicense; let mode = this.drawingMode ? (<div><Icon name="pencil"/> {this.context.intl.formatMessage(this.messages.drawingMode)}</div>) : (<div><Icon name="hand point up outline"/>{this.context.intl.formatMessage(this.messages.selectMode)}</div>); let heading = this.context.intl.formatMessage(this.messages.paintHeading); let licenseBoxes = ''; let content = <div> <div id="paintModalDescription" tabIndex="0">{this.context.intl.formatMessage(this.messages.paintTitle)}</div> <Segment textAlign="center" > <div className="ui padded grid"> <div className="four wide column"> <div className="ui grid"> <div className="sixteen wide column"> <Button className="icon button" onClick={this.undo} disabled={this.canvas_config.undoDisabled} data-tooltip={this.context.intl.formatMessage(this.messages.undo)} aria-label={this.context.intl.formatMessage(this.messages.undo)}><Icon name="reply"/></Button> <Button className="icon button" onClick={this.redo} disabled={this.canvas_config.redoDisabled} data-tooltip={this.context.intl.formatMessage(this.messages.redo)} aria-label={this.context.intl.formatMessage(this.messages.redo)}><Icon name="share"/></Button> <Button className="icon button" onClick={this.bringForwards} disabled={this.noActiveObject} data-tooltip={this.context.intl.formatMessage(this.messages.bringForwards)} aria-label={this.context.intl.formatMessage(this.messages.bringForwards)}><Icon name="arrow up"/></Button> <Button className="icon button" onClick={this.sendBackwards} disabled={this.noActiveObject} data-tooltip={this.context.intl.formatMessage(this.messages.sendBackwards)} aria-label={this.context.intl.formatMessage(this.messages.sendBackwards)}><Icon name="arrow down"/></Button> </div> </div> <div className="ui grid"> <div className="sixteen wide column"> <Button className="icon button" onClick={() => {$('#uploadImage').click();}} data-tooltip={this.context.intl.formatMessage(this.messages.uploadImage)} aria-label={this.context.intl.formatMessage(this.messages.uploadImage)}><Icon name="upload"/></Button> <input type="file" id="uploadImage" style={{ display: 'none' }} onChange={this.loadImg}/> <Button className="icon button" onClick={this.downloadImg} disabled={!this.state.canvasDirty} data-tooltip={this.context.intl.formatMessage(this.messages.downloadImage)} aria-label={this.context.intl.formatMessage(this.messages.downloadImage)}><Icon name="download"/></Button> <Button className="icon button" onClick={this.copyActiveObjects} data-tooltip={this.context.intl.formatMessage(this.messages.clone)} aria-label={this.context.intl.formatMessage(this.messages.clone)}><Icon name="copy"/></Button> <Button className="icon button" onClick={this.deleteElement} data-tooltip={this.context.intl.formatMessage(this.messages.delete)} aria-label={this.context.intl.formatMessage(this.messages.delete)}><Icon name="trash"/></Button> </div> </div><br/> <Button className="icon button" onClick={this.addRect} data-tooltip={this.context.intl.formatMessage(this.messages.addRectangle)} aria-label={this.context.intl.formatMessage(this.messages.addRectangle)}><Icon name="stop"/></Button> <Button className="icon button" onClick={this.addCircle} data-tooltip={this.context.intl.formatMessage(this.messages.addCircle)} aria-label={this.context.intl.formatMessage(this.messages.addCircle)}><Icon name="circle"/></Button> <Button className="icon button" onClick={this.addTriangle} data-tooltip={this.context.intl.formatMessage(this.messages.addTriangle)} aria-label={this.context.intl.formatMessage(this.messages.addTriangle)}><Icon name="caret up"/></Button> {/*<button onClick={this.addText}>Add Text</button>*/} <Button className="icon button" onClick={this.addArrow} data-tooltip={this.context.intl.formatMessage(this.messages.addArrow)} aria-label={this.context.intl.formatMessage(this.messages.addArrow)}><Icon name="arrow right"/></Button> <br/> <div className="ui slider checkbox" style={modePadding}> <input type="checkbox" id="drawing" defaultChecked={this.drawingMode} value={this.drawingMode} onClick={this.setDrawingMode} aria-label={this.drawingMode ? this.context.intl.formatMessage(this.messages.drawingMode) : this.context.intl.formatMessage(this.messages.selectMode)}/> <label htmlFor="drawing">{mode}</label> {/*<label htmlFor="drawing">{this.drawingMode ? '<Icon name="pencil alternate"/> Drawing Mode' : '<Icon name="mouse pointer"/> Select Mode'}</label>*/} </div> <br/> <div> <p><label htmlFor="primaryColor">{this.context.intl.formatMessage(this.messages.primaryColourInput)}</label> <input type="color" id="primaryColor"/></p> <p><label htmlFor="secondaryColor">{this.context.intl.formatMessage(this.messages.secondaryColourInput)}</label> <input type="color" id="secondaryColor"/></p> </div> <br/> <div> <p><label htmlFor="widthInput">{this.context.intl.formatMessage(this.messages.lineBorderWidthInput)}</label> </p> <input type="range" min="0" max="50" step="5" onChange={this.setLineWidth} defaultValue={0} id="widthInput"/> </div> <div> <p><label htmlFor="widthInput">{this.context.intl.formatMessage(this.messages.transparencyInput)}</label> </p> <input type="range" min="0" max="100" step="5" onChange={this.setTransparency} defaultValue={0} id="widthInput"/> </div> </div> <div className="twelve wide column"> <p>{this.context.intl.formatMessage(this.messages.paintInstruction)}</p> <canvas id="fabriccanvas" style={canvasStyle}/> </div> </div> </Segment> </div>; if(this.state.license){ heading = this.context.intl.formatMessage(this.messages.licenseHeading); let innerSvg = '<svg' + this.state.file.url.split('<svg')[1]; //licenseBoxes = (this.state.licenseValue !== 'CC0') ? <div className="required field"><label htmlFor="copyrightHolder">Image created by/ attributed to:</label><Input id="copyrightHolder" aria-required="true" ref="copyrightHolder" name="copyrightHolder" onChange={this.handleChange.bind(this)} required defaultValue={this.props.userFullName}/></div> : ''; licenseBoxes = (this.state.licenseValue !== 'CC0') ? <div className="required field"><label htmlFor="copyrightHolder">{this.context.intl.formatMessage(this.messages.imageAttribution)}</label><Input id="copyrightHolder" ref="copyrightHolder" name="copyrightHolder" onChange={this.handleChange.bind(this)} aria-label={this.context.intl.formatMessage(this.messages.copyrightholder)} aria-required="true" required defaultValue={this.props.userFullName}/></div> : ''; content = <div> {/*<Img src={this.state.file.url} size="large" centered={true}/>*/} <div style={{ textAlign: 'center' }} dangerouslySetInnerHTML={{ __html: innerSvg }} /> <Divider/> <form className="ui form" onSubmit={this.submitPressed.bind(this)}> <div className="required field"> <label htmlFor="mediaTitle">{this.context.intl.formatMessage(this.messages.imageTitle)}</label> <Input defaultValue={this.state.title ? this.state.title : 'Image'} id="mediaTitle" ref="mediaTitle" name="title" onChange={this.handleChange.bind(this)} aria-label={this.context.intl.formatMessage(this.messages.imageTitleAria)} aria-required="true"required autoFocus/> </div> <div className="required field"> <label htmlFor="mediaAltText">{this.context.intl.formatMessage(this.messages.imageDescription)}</label> <Popup trigger={<input id="mediaAltText" ref="mediaAltText" id="UploadMediaModal_input_mediaAltText" name="alt" onChange={this.handleChange.bind(this)} aria-label={this.context.intl.formatMessage(this.messages.imageDescriptionAria)} aria-required="true" defaultValue={this.state.alt ? this.state.alt : ''} required/>} content={this.context.intl.formatMessage(this.messages.imageDescriptionQuestion)} position='top center'/> </div> <div className="required field"> <label htmlFor="mediaLicense">{this.context.intl.formatMessage(this.messages.chooseLicense)}</label> <Dropdown id="mediaLicense" selection options={[{text: 'CC0 Public Domain', value: 'CC0'},{text: 'CC-BY Creative Commons Attribution 4.0', value: 'CC BY 4.0'},{text: 'CC-BY-SA Creative Common Attribution Share-Alike 4.0', value: 'CC BY SA 4.0'}]} defaultValue='CC0' onChange={this.changeLicense.bind(this)} ref="mediaLicense" aria-label={this.context.intl.formatMessage(this.messages.selectLicense)} aria-required="true" required/> </div> {licenseBoxes} <div className="required field"> <div className="ui checkbox"> <input id="terms" type="checkbox" aria-label={this.context.intl.formatMessage(this.messages.agreementAria)} aria-required="true" required/> <label htmlFor="terms">{this.context.intl.formatMessage(this.messages.agreement1)}<a href="/imprint" target="_blank"> {this.context.intl.formatMessage(this.messages.agreement2)} </a>{this.context.intl.formatMessage(this.messages.agreement3)}<a href="/license" target="_blank"> {this.context.intl.formatMessage(this.messages.agreement4)} </a>{this.context.intl.formatMessage(this.messages.agreement5)}</label>{/*TODO Add a link to the slidewiki terms/cond site, currently not exising*/} </div> </div> <Button type='submit' id="UploadFormSubmitButton" style={{display: 'none'}}>Submit</Button> {/*black magic hack to trigger the form from the outside*/} </form> </div>; saveHandler = (() => {$('#UploadFormSubmitButton').click();}); submitButtonText = this.context.intl.formatMessage(this.messages.upload); submitButtonIcon = 'upload'; } return( <Modal trigger={ <a className="item" id="paintModalTrigger" role="button" onClick={this.handleOpen} onKeyPress={(evt) => this.handleKeyPress(evt, 'handlePaintOpen')}> <i tabIndex="0" className="paint brush icon"></i>{this.context.intl.formatMessage(this.messages.paintButton)} </a> } open={this.state.modalOpen} onOpen={this.handleOpen} onClose={this.handleClose} id="paintModal" aria-labelledby="paintModalHeader" aria-describedby="paintModalDescription" tabIndex="0" > <FocusTrap id="focus-trap-paintModal" className = "header" active={this.state.activeTrap} focusTrapOptions={{ onDeactivate:this.unmountTrap, clickOutsideDeactivates:true, initialFocus: '#paintModalDescription' }} > <Modal.Header className="ui center aligned" id="paintModalHeader"> <h1 style={headerStyle}>{heading}</h1> </Modal.Header> <Modal.Content> <Divider/> {content} <Divider/> </Modal.Content> <Modal.Actions> <button onClick={this.handleClose} className="ui cancel button"> <i className="remove icon"/> {this.context.intl.formatMessage(this.messages.cancel)} </button> <Button id="PaintModalSaveButton" ref="PaintModalSaveButton" color="green" tabIndex="0" type="button" aria-label={this.context.intl.formatMessage(this.messages.upload)} icon={submitButtonIcon} labelPosition='left' content={submitButtonText} disabled={!this.state.canvasDirty} onClick={saveHandler} /> </Modal.Actions> </FocusTrap> </Modal> ); } } PaintModal.contextTypes = { executeAction: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, getUser: PropTypes.func }; PaintModal = connectToStores(PaintModal, [PaintModalStore], (context, props) => { return { PaintModalStore: context.getStore(PaintModalStore).getState() }; }); export default PaintModal;
assets/jqwidgets/jqwidgets-react/react_jqxdocking.js
juannelisalde/holter
/* jQWidgets v4.5.4 (2017-June) Copyright (c) 2011-2017 jQWidgets. License: http://jqwidgets.com/license/ */ import React from 'react'; const JQXLite = window.JQXLite; export default class JqxDocking extends React.Component { componentDidMount() { let options = this.manageAttributes(); this.createComponent(options); }; manageAttributes() { let properties = ['cookies','cookieOptions','disabled','floatingWindowOpacity','height','keyboardNavigation','mode','orientation','rtl','theme','width','windowsMode','windowsOffset']; let options = {}; for(let item in this.props) { if(item === 'settings') { for(let itemTwo in this.props[item]) { options[itemTwo] = this.props[item][itemTwo]; } } else { if(properties.indexOf(item) !== -1) { options[item] = this.props[item]; } } } return options; }; createComponent(options) { if(!this.style) { for (let style in this.props.style) { JQXLite(this.componentSelector).css(style, this.props.style[style]); } } if(this.props.className !== undefined) { let classes = this.props.className.split(' '); for (let i = 0; i < classes.length; i++ ) { JQXLite(this.componentSelector).addClass(classes[i]); } } if(!this.template) { JQXLite(this.componentSelector).html(this.props.template); } JQXLite(this.componentSelector).jqxDocking(options); }; setOptions(options) { JQXLite(this.componentSelector).jqxDocking('setOptions', options); }; getOptions() { if(arguments.length === 0) { throw Error('At least one argument expected in getOptions()!'); } let resultToReturn = {}; for(let i = 0; i < arguments.length; i++) { resultToReturn[arguments[i]] = JQXLite(this.componentSelector).jqxDocking(arguments[i]); } return resultToReturn; }; on(name,callbackFn) { JQXLite(this.componentSelector).on(name,callbackFn); }; off(name) { JQXLite(this.componentSelector).off(name); }; cookies(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('cookies', arg) } else { return JQXLite(this.componentSelector).jqxDocking('cookies'); } }; cookieOptions(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('cookieOptions', arg) } else { return JQXLite(this.componentSelector).jqxDocking('cookieOptions'); } }; disabled(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('disabled', arg) } else { return JQXLite(this.componentSelector).jqxDocking('disabled'); } }; floatingWindowOpacity(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('floatingWindowOpacity', arg) } else { return JQXLite(this.componentSelector).jqxDocking('floatingWindowOpacity'); } }; height(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('height', arg) } else { return JQXLite(this.componentSelector).jqxDocking('height'); } }; keyboardNavigation(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('keyboardNavigation', arg) } else { return JQXLite(this.componentSelector).jqxDocking('keyboardNavigation'); } }; mode(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('mode', arg) } else { return JQXLite(this.componentSelector).jqxDocking('mode'); } }; orientation(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('orientation', arg) } else { return JQXLite(this.componentSelector).jqxDocking('orientation'); } }; rtl(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('rtl', arg) } else { return JQXLite(this.componentSelector).jqxDocking('rtl'); } }; theme(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('theme', arg) } else { return JQXLite(this.componentSelector).jqxDocking('theme'); } }; width(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('width', arg) } else { return JQXLite(this.componentSelector).jqxDocking('width'); } }; windowsMode(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('windowsMode', arg) } else { return JQXLite(this.componentSelector).jqxDocking('windowsMode'); } }; windowsOffset(arg) { if (arg !== undefined) { JQXLite(this.componentSelector).jqxDocking('windowsOffset', arg) } else { return JQXLite(this.componentSelector).jqxDocking('windowsOffset'); } }; addWindow(windowId, mode, panel, position) { JQXLite(this.componentSelector).jqxDocking('addWindow', windowId, mode, panel, position); }; closeWindow(windowId) { JQXLite(this.componentSelector).jqxDocking('closeWindow', windowId); }; collapseWindow(windowId) { JQXLite(this.componentSelector).jqxDocking('collapseWindow', windowId); }; destroy() { JQXLite(this.componentSelector).jqxDocking('destroy'); }; disableWindowResize(windowId) { JQXLite(this.componentSelector).jqxDocking('disableWindowResize', windowId); }; disable() { JQXLite(this.componentSelector).jqxDocking('disable'); }; exportLayout() { return JQXLite(this.componentSelector).jqxDocking('exportLayout'); }; enable() { JQXLite(this.componentSelector).jqxDocking('enable'); }; expandWindow(windowId) { JQXLite(this.componentSelector).jqxDocking('expandWindow', windowId); }; enableWindowResize(windowId) { JQXLite(this.componentSelector).jqxDocking('enableWindowResize', windowId); }; focus() { JQXLite(this.componentSelector).jqxDocking('focus'); }; hideAllCloseButtons() { JQXLite(this.componentSelector).jqxDocking('hideAllCloseButtons'); }; hideAllCollapseButtons() { JQXLite(this.componentSelector).jqxDocking('hideAllCollapseButtons'); }; hideCollapseButton(windowId) { JQXLite(this.componentSelector).jqxDocking('hideCollapseButton', windowId); }; hideCloseButton(windowId) { JQXLite(this.componentSelector).jqxDocking('hideCloseButton', windowId); }; importLayout(Json) { JQXLite(this.componentSelector).jqxDocking('importLayout', Json); }; move(windowId, panel, position) { JQXLite(this.componentSelector).jqxDocking('move', windowId, panel, position); }; pinWindow(windowId) { JQXLite(this.componentSelector).jqxDocking('pinWindow', windowId); }; setWindowMode(windowId, mode) { JQXLite(this.componentSelector).jqxDocking('setWindowMode', windowId, mode); }; showCloseButton(windowId) { JQXLite(this.componentSelector).jqxDocking('showCloseButton', windowId); }; showCollapseButton(windowId) { JQXLite(this.componentSelector).jqxDocking('showCollapseButton', windowId); }; setWindowPosition(windowId, top, left) { JQXLite(this.componentSelector).jqxDocking('setWindowPosition', windowId, top, left); }; showAllCloseButtons() { JQXLite(this.componentSelector).jqxDocking('showAllCloseButtons'); }; showAllCollapseButtons() { JQXLite(this.componentSelector).jqxDocking('showAllCollapseButtons'); }; unpinWindow(windowId) { JQXLite(this.componentSelector).jqxDocking('unpinWindow', windowId); }; render() { let id = 'jqxDocking' + JQXLite.generateID(); this.componentSelector = '#' + id; return ( <div id={id}>{this.props.value}{this.props.children}</div> ) }; };
src/routes/login/index.js
donal-crotty/fuzzy-telegram
/** * React Starter Kit (https://www.reactstarterkit.com/) * * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import React from 'react'; // import App from '../../components/App'; import Login from './Login'; export default { path: '/', action() { return <Login />; }, };