path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
app/components/Header/HeaderComponent.js
TriPSs/popcorn-time-desktop
// @flow import React from 'react' import { withRouter } from 'react-router' import { Link } from 'react-router-dom' import classNames from 'classnames' import logoImage from 'images/logo.png' import * as HomeConstants from 'components/Home/HomeConstants' import classes from './Header.scss' import type { Props } from './HeaderTypes' export default withRouter(class extends React.Component { props: Props state = { searchQuery: '', } handleSearchChange = event => this.setState({ searchQuery: event.target.value }) handleKeyPress = (event) => { if (event.key === 'Enter') { this.handleSearch() } } handleSearch = () => { const { history } = this.props const { searchQuery } = this.state history.replace({ pathname: '/search', state : { keywords: searchQuery, }, }) } render() { const { match: { params: { mode } } } = this.props return ( <div className={classes.menu__container}> <ul className={classes.menu}> <li className={classNames(classes.menu__item, { [classes['menu__item--active']]: mode === HomeConstants.MODE_MOVIES, }, classes['menu__item-left'])}> <Link to={'/movies'} replace className="nav-link"> Movies </Link> </li> <li className={classNames(classes.menu__item, { [classes['menu__item--active']]: mode === HomeConstants.MODE_SHOWS, }, classes['menu__item-left'])}> <Link className="nav-link" to={'/shows'} replace> TV Shows </Link> </li> <li className={classNames(classes.menu__item, classes['menu__item-logo'])}> <img src={logoImage} alt={'Popcorn Time'} /> </li> <li className={classNames(classes.menu__item, { [classes['menu__item--active']]: mode === HomeConstants.MODE_BOOKMARKS, }, classes['menu__item-right'])}> <Link className="nav-link" to={'/bookmarks'} replace> <i className={'ion-heart'} /> </Link> </li> <li className={classNames(classes.menu__item, classes['menu__item-search'], { [classes['menu__item--active']]: mode === HomeConstants.MODE_SEARCH, }, classes['menu__item-right'])}> <input type={'text'} onChange={this.handleSearchChange} onKeyPress={this.handleKeyPress} placeholder={'Search'} /> <i role={'presentation'} onClick={this.handleSearch} className={'ion-search'} /> </li> </ul> </div> ) } })
src/svg-icons/communication/import-export.js
mmrtnz/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let CommunicationImportExport = (props) => ( <SvgIcon {...props}> <path d="M9 3L5 6.99h3V14h2V6.99h3L9 3zm7 14.01V10h-2v7.01h-3L15 21l4-3.99h-3z"/> </SvgIcon> ); CommunicationImportExport = pure(CommunicationImportExport); CommunicationImportExport.displayName = 'CommunicationImportExport'; CommunicationImportExport.muiName = 'SvgIcon'; export default CommunicationImportExport;
src/svg-icons/action/record-voice-over.js
tan-jerene/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionRecordVoiceOver = (props) => ( <SvgIcon {...props}> <circle cx="9" cy="9" r="4"/><path d="M9 15c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4zm7.76-9.64l-1.68 1.69c.84 1.18.84 2.71 0 3.89l1.68 1.69c2.02-2.02 2.02-5.07 0-7.27zM20.07 2l-1.63 1.63c2.77 3.02 2.77 7.56 0 10.74L20.07 16c3.9-3.89 3.91-9.95 0-14z"/> </SvgIcon> ); ActionRecordVoiceOver = pure(ActionRecordVoiceOver); ActionRecordVoiceOver.displayName = 'ActionRecordVoiceOver'; ActionRecordVoiceOver.muiName = 'SvgIcon'; export default ActionRecordVoiceOver;
client/views/omnichannel/agents/RemoveAgentButton.js
VoiSmart/Rocket.Chat
import { Table, Icon, Button } from '@rocket.chat/fuselage'; import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import React from 'react'; import DeleteWarningModal from '../../../components/DeleteWarningModal'; import { useSetModal } from '../../../contexts/ModalContext'; import { useToastMessageDispatch } from '../../../contexts/ToastMessagesContext'; import { useTranslation } from '../../../contexts/TranslationContext'; import { useEndpointAction } from '../../../hooks/useEndpointAction'; function RemoveAgentButton({ _id, reload }) { const deleteAction = useEndpointAction('DELETE', `livechat/users/agent/${_id}`); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); const t = useTranslation(); const handleRemoveClick = useMutableCallback(async () => { const result = await deleteAction(); if (result.success === true) { reload(); } }); const handleDelete = useMutableCallback((e) => { e.stopPropagation(); const onDeleteAgent = async () => { try { await handleRemoveClick(); dispatchToastMessage({ type: 'success', message: t('Agent_removed') }); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); } setModal(); }; setModal(<DeleteWarningModal onDelete={onDeleteAgent} onCancel={() => setModal()} />); }); return ( <Table.Cell fontScale='p1' color='hint' withTruncatedText> <Button small ghost title={t('Remove')} onClick={handleDelete}> <Icon name='trash' size='x16' /> </Button> </Table.Cell> ); } export default RemoveAgentButton;
docs/client.js
xiaoking/react-bootstrap
import 'bootstrap/less/bootstrap.less'; import './assets/docs.css'; import './assets/style.css'; import './assets/carousel.png'; import './assets/logo.png'; import './assets/favicon.ico'; import './assets/thumbnail.png'; import './assets/thumbnaildiv.png'; import 'codemirror/mode/htmlmixed/htmlmixed'; import 'codemirror/mode/javascript/javascript'; import 'codemirror/theme/solarized.css'; import 'codemirror/lib/codemirror.css'; import './assets/CodeMirror.css'; import React from 'react'; import CodeMirror from 'codemirror'; import 'codemirror/addon/runmode/runmode'; import Router from 'react-router'; import routes from './src/Routes'; global.CodeMirror = CodeMirror; Router.run(routes, Router.RefreshLocation, Handler => { React.render( React.createElement(Handler, window.INITIAL_PROPS), document); });
src/components/groups/AffectSummaryLaggerRowTableGroup.js
nbuechler/ample-affect-exhibit
import React from 'react'; import DivList from '../lists/DivList' export default class AffectSummaryLaggerRowTableGroup extends React.Component { constructor (props) { super(props); } render () { let array = this.props.data; let i = this.props.iterator; return ( <tr key={i + '-affect-row'}> <td> <div className="affect--display_name" key={i + '-r-affect'}> {array[i].emotion} </div> </td> <td> <div className="affect--display_rank" key={i + '-r-rank'}> {array.length - i} </div> </td> <td> <div className="affect--display_scores" key={i + '-normal-scores'}> {array[i].normalized_r_score.toFixed(4)} </div> </td> </tr> ); } }
src/svg-icons/maps/flight.js
lawrence-yu/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsFlight = (props) => ( <SvgIcon {...props}> <path d="M10.18 9"/><path d="M21 16v-2l-8-5V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5l8 2.5z"/> </SvgIcon> ); MapsFlight = pure(MapsFlight); MapsFlight.displayName = 'MapsFlight'; MapsFlight.muiName = 'SvgIcon'; export default MapsFlight;
packages/vx-shape/src/shapes/LinePath.js
Flaque/vx
import React from 'react'; import cx from 'classnames'; import { line } from 'd3-shape'; import { curveLinear } from '@vx/curve'; import additionalProps from '../util/additionalProps'; export default function LinePath({ data, xScale, yScale, x, y, defined = () => true, className, stroke = 'steelblue', strokeWidth = 2, strokeDasharray = '', strokeDashoffset = 0, fill = 'none', curve = curveLinear, glyph, ...restProps }) { const path = line() .x(d => xScale(x(d))) .y(d => yScale(y(d))) .defined(defined) .curve(curve); return ( <g> <path className={cx('vx-linepath', className)} d={path(data)} stroke={stroke} strokeWidth={strokeWidth} strokeDasharray={strokeDasharray} strokeDashoffset={strokeDashoffset} fill={fill} {...additionalProps(restProps, data)} /> {glyph && <g className="vx-linepath-glyphs"> {data.map(glyph)} </g>} </g> ); }
hw7-frontend/src/components/article/article.js
lanyangyang025/COMP531
import React from 'react' import { connect } from 'react-redux' import { Comment } from './comment' import { AddComment } from './addComment' import { searchKeyword,showComments,addArticle,addComments,editPost } from './articleActions' //content of a card export const Article = ({ count, article, _id, author, date, text, img, comments, dispatch, username}) => { let word; return( <div name="all_articles" className="panel panel-default text-left"> <div className="panel-body"> <div className="col-sm-3"> <div className="well"> <p><span>{date}, {author}:</span></p> </div> </div> <div className="col-sm-9"> <p><img src={img} id="december18" className="ys"></img></p> { (author==username)? <div> <textarea id={'edit_post'+count} name='edit_article' className="form-control col-sm-12" rows="6" value={text} ref={ (node) => { word = node }} onChange={()=>{dispatch(editPost(word.value, article))}}></textarea> </div> :<div><p>{text}</p></div> } <div> <input type="button" className="btn btn-primary btn-sm" id={'showComment'} value={article.displayComment?'Hide Comments':'Show Comments'} onClick={() => dispatch(showComments(article))}></input> <input type="button" className="btn btn-primary btn-sm" id={'addComment'} value={article.displayaddComment?'Cancel a Comment':'Add a Comment'} onClick={() => {dispatch(addComments(article))}}></input> </div> </div> <div> { (article.displayaddComment==true)? <AddComment article={article} dispatch={dispatch}/> :'' } </div> <div> { (article.displayComment==true && comments.length>0)? comments.sort((a,b) => { if (a.date < b.date) return 1; if (a.date > b.date) return -1; return 0 }).map( comment => (<Comment commentId={comment.commentId} key={comment.commentId} author={comment.author} date={comment.date} text={comment.text} username={username} comment={comment} dispatch={dispatch} article={article}/>) ) :'' } </div> </div> </div> ) } export default connect()(Article)
src/static/containers/NotFound/index.js
AdrienAgnel/testDjangoApp
import React from 'react'; export default class NotFoundView extends React.Component { render() { return ( <div> <h1>NOT FOUND</h1> </div> ); } }
internals/templates/containers/HomePage/index.js
fascinating2000/productFrontend
/* * HomePage * * This is the first thing users see of our App, at the '/' route * * NOTE: while this component should technically be a stateless functional * component (SFC), hot reloading does not currently support SFCs. If hot * reloading is not a necessity for you then you can refactor it and remove * the linting exception. */ import React from 'react'; import { FormattedMessage } from 'react-intl'; import messages from './messages'; export default class HomePage extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function render() { return ( <h1> <FormattedMessage {...messages.header} /> </h1> ); } }
src/components/Tree/Tree.js
wundery/wundery-ui-react
import React from 'react'; import TreeItem from './TreeItem'; class Tree extends React.Component { static propTypes = { // Tree data, see docs data: React.PropTypes.oneOfType([ React.PropTypes.array, React.PropTypes.object, ]).isRequired, // Triggered on item click onItemClick: React.PropTypes.func.isRequired, // Rendered on each level once levelPrefix: React.PropTypes.func, // maximum tree depth maxDepth: React.PropTypes.number, // Rendered on each item itemAddon: React.PropTypes.func, // Func that returns a boolean value indicating if a node should be highlighted highlighted: React.PropTypes.func, }; static defaultProps = { levelPrefix: null, maxDepth: null, highlighted: null, }; constructor(props) { super(props); const { data } = props; this.state = { data, }; } componentWillReceiveProps({ data }) { this.setState({ data }); } renderNode = (node, index) => { const { onItemClick, levelPrefix, maxDepth, itemAddon, highlighted } = this.props; const { childs, depth, expanded, label } = node; return ( <TreeItem label={label} depth={depth} key={index} expanded={expanded} childs={childs} onClick={onItemClick} node={node} levelPrefix={levelPrefix} maxDepth={maxDepth} itemAddon={itemAddon} highlighted={highlighted} /> ); } renderLevelPrefix() { const { levelPrefix } = this.props; if (levelPrefix) { return levelPrefix(null, 0); } return null; } render() { const { data } = this.state; const nodes = [].concat(data); return ( <div className="ui-tree"> {this.renderLevelPrefix()} {nodes.map(this.renderNode)} </div> ); } } export default Tree;
examples/huge-apps/routes/Course/components/Course.js
arbas/react-router
import React from 'react'; import Dashboard from './Dashboard'; import Nav from './Nav'; var styles = {}; styles.sidebar = { float: 'left', width: 200, padding: 20, borderRight: '1px solid #aaa', marginRight: 20 }; class Course extends React.Component { render () { let { children, params } = this.props; let course = COURSES[params.courseId]; return ( <div> <h2>{course.name}</h2> <Nav course={course} /> {children && children.sidebar && children.main ? ( <div> <div className="Sidebar" style={styles.sidebar}> {children.sidebar} </div> <div className="Main" style={{padding: 20}}> {children.main} </div> </div> ) : ( <Dashboard /> )} </div> ); } } export default Course;
app/javascript/mastodon/features/ui/components/link_footer.js
d6rkaiz/mastodon
import { connect } from 'react-redux'; import React from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; import { Link } from 'react-router-dom'; import { invitesEnabled, version, repository, source_url } from 'mastodon/initial_state'; import { logOut } from 'mastodon/utils/log_out'; import { openModal } from 'mastodon/actions/modal'; const messages = defineMessages({ logoutMessage: { id: 'confirmations.logout.message', defaultMessage: 'Are you sure you want to log out?' }, logoutConfirm: { id: 'confirmations.logout.confirm', defaultMessage: 'Log out' }, }); const mapDispatchToProps = (dispatch, { intl }) => ({ onLogout () { dispatch(openModal('CONFIRM', { message: intl.formatMessage(messages.logoutMessage), confirm: intl.formatMessage(messages.logoutConfirm), onConfirm: () => logOut(), })); }, }); export default @injectIntl @connect(null, mapDispatchToProps) class LinkFooter extends React.PureComponent { static propTypes = { withHotkeys: PropTypes.bool, onLogout: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; handleLogoutClick = e => { e.preventDefault(); e.stopPropagation(); this.props.onLogout(); return false; } render () { const { withHotkeys } = this.props; return ( <div className='getting-started__footer'> <ul> {invitesEnabled && <li><a href='/invites' target='_blank'><FormattedMessage id='getting_started.invite' defaultMessage='Invite people' /></a> · </li>} {withHotkeys && <li><Link to='/keyboard-shortcuts'><FormattedMessage id='navigation_bar.keyboard_shortcuts' defaultMessage='Hotkeys' /></Link> · </li>} <li><a href='/auth/edit'><FormattedMessage id='getting_started.security' defaultMessage='Security' /></a> · </li> <li><a href='/about/more' target='_blank'><FormattedMessage id='navigation_bar.info' defaultMessage='About this server' /></a> · </li> <li><a href='https://joinmastodon.org/apps' target='_blank'><FormattedMessage id='navigation_bar.apps' defaultMessage='Mobile apps' /></a> · </li> <li><a href='/terms' target='_blank'><FormattedMessage id='getting_started.terms' defaultMessage='Terms of service' /></a> · </li> <li><a href='/settings/applications' target='_blank'><FormattedMessage id='getting_started.developers' defaultMessage='Developers' /></a> · </li> <li><a href='https://docs.joinmastodon.org' target='_blank'><FormattedMessage id='getting_started.documentation' defaultMessage='Documentation' /></a> · </li> <li><a href='/auth/sign_out' onClick={this.handleLogoutClick}><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></a></li> </ul> <p> <FormattedMessage id='getting_started.open_source_notice' defaultMessage='Mastodon is open source software. You can contribute or report issues on GitHub at {github}.' values={{ github: <span><a href={source_url} rel='noopener' target='_blank'>{repository}</a> (v{version})</span> }} /> </p> </div> ); } };
src/routes/Simon/containers/PlayingView.js
dimitrisafendras/multiGame
import React from 'react' import { bindActionCreators } from 'redux' import { createStore } from 'redux' import { connect } from 'react-redux' import { Pads } from '../containers/Pads' import { startGame, reset } from '../modules/actions' import './PlayingView.scss' const buttonStyle = { border: '2px solid #a1a1a1', padding: '10px 40px', background: '#dddddd', width: '250px', borderRadius:'25px', } const style = { fontFamily: "Times New Roman", color: 'black', } const playingViewActions = { startGame, reset } export let PlayingView = ({ actions, gameState, score, highScore }) => { switch (gameState) { case 'started': return( <div style = {style}> <h1>Simon </h1> <Pads /> <h2> SCORE: { score } </h2> <h5> HIGH SCORE: { highScore } </h5> <button type='reset' onClick={actions.reset} style = {buttonStyle}>RESET</button> </div> ); case 'lose': return( <div style = {style}> <div className="buttons"> <h1>Try again!</h1> <button type="start" onClick={ actions.startGame } style = {buttonStyle}>New game!</button> </div> </div> ); case 'reset': return ( <div style = {style}> <div className="buttons"> <button type="start" onClick={ actions.startGame } style = {buttonStyle}>Start game!</button> </div> </div> ) default: return ( <div style = {style}> <div className="buttons"> <button type="start" onClick={ actions.startGame } style = {buttonStyle}>Start game!</button> </div> </div> ) } }; PlayingView = connect( ({ Simon: { gameState, score, highScore } }) => ({ gameState, score, highScore, }), (dispatch) => ({ actions: bindActionCreators(playingViewActions, dispatch), }), )(PlayingView); export default PlayingView;
app/containers/HomePage/index.js
joegattnet/joegatt.net-client
/* * HomePage * * This is the first thing users see of our App, at the '/' route */ import React from 'react'; import Helmet from 'react-helmet'; import { FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; import { createStructuredSelector } from 'reselect'; import { makeSelectNotes, makeSelectLoading, makeSelectError } from 'containers/App/selectors'; import H2 from 'components/H2'; import NotesList from 'components/NotesList'; import Text from 'components/Text'; import AtPrefix from './AtPrefix'; import Form from './Form'; import Input from './Input'; import messages from './messages'; import { loadNotes } from '../App/actions'; import { changeUsername } from './actions'; import { makeSelectUsername } from './selectors'; export class HomePage extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function /** * when initial state username is not null, submit the form to load notes */ componentWillMount() { this.annotations = []; this.annotationMarks = []; } componentDidMount() { if (this.props.username && this.props.username.trim().length > 0) { this.props.onSubmitForm(); } let minimum = 0; //$('.body').offset().top // if $('#single_map:visible').length > 0 then minimum += $('#single_map').outerHeight(true) let newTop = minimum; let correctedTop = minimum; this.annotationMarks.forEach((annotationMark, index) => { newTop = annotationMark.offsetTop; correctedTop = (newTop <= minimum ? minimum : newTop); this.annotations[index].style.top = `${correctedTop}px`; minimum = correctedTop + this.annotations[index].offsetHeight; }); const reversedAnnotations = this.annotations.reverse(); let maximum = this.annotationsContainer.offsetHeight; let newBottom; reversedAnnotations.forEach((annotation, index) => { newTop = annotation.offsetTop; newBottom = newTop + annotation.offsetHeight; correctedTop = newBottom > maximum ? maximum - annotation.offsetHeight : newTop; this.annotations[index].style.top = `${correctedTop}px`; maximum = correctedTop; }); } render() { const { loading, error, notes } = this.props; const NotesListProps = { loading, error, notes, }; return ( <div> <Helmet title="Home Page" meta={[ { name: 'description', content: 'A React.js Boilerplate application homepage' }, ]} /> <div> <H2> <FormattedMessage {...messages.trymeHeader} /> </H2> <Form onSubmit={this.props.onSubmitForm}> <label htmlFor="username"> <FormattedMessage {...messages.trymeMessage} /> <AtPrefix> <FormattedMessage {...messages.trymeAtPrefix} /> </AtPrefix> <Input id="username" type="text" placeholder="mxstbr" value={this.props.username} onChange={this.props.onChangeUsername} /> </label> </Form> <NotesList {...NotesListProps} /> </div> <section id="content"> <Text> <section id="body"> <p id="paragraph-1">At HKW’s <a href="https://www.hkw.de/en/programm/projekte/veranstaltung/p_100677.php">The Principle of the City</a> tonight, <a href="http://www.gsd.harvard.edu/#/people/eve-blau.html">Eve Blau</a> was one of the speakers offering a reaction to Richard Sennet’s (et al) discussion <a href="#annotation-1" id="annotation-mark-1" ref={(annotationMark) => { this.annotationMarks[0] = annotationMark; }}>1</a>. Sennett had referred to one of his central ideas, the <a href="http://www.richardsennett.com/site/SENN/UploadedResources/The%20Open%20City.pdf">Open City</a>, <a href="#annotation-2" id="annotation-mark-2" ref={(annotationMark) => { this.annotationMarks[1] = annotationMark; }}>2</a> and mentioned that he has become interested in open software, specifically Linux. Blau contrasted this form of open-ness with Umberto Eco’s idea of the open work. <a href="#annotation-3" id="annotation-mark-3" ref={(annotationMark) => { this.annotationMarks[2] = annotationMark; }}>3</a>.</p> <p id="paragraph-2">Insofar as I’d ever thought about it, I realise that I had always taken “open” to mean the same thing in both cases. For Eco, a work is open in the sense that it can be “closed off” in one of many ways by the reader; open in the software (and, perhaps, Sennett’s) sense is probably something else. There is not really the distinction of reader/producer. The readers are assumed to be future producers.</p> <p id="paragraph-3">Having said that, it is also a principle of open software, that the software can be put to different uses, read differently, closed off’ differently in Eco’s sense. <a href="#annotation-4" id="annotation-mark-4" ref={(annotationMark) => { this.annotationMarks[3] = annotationMark; }}>4</a> </p> <p id="paragraph-4">While listening to Sennett, the military term of art, open city kept coming to mind. An open city is a demilitarised city, one that is not defended and therefore—in international law—not legitimately<a href="#annotation-5" id="annotation-mark-5" ref={(annotationMark) => { this.annotationMarks[4] = annotationMark; }}>5</a> attacked.</p> </section> <section id="annotations" className="side-annotations" ref={(annotationsContainer) => { this.annotationsContainer = annotationsContainer; }}> <header> <h3>Annotations</h3> </header> <ol> <li id="annotation-1" ref={(annotation) => { this.annotations[0] = annotation; }}> <a href="#annotation-mark-1">1</a>Blau’s statement is available <a href="http://hkw.de/de/app/mediathek/video/26489">here</a>, starting at 73:30 </li> <li id="annotation-2" ref={(annotation) => { this.annotations[1] = annotation; }}> <a href="#annotation-mark-2">2</a>See also, <a href="https://www.youtube.com/watch?v=eEx1apBAS9A">lecture</a> delivered at Harvard GSD. </li> <li id="annotation-3" ref={(annotation) => { this.annotations[2] = annotation; }}> <a href="#annotation-mark-3">3</a>See, for instance, The Role of the Reader </li> <li id="annotation-4" ref={(annotation) => { this.annotations[3] = annotation; }}> <a href="#annotation-mark-4">4</a>Bergson’s and Popper’s “open society” is yet another tangent which can be contrasted with these other uses of the word. </li> <li id="annotation-5" ref={(annotation) => { this.annotations[4] = annotation; }}> <a href="#annotation-mark-5">5</a>Bergson’s and Popper’s “open society” is yet another tangent which can be contrasted with these other uses of the word. Bergson’s and Popper’s “open society” is yet another tangent which can be contrasted with these other uses of the word. Bergson’s and Popper’s “open society” is yet another tangent which can be contrasted with these other uses of the word. </li> </ol> </section> </Text> <aside> <nav id="tags"> <header> <h3> Tags </h3> </header> <ul className="tags"> <li> <a rel="tag" href="/tags/blog">blog</a> </li> </ul> </nav><nav id="versions"> <header> <h3> Versions </h3> </header> <ol> <li> <a href="/texts/212/v/3">v3 (<time title="Sun, 08 Nov 2015 11:33:43 +0000">2 years ago</time>, 195 words, <span title="Damerau-Levenshtein edit distance between this version and the previous one">127 changes</span>)</a> </li> <li> <a href="/texts/212/v/2">v2 (<time title="Mon, 21 Apr 2014 21:27:28 +0000">3 years ago</time>, 195 words, <span title="Damerau-Levenshtein edit distance between this version and the previous one">122 changes</span>)</a> </li> <li> <a href="/texts/212/v/1">v1 (<time title="Thu, 03 Apr 2014 21:47:48 +0000">3 years ago</time>, 194 words, <span title="Damerau-Levenshtein edit distance between this version and the previous one">1,722 changes</span>)</a> </li> </ol> </nav> </aside> </section> </div> ); } } HomePage.propTypes = { loading: React.PropTypes.bool, error: React.PropTypes.oneOfType([ React.PropTypes.object, React.PropTypes.bool, ]), notes: React.PropTypes.oneOfType([ React.PropTypes.array, React.PropTypes.bool, ]), onSubmitForm: React.PropTypes.func, username: React.PropTypes.string, onChangeUsername: React.PropTypes.func, }; export function mapDispatchToProps(dispatch) { return { onChangeUsername: (evt) => dispatch(changeUsername(evt.target.value)), onSubmitForm: (evt) => { if (evt !== undefined && evt.preventDefault) evt.preventDefault(); dispatch(loadNotes()); }, }; } const mapStateToProps = createStructuredSelector({ notes: makeSelectNotes(), username: makeSelectUsername(), loading: makeSelectLoading(), error: makeSelectError(), }); // Wrap the component to inject dispatch and state into it export default connect(mapStateToProps, mapDispatchToProps)(HomePage);
src/routes/Signup/components/SignupForm/SignupForm.js
skylus/tom-rrf
import React from 'react' import PropTypes from 'prop-types' import { Field, reduxForm } from 'redux-form' import RaisedButton from 'material-ui/RaisedButton' import { TextField } from 'redux-form-material-ui' import { required, validateEmail } from 'utils/form' import { SIGNUP_FORM_NAME } from 'constants' import classes from './SignupForm.scss' const SignupForm = ({ pristine, submitting, handleSubmit }) => ( <form className={classes.container} onSubmit={handleSubmit}> <Field name='username' component={TextField} floatingLabelText='Username' validate={required} /> <Field name='email' component={TextField} floatingLabelText='Email' validate={[required, validateEmail]} /> <Field name='password' component={TextField} floatingLabelText='Password' type='password' validate={required} /> <Field name='team' component={TextField} floatingLabelText='Team' validate={required} /> <div className={classes.submit}> <RaisedButton label='Signup' primary type='submit' disabled={pristine || submitting} /> </div> </form> ) SignupForm.propTypes = { pristine: PropTypes.bool.isRequired, // added by redux-form submitting: PropTypes.bool.isRequired, // added by redux-form handleSubmit: PropTypes.func.isRequired // added by redux-form } export default reduxForm({ form: SIGNUP_FORM_NAME })(SignupForm)
milestones/03-inline-styles/After/src/index.js
jaketrent/react-drift
import React from 'react' import ReactDOM from 'react-dom' import DriftApp from './app.js' ReactDOM.render(<DriftApp />, document.getElementById('app'))
app/core.js
Cu7ious/Twitch-App
import React from 'react' import { render } from 'react-dom' import { createStore, combineReducers, applyMiddleware } from 'redux' import { Provider } from 'react-redux' import App from './components/App' import * as reducers from './reducers' import thunk from 'redux-thunk' // ** EDUCATIONAL ** // // ping middleware - simplest Middleware example const ping = function ping(store) { return function (next) { return function (action) { console.log('ping middleware was triggered'); return next(action); }; }; }; // ** EDUCATIONAL ** // const store = createStore( combineReducers( { data: reducers.data, query: reducers.query, filter: reducers.filter, byQuery: reducers.byQuery } ), applyMiddleware(thunk, ping) ) // ** DEBUG CODE ** // import { fetchData, searchChannels, filterAll, filterOnline, filterOffline, filterByQuery } from './actions' window.store = store window.fetchData = fetchData window.searchChannels = searchChannels window.filterAll = filterAll window.filterOnline = filterOnline window.filterOffline = filterOffline window.filterOffline = filterByQuery // ** DEBUG CODE ** // const run = () => { render( <Provider store={store}> <App /> </Provider> , document.getElementById('app') ) } run() store.subscribe(run)
src/main/jsx/client/BuildMetricsPageActions.js
dimacus/DotCi
import ReactDOM from 'react-dom'; import React from 'react'; import BuildMetricsPage from './../pages/BuildMetricsPage.jsx'; import {job} from './../api/Api.jsx'; import {removeFilter,addFilter} from './../api/Api.jsx'; import Drawer from './../Drawer.jsx'; function dataChange(buildMetrics){ ReactDOM.render(<BuildMetricsPage buildMetrics={buildMetrics}/>, document.getElementById('content')); ReactDOM.render(<Drawer menu="job"/>, document.getElementById('nav')); } function queryChange(buildMetrics){ const actions = buildMetrics.actions; let query = buildMetrics.query; job("buildHistoryTabs,metrics[title,chart[*,dataSets[*]]]",query.filter ,query.limit).then(data => { actions.DataChange({...data, filters: data.buildHistoryTabs}); }); } export default function(buildHistory){ const actions = buildHistory.actions; actions.DataChange.onAction = dataChange; actions.QueryChange.onAction = queryChange; actions.RemoveFilter.onAction = removeFilter; actions.AddFilter.onAction = addFilter; }
imports/ui/components/organisms/AppNavigation/PublicNavigation.js
latotty/meteor-sweeper
import React from 'react'; import { LinkContainer } from 'react-router-bootstrap'; import { Nav, NavItem } from 'react-bootstrap'; export const PublicNavigation = () => ( <Nav pullRight> <LinkContainer to="signup"> <NavItem eventKey={1} href="/signup">Sign Up</NavItem> </LinkContainer> <LinkContainer to="login"> <NavItem eventKey={2} href="/login">Log In</NavItem> </LinkContainer> </Nav> ); export default PublicNavigation;
archimate-frontend/src/main/javascript/components/view/edges/model/accessRelationship.js
zhuj/mentha-web-archimate
import React from 'react' import { ModelLinkWidget } from '../BaseLinkWidget' export const TYPE='accessRelationship'; export class AccessRelationshipWidget extends ModelLinkWidget { getBaseClassName(link) { switch (this.props.conceptInfo['access']) { case "r": return TYPE + " r"; case "w": return TYPE + " w"; case "rw": return TYPE + " r w"; } return TYPE; } // drawTitle(link) { // const conceptInfo = this.getConceptInfo(link); // if (conceptInfo) { // const fullTitle = (a) => { // switch (a) { // case "r": return "reads"; // case "w": return "writes"; // case "rw": return "reads and writes"; // } // return a; // }; // return this.drawTitleText(link, fullTitle(conceptInfo['access']), "middle", 0, "50%"); // } // return null; // } }
definitions/npm/fixed-data-table-2_v0.7.x/flow_v0.47.x-v0.52.x/test_fixed-data-table-2_v0.7.x.js
splodingsocks/FlowTyped
/* @flow */ import React from 'react'; import {Cell, Column, ColumnGroup, Table} from 'fixed-data-table-2'; let cell = <Cell/>; cell = <Cell onColumnResize={(left, width, minWidth, maxWidth, columnKey, event) => {event.target;}}/>; // $FlowExpectedError cell = <Cell onColumnResize={(left, width, minWidth, maxWidth, columnKey, event) => minWidth + maxWidth}/>; // $FlowExpectedError let column = <Column/>; column = <Column width={300} minWidth={null}/>; let columnGroup = <ColumnGroup/>; // $FlowExpectedError columnGroup = <ColumnGroup align='top'/>; // $FlowExpectedError let table = <Table/>; table = <Table width={900} rowsCount={10} rowHeight={50} headerHeight={60} />;
node_modules/react-bootstrap/es/Clearfix.js
GregSantulli/react-drum-sequencer
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'; import capitalize from './utils/capitalize'; import { DEVICE_SIZES } from './utils/StyleConfig'; var propTypes = { componentClass: elementType, /** * Apply clearfix * * on Extra small devices Phones * * adds class `visible-xs-block` */ visibleXsBlock: React.PropTypes.bool, /** * Apply clearfix * * on Small devices Tablets * * adds class `visible-sm-block` */ visibleSmBlock: React.PropTypes.bool, /** * Apply clearfix * * on Medium devices Desktops * * adds class `visible-md-block` */ visibleMdBlock: React.PropTypes.bool, /** * Apply clearfix * * on Large devices Desktops * * adds class `visible-lg-block` */ visibleLgBlock: React.PropTypes.bool }; var defaultProps = { componentClass: 'div' }; var Clearfix = function (_React$Component) { _inherits(Clearfix, _React$Component); function Clearfix() { _classCallCheck(this, Clearfix); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } Clearfix.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); DEVICE_SIZES.forEach(function (size) { var propName = 'visible' + capitalize(size) + 'Block'; if (elementProps[propName]) { classes['visible-' + size + '-block'] = true; } delete elementProps[propName]; }); return React.createElement(Component, _extends({}, elementProps, { className: classNames(className, classes) })); }; return Clearfix; }(React.Component); Clearfix.propTypes = propTypes; Clearfix.defaultProps = defaultProps; export default bsClass('clearfix', Clearfix);
src/components/Pomodoro/Pomodoro.js
allanesquina/react-pomodoro
import React from 'react' import classes from './Pomodoro.scss' import ActionButton from './ActionButton' import AlertBox from './AlertBox' import Timer from './Timer' const Audio = window.Audio || (() => false) const START_LABEL = 'Start' const STOP_LABEL = 'Stop' const RESET_LABEL = 'Reset' const POMODORO_TIME = 25 * (60 * 1000) // http://stackoverflow.com/questions/21294302/converting-soundclouds- // milliseconds-to-minutes-and-seconds-with-javascript function millisToMinutesAndSeconds (millis) { const minutes = Math.floor(millis / 60000) const seconds = ((millis % 60000) / 1000).toFixed(0) return minutes + ':' + (seconds < 10 ? '0' : '') + seconds } function playAudio (audio) { if (audio) { audio.currentTime = 0 audio.play() } } export class Pomodoro extends React.Component { constructor (props) { super(props) this.state = { isRunning: false, actionLabel: START_LABEL, time: POMODORO_TIME } this.state.audioList = {} this._loadAudioFiles() this.props.setTime(this.state.time) this.handleTimeActions = this.handleTimeActions.bind(this) this.handleResetAction = this.handleResetAction.bind(this) this.handleCloseAlertBox = this.handleCloseAlertBox.bind(this) } _loadAudioFiles () { ['stop', 'start', 'alarm'].map((file) => { this.state.audioList[file] = new Audio(`${file}.wav`) }) } _startTime () { playAudio(this.state.audioList.start) this._closeAlertBox() const interval = setInterval(() => { if (this.state.time > 0) { this.setState({time: this.state.time - 1000}) this.props.setTime(this.state.time) } else { this._resetTime() this._openAlertBox() } }, 1000) this.setState({ interval, isRunning: true }) } _openAlertBox () { playAudio(this.state.audioList.alarm) this.setState({isAlertBoxActivated: true}) } _closeAlertBox () { this.setState({isAlertBoxActivated: false}) } _stopTime () { playAudio(this.state.audioList.stop) clearInterval(this.state.interval) this.setState({ isRunning: false }) } _resetTime () { clearInterval(this.state.interval) this.props.setTime(POMODORO_TIME) this.setState({ isRunning: false, time: POMODORO_TIME }) } handleTimeActions () { this[this.state.isRunning ? '_stopTime' : '_startTime']() } handleResetAction () { playAudio(this.state.audioList.stop) this._resetTime() } handleCloseAlertBox () { this._closeAlertBox() } render () { const currentTime = millisToMinutesAndSeconds(this.props.currentTime) const actionLabel = this.state.isRunning ? STOP_LABEL : START_LABEL const { handleTimeActions, handleResetAction, handleCloseAlertBox } = this return ( <div className={classes.wrapper}> <Timer currentTime={currentTime} /> <ActionButton text={actionLabel} onClick={handleTimeActions} /> <ActionButton text={RESET_LABEL} onClick={handleResetAction} /> {(this.state.isAlertBoxActivated && <AlertBox onClick={handleCloseAlertBox} /> )} </div> ) } } Pomodoro.propTypes = { currentTime: React.PropTypes.number.isRequired, setTime: React.PropTypes.func.isRequired } Pomodoro.defaultProps = { setTime: () => false, currentTime: 0 } export default Pomodoro
frontend/src/Components/Link/SpinnerErrorButton.js
lidarr/Lidarr
import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Icon from 'Components/Icon'; import SpinnerButton from 'Components/Link/SpinnerButton'; import { icons, kinds } from 'Helpers/Props'; import styles from './SpinnerErrorButton.css'; function getTestResult(error) { if (!error) { return { wasSuccessful: true, hasWarning: false, hasError: false }; } if (error.status !== 400) { return { wasSuccessful: false, hasWarning: false, hasError: true }; } const failures = error.responseJSON; const hasWarning = _.some(failures, { isWarning: true }); const hasError = _.some(failures, (failure) => !failure.isWarning); return { wasSuccessful: false, hasWarning, hasError }; } class SpinnerErrorButton extends Component { // // Lifecycle constructor(props, context) { super(props, context); this._testResultTimeout = null; this.state = { wasSuccessful: false, hasWarning: false, hasError: false }; } componentDidUpdate(prevProps) { const { isSpinning, error } = this.props; if (prevProps.isSpinning && !isSpinning) { const testResult = getTestResult(error); this.setState(testResult, () => { const { wasSuccessful, hasWarning, hasError } = testResult; if (wasSuccessful || hasWarning || hasError) { this._testResultTimeout = setTimeout(this.resetState, 3000); } }); } } componentWillUnmount() { if (this._testResultTimeout) { clearTimeout(this._testResultTimeout); } } // // Control resetState = () => { this.setState({ wasSuccessful: false, hasWarning: false, hasError: false }); } // // Render render() { const { isSpinning, error, children, ...otherProps } = this.props; const { wasSuccessful, hasWarning, hasError } = this.state; const showIcon = wasSuccessful || hasWarning || hasError; let iconName = icons.CHECK; let iconKind = kinds.SUCCESS; if (hasWarning) { iconName = icons.WARNING; iconKind = kinds.WARNING; } if (hasError) { iconName = icons.DANGER; iconKind = kinds.DANGER; } return ( <SpinnerButton isSpinning={isSpinning} {...otherProps} > <span className={showIcon ? styles.showIcon : undefined}> { showIcon && <span className={styles.iconContainer}> <Icon name={iconName} kind={iconKind} /> </span> } { <span className={styles.label}> { children } </span> } </span> </SpinnerButton> ); } } SpinnerErrorButton.propTypes = { isSpinning: PropTypes.bool.isRequired, error: PropTypes.object, children: PropTypes.node.isRequired }; export default SpinnerErrorButton;
components/GameListing.js
turntwogg/final-round
import React from 'react'; import Card from './Card'; import Ratio from './Ratio'; import Image from './Image'; import FollowButton from './FollowButton'; const GameListing = ({ game }) => { const { fieldGameCardImage, fieldGameSlug, name, description } = game; const cardMedia = fieldGameCardImage && ( <Ratio ratio={16 / 9}> <Image src={fieldGameCardImage.links['500xh'].href} className="game-listing__img" alt={name} /> </Ratio> ); return ( <Card media={cardMedia} title={name} primaryAction={{ href: '/games/[slug]', as: `/games/${fieldGameSlug}`, }} variant="full-media" badge={<FollowButton entityType="games" entity={game} size="tiny" />} > <div dangerouslySetInnerHTML={{ __html: description.value, }} /> </Card> ); }; export default GameListing;
app/javascript/mastodon/features/standalone/compose/index.js
kirakiratter/mastodon
import React from 'react'; import ComposeFormContainer from '../../compose/containers/compose_form_container'; import NotificationsContainer from '../../ui/containers/notifications_container'; import LoadingBarContainer from '../../ui/containers/loading_bar_container'; import ModalContainer from '../../ui/containers/modal_container'; export default class Compose extends React.PureComponent { render () { return ( <div> <ComposeFormContainer /> <NotificationsContainer /> <ModalContainer /> <LoadingBarContainer className='loading-bar' /> </div> ); } }
src/components/test/HeatmapTest.js
opiskelija-dashboard/dashboard
import test from 'ava'; import React from 'react'; import {shallow, mount} from 'enzyme'; import ReactDOM from 'react-dom'; import Heatmap from '../Heatmap'; import CalendarHeatmap from "react-calendar-heatmap"; test.skip('renders without crashing', t => { const wrapper = shallow( <Heatmap endDate={new Date()} numDays={7} values={[]} /> ) t.deepEqual(wrapper.find(CalendarHeatmap).length(), 1); });
src/decorators/withViewport.js
ycjonlin/voca-toca
/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */ import React, { Component } from 'react'; // eslint-disable-line no-unused-vars import EventEmitter from 'eventemitter3'; import { canUseDOM } from '../../node_modules/react/lib/ExecutionEnvironment'; let EE; let viewport = {width: 1366, height: 768}; // Default size for server-side rendering const RESIZE_EVENT = 'resize'; function handleWindowResize() { if (viewport.width !== window.innerWidth || viewport.height !== window.innerHeight) { viewport = {width: window.innerWidth, height: window.innerHeight}; EE.emit(RESIZE_EVENT, viewport); } } function withViewport(ComposedComponent) { return class WithViewport extends Component { constructor() { super(); this.state = { viewport: canUseDOM ? {width: window.innerWidth, height: window.innerHeight} : viewport }; } componentDidMount() { if (!EE) { EE = new EventEmitter(); window.addEventListener('resize', handleWindowResize); window.addEventListener('orientationchange', handleWindowResize); } EE.on('resize', this.handleResize, this); } componentWillUnmount() { EE.removeListener(RESIZE_EVENT, this.handleResize, this); if (!EE.listeners(RESIZE_EVENT, true)) { window.removeEventListener('resize', handleWindowResize); window.removeEventListener('orientationchange', handleWindowResize); EE = null; } } render() { return <ComposedComponent {...this.props} viewport={this.state.viewport}/>; } handleResize(value) { this.setState({viewport: value}); } }; } export default withViewport;
src/views/card.js
jessy1092/react-semantify
import React from 'react'; import filter from '../filter'; import Div from '../commons/div'; const defaultClassName = 'ui card'; const componentName = 'Card'; const Card = new filter(Div) .classGenerator(defaultClassName) .getComposeComponent(componentName); export default Card;
src/svg-icons/image/grid-on.js
frnk94/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageGridOn = (props) => ( <SvgIcon {...props}> <path d="M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"/> </SvgIcon> ); ImageGridOn = pure(ImageGridOn); ImageGridOn.displayName = 'ImageGridOn'; ImageGridOn.muiName = 'SvgIcon'; export default ImageGridOn;
src/components/Button/ButtonDeprecated.js
Barylskyigb/simple-debts-react-native
import React, { Component } from 'react'; import { Text, View, Platform, ActivityIndicator, ViewPropTypes } from 'react-native'; import PropTypes from 'prop-types'; import TouchableArea from '../TouchableArea/TouchableArea'; import styles from './Button.styles'; import * as colors from '../../utils/colors'; const isIOS = Platform.OS === 'ios'; export default class ButtonDeprecated extends Component { static propTypes = { children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]), onPress: PropTypes.func, renderText: PropTypes.func, title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), disabled: PropTypes.bool, loading: PropTypes.bool, lowercase: PropTypes.bool, style: ViewPropTypes.style, disabledStyle: ViewPropTypes.style, textStyle: Text.propTypes.style, disabledTextStyle: Text.propTypes.style, spinnerColor: PropTypes.string }; static defaultProps = { title: '', disabled: false, loading: false, lowercase: false, spinnerColor: colors.white }; renderText = () => { const { title, disabled, renderText, textStyle, disabledTextStyle, lowercase } = this.props; let text; if (renderText) return renderText(); if (Platform.OS === 'android' && !lowercase) { text = typeof title === 'string' ? title.toUpperCase() : title; } else { text = title; } return ( <View> <Text style={[ styles.defTextStyle, textStyle, disabled ? disabledTextStyle || styles.disabledText : null ]} > {text} </Text> </View> ); }; renderSpinner = () => <ActivityIndicator color={this.props.spinnerColor} />; renderContent = () => (this.props.children ? this.props.children : this.renderText()); render() { const { disabled, loading, lowercase, style, disabledStyle, onPress, ...rest } = this.props; return ( <TouchableArea onPress={disabled || loading ? null : onPress} style={[styles.container, style, disabled ? disabledStyle : null]} noRipple={disabled || !onPress || (lowercase && !isIOS)} {...rest} > {loading ? this.renderSpinner() : this.renderContent()} </TouchableArea> ); } }
index.android.js
xclassworks/bmobileclient
import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View, ListView, NativeModules } from 'react-native'; import App from './app/component/App'; class bmobileclient extends Component { render() { return ( <App /> ); } } AppRegistry.registerComponent('bmobileclient', () => bmobileclient);
src/js/components/PortfolioSixPic.js
hadnazzar/ModernBusinessBootstrap-ReactComponent
import React from 'react'; export default class PortfolioSixPic extends React.Component { render() { return( <div class="container"> <div class="row"> <div class="col-lg-12"> <h2 class="page-header">Portfolio Heading</h2> </div> <div class="col-md-4 col-sm-6"> <a href="portfolio-item.html"> <img class="img-responsive img-portfolio img-hover" src="http://placehold.it/700x450" alt=""/> </a> </div> <div class="col-md-4 col-sm-6"> <a href="portfolio-item.html"> <img class="img-responsive img-portfolio img-hover" src="http://placehold.it/700x450" alt=""/> </a> </div> <div class="col-md-4 col-sm-6"> <a href="portfolio-item.html"> <img class="img-responsive img-portfolio img-hover" src="http://placehold.it/700x450" alt=""/> </a> </div> <div class="col-md-4 col-sm-6"> <a href="portfolio-item.html"> <img class="img-responsive img-portfolio img-hover" src="http://placehold.it/700x450" alt=""/> </a> </div> <div class="col-md-4 col-sm-6"> <a href="portfolio-item.html"> <img class="img-responsive img-portfolio img-hover" src="http://placehold.it/700x450" alt=""/> </a> </div> <div class="col-md-4 col-sm-6"> <a href="portfolio-item.html"> <img class="img-responsive img-portfolio img-hover" src="http://placehold.it/700x450" alt=""/> </a> </div> </div> </div> ); } }
app/components/Manage.js
hlynn93/basic_ims
import React, { Component } from 'react'; import { Menu, Segment } from 'semantic-ui-react'; import { RestockForm, UpdateForm, CreateForm } from './AddComponents'; const RESTOCK = 'restock'; const EDIT = 'edit'; const CREATE = 'create'; const initialState = { item: {}, activeTab: EDIT }; class Manage extends Component { props: { items: [], actions: { initInventory: () => void, restock: () => void, updateItem: () => void, createItem: () => void } } state = { ...initialState } componentDidMount() { this.props.actions.initInventory(); } resetItem() { return this.setState({ item: {} }); } handleTabClick = (e, { name }) => this.setState({ activeTab: name }) handleResultSelect(id: number) { const { items } = this.props; this.setState({ ...this.state, item: items.find(item => item.id === id) }); } handleAdd(transaction: {}={}) { return this.props.actions.restock(transaction) .then(() => this.resetItem()); } handleUpdate(index: number, fields: {}={}) { return this.props.actions.updateItem(index, fields) .then(() => this.resetItem()); } handleCreate(item: {}={}) { return this.props.actions.createItem(item); } render() { const { item, activeTab } = this.state; const tabContent = { [RESTOCK]: (<RestockForm items={this.props.items} item={item} onResultSelect={this.handleResultSelect.bind(this)} onSubmit={this.handleAdd.bind(this)} />), [EDIT]: (<UpdateForm items={this.props.items} item={item} onResultSelect={this.handleResultSelect.bind(this)} onSubmit={this.handleUpdate.bind(this)} />), [CREATE]: (<CreateForm item={item} onSubmit={this.handleCreate.bind(this)} />), }; return ( <div> <Menu pointing secondary> <Menu.Item name={RESTOCK} active={activeTab === RESTOCK} onClick={this.handleTabClick} /> <Menu.Item name={EDIT} active={activeTab === EDIT} onClick={this.handleTabClick} /> <Menu.Item name={CREATE} active={activeTab === CREATE} onClick={this.handleTabClick} /> </Menu> <Segment padded> {tabContent[activeTab]} </Segment> </div> ); } } Manage.propTypes = { }; export default Manage;
src/js/components/nodes/registerNodes/driverFields/PXEAndIPMITool.js
knowncitizen/tripleo-ui
/** * Copyright 2017 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ import { defineMessages, injectIntl } from 'react-intl'; import PropTypes from 'prop-types'; import React from 'react'; import DriverFields from './DriverFields'; const messages = defineMessages({ address: { id: 'PXEAndIPMIToolDriverFields.address', defaultMessage: 'IPMI IP Address or FQDN' }, port: { id: 'PXEAndIPMIToolDriverFields.port', defaultMessage: 'IPMI Port' }, user: { id: 'PXEAndIPMIToolDriverFields.user', defaultMessage: 'IPMI Username' }, password: { id: 'PXEAndIPMIToolDriverFields.password', defaultMessage: 'IPMI Password' } }); const PXEAndIPMITool = ({ intl: { formatMessage }, node }) => ( <DriverFields node={node} addressLabel={formatMessage(messages.address)} portLabel={formatMessage(messages.port)} userLabel={formatMessage(messages.user)} passwordLabel={formatMessage(messages.password)} /> ); PXEAndIPMITool.propTypes = { intl: PropTypes.object.isRequired, node: PropTypes.string.isRequired }; export default injectIntl(PXEAndIPMITool);
src/icons/IosCloudy.js
fbfeix/react-icons
import React from 'react'; import IconBase from './../components/IconBase/IconBase'; export default class IosCloudy extends React.Component { render() { if(this.props.bare) { return <g> <style type="text/css"> .st0{fill:#010101;} </style> <path class="st0" d="M244,160c-43,0-78.3,35.2-78.3,78.5c0,2.6,0.1,5.2,0.4,7.8c-26.4,2.3-47.1,25.5-47.1,52.6 c0,28.6,23.2,53.1,51.7,53.1h157.7c35.7,0,64.6-29.9,64.6-65.7S364.1,221,328.4,221c-2.7,0-5.4,0-8,0.3C312.5,186.3,281,160,244,160 L244,160z"></path> </g>; } return <IconBase> <style type="text/css"> .st0{fill:#010101;} </style> <path class="st0" d="M244,160c-43,0-78.3,35.2-78.3,78.5c0,2.6,0.1,5.2,0.4,7.8c-26.4,2.3-47.1,25.5-47.1,52.6 c0,28.6,23.2,53.1,51.7,53.1h157.7c35.7,0,64.6-29.9,64.6-65.7S364.1,221,328.4,221c-2.7,0-5.4,0-8,0.3C312.5,186.3,281,160,244,160 L244,160z"></path> </IconBase>; } };IosCloudy.defaultProps = {bare: false}
src/index.js
kad3nce/react-transform-boilerplate
import React from 'react'; import { App } from './App'; React.render(<App />, document.getElementById('root'));
src/svg-icons/image/timelapse.js
barakmitz/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageTimelapse = (props) => ( <SvgIcon {...props}> <path d="M16.24 7.76C15.07 6.59 13.54 6 12 6v6l-4.24 4.24c2.34 2.34 6.14 2.34 8.49 0 2.34-2.34 2.34-6.14-.01-8.48zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/> </SvgIcon> ); ImageTimelapse = pure(ImageTimelapse); ImageTimelapse.displayName = 'ImageTimelapse'; ImageTimelapse.muiName = 'SvgIcon'; export default ImageTimelapse;
examples/index.android.js
Recr0ns/react-native-material-switch
import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; import Switch from 'react-native-material-switch'; export default class examples extends Component { render() { return ( <View style={styles.container}> <Text style={styles.title}>{'Material Switch'}</Text> <View style={styles.block}> <Text style={styles.blockText}>{'Default'}</Text> <Switch/> </View> <View style={styles.block}> <Text style={styles.blockText}>{'Custom colors'}</Text> <Switch activeBackgroundColor='rgba(206, 182, 255, 0.74)' inactiveBackgroundColor='rgba(252, 16, 148, 0.62)' activeButtonColor='#6d3abf' activeButtonPressedColor='#7943d1' inactiveButtonColor='#ba2a8f' inactiveButtonPressedColor='#cf39a2' /> </View> <View style={styles.block}> <Text style={styles.blockText}>{'With callbacks'}</Text> <Switch onActivate={() => {alert('activate')}} onDeactivate={() => {alert('deactivate')}} onChangeState={(state) => alert('change state '+ state)} /> </View> <View style={styles.block}> <Text style={styles.blockText}>{'Custom sizes'}</Text> <Switch style={{marginBottom:10}} buttonRadius={8} switchHeight={10} switchWidth={100} /> <Switch buttonRadius={14} switchHeight={29} switchWidth={50} /> </View> <View style={styles.block}> <Text style={styles.blockText}>{'Disabled swipe'}</Text> <Switch enableSlide={false}/> </View> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#bdebff', }, block: { justifyContent: 'center', alignItems: 'center', padding: 15, }, blockText: { marginBottom: 10, }, title: { fontSize: 22, fontWeight: 'bold', marginBottom: 20 } }); AppRegistry.registerComponent('examples', () => examples);
spec/javascripts/jsx/external_apps/components/DuplicateConfirmationFormSpec.js
djbender/canvas-lms
/* * Copyright (C) 2017 - present Instructure, Inc. * * This file is part of Canvas. * * Canvas is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3 of the License. * * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ import React from 'react' import ReactDOM from 'react-dom' import TestUtils from 'react-dom/test-utils' import DuplicateConfirmationForm from 'jsx/external_apps/components/DuplicateConfirmationForm' let domNode function renderComponent(props) { domNode = domNode || document.createElement('div') ReactDOM.render(<DuplicateConfirmationForm {...props} />, domNode) } const props = { onCancel: sinon.spy(), onSuccess: sinon.spy(), onError: sinon.spy(), toolData: {}, configurationType: '', store: {} } QUnit.module('DuplicateConfirmationForm', { teardown() { document.querySelector('#fixtures').innerHTML = '' } }) test('renders the component', () => { renderComponent(props) const component = domNode.querySelector('#duplicate-confirmation-form') ok(component) }) test('calls the onCancel prop when the "cancel install" button is clicked', () => { renderComponent(props) const component = domNode.querySelector('#duplicate-confirmation-form') const button = domNode.querySelector('#cancel-install') TestUtils.Simulate.click(button) ok(props.onCancel.calledOnce) }) test('calls the force install function if the "install anyway" button is clicked', () => { const saveSpy = sinon.spy() const propsDup = {...props} propsDup.store = {save: saveSpy} renderComponent(propsDup) const button = domNode.querySelector('#continue-install') TestUtils.Simulate.click(button) ok(saveSpy.calledOnce) }) test('calls the force install prop if the "install anyway" button is clicked', () => { const saveSpy = sinon.spy() const propsDup = {forceSaveTool: saveSpy} renderComponent(propsDup) const button = domNode.querySelector('#continue-install') TestUtils.Simulate.click(button) ok(saveSpy.calledOnce) }) test('sets "verifyUniqueness" to undefined when doing a force install', () => { const saveSpy = sinon.spy() const propsDup = {...props} propsDup.store = {save: saveSpy} renderComponent(propsDup) const button = domNode.querySelector('#continue-install') TestUtils.Simulate.click(button) equal(saveSpy.getCall(0).args[1].verifyUniqueness, undefined) })
docs/src/PropTable.js
tonylinyy/react-bootstrap
import merge from 'lodash/object/merge'; import React from 'react'; import Label from '../../src/Label'; import Table from '../../src/Table'; let cleanDocletValue = str => str.trim().replace(/^\{/, '').replace(/\}$/, ''); function getPropsData(componentData, metadata){ let props = componentData.props || {}; if (componentData.composes) { componentData.composes.forEach( other => { props = merge({}, getPropsData(metadata[other] || {}, metadata), props); }); } if (componentData.mixins) { componentData.mixins.forEach( other => { if ( componentData.composes.indexOf(other) === -1) { props = merge({}, getPropsData(metadata[other] || {}, metadata), props); } }); } return props; } const PropTable = React.createClass({ contextTypes: { metadata: React.PropTypes.object }, componentWillMount(){ let componentData = this.context.metadata[this.props.component] || {}; this.propsData = getPropsData(componentData, this.context.metadata); }, render(){ let propsData = this.propsData; if ( !Object.keys(propsData).length){ return <span/>; } return ( <Table bordered striped className="prop-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Default</th> <th>Description</th> </tr> </thead> <tbody> { this._renderRows(propsData) } </tbody> </Table> ); }, _renderRows(propsData){ return Object.keys(propsData) .sort() .filter(propName => propsData[propName].type && !propsData[propName].doclets.private ) .map(propName => { let propData = propsData[propName]; return ( <tr key={propName} className='prop-table-row'> <td> {propName} {this.renderRequiredLabel(propData)} </td> <td> <div>{this.getType(propData)}</div> </td> <td>{propData.defaultValue}</td> <td> { propData.doclets.deprecated && <div><strong className='text-danger'>{'Deprecated: ' + propData.doclets.deprecated + ' '}</strong></div> } <div dangerouslySetInnerHTML={{__html: propData.descHtml }} /> </td> </tr> ); }); }, renderRequiredLabel(prop) { if (!prop.required) { return null; } return ( <Label>required</Label> ); }, getType(prop) { let type = prop.type || {}; let name = this.getDisplayTypeName(type.name); let doclets = prop.doclets || {}; switch (name) { case 'object': return name; case 'union': return type.value.reduce((current, val, i, list) => { let item = this.getType({ type: val }); if (React.isValidElement(item)) { item = React.cloneElement(item, {key: i}); } current = current.concat(item); return i === (list.length - 1) ? current : current.concat(' | '); }, []); case 'array': let child = this.getType({ type: type.value }); return <span>{'array<'}{ child }{'>'}</span>; case 'enum': return this.renderEnum(type); case 'custom': return cleanDocletValue(doclets.type || name); default: return name; } }, getDisplayTypeName(typeName) { if (typeName === 'func') { return 'function'; } else if (typeName === 'bool') { return 'boolean'; } else { return typeName; } }, renderEnum(enumType) { const enumValues = enumType.value || []; const renderedEnumValues = []; enumValues.forEach(function renderEnumValue(enumValue, i) { if (i > 0) { renderedEnumValues.push( <span key={`${i}c`}>, </span> ); } renderedEnumValues.push( <code key={i}>{enumValue}</code> ); }); return ( <span>one of: {renderedEnumValues}</span> ); } }); export default PropTable;
src/app/components/graphs/vectormap/VectorMap.js
backpackcoder/world-in-flames
import React from 'react' var VectorMap = React.createClass({ componentDidMount: function(){ var data = this.props.data; // $(this.getHold()).vectorMap({ // map: 'world_mill_en', // backgroundColor: '#fff', // regionStyle: { // initial: { // fill: '#c4c4c4' // }, // hover: { // "fill-opacity": 1 // } // }, // series: { // regions: [ // { // values: data, // scale: ['#85a8b6', '#4d7686'], // normalizeFunction: 'polynomial' // } // ] // }, // onRegionLabelShow: function (e, el, code) { // if (typeof data[code] == 'undefined') { // e.preventDefault(); // } else { // var countrylbl = data[code]; // el.html(el.html() + ': ' + countrylbl + ' visits'); // } // } // }); }, componentWillUnmount: function(){ let mapObject = $(this.getHold()).children('.jvectormap-container').data('mapObject'); mapObject && mapObject.remove(); }, render: function () { return ( <div id="vector-map" className="vector-map" ref={ref=>this.setHold(ref)}/> ) } }); export default VectorMap
src/components/ExternalLink.js
joshforisha/fred-talks
import Color from 'lib/Color'; import PropTypes from 'prop-types'; import React from 'react'; import styled from 'styled-components'; const Link = styled.a` color: ${Color.Fuchsia}; cursor: pointer; text-decoration: underline; transition: color 100ms ease-out; :hover { color: ${Color.Purple}; } `; export default function ExternalLink(props) { return ( <Link className={props.className} href={props.href} target="_blank"> {props.children} </Link> ); } ExternalLink.propTypes = { className: PropTypes.string, children: PropTypes.node, href: PropTypes.string };
plugins/Files/js/components/searchfield.js
NebulousLabs/New-Sia-UI
import PropTypes from 'prop-types' import React from 'react' const SearchField = ({ searchText, path, actions }) => { const onSearchChange = e => actions.setSearchText(e.target.value, path) return ( <div className='search-field'> <input value={searchText} autoFocus onChange={onSearchChange} /> <i className='fa fa-search' /> </div> ) } SearchField.propTypes = { searchText: PropTypes.string.isRequired, path: PropTypes.string.isRequired } export default SearchField
lib/pages/index.js
adjohnston/react-css-modules-postcss-jspm-example
import React from 'react'; import ActionButton from '../atoms/action-button'; class IndexPage extends React.Component { render() { return ( <main role="main"> <ActionButton className="primary" text="Primary Button" /> <ActionButton className="warning" text="Warning Button" /> </main> ) } } export default IndexPage; export let __hotReload = true;
app/containers/ProjectSelector.js
arwilczek90/OpenPresenter
/** * Created by awilczek on 1/22/17. */ import React from 'react'; import PageWrapper from '../components/PageWrapper'; import ProjectSelectorButtons from '../components/ProjectSelectorButtons'; export default class ProjectSelector extends React.Component { constructor(props, context) { super(props, context); this.state = { projectOpen: true }; } render() { return ( <PageWrapper> <ProjectSelectorButtons projectOpen={this.state.projectOpen} /> </PageWrapper> ); } }
src/components/case-study/single/templates/cnbc/profit.js
adrienhobbs/redux-glow
import React from 'react'; import BaseTemplate from '../base-study-template'; import AboutSection from '../../../content-modules/about.js'; // import styles from './profit.css'; export class Profit extends BaseTemplate { static propTypes = { data: React.PropTypes.object }; constructor (props) { super(props); } render () { const copyStyle = this.getCopyStyle(); return ( <div ref='studyContent' className='study-content' style={{fontWeight: 300, background: this.props.data.get('secColor')}}> <div className='content-container' style={{backgroundColor: this.props.data.get('secColor')}}> <AboutSection data={this.props.data} /> <article className='approach'> {this.createHeadlineEl('the deal map')} <div className='img-single inner_section' style={{marginTop: 0}}> <img src='https://s3.amazonaws.com/weareglow-assets/case-studies/cnbc/the_profit/profit-img-4.jpg' alt='profit' /> </div> <div className='copy'> <div className='copy-inner'> <p style={copyStyle}>Our team conceived, designed and developed The Deal Map (thedealmap.cnbc.com), an interactive experience to give fans a deeper dive into The Profit’s past business ventures. To provide the most authentic map experience we integrated Mapbox technology into our solution, allowing for optimized performance in a responsive web environment. Interacting with the various location indicated on the map enables fans to explore each business in more detail.</p> <p style={copyStyle}>Each location on the map includes more information on the company such as the headquarters location, the financial basics of the deal, company site and social channels, video of the deal negotiated with Marcus and a number of moments from the episode that fans can share to their social channels. Fans can also see the various additional locations for any businesses that have expanded through franchises.</p> </div> </div> <div className='img-single inner_section'> <img src='https://s3.amazonaws.com/weareglow-assets/case-studies/cnbc/the_profit/profit-img-3.jpg' alt='profit' /> </div> <div className='img-single inner_section'> <img src='https://s3.amazonaws.com/weareglow-assets/case-studies/cnbc/the_profit/profit-img-2.jpg' alt='profit' /> </div> <div className='img-single inner_section'> <img src='https://s3.amazonaws.com/weareglow-assets/case-studies/cnbc/the_profit/profit-img-1.jpg' alt='profit' /> </div> </article> </div> </div> ); } } export default Profit; // <a target='_blank' href='http://www.syfy.com/hunters/theyareamongus/'> // <div className={styles.profitBtn}> // view the map // </div> // </a>
app/js/pages/search-page.js
workco/hackathon-talent
'use strict'; import React from 'react'; import DocumentTitle from 'react-document-title'; import { Link } from 'react-router'; import Search from '../components/search'; export default React.createClass({ render() { return ( <DocumentTitle title="Search"> <Search/> </DocumentTitle> ); } });
src/elements/Placeholder/Placeholder.js
Semantic-Org/Semantic-UI-React
import cx from 'clsx' import PropTypes from 'prop-types' import React from 'react' import { childrenUtils, customPropTypes, getElementType, getUnhandledProps, useKeyOnly, } from '../../lib' import PlaceholderHeader from './PlaceholderHeader' import PlaceholderImage from './PlaceholderImage' import PlaceholderLine from './PlaceholderLine' import PlaceholderParagraph from './PlaceholderParagraph' /** * A placeholder is used to reserve space for content that soon will appear in a layout. */ function Placeholder(props) { const { children, className, content, fluid, inverted } = props const classes = cx( 'ui', useKeyOnly(fluid, 'fluid'), useKeyOnly(inverted, 'inverted'), 'placeholder', className, ) const rest = getUnhandledProps(Placeholder, props) const ElementType = getElementType(Placeholder, props) return ( <ElementType {...rest} className={classes}> {childrenUtils.isNil(children) ? content : children} </ElementType> ) } Placeholder.propTypes = { /** An element type to render as (string or function). */ as: PropTypes.elementType, /** Primary content. */ children: PropTypes.node, /** Additional classes. */ className: PropTypes.string, /** Shorthand for primary content. */ content: customPropTypes.contentShorthand, /** A fluid placeholder takes up the width of its container. */ fluid: PropTypes.bool, /** A placeholder can have their colors inverted. */ inverted: PropTypes.bool, } Placeholder.Header = PlaceholderHeader Placeholder.Image = PlaceholderImage Placeholder.Line = PlaceholderLine Placeholder.Paragraph = PlaceholderParagraph export default Placeholder
fields/types/code/CodeField.js
michaelerobertsjr/keystone
import _ from 'lodash'; import CodeMirror from 'codemirror'; import Field from '../Field'; import React from 'react'; import { findDOMNode } from 'react-dom'; import { FormInput } from 'elemental'; import classnames from 'classnames'; /** * TODO: * - Remove dependency on underscore */ // See CodeMirror docs for API: // http://codemirror.net/doc/manual.html module.exports = Field.create({ displayName: 'CodeField', statics: { type: 'Code', }, getInitialState () { return { isFocused: false, }; }, componentDidMount () { if (!this.refs.codemirror) { return; } var options = _.defaults({}, this.props.editor, { lineNumbers: true, readOnly: this.shouldRenderField() ? false : true, }); this.codeMirror = CodeMirror.fromTextArea(findDOMNode(this.refs.codemirror), options); this.codeMirror.setSize(null, this.props.height); this.codeMirror.on('change', this.codemirrorValueChanged); this.codeMirror.on('focus', this.focusChanged.bind(this, true)); this.codeMirror.on('blur', this.focusChanged.bind(this, false)); this._currentCodemirrorValue = this.props.value; }, componentWillUnmount () { // todo: is there a lighter-weight way to remove the cm instance? if (this.codeMirror) { this.codeMirror.toTextArea(); } }, componentWillReceiveProps (nextProps) { if (this.codeMirror && this._currentCodemirrorValue !== nextProps.value) { this.codeMirror.setValue(nextProps.value); } }, focus () { if (this.codeMirror) { this.codeMirror.focus(); } }, focusChanged (focused) { this.setState({ isFocused: focused, }); }, codemirrorValueChanged (doc, change) { var newValue = doc.getValue(); this._currentCodemirrorValue = newValue; this.props.onChange({ path: this.props.path, value: newValue, }); }, renderCodemirror () { const className = classnames('CodeMirror-container', { 'is-focused': this.state.isFocused && this.shouldRenderField(), }); return ( <div className={className}> <FormInput autoComplete="off" multiline name={this.props.path} onChange={this.valueChanged} ref="codemirror" value={this.props.value} /> </div> ); }, renderValue () { return this.renderCodemirror(); }, renderField () { return this.renderCodemirror(); }, });
src/components/arrowRight/index.js
treeok/react-es6-webpack
// react import React from 'react'; import Template from './template.jsx'; const ArrowRight = React.createClass({ render: Template }); export default ArrowRight;
app/javascript/mastodon/containers/compose_container.js
rainyday/mastodon
import React from 'react'; import { Provider } from 'react-redux'; import PropTypes from 'prop-types'; import configureStore from '../store/configureStore'; import { hydrateStore } from '../actions/store'; import { IntlProvider, addLocaleData } from 'react-intl'; import { getLocale } from '../locales'; import Compose from '../features/standalone/compose'; import initialState from '../initial_state'; import { fetchCustomEmojis } from '../actions/custom_emojis'; const { localeData, messages } = getLocale(); addLocaleData(localeData); const store = configureStore(); if (initialState) { store.dispatch(hydrateStore(initialState)); } store.dispatch(fetchCustomEmojis()); export default class TimelineContainer extends React.PureComponent { static propTypes = { locale: PropTypes.string.isRequired, }; render () { const { locale } = this.props; return ( <IntlProvider locale={locale} messages={messages}> <Provider store={store}> <Compose /> </Provider> </IntlProvider> ); } }
examples/react/src/ErrorBoundary.js
rollbar/rollbar.js
import React from 'react'; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error) { // Update state so the next render will show the fallback UI. return { hasError: true }; } componentDidCatch(error, info) { this.props.rollbar.info(error.message); } render() { if (this.state.hasError) { // You can render any custom fallback UI return <h1>Something went wrong.</h1>; } return this.props.children; } } export default ErrorBoundary;
src/App.js
nolanlawson/react-wheel-jank-demo
import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import logo from './logo.svg'; import './App.css'; import { times, noop } from 'lodash'; function wait(time) { var startTime = (new Date()).getTime(); var endTime = startTime + time; while ((new Date()).getTime() < endTime) { // wait for it... } } // jank up the main thread! setInterval(() => wait(1000), 2000) var scrollableDivStyle = { width: 300, height: 200, overflowY: 'auto', margin: '0 auto', background: '#ededed' }; class App extends Component { render() { return ( <div className="App"> <div className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <h2>React Wheel Jank Demo</h2> </div> <h3>Version 3</h3> <p className="App-intro"> In this version, we have an <code>onwheel</code> event attached directly to the DOM node of the inner scrollable div. </p> <div style={scrollableDivStyle} ref="scrollableDiv"> <h2>I am scrollable!</h2> <ul> {(times(50, i => (<li key={i}>List item #{i + 1}</li>)))} </ul> </div> <ul> {(times(50, i => (<li key={i}>List item #{i + 1}</li>)))} </ul> </div> ); } componentDidMount() { ReactDOM.findDOMNode(this.refs.scrollableDiv).onwheel = noop } } export default App;
app/javascript/mastodon/features/compose/components/poll_form.js
MitarashiDango/mastodon
import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import IconButton from 'mastodon/components/icon_button'; import Icon from 'mastodon/components/icon'; import AutosuggestInput from 'mastodon/components/autosuggest_input'; import classNames from 'classnames'; const messages = defineMessages({ option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' }, add_option: { id: 'compose_form.poll.add_option', defaultMessage: 'Add a choice' }, remove_option: { id: 'compose_form.poll.remove_option', defaultMessage: 'Remove this choice' }, poll_duration: { id: 'compose_form.poll.duration', defaultMessage: 'Poll duration' }, switchToMultiple: { id: 'compose_form.poll.switch_to_multiple', defaultMessage: 'Change poll to allow multiple choices' }, switchToSingle: { id: 'compose_form.poll.switch_to_single', defaultMessage: 'Change poll to allow for a single choice' }, minutes: { id: 'intervals.full.minutes', defaultMessage: '{number, plural, one {# minute} other {# minutes}}' }, hours: { id: 'intervals.full.hours', defaultMessage: '{number, plural, one {# hour} other {# hours}}' }, days: { id: 'intervals.full.days', defaultMessage: '{number, plural, one {# day} other {# days}}' }, }); @injectIntl class Option extends React.PureComponent { static propTypes = { title: PropTypes.string.isRequired, index: PropTypes.number.isRequired, isPollMultiple: PropTypes.bool, autoFocus: PropTypes.bool, onChange: PropTypes.func.isRequired, onRemove: PropTypes.func.isRequired, onToggleMultiple: PropTypes.func.isRequired, suggestions: ImmutablePropTypes.list, onClearSuggestions: PropTypes.func.isRequired, onFetchSuggestions: PropTypes.func.isRequired, onSuggestionSelected: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; handleOptionTitleChange = e => { this.props.onChange(this.props.index, e.target.value); }; handleOptionRemove = () => { this.props.onRemove(this.props.index); }; handleToggleMultiple = e => { this.props.onToggleMultiple(); e.preventDefault(); e.stopPropagation(); }; handleCheckboxKeypress = e => { if (e.key === 'Enter' || e.key === ' ') { this.handleToggleMultiple(e); } } onSuggestionsClearRequested = () => { this.props.onClearSuggestions(); } onSuggestionsFetchRequested = (token) => { this.props.onFetchSuggestions(token); } onSuggestionSelected = (tokenStart, token, value) => { this.props.onSuggestionSelected(tokenStart, token, value, ['poll', 'options', this.props.index]); } render () { const { isPollMultiple, title, index, autoFocus, intl } = this.props; return ( <li> <label className='poll__option editable'> <span className={classNames('poll__input', { checkbox: isPollMultiple })} onClick={this.handleToggleMultiple} onKeyPress={this.handleCheckboxKeypress} role='button' tabIndex='0' title={intl.formatMessage(isPollMultiple ? messages.switchToSingle : messages.switchToMultiple)} aria-label={intl.formatMessage(isPollMultiple ? messages.switchToSingle : messages.switchToMultiple)} /> <AutosuggestInput placeholder={intl.formatMessage(messages.option_placeholder, { number: index + 1 })} maxLength={50} value={title} onChange={this.handleOptionTitleChange} suggestions={this.props.suggestions} onSuggestionsFetchRequested={this.onSuggestionsFetchRequested} onSuggestionsClearRequested={this.onSuggestionsClearRequested} onSuggestionSelected={this.onSuggestionSelected} searchTokens={[':']} autoFocus={autoFocus} /> </label> <div className='poll__cancel'> <IconButton disabled={index <= 1} title={intl.formatMessage(messages.remove_option)} icon='times' onClick={this.handleOptionRemove} /> </div> </li> ); } } export default @injectIntl class PollForm extends ImmutablePureComponent { static propTypes = { options: ImmutablePropTypes.list, expiresIn: PropTypes.number, isMultiple: PropTypes.bool, onChangeOption: PropTypes.func.isRequired, onAddOption: PropTypes.func.isRequired, onRemoveOption: PropTypes.func.isRequired, onChangeSettings: PropTypes.func.isRequired, suggestions: ImmutablePropTypes.list, onClearSuggestions: PropTypes.func.isRequired, onFetchSuggestions: PropTypes.func.isRequired, onSuggestionSelected: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; handleAddOption = () => { this.props.onAddOption(''); }; handleSelectDuration = e => { this.props.onChangeSettings(e.target.value, this.props.isMultiple); }; handleToggleMultiple = () => { this.props.onChangeSettings(this.props.expiresIn, !this.props.isMultiple); }; render () { const { options, expiresIn, isMultiple, onChangeOption, onRemoveOption, intl, ...other } = this.props; if (!options) { return null; } const autoFocusIndex = options.indexOf(''); return ( <div className='compose-form__poll-wrapper'> <ul> {options.map((title, i) => <Option title={title} key={i} index={i} onChange={onChangeOption} onRemove={onRemoveOption} isPollMultiple={isMultiple} onToggleMultiple={this.handleToggleMultiple} autoFocus={i === autoFocusIndex} {...other} />)} </ul> <div className='poll__footer'> <button disabled={options.size >= 4} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button> {/* eslint-disable-next-line jsx-a11y/no-onchange */} <select value={expiresIn} onChange={this.handleSelectDuration}> <option value={300}>{intl.formatMessage(messages.minutes, { number: 5 })}</option> <option value={1800}>{intl.formatMessage(messages.minutes, { number: 30 })}</option> <option value={3600}>{intl.formatMessage(messages.hours, { number: 1 })}</option> <option value={21600}>{intl.formatMessage(messages.hours, { number: 6 })}</option> <option value={86400}>{intl.formatMessage(messages.days, { number: 1 })}</option> <option value={259200}>{intl.formatMessage(messages.days, { number: 3 })}</option> <option value={604800}>{intl.formatMessage(messages.days, { number: 7 })}</option> </select> </div> </div> ); } }
docs/src/components/Docs/DataConversion/index.js
jpuri/react-draft-wysiwyg
/* @flow */ import React from 'react'; import Codemirror from 'react-codemirror'; import { RawEditorStateLink } from '../Props/EditorStateProp'; export default () => ( <div className="docs-section"> <h2>Data Conversion</h2> <h3>JSON</h3> <div className="docs-desc top-margined"> <RawEditorStateLink /> format is very well suited to save data in DB. This JSON can be easily converted back to Editor state of even HTML or Markdown. </div> <Codemirror value={ 'import React, { Component } from \'react\';\n' + 'import { convertFromRaw } from \'draft-js\';\n' + 'import { Editor } from \'react-draft-wysiwyg\';\n' + '\n\n' + 'const content = {"entityMap":{},"blocks":[{"key":"637gr","text":"Initialized from content state.","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}}]};\n' + '\n' + 'class EditorConvertToJSON extends Component {\n' + ' constructor(props) {\n' + ' super(props);\n' + ' const contentState = convertFromRaw(content);\n' + ' this.state = {\n' + ' contentState,\n' + ' }\n' + ' }\n' + '\n' + ' onContentStateChange: Function = (contentState) => {\n' + ' this.setState({\n' + ' contentState,\n' + ' });\n' + ' };\n' + '\n' + ' render() {\n' + ' const { contentState } = this.state;\n' + ' return (\n' + ' <Editor\n' + ' wrapperClassName="demo-wrapper"\n' + ' editorClassName="demo-editor"\n' + ' onContentStateChange={this.onContentStateChange}\n' + ' />\n' + ' );\n' + ' }\n' + '}' } options={{ lineNumbers: true, mode: 'jsx', readOnly: true, }} /> <h3>HTML</h3> <div className="docs-desc top-margined"> Libraries <a href="https://github.com/jpuri/draftjs-to-html">draftjs-to-html</a> can be used to convert <RawEditorStateLink /> to html. <br /> <a href="https://github.com/jpuri/html-to-draftjs">html-to-draftjs</a> provides the option to convert HTML generated by react-draft-wysiwyg back to draftJS ContentState which can be used to initialize the Editor. </div> <Codemirror value={ 'import React, { Component } from \'react\';\n' + 'import { EditorState, convertToRaw, ContentState } from \'draft-js\';\n' + 'import { Editor } from \'react-draft-wysiwyg\';\n' + 'import draftToHtml from \'draftjs-to-html\';\n' + 'import htmlToDraft from \'html-to-draftjs\';\n' + '\n\n' + 'class EditorConvertToHTML extends Component {\n' + ' constructor(props) {\n' + ' super(props);\n' + ' const html = \'<p>Hey this <strong>editor</strong> rocks 😀</p>\';\n' + ' const contentBlock = htmlToDraft(html);\n' + ' if (contentBlock) {\n' + ' const contentState = ContentState.createFromBlockArray(contentBlock.contentBlocks);\n' + ' const editorState = EditorState.createWithContent(contentState);\n' + ' this.state = {\n' + ' editorState,\n' + ' };\n' + ' }\n' + ' }\n' + '\n' + ' onEditorStateChange: Function = (editorState) => {\n' + ' this.setState({\n' + ' editorState,\n' + ' });\n' + ' };\n' + '\n' + ' render() {\n' + ' const { editorState } = this.state;\n' + ' return (\n' + ' <div>\n' + ' <Editor\n' + ' editorState={editorState}\n' + ' wrapperClassName="demo-wrapper"\n' + ' editorClassName="demo-editor"\n' + ' onEditorStateChange={this.onEditorStateChange}\n' + ' />\n' + ' <textarea\n' + ' disabled\n' + ' value={draftToHtml(convertToRaw(editorState.getCurrentContent()))}\n' + ' />\n' + ' </div>\n' + ' );\n' + ' }\n' + '}' } options={{ lineNumbers: true, mode: 'jsx', readOnly: true, }} /> <h3>Markdown</h3> <div className="docs-desc top-margined"> Library <a href="https://github.com/jpuri/draftjs-to-markdown">draftjs-to-markdown</a> can be used to convert <RawEditorStateLink /> to markdown format. </div> </div> );
app/jsx/gradezilla/default_gradebook/components/LatePolicyGrade.js
venturehive/canvas-lms
/* * Copyright (C) 2017 - present Instructure, Inc. * * This file is part of Canvas. * * Canvas is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3 of the License. * * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ import React from 'react'; import { number, shape, string } from 'prop-types'; import Typography from 'instructure-ui/lib/components/Typography'; import I18n from 'i18n!gradebook'; import GradeFormatHelper from 'jsx/gradebook/shared/helpers/GradeFormatHelper'; export default function LatePolicyGrade (props) { const { grade } = props.submission; const pointsDeducted = I18n.n(-props.submission.pointsDeducted); let finalGrade; if (isNaN(grade)) { finalGrade = GradeFormatHelper.formatGrade(props.submission.grade); } else { finalGrade = GradeFormatHelper.formatGrade(props.submission.grade, { precision: 2 }); } return ( <div style={{ display: 'flex', flexDirection: 'row' }}> <div style={{ paddingRight: '.5rem' }}> <div> <Typography color="error" as="span"> { I18n.t('Late Penalty:') } </Typography> </div> <div> <Typography color="secondary" as="span"> { I18n.t('Final Grade:') } </Typography> </div> </div> <div style={{ flex: 1 }}> <div id="late-penalty-value"> <Typography color="error" as="span"> { pointsDeducted } </Typography> </div> <div id="final-grade-value"> <Typography color="secondary" as="span"> { finalGrade } </Typography> </div> </div> </div> ); } LatePolicyGrade.propTypes = { submission: shape({ grade: string, pointsDeducted: number }).isRequired };
site/components/StaticHTMLBlock.js
longlho/react-dnd
import React, { Component } from 'react'; import CodeBlock from './CodeBlock'; export default class StaticHTMLBlock extends Component { static propTypes = { html: React.PropTypes.string.isRequired }; render() { const { html } = this.props; // Here goes a really hack-ish way to convert // areas separated by Markdown <hr>s into code tabs. const blocks = html.split('<hr/>'); const elements = []; let es5Content = null; let es6Content = null; let es7Content = null; for (let i = 0; i < blocks.length; i++) { const content = blocks[i]; switch (i % 4) { case 0: elements.push( <div key={i} style={{ width: '100%' }} dangerouslySetInnerHTML={{__html: content}} /> ); break; case 1: es5Content = content; break; case 2: es6Content = content; break; case 3: es7Content = content; elements.push( <CodeBlock key={i} es5={es5Content} es6={es6Content} es7={es7Content} /> ); break; } } return ( <div style={{ width: '100%' }}> {elements} </div> ); } }
src/decorators/withViewport.js
RenRenTeam/react-starter-kit
/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */ import React, { Component } from 'react'; // eslint-disable-line no-unused-vars import EventEmitter from 'eventemitter3'; import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment'; let EE; let viewport = {width: 1366, height: 768}; // Default size for server-side rendering const RESIZE_EVENT = 'resize'; function handleWindowResize() { if (viewport.width !== window.innerWidth || viewport.height !== window.innerHeight) { viewport = {width: window.innerWidth, height: window.innerHeight}; EE.emit(RESIZE_EVENT, viewport); } } function withViewport(ComposedComponent) { return class WithViewport extends Component { constructor() { super(); this.state = { viewport: canUseDOM ? {width: window.innerWidth, height: window.innerHeight} : viewport }; } componentDidMount() { if (!EE) { EE = new EventEmitter(); window.addEventListener('resize', handleWindowResize); window.addEventListener('orientationchange', handleWindowResize); } EE.on('resize', this.handleResize, this); } componentWillUnmount() { EE.removeListener(RESIZE_EVENT, this.handleResize, this); if (!EE.listeners(RESIZE_EVENT, true)) { window.removeEventListener('resize', handleWindowResize); window.removeEventListener('orientationchange', handleWindowResize); EE = null; } } render() { return <ComposedComponent {...this.props} viewport={this.state.viewport}/>; } handleResize(value) { this.setState({viewport: value}); } }; } export default withViewport;
frontend/src/components/article/article-container/index.js
loganabsher/portfolio
'use strict'; import React from 'react'; import {connect} from 'react-redux'; import propTypes from 'prop-types'; import ArticleForm from '../../forms/article-form'; import ArticleTemplate from '../../templates/article-template'; import {articleCreateRequest, articleFetchRequest} from '../../../../actions/article-actions.js'; class ArticleContainer extends React.Component{ constructor(props){ super(props); this.state = { article: null }; this.handleNewArticle = this.handleNewArticle.bind(this); } componentDidMount(){ let article = {type: 'all'}; return this.props.articleFetch(article); } componentWillReceiveProps(nextProps){ this.setState({article: nextProps.article}); } handleNewArticle(article){ console.log('article-container : ', article); return this.props.articleCreate(article); } render(){ console.log(this.state.article) return( <div className="article-container"> <p>start of the article page</p> <ArticleForm onComplete={this.handleNewArticle} /> {this.state.article ? this.state.article.map((article, index) => { console.log(article) return (<ArticleTemplate article={article} key={index} />); }) : <p>...loading</p>} </div> ); } } ArticleContainer.propTypes = { article: propTypes.array }; const mapStateToProps = (state) => ({ article: state.article }); const mapDispatchToProps = (dispatch) => ({ articleCreate: (article) => dispatch(articleCreateRequest(article)), articleFetch: (article) => dispatch(articleFetchRequest(article)) }); export default connect(mapStateToProps, mapDispatchToProps)(ArticleContainer);
app/react-icons/fa/stethoscope.js
scampersand/sonos-front
import React from 'react'; import IconBase from 'react-icon-base'; export default class FaStethoscope extends React.Component { render() { return ( <IconBase viewBox="0 0 40 40" {...this.props}> <g><path d="m33.1 15.7q0-0.6-0.5-1t-1-0.4-1 0.4-0.4 1 0.4 1 1 0.4 1-0.4 0.5-1z m2.8 0q0 1.4-0.8 2.5t-2 1.6v8.8q0 3.5-3 6t-7 2.5-7.1-2.5-2.9-6v-3q-3.7-0.4-6.1-2.8t-2.5-5.7v-11.4q0-0.6 0.4-1t1-0.4q0.2 0 0.4 0 0.4-0.6 1-1t1.5-0.4q1.2 0 2 0.8t0.8 2-0.8 2-2 0.9q-0.8 0-1.4-0.4v8.9q0 2.4 2.1 4.1t5 1.7 5-1.7 2.1-4.1v-8.9q-0.6 0.4-1.4 0.4-1.2 0-2-0.9t-0.8-2 0.8-2 2-0.8q0.8 0 1.5 0.4t1 1q0.2 0 0.4 0 0.6 0 1 0.4t0.4 1v11.4q0 3.3-2.5 5.7t-6.1 2.8v3q0 2.3 2.1 4t5.1 1.7 5-1.7 2.1-4v-8.8q-1.3-0.5-2.1-1.6t-0.7-2.5q0-1.8 1.2-3t3-1.3 3.1 1.3 1.2 3z"/></g> </IconBase> ); } }
examples/src/views/ToolBarView.js
LayGit/layui
import React from 'react' import { Container, ToolBar, Icon } from 'layui' const ToolBarItem = ToolBar.Item export default class ToolBarView extends React.Component { render () { return ( <div> <Container></Container> <ToolBar activeIndex={0}> <ToolBarItem icon={<Icon name="home" componet="span" />} title="文案"></ToolBarItem> <ToolBarItem icon={<Icon name="me" componet="span" />} title="文案" badge={2}></ToolBarItem> <ToolBarItem icon={<Icon name="star" componet="span" />} title="文案"></ToolBarItem> <ToolBarItem icon={<Icon name="cart" componet="span" />} title="文案"></ToolBarItem> <ToolBarItem icon={<Icon name="settings" componet="span" />} title="文案"></ToolBarItem> </ToolBar> </div> ) } } module.exports = exports['default']
src/index.js
hacklag/hacklag-website
// Global styles import 'styles/styles.css'; import React from 'react'; import { render } from 'react-dom'; import { AppContainer } from 'react-hot-loader'; import App from 'views/App'; const $root = document.getElementById('root'); window.drift.load(DRIFT_WRITE_KEY); window.fbq('init', PIXEL_WRITE_KEY); window.ga('create', GOOGLE_WRITE_KEY, 'auto'); render(<AppContainer children={<App />} />, $root); if (module.hot) { module.hot.accept('views/App', () => { // Reloading doesn't work without this line require('views/App'); // eslint-disable-line render(<AppContainer children={<App />} />, $root); }); }
App/src/Event.js
hgoldwire/bikewatch
import React from 'react'; import PropTypes from 'prop-types'; import {StyleSheet, Text, View,} from 'react-native'; export class Event extends React.Component { shouldComponentUpdate(nextProps) { return this.props.event.id !== nextProps.event.id; } render() { const {event} = this.props; return ( <View style={styles.event}> <Text style={styles.eventName}>{event.name}</Text> <Text style={styles.eventData}>{JSON.stringify(event.data, null, 2)}</Text> </View> ); } } Event.propTypes = { event: PropTypes.object, }; const styles = StyleSheet.create({ event: { borderBottomWidth: 1, borderBottomColor: '#ccc', padding: 8, }, eventData: { fontSize: 10, color: '#555', }, eventName: { fontSize: 13, fontWeight: 'bold', color: '#222', }, });
js/DeleteDictionaryDialog.js
dmitriykovalev/slovareg
import React from 'react'; import {Button, Modal} from 'react-bootstrap'; const DeleteDictionaryDialog = React.createClass({ propTypes: { show: React.PropTypes.bool.isRequired, onDone: React.PropTypes.func.isRequired, onHide: React.PropTypes.func.isRequired, name: React.PropTypes.string, }, handleSubmit(event) { event.preventDefault(); this.props.onDone(); this.props.onHide(); }, render() { return ( <Modal bsSize='small' animation={false} onHide={this.props.onHide} show={this.props.show}> <form> <Modal.Header closeButton> <Modal.Title>Delete dictionary &lsquo;{this.props.name}&rsquo;?</Modal.Title> </Modal.Header> <Modal.Footer> <Button onClick={this.props.onHide}>Cancel</Button> <Button bsStyle='danger' onClick={this.handleSubmit}>Delete</Button> </Modal.Footer> </form> </Modal> ); } }); export default DeleteDictionaryDialog;
classic/src/scenes/mailboxes/src/Scenes/AppScene/Sidelist/SidelistControls/SidelistControlDownloads/SidelistControlDownloads.js
wavebox/waveboxapp
import React from 'react' import SidelistControl from '../SidelistControl' import { settingsStore } from 'stores/settings' import { localHistoryStore } from 'stores/localHistory' import shallowCompare from 'react-addons-shallow-compare' import { UISettings } from 'shared/Models/Settings' import { withStyles } from '@material-ui/core/styles' import classNames from 'classnames' import SidelistFAIcon from '../SidelistFAIcon' import ThemeTools from 'wbui/Themes/ThemeTools' import FASArrowToBottom from 'wbfa/FASArrowToBottom' import { Popover, CircularProgress } from '@material-ui/core' import pluralize from 'pluralize' import DownloadsPopoutContent from './DownloadsPopoutContent' import ReactDOM from 'react-dom' import StyleMixins from 'wbui/Styles/StyleMixins' import SidelistControlDownloadsContextMenu from './SidelistControlDownloadsContextMenu' const styles = (theme) => ({ icon: { color: ThemeTools.getStateValue(theme, 'wavebox.sidebar.downloads.icon.color'), '&:hover': { color: ThemeTools.getStateValue(theme, 'wavebox.sidebar.downloads.icon.color', 'hover') } }, popout: { maxHeight: 500, maxWidth: 400, marginLeft: -10, overflowY: 'auto', ...StyleMixins.scrolling.alwaysShowVerticalScrollbars }, popoutBackdrop: { backgroundColor: 'rgba(0, 0, 0, 0.5)' }, progressWrap: { position: 'relative' }, progress: { position: 'absolute', top: 3, left: -7 }, progressCircle: { color: ThemeTools.getStateValue(theme, 'wavebox.sidebar.downloads.icon.color') } }) @withStyles(styles, { withTheme: true }) class SidelistControlDownloads extends React.Component { /* **************************************************************************/ // Lifecycle /* **************************************************************************/ constructor (props) { super(props) this.rootRef = React.createRef() this.deferredHide = null } /* **************************************************************************/ // Component lifecycle /* **************************************************************************/ componentDidMount () { settingsStore.listen(this.settingsChanged) localHistoryStore.listen(this.localHistoryChanged) window.addEventListener('hashchange', this.closePopout) } componentWillUnmount () { settingsStore.unlisten(this.settingsChanged) localHistoryStore.unlisten(this.localHistoryChanged) window.removeEventListener('hashchange', this.closePopout) clearTimeout(this.deferredHide) } /* **************************************************************************/ // Data lifecycle /* **************************************************************************/ state = (() => { const settingsState = settingsStore.getState() const localHistoryState = localHistoryStore.getState() return { showMode: settingsState.ui.showSidebarDownloads, hasActiveDownloads: localHistoryState.hasActiveDownloads(), activeDownloadCount: localHistoryState.getActiveDownloadCount(), activeDownloadPercent: localHistoryState.getActiveDownloadPercent(), popoutAnchor: null, deferredHold: false } })() settingsChanged = (settingsState) => { this.setState({ showMode: settingsState.ui.showSidebarDownloads }) } localHistoryChanged = (localHistoryState) => { this.setState((prevState) => { const update = { hasActiveDownloads: localHistoryState.hasActiveDownloads(), activeDownloadCount: localHistoryState.getActiveDownloadCount(), activeDownloadPercent: localHistoryState.getActiveDownloadPercent() } if (update.hasActiveDownloads !== prevState.hasActiveDownloads) { clearTimeout(this.deferredHide) if (update.hasActiveDownloads === false) { update.deferredHold = true this.deferredHide = setTimeout(() => { this.setState({ deferredHold: false }) }, 3000) } else { update.deferredHold = false } } return update }) } /* **************************************************************************/ // UI Events /* **************************************************************************/ openPopout = (evt) => { this.setState({ popoutAnchor: ReactDOM.findDOMNode(this.rootRef.current) }) } closePopout = () => { this.setState((prevState) => { if (!prevState.popoutAnchor) { return undefined } else { clearTimeout(this.deferredHide) this.deferredHide = setTimeout(() => { this.setState({ deferredHold: false }) }, 3000) return { popoutAnchor: null, deferredHold: true } } }) } /* **************************************************************************/ // Rendering /* **************************************************************************/ shouldComponentUpdate (nextProps, nextState) { return shallowCompare(this, nextProps, nextState) } render () { const { classes } = this.props const { showMode, hasActiveDownloads, activeDownloadCount, activeDownloadPercent, popoutAnchor, deferredHold } = this.state // Check if we should show if (!popoutAnchor) { if (showMode === UISettings.SIDEBAR_DOWNLOAD_MODES.NEVER) { return false } else if (showMode === UISettings.SIDEBAR_DOWNLOAD_MODES.ACTIVE) { if (!hasActiveDownloads && !deferredHold) { return false } } } return ( <React.Fragment> <SidelistControl ref={this.rootRef} className={classNames(`WB-SidelistControlDownloads`)} onClick={this.openPopout} tooltip={hasActiveDownloads ? ( `${activeDownloadCount} ${pluralize('Downloads', activeDownloadCount)} - ${Math.round(activeDownloadPercent)}%` ) : ( `Downloads` )} icon={( <span className={classes.progressWrap}> {hasActiveDownloads ? ( <CircularProgress className={classes.progress} classes={{ circle: classes.progressCircle }} value={activeDownloadPercent} size={28} variant='static' /> ) : undefined} <SidelistFAIcon className={classNames(classes.icon)} IconClass={FASArrowToBottom} /> </span> )} ContextMenuComponent={SidelistControlDownloadsContextMenu} /> <Popover anchorEl={popoutAnchor} anchorOrigin={{ vertical: 'center', horizontal: 'right' }} BackdropProps={{ classes: { root: classes.popoutBackdrop } }} disableEnforceFocus open={!!popoutAnchor} classes={{ paper: classes.popout }} onClose={this.closePopout}> <DownloadsPopoutContent /> </Popover> </React.Fragment> ) } } export default SidelistControlDownloads
projects/lost-text-mining/viz2/src/components/ButtonGroup/index.js
ebemunk/blog
import React from 'react' import classnames from 'classnames' import css from './ButtonGroup.css' export default function ButtonGroup({ options, onChange, selected, ...other }) { return ( <div className={css.wrapper} {...other}> {options.map(opt => ( <button children={opt.name} onClick={() => onChange(opt.value)} className={classnames('button', css.groupedButton, { active: opt.value === selected, })} key={opt.value} /> ))} </div> ) }
node_modules/rc-slider/es/common/createSlider.js
prodigalyijun/demo-by-antd
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _extends from 'babel-runtime/helpers/extends'; import _defineProperty from 'babel-runtime/helpers/defineProperty'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _createClass from 'babel-runtime/helpers/createClass'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _get from 'babel-runtime/helpers/get'; import _inherits from 'babel-runtime/helpers/inherits'; import React from 'react'; import PropTypes from 'prop-types'; import addEventListener from 'rc-util/es/Dom/addEventListener'; import classNames from 'classnames'; import warning from 'warning'; import Steps from './Steps'; import Marks from './Marks'; import Handle from '../Handle'; import * as utils from '../utils'; function noop() {} export default function createSlider(Component) { var _class, _temp; return _temp = _class = function (_Component) { _inherits(ComponentEnhancer, _Component); function ComponentEnhancer(props) { _classCallCheck(this, ComponentEnhancer); var _this = _possibleConstructorReturn(this, (ComponentEnhancer.__proto__ || Object.getPrototypeOf(ComponentEnhancer)).call(this, props)); _this.onMouseDown = function (e) { if (e.button !== 0) { return; } var isVertical = _this.props.vertical; var position = utils.getMousePosition(isVertical, e); if (!utils.isEventFromHandle(e, _this.handlesRefs)) { _this.dragOffset = 0; } else { var handlePosition = utils.getHandleCenterPosition(isVertical, e.target); _this.dragOffset = position - handlePosition; position = handlePosition; } _this.onStart(position); _this.addDocumentMouseEvents(); utils.pauseEvent(e); }; _this.onTouchStart = function (e) { if (utils.isNotTouchEvent(e)) return; var isVertical = _this.props.vertical; var position = utils.getTouchPosition(isVertical, e); if (!utils.isEventFromHandle(e, _this.handlesRefs)) { _this.dragOffset = 0; } else { var handlePosition = utils.getHandleCenterPosition(isVertical, e.target); _this.dragOffset = position - handlePosition; position = handlePosition; } _this.onStart(position); _this.addDocumentTouchEvents(); utils.pauseEvent(e); }; _this.onMouseMove = function (e) { if (!_this.sliderRef) { _this.onEnd(); return; } var position = utils.getMousePosition(_this.props.vertical, e); _this.onMove(e, position - _this.dragOffset); }; _this.onTouchMove = function (e) { if (utils.isNotTouchEvent(e) || !_this.sliderRef) { _this.onEnd(); return; } var position = utils.getTouchPosition(_this.props.vertical, e); _this.onMove(e, position - _this.dragOffset); }; _this.saveSlider = function (slider) { _this.sliderRef = slider; }; if (process.env.NODE_ENV !== 'production') { var step = props.step, max = props.max, min = props.min; warning(step && Math.floor(step) === step ? (max - min) % step === 0 : true, 'Slider[max] - Slider[min] (%s) should be a multiple of Slider[step] (%s)', max - min, step); } _this.handlesRefs = {}; return _this; } _createClass(ComponentEnhancer, [{ key: 'componentWillUnmount', value: function componentWillUnmount() { if (_get(ComponentEnhancer.prototype.__proto__ || Object.getPrototypeOf(ComponentEnhancer.prototype), 'componentWillUnmount', this)) _get(ComponentEnhancer.prototype.__proto__ || Object.getPrototypeOf(ComponentEnhancer.prototype), 'componentWillUnmount', this).call(this); this.removeDocumentEvents(); } }, { key: 'addDocumentTouchEvents', value: function addDocumentTouchEvents() { this.onTouchMoveListener = addEventListener(document, 'touchmove', this.onTouchMove); this.onTouchUpListener = addEventListener(document, 'touchend', this.onEnd); } }, { key: 'addDocumentMouseEvents', value: function addDocumentMouseEvents() { this.onMouseMoveListener = addEventListener(document, 'mousemove', this.onMouseMove); this.onMouseUpListener = addEventListener(document, 'mouseup', this.onEnd); } }, { key: 'removeDocumentEvents', value: function removeDocumentEvents() { this.onTouchMoveListener && this.onTouchMoveListener.remove(); this.onTouchUpListener && this.onTouchUpListener.remove(); this.onMouseMoveListener && this.onMouseMoveListener.remove(); this.onMouseUpListener && this.onMouseUpListener.remove(); } }, { key: 'getSliderStart', value: function getSliderStart() { var slider = this.sliderRef; var rect = slider.getBoundingClientRect(); return this.props.vertical ? rect.top : rect.left; } }, { key: 'getSliderLength', value: function getSliderLength() { var slider = this.sliderRef; if (!slider) { return 0; } return this.props.vertical ? slider.clientHeight : slider.clientWidth; } }, { key: 'calcValue', value: function calcValue(offset) { var _props = this.props, vertical = _props.vertical, min = _props.min, max = _props.max; var ratio = Math.abs(Math.max(offset, 0) / this.getSliderLength()); var value = vertical ? (1 - ratio) * (max - min) + min : ratio * (max - min) + min; return value; } }, { key: 'calcValueByPos', value: function calcValueByPos(position) { var pixelOffset = position - this.getSliderStart(); var nextValue = this.trimAlignValue(this.calcValue(pixelOffset)); return nextValue; } }, { key: 'calcOffset', value: function calcOffset(value) { var _props2 = this.props, min = _props2.min, max = _props2.max; var ratio = (value - min) / (max - min); return ratio * 100; } }, { key: 'saveHandle', value: function saveHandle(index, handle) { this.handlesRefs[index] = handle; } }, { key: 'render', value: function render() { var _classNames; var _props3 = this.props, prefixCls = _props3.prefixCls, className = _props3.className, marks = _props3.marks, dots = _props3.dots, step = _props3.step, included = _props3.included, disabled = _props3.disabled, vertical = _props3.vertical, min = _props3.min, max = _props3.max, children = _props3.children, maximumTrackStyle = _props3.maximumTrackStyle, style = _props3.style; var _get$call = _get(ComponentEnhancer.prototype.__proto__ || Object.getPrototypeOf(ComponentEnhancer.prototype), 'render', this).call(this), tracks = _get$call.tracks, handles = _get$call.handles; var sliderClassName = classNames((_classNames = {}, _defineProperty(_classNames, prefixCls, true), _defineProperty(_classNames, prefixCls + '-with-marks', Object.keys(marks).length), _defineProperty(_classNames, prefixCls + '-disabled', disabled), _defineProperty(_classNames, prefixCls + '-vertical', vertical), _defineProperty(_classNames, className, className), _classNames)); return React.createElement( 'div', { ref: this.saveSlider, className: sliderClassName, onTouchStart: disabled ? noop : this.onTouchStart, onMouseDown: disabled ? noop : this.onMouseDown, style: style }, React.createElement('div', { className: prefixCls + '-rail', style: maximumTrackStyle }), tracks, React.createElement(Steps, { prefixCls: prefixCls, vertical: vertical, marks: marks, dots: dots, step: step, included: included, lowerBound: this.getLowerBound(), upperBound: this.getUpperBound(), max: max, min: min }), handles, React.createElement(Marks, { className: prefixCls + '-mark', vertical: vertical, marks: marks, included: included, lowerBound: this.getLowerBound(), upperBound: this.getUpperBound(), max: max, min: min }), children ); } }]); return ComponentEnhancer; }(Component), _class.displayName = 'ComponentEnhancer(' + Component.displayName + ')', _class.propTypes = _extends({}, Component.propTypes, { min: PropTypes.number, max: PropTypes.number, step: PropTypes.number, marks: PropTypes.object, included: PropTypes.bool, className: PropTypes.string, prefixCls: PropTypes.string, disabled: PropTypes.bool, children: PropTypes.any, onBeforeChange: PropTypes.func, onChange: PropTypes.func, onAfterChange: PropTypes.func, handle: PropTypes.func, dots: PropTypes.bool, vertical: PropTypes.bool, style: PropTypes.object, minimumTrackStyle: PropTypes.object, maximumTrackStyle: PropTypes.object, handleStyle: PropTypes.object }), _class.defaultProps = _extends({}, Component.defaultProps, { prefixCls: 'rc-slider', className: '', min: 0, max: 100, step: 1, marks: {}, handle: function handle(_ref) { var index = _ref.index, restProps = _objectWithoutProperties(_ref, ['index']); delete restProps.dragging; delete restProps.value; return React.createElement(Handle, _extends({}, restProps, { key: index })); }, onBeforeChange: noop, onChange: noop, onAfterChange: noop, included: true, disabled: false, dots: false, vertical: false, minimumTrackStyle: {}, maximumTrackStyle: {}, handleStyle: {} }), _temp; }
packages/zensroom/lib/components/rooms/RoomsNewPage.js
SachaG/Zensroom
/* Page for inserting a new room */ import React from 'react'; import { Components, registerComponent } from 'meteor/vulcan:core'; import { FormattedMessage } from 'meteor/vulcan:i18n'; // import RoomsNewForm from './RoomsNewForm'; const RoomsNewPage = () => <div className="page"> <h2 className="page-title"><FormattedMessage id="rooms.create_new"/></h2> <Components.RoomsNewForm /> </div> registerComponent('RoomsNewPage', RoomsNewPage); // export default RoomsNewPage;
react-flux-mui/js/material-ui/src/svg-icons/navigation/first-page.js
pbogdan/react-flux-mui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let NavigationFirstPage = (props) => ( <SvgIcon {...props}> <path d="M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"/> </SvgIcon> ); NavigationFirstPage = pure(NavigationFirstPage); NavigationFirstPage.displayName = 'NavigationFirstPage'; NavigationFirstPage.muiName = 'SvgIcon'; export default NavigationFirstPage;
src/index.js
mathieulesniak/react-starter-kit
import React from 'react'; import { render } from 'react-dom'; import { Router, browserHistory } from 'react-router'; import { Provider } from 'react-redux'; import routes from './routes'; import configureStore from './store'; const store = configureStore(); render( <Provider store={store}> <Router history={browserHistory} routes={routes} /> </Provider>, document.getElementById('app') );
node_modules/react-router-dom/es/Link.js
aggiedefenders/aggiedefenders.github.io
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; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import React from 'react'; import PropTypes from 'prop-types'; import invariant from 'invariant'; var isModifiedEvent = function isModifiedEvent(event) { return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); }; /** * The public API for rendering a history-aware <a>. */ var Link = function (_React$Component) { _inherits(Link, _React$Component); function Link() { var _temp, _this, _ret; _classCallCheck(this, Link); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleClick = function (event) { if (_this.props.onClick) _this.props.onClick(event); if (!event.defaultPrevented && // onClick prevented default event.button === 0 && // ignore right clicks !_this.props.target && // let browser handle "target=_blank" etc. !isModifiedEvent(event) // ignore clicks with modifier keys ) { event.preventDefault(); var history = _this.context.router.history; var _this$props = _this.props, replace = _this$props.replace, to = _this$props.to; if (replace) { history.replace(to); } else { history.push(to); } } }, _temp), _possibleConstructorReturn(_this, _ret); } Link.prototype.render = function render() { var _props = this.props, replace = _props.replace, to = _props.to, innerRef = _props.innerRef, props = _objectWithoutProperties(_props, ['replace', 'to', 'innerRef']); // eslint-disable-line no-unused-vars invariant(this.context.router, 'You should not use <Link> outside a <Router>'); var href = this.context.router.history.createHref(typeof to === 'string' ? { pathname: to } : to); return React.createElement('a', _extends({}, props, { onClick: this.handleClick, href: href, ref: innerRef })); }; return Link; }(React.Component); Link.propTypes = { onClick: PropTypes.func, target: PropTypes.string, replace: PropTypes.bool, to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired, innerRef: PropTypes.oneOfType([PropTypes.string, PropTypes.func]) }; Link.defaultProps = { replace: false }; Link.contextTypes = { router: PropTypes.shape({ history: PropTypes.shape({ push: PropTypes.func.isRequired, replace: PropTypes.func.isRequired, createHref: PropTypes.func.isRequired }).isRequired }).isRequired }; export default Link;
client/component/redirect-edit/action/index.js
johngodley/redirection
/** * External dependencies */ import React from 'react'; /** * Internal dependencies */ import ActionLogin from './login'; import ActionUrl from './url'; import ActionUrlFrom from './url-from'; import { MATCH_URL, MATCH_LOGIN, MATCH_PAGE, hasUrlTarget, getMatchState, } from 'state/redirect/selector'; function getComponentForType( type ) { if ( type === MATCH_LOGIN ) { return ActionLogin; } if ( type === MATCH_URL || type === MATCH_PAGE ) { return ActionUrl; } return ActionUrlFrom; } const ActionTarget = ( { actionType, matchType, actionData, onChange } ) => { if ( hasUrlTarget( actionType ) ) { const Component = getComponentForType( matchType ); const state = getMatchState( matchType, actionData ); return <Component data={ state === null ? {} : state } onChange={ onChange } />; } return null; }; export default ActionTarget;
doc/workshop-react-laborator-11-12/solutie/my-dogs/src/index.js
bmnicolae/laborator-tehnici-web
import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.getElementById('root') ); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals reportWebVitals();
src/PaginationBox.js
panacholn/pagination
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router'; import PaginationItem from './PaginationItem'; class PaginationBox extends Component { handlePreviousPage = () => { if (this.props.page > 1) { return this.props.page - 1; } return this.props.page; }; handleNextPage = () => { if (this.props.page < this.props.pageCount) { return this.props.page + 1; } return this.props.page; }; displayFirstButton = () => { if (this.props.pageCount > this.props.pageRangeDisplayed && this.props.page !== 1) { return ( <PaginationItem url={this.props.genUrl(1)} pageClassName={this.props.firstClassName} pageLinkClassName={this.props.firstLinkClassName} activeClassName={this.props.activeClassName} id={'first-button'} label={this.props.firstLabel} /> ); } return null; }; displayPreviousButton = () => { if (this.props.pageCount > this.props.pageRangeDisplayed && this.props.page !== 1) { return ( <PaginationItem url={this.props.genUrl(this.handlePreviousPage())} pageClassName={this.props.previousClassName} pageLinkClassName={this.props.previousLinkClassName} activeClassName={this.props.activeClassName} id={'previous-button'} label={this.props.previousLabel} /> ); } return null; }; displayNextButton = () => { if (this.props.pageCount > this.props.pageRangeDisplayed && this.props.page !== this.props.pageCount) { return ( <PaginationItem url={this.props.genUrl(this.handleNextPage())} pageClassName={this.props.nextClassName} pageLinkClassName={this.props.nextLinkClassName} activeClassName={this.props.activeClassName} id={'next-button'} label={this.props.nextLabel} /> ); } return null; }; displayLastButton = () => { if (this.props.pageCount > this.props.pageRangeDisplayed && this.props.page !== this.props.pageCount) { return ( <PaginationItem url={this.props.genUrl(this.props.pageCount)} pageClassName={this.props.lastClassName} pageLinkClassName={this.props.lastLinkClassName} activeClassName={this.props.activeClassName} id={'last-button'} label={this.props.lastLabel} /> ); } return null; }; calculateBound = () => { const maxPageCount = this.props.pageCount - 1; const pageRange = this.props.pageRangeDisplayed - 1; let result = { min: 0, max: maxPageCount }; if (maxPageCount > pageRange) { const lowerBound = Math.floor(pageRange / 2); const higherBound = pageRange - lowerBound; let relatedLowerBound = (this.props.page - 1) - lowerBound; let relatedHigherBound = (this.props.page - 1) + higherBound; if (relatedLowerBound < 0) { relatedHigherBound -= relatedLowerBound; relatedLowerBound = 0; } if (relatedHigherBound > maxPageCount) { relatedLowerBound -= relatedHigherBound - maxPageCount; relatedHigherBound = maxPageCount; } result = { min: relatedLowerBound, max: relatedHigherBound }; } return result; }; pagination = () => { const items = []; const { min, max } = this.calculateBound(); for (let index = min; index <= max; index += 1) { items.push(<PaginationItem key={index} url={this.props.genUrl(index + 1)} selected={this.props.page === index + 1} pageClassName={this.props.pageClassName} pageLinkClassName={this.props.pageLinkClassName} activeClassName={this.props.activeClassName} id={`page-${index + 1}`} label={`${index + 1}`} />); } return items; }; render() { return ( <ul className={this.props.containerClassName}> {this.displayFirstButton()} {this.displayPreviousButton()} {this.pagination()} {this.displayNextButton()} {this.displayLastButton()} </ul> ); } } PaginationBox.propTypes = { pageCount: PropTypes.number.isRequired, pageRangeDisplayed: PropTypes.number.isRequired, firstLabel: PropTypes.node, previousLabel: PropTypes.node, nextLabel: PropTypes.node, lastLabel: PropTypes.node, genUrl: PropTypes.func.isRequired, page: PropTypes.number, containerClassName: PropTypes.string, pageClassName: PropTypes.string, pageLinkClassName: PropTypes.string, activeClassName: PropTypes.string, firstClassName: PropTypes.string, previousClassName: PropTypes.string, nextClassName: PropTypes.string, lastClassName: PropTypes.string, firstLinkClassName: PropTypes.string, previousLinkClassName: PropTypes.string, nextLinkClassName: PropTypes.string, lastLinkClassName: PropTypes.string, }; PaginationBox.defaultProps = { firstLabel: '\xAB', previousLabel: '\u2039', nextLabel: '\u203A', lastLabel: '\xBB', page: 1, containerClassName: 'pagination', pageClassName: 'page', pageLinkClassName: 'page-link', activeClassName: 'active', firstClassName: 'first', previousClassName: 'previous', nextClassName: 'next', lastClassName: 'last', firstLinkClassName: 'first-link', previousLinkClassName: 'previous-link', nextLinkClassName: 'next-link', lastLinkClassName: 'last-link', }; export default PaginationBox;
src/component/SkillsList.js
Valtena/valt-code
import React from 'react'; import MDLComponent from '../utils/MDLComponent.js'; import Skill from './Skill.js'; class SkillsList extends MDLComponent { render() { return ( <div className="skillsList"> <h2>{this.props.title}</h2> <ul className="mdl-list"> {this.props.items.map((item) => <Skill item={item}/>)} </ul> </div> ); } } export default SkillsList;
src/svg-icons/maps/store-mall-directory.js
spiermar/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsStoreMallDirectory = (props) => ( <SvgIcon {...props}> <path d="M20 4H4v2h16V4zm1 10v-2l-1-5H4l-1 5v2h1v6h10v-6h4v6h2v-6h1zm-9 4H6v-4h6v4z"/> </SvgIcon> ); MapsStoreMallDirectory = pure(MapsStoreMallDirectory); MapsStoreMallDirectory.displayName = 'MapsStoreMallDirectory'; MapsStoreMallDirectory.muiName = 'SvgIcon'; export default MapsStoreMallDirectory;
client/modules/Exercise/components/ExerciseListItem.js
Danielbook/liftinglog
import React from 'react'; import PropTypes from 'prop-types'; import SetList from '../../Set/components/SetList'; import IconButton from 'material-ui/IconButton'; import ContentRemoveCircle from 'material-ui/svg-icons/content/remove-circle-outline'; import ContentAddCircle from 'material-ui/svg-icons/content/add-circle-outline'; import { Col, Row } from 'react-flexbox-grid'; // https://github.com/callemall/material-ui/issues/3543 to stop selecting both row and item in LIST const ExerciseListItem = (props) => ( <Row style={{ marginBottom: 40 }}> <Col xs={10}> <h3>{props.exercise.title}</h3> </Col> <Col xs={1}> <IconButton onTouchTap={props.onAddSet} tooltip="Add set" > <ContentAddCircle /> </IconButton> </Col> <Col xs={1}> <IconButton onTouchTap={props.onDelete} tooltip="Delete exercise" > <ContentRemoveCircle /> </IconButton> </Col> <SetList sets={props.exercise.sets} handleDeleteSet={props.handleDeleteSet} /> </Row> ); ExerciseListItem.propTypes = { exercise: PropTypes.shape({ title: PropTypes.string.isRequired, sets: PropTypes.array.isRequired, }).isRequired, onDelete: PropTypes.func.isRequired, onAddSet: PropTypes.func.isRequired, handleDeleteSet: PropTypes.func.isRequired, }; export default ExerciseListItem;
src/client/story_list.js
Ribeiro/hacker-menu
import React from 'react' import Story from './story.js' import _ from 'lodash' export default class StoryList extends React.Component { render () { var onUrlClick = this.props.onUrlClick var onMarkAsRead = this.props.onMarkAsRead var storyNodes = _.map(this.props.stories, function (story, index) { return ( <li key={index} className='table-view-cell media'> <Story story={story} onUrlClick={onUrlClick} onMarkAsRead={onMarkAsRead}/> </li> ) }) return ( <ul className='content table-view'> {storyNodes} </ul> ) } } StoryList.propTypes = { onUrlClick: React.PropTypes.func.isRequired, onMarkAsRead: React.PropTypes.func.isRequired, stories: React.PropTypes.array.isRequired }
src/components/FormItem/FormItem.js
wfp/ui
import PropTypes from 'prop-types'; import React from 'react'; import classnames from 'classnames'; import settings from '../../globals/js/settings'; const { prefix } = settings; const FormItem = ({ className, children, invalid, ...other }) => { const classNames = classnames( `${prefix}--form-item`, { [`${prefix}--form-item--invalid`]: invalid, }, className ); return ( <div className={classNames} {...other}> {children} </div> ); }; FormItem.propTypes = { children: PropTypes.node, className: PropTypes.string, }; export default FormItem;
src/js/components/icons/base/PlatformSolaris.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}-platform-solaris`, className, { [`${CLASS_ROOT}--${size}`]: size, [`${CLASS_ROOT}--responsive`]: responsive, [`${COLOR_INDEX}-${colorIndex}`]: colorIndex } ); a11yTitle = a11yTitle || Intl.getMessage(intl, 'platform-solaris'); const restProps = Props.omit(this.props, Object.keys(Icon.propTypes)); return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fillRule="evenodd" d="M10.1802464,4.7643196 C9.30783675,4.45498283 8.90876565,3.63737375 8.90876565,3.63737375 C8.84089823,3.54283936 8.5558284,2.85816509 8.5562284,2.85789842 C8.25689174,2.06482294 7.71088568,1.82242025 7.71088568,1.82242025 C7.03954488,1.42788253 6.21046901,1.41801576 6.21046901,1.41801576 C6.24620274,1.4132157 6.70394115,1.62521806 6.70394115,1.62521806 C7.78395316,2.13989044 7.46048289,3.3691041 7.46048289,3.3691041 C7.39021545,3.70004111 7.37381526,4.33911488 7.37381526,4.33911488 C7.35914843,5.19085768 7.96582184,5.60659563 8.03302259,5.65099612 C8.3674263,5.44779386 8.7239636,5.26739186 9.09756775,5.1147235 C9.45570506,4.96832187 9.81744242,4.85138724 10.1802464,4.7643196 M5.59699552,8.17022411 C4.76098623,8.56862854 3.90111001,8.27249192 3.90111001,8.27249192 C3.78604207,8.25382504 3.10043445,7.97115524 3.10043445,7.97115524 C2.32802587,7.62208469 1.77081968,7.83648707 1.77081968,7.83648707 C1.0168113,8.03182258 0.423738042,8.61142902 0.423738042,8.61142902 C0.445338282,8.58276203 0.919076879,8.40889343 0.919076879,8.40889343 C2.04668941,8.00915566 2.68682985,9.10716786 2.68682985,9.10716786 C2.87149857,9.39063767 3.31177013,9.85410949 3.31177013,9.85410949 C3.9033767,10.4670496 4.62685141,10.3319815 4.70538562,10.3161146 C4.79818665,9.93531039 4.9228547,9.55610618 5.0791231,9.18383538 C5.2288581,8.82703141 5.40166002,8.48876099 5.59699552,8.17022411 M4.76458627,13.8196202 C4.45511617,14.6924299 3.63764042,15.0916344 3.63764042,15.0916344 C3.54310603,15.1592351 2.85843176,15.4444383 2.85816509,15.4443049 C2.06508961,15.7436416 1.82268692,16.2895143 1.82268692,16.2895143 C1.42788253,16.9605885 1.41854909,17.7897977 1.41854909,17.7897977 C1.41361571,17.7540639 1.62535139,17.2963255 1.62535139,17.2963255 C2.14002378,16.2163135 3.36950411,16.5401838 3.36950411,16.5401838 C3.70004111,16.6097846 4.33898154,16.6264514 4.33898154,16.6264514 C5.19085768,16.6415182 5.6068623,16.0343115 5.65099612,15.9676441 C5.4479272,15.6325737 5.26765853,15.2763031 5.1151235,14.9026989 C4.96832187,14.5444283 4.8512539,14.1826909 4.76458627,13.8196202 M8.17075745,18.4032711 C8.56889521,19.2391471 8.27315859,20.0994233 8.27315859,20.0994233 C8.25435838,20.2138246 7.97155524,20.9000989 7.97128857,20.8999656 C7.62195136,21.6722408 7.83675374,22.2297137 7.83675374,22.2297137 C8.03195591,22.9835887 8.61169569,23.5767953 8.61169569,23.5767953 C8.5830287,23.5549284 8.40902677,23.0813231 8.40902677,23.0813231 C8.00942233,21.9535773 9.1077012,21.3135702 9.1077012,21.3135702 C9.39103768,21.1287681 9.85464283,20.6884965 9.85464283,20.6884965 C10.4673163,20.09689 10.3325148,19.3735486 10.3163813,19.2951477 C9.9357104,19.2019467 9.55610618,19.077412 9.18370204,18.9211436 C8.82703141,18.7716752 8.48876099,18.5984733 8.17075745,18.4032711 M13.8200202,19.2359471 C14.6929633,19.5448838 15.0917677,20.3626263 15.0917677,20.3626263 C15.1596351,20.4571606 15.4445716,21.1421016 15.4441716,21.1423682 C15.7435083,21.9353104 16.289781,22.1777131 16.289781,22.1777131 C16.9609885,22.5727841 17.7900643,22.5822509 17.7900643,22.5822509 C17.7545973,22.5869176 17.2967255,22.3749153 17.2967255,22.3749153 C16.2163135,21.8602429 16.5403171,20.6311626 16.5403171,20.6311626 C16.6103179,20.3000922 16.6264514,19.6612851 16.6264514,19.6612851 C16.6416516,18.8092757 16.0344448,18.393271 15.9680441,18.3492705 C15.6328404,18.5524728 15.2767031,18.7326081 14.9026989,18.8852765 C14.5448283,19.0319448 14.1833576,19.1488794 13.8200202,19.2359471 M18.4035378,15.8299092 C19.2394138,15.4312381 20.09969,15.7275081 20.09969,15.7275081 C20.2146246,15.7463083 20.9002322,16.0291114 20.8999656,16.0293781 C21.6726408,16.3783153 22.2299803,16.1636463 22.2299803,16.1636463 C22.984122,15.9681774 23.5769286,15.3887043 23.5769286,15.3887043 C23.5551951,15.4175046 23.0818565,15.5911066 23.0818565,15.5911066 C21.9538439,15.990711 21.3135702,14.8928321 21.3135702,14.8928321 C21.1287681,14.6093623 20.6887632,14.1460238 20.6887632,14.1460238 C20.0970233,13.532817 19.3736819,13.6680185 19.2952811,13.6838854 C19.2023467,14.0645563 19.0775453,14.4441605 18.9214102,14.816298 C18.7720752,15.1731019 18.5988733,15.5113723 18.4035378,15.8299092 M19.2364804,10.1802464 C19.5455505,9.30757008 20.3628929,8.90849898 20.3628929,8.90849898 C20.4574273,8.84063156 21.1426349,8.55542839 21.1429016,8.55596173 C21.9351771,8.25662507 22.1777131,7.71101901 22.1777131,7.71101901 C22.5726508,7.03927821 22.5826509,6.21046901 22.5826509,6.21046901 C22.587051,6.24593607 22.3753153,6.70367449 22.3753153,6.70367449 C21.8606429,7.78368649 20.6312959,7.46021622 20.6312959,7.46021622 C20.3003589,7.39034878 19.6615518,7.37368193 19.6615518,7.37368193 C18.809409,7.35848176 18.393671,7.96582184 18.3492705,8.03235592 C18.5527395,8.36729297 18.7330081,8.72383026 18.8854098,9.09756775 C19.0323448,9.45557173 19.1488794,9.81730908 19.2364804,10.1802464 M15.8303092,5.59659552 C15.4316381,4.76111957 15.7273747,3.90084334 15.7273747,3.90084334 C15.7464416,3.78604207 16.0289781,3.09990111 16.0296448,3.10030111 C16.378582,2.32789253 16.1639129,1.77055301 16.1639129,1.77055301 C15.9681774,1.01641129 15.3892377,0.423471372 15.3892377,0.423471372 C15.417638,0.445338282 15.5916399,0.918810209 15.5916399,0.918810209 C15.9909777,2.04642274 14.8928321,2.68669652 14.8928321,2.68669652 C14.609629,2.87163191 14.1464238,3.31150346 14.1464238,3.31150346 C13.5330837,3.9029767 13.6684185,4.62658474 13.6844187,4.70525228 C14.0649563,4.79791998 14.4445605,4.92298803 14.8164313,5.07885643 C15.1732353,5.22819142 15.511639,5.40139335 15.8301759,5.59659552 M7.58741764,5.98366649 C6.66234069,6.02633363 5.98473316,5.41926021 5.98473316,5.41926021 C5.88633207,5.35752619 5.36419294,4.83058701 5.36432627,4.830187 C4.78831987,4.2085801 4.19124657,4.19017989 4.19124657,4.19017989 C3.42070467,4.07711197 2.64896277,4.38084868 2.64896277,4.38084868 C2.68016311,4.36271514 3.18416871,4.38658207 3.18416871,4.38658207 C4.37844865,4.45618285 4.5417838,5.71699686 4.5417838,5.71699686 C4.60205113,6.04966722 4.82752031,6.6478072 4.82752031,6.6478072 C5.13472372,7.44248269 5.85366504,7.5987511 5.93233258,7.61448461 C6.16580184,7.30021445 6.42793809,6.99874443 6.71660796,6.71660796 C6.99314437,6.44580495 7.2839476,6.20113557 7.58741764,5.98366649 M4.6256514,10.8662541 C4.00151113,11.5502617 3.0933677,11.6003956 3.0933677,11.6003956 C2.97989978,11.6261292 2.23829154,11.6227958 2.23829154,11.6223958 C1.39108212,11.5899954 0.955743953,11.9990667 0.955743953,11.9990667 C0.331337015,12.4642718 0,13.2248136 0,13.2248136 C0.00946677185,13.1897466 0.382670919,12.8502761 0.382670919,12.8502761 C1.27641418,12.0552006 2.2833587,12.8309426 2.2833587,12.8309426 C2.56109512,13.0237447 3.14363493,13.2873476 3.14363493,13.2873476 C3.92271025,13.6320181 4.5417838,13.234147 4.60845121,13.1896132 C4.5513839,12.8021422 4.52338359,12.4037378 4.52805031,12.0002667 C4.53218369,11.612929 4.56498406,11.2343915 4.6256514,10.8662541 M5.98393315,16.4127157 C6.02646696,17.3377926 5.41952688,18.0155335 5.41952688,18.0155335 C5.35752619,18.1140679 4.83058701,18.6360737 4.83032034,18.6359404 C4.2085801,19.2119468 4.19004656,19.8090201 4.19004656,19.8090201 C4.07711197,20.5794287 4.38084868,21.3513039 4.38084868,21.3513039 C4.36284848,21.3201036 4.38658207,20.8162313 4.38658207,20.8162313 C4.45631618,19.6216847 5.71673019,19.4584829 5.71673019,19.4584829 C6.04966722,19.3982155 6.6478072,19.1728797 6.6478072,19.1728797 C7.44248269,18.8658096 7.59901777,18.1466016 7.61461794,18.0680674 C7.30021445,17.8343315 6.9990111,17.5721952 6.7167413,17.2836587 C6.44580495,17.007389 6.2012689,16.7163191 5.98393315,16.4127157 M10.8663874,19.3746153 C11.550395,19.9987555 11.6002622,20.906899 11.6002622,20.906899 C11.6262625,21.0203669 11.6227958,21.7622418 11.6225291,21.7622418 C11.5902621,22.6090512 11.9993333,23.0446561 11.9993333,23.0446561 C12.4644052,23.6693297 13.2248136,24 13.2248136,24 C13.1900132,23.9905332 12.8504094,23.6175958 12.8504094,23.6175958 C12.0552006,22.7237192 12.8310759,21.7170413 12.8310759,21.7170413 C13.023878,21.4391715 13.2873476,20.8566317 13.2873476,20.8566317 C13.6320181,20.0775564 13.2340137,19.4584829 13.1900132,19.3916821 C12.8022756,19.4491494 12.4038712,19.4767497 12.0001333,19.4722164 C11.6131957,19.4679496 11.2345248,19.4354159 10.8663874,19.3746153 M16.4129824,18.0166002 C17.3380593,17.9740664 18.0155335,18.5810065 18.0155335,18.5810065 C18.1140679,18.6427405 18.6363404,19.1696797 18.6359404,19.1699463 C19.2119468,19.7916866 19.8092868,19.8104868 19.8092868,19.8104868 C20.5798287,19.923288 21.3514372,19.6195513 21.3514372,19.6195513 C21.3202369,19.6372849 20.8162313,19.6136846 20.8162313,19.6136846 C19.621818,19.5439505 19.4584829,18.2834031 19.4584829,18.2834031 C19.3983489,17.9505995 19.1727464,17.3525928 19.1727464,17.3525928 C18.8656763,16.557784 18.1466016,16.4012489 18.0682008,16.3855154 C17.8345982,16.7001856 17.5723286,17.0013889 17.2836587,17.2835254 C17.007389,17.5544617 16.7164524,17.7989978 16.4129824,18.0166002 M19.3748819,13.1341459 C19.9988889,12.4497383 20.9070323,12.3998711 20.9070323,12.3998711 C21.0206336,12.3740042 21.7625085,12.3772042 21.7625085,12.3780042 C22.6093179,12.4098712 23.0446561,12.0008 23.0446561,12.0008 C23.669463,11.5355948 24.0004,10.7755864 24.0004,10.7755864 C23.9907999,10.8102534 23.6177291,11.1498572 23.6177291,11.1498572 C22.7239858,11.9451994 21.7167746,11.1693241 21.7167746,11.1693241 C21.4391715,10.9763886 20.8568984,10.7130524 20.8568984,10.7130524 C20.0775564,10.3682485 19.4584829,10.7659863 19.3919488,10.8102534 C19.4491494,11.1978578 19.4767497,11.5965289 19.472083,12 C19.4683496,12.3869376 19.4354159,12.7654752 19.3748819,13.1341459 M18.0167335,7.5872843 C17.973933,6.66220736 18.5808731,5.98473316 18.5808731,5.98473316 C18.6430071,5.88619874 19.1699463,5.36379293 19.170213,5.3640596 C19.7916866,4.78831987 19.8104868,4.19124657 19.8104868,4.19124657 C19.9231547,3.42030467 19.619818,2.64896277 19.619818,2.64896277 C19.6375515,2.68002978 19.6136846,3.18416871 19.6136846,3.18416871 C19.5439505,4.37844865 18.2835365,4.54165046 18.2835365,4.54165046 C17.9505995,4.6019178 17.3527261,4.82752031 17.3527261,4.82752031 C16.557784,5.13445705 16.4013822,5.85366504 16.3853821,5.93206591 C16.7000522,6.16553517 17.0013889,6.42820476 17.2835254,6.71647463 C17.5547284,6.9928777 17.7989978,7.28354759 18.0167335,7.5872843 M13.1341459,4.62551806 C12.450005,4.00164446 12.3997378,3.09323437 12.3997378,3.09323437 C12.3742708,2.97963311 12.3773375,2.23789153 12.3778709,2.23789153 C12.4101379,1.39094879 12.0012,0.955743953 12.0012,0.955743953 C11.5358615,0.330803676 10.7757197,0 10.7757197,0 C10.8103868,0.00946677185 11.1499906,0.382537584 11.1499906,0.382537584 C11.9451994,1.27654752 11.1693241,2.2833587 11.1693241,2.2833587 C10.976522,2.56122846 10.713319,3.14336826 10.713319,3.14336826 C10.3681152,3.92271025 10.766253,4.54165046 10.8103868,4.60858454 C11.1979911,4.5509839 11.5965289,4.52365026 12,4.52818365 C12.3869376,4.53191702 12.7656085,4.56485072 13.1340126,4.62551806"/></svg>; } }; Icon.contextTypes = { intl: PropTypes.object }; Icon.defaultProps = { responsive: true }; Icon.displayName = 'PlatformSolaris'; Icon.icon = true; Icon.propTypes = { a11yTitle: PropTypes.string, colorIndex: PropTypes.string, size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']), responsive: PropTypes.bool };
views/blocks/SearchBar/SearchBarParams/SearchBarParams.js
MozalovPavel/team5
import React from 'react'; import ImagesCountControl from './../../ImagesCountControl/ImagesCountControl'; import DropDownButton from './../../DropDownButton/DropDownButton'; import './SearchBarParams.css'; import Item from './Item'; import b from 'b_'; function itemWithDropDownButton(className, param, params) { return ( <Item className={className} title={param.title}> <DropDownButton options={param.options} value={params[param.name]} name={param.name} /> </Item>); } export default class SearchBarParams extends React.Component { render() { const { imagesCount, searchCity, likesCount, reviewsCount, searchByField, params} = this.props; const imagesCountValue = { from: params[imagesCount.name.from], to: params[imagesCount.name.to]}; return ( <div className={b('container', {hidden: !this.props.showParams})}> <div className={b('searchbar', 'params-group', {hidden: !this.props.showParams})}> <Item className={b('param-item', {n: 1})} title={imagesCount.title}> <ImagesCountControl value={imagesCountValue} name={imagesCount.name} /> </Item> {itemWithDropDownButton(b('param-item', {n: 2}), searchCity, params)} {itemWithDropDownButton(b('param-item', {n: 3}), likesCount, params)} {itemWithDropDownButton(b('param-item', {n: 4}), reviewsCount, params)} {itemWithDropDownButton(b('param-item', {n: 5}), searchByField, params)} </div> </div>); } }
assets/jqwidgets/demos/react/app/input/autocomplete/app.js
juannelisalde/holter
import React from 'react'; import ReactDOM from 'react-dom'; import JqxInput from '../../../jqwidgets-react/react_jqxinput.js'; class App extends React.Component { render() { let source = (query, response) => { let dataAdapter = new $.jqx.dataAdapter ( { datatype: 'jsonp', datafields: [ { name: 'countryName' }, { name: 'name' }, { name: 'population', type: 'float' }, { name: 'continentCode' }, { name: 'adminName1' } ], url: 'http://api.geonames.org/searchJSON', data: { featureClass: 'P', style: 'full', maxRows: 12, username: 'jqwidgets' } }, { autoBind: true, formatData: (data) => { data.name_startsWith = query; return data; }, loadComplete: (data) => { if (data.geonames.length > 0) { response($.map(data.geonames, (item) => { return { label: item.name + (item.adminName1 ? ', ' + item.adminName1 : '') + ', ' + item.countryName, value: item.name } })); } } } ); }; return ( <JqxInput width={200} height={25} source={source} minLength={1} placeHolder={'Enter a Country'} /> ) } } ReactDOM.render(<App />, document.getElementById('app'));
docs/src/pages/components/popover/PopoverPopupState.js
lgollut/material-ui
import React from 'react'; import Typography from '@material-ui/core/Typography'; import Box from '@material-ui/core/Box'; import Button from '@material-ui/core/Button'; import Popover from '@material-ui/core/Popover'; import PopupState, { bindTrigger, bindPopover } from 'material-ui-popup-state'; export default function PopoverPopupState() { return ( <PopupState variant="popover" popupId="demo-popup-popover"> {(popupState) => ( <div> <Button variant="contained" color="primary" {...bindTrigger(popupState)}> Open Popover </Button> <Popover {...bindPopover(popupState)} anchorOrigin={{ vertical: 'bottom', horizontal: 'center', }} transformOrigin={{ vertical: 'top', horizontal: 'center', }} > <Box p={2}> <Typography>The content of the Popover.</Typography> </Box> </Popover> </div> )} </PopupState> ); }
src/svg-icons/action/assignment-turned-in.js
skarnecki/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionAssignmentTurnedIn = (props) => ( <SvgIcon {...props}> <path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm-2 14l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z"/> </SvgIcon> ); ActionAssignmentTurnedIn = pure(ActionAssignmentTurnedIn); ActionAssignmentTurnedIn.displayName = 'ActionAssignmentTurnedIn'; export default ActionAssignmentTurnedIn;
src/DayOfWeek.js
ygt-mikekchar/react-calendar-pane
import React from 'react'; let DayOfWeek = React.createClass({ render() { return <th className="DayOfWeek">{this.props.date.format('dd')}</th> } }); export default DayOfWeek;
node_modules/react-router/modules/Link.js
kevinsimper/isomorphic-apps-presentation
import React from 'react'; var { object, string, func } = React.PropTypes; function isLeftClickEvent(event) { return event.button === 0; } function isModifiedEvent(event) { return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); } /** * <Link> components are used to create an <a> element that links to a route. * When that route is active, the link gets an "active" class name (or the * value of its `activeClassName` prop). * * For example, assuming you have the following route: * * <Route name="showPost" path="/posts/:postID" handler={Post}/> * * You could use the following component to link to that route: * * <Link to="showPost" params={{ postID: "123" }} /> * * In addition to params, links may pass along query string parameters * using the `query` prop. * * <Link to="showPost" params={{ postID: "123" }} query={{ show:true }}/> */ export var Link = React.createClass({ contextTypes: { router: object }, propTypes: { activeStyle: object, activeClassName: string, to: string.isRequired, query: object, state: object, onClick: func }, getDefaultProps() { return { className: '', activeClassName: 'active', style: {} }; }, handleClick(event) { var allowTransition = true; var clickResult; if (this.props.onClick) clickResult = this.props.onClick(event); if (isModifiedEvent(event) || !isLeftClickEvent(event)) return; if (clickResult === false || event.defaultPrevented === true) allowTransition = false; event.preventDefault(); if (allowTransition) this.context.router.transitionTo(this.props.to, this.props.query, this.props.state); }, render() { var { router } = this.context; var { to, query } = this.props; var props = Object.assign({}, this.props, { href: router.makeHref(to, query), onClick: this.handleClick }); // ignore if rendered outside of the context of a router, simplifies unit testing if (router && router.isActive(to, query)) { if (props.activeClassName) props.className += ` ${props.activeClassName}`; if (props.activeStyle) Object.assign(props.style, props.activeStyle); } return React.createElement('a', props); } }); export default Link;
actor-apps/app-web/src/app/components/common/AvatarItem.react.js
v2tmobile/actor-platform
import React from 'react'; import classNames from 'classnames'; class AvatarItem extends React.Component { static propTypes = { image: React.PropTypes.string, placeholder: React.PropTypes.string.isRequired, size: React.PropTypes.string, title: React.PropTypes.string.isRequired }; constructor(props) { super(props); } render() { const title = this.props.title; const image = this.props.image; const size = this.props.size; let placeholder, avatar; let placeholderClassName = classNames('avatar__placeholder', `avatar__placeholder--${this.props.placeholder}`); let avatarClassName = classNames('avatar', { 'avatar--tiny': size === 'tiny', 'avatar--small': size === 'small', 'avatar--medium': size === 'medium', 'avatar--big': size === 'big', 'avatar--huge': size === 'huge', 'avatar--square': size === 'square' }); placeholder = <span className={placeholderClassName}>{title[0]}</span>; if (image) { avatar = <img alt={title} className="avatar__image" src={image}/>; } return ( <div className={avatarClassName}> {avatar} {placeholder} </div> ); } } export default AvatarItem;
src/components/common/icons/Magnifiner.js
goodjoblife/GoodJobShare
import React from 'react'; /* eslint-disable */ const Magnifiner = (props) => ( <svg {...props} width="148" height="148" viewBox="0 0 148 148"> <path d="M60.2523446,120.503385 C75.1785042,120.503385 88.8220019,115.016701 99.3594914,106.00019 L139.985703,146.625988 C140.903228,147.541216 142.101627,148 143.304708,148 C144.505448,148 145.703848,147.541216 146.623713,146.625988 C147.541238,145.70608 148,144.509964 148,143.306826 C148,142.103688 147.541238,140.902891 146.623713,139.985323 L105.997501,99.3595243 C115.015926,88.8262162 120.502349,75.1773898 120.502349,60.2528627 C120.502349,27.0284684 93.4704813,0 60.2523446,0 C27.0295267,0 0,27.0284684 0,60.2528627 C-1.26032814e-14,93.4749162 27.0295267,120.503385 60.2523446,120.503385 Z M60.2523446,9.38868856 C88.2930208,9.38868856 111.111765,32.2038337 111.111765,60.2505219 C111.111765,88.2925286 88.2930208,111.112355 60.2523446,111.112355 C32.2093277,111.112355 9.39058373,88.2948694 9.39058373,60.2505219 C9.39058373,32.2038337 32.2093277,9.38868856 60.2523446,9.38868856 Z"/> </svg> ); /* eslint-enable */ export default Magnifiner;
demo/components/datepicker/DateRangePickerDemo.js
f0zze/rosemary-ui
import React from 'react'; import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {DateRangePicker} from '../../../src'; import DemoWithSnippet from '../../layout/DemoWithSnippet'; import {updateDateFrom, updateDateTo,changePopupState} from '../../actions/date-picker-actions'; export class DateRangePickerDemo extends React.Component { constructor(props) { super(props); } handleRangeChange(value) { this.props.updateDateTo(value.to); this.props.updateDateFrom(value.from); } render() { return ( <div> <DemoWithSnippet> <DateRangePicker /> <h3>DRP can be controlled</h3> <DateRangePicker open={this.props.open} onPopupStateChange={(open) => this.props.changePopupState(open)} onChange={(value) => this.handleRangeChange(value)} value={this.props.value}/> </DemoWithSnippet> </div> ); } } const mapStateToProps = ({datePicker}) => ({ value: { from: datePicker.from, to: datePicker.to }, open: datePicker.open }); const mapDispatchToProps = (dispatch) => ( bindActionCreators({ updateDateFrom, updateDateTo, changePopupState }, dispatch) ); export default connect(mapStateToProps, mapDispatchToProps)(DateRangePickerDemo);
techCurriculum/ui/solutions/4.7/src/index.js
tadas412/EngineeringEssentials
/** * Copyright 2017 Goldman Sachs. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. **/ import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import '../stylesheet.css'; ReactDOM.render( <App />, document.getElementById('root') );
react-release/dominion-js/src/components/organisms/Organism.playSurface.js
ExplosiveHippo/Dominion.js
import React, { Component } from 'react'; import MoleculeTableCard from '../molecules/Molecule.tableCard'; import MoleculePlayerTracker from '../molecules/Molecule.playerTracker'; import '../../scss/App.scss'; export default class playSurface extends Component { constructor(props) { super(props); this.state = { actionCards: this.props.cards.actions, moneyCards: this.props.cards.money, victoryCards: this.props.cards.victory }; this.renderActionCards = this.renderActionCards.bind(this); this.renderMoneyCards = this.renderMoneyCards.bind(this); this.renderVictoryCards = this.renderVictoryCards.bind(this); } componentWillMount(){ // This is setup for the play surface, which starts with getting random action cards this.shuffleCards(); } shuffleCards(){ let actionCards = this.props.cards.actions; for (var i = actionCards.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = actionCards[i]; actionCards[i] = actionCards[j]; actionCards[j] = temp; } return actionCards; } renderActionCards(card, index){ // Dominion is played with only 10 table cards if(index <= 9){ return( <MoleculeTableCard cardData={card} handWorth={this.props.handWorth} key={index}/> ) } } renderMoneyCards(card, index){ return( <MoleculeTableCard cardData={card} handWorth={this.props.handWorth} key={index} /> ) } renderVictoryCards(card, index){ return( <MoleculeTableCard cardData={card} handWorth={this.props.handWorth} key={index} /> ) } renderPlayerTracker(){ return( <MoleculePlayerTracker handWorth={this.props.handWorth} /> ) } render() { return ( <div className="playSurface"> {this.props.cards.actions.map(this.renderActionCards)} {this.props.cards.money.map(this.renderMoneyCards)} {this.props.cards.victory.map(this.renderVictoryCards)} {this.renderPlayerTracker()} </div> ); } }
docs/app/Examples/views/Card/Variations/CardExampleColored.js
koenvg/Semantic-UI-React
import React from 'react' import { Card } from 'semantic-ui-react' const src = 'http://semantic-ui.com/images/wireframe/white-image.png' const CardExampleColored = () => ( <Card.Group itemsPerRow={4}> <Card color='red' image={src} /> <Card color='orange' image={src} /> <Card color='yellow' image={src} /> <Card color='olive' image={src} /> <Card color='green' image={src} /> <Card color='teal' image={src} /> <Card color='blue' image={src} /> <Card color='violet' image={src} /> <Card color='purple' image={src} /> <Card color='pink' image={src} /> <Card color='brown' image={src} /> <Card color='grey' image={src} /> </Card.Group> ) export default CardExampleColored
packages/material-ui-icons/src/BurstMode.js
AndriusBil/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from 'material-ui/SvgIcon'; let BurstMode = props => <SvgIcon {...props}> <path d="M1 5h2v14H1zm4 0h2v14H5zm17 0H10c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zM11 17l2.5-3.15L15.29 16l2.5-3.22L21 17H11z" /> </SvgIcon>; BurstMode = pure(BurstMode); BurstMode.muiName = 'SvgIcon'; export default BurstMode;
src/client/index.js
zebulonj/exygen
import PropTypes from 'prop-types'; import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter } from 'react-router-dom'; import { createStore, applyMiddleware } from 'redux'; import logger from 'redux-logger'; import thunk from 'redux-thunk'; import { Provider } from 'react-redux'; import { App } from '../app'; export const defaultMiddleware = [ logger, thunk ]; const defaultOptions = { middleware: defaultMiddleware }; export function initialState() { try { const state = document.getElementById( 'state' ); return state ? JSON.parse( state.innerHTML ) : {}; } catch ( err ) { console.error( "Failed to initialize state.", err ); return {}; } } export function client( options, callback ) { options = Object.assign( {}, defaultOptions, options ); const { Wrapper, routes, reducer, middleware } = options; const store = createStore( reducer, initialState(), applyMiddleware( ...middleware ) ); function mount() { ReactDOM.render( React.createElement( Root, { Wrapper, routes, store }), document.getElementById( 'content' ) ); } mount(); callback && callback( mount ); } export default client; export const Root = ({ Wrapper, routes, store }) => ( <BrowserRouter> <Provider store={ store }> <App Wrapper={ Wrapper } routes={ routes } /> </Provider> </BrowserRouter> ); Root.propTypes = { routes: PropTypes.array, store: PropTypes.any };
es2015plus/react/src/components/Input/index.js
lshig/forms-challenge
import React from 'react'; import PropTypes from 'prop-types'; export default function Input({ className, label, name, onClick, type, value }) { return ( <label className={`input ${className}`}> {label} <input name={name} onClick={onClick} type={type} value={value} /> <div className="input__choice" /> </label> ); } Input.propTypes = { className: PropTypes.string.isRequired, label: PropTypes.string.isRequired, name: PropTypes.string.isRequired, onClick: PropTypes.func.isRequired, type: PropTypes.string.isRequired, value: PropTypes.string.isRequired };
frontend/src/DiscoverMovie/Table/DiscoverMovieActionsCell.js
geogolem/Radarr
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; class DiscoverMovieActionsCell extends Component { // // Render render() { const { id, ...otherProps } = this.props; return ( <VirtualTableRowCell {...otherProps} > {/* <SpinnerIconButton name={icons.REFRESH} title="Refresh Movie" isSpinning={isRefreshingMovie} onPress={onRefreshMoviePress} /> <IconButton name={icons.EDIT} title="Edit Movie" onPress={this.onEditMoviePress} /> */} {/* <EditMovieModalConnector isOpen={isEditMovieModalOpen} movieId={id} onModalClose={this.onEditMovieModalClose} onDeleteMoviePress={this.onDeleteMoviePress} /> <DeleteMovieModal isOpen={isDeleteMovieModalOpen} movieId={id} onModalClose={this.onDeleteMovieModalClose} /> */} </VirtualTableRowCell> ); } } DiscoverMovieActionsCell.propTypes = { id: PropTypes.number.isRequired }; export default DiscoverMovieActionsCell;
source/app/app.js
Vuanjun/meep-toy
import React from 'react'; import House from './lib/container'; import 'normalize.css/normalize.css!'; import 'font-awesome/css/font-awesome.min.css!'; // import Sidebar from './lib/sidebar'; // import Meeptv Vfrom './lib/meeptv'; import RouterStore from 'meepworks/stores/router-store'; // import ChatStore from './stores/chat-store' const App = React.createClass({ render() { let Children = RouterStore.getChildComponent(App); if(Children) { return <Children />; } return <House />; } }); export default { component: App, routes: { '/': { name: 'home', title: 'House' }, '/sidebar': { name: 'sidebar', title: 'Sidebar', app: './lib/sidebar' }, '/meeptv': { name: 'meeptv', title: 'meeptv', app: './lib/meeptv' } } };